external/wireless-tools
Revisión | 9ec0f62f146639f364238cbb7821ca47222e3bb9 (tree) |
---|---|
Tiempo | 2016-10-12 06:13:40 |
Autor | chris-kirby <chris.kirby@hpe....> |
Commiter | chris-kirby |
v28
@@ -532,6 +532,99 @@ | ||
532 | 532 | * o Make sure gcc inline stuff properly [iwlib.h] |
533 | 533 | * o Update Hotplug documentation [HOTPLUG.txt] |
534 | 534 | * o Add support for new selector firmware [ifrename] |
535 | + * | |
536 | + * wireless 28 : | |
537 | + * ----------- | |
538 | + * o Fix gcc inline hack when using kernel headers [iwlib.h] | |
539 | + * (From Denis Ovsienko <pilot@altlinux.ru>) | |
540 | + * o Allow '-n' without '-i', even though inefficient [ifrename] | |
541 | + * (From Thomas Hood <jdthood@aglu.demon.nl>) | |
542 | + * o Fix technical and spelling errors in Hotplug doc [HOTPLUG.txt] | |
543 | + * --- | |
544 | + * o Include wireless.h as a local file, not a system file [iwlib.h] | |
545 | + * o Split install targets [Makefile] | |
546 | + * (Suggested by Jost Diederichs <jost@qdusa.com>) | |
547 | + * o Increase scanning timeout for MadWifi [iwlib/iwlist] | |
548 | + * (Suggested by Ned Ludd <solar@gentoo.org>) | |
549 | + * o Multicall version of the tools for embedded [iwmulticall] | |
550 | + * --- | |
551 | + * o Fix some install Makefile targets broken in pre2 [Makefile] | |
552 | + * --- | |
553 | + * o Add option for stripping symbols on tools [Makefile] | |
554 | + * o Add escaping of essid keyworks with -- in manpage [iwconfig.8] | |
555 | + * o Update sensitivity description [iwconfig.8] | |
556 | + * o Fix iw_print_timeval() for timezone [iwlib/iwevent] | |
557 | + * (Suggested by Jan Minar <jjminar@FastMail.FM>) | |
558 | + * o Escape interface name for --help/--version with -- [iwconfig] | |
559 | + * o Allow --help/--version to be interface names [iwlist] | |
560 | + * (From Martynas Dubauskis <martynas@gemtek.lt>) | |
561 | + * o Fix invalid sizeof for stat memcpy in easy scanning API [iwlib.c] | |
562 | + * (From Andreas Mohr <andi@rhlx01.fht-esslingen.de>) | |
563 | + * o Fix my horrendous spelling [HOTPLUG.txt/PCMCIA.txt/README/*.8] | |
564 | + * --- | |
565 | + * o Make static lib use PIC objects [Makefile] | |
566 | + * o Add SYSFS selector support to ifrename [ifrename] | |
567 | + * o Fix a fd leak in pcmciaslot selector [ifrename] | |
568 | + * o Don't complain about eth0/wlan0 if takeover enabled [ifrename] | |
569 | + * o Update man pages for sysfs and eth0/wlan0 [ifrename.8] | |
570 | + * o Update man pages for frequ auto/off [iwconfig.8] | |
571 | + * o More clever manual loading and docking tricks [HOTPLUG.txt] | |
572 | + * (From Pavel Heimlich tropikhajma@seznam.cz) | |
573 | + * o Czech (cs) man pages [cs/*] | |
574 | + * --- | |
575 | + * o Fudge patch below for better integration [iwconfig/iwevent/iwlist] | |
576 | + * (From Jouni Malinen <jkmaline@cc.hut.fi>) | |
577 | + * o WE-18/WPA event display [iwevent] | |
578 | + * o WE-18/WPA parameter display [iwconfig] | |
579 | + * --- | |
580 | + * o Replace iw_pr_ether() with iw_saether_ntop() [iwlib] | |
581 | + * o Replace iw_in_ether() with iw_saether_aton() [iwlib] | |
582 | + * o Remove iw_get_mac_addr() -> unused and bad API [iwlib] | |
583 | + * o Add iw_mac_ntop() and iw_mac_aton() for any-len mac addr [iwlib] | |
584 | + * o Slim down iw_ether_aton() using iw_mac_ntop() [iwlib] | |
585 | + * o Slim down iw_in_key(), avoid memcpy [iwlib] | |
586 | + * o Add support for any-len mac addr selector [ifrename] | |
587 | + * --- | |
588 | + * o Re-add temp output buffer in iw_in_key() to avoid corruptions [iwlib] | |
589 | + * --- | |
590 | + * o Add WE-19 headers, compile with that as default | |
591 | + * o IW_EV_POINT_LEN has shrunk, so invert IW_EV_POINT_OFF fixup [iwlib] | |
592 | + * o Remove WE backward compat from iwlib.h header [iwlib] | |
593 | + * o Add support for IW_QUAL_DBM in iw_print_stats() [iwlib] | |
594 | + * o Add support for ARPHRD_IEEE80211 in iw_check_mac_addr_type() [iwlib] | |
595 | + * -> iwspy work on wifi0 netdev from airo.c | |
596 | + * --- | |
597 | + * o Set flags to 0 before asking old power settings for 'on' [iwconfig] | |
598 | + * (Suggested by Denis Ovsienko <pilot@altlinux.ru>) | |
599 | + * o Ignore empty lines in iface enumeration iw_enum_devices() [iwlib] | |
600 | + * (From Pavel Roskin <proski@gnu.org>) | |
601 | + * o Fix invalid buffer size in 'iwlist power' [iwlist] | |
602 | + * (Suggested by Francesco Potorti` <pot@gnu.org>) | |
603 | + * o Remove kernel headers, use glibc headers [iwlib] | |
604 | + * --- | |
605 | + * o Show explicit state for SIOCSIWAP, not numbers [iwconfig/iwevent] | |
606 | + * o Add WE-18 ioctls to the stream parser in standard_ioctl_hdr [iwlib] | |
607 | + * (From Chris Hessing <Chris.Hessing@utah.edu>) | |
608 | + * o Add GENIE parsing support in scan resuls [iwlist] | |
609 | + * --- | |
610 | + * o Change iw_extract_event_stream() API to add value index [iwlib] | |
611 | + * o Scan : display bitrate values on a single line [iwlist] | |
612 | + * --- | |
613 | + * o Revert to previous iw_extract_event_stream() API, debloat [iwlib] | |
614 | + * o Keep track of value index in [iwlist] | |
615 | + * --- | |
616 | + * o Check event stream 'point' payload size to avoid overflow [iwlib] | |
617 | + * o Make all users of event stream 'point' safe to NULL [iwlist/iwevent] | |
618 | + * o 'iwconfig txpower 1dBm' should not be 'mW' [iwconfig] | |
619 | + * o Forward compat. to WE-21 : essid len is strlen, not +1 [iwconfig] | |
620 | + * --- | |
621 | + * o Forgot one place where essid len was strlen+1 [iwlib] | |
622 | + * o Update definition of 'ap' and 'sens' to reflect reality [man] | |
623 | + * --- | |
624 | + * o Introduce WE_MAX_VERSION to take into account forward compat [iwlib] | |
625 | + * o Add WE-20 headers, compile with that as default | |
626 | + * --- | |
627 | + * o Fix 'inline' for gcc-4 as well. Grrr... [iwlib] | |
535 | 628 | */ |
536 | 629 | |
537 | 630 | /* ----------------------------- TODO ----------------------------- */ |
@@ -559,13 +652,8 @@ | ||
559 | 652 | * ifrename : |
560 | 653 | * -------- |
561 | 654 | * Link Type should use readable form instead of numeric value |
562 | - * Support non MAC/Eth addresses ? | |
563 | 655 | * |
564 | 656 | * Doc & man pages : |
565 | 657 | * --------------- |
566 | 658 | * Update main doc. |
567 | - * | |
568 | - * Other : | |
569 | - * ----- | |
570 | - * What about some graphical tools ? | |
571 | 659 | */ |
@@ -1,20 +1,19 @@ | ||
1 | - Sane Hotplug network interface management | |
2 | - ----------------------------------------- | |
1 | + Sane network interface management with Hotplug | |
2 | + ---------------------------------------------- | |
3 | 3 | |
4 | 4 | INTRODUCTION |
5 | 5 | ------------ |
6 | - In the old day, all Wireless cards were managed by the | |
6 | + In the old days all wireless cards were managed by the | |
7 | 7 | excellent Pcmcia subsystem and its rich configuration scripts, and |
8 | -life was happy. Then came the wireless PCI cards, then the wireless | |
8 | +life was good. Then came the wireless PCI cards, then the wireless | |
9 | 9 | USB dongles. Some unification was needed, and rather than adapt the |
10 | 10 | Pcmcia subsystem for PCI and USB, it was decided to create the much |
11 | -simpler Hotplug systems. | |
12 | - The USB subsystem already use Hotplug, and the Pcmcia | |
13 | -subsystem is migrating to it, CardBus cards (32 bits) already use | |
14 | -Hotplug, whereas Pcmcia cards (16 bits) still use the old Pcmcia | |
15 | -scripts. | |
16 | - The Hotplug system is still in its infancy, but already show | |
17 | -some good promises. Most users are disapointed at first by its | |
11 | +simpler Hotplug system. | |
12 | + The USB subsystem already uses Hotplug. The Pcmcia subsystem | |
13 | +is migrating to it : CardBus cards (32 bits) already use Hotplug, | |
14 | +whereas Pcmcia cards (16 bits) still use the old Pcmcia scripts. | |
15 | + The Hotplug system is still in its infancy, but already shows | |
16 | +some good promise. Most users are disappointed at first by its | |
18 | 17 | apparent lack of features compared to the Pcmcia scripts. In this |
19 | 18 | document, we will show how to fully exploit the Hotplug system and try |
20 | 19 | 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 | ||
27 | 26 | newbies. You should have read and understood DISTRIBUTIONS.txt. The |
28 | 27 | procedures described here are more advanced than the simple |
29 | 28 | configuration described in DISTRIBUTIONS.txt. |
30 | - The main focus is of course removable wireless interfaces, but | |
31 | -we will try to keep things generic and talk of the whole network | |
32 | -interface management, so this should apply also to built-in Ethernet | |
33 | -cards. | |
29 | + The main focus is of course on removable wireless interfaces, | |
30 | +but we will to talk about network interface management in general, so | |
31 | +this should apply also to built-in Ethernet cards. | |
34 | 32 | |
35 | 33 | PROBLEM STATEMENT |
36 | 34 | ----------------- |
37 | - Let assume a Linux system and two or more network devices, | |
35 | + Let's assume a Linux system and two or more network devices, | |
38 | 36 | Device A and Device B. Those devices may be built-in or removable, |
39 | -they may be present or absent from the system at any time, and | |
40 | -activated in any particular order. | |
37 | +they may be present or absent from the system at any time, and they | |
38 | +may activated in any particular order. | |
41 | 39 | The user wants to assign Configuration A to Device A and |
42 | -Configuration B to Device B, without the possibility that Device A get | |
43 | -assigned Configuration B. | |
44 | - Different users may have different definition of what is | |
40 | +Configuration B to Device B, without the possibility that Device A | |
41 | +gets assigned Configuration B. | |
42 | + Different users may have different definitions of what is | |
45 | 43 | Device A. For some, it's a specific instance of a specific hardware, |
46 | -for others any hardware that meet some criteria (a wireless card, an | |
44 | +for others any hardware that meets some criteria (a wireless card, an | |
47 | 45 | Ethernet card). |
48 | - The user may also want to have multiple configurations | |
49 | -depending on various factors (like the old Pcmcia schemes). Device A | |
50 | -may get Configuration A1 or Configuration A2 depending on those | |
51 | -factors. | |
52 | - By default, all network interfaces are created using a default | |
53 | -interface name (starting at "eth0" and going up). I call that problem | |
54 | -"all my cards are eth0". And by default, "eth0" point to a single | |
55 | -fixed configuration in the configuration database. Clearly, this won't | |
56 | -satisfy our requirements. | |
46 | + The user may also want to have multiple configurations for a | |
47 | +given device such that the chosen configuration depends on various | |
48 | +factors, just as with the old Pcmcia schemes. Device A may need | |
49 | +Configuration A1 or Configuration A2 depending on those factors. | |
50 | + By default, all network interfaces are created using default | |
51 | +interface names (starting at "eth0" and going up). I call that the | |
52 | +"all my cards are eth0" problem : im most distributions, "eth0" points | |
53 | +to a single fixed configuration in the configuration | |
54 | +database. Clearly, this won't satisfy our requirements. | |
57 | 55 | |
58 | 56 | EXAMPLE SYSTEM |
59 | 57 | -------------- |
60 | - The distribution I use is Debian 3.0, and some parts will be | |
61 | -specific to it. However, it should be easy to translate to other | |
62 | -distributions and I welcome additions to this document. | |
58 | + The distribution I use is Debian 3.0, and some parts of what I | |
59 | +say here will be specific to it. However, it should be easy to | |
60 | +translate this material to other distributions and I welcome additions | |
61 | +to this document. | |
63 | 62 | |
64 | 63 | The example system is as follows : |
65 | 64 | o Linux 2.6.X SMP kernel with hotplug support |
@@ -73,26 +72,26 @@ distributions and I welcome additions to this document. | ||
73 | 72 | o Pcmcia 802.11 card : Lucent Orinoco (orinoco_cs - eth0) |
74 | 73 | o CardBus 802.11 card : SMC 2835W (prism54 - prism0) |
75 | 74 | |
76 | - This system just happen to be my Linux development box, and | |
77 | -has enough interfaces to make it interesting. All the example I quote | |
78 | -in this document are extracted from this fully working system. | |
75 | + This system just happens to be my Linux development box. It | |
76 | +has enough interfaces to make it interesting. All the examples I | |
77 | +present in this document are extracted from this system. | |
79 | 78 | |
80 | 79 | BASIC CONCEPTS |
81 | 80 | -------------- |
82 | 81 | Most of the concept and tricks presented here are not really |
83 | -new, the main contribution is to integrate them together and make them | |
84 | -work. | |
82 | +new. The main contribution is to integrate them. | |
85 | 83 | |
86 | 84 | 1) Removable network interfaces are managed by Hotplug |
87 | 85 | (Pcmcia, CardBus, USB...). We can't assume that those interfaces are |
88 | 86 | always present in this system and available at boot time (Pcmcia cards |
89 | -are not made to be soldered in the Pcmcia slot), therefore Hotplug is | |
90 | -the only way to go. | |
87 | +were not made to be soldered in the Pcmcia slot). Therefore Hotplug is | |
88 | +the way to go. | |
91 | 89 | 2) Built-in PCI and ISA cards are managed by the init scripts, |
92 | -like they have always been. The ISA subsystem will never have Hotplug | |
90 | +as they have always been. The ISA subsystem will never have Hotplug | |
93 | 91 | support, and hotplug is not necessary for PCI cards. |
94 | 92 | 3) Built-in devices that are disable most of the time should |
95 | -be enabled manually. | |
93 | +be enabled manually by the user. Therefore both Hotplug and the init | |
94 | +scripts should ignore those devices by default. | |
96 | 95 | 4) (1), (2) and (3) must be compatible on the same system and |
97 | 96 | play nice with each other. |
98 | 97 |
@@ -101,72 +100,74 @@ assigned to each network hardware interface using 'ifrename'. Device A | ||
101 | 100 | is always named 'ethA' (or whatever name you like such as |
102 | 101 | 'mynetworkcard'). |
103 | 102 | 6) No interface is called 'eth0' (or 'wlan0'). Any unknown |
104 | -device would be 'eth0', thefore known device should avoid using it | |
105 | -because it might be already taken. | |
103 | +device would be 'eth0', so known devices should be called something | |
104 | +else. | |
106 | 105 | 7) Multiple configurations for a single interface (schemes) |
107 | 106 | are managed by the ifup/ifdown subsystem. |
108 | 107 | |
109 | 108 | CONFIGURATION FROM INIT SCRIPTS |
110 | 109 | ------------------------------- |
111 | - It may seems paradoxal, but before setting up Hotplug, we need | |
112 | -to make sure that the initialisation of network cards via init | |
113 | -scripts is done properly and doesn't get in our way. | |
110 | + It may seem paradoxical, but before setting up Hotplug, we | |
111 | +need to make sure that the initialisation of network cards via init | |
112 | +scripts is done properly and doesn't get in the way of the Hotplug | |
113 | +subsystem. | |
114 | 114 | The configuration of network cards via init scripts is the |
115 | -traditional way network is initialised in Linux. The advantage of this | |
116 | -method is that it's very well documented and understood, and has not | |
117 | -changed much over the years. Unfortunately, it doesn't support | |
118 | -properly removable cards. | |
119 | - The init scripts perform the following 3 functions in that | |
120 | -order : | |
121 | - 1) load necessary driver modules | |
122 | - 2) rename interface to name chosen by the user | |
123 | - 3) configure those interfaces | |
115 | +traditional way networking is initialised in Linux. The advantage of | |
116 | +this method is that it's very well documented and understood, and has | |
117 | +not changed much over the years. Unfortunately, it doesn't adequately | |
118 | +support removable cards. | |
119 | + | |
120 | + The init scripts perform the following 3 functions in order : | |
121 | + 1) Load necessary driver modules | |
122 | + 2) Rename interface to name chosen by the user | |
123 | + 3) Configure those network interfaces | |
124 | 124 | |
125 | 125 | 1) Applicability |
126 | 126 | ---------------- |
127 | 127 | Configuration from init scripts is applicable to any built-in |
128 | -network interface (ISA, PCI...), i.e. interfaces availalble at boot | |
128 | +network interface (ISA, PCI...), i.e., interfaces available at boot | |
129 | 129 | time and that will never be removed from the system. |
130 | - The Hotplug subsystem has also the ability to configure some | |
130 | + The Hotplug subsystem also has the ability to configure some | |
131 | 131 | of the built-in network interfaces, such as PCI cards. However, there |
132 | 132 | is a class of devices that will never have Hotplug support, such as |
133 | -ISA and EISA cards, and for those Hotplug won't work. | |
134 | - The advantage of using the init script method is that you are | |
135 | -probably already familiar with it and you have the ability to select | |
136 | -which interfaces should be configured at boot and which interface | |
137 | -should only be enabled manually (whereas Hotplug just configures | |
138 | -everything). | |
133 | +ISA and EISA cards. | |
139 | 134 | |
140 | 135 | 2) Loading driver modules (if/as needed) |
141 | 136 | ---------------------------------------- |
142 | 137 | Most distributions build the kernel drivers as modules. This |
143 | -modular setup allow to minimise the amount of memory used by the | |
138 | +modular setup allows to minimise the amount of memory used by the | |
144 | 139 | system and the flexible loading/unloading of drivers. |
145 | 140 | You can also compile your kernel with static drivers |
146 | 141 | (non-modular). In that case, the driver will always be available in |
147 | -your kernel, you don't need to configure the module subsystem, so you | |
142 | +the kernel, you don't need to configure the module subsystem, so you | |
148 | 143 | can skip directly to the next section. |
149 | 144 | |
150 | 145 | There are 3 alternatives to manage device drivers as |
151 | -modules. Some distribution have explicit list of modules that are | |
152 | -loaded at boot time, if you want to use that feature you need to check | |
153 | -your distribution. Some system, such as hotplug or kudzu, can scan the | |
154 | -various buses of the PC and load the appropriate drivers, and this is | |
155 | -mostly configuration-free, but may not support all devices. The module | |
156 | -subsystem also allow to load modules 'on-demand'. | |
146 | +modules. | |
147 | + 1) Some distributions have an explicit list of modules | |
148 | +that are loaded at boot time. If you want to use that feature you need | |
149 | +to check the documentation of your distribution. | |
150 | + 2) Some system, such as Hotplug, Discover or Kudzu, | |
151 | +can scan the various buses of the PC and load the appropriate | |
152 | +drivers. This is mostly configuration-free, but may not support all | |
153 | +devices and may load unnecessary modules. | |
154 | + 3) The module subsystem also allows to load modules | |
155 | +'on-demand'. When an application try to access or configure a network | |
156 | +interface, the corresponding module is loaded. | |
157 | 157 | |
158 | 158 | I personally prefer to use the 'on-demand' feature of the |
159 | -module subsystem has, as it allows you to not have to specify the list | |
160 | -of modules that need to be loaded, and only modules really necessary | |
161 | -are loaded which save kernel memory. You can also choose which module | |
162 | -to load when there are multiple altenate modules valid for your | |
159 | +module subsystem, as this allow you to not have to specify a static | |
160 | +list of modules that need to be loaded, and only modules really needed | |
161 | +are loaded which saves kernel memory. You can also choose which module | |
162 | +to load when there are multiple modules available that support your | |
163 | 163 | hardware (which happens quite often). |
164 | 164 | |
165 | - With kernel 2.6.X, the module subsystem is configured in | |
166 | -/etc/modprobe.conf. To configure 'on-demand' module loading, I need to | |
167 | -add to this file the following lines : | |
165 | + With kernel 2.6.X the module subsystem is configured in the | |
166 | +file /etc/modprobe.conf or files in the directory /etc/modprobe.d/. To | |
167 | +configure 'on-demand' module loading, on my test system I need to add | |
168 | +to the following lines to the configuration : | |
168 | 169 | |
169 | ---------- /etc/modprobe.conf ---------------- | |
170 | +--------- /etc/modprobe.d/local or /etc/modprobe.conf ------ | |
170 | 171 | # HP 100VG J2585B PCI card |
171 | 172 | alias eth2 hp100 |
172 | 173 |
@@ -176,32 +177,32 @@ alias eth4 pcnet32 | ||
176 | 177 | # Old AT&T Wavelan ISA card |
177 | 178 | alias eth3 wavelan |
178 | 179 | options wavelan io=0x390 irq=15 |
179 | ---------------------------------------------- | |
180 | +------------------------------------------------------------ | |
180 | 181 | |
181 | 182 | Your distribution may already have lines for your interfaces, |
182 | -either replace them or make sure they are correct (some distro are | |
183 | -notorious for picking the wrong driver name). This file also contains | |
184 | -configuration for lot of other subsystems, obviously you don't want to | |
185 | -touch that. | |
183 | +either replace these or make sure they are correct (some distributions | |
184 | +are notorious for picking the wrong driver name in some cases). This | |
185 | +file also contains configuration for lot of other subsystems, | |
186 | +obviously you don't want to touch that. | |
186 | 187 | In this file, you put the name you would like the interface to |
187 | -have (we'll fix that in a minute). You note that for modern PCI cards, | |
188 | -this is much more straightforward than for old ISA cards. | |
188 | +have (we'll fix that in a minute). Note that for modern PCI cards this | |
189 | +is much more straightforward than for old ISA cards. | |
189 | 190 | |
190 | 191 | 3) Installing 'ifrename' |
191 | 192 | ------------------------ |
192 | 193 | You will need to install ifrename on your system. 'ifrename' |
193 | 194 | is part of the Wireless Tools package (version 27 and later) and is a |
194 | 195 | complete rewrite of the now obsolete 'nameif'. |
195 | - Some distributions, such as Debian Sarge, offer a specific | |
196 | + Some distributions, such as Debian Sarge, offer a separate | |
196 | 197 | package for 'ifrename', and in this case you should just install this |
197 | 198 | package. Other distributions may include ifrename as part of their |
198 | -'wireless tools' package (this should be the case for Geentoo and | |
199 | -Mandrake). Other distributions, such as Debian 3.0, don't include | |
200 | -ifrename at all, and you should compile yourself a recent version of | |
199 | +'wireless-tools' package (this should be the case for Gentoo, Fedora | |
200 | +and Mandrake). Other distributions, such as Debian 3.0, don't include | |
201 | +ifrename at all, so you should compile yourself a recent version of | |
201 | 202 | Wireless Tools (v27 or later) and install it. |
202 | 203 | |
203 | - In any case, you should verify if 'ifrename' is properly | |
204 | -installed, and what is the path to call it. | |
204 | + In any case, you should verify that 'ifrename' is properly | |
205 | +installed and check the path needed to call it : | |
205 | 206 | -------------------------- |
206 | 207 | > which ifrename |
207 | 208 | /sbin/ifrename |
@@ -213,12 +214,14 @@ you compile your own wireless tools, it will be in '/usr/local/sbin'. | ||
213 | 214 | ------------------------------------------ |
214 | 215 | You need to make sure 'ifrename' is run at boot time. Most |
215 | 216 | distributions don't do that yet by default. |
216 | - This is a part that is distribution specific, so you will need | |
217 | -to look into your init files. It will need to run just before the call | |
218 | -to 'ifup' or 'ifconfig' command. | |
217 | + This is a part that is distribution-specific, so you will need | |
218 | +to look into your own init files, or ask people familiar with your | |
219 | +distribution. It will need to run just before the call to 'ifup' or | |
220 | +'ifconfig' command. | |
219 | 221 | |
220 | - In Debian 3.0, it needs to be run from /etc/init.d/networking, | |
221 | -which is not the default. The necessary patch is below : | |
222 | + In Debian 3.0 and Debian Sarge, it needs to be run from | |
223 | +/etc/init.d/networking, which is not the default. The necessary patch | |
224 | +is below : | |
222 | 225 | |
223 | 226 | ---------------------------------------------------------------- |
224 | 227 | --- networking-orig Wed Feb 18 13:56:23 2004 |
@@ -240,13 +243,13 @@ which is not the default. The necessary patch is below : | ||
240 | 243 | ifup -a |
241 | 244 | echo "done." |
242 | 245 | ---------------------------------------------------------------- |
243 | - Don't forget to set the appropriate path to call ifrename (see | |
244 | -step (3) above). | |
246 | + Don't forget to set the appropriate path to the ifrename | |
247 | +command (see step (3) above). | |
245 | 248 | |
246 | - You may want to also set the proper options for ifrename | |
249 | + You may also want to also set the proper options for ifrename | |
247 | 250 | (check the man page). |
248 | - The option '-p' enable module autoloading compatibility. | |
249 | - The default version of 'ifrename' also includes some specific | |
251 | + The option '-p' enables module autoloading compatibility. | |
252 | + The default version of 'ifrename' also includes some special | |
250 | 253 | Debian support : using "ifrename -p -d", only the proper modules are |
251 | 254 | loaded. If you are using Debian, you should use this option. |
252 | 255 |
@@ -255,14 +258,15 @@ loaded. If you are using Debian, you should use this option. | ||
255 | 258 | As stated above, we use 'ifrename' to assign names to |
256 | 259 | interfaces. |
257 | 260 | |
258 | - First, you need to get the MAC address of each of you | |
259 | -interface. You can read it on the label on the card or display it | |
260 | -using the 'ifconfig' command. Remember that the interface won't load | |
261 | -yet with the proper name, so you may need to do a bit looking around : | |
261 | + First, you need to get the MAC address of each of your | |
262 | +interfaces. You can read the MAC address on the label of the card, or | |
263 | +display it using the 'ifconfig -a' command. Remember that the | |
264 | +interface won't load yet with the proper name, so you may need to do a | |
265 | +bit looking around : | |
262 | 266 | |
263 | 267 | ----------------------------- |
264 | -> modprobe pcnet32 | |
265 | -> ifconfig eth0 | |
268 | +# modprobe pcnet32 | |
269 | +# ifconfig eth0 | |
266 | 270 | eth0 Link encap:Ethernet HWaddr 00:10:83:34:BA:E5 |
267 | 271 | [...] |
268 | 272 | ----------------------------- |
@@ -282,33 +286,33 @@ eth3 mac 08:00:0E:* | ||
282 | 286 | eth4 mac 00:10:83:* |
283 | 287 | --------------------------------------------- |
284 | 288 | |
285 | - The '*' in the MAC address is a wildcard and allow me to | |
289 | + The '*' in the MAC address is a wildcard and allows me to | |
286 | 290 | replicate my configuration between multiple identical computers. If |
287 | -you have to manage large number of computers (like a rack of server or | |
288 | -clusters), you may want to look at other selectors offered by | |
289 | -'ifrename', such as the ability to base interface name on Bus | |
290 | -Information. | |
291 | +you have to manage large number of computers (like a rack of servers | |
292 | +or clusters), then you may want to look at other selectors offered by | |
293 | +'ifrename'. | |
291 | 294 | |
292 | 295 | To test that ifrename works, do the following : |
293 | - o load all your drivers, see section (2) | |
294 | - o check /proc/net/dev to see which interface exist | |
295 | - o bring all interfaces down : ifconfig ethX down | |
296 | - o run ifrename | |
297 | - o check each interface with ifconfig | |
296 | + o Load all your drivers, see section (2) | |
297 | + o Check /proc/net/dev to see which interface exist | |
298 | + o Bring all interfaces down : ifconfig ethX down | |
299 | + o Run ifrename | |
300 | + o Check each interface with ifconfig | |
301 | + o Bring all interfaces up : ifconfig ethX up | |
298 | 302 | |
299 | 303 | 6) Configuring interfaces |
300 | 304 | ------------------------- |
301 | 305 | Most likely, your distribution is already doing this part |
302 | 306 | properly. Just assign the proper IP and wireless configuration to each |
303 | -of the interface name you have chosen. | |
307 | +of the interface names you have chosen. | |
304 | 308 | This part is distribution specific, and I already document it |
305 | 309 | in the file DISTRIBUTIONS.txt. |
306 | 310 | |
307 | 311 | In Debian, you would need to modify the file |
308 | -/etc/network/interfaces like this : | |
312 | +/etc/network/interfaces so that it looks something like this : | |
309 | 313 | |
310 | 314 | --------- /etc/network/interfaces ----------- |
311 | -# AMD AMD PCnet LANCE PCI card | |
315 | +# AMD PCnet LANCE PCI card | |
312 | 316 | auto eth4 |
313 | 317 | iface eth4 inet dhcp |
314 | 318 |
@@ -316,23 +320,22 @@ iface eth4 inet dhcp | ||
316 | 320 | auto eth2 |
317 | 321 | iface eth2 inet static |
318 | 322 | address 10.0.0.2 |
319 | - network 10.0.0.0 | |
320 | 323 | netmask 255.255.255.0 |
321 | 324 | broadcast 10.0.0.255 |
322 | 325 | gateway 10.0.0.1 |
323 | 326 | --------------------------------------------- |
324 | 327 | |
325 | 328 | This was the last part. Now, at your next boot, all your |
326 | -interfaces should be assigned the proper name and proper | |
329 | +interfaces should be assigned the proper name and the proper | |
327 | 330 | configuration. |
328 | 331 | |
329 | 332 | CONFIGURATION VIA HOTPLUG |
330 | 333 | ------------------------- |
331 | - Dealing with removable interfaces is similar to built-in | |
332 | -interfaces, the only difference is that we will use the Hotplug | |
333 | -scripts instead of the init scripts. Another difference is that it | |
334 | -will require more work on your part because most distributions are not | |
335 | -fully ready for it. | |
334 | + Dealing with removable interfaces is similar to dealing with | |
335 | +built-in interfaces, the main difference is that we will use the | |
336 | +Hotplug scripts instead of the init scripts. Another difference is | |
337 | +that it will likely require more work on your part because most | |
338 | +distributions are not fully ready for it. | |
336 | 339 | |
337 | 340 | 1) Applicability |
338 | 341 | ---------------- |
@@ -349,8 +352,8 @@ interfaces, although it may not be the best choice for them. | ||
349 | 352 | -------------------- |
350 | 353 | Conceptually, Hotplug is very simple. When something |
351 | 354 | interesting happens, the Linux kernel generates an Hotplug event. This |
352 | -run the proper script from the /etc/hotplug directory. | |
353 | - There is 3 types of Hotplug events we care about : | |
355 | +runs the proper script from the /etc/hotplug directory. | |
356 | + There are 3 types of Hotplug events we care about : | |
354 | 357 | o PCI event : a CardBus device is added or removed |
355 | 358 | from the system. The script /etc/hotplug/pci.agent is run. |
356 | 359 | 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. | ||
362 | 365 | following happens : |
363 | 366 | 1) Kernel detects new CardBus device |
364 | 367 | 2) Kernel generates PCI Hotplug event |
365 | - 3) /etc/hotplug/pci.agent runs, find proper driver module | |
368 | + 3) /etc/hotplug/pci.agent runs, finds proper driver module | |
366 | 369 | 4) /etc/hotplug/pci.agent loads driver module |
367 | 370 | 5) Driver module initialises, creates new network device |
368 | 371 | 6) Kernel detects new network device |
369 | 372 | 7) Kernel generates Network Hotplug event |
370 | - 8) /etc/hotplug/net.agent runs, configure network device | |
373 | + 8) /etc/hotplug/net.agent runs, configures network device | |
371 | 374 | The sequence of events is similar for removals and USB devices. |
372 | 375 | |
373 | - 3) Make ifup reentrant | |
374 | - ---------------------- | |
376 | + 3) Make sure ifup does not deadlock | |
377 | + ----------------------------------- | |
375 | 378 | <Most people should ignore this part> |
376 | 379 | The first problem is that we need to make sure the command |
377 | -'ifup' is fully reentrant. If the system has built-in interfaces, the | |
378 | -'ifup' may reenter itself at boot time : | |
380 | +'ifup' does not deadlock by calling itself re-entrantly. If the system | |
381 | +has built-in interfaces, the 'ifup' may reenter itself at boot time | |
382 | +via Hotplug : | |
379 | 383 | 1) Init scripts start running |
380 | - 2) Init script calls 'ifup -a' to initialise built-in network | |
381 | - interfaces | |
384 | + 2) Init script calls 'ifup -a' to initialise built-in | |
385 | + network interfaces | |
382 | 386 | 3) 'ifup' auto-loads driver module for built-in network |
383 | 387 | interface 'eth4' |
384 | 388 | 4) Driver module initialises, creates new network device |
385 | 389 | 5) Kernel generates Network hotplug event |
386 | 390 | 6) /etc/hotplug/net.agent runs, call 'ifup eth4' |
387 | - You can produce the same reentrancy if want to manually load | |
388 | -module with the ifup command. | |
391 | + Note that you can produce the same reentrancy if you call ifup | |
392 | +manually on an interface which module is not yet loaded. | |
389 | 393 | |
390 | - The default version of 'ifup' for Debian 3.0 is not reentrant and | |
391 | -may deadlock during boot or if you use it manually. The patch to make | |
392 | -'ifup' properly reentrant is available here : | |
394 | + The default version of 'ifup' for Debian 3.0 and Debian Sarge | |
395 | +is not reentrant and can therefore deadlock if not used properly. The | |
396 | +patch to make 'ifup' properly reentrant is available here : | |
393 | 397 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231197 |
394 | - Later version of Debian (Sarge and later) have some workaround | |
395 | -that prevent deadlock in most case (but not fully eliminate them), so | |
396 | -for normal use the default 'ifup' should work fine. | |
398 | + Contemporary versions of Debian (Sarge and later) have a | |
399 | +net.agent script that contains workarounds to prevents deadlock | |
400 | +situations, so for normal use the default 'ifup' should work fine. | |
397 | 401 | |
398 | - Other distributions have very different version of ifup, and I | |
399 | -have not tried those (tell me about it). | |
402 | + Other distributions have very different ifup programs and I | |
403 | +have not tried those (tell me about it !). | |
400 | 404 | |
401 | 405 | 4) Installing Hotplug for Debian Sarge (testing/unstable) |
402 | 406 | --------------------------------------------------------- |
@@ -408,41 +412,53 @@ of the box'. | ||
408 | 412 | o ifrename |
409 | 413 | |
410 | 414 | While the installation of Hotplug is simple, its configuration |
411 | -may seem complex. The current network Hotplug script has 3 modes, | |
412 | -'all', 'auto' and 'hotplug', however for our purpose they all produce | |
413 | -the same results when configured. This is controlled by the variable | |
414 | -NET_AGENT_POLICY in /etc/default/hotplug. | |
415 | - | |
416 | - In the mode "all", all interfaces are processed by | |
417 | -'ifup'. This will work without further configuration. | |
418 | - | |
419 | - In the mode "auto", only interfaces listed in a auto statement | |
420 | -in /etc/network/interfaces will be processed by 'ifup'. If you choose | |
421 | -this mode, you need to put in /etc/network/interfaces a statement auto | |
422 | -with the complete list of all interfaces. | |
415 | +may seem complex. The current network Hotplug script has 3 modes : | |
416 | +'all', 'auto' and 'hotplug'. However for our purpose they all produce | |
417 | +the same results when configured. This mode is controlled by the | |
418 | +variable NET_AGENT_POLICY in /etc/default/hotplug. | |
419 | + | |
420 | + In the mode "all", Hotplug will run ifup for all network | |
421 | +events. This will result in failure messages if some interfaces have | |
422 | +already been configured by the init scripts. This mode is not | |
423 | +recommended. | |
424 | + | |
425 | + In the mode "auto", Hotplug will run ifup only for those | |
426 | +interfaces listed in a auto stanza in /etc/network/interfaces. If | |
427 | +you choose this mode, you need to put in /etc/network/interfaces a | |
428 | +"auto" line for the interfaces you want to control with hotplug. | |
423 | 429 | --------- /etc/network/interfaces ----------- |
424 | 430 | # Enable Hotplug support for "auto" mode (Sarge and later) |
425 | 431 | auto eth0 eth1 eth2 eth3 eth4 wlan0 wlan1 prism0 prism1 airo0 airo1 |
426 | 432 | --------------------------------------------- |
427 | - Unfortunately, this will make 'ifup' complain at boot time | |
428 | -that it can't find those interfaces. This is why I don't recommend | |
429 | -this mode. | |
433 | + This will result in some failure message at boot time, the | |
434 | +init script will attempt to enable all those interfaces, and generate | |
435 | +an error for all those not available at this time. It will also | |
436 | +generate an error messages for interface which have already been | |
437 | +configured by the init scripts. This mode is also not recommended. | |
430 | 438 | |
431 | 439 | In the mode "hotplug", hotplug network events are ignored by |
432 | -ifup by default. To enable them, therefore making this mode equal to | |
433 | -"all", you will need to add the following lines to | |
434 | -/etc/network/interfaces : | |
440 | +ifup by default. To enable them you will need to add the following | |
441 | +lines to /etc/network/interfaces : | |
435 | 442 | --------- /etc/network/interfaces ----------- |
436 | 443 | # Enable Hotplug support for "hotplug" mode (Sarge and later) |
437 | 444 | mapping hotplug |
438 | 445 | script echo |
439 | 446 | --------------------------------------------- |
440 | 447 | |
448 | + To enable them for only selected interfaces, e.g., ethA, make | |
449 | +/etc/network/interfaces look like this : | |
450 | +--------- /etc/network/interfaces ----------- | |
451 | +# Enable Hotplug support for "hotplug" mode (Sarge and later) | |
452 | +mapping hotplug | |
453 | + script grep | |
454 | + map ethA | |
455 | +--------------------------------------------- | |
456 | + | |
441 | 457 | 5) Installing Hotplug for Debian 3.0 |
442 | 458 | ------------------------------------ |
443 | 459 | Debian 3.0 doesn't come by default with hotplug, but the |
444 | 460 | hotplug package is available as regular Debian package (on the CD or |
445 | -downloadable via apt-get), so you can just install that. | |
461 | +downloadable in Debian archive), so you can just install that. | |
446 | 462 | |
447 | 463 | Unfortunately, this version of hotplug is not fully compatible |
448 | 464 | with kernel 2.6.X. You will need to do the following modifications to |
@@ -475,71 +491,67 @@ the file /etc/hotplug/net.agent. | ||
475 | 491 | hotplug is much more basic, and doesn't have any scanning at boot time |
476 | 492 | and doesn't need to be enabled in /etc/network/interfaces. |
477 | 493 | |
478 | - 6) Installing hotplug, other cases | |
479 | - ---------------------------------- | |
494 | + 6) Installing hotplug on other distributions | |
495 | + -------------------------------------------- | |
480 | 496 | The canonical version of hotplug is available at : |
481 | 497 | http://linux-hotplug.sourceforge.net/ |
482 | 498 | |
483 | - Most distributions have various version of hotplug with | |
484 | -various modifications on top of the canonical version, and chances are | |
485 | -that the canonical version won't completely work on your system. | |
486 | - All these various changing versions make it difficult for me | |
487 | -to tell what exactly need to be changed in the hotplug scripts to make | |
488 | -them work. | |
489 | - | |
490 | - Some version of hotplug will do scan at boot time, see section | |
491 | -(4) for my comments on this. | |
499 | + Most distributions have customized hotplug packages and | |
500 | +chances are that the canonical version won't completely work on your | |
501 | +system. All these various changing versions make it difficult for me | |
502 | +to tell what exactly needs to be changed in the hotplug scripts to | |
503 | +make them work. However, most should work out of the box. | |
492 | 504 | |
493 | - My guess is that in a few release, all these problems will | |
505 | + My guess is that in a few releases, all these problems will | |
494 | 506 | sort themselves out. Just be patient. |
495 | 507 | |
496 | 508 | 7) Dealing with 'init' hotplug |
497 | 509 | ------------------------------ |
498 | 510 | In addition to the standard kernel Hotplug events, modern |
499 | 511 | versions of the Hotplug scripts add init scripts that scan the system |
500 | -buses and generate pseudo Hotplug events. For the PCI buses, the | |
501 | -script /etc/hotplug/pci.rc is run after the boot, for the USB bus, | |
512 | +buses and generate pseudo Hotplug events at boot time. For the PCI | |
513 | +buses, the script /etc/hotplug/pci.rc is run, for the USB bus, | |
502 | 514 | /etc/hotplug/usb.rc is run. |
503 | 515 | The end result is that the Hotplug subsystem will also attempt |
504 | 516 | to configure built-in devices : |
505 | 517 | 1) Kernel boots |
506 | 518 | 2) Init runs, start to initialise the OS |
507 | - 3) /etc/hotplug/pci.rc runs, generate pseudo Hotplug event | |
519 | + 3) /etc/hotplug/pci.rc runs, generates pseudo Hotplug event | |
508 | 520 | 4) /etc/hotplug/pci.agent loads driver module |
509 | 521 | 5) Driver module initialises, creates new network device |
510 | 522 | 6) Kernel generates Network Hotplug event |
511 | - 7) /etc/hotplug/net.agent runs, configure network device | |
523 | + 7) /etc/hotplug/net.agent runs, configures network device | |
512 | 524 | |
513 | 525 | At this point, you realise that at initialisation, both |
514 | 526 | Hotplug and the regular init scripts (see "CONFIGURATION FROM INIT |
515 | 527 | SCRIPTS") are trying to configure the same devices in parallel. This |
516 | -may create problem, and it is totally redundant. | |
528 | +may create problems and is totally redundant. | |
517 | 529 | Another reason I don't like this mechanism is that it blindly |
518 | -attempt to load drivers for all hardware present on the system, and | |
519 | -don't use the configuration in /etc/modules.conf to select the proper | |
520 | -driver. It's fairly common to have multiple driver for some hardware, | |
521 | -and because of Murphy's law, Hotplug will usually load the wrong | |
522 | -one. It's also fairly common to have hardware on the system that | |
530 | +attempts to load drivers for all hardware present on the system and | |
531 | +doesn't use the module loader configuration files to select preferred | |
532 | +drivers. It's fairly common to have multiple drivers for a given | |
533 | +hardware, and because of Murphy's law, Hotplug will usually load the | |
534 | +wrong one. It's also fairly common to have hardware on the system that | |
523 | 535 | doesn't need enabling (for example, the IDE controller on my SCSI |
524 | 536 | machine), not loading the driver makes your kernel smaller and boot |
525 | 537 | faster. |
526 | - Unfortunately, Hotplug did not provide a simple way to disable | |
527 | -such a feature. More importantly, there is no way to selectively | |
528 | -disable it (let say, disabled for network, enabled for sound). | |
529 | 538 | |
530 | - One way to disable this functionality is to delete or rename | |
531 | -the files /etc/hotplug/pci.rc and /etc/hotplug/usb.rc. | |
539 | + Hotplug does have a way of disabling the loading of drivers | |
540 | +on a case by case basis. Drivers listed in /etc/hotplug/blacklist | |
541 | +will not be loaded. | |
542 | + Hotplug can be disabled for a whole subsystem by editing the | |
543 | +appropriate .rc script in /etc/hotplug, or just deleting/renaming | |
544 | +those files. | |
532 | 545 | |
533 | 546 | 8) Making hotplug scripts call ifrename |
534 | 547 | --------------------------------------- |
535 | 548 | The last hotplug step is to make sure that 'ifrename' is run |
536 | 549 | by the hotplug subsystem at the right time. As before, we want to run |
537 | 550 | it just before calling 'ifup'. |
538 | - The latest version of the hotplug scripts have this | |
539 | -integrated. However, you need to check that the path they use for | |
540 | -calling 'ifrename' is the proper one on your system. And, for older | |
541 | -versions of hotplug scripts, you will need to add this support | |
542 | -yourself. | |
551 | + The latest version of the hotplug scripts have this feature | |
552 | +integrated. However, you need to check that the path used for calling | |
553 | +'ifrename' is the proper one on your system. And, for older versions | |
554 | +of hotplug scripts, you will need to add this support yourself. | |
543 | 555 | |
544 | 556 | Check the path for ifrename : |
545 | 557 | -------------------------- |
@@ -557,10 +569,10 @@ yourself. | ||
557 | 569 | # such as whether/how to invoke DHCP, set up bridging, etc. |
558 | 570 | |
559 | 571 | + # Run ifrename as needed - Jean II |
560 | -+ # Remap interface names based on MAC address. This workaround | |
572 | ++ # Remap interface names based on MAC address. This works around | |
561 | 573 | + # the dreaded configuration problem "all my cards are 'eth0'"... |
562 | -+ # This needs to be done before ifup otherwise ifup will get | |
563 | -+ # confused by the name changed and because iface need to be | |
574 | ++ # This needs to be done before ifup, otherwise ifup will get | |
575 | ++ # confused by the name change and because iface needs to be | |
564 | 576 | + # down to change its name. |
565 | 577 | + if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then |
566 | 578 | + debug_mesg invoke ifrename for $INTERFACE |
@@ -576,11 +588,12 @@ yourself. | ||
576 | 588 | if [ -x /sbin/ifup ]; then |
577 | 589 | ------------------------------------------------- |
578 | 590 | |
579 | - If your hotplug scrips already include ifrename support, you | |
580 | -should find a section in /etc/hotplug/net.agent looking like the patch | |
581 | -above. Otherwise, just cut'n'paste the patch above in the right place. | |
591 | + If your hotplug scripts already include ifrename support then | |
592 | +you should find a section in /etc/hotplug/net.agent looking like the | |
593 | +patch above. Otherwise, just cut'n'paste the patch above in the right | |
594 | +place. | |
582 | 595 | The path for 'ifrename' is used twice above, so don't forget |
583 | -to modify both occurences... | |
596 | +to modify both occurences. | |
584 | 597 | |
585 | 598 | |
586 | 599 | 9) Loading driver modules |
@@ -589,11 +602,11 @@ to modify both occurences... | ||
589 | 602 | In theory, you don't need to do any specific configuration for |
590 | 603 | the driver modules to be loaded. The 'pci.agent' and 'usb.agent' |
591 | 604 | should load the right driver module for you. |
592 | - Also, you don't need to define aliases in /etc/modprobe.conf, | |
593 | -it's useless (and may be counter productive). | |
605 | + Also, you don't need to define aliases in /etc/modprobe.d/* or | |
606 | +in /etc/modprobe.conf, it's useless and may be counterproductive. | |
594 | 607 | |
595 | - If you use driver compiled statically in the kernel, you also | |
596 | -have nothing to do. | |
608 | + If you use a driver compiled statically in the kernel, you | |
609 | +also have nothing to do. | |
597 | 610 | |
598 | 611 | 10) Renaming interfaces |
599 | 612 | ----------------------- |
@@ -609,8 +622,8 @@ prism* mac 00:30:B4:* | ||
609 | 622 | |
610 | 623 | If you insert two cards, they would be named prism0 and |
611 | 624 | prism1. Note that 'name wildcarding' is a feature only available in |
612 | -2.6.X, so if you use 2.4.X you will need to be explicit and list each | |
613 | -card separatly : | |
625 | +2.6.X and 2.4.30 and later, so if you use older version of 2.4.X you | |
626 | +will need to be explicit and list each card separatly : | |
614 | 627 | |
615 | 628 | --------- /etc/iftab ----------------------- |
616 | 629 | # SMC 2835W wireless CardBus card |
@@ -622,7 +635,7 @@ prism1 mac 00:30:B4:64:27:8D | ||
622 | 635 | ------------------------- |
623 | 636 | At this point, configuration of Hotplug interfaces is done |
624 | 637 | just like their built-in counterparts. This part is still distribution |
625 | -specific, and still already document in the file DISTRIBUTIONS.txt.. | |
638 | +specific, and still already documented in the file DISTRIBUTIONS.txt. | |
626 | 639 | |
627 | 640 | In Debian, you would need to modify the file |
628 | 641 | /etc/network/interfaces like this : |
@@ -630,12 +643,12 @@ specific, and still already document in the file DISTRIBUTIONS.txt.. | ||
630 | 643 | --------- /etc/network/interfaces ----------- |
631 | 644 | # Enable Hotplug support (Sarge and later) |
632 | 645 | mapping hotplug |
633 | - script echo | |
646 | + script grep | |
647 | + map prism0 | |
634 | 648 | |
635 | 649 | # SMC 2835W wireless CardBus card |
636 | 650 | iface prism0 inet static |
637 | 651 | address 10.0.1.2 |
638 | - network 10.0.1.0 | |
639 | 652 | netmask 255.255.255.0 |
640 | 653 | broadcast 10.0.1.255 |
641 | 654 | wireless-essid THE_ESSID |
@@ -643,53 +656,57 @@ iface prism0 inet static | ||
643 | 656 | wireless-channel 5 |
644 | 657 | --------------------------------------------- |
645 | 658 | |
646 | - Now, just cross your finger and plug the card in the slot... | |
659 | + Note that you should not have wireless-* lines if you are | |
660 | +using waproamd to set these parameters. | |
661 | + | |
662 | + Now, just cross your fingers and plug the card in the slot... | |
647 | 663 | |
648 | 664 | PCMCIA INTERFACES (16 bits) |
649 | 665 | --------------------------- |
650 | 666 | The Pcmcia subsystem has quite some legacy, and can use |
651 | -various configuration procedure. The Pcmcia subsystem fully use | |
652 | -hotplug for 32 bits card (if you are using the kernel Pcmcia modules, | |
653 | -which is the only option for 2.6.X). For 16 bits cards, we can't make | |
654 | -them fully hotplug yet and need the cardmgr and /etc/pcmcia directory, | |
655 | -however we can make their network configuration use hotplug. | |
667 | +various configuration procedures. The Pcmcia subsystem exclusively | |
668 | +uses hotplug for 32 bits cards (if you are using the kernel Pcmcia | |
669 | +modules, which is the only option for 2.6.X). For 16 bit cards cardmgr | |
670 | +is still required for managing the sockets and loading | |
671 | +modules. Cardmgr is configured by files in the /etc/pcmcia directory. | |
656 | 672 | |
657 | 673 | To use Hotplug network configuration with 16 bits Pcmcia |
658 | 674 | cards, first make sure the Pcmcia subsystem is properly configured and |
659 | -that cardmgr load the right module (in most case, it should). Then, | |
660 | -make sure that you don't have any configuration entries in | |
661 | -/etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Make sure that | |
662 | -none of entries in your system network configuration use 'eth0' or | |
663 | -'wlan0' (in /etc/network/interfaces for Debian users). | |
675 | +that cardmgr loads the right driver module (in most case, it | |
676 | +should). Then, make sure that you don't have any configuration entries | |
677 | +in /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Make sure | |
678 | +that none of the entries in your system network configuration use | |
679 | +'eth0' or 'wlan0' (in /etc/network/interfaces for Debian users). | |
664 | 680 | Then, just follow the procedure described above for |
665 | 681 | "Configuration Using Hotplug" to configure your network cards. |
666 | 682 | |
667 | 683 | You might want a little bit of explanation on why this magic |
668 | 684 | will work (which would help in case it doesn't work). |
669 | - There is two types of Pcmcia network configuration scripts, | |
670 | -available as /etc/pcmcia/network. The original Pcmcia script configure | |
671 | -network cards using options found in /etc/pcmcia/network.opts and | |
672 | -/etc/pcmcia/wireless.opts. Most distributions replace it with a script | |
673 | -calling 'ifup'. By making sure that network.opts and wireless.opts are | |
674 | -"empty", we neutralise the first set of scripts. By making sure no | |
675 | -system configuration uses 'eth0' or 'wlan0', we neutralise the second | |
676 | -set of scripts, the script would call 'ifup' with the default | |
677 | -interface name, which is usually 'eth0', ifup would not find a | |
678 | -configuration for it and would just ignores it. | |
685 | + There are two types of Pcmcia network configuration scripts, | |
686 | +available as /etc/pcmcia/network. The original Pcmcia script | |
687 | +configures network cards using options found in | |
688 | +/etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Most | |
689 | +distributions replace it with a script calling 'ifup'. By making sure | |
690 | +that network.opts and wireless.opts are "empty", we neutralise the | |
691 | +first set of scripts. By making sure no system configuration uses | |
692 | +'eth0' or 'wlan0', we neutralise the second set of scripts, the script | |
693 | +would call 'ifup' with the default interface name, which is usually | |
694 | +'eth0', ifup would not find a configuration for it and would just | |
695 | +ignore it. | |
679 | 696 | The card would still be configured because hotplug network |
680 | 697 | events are generated for every interfaces, not only for devices |
681 | 698 | managed by hotplug. So, net.agent would receive an event and perform |
682 | 699 | the necessary steps to configure it. |
683 | 700 | |
684 | 701 | Personally, I'm still using the original Pcmcia scripts for my |
685 | -Pcmcia cards as described in the file PCMCIA.txt, because I will | |
686 | -migrate my complex configurations over time. | |
702 | +Pcmcia cards as described in the file PCMCIA.txt, because it still | |
703 | +works and I will migrate my complex configurations over time. | |
687 | 704 | You can also decide to not use Hotplug for Pcmcia cards and |
688 | 705 | modify the distribution Pcmcia scripts in /etc/pcmcia/* to handle |
689 | -Pcmcia cards properly. You would need to modify /etc/pcmcia/network to | |
690 | -add 'ifrename' before 'ifup' the same way it was done for | |
691 | -/etc/hotplug/net.agent. But, as in the long term Pcmcia will migrate | |
692 | -to Hotplug, I would not bother... | |
706 | +Pcmcia cards with ifrename. You would need to modify | |
707 | +/etc/pcmcia/network to add 'ifrename' before 'ifup' the same way it | |
708 | +was done for /etc/hotplug/net.agent. But, as in the long term Pcmcia | |
709 | +will migrate to Hotplug, I would not bother... | |
693 | 710 | |
694 | 711 | MANUAL LOADING, DOCKING STATIONS |
695 | 712 | -------------------------------- |
@@ -705,18 +722,65 @@ not be enabled at boot time. It's also a good idea to disable Hotplug | ||
705 | 722 | init scripts. |
706 | 723 | With Debian, you just need to make sure that the 'auto" |
707 | 724 | keyword doesn't apply to this interface. |
725 | + | |
726 | + If you use drivers statically built in the kernel, make sure | |
727 | +that ifrename runs at boot time (see CONFIGURATION FROM INIT | |
728 | +SCRIPTS). Once it's done, you can just enable and disable those | |
729 | +interfaces with 'ifup ethX' and 'ifdown ethX'. | |
730 | + | |
731 | + If you use both a modular system, make sure that the | |
732 | +'on-demand' module loading is properly configured : | |
733 | + | |
734 | +--------- /etc/modprobe.d/local or /etc/modprobe.conf ------ | |
735 | +# HP 100VG J2585B PCI card | |
736 | +alias eth2 hp100 | |
737 | + | |
738 | +# AMD AMD PCnet LANCE PCI card | |
739 | +alias eth4 pcnet32 | |
740 | +------------------------------------------------------------ | |
741 | + | |
742 | + Then, you should instruct 'ifup' to load module and use | |
743 | +ifrename prior to configuring the interface, and remove the module | |
744 | +when going down. With Debian, this is done with : | |
745 | + | |
708 | 746 | --------- /etc/network/interfaces ----------- |
709 | 747 | # AMD AMD PCnet LANCE PCI card |
748 | +# noauto | |
710 | 749 | iface eth4 inet dhcp |
750 | + pre-up /sbin/ifrename -p -n eth4 | |
751 | + post-down /sbin/modprobe -r eth4 | |
752 | + | |
753 | +# HP 100VG J2585B PCI card | |
754 | +# noauto | |
755 | +iface eth2 inet static | |
756 | + address 10.0.0.2 | |
757 | + netmask 255.255.255.0 | |
758 | + broadcast 10.0.0.255 | |
759 | + gateway 10.0.0.1 | |
760 | + pre-up /sbin/ifrename -p -n eth2 | |
761 | + post-down /sbin/modprobe -r eth2 | |
711 | 762 | --------------------------------------------- |
712 | 763 | |
713 | - If you use driver statically built in the kernel, you can just | |
714 | -enable and disable those interfaces with 'ifup ethX' and 'ifdown ethX'. | |
764 | + We use the '-n' option of ifrename to specify the name of the | |
765 | +interface after renaming. This assume that the mapping for those | |
766 | +interfaces don't use wildcards. The '-p' option make sure ifrename | |
767 | +probes the module prior to using it. | |
768 | + Using "modprobe -r" make sure that if the driver is composed | |
769 | +of multiple module all the modules are unloaded. | |
770 | + | |
771 | + To enable the interface, just use : | |
772 | +----------------------------------- | |
773 | +ifup eth4 | |
774 | +----------------------------------- | |
775 | + And to disable the interface : | |
776 | +----------------------------------- | |
777 | +ifdown eth4 | |
778 | +----------------------------------- | |
715 | 779 | |
716 | - If you use both a modular system and 'ifrename', you will need | |
717 | -to change your habits when enabling those devices. The classical 'ifup | |
718 | -ethX' won't work. | |
719 | - If you don't use Hotplug, you need to do : | |
780 | + This solution is obviously Debian specific, but could be | |
781 | +adapted to other distributions. If you can't manage to get your | |
782 | +distributions to use those tricks, you can do things manually. | |
783 | + If you don't use Hotplug, you enable an interface with : | |
720 | 784 | ----------------------------------- |
721 | 785 | modprobe eth4 |
722 | 786 | ifrename |
@@ -726,19 +790,24 @@ ifup eth4 | ||
726 | 790 | ----------------------------------- |
727 | 791 | modprobe eth4 |
728 | 792 | ----------------------------------- |
729 | - | |
730 | - On the other hand, disabling the interface has not changed : | |
793 | + On the other hand, disabling the interface is done with : | |
731 | 794 | ----------------------------------- |
732 | 795 | ifdown eth4 |
733 | 796 | modprobe -r eth4 |
734 | 797 | ----------------------------------- |
735 | - Using "modprobe -r" make sure that if the driver is composed | |
736 | -of multiple module all the modules are unloaded. | |
798 | + | |
737 | 799 | |
738 | 800 | Docking stations for laptops may contain built-in |
739 | 801 | interfaces. My previous laptop had one, and Linux had no support for |
740 | -it. To be able to simply manage my docking station, I had created two | |
741 | -little scripts to enable and disable my network interface. | |
802 | +it. After docking, I was able to bring up the network ISA card in the | |
803 | +docking station. | |
804 | + However, with most laptops and version of Linux, the issue is | |
805 | +that after docking, the new devices are not seen. The solutions is to | |
806 | +force a rescan of the PCI bus. Documentation is unclear on that, maybe | |
807 | +'scanpci' may help. | |
808 | + | |
809 | + To be able to simply manage my docking station, I had created | |
810 | +two little scripts to enable and disable my network interface. | |
742 | 811 | After docking, you would run : |
743 | 812 | -------- /sbin/dock ---------------------------- |
744 | 813 | #!/bin/sh |
@@ -756,6 +825,7 @@ modprobe -r eth4 | ||
756 | 825 | always be properly configured regardless of if you have a Pcmcia |
757 | 826 | network card in the Pcmcia slot or not. |
758 | 827 | |
828 | + | |
759 | 829 | SCHEMES (MULTI-CONFIG) |
760 | 830 | ---------------------- |
761 | 831 | Most Ethernet cards will only connect to a single network, or |
@@ -769,8 +839,8 @@ offer "overall" schemes changing the whole configuration. I document | ||
769 | 839 | the support for schemes in various distributions in the file |
770 | 840 | DISTRIBUTIONS.txt. |
771 | 841 | |
772 | - You can also use tools such as IfPlugd, WapRoamd or | |
773 | -Wlandetect. Those tools are a kind of "wireless-DHCP", they attempt to | |
842 | + You can also use tools such as ifplugd, waproamd or | |
843 | +wlandetect. Those tools are a kind of "wireless-DHCP", they attempt to | |
774 | 844 | automatically detect the proper wireless configuration and apply |
775 | 845 | it. Most will also attempt to detect network changes. |
776 | 846 | The main limitation of those tools is that they offer very |
@@ -825,12 +895,14 @@ iface prism0-other inet static | ||
825 | 895 | FIRMWARE LOADING |
826 | 896 | ---------------- |
827 | 897 | A lot of modern wireless card don't have built in firmware and |
828 | -need firmware loading. Recent kernel (2.6.X) have a firmware | |
898 | +need firmware loading. Recent kernels (2.6.X) have a firmware | |
829 | 899 | loader. These are a few notes on how to use it. |
830 | 900 | |
831 | 901 | First, read the documentation coming with your driver, because |
832 | 902 | each driver has specificities (like the name of the firmware file it |
833 | -requires). | |
903 | +requires). Some drivers may offer additional ways to load the | |
904 | +firmware, but in the long term things should be standardised around | |
905 | +the hotplug method to simplify packaging in distributions. | |
834 | 906 | |
835 | 907 | You need to compile your kernel with firmware loading |
836 | 908 | (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). | ||
859 | 931 | Note that firmware loading will usually only work with |
860 | 932 | interfaces that are fully managed by Hotplug. This is the only way to |
861 | 933 | ensure the that proper sequence of action is happening in the right |
862 | -order every time. Firmware loading will usually not work properly for | |
934 | +order every time. Firmware loading may not work properly for | |
863 | 935 | interfaces configured in the init scripts. |
864 | 936 | This means that if you have a built-in interface that require |
865 | 937 | firmware loading, you should just use manage those interfaces like |
866 | 938 | removable interfaces (see section above). However, interface |
867 | -configuration need to be explicitely triggered at boot time. | |
939 | +configuration need to be explicitly triggered at boot time. | |
868 | 940 | |
869 | 941 | One possibility is to set-up Hotplug to be run from the init |
870 | 942 | script at boot time. This is usually an option for recent |
@@ -874,9 +946,9 @@ have seen that this has some issues. | ||
874 | 946 | script method and the hotplug method. First, you need to add an alias |
875 | 947 | for the driver in /etc/modprobe.conf. Then, you need to specify a |
876 | 948 | mapping for this interface in /etc/iftab, and specify a configuration |
877 | -for this interface and that that it is enabled at boot time. Lastly, | |
949 | +for this interface and that it is enabled at boot time. Lastly, | |
878 | 950 | you make sure that the network init scripts run 'ifrename |
879 | --p'. 'Ifrename' will trigger the module to load, and all the Hotplug | |
951 | +-p'. 'ifrename' will trigger the module to load, and all the Hotplug | |
880 | 952 | events will be generated properly to configure the interface. |
881 | 953 | |
882 | 954 | DEVICES WITH MULTIPLE NAMES |
@@ -885,7 +957,7 @@ DEVICES WITH MULTIPLE NAMES | ||
885 | 957 | the same device. A classical example is the Aironet driver that |
886 | 958 | creates a 'ethX' and 'wifiY' for each card. |
887 | 959 | |
888 | - 'ifrename' allow you a finer selection of interfaces than | |
960 | + 'ifrename' allows you a finer selection of interfaces than | |
889 | 961 | 'nameif'. For example, to only rename the pseudo-Ethernet network |
890 | 962 | interface name of the Aironet driver, you would do : |
891 | 963 |
@@ -898,16 +970,16 @@ airo* mac 00:07:0E:* arp 1 | ||
898 | 970 | 'wifi0'. |
899 | 971 | |
900 | 972 | You can rename both interfaces. You just need to remember that |
901 | -'ifrename' start matching from the last line of the file, so you would | |
902 | -do : | |
973 | +'ifrename' starts matching from the last line of the file, so you | |
974 | +would do : | |
903 | 975 | --------- /etc/iftab ----------------------- |
904 | 976 | # Cisco Aironet 350 wireless Pcmcia card |
905 | 977 | wifi* mac 00:07:0E:* |
906 | 978 | airo* mac 00:07:0E:* arp 1 |
907 | 979 | --------------------------------------------- |
908 | 980 | |
909 | - The current version of 'ifrename' support only the most useful | |
910 | -selectors, and is architectured such as adding selectors is relatively | |
981 | + The current version of 'ifrename' supports only the most useful | |
982 | +selectors, but it is architectured such as adding selectors is relatively | |
911 | 983 | trivial. If you find a case that 'ifrename' can't handle, you should |
912 | 984 | just extend it. |
913 | 985 |
@@ -915,20 +987,20 @@ DEVICES WITHOUT MAC ADDRESSES | ||
915 | 987 | ----------------------------- |
916 | 988 | Most Ethernet and Wireless devices have a fixed and unique MAC |
917 | 989 | address, and it is therefore advised to name them based on this |
918 | -criteria. However, there is also network interfaces that don't have a | |
990 | +criteria. However, there are also network interfaces that don't have a | |
919 | 991 | fixed and unique MAC address, for example Ethernet over USB, IP over |
920 | 992 | FireWire, PPP and tunnel interfaces. |
921 | - The driver for those devices create the interface with a name | |
993 | + The driver for those devices creates the interface with a name | |
922 | 994 | specific to the driver, such as ppp* for PPP interfaces and usb* for |
923 | 995 | Ethernet over USB, and therefore they are easy to identify and |
924 | 996 | configure, and few users feel the need to rename them. Moreover, some |
925 | 997 | of them, such as PPP, have their own configuration scripts and |
926 | 998 | methodology addressing their unique needs. |
927 | 999 | |
928 | - There is a few cases where you might want to rename interfaces | |
929 | -withour MAC addresses. One example is two Ethernet over USB | |
1000 | + There are a few cases where you might want to rename | |
1001 | +interfaces without MAC addresses. One example is two Ethernet over USB | |
930 | 1002 | dongles. The way to do this is to use alternate ifrename |
931 | -selectors. Choosing the right selector depend on what you want to | |
1003 | +selectors. Choosing the right selector depends on what you want to | |
932 | 1004 | achieve. |
933 | 1005 | A quick theoretical example to illustrate : |
934 | 1006 | --------- /etc/iftab ----------------------- |
@@ -945,14 +1017,14 @@ TROUBLESHOOTING | ||
945 | 1017 | you will need to find out why. First, you need to be familiar with the |
946 | 1018 | sequence of actions in the system and find which one did not happen. |
947 | 1019 | |
948 | - You need to check if the driver module(s) was loaded using | |
1020 | + You need to check that the driver module(s) was loaded using | |
949 | 1021 | 'lsmod'. |
950 | 1022 | |
951 | 1023 | You need to check if the interface was properly renamed with |
952 | 1024 | 'ifrename'. You can use 'ifrename -D -V' to debug your /etc/iftab. |
953 | - Get the the list of interfaces on your system with 'cat | |
954 | -/proc/net/dev', and check if an interface is using the name you | |
955 | -assigned or 'eth0'. Check any suspicious interfaces with 'ifconfig | |
1025 | + Get the list of interfaces on your system with 'ifconfig -a' | |
1026 | +or 'cat /proc/net/dev', and check if an interface is using the name | |
1027 | +you assigned or 'eth0'. Check any suspicious interfaces with 'ifconfig | |
956 | 1028 | eth0', and check its MAC address. Note that some rare drivers don't |
957 | 1029 | have a proper MAC address before brought up, which fools ifrename. |
958 | 1030 | Verify that no line in /etc/iftab matches the all-zero MAC |
@@ -0,0 +1,139 @@ | ||
1 | + Network interface renaming comparison | |
2 | + ------------------------------------- | |
3 | + | |
4 | +INTRODUCTION | |
5 | +------------ | |
6 | + The Wireless Tools package includes 'ifrename', a tool to | |
7 | +rename network interfaces. However, this is not the only solution to | |
8 | +the problem of renaming network interfaces. This document explain the | |
9 | +differences between ifrename and the various alternatives. | |
10 | + The subject of interface renaming may look simple at first | |
11 | +glance, and is simple in 95% of the cases, however there are many | |
12 | +complex scenario and those tools have many features, which explain why | |
13 | +we need to go in more details than just saying 'tool X is better'. | |
14 | + | |
15 | +NAMEIF | |
16 | +------ | |
17 | + The tool 'nameif' was designed to rename network | |
18 | +interfaces. It either loads mapping from the file /etc/mactab or | |
19 | +accept mapping on the command line. | |
20 | + It is part of the net-tools package : | |
21 | + http://www.tazenda.demon.co.uk/phil/net-tools/ | |
22 | + | |
23 | + Advantages over 'ifrename' : | |
24 | + + More widespread, available in very old distributions | |
25 | + + simpler/smaller | |
26 | + Drawbacks compared to 'ifrename' : | |
27 | + - Only support MAC address selector | |
28 | + - Does not support hotplug invocation | |
29 | + - Does not support module on-demand loading | |
30 | + Comments : | |
31 | + o The fact that nameif does not support selector other | |
32 | +than the MAC address is problematic, as USB-NET devices may not have | |
33 | +MAC addresses and some ethernet/wireless drivers can't query the MAC | |
34 | +address before 'ifconfig up'. | |
35 | + o 'ifrename' was designed as a better 'nameif', and | |
36 | +its concept is very similar. | |
37 | + | |
38 | +IPROUTE | |
39 | +------- | |
40 | + The tool 'ip' can rename network interfaces with the following | |
41 | +syntax : | |
42 | + > ip link set <oldname> name <newname> | |
43 | + It is part of the 'iproute' package : | |
44 | + http://developer.osdl.org/dev/iproute2/ | |
45 | + | |
46 | + Advantages over 'ifrename' : | |
47 | + + integrated in 'iproute', which most people need anyway | |
48 | + Drawbacks compared to 'ifrename' : | |
49 | + - Do not support any selector, must use old interface name | |
50 | + - No 'batch' mode, must rename each interface manually | |
51 | + Comments : | |
52 | + o 'ip' only provide the most basic facility. To use it | |
53 | +automatically, like in init/hotplug scripts, wrappers adding some | |
54 | +rules/selector must be written. | |
55 | + | |
56 | +DRIVER MODULE PARAMETERS | |
57 | +------------------------ | |
58 | + Some network driver have module parameters enabling to specify | |
59 | +the network name of all the devices created by the driver. This is | |
60 | +driver specific, so you will need to check your driver. | |
61 | + | |
62 | + Advantages over 'ifrename' : | |
63 | + + very simple to get configured and running | |
64 | + Drawbacks compared to 'ifrename' : | |
65 | + - Not universally supported : few drivers do it | |
66 | + - Fragmented : each driver does it differently | |
67 | + - The only selector available is the driver | |
68 | + Comments : | |
69 | + o This method was never popular with the kernel | |
70 | +people, and this feature is being removed from driver that use to | |
71 | +include it. | |
72 | + | |
73 | +UDEV | |
74 | +---- | |
75 | + The package 'udev' include facility to rename network | |
76 | +interfaces, with rules such as : | |
77 | + KERNEL="eth*", SYSFS{address}="00:52:8b:d5:04:48", NAME="lan" | |
78 | + This is part of the udev package : | |
79 | + http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html | |
80 | + | |
81 | + Advantages over 'ifrename' : | |
82 | + + integrated into 'udev' | |
83 | + + simpler to setup if 'udev' is already properly setup | |
84 | + Drawbacks compared to 'ifrename' : | |
85 | + - Less selectors that 'ifrename' | |
86 | + - Require kernel 2.6.X or later with sysfs support | |
87 | + - Do no support non-hotplug interfaces | |
88 | + - Require 'udev', not everybody uses it (static /dev, devfs) | |
89 | + - Does not support module on-demand loading | |
90 | + Comments : | |
91 | + o 'udev' support many selectors, basically all those | |
92 | +present in 'sysfs', even if the documentation only show instructions | |
93 | +to use the MAC address (which is problematic with virtual devices some | |
94 | +drivers - see above). 'ifrename' can also use all selectors present in | |
95 | +'sysfs' (like 'udev'), plus some other selectors not present in sysfs | |
96 | +that were found to be useful. | |
97 | + o Not all interfaces are managed by hotplug. All | |
98 | +virtual devices, such as tunnels and loopbacks, are not associated | |
99 | +with a hardware bus, and therefore are not managed by hotplug. All | |
100 | +driver compiled statically into the kernel are not managed by | |
101 | +hotplug. 'udev' can't deal with those devices. | |
102 | + o It is common practice on embedded system to use a | |
103 | +static /dev and not 'udev' to save space and boot time. And to not use | |
104 | +hotplug for the same reasons. | |
105 | + o 'ifrename' could be better integrated in 'udev', I don't foresee any technical issues. | |
106 | + | |
107 | +SELECTOR AWARE NETWORK SCRIPTS | |
108 | +------------------------------ | |
109 | + Another method is to not rename the interface at all, and make | |
110 | +the various network script selector aware. The basic idea is to simply | |
111 | +ignore the interface name and have all the network scripts based on | |
112 | +selectors. | |
113 | + The main example is the original Pcmcia network scripts. They | |
114 | +allow you to configure an interface directly based on MAC address and | |
115 | +Pcmcia socket. Another example is the script get-mac-address.sh used | |
116 | +as a mapping in some Debian configuration. On the other hand, Red-Hat | |
117 | +and Fedora scripts don't apply, as they wrap around 'nameif'. | |
118 | + | |
119 | + Advantages over 'ifrename' : | |
120 | + + usually simpler to setup and understand | |
121 | + Drawbacks compared to 'ifrename' : | |
122 | + - Less selectors that 'ifrename' | |
123 | + - Only work for the scripts, other tools left confused | |
124 | + Comments : | |
125 | + o This method is conceptually simpler, and works | |
126 | +well. It eliminates the two steps process of other methods (renaming ; | |
127 | +configuring). | |
128 | + o Unfortunately, this method only apply to the | |
129 | +specific scripts, and not to the majority of the networking tools | |
130 | +which are still based on interface name. This means that when the user | |
131 | +use those other tools, he is left guessing which interface is which. | |
132 | + o Distributions never never really embraced this | |
133 | +method, as they all replaced the original Pcmcia scripts with one | |
134 | +using the interfacename. | |
135 | + | |
136 | + Have fun... | |
137 | + | |
138 | + Jean | |
139 | + |
@@ -71,6 +71,10 @@ Other useful Makefile options : | ||
71 | 71 | Note that you should pass the same command line options for |
72 | 72 | all invocations of make ("make" and "make install"). |
73 | 73 | |
74 | + If you want the absolute minimal footprint, you may want to | |
75 | +look into the multicall version of the tools. You can build it with | |
76 | +"make iwmulticall" and install it with "make install-iwmulticall". | |
77 | + | |
74 | 78 | Old kernel with older Wireless Extensions : |
75 | 79 | ----------------------------------------- |
76 | 80 | Kernel prior to 2.2.14 : Those kernels include Wireless |
@@ -23,6 +23,10 @@ RANLIB = ranlib | ||
23 | 23 | ## This is mostly useful for embedded platforms without maths. |
24 | 24 | # BUILD_NOLIBM = y |
25 | 25 | |
26 | +## Uncomment this to strip binary from symbols. This reduce binary size | |
27 | +## by a few percent but make debug worse... | |
28 | +# BUILD_STRIPPING = y | |
29 | + | |
26 | 30 | # *************************************************************************** |
27 | 31 | # ***** Most users should not need to change anything beyond this point ***** |
28 | 32 | # *************************************************************************** |
@@ -43,7 +47,7 @@ PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename | ||
43 | 47 | MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8 |
44 | 48 | MANPAGES7=wireless.7 |
45 | 49 | MANPAGES5=iftab.5 |
46 | -EXTRAPROGS= macaddr | |
50 | +EXTRAPROGS= macaddr iwmulticall | |
47 | 51 | |
48 | 52 | # Composition of the library : |
49 | 53 | OBJS = iwlib.o |
@@ -75,11 +79,18 @@ LDCONFIG = ldconfig | ||
75 | 79 | # Do we want to build with or without libm ? |
76 | 80 | ifdef BUILD_NOLIBM |
77 | 81 | LIBS= |
78 | - WELIB_FLAG = -DWE_NOLIBM=y | |
82 | + WELIB_FLAG= -DWE_NOLIBM=y | |
79 | 83 | else |
80 | 84 | LIBS= -lm |
81 | 85 | endif |
82 | 86 | |
87 | +# Stripping or not ? | |
88 | +ifdef BUILD_STRIPPING | |
89 | + STRIPFLAGS= -Wl,-s | |
90 | +else | |
91 | + STRIPFLAGS= | |
92 | +endif | |
93 | + | |
83 | 94 | # Other flags |
84 | 95 | CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \ |
85 | 96 | -Wpointer-arith -Wcast-qual -Winline -I. |
@@ -92,7 +103,7 @@ PICFLAG=-fPIC | ||
92 | 103 | all:: $(IWLIB) $(PROGS) |
93 | 104 | |
94 | 105 | %: %.o |
95 | - $(CC) $(LDFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) | |
106 | + $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) | |
96 | 107 | %.o: %.c wireless.h |
97 | 108 | $(CC) $(XCFLAGS) -c $< |
98 | 109 | %.so: %.c wireless.h |
@@ -114,34 +125,27 @@ ifrename: ifrename.o $(IWLIB) | ||
114 | 125 | |
115 | 126 | macaddr: macaddr.o $(IWLIB) |
116 | 127 | |
128 | +# Always do symbol stripping here | |
129 | +iwmulticall: iwmulticall.o | |
130 | + $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS) | |
131 | + | |
117 | 132 | # It's a kind of magic... |
118 | 133 | wireless.h: |
119 | 134 | cp $(WEXT_HEADER) wireless.h |
120 | 135 | |
121 | 136 | # Compilation of the dynamic library |
122 | 137 | $(DYNAMIC): $(OBJS:.o=.so) |
123 | - $(CC) -shared -o $@ -Wl,-soname,$@ $(LIBS) -lc $^ | |
138 | + $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^ | |
124 | 139 | |
125 | 140 | # Compilation of the static library |
126 | -$(STATIC): $(OBJS) | |
141 | +$(STATIC): $(OBJS:.o=.so) | |
127 | 142 | $(RM) $@ |
128 | 143 | $(AR) cru $@ $^ |
129 | 144 | $(RANLIB) $@ |
130 | 145 | |
131 | -# So crude but so effective ;-) | |
146 | +# Installation : So crude but so effective ;-) | |
132 | 147 | # Less crude thanks to many contributions ;-) |
133 | -install:: all $(IWLIB_INSTALL) | |
134 | - install -m 755 -d $(INSTALL_DIR) | |
135 | - install -m 755 $(PROGS) $(INSTALL_DIR) | |
136 | - install -m 755 -d $(INSTALL_INC) | |
137 | - install -m 644 iwlib.h $(INSTALL_INC) | |
138 | - install -m 644 wireless.h $(INSTALL_INC) | |
139 | - install -m 755 -d $(INSTALL_MAN)/man8/ | |
140 | - install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/ | |
141 | - install -m 755 -d $(INSTALL_MAN)/man7/ | |
142 | - install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/ | |
143 | - install -m 755 -d $(INSTALL_MAN)/man5/ | |
144 | - install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/ | |
148 | +install:: $(IWLIB_INSTALL) install-bin install-hdr install-man | |
145 | 149 | |
146 | 150 | # Install the dynamic library |
147 | 151 | install-dynamic:: $(DYNAMIC) |
@@ -156,6 +160,35 @@ install-static:: $(STATIC) | ||
156 | 160 | install -m 755 -d $(INSTALL_LIB) |
157 | 161 | install -m 644 $(STATIC) $(INSTALL_LIB) |
158 | 162 | |
163 | +# All the binaries. Careful, no dependancy on install-dynamic | |
164 | +install-bin:: all | |
165 | + install -m 755 -d $(INSTALL_DIR) | |
166 | + install -m 755 $(PROGS) $(INSTALL_DIR) | |
167 | + | |
168 | +# Headers to go with the wireless lib (dev) | |
169 | +install-hdr:: wireless.h | |
170 | + install -m 755 -d $(INSTALL_INC) | |
171 | + install -m 644 iwlib.h $(INSTALL_INC) | |
172 | + install -m 644 wireless.h $(INSTALL_INC) | |
173 | + | |
174 | +# How could you live without those manapages ? | |
175 | +install-man:: | |
176 | + install -m 755 -d $(INSTALL_MAN)/man8/ | |
177 | + install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/ | |
178 | + install -m 755 -d $(INSTALL_MAN)/man7/ | |
179 | + install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/ | |
180 | + install -m 755 -d $(INSTALL_MAN)/man5/ | |
181 | + install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/ | |
182 | + | |
183 | +install-iwmulticall:: iwmulticall | |
184 | + install -m 755 -d $(INSTALL_DIR) | |
185 | + install -m 755 $< $(INSTALL_DIR)/iwconfig | |
186 | + ( cd $(INSTALL_DIR) ; \ | |
187 | + ln -f -s iwconfig iwlist ; \ | |
188 | + ln -f -s iwconfig iwspy ; \ | |
189 | + ln -f -s iwconfig iwpriv ; \ | |
190 | + ln -f -s iwconfig iwgetid ) | |
191 | + | |
159 | 192 | clean:: |
160 | 193 | $(RM_CMD) |
161 | 194 |
@@ -1,8 +1,8 @@ | ||
1 | 1 | Pcmcia Wireless configuration |
2 | 2 | ----------------------------- |
3 | 3 | |
4 | - One of the most exciting thing having happen after release 20 | |
5 | -is the addition of Wireless Extension support in the Pcmcia init | |
4 | + One of the most exciting things having happen after release 20 | |
5 | +is the addition of Wireless Tools support in the Pcmcia init | |
6 | 6 | scripts. Here is a quick intro on the subject... |
7 | 7 | |
8 | 8 | Pre-requisite : |
@@ -14,11 +14,11 @@ Pre-requisite : | ||
14 | 14 | |
15 | 15 | Raylink driver : |
16 | 16 | -------------- |
17 | - The Raylink driver as of 1.70 doesn't support yet writable | |
17 | + The Raylink driver as of 1.70 doesn't support writable | |
18 | 18 | Wireless Extensions, so enabling wireless.opts on this driver will |
19 | -make thing worse. | |
19 | +make things worse. | |
20 | 20 | On the other hand, the latest version of the Raylink driver |
21 | -accept Wireless Extensions at boot time, so the procedure described | |
21 | +accepts Wireless Extensions at boot time, so the procedure described | |
22 | 22 | below will work. |
23 | 23 | |
24 | 24 | Distribution specific notes : |
@@ -36,7 +36,7 @@ proper init scripts and those instructions will apply. | ||
36 | 36 | |
37 | 37 | Basic support : |
38 | 38 | ------------- |
39 | - The file /etc/pcmcia/wireless.opts contain some templates for | |
39 | + The file /etc/pcmcia/wireless.opts contains some templates for | |
40 | 40 | the most common drivers. Just fill in your card configuration in the |
41 | 41 | template corresponding to your driver configuration. |
42 | 42 | Then, to activate it, you just need to remove or comment the 4 |
@@ -75,13 +75,13 @@ esac | ||
75 | 75 | |
76 | 76 | Scheme support : |
77 | 77 | -------------- |
78 | - The file wireless.opts fully support schemes. This allow you | |
78 | + The file wireless.opts fully supports schemes. This allow you | |
79 | 79 | to define different configurations (home, work...) and to switch on |
80 | 80 | the fly between them. |
81 | 81 | The best way to explain it is to show an example. |
82 | 82 | Let's say you have an infrastructured setup at work (MY_WORK) |
83 | -and an adhoc network at home (MY_HOME). Moreover, when a specific card | |
84 | -is inserted, you want it to be in adhoc mode (TEST). The work setup | |
83 | +and an Ad-Hoc network at home (MY_HOME). Moreover, when a specific card | |
84 | +is inserted, you want it to be in Ad-Hoc mode (TEST). The work setup | |
85 | 85 | will be the default... |
86 | 86 | |
87 | 87 | Each Wireless LAN will have the following configuration : |
@@ -16,7 +16,7 @@ Precompiled version : | ||
16 | 16 | ------------------- |
17 | 17 | Most Linux distributions offer precompiled package containing |
18 | 18 | these tools. And many of them preinstall them by default. On the other |
19 | -hand, installation of this package is (now) easy and allow you to get | |
19 | +hand, installation of this package is (now) easy and allows you to get | |
20 | 20 | a more up-to-date version. |
21 | 21 | |
22 | 22 | INSTALL |
@@ -26,7 +26,7 @@ INSTALL | ||
26 | 26 | |
27 | 27 | DISTRIBUTION.txt |
28 | 28 | ---------------- |
29 | - This file will document how to configure wireless cards at | |
29 | + This file documents how to configure wireless cards at | |
30 | 30 | boot time with various Linux distributions (using Wireless |
31 | 31 | Extensions). Please read it carefully before asking questions. |
32 | 32 | In this file, I try to collect all the specifics of Wireless |
@@ -35,7 +35,7 @@ your help to complete this file. | ||
35 | 35 | |
36 | 36 | HOTPLUG.txt |
37 | 37 | ----------- |
38 | - This file document how to manage and configure removable | |
38 | + This file documents how to manage and configure removable | |
39 | 39 | wireless cards using Hotplug. This is more advanced than the simple |
40 | 40 | procedures of DISTRIBUTION.txt. This is currently mostly Debian |
41 | 41 | specific, but I hope you will contribute for other distributions. |
@@ -65,8 +65,8 @@ read locally with the command : | ||
65 | 65 | localised man pages (fr/*) |
66 | 66 | ------------------- |
67 | 67 | Localised man pages are not made by me, therefore the only |
68 | -localisations available are those sent to me by courageous volonteers | |
69 | -and are expect those man pages to 'lag' compared to the english | |
68 | +localisations available are those sent to me by courageous volonteers, | |
69 | +and I expect those man pages to 'lag' compared to the english | |
70 | 70 | version (i.e. not have all the latest updates). Translating man pages |
71 | 71 | is not a very gratifying task, especially due to my broken english, |
72 | 72 | and many technical terms don't translate well to other languages, so |
@@ -84,7 +84,7 @@ iwlist.c | ||
84 | 84 | |
85 | 85 | iwspy.c |
86 | 86 | ------- |
87 | - Mobile IP support test and allows get get stats per MAC | |
87 | + Mobile IP support test and allows to get stats per MAC | |
88 | 88 | address (instead of globally). Also, for some drivers/devices, this is |
89 | 89 | the only way to get stats in Ad-Hoc mode. |
90 | 90 |
@@ -100,8 +100,8 @@ iwgetid.c | ||
100 | 100 | |
101 | 101 | iwevent.c |
102 | 102 | --------- |
103 | - Display Wireless Events. This is new, so there is not much support | |
104 | -in drivers for it yet... | |
103 | + Display Wireless Events. Most recent drivers will support this | |
104 | +relatively new feature, but some older drivers may not support it. | |
105 | 105 | |
106 | 106 | ifrename.c : |
107 | 107 | ---------- |
@@ -131,7 +131,7 @@ your kernel/drivers are old, you may want to try the older releases... | ||
131 | 131 | sample_xxx.c : |
132 | 132 | ------------ |
133 | 133 | Various samples of code showing how to implement some of the |
134 | -more tricky feature of Wireless Extensions in your driver. | |
134 | +more tricky features of Wireless Extensions in your driver. | |
135 | 135 | Note that there is no guarantee that this code compiles, let |
136 | 136 | alone works, but it should point you in the proper direction. |
137 | 137 | Also, have a look at existing drivers in the Linux kernel. |
@@ -0,0 +1,158 @@ | ||
1 | +.\" Jean II - HPL - 2004 | |
2 | +.\" ifrename.8 | |
3 | +.\" | |
4 | +.TH IFRENAME 8 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +ifrename \- Pøejmenuje sí»ová rozhraní v závislosti na rùzných statických kritériích | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTAXE | |
14 | +.B "ifrename [-c configfile] [-p] [-d] [-v] [-V] [-D]" | |
15 | +.br | |
16 | +.B "ifrename [-c configfile] [-i interface] [-n newname]" | |
17 | +.\" | |
18 | +.\" DESCRIPTION part | |
19 | +.\" | |
20 | +.SH POPIS | |
21 | +.B Ifrename | |
22 | +je nástroj, který umo¾òuje pøiøadit stálý název pro ka¾dé | |
23 | +sí»ové rozhraní. | |
24 | +.PP | |
25 | +Ve výchozím stavu jsou názvy rozhraní dynamické a ka¾dému sí»ovému rozhraní | |
26 | +je pøiøazen první dostupný název | |
27 | +.RI ( eth0 ", " eth1 "...)." | |
28 | +Poøadí, v kterém jsou sí»ová rozhraní vytváøena, se mù¾e li¹it. U zabudovaných | |
29 | +rozhraní závisí na jejich rozpoznání kernelem pøi spou¹tìní. Výmìnná zaøízení mù¾e | |
30 | +u¾ivatel pøipojit v jakémkoliv poøadí. | |
31 | +.PP | |
32 | +.B Ifrename | |
33 | +umo¾òuje u¾ivateli rozhodnout, jaký název bude sí»ové rozhraní mít. | |
34 | +.B Ifrename | |
35 | +mù¾e vyu¾ít celou øadu | |
36 | +.IR voleb ", " | |
37 | +aby urèil, jak jsou názvy rozhraní pøiøazovány sí»ovým rozhraním v systému. | |
38 | +Nejbì¾nìj¹í volbou je | |
39 | +.IR "MAC adresa" | |
40 | +rozhraní. | |
41 | +.PP | |
42 | +.B Ifrename | |
43 | +musí být spu¹tìn pøedtím, ne¾ jsou rozhraní aktivována, proto je vìt¹inou pou¾íván | |
44 | +v rùzných skriptech (init, hotplug), ale jen zøídka pøímo u¾ivatelem. | |
45 | +Jako výchozí, | |
46 | +.B ifrename | |
47 | +pøejmenuje v¹echna rozhraní pøítomná v systému pou¾itím namapování definovaného v | |
48 | +.IR /etc/iftab . | |
49 | +.\" | |
50 | +.\" PARAMETER part | |
51 | +.\" | |
52 | +.SH PARAMETRY | |
53 | +.TP | |
54 | +.BI "-c " konfiguracni_soubor | |
55 | +Nastaví konfiguraèní soubor, který bude pou¾it (výchozí je | |
56 | +.IR /etc/iftab ). | |
57 | +Konfiguraèní soubor definuje namapování voleb a názvù rozhraní | |
58 | +a je popsán v | |
59 | +.IR iftab (5). | |
60 | +.br | |
61 | +Pokud je | |
62 | +.I konfiguracni_soubor | |
63 | +urèen jako "-", je konfigurace naètena ze stdin. | |
64 | +.TP | |
65 | +.B -p | |
66 | +Pokusí se zavést moduly jádra pøed pøejmenováním rozhraní. Jako výchozí | |
67 | +prochází | |
68 | +.B ifrename | |
69 | +pouze rozhraní, která jsou ji¾ zavedena a nezavádí automaticky po¾adované | |
70 | +jaderné moduly. Tento pøepínaè umo¾òuje hladkou integraci se systémem, který | |
71 | +nezavádí moduly pøed voláním | |
72 | +.BR ifrename . | |
73 | +.TP | |
74 | +.B -d | |
75 | +Povolí rùzné úpravy specifické pro | |
76 | +.B Debian. | |
77 | +V kombinaci s | |
78 | +.BR -p | |
79 | +budou zavedeny pouze moduly pro rozhraní urèená v | |
80 | +.I /etc/network/interface | |
81 | +. | |
82 | +.TP | |
83 | +.BI "-i " rozhraní | |
84 | +Pøejmenuje pouze urèené | |
85 | +.IR rozhraní , | |
86 | +místo v¹ech rozhraní v systému. Vypí¹e nový název rozhraní. | |
87 | +.TP | |
88 | +.BI "-n " novy_nazev | |
89 | +Kdy¾ je pou¾ito spolu s | |
90 | +.IR -i , | |
91 | +urèí nový název rozhraní. Seznam namapování z konfiguraèního | |
92 | +souboru je ignorován, rozhraní urèené pomocí | |
93 | +.I -i | |
94 | +je rovnou pøejmenováno na | |
95 | +.IR novy_nazev | |
96 | +Nový název mù¾e být ¾olík (wildcard), ale mù¾e obsahovat pouze jedinou "*". | |
97 | +.br | |
98 | +Pokud je pou¾it bez | |
99 | +.IR -i , | |
100 | +pøejmenuje rozhraní s pou¾itím pouze tìch namapování, která by je pøejmenovala na | |
101 | +.IR novy_nazev . | |
102 | +Nový název nesmí být ¾olík. Tento zpùsob pou¾ití ifrename | |
103 | +.RI ( -n " bez " -i ) | |
104 | +není doporuèen, proto¾e je neefektivní. Musejí být zpracována v¹echna rozhraní systému, | |
105 | +a proto není ve vìt¹inì pøípadù rychlej¹í ne¾ kdyby je ifrename pøejmenovalo v¹echny (bez | |
106 | +.IR -n " a zároveò bez " -i ). | |
107 | +.TP | |
108 | +.B -t | |
109 | +Povolí podporu pøevzetí názvù. To umo¾ní výmìnu názvù rozhraní | |
110 | +mezi dvìma èi více rozhraními. | |
111 | +.br | |
112 | +Pøevzetí umo¾òuje rozhraní "ukrást" název jinému rozhraní. | |
113 | +To funguje pouze s jádrem 2.6.x a pokud druhé rozhraní nebì¾í. | |
114 | +Tímpádem není kompatibilní s Hotplug. Druhému rozhraní je pøiøazen | |
115 | +náhodný název, který lze pozdìji pomocí "ifrename" zmìnit. | |
116 | +.br | |
117 | +Poèet pøevzetí je omezen, aby se zabránilo nekoneèným smyèkám, | |
118 | +a proto nemusejí být nìkteré komplexní vícecestné situace správnì zpracovány. | |
119 | +.br | |
120 | +V ka¾dém pøípadì není pøevod názvù a ani pou¾ívání této mo¾nosti doporuèeno, | |
121 | +je lep¹í zvolit pro rozhraní jedineèné a jednoznaèné názvy... | |
122 | +.TP | |
123 | +.B -D | |
124 | +Re¾im dry-run ("naneèisto"). Ifrename nezmìní ¾ádné rozhraní, pouze vypí¹e | |
125 | +nový název rozhraní, pokud je to mo¾né, a skonèí. | |
126 | +.br | |
127 | +V re¾imu dry-run nejsou øe¹eny wildcards. Nový název rozhraní je vyti¹tìn | |
128 | +i v pøípadì, ¾e je stejný jako pùvodní název. | |
129 | +.TP | |
130 | +.B -V | |
131 | +U¾vanìný re¾im. Ifrename zobrazí interní výsledky prùchodu svým | |
132 | +konfiguraèním souborem a dotazy na volby rozhraní. V kombinaci s | |
133 | +pøepínaèem | |
134 | +.I dry-run | |
135 | +pøedstavuje dobrý zpùsob debugování komplexních nastavení nebo triviálních | |
136 | +problémù. | |
137 | +.\" | |
138 | +.\" AUTHOR part | |
139 | +.\" | |
140 | +.SH AUTOR | |
141 | +Jean Tourrilhes \- jt@hpl.hp.com | |
142 | +.\" | |
143 | +.\" TRANSLATION part | |
144 | +.\" | |
145 | +.SH PØEKLAD | |
146 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
147 | +.\" | |
148 | +.\" FILES part | |
149 | +.\" | |
150 | +.SH SOUBORY | |
151 | +.I /etc/iftab | |
152 | +.\" | |
153 | +.\" SEE ALSO part | |
154 | +.\" | |
155 | +.SH DAL©Í INFORMACE | |
156 | +.BR ifconfig (8), | |
157 | +.BR ip (8), | |
158 | +.BR iftab (5). |
@@ -0,0 +1,189 @@ | ||
1 | +.\" Jean II - HPL - 2004 | |
2 | +.\" iftab.5 | |
3 | +.\" | |
4 | +.TH IFTAB 5 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iftab \- statické informace o sí»ových rozhraních | |
10 | +.\" | |
11 | +.\" DESCRIPTION part | |
12 | +.\" | |
13 | +.SH POPIS | |
14 | +Soubor | |
15 | +.B /etc/iftab | |
16 | +obsahuje popisnou informaci o rùzných sí»ových rozhraních. | |
17 | +.B iftab | |
18 | +je pou¾íván pouze programem | |
19 | +.IR ifrename (8) | |
20 | +k pøiøazení stálých názvù sí»ových rozhraní ka¾dému sí»ovému rozhraní. | |
21 | +.PP | |
22 | +.B /etc/iftab | |
23 | +definuje sadu | |
24 | +.IR namapování . | |
25 | +Ka¾dé namapování obsahuje název rozhraní a sadu deskriptorù. | |
26 | +Deskriptory umo¾òují | |
27 | +.B ifrename | |
28 | +identifikovat ka¾dé sí»ové rozhraní v systému. Pokud sí»ové rozhraní odpovídá | |
29 | +v¹em deskriptorùm z namapování, | |
30 | +.B ifrename | |
31 | +se pokusí zmìnit název rozhraní na název urèený v namapování. | |
32 | +.\" | |
33 | +.\" MAPPINGS part | |
34 | +.\" | |
35 | +.SH NAMAPOVÁNÍ | |
36 | +Ka¾dé namapování je popsáno na zvlá¹tní øádce, zaèínající | |
37 | +.IR "interface name" , | |
38 | +(názvem rozhraní) a obsahuje sadu | |
39 | +.IR deskriptorù , | |
40 | +oddìlených mezerami nebo tabulátory. | |
41 | +.PP | |
42 | +Vztah mezi deskriptory v namapování je | |
43 | +.IR "logické a" . | |
44 | +Namapování odpovídá sí»ovému rozhraní, pouze kdy¾ odpovídají v¹echny deskriptory. | |
45 | +Pokud sí»ové rozhraní nepodporuje urèitý deskriptor, nebude vyhovovat ¾ádnému | |
46 | +namapování pou¾ívajícímu tento deskriptor. | |
47 | +.PP | |
48 | +Pokud je potøeba pou¾ít alternativní deskriptory pro název rozhraní | |
49 | +(logické nebo), vytvoøte dvì rùzná namapování se stejným názvem rozhraní | |
50 | +(na ka¾dém øádku jednu). | |
51 | +.B Ifrename | |
52 | +v¾dycky pou¾ije první odpovídající namapování od | |
53 | +.I konce | |
54 | +.BR iftab , | |
55 | +proto by restriktivnìj¹í namapování mìla být uvedena naposled. | |
56 | +.\" | |
57 | +.\" INTERFACE NAME part | |
58 | +.\" | |
59 | +.SH NÁZEV ROZHRANÍ | |
60 | +První èástí ka¾dého namapování je název rozhraní. Pokud sí»ové rozhraní | |
61 | +odpovídá v¹em deskriptorùm v namapování, | |
62 | +.B ifrename | |
63 | +se pokusí zmìnit název rozhraní na název urèený v namapování. | |
64 | +.PP | |
65 | +Název rozhraní v namapování je buïto pouhý název rozhraní (jako tøeba | |
66 | +.IR eth2 " nebo " wlan0 ) | |
67 | +nebo ¹ablona obsahující jediného ¾olíka (wildcard) (napø. | |
68 | +.IR eth* " nebo " wlan* ). | |
69 | +V pøípadì ¾olíka nahradí jádro znak "*" za nejni¾¹í dostupné | |
70 | +celé èíslo, které zajistí jedineènost názvu rozhraní. | |
71 | +.\" | |
72 | +.\" DESCRIPTORS part | |
73 | +.\" | |
74 | +.SH DESKRIPTORY | |
75 | +Ka¾dý deskriptor je slo¾en z názvu deskriptoru a hodnoty deskriptoru. | |
76 | +Deskriptory urèují statické vlastnosti sí»ového rozhraní, jejich | |
77 | +cílem je jednoznaènì identifikovat ka¾dý kus hardware. | |
78 | +.PP | |
79 | +Vìt¹ina u¾ivatelù pou¾ije pouze volbu | |
80 | +.B mac | |
81 | +, ostatní volby jsou urèeny k zvlá¹tním nastavením. | |
82 | +.TP | |
83 | +.BI mac " MAC adresa" | |
84 | +Porovná MAC adresu rozhraní se zadanou MAC adresou. MAC adresu | |
85 | +rozhraní je mo¾né zobrazit pomocí | |
86 | +.IR ifconfig (8) | |
87 | +nebo | |
88 | +.IR ip (8). | |
89 | +Zadaná MAC adresa mù¾e | |
90 | +obsahovat "*" pro výbìr ¾olíkù (wildcards). | |
91 | +.br | |
92 | +Je to nejbì¾nìj¹í volba, proto¾e vìt¹ina rozhraní má unikátní MAC | |
93 | +adresu, která umo¾òuje sí»ové rozhraní jednoznaènì identifikovat. | |
94 | +Nicménì nìkterá rozhraní nemají MAC adresu, dokud nejsou aktivována | |
95 | +a v takovém pøípadì je u¾ití tohoto selektoru o¹idné. | |
96 | +.TP | |
97 | +.BI arp " typ arp" | |
98 | +Porovná typ ARP (ARP Type)(také zvané "Link Type") rozhraní se zadaným typem ARP. | |
99 | +Typ ARP u rozhraní je mo¾né zobrazit pomocí | |
100 | +.IR ifconfig (8) | |
101 | +nebo | |
102 | +.IR ip (8). | |
103 | +.br | |
104 | +Tento selektor je u¾iteèný pokud ovladaè vytváøí více sí»ových rozhraní | |
105 | +pro jedinou sí»ovou kartu. | |
106 | +.TP | |
107 | +.BI driver " název ovladaèe" | |
108 | +Porovná název ovladaèe rozhraní se zadaným názvem ovladaèe. | |
109 | +Název ovladaèe rozhraní je mo¾né zobrazit pomocí | |
110 | +.IR "ethtool -i" (8). | |
111 | +.TP | |
112 | +.BI businfo " informace o sbìrnici" | |
113 | +Porovná informaci o sbìrnici rozhraní rozhraní se zadanou informací | |
114 | +o sbìrnici. Informaci o sbìrnici rozhraní je mo¾né zobrazit pomocí | |
115 | +.IR "ethtool -i" (8). | |
116 | +.TP | |
117 | +.BI firmware " verze firmware" | |
118 | +Porovná verzi firmware rozhraní s informací o verzi firmware. | |
119 | +Revizi firmware rozhraní je mo¾né zobrazit pomocí | |
120 | +.IR "ethtool -i" (8). | |
121 | +.TP | |
122 | +.BI baseaddress " port" | |
123 | +Porovná port rozhraní se zadaným portem. Port rozhraní je mo¾né zobrazit pomocí | |
124 | +.IR ifconfig (8). | |
125 | +.br | |
126 | +Proto¾e vìt¹ina karet pou¾ívá dynamické pøidìlování portù, je | |
127 | +tato volba u¾iteèná pouze pro ISA a EISA karty. | |
128 | +.TP | |
129 | +.BI irq " èíslo pøeru¹ení" | |
130 | +Porovná èíslo pøeru¹ení (IRQ) rozhraní se zadaným | |
131 | +èíslem pøeru¹ení. Èíslo pøeru¹ení rozhraní je mo¾né zobrazit pomocí | |
132 | +.IR ifconfig (8). | |
133 | +.br | |
134 | +Proto¾e pøeru¹ení mohou být sdílená, obvykle tento selektor nestaèí | |
135 | +k jednoznaèné identifikaci rozhraní. | |
136 | +.TP | |
137 | +.BI iwproto " bezdrátový protokol" | |
138 | +Porovná bezdrátový protokol rozhraní se zadaným | |
139 | +bezdrátovým protokolem. Bezdrátový protokol rozhraní je mo¾né zobrazit pomocí | |
140 | +.IR iwconfig (8). | |
141 | +.br | |
142 | +Tato volba je podporována pouze na bezdrátových rozhraních a nestaèí | |
143 | +k jednoznaèné identifikaci rozhraní. | |
144 | +.TP | |
145 | +.BI pcmciaslot " pcmcia slot" | |
146 | +Porovná èíslo Pcmcia socketu rozhraní se zadaným èíslem slotu. Èíslo Pcmcia socketu | |
147 | +rozhraní je mo¾né zobrazit pomocí | |
148 | +.IR "cardctl ident" (8). | |
149 | +.br | |
150 | +Tato volba je obvykle podporována pouze na 16 bitových kartách, pro 32 bitové | |
151 | +karty je lep¹í pou¾ít selektor | |
152 | +.BR businfo . | |
153 | +.\" | |
154 | +.\" EXAMPLE part | |
155 | +.\" | |
156 | +.SH PØÍKLAD | |
157 | +# Toto je komentáø | |
158 | +.br | |
159 | +eth2 mac 08:00:09:DE:82:0E | |
160 | +.br | |
161 | +eth3 driver wavelan irq 15 baseaddress 0x390 | |
162 | +.br | |
163 | +eth4 driver pcnet32 businfo 0000:02:05.0 | |
164 | +.br | |
165 | +air* mac 00:07:0E:* arp 1 | |
166 | +.\" | |
167 | +.\" AUTHOR part | |
168 | +.\" | |
169 | +.SH AUTOR | |
170 | +Jean Tourrilhes \- jt@hpl.hp.com | |
171 | +.\" | |
172 | +.\" TRANSLATION part | |
173 | +.\" | |
174 | +.SH PØEKLAD | |
175 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
176 | +.\" | |
177 | +.\" FILES part | |
178 | +.\" | |
179 | +.SH SOUBORY | |
180 | +.I /etc/iftab | |
181 | +.\" | |
182 | +.\" SEE ALSO part | |
183 | +.\" | |
184 | +.SH DAL©Í INFORMACE | |
185 | +.BR ifrename (8), | |
186 | +.BR ifconfig (8), | |
187 | +.BR ip (8), | |
188 | +.BR ethtool (8), | |
189 | +.BR iwconfig (8). |
@@ -0,0 +1,535 @@ | ||
1 | +.\" Jean II - HPLB - 1996 => HPL - 2004 | |
2 | +.\" iwconfig.8 | |
3 | +.\" | |
4 | +.TH IWCONFIG 8 "22.èervna 2004" "wireless-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iwconfig \- nastavuje rozhraní bezdrátové sítì | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTAXE | |
14 | +.BI "iwconfig [" rozhraní ] | |
15 | +.br | |
16 | +.BI "iwconfig " rozhraní " [essid " X "] [nwid " N "] [mode " M "] [freq " F "] | |
17 | +.br | |
18 | +.BI " [channel " C ] [sens " S "] [ap " A "] [nick " NN ] | |
19 | +.br | |
20 | +.BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ] | |
21 | +.br | |
22 | +.BI " [enc " E "] [key " K "] [power " P "] [retry " R ] | |
23 | +.br | |
24 | +.BI " [commit] | |
25 | +.br | |
26 | +.BI "iwconfig --help" | |
27 | +.br | |
28 | +.BI "iwconfig --version" | |
29 | +.\" | |
30 | +.\" DESCRIPTION part | |
31 | +.\" | |
32 | +.SH POPIS | |
33 | +.B Iwconfig | |
34 | +je podobný pøíkazu | |
35 | +.IR ifconfig (8), | |
36 | +ale je vìnovaný bezdrátovým rozhraním. Je pou¾íván k nastavení tìch parametrù | |
37 | +sí»ových rozhraní, které jsou specifické pro bezdrátový provoz (napø. frekvence). | |
38 | +.B Iwconfig | |
39 | +mù¾e být také pou¾it k zobrazení tìchto parametrù a bezdrátových | |
40 | +statistik (získaných z | |
41 | +.IR /proc/net/wireless ). | |
42 | +.PP | |
43 | +V¹echny tyto parametry a statistiky jsou závislé na zaøízení. Ka¾dý ovladaè | |
44 | +poskytuje, v závislosti na hardwarové podpoøe, jen nìkteré z nich | |
45 | +a rozsah hodnot se mù¾e mìnit. Prosím obracejte se na manuálové stránky | |
46 | +jednotlivých zaøízení pro dal¹í detaily. | |
47 | +.\" | |
48 | +.\" PARAMETER part | |
49 | +.\" | |
50 | +.SH PARAMETRY | |
51 | +.TP | |
52 | +.B essid | |
53 | +Nastaví ESSID (nebo Network Name - u nìkterých produktù mù¾e být nazváno | |
54 | +Domain ID). ESSID se pou¾ívá k identifikaci bunìk, které jsou | |
55 | +souèástí stejné virtuální sítì. | |
56 | +.br | |
57 | +Na rozdíl od adresy AP nebo NWID, která urèuje jedinou buòku, ESSID | |
58 | +urèuje skupinu bunìk, spojených opakovaèi (repeater) nebo infrastrukturou, | |
59 | +mezi kterými mù¾e u¾ivatel transparentnì pøecházet. | |
60 | +.br | |
61 | +U nìkterých karet je mo¾né vypnout kontrolu ESSID (promiskuitní ESSID) | |
62 | +pomocí | |
63 | +.IR off " nebo " any " (a " on | |
64 | +k opìtovnému zapnutí). | |
65 | +.br | |
66 | +Pokud je ESSID sítì jedním z klíèových slov | |
67 | +.RI ( off ", " on " nebo " any ), | |
68 | +pou¾ije se | |
69 | +.I -- | |
70 | +.br | |
71 | +.B Pøíklady: | |
72 | +.br | |
73 | +.I " iwconfig eth0 essid any" | |
74 | +.br | |
75 | +.I " iwconfig eth0 essid ""Moje sit"" | |
76 | +.br | |
77 | +.I " iwconfig eth0 essid -- ""ANY"" | |
78 | +.TP | |
79 | +.BR nwid / domain | |
80 | +Nastaví Network ID (u nìkterých produktù mù¾e být nazváno Domain ID). | |
81 | +Proto¾e v¹echny sousedící bezdrátové sítì sdílejí stejné médium, je | |
82 | +tento parametr pou¾íván k jejich rozli¹ení (tvorbì logických kolokovaných | |
83 | +sítí) a identifikaci nodù patøících do stejné buòky. | |
84 | +.br | |
85 | +Tento parametr se pou¾ívá pouze u pre-802.11 zaøízení. Protokol 802.11 | |
86 | +pou¾ívá pro tuto funkci ESSID a adresu AP. | |
87 | +.br | |
88 | +U nìkterých karet je mo¾né vypnout kontrolu Network ID (promiskuitní NWID) | |
89 | +pomocí | |
90 | +.IR off " (a " on | |
91 | +k opìtovnému zapnutí). | |
92 | +.br | |
93 | +.B Pøíklady: | |
94 | +.br | |
95 | +.I " iwconfig eth0 nwid AB34 | |
96 | +.br | |
97 | +.I " iwconfig eth0 nwid off" | |
98 | +.TP | |
99 | +.BR freq / channel | |
100 | +Nastaví pracovní frekvenci nebo kanál zaøízení. Hodnota ni¾¹í ne¾ 1000 | |
101 | +znamená èíslo kanálu, hodnota vy¹¹í ne¾ 1000 je frekvence v Hz. | |
102 | +Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (napøíklad "2.46G" pro | |
103 | +frekvenci 2,46 GHz), nebo doplnit dostateèný poèet nul. | |
104 | +.br | |
105 | +Kanály jsou obvykle èíslovány od 1, je mo¾né pou¾ít | |
106 | +.IR iwlist (8) | |
107 | +k získání celkového poètu kanálù, seznamu dostupných frekvencí a zobrazení souèasné | |
108 | +frekvence jako kanálu. V závislosti na pøedpisech mohou být nìkteré frekvence/kanály | |
109 | +nedostupné. | |
110 | +.br | |
111 | +.B Pøíklady: | |
112 | +.br | |
113 | +.I " iwconfig eth0 freq 2422000000" | |
114 | +.br | |
115 | +.I " iwconfig eth0 freq 2.422G" | |
116 | +.br | |
117 | +.I " iwconfig eth0 channel 3" | |
118 | +.TP | |
119 | +.B sens | |
120 | +Nastaví práh citlivosti. To je nejni¾¹í úroveò síly signálu pøi které | |
121 | +hardware pova¾uje pøijaté pakety za pou¾itelné. Kladné hodnoty jsou | |
122 | +interpretovány jako hodnota pou¾ívaná hardwarem nebo jako procenta, | |
123 | +negativní hodnoty jako dBm. V závislosti na hardwarové implementaci mù¾e | |
124 | +mít tento parametr dal¹í funkce. | |
125 | +.br | |
126 | +Tento parametr mù¾e ovládat práh pøíjmu (receive threshold) - nejni¾¹í úroveò signálu | |
127 | +pøi které se hardware pokusí o pøíjem paketu, slab¹í signál je ignorován. Mù¾e také | |
128 | +nastavovat práh ústupu (defer threshold) - nejni¾¹í úroveò signálu, od které hardware | |
129 | +pova¾uje kanál za obsazený. Pøi správném nastavení tìchto prahù karta neztrácí èas | |
130 | +pøíjmen ¹umu. U moderních zaøízení se zdá, ¾e tyto prahy regulují automaticky. | |
131 | +.br | |
132 | +U moderních karet mù¾e tento parametr ovládat práh pøedání (handover/roaming | |
133 | +threshold) - nejni¾¹í úroveò signálu pøi které hardware je¹tì zùstane asociováno se | |
134 | +souèasným pøístupovým bodem. Pokud úroveò signálu poklesne pod tuto hodnotu, | |
135 | +zaène karta hledat nový/lep¹í pøístupový bod. | |
136 | +.br | |
137 | +.B Pøíklad: | |
138 | +.br | |
139 | +.I " iwconfig eth0 sens -80" | |
140 | +.TP | |
141 | +.B mode | |
142 | +nastaví pracovní re¾im zaøízení, co¾ závisí na topologii sítì. | |
143 | +Re¾im mù¾e být | |
144 | +.I Ad-Hoc | |
145 | +(sí» slo¾ená pouze z jedné buòky a bez pøístupového bodu), | |
146 | +.I Managed | |
147 | +(node se pøipojuje do sítì slo¾ené z mnoha pøístupových bodù, s roamingem), | |
148 | +.I Master | |
149 | +(node je synchronisation master nebo slou¾í jako pøístupový bod), | |
150 | +.I Repeater | |
151 | +(node pøedává pakety mezi ostatními bezdrátovými nody), | |
152 | +.I Secondary | |
153 | +(node slou¾í jako zálo¾ní master/repeater), | |
154 | +.I Monitor | |
155 | +(node není asociován s ¾ádnou buòkou a pasivnì monitoruje pakety na frekvenci) nebo | |
156 | +.IR Auto . | |
157 | +.br | |
158 | +.B pøíklad: | |
159 | +.br | |
160 | +.I " iwconfig eth0 mode Managed" | |
161 | +.br | |
162 | +.I " iwconfig eth0 mode Ad-Hoc" | |
163 | +.TP | |
164 | +.B ap | |
165 | +Naøídí kartì pøipojit se k pøístupovému bodu urèenému adresou, | |
166 | +pokud je to mo¾né. Pokud se kvalita spojení pøíli¹ sní¾í, | |
167 | +mù¾e se ovladaè vrátit do automatického módu (karta vybere | |
168 | +nejlep¹í pøístupový bod v dosahu). | |
169 | +.br | |
170 | +Je také mo¾né pou¾ít | |
171 | +.I off | |
172 | +k opìtovnému zapnutí automatického módu beze zmìny souèasného pøístupového bodu | |
173 | +nebo | |
174 | +.I any | |
175 | +èi | |
176 | +.I auto | |
177 | +k vynucení opìtovné asociace karty s momentálnì nejlep¹ím pøístupovým bodem. | |
178 | +.br | |
179 | +.B Pøíklad : | |
180 | +.br | |
181 | +.I " iwconfig eth0 ap 00:60:1D:01:23:45" | |
182 | +.br | |
183 | +.I " iwconfig eth0 ap any" | |
184 | +.br | |
185 | +.I " iwconfig eth0 ap off" | |
186 | +.TP | |
187 | +.BR nick [name] | |
188 | +Nastaví pøezdívku neboli station name. Nìkteré 802.11 produkty ji definují, | |
189 | +ale co se týká protokolù (MAC, IP, TCP), není pou¾ívána a pøi konfiguraci je | |
190 | +zcela nepotøebná. Pou¾ívají ji pouze nìkteré diagnostické nástroje. | |
191 | +.br | |
192 | +.B Pøíklad: | |
193 | +.br | |
194 | +.I " iwconfig eth0 nickname ""Muj linuxovy node"" | |
195 | +.TP | |
196 | +.BR rate / bit [rate] | |
197 | +U karet, které podporují více pøenosových rychlostí, nastaví rychlost pøenosu v b/s. | |
198 | +Rychlost pøenosu je rychlost, kterou jsou bity pøená¹eny médiem, | |
199 | +rychlost pro u¾ivatele je ni¾¹í kvùli sdílení média a rùzné re¾ii. | |
200 | +.br | |
201 | +Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (dekadický násobitel: | |
202 | +10^3, 10^6 a 10^9 b/s), nebo doplnit dostateèný poèet nul. Význam hodnoty ni¾¹í ne¾ | |
203 | +1000 závisí na pou¾ité kartì, obvykle znamená index v seznamu pøenosových rychlostí. | |
204 | +Je mo¾né pou¾ít | |
205 | +.I auto | |
206 | +ke zvolení re¾imu automatické pøenosové rychlosti (ústup na ni¾¹í rychlost v za¹umìných | |
207 | +kanálech), co¾ je u vìt¹iny karet výchozí nastavení, a | |
208 | +.I fixed | |
209 | +k návratu k pevnému nastavení. Pokud je urèena pøenosová rychlost a | |
210 | +.IR auto , | |
211 | +mù¾e ovladaè pou¾ít v¹echny pøenosové rychlosti rovné této hodnotì a ni¾¹í. | |
212 | +.br | |
213 | +.B Pøíklady: | |
214 | +.br | |
215 | +.I " iwconfig eth0 rate 11M" | |
216 | +.br | |
217 | +.I " iwconfig eth0 rate auto" | |
218 | +.br | |
219 | +.I " iwconfig eth0 rate 5.5M auto" | |
220 | +.TP | |
221 | +.BR rts [_threshold] | |
222 | +RTS/CTS pøidá handshake pøed ka¾dým pøenosem paketù, aby se zajistilo, | |
223 | +¾e je kanál volný. To zvý¹í re¾ii, ale také výkon v pøípadì skrytých nodù | |
224 | +nebo velkého poètu aktivních nodù. Tento parametr nastavuje velikost nejmen¹ího | |
225 | +paketu, pro který node vysílá RTS; hodnota rovná maximální velikosti paketu | |
226 | +tento mechanismus vypne. Je také mo¾né nastavit tento parametr na | |
227 | +.IR auto ", " fixed " nebo " off . | |
228 | +.br | |
229 | +.B Pøíklady: | |
230 | +.br | |
231 | +.I " iwconfig eth0 rts 250" | |
232 | +.br | |
233 | +.I " iwconfig eth0 rts off" | |
234 | +.TP | |
235 | +.BR frag [mentation_threshold] | |
236 | +Fragmentace dovoluje rozdìlit IP paket na dávku nìkolika men¹ích èástí | |
237 | +pøenesených médiem. To ve vìt¹inì pøípadù zvìt¹í re¾ii, ale ve velmi za¹umìnìm | |
238 | +prostøedí sní¾í ztráty zpùsobené chybami a umo¾ní paketùm projít | |
239 | +pøi zaru¹ení. Tento parametr nastaví maximální velikost fragmentu; hodnota | |
240 | +rovná maximální velikosti paketu tento mechanismus vypne. Je také | |
241 | +mo¾né nastavit tento mechanismus na | |
242 | +.IR auto ", " fixed " nebo " off . | |
243 | +.br | |
244 | +.B Pøíklady: | |
245 | +.br | |
246 | +.I " iwconfig eth0 frag 512" | |
247 | +.br | |
248 | +.I " iwconfig eth0 frag off" | |
249 | +.TP | |
250 | +.BR key / enc [ryption] | |
251 | +Pou¾ívá se k nastavení ¹ifrovacích klíèù a bezpeènostního re¾imu. | |
252 | +.br | |
253 | +Pro nastavení aktuálního ¹ifrovacího klíèe se pouze zadá klíè v hexadecimální podobì jako | |
254 | +.IR XXXX-XXXX-XXXX-XXXX " nebo " XXXXXXXX . | |
255 | +Pro nastavení jiného ne¾ aktuálního klíèe pøidejte pøed nebo za vlastní klíè | |
256 | +.I [index] | |
257 | +(tím se nezmìní aktuální klíè). Je také mo¾né zadat klíè | |
258 | +jako øetìzec ASCII znakù pomocí pøedpony | |
259 | +.I s: | |
260 | +. Passphrase není v souèasnosti podporovaná. | |
261 | +.br | |
262 | +Pro urèení, který klíè má být aktivní, se vlo¾í | |
263 | +.I [index] | |
264 | +(bez zadání hodnoty klíèe). | |
265 | +.br | |
266 | +.IR off " a " on | |
267 | +Vypnou a znovu zapnou ¹ifrování. | |
268 | +.br | |
269 | +Bezpeènostní re¾im mù¾e být | |
270 | +.I open | |
271 | +(otevøený) nebo | |
272 | +.IR restricted , | |
273 | +(uzavøený) a jeho význam závisí na pou¾ité kartì. Vìt¹ina karet nepou¾ívá v | |
274 | +.I open | |
275 | +(otevøeném) re¾imu ¾ádnou autentizaci a karta mù¾e také pøijímat | |
276 | +neza¹ifrované relace, zatímco v | |
277 | +.I restricted | |
278 | +(uzavøeném) re¾imu jsou akceptovány pouze za¹ifrované relace a karta pou¾ije autentizaci, | |
279 | +pokud je k dispozici. | |
280 | +.br | |
281 | +Pokud je tøeba nastavit více klíèù, nebo nastavit klíè a urèit aktivní klíè, | |
282 | +je nutné pou¾ít více pøepínaèù | |
283 | +.B key | |
284 | +. Parametry mohou být v jakémkoliv poøadí, poslední má pøednost. | |
285 | +.br | |
286 | +.B Pøíklady: | |
287 | +.br | |
288 | +.I " iwconfig eth0 key 0123-4567-89" | |
289 | +.br | |
290 | +.I " iwconfig eth0 key [3] 0123-4567-89" | |
291 | +.br | |
292 | +.I " iwconfig eth0 key s:password [2]" | |
293 | +.br | |
294 | +.I " iwconfig eth0 key [2]" | |
295 | +.br | |
296 | +.I " iwconfig eth0 key open" | |
297 | +.br | |
298 | +.I " iwconfig eth0 key off" | |
299 | +.br | |
300 | +.I " iwconfig eth0 key restricted [3] 0123456789" | |
301 | +.br | |
302 | +.I " iwconfig eth0 key 01-23 key 45-67 [4] key [4]" | |
303 | +.TP | |
304 | +.BR power | |
305 | +Nastavuje re¾im øízení spotøeby a jeho parametry. | |
306 | +.br | |
307 | +Pro nastavení èasu mezi probuzeními se vlo¾í | |
308 | +.IR "period `hodnota'" . | |
309 | +Pro nastavení prodlevy pøed návratem do spánku se vlo¾í | |
310 | +.IR "timeout `hodnota'" . | |
311 | +Je také mo¾né pøidat modifikátory | |
312 | +.IR min " a " max | |
313 | +. Hodnoty znamenají poèet sekund, pro urèení v milisekundách | |
314 | +nebo mikrosekundách se pou¾ije pøípona m nebo u. Nìkdy jsou | |
315 | +tyto hodnoty bez jednotek (poèet období mezi beacons a podobnì). | |
316 | +.br | |
317 | +.IR off " a " on | |
318 | +vypne a novu zapne øízení spotøeby. Je také mo¾né nastavit | |
319 | +re¾im øízení spotøeby na | |
320 | +.I all | |
321 | +(pøijímá v¹echny pakety), | |
322 | +.I unicast | |
323 | +(pøijímá pouze unicast pakety, zahazuje multicast a broadcast) a | |
324 | +.I multicast | |
325 | +(pøijímá pouze multicast a broadcast, zahazuje unicast pakety). | |
326 | +.br | |
327 | +.B Pøíklady: | |
328 | +.br | |
329 | +.I " iwconfig eth0 power period 2" | |
330 | +.br | |
331 | +.I " iwconfig eth0 power 500m unicast" | |
332 | +.br | |
333 | +.I " iwconfig eth0 power timeout 300u all" | |
334 | +.br | |
335 | +.I " iwconfig eth0 power off" | |
336 | +.br | |
337 | +.I " iwconfig eth0 power min period 2 power max period 4" | |
338 | +.TP | |
339 | +.BR txpower | |
340 | +U karet podporujících rozdílné vysílací výkony nastavuje vysílací výkon v dBm. Je-li dán výkon | |
341 | +.I W | |
342 | +ve Wattech, je výkon v dBm roven | |
343 | +.IR "P = 30 + 10.log(W)" . | |
344 | +Pokud je hodnota doplnìna pøíponou | |
345 | +.IR mW , | |
346 | +je automaticky pøevedena na dBm. | |
347 | +.br | |
348 | +Navíc volby | |
349 | +.IR on " a " off | |
350 | +povolí a zaká¾ou vysílání, | |
351 | +.IR auto " a " fixed | |
352 | +povolí a zaká¾ou mo¾nost mìnit výkon (pokud je tato vlastnost k dispozici). | |
353 | +.br | |
354 | +.B Pøíklady: | |
355 | +.br | |
356 | +.I " iwconfig eth0 txpower 15" | |
357 | +.br | |
358 | +.I " iwconfig eth0 txpower 30mW" | |
359 | +.br | |
360 | +.I " iwconfig eth0 txpower auto" | |
361 | +.br | |
362 | +.I " iwconfig eth0 txpower off" | |
363 | +.TP | |
364 | +.BR retry | |
365 | +Vìt¹ina karet umí MAC retransmisi a nìkteré umo¾òují nastavit | |
366 | +chování tohoto mechanismu. | |
367 | +.br | |
368 | +pro nastavení maximálního poètu pokusù o zaslání se zadá | |
369 | +.IR "limit `hodnota'" . | |
370 | +Toto je absolutní hodnota (bez jednotky). | |
371 | +Pro nastavení nejdel¹ího období, ve kterém se má MAC pokou¹et o zaslání, se zadá | |
372 | +.IR "lifetime `hodnota'" . | |
373 | +Hodnoty znamenají poèet sekund, pro urèení v milisekundách | |
374 | +nebo mikrosekundách se pou¾ije pøípona m nebo u. | |
375 | +.br | |
376 | +je také mo¾né pøidat modifikátory | |
377 | +.IR min " a " max | |
378 | +. Pokud karta podporuje automatický re¾im, urèují tyto modifikátory rozmezí pro limit nebo lifetime. | |
379 | +Nìkteré karty definují rùzné hodnoty v závislosti na velikosti | |
380 | +paketù, napø. v 802.11 urèuje | |
381 | +.I min limit | |
382 | +tzv. "short retry limit" - limit pro pakety, na které není aplikováno RTS/CTS. | |
383 | +.br | |
384 | +.B Pøíklady: | |
385 | +.br | |
386 | +.I " iwconfig eth0 retry 16" | |
387 | +.br | |
388 | +.I " iwconfig eth0 retry lifetime 300m" | |
389 | +.br | |
390 | +.I " iwconfig eth0 retry min limit 8" | |
391 | +.TP | |
392 | +.BR commit | |
393 | +Nìkteré karty nemusí provést zmìny zadané pøes Wireless Extensions | |
394 | +okam¾itì (mohou èekat na nashromá¾dìní zmìn a pøijmout je | |
395 | +a¾ kdy¾ je karta aktivována pomocí ifconfig). Tento pøíkaz (pokud | |
396 | +je dostupný) pøinutí kartu k pøijetí v¹ech nevyøízených zmìn. | |
397 | +.br | |
398 | +To není vìt¹inou potøeba, proto¾e karta èasem zmìny pøijme, ale mù¾e to | |
399 | +být u¾iteèné pøi ladìní. | |
400 | +.\" | |
401 | +.\" DISPLAY part | |
402 | +.\" | |
403 | +.SH ZOBRAZENÍ | |
404 | +Pro ka¾dé zaøízení, které podporuje wireless extensions, zobrazí | |
405 | +.I iwconfig | |
406 | +název pou¾itého | |
407 | +.B MAC protokolu | |
408 | + (název zaøízení u proprietárních protokolù), | |
409 | +.B ESSID | |
410 | +(Network Name), | |
411 | +.BR NWID , | |
412 | +.B frekvenci | |
413 | +(nebo kanál), | |
414 | +.BR sensitivity | |
415 | +(citlivost), | |
416 | +.B mode | |
417 | +(pracovní re¾im), | |
418 | +.B Access Point | |
419 | +(adresu pøístupového bodu), | |
420 | +.B bit-rate | |
421 | +(pøenosovou rychlost), | |
422 | +.BR "RTS threshold" | |
423 | +(práh RTS), | |
424 | +.BR "fragmentation threshold" | |
425 | +(práh fragmentace), | |
426 | +.B encryption key | |
427 | +(¹ifrovací klíè) a nastavení | |
428 | +.B power management | |
429 | +(øízení spotøeby)(pokud je k dispozici). | |
430 | +.PP | |
431 | +Zobrazené parametry mají stejný význam a hodnoty jako parametry, | |
432 | +které mohou být nastaveny, pro jejich podrobnìj¹í vysvìtlení se prosím | |
433 | +obra»te se na pøedchozí èást. | |
434 | +.br | |
435 | +Nìkteré parametry jsou zobrazeny pouze ve své krátké/zkrácené podobì | |
436 | +(napø. ¹ifrování). Je mo¾né pou¾ít | |
437 | +.IR iwlist (8) | |
438 | +k získání detailù. | |
439 | +.br | |
440 | +Nìkteré parametry mají dva re¾imy (napø. pøenosová rychlost). Pokud | |
441 | +hodnotu uvozuje | |
442 | +.RB ` = ', | |
443 | +znamená to, ¾e parametr je pevný a daný touto hodnotou, pokud | |
444 | +ji uvozuje | |
445 | +.RB ` : ', | |
446 | +je parametr v automatickém re¾imu a je zobrazena aktuální hodnota (a | |
447 | +mù¾e se zmìnit). | |
448 | +.TP | |
449 | +.BR "Access Point" / Cell | |
450 | +Adresa rovná 00:00:00:00:00:00 znamená, ¾e se karta nedokázala asociovat | |
451 | +s pøístupovým bodem (nejspí¹e problém v nastavení). | |
452 | +Parametr | |
453 | +.B Access Point | |
454 | +bude zobrazen jako | |
455 | +.B Cell | |
456 | +v re¾imu ad-hoc (ze zøejmých dùvodù), ale jinak znamená to samé. | |
457 | +.PP | |
458 | +Pokud existuje | |
459 | +.IR "/proc/net/wireless" , | |
460 | +.I iwconfig | |
461 | +se také pokusí zobrazit jeho obsah. Nicménì tyto hodnoty závisí na | |
462 | +ovladaèi a zvlá¹tnostech hardware, tak¾e pro jejich správnou interpretaci je nutné obrátit se na | |
463 | +dokumentaci ovladaèe. | |
464 | +.TP | |
465 | +.B Link quality | |
466 | +Celková kvalita spoje. Mù¾e být zalo¾ena na úrovni ru¹ení | |
467 | +èi interference, poètu chyb na úrovni bitù nebo rámcù, síle pøijímaného | |
468 | +signálu, synchronizaci èasování nebo dal¹ích hardwarových mìøeních. Je to | |
469 | +celková hodnota a zcela zále¾í na ovladaèi a hardware. | |
470 | +.TP | |
471 | +.B Signal level | |
472 | +Received signal strength (RSSI - indikátor síly pøijímaného signálu). | |
473 | +Mù¾e být v libovolných jednotkách nebo dBm, | |
474 | +.I iwconfig | |
475 | +pou¾ívá informace z ovladaèe k interpretaci surových dat v | |
476 | +.I /proc/net/wireless | |
477 | +a zobrazení správné jednotky nebo maximální hodnoty (pomocí 8 bitových výpoètù). V | |
478 | +.I Ad-Hoc | |
479 | +re¾imu mù¾e být nedefinovaná a mìl by být pou¾it | |
480 | +.IR iwspy . | |
481 | +.TP | |
482 | +.B Noise level | |
483 | +Úroveò ¹umu pozadí (kdy¾ není pøená¹en ¾ádný paket). Platí stejné poznámky | |
484 | +jako pro | |
485 | +.BR "Signal level" . | |
486 | +.TP | |
487 | +.B Rx invalid nwid | |
488 | +Poèet pøijatých paketù s odli¹ným NWID nebo ESSID. Pou¾ívá se | |
489 | +k detekci problémù v nastavení nebo existence sousední sítì | |
490 | +(na stejné frekvuenci). | |
491 | +.TP | |
492 | +.B Rx invalid crypt | |
493 | +Poèet paketù, které hardware nedokázal de¹ifrovat. Mù¾e indikovat | |
494 | +neplatné nastavení ¹ifrování. | |
495 | +.TP | |
496 | +.B Rx invalid frag | |
497 | +Poèet paketù, pro které hardware nedokázal správnì znovu sestavit | |
498 | +jednotlivé fragmenty na fyzické vrstvì (nejspí¹e jeden chybìl). | |
499 | +.TP | |
500 | +.B Tx excessive retries | |
501 | +Poèet paketù, které hardware nedokázal odeslat. Vìt¹ina MAC | |
502 | +protokolù zkusí poslat paket nìkolikrát, ne¾ to vzdá. | |
503 | +.TP | |
504 | +.B Invalid misc | |
505 | +Ostatní pakety ztracené v souvislosti s urèitými bezdrátovými operacemi. | |
506 | +.TP | |
507 | +.B Missed beacon | |
508 | +Poèet pravidelných beacons z buòky nebo pøístupového bodu, které nebyly zachyceny. | |
509 | +Beacons jsou vysílány v pravidelných intervalech pro udr¾ení koordinace a | |
510 | +pokud nejsou zachyceny, vìt¹inou to znamená, ¾e je karta mimo dosah. | |
511 | +.\" | |
512 | +.\" AUTHOR part | |
513 | +.\" | |
514 | +.SH AUTOR | |
515 | +Jean Tourrilhes \- jt@hpl.hp.com | |
516 | +.\" | |
517 | +.\" TRANSLATION part | |
518 | +.\" | |
519 | +.SH PØEKLAD | |
520 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
521 | +.\" | |
522 | +.\" FILES part | |
523 | +.\" | |
524 | +.SH SOUBORY | |
525 | +.I /proc/net/wireless | |
526 | +.\" | |
527 | +.\" SEE ALSO part | |
528 | +.\" | |
529 | +.SH DAL©Í INFORMACE | |
530 | +.BR ifconfig (8), | |
531 | +.BR iwspy (8), | |
532 | +.BR iwlist (8), | |
533 | +.BR iwevent (8), | |
534 | +.BR iwpriv (8), | |
535 | +.BR wireless (7). |
@@ -0,0 +1,118 @@ | ||
1 | +.\" Jean Tourrilhes - HPL - 2002 - 2004 | |
2 | +.\" iwevent.8 | |
3 | +.\" | |
4 | +.TH IWEVENT 8 "23.èerven 2004" "net-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iwevent \- Zobrazí bezdrátové události vyvolané ovladaèi a zmìnami nastavení | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTAXE | |
14 | +.BI "iwevent " | |
15 | +.br | |
16 | +.\" | |
17 | +.\" DESCRIPTION part | |
18 | +.\" | |
19 | +.SH POPIS | |
20 | +.B iwevent | |
21 | +zobrazí bezdrátové události pøijaté prostøednictvím socketu RTNetlink. Ka¾dý | |
22 | +øádek zobrazuje jednotlivou bezdrátovou událost popisující, co se stalo | |
23 | +na urèeném bezdrátovém rozhraní. | |
24 | +.br | |
25 | +Tento pøíkaz nemá ¾ádné parametry. | |
26 | +.\" | |
27 | +.\" DISPLAY part | |
28 | +.\" | |
29 | +.SH ZOBRAZENÍ | |
30 | +Jsou dva typy bezdrátových událostí. | |
31 | +.PP | |
32 | +První typ jsou události vztahující se ke zmìnì bezdrátových nastavení na | |
33 | +rozhraní (typicky prostøednictvím | |
34 | +.B iwconfig | |
35 | +nebo skriptu volajícího | |
36 | +.BR iwconfig ). | |
37 | +Jsou oznamována pouze nastavení, která mohou vést k naru¹ení spojení. | |
38 | +V souèasnosti jsou oznamovány události mìnící jedno z následujících | |
39 | +nastavení: | |
40 | +.br | |
41 | +.I " Network ID" | |
42 | +.br | |
43 | +.I " ESSID" | |
44 | +.br | |
45 | +.I " Frequency" | |
46 | +.br | |
47 | +.I " Mode" | |
48 | +.br | |
49 | +.I " Encryption" | |
50 | +.br | |
51 | +V¹echny tyto události jsou generovány na v¹ech bezdrátových rozhraních | |
52 | +bezdrátovým subsystémem jádra (ale jen kdy¾ byl ovladaè pøeveden na | |
53 | +nové API ovladaèù). | |
54 | +.PP | |
55 | +Dal¹ím typem jsou události generované hardwarem, kdy¾ se nìco stane | |
56 | +nebo byl byla dokonèena úloha. Tyto události zahrnují: | |
57 | +.TP | |
58 | +.B New Access Point/Cell address | |
59 | +(nová adresa pøístupového bodu/buòky) Rozhraní se pøipojilo k novému | |
60 | +pøístupovému bodu èi AD-Hoc buòce nebo s ním ztratilo spojení. Je to | |
61 | +stejná MAC adresa, jako hlásí | |
62 | +.BR iwconfig . | |
63 | +.TP | |
64 | +.B Scan request completed | |
65 | +(po¾adavek na skenování dokonèen) Po¾adavek na skenování byl dokonèen, | |
66 | +výsledek je k dispozici (viz | |
67 | +.BR iwlist | |
68 | +). | |
69 | +.TP | |
70 | +.B Tx packet dropped | |
71 | +(vyslaný paket zahozen) Paket smìrovaný na tuto adresu byl zahozen, proto¾e rozhraní se | |
72 | +domnívá, ¾e tento node u¾ neodpovídá (obvykle pokud bylo pøekroèeno maximum | |
73 | +pokusù na úrovni MAC). Toto je obvykle prvotní známka toho, ¾e | |
74 | +node mohl opustit buòku nebo se ocitl mimo dosah, ale mù¾e to být i | |
75 | +zeslabením signálu nebo nadmìrným ru¹ením. | |
76 | +.TP | |
77 | +.B Custom driver event | |
78 | +(Zvlá¹tní událost ovladaèe) Událost specifická pro ovladaè. Prosím prozkoumejte dokumentaci ovladaèe. | |
79 | +.TP | |
80 | +.B Registered node | |
81 | +Rozhraní úspì¹nì zaregistrovalo nového bezdrátového klienta/peer. | |
82 | +Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod | |
83 | +(re¾im master). | |
84 | +.TP | |
85 | +.B Expired node | |
86 | +Registrace klienta/peer na tomto rozhraní vypr¹ela. | |
87 | +Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod | |
88 | +(re¾im master). | |
89 | +.TP | |
90 | +.B Spy threshold crossed | |
91 | +(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 | |
92 | +pøekroèila horní práh. | |
93 | +.PP | |
94 | +Vìt¹ina bezdrátových ovladaèù generuje pouze èást z tìchto událostí, nikoli | |
95 | +v¹echny. Jejich seznam zále¾í na konkrétní kombinaci hardware a ovladaèe. | |
96 | +Pro více informací o vytváøení událostí prosím prozkoumejte dokumentaci | |
97 | +ovladaèe a pou¾ijte | |
98 | +.IR iwlist (8) | |
99 | +k zji¹tìní, co ovladaè podporuje. | |
100 | +.\" | |
101 | +.\" AUTHOR part | |
102 | +.\" | |
103 | +.SH AUTOR | |
104 | +Jean Tourrilhes \- jt@hpl.hp.com | |
105 | +.\" | |
106 | +.\" TRANSLATION part | |
107 | +.\" | |
108 | +.SH PØEKLAD | |
109 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
110 | +.\" | |
111 | +.\" SEE ALSO part | |
112 | +.\" | |
113 | +.SH DAL©Í INFORMACE | |
114 | +.BR iwconfig (8), | |
115 | +.BR iwlist (8), | |
116 | +.BR iwspy (8), | |
117 | +.BR iwpriv (8), | |
118 | +.BR wireless (7). |
@@ -0,0 +1,118 @@ | ||
1 | +.\" Guus Sliepen - 2001 | |
2 | +.\" Doplnil a opravil Jean Tourrilhes - 2002-2003 | |
3 | +.\" iwgetid.8 | |
4 | +.\" | |
5 | +.TH IWGETID 8 "2.prosinec 2003" "wireless-tools" "Linux - Manuál programátora" | |
6 | +.\" | |
7 | +.\" NAME part | |
8 | +.\" | |
9 | +.SH JMÉNO | |
10 | +iwgetid \- Zobrazí ESSID, NWID nebo adresu AP/Cell (pøístupového bodu/buòky) v bezdrátové síti | |
11 | +.\" | |
12 | +.\" SYNOPSIS part | |
13 | +.\" | |
14 | +.SH SYNTAXE | |
15 | +.BI "iwgetid " [interface] " [--raw] [--scheme] [--ap] [--freq]" | |
16 | +.br | |
17 | +.BI " [--mode] [--protocol] [--channel] | |
18 | +.br | |
19 | +.\" | |
20 | +.\" DESCRIPTION part | |
21 | +.\" | |
22 | +.SH POPIS | |
23 | +.B iwgetid | |
24 | +se pou¾ívá k zji¹tìní NWID, ESSID nebo adresy AP/Cell (pøístupového bodu/buòky) | |
25 | +v bezdrátové síti, která je právì vyu¾ívána. Zobrazená informace je stejná jako | |
26 | +ta, kterou ukazuje | |
27 | +.BR iwconfig ", ale " iwgetid | |
28 | +se snadnìji integruje do skriptù. | |
29 | +.br | |
30 | +Jako výchozí, | |
31 | +.B iwgetid | |
32 | +vypí¹e | |
33 | +.I ESSID | |
34 | +zaøízení, pokud zaøízení nemá ¾ádné ESSID, vytiskne jeho | |
35 | +.IR NWID . | |
36 | +.br | |
37 | +Výchozí formát pro výstup je pretty-printing (èlovìkem èitelný). | |
38 | +.\" | |
39 | +.\" OPTIONS part | |
40 | +.\" | |
41 | +.SH VOLBY | |
42 | +.TP | |
43 | +.B --raw | |
44 | +Tento pøepínaè vypne pretty-printing. | |
45 | +Je mo¾né jej kombinovat s ostatními pøepínaèi (s výjimkou | |
46 | +.BR --scheme ), | |
47 | +tak¾e se správnou kombinací pøepínaèù lze vytisknout surové | |
48 | +ESSID, adresu AP nebo Mode. | |
49 | +.br | |
50 | +Tento formát je ideální pro ulo¾ení výsledku iwgetid jako promìnné ve skriptech | |
51 | +.I Shellu | |
52 | +nebo | |
53 | +.I Perlu | |
54 | +nebo pro pøedání výsledku jako parametru pøíkazové øádky pro | |
55 | +.BR iwconfig . | |
56 | +.TP | |
57 | +.B --scheme | |
58 | +Tento pøepínaè je podobný pøedchozímu, vypne pretty-printing | |
59 | +a odstraní v¹echny znaky, které nejsou alfanumerické | |
60 | +(jako mezery, interpunkci a kontrolní znaky). | |
61 | +.br | |
62 | +Výsledný výstup je validní <<\ Pcmcia scheme identifer\ >> (který mù¾e být | |
63 | +pou¾it jako parametr pøíkazu | |
64 | +.BR "cardctl scheme" ). | |
65 | +Tento formát je také ideální, pokud je výsledek iwgetid pou¾it jako volba ve skriptech | |
66 | +.I Shellu | |
67 | +nebo | |
68 | +.I Perlu | |
69 | +nebo jako název souboru. | |
70 | +.TP | |
71 | +.B --ap | |
72 | +Zobrazí MAC adresu bezdrátového | |
73 | +.I Access Point | |
74 | +(pøístupového bodu) nebo | |
75 | +.IR Cell . | |
76 | +(buòky) | |
77 | +.TP | |
78 | +.B --freq | |
79 | +Zobrazí aktuální | |
80 | +.I frequency | |
81 | +(frekvenci) nebo | |
82 | +.I channel | |
83 | +(kanál), pou¾ívaný rozhraním. | |
84 | +.TP | |
85 | +.B --channel | |
86 | +Zobrazí aktuální | |
87 | +.I channel | |
88 | +(kanál), pou¾ívaný rozhraním. Kanál je získán z aktuální frekvence | |
89 | +a seznamu frekvencí dodaného rozhraním. | |
90 | +.TP | |
91 | +.B --mode | |
92 | +Zobrazí aktuální | |
93 | +.I mode | |
94 | +(re¾im) rozhraní. | |
95 | +.TP | |
96 | +.B --protocol | |
97 | +Zobrazí | |
98 | +.I protocol name | |
99 | +(název protokolu) rozhraní. Tak je mo¾né identifikovat v¹echny karty, které | |
100 | +jsou vzájemnì kompatibilní a akceptují stejný typ nastavení. | |
101 | +.br | |
102 | +Je to také mo¾nost jak | |
103 | +.I ovìøit podporu Wireless Extensions | |
104 | +na rozhraní, proto¾e je to jediný atribut, | |
105 | +který v¹echny ovladaèe podporující Wireless Extensions musejí podporovat. | |
106 | +.\" | |
107 | +.\" TRANSLATION part | |
108 | +.\" | |
109 | +.SH PØEKLAD | |
110 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
111 | +.\" | |
112 | +.\" SEE ALSO part | |
113 | +.\" | |
114 | +.SH DAL©Í INFORMACE | |
115 | +.BR iwconfig (8), | |
116 | +.BR ifconfig (8), | |
117 | +.BR iwspy (8), | |
118 | +.BR iwpriv (8). |
@@ -0,0 +1,120 @@ | ||
1 | +.\" Jean II - HPLB - 96 | |
2 | +.\" iwlist.8 | |
3 | +.\" | |
4 | +.TH IWLIST 8 "23.èerven 2004" "wireless-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iwlist \- Získá podrobnìj¹í bezdrátové informace o bezdrátovém rozhraní | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTAXE | |
14 | +.BI "iwlist " rozhraní " scanning" | |
15 | +.br | |
16 | +.BI "iwlist " rozhraní " frequency" | |
17 | +.br | |
18 | +.BI "iwlist " rozhraní " rate" | |
19 | +.br | |
20 | +.BI "iwlist " rozhraní " key" | |
21 | +.br | |
22 | +.BI "iwlist " rozhraní " power" | |
23 | +.br | |
24 | +.BI "iwlist " rozhraní " txpower" | |
25 | +.br | |
26 | +.BI "iwlist " rozhraní " retry" | |
27 | +.br | |
28 | +.BI "iwlist " rozhraní " event" | |
29 | +.br | |
30 | +.BI "iwlist --help" | |
31 | +.br | |
32 | +.BI "iwlist --version" | |
33 | +.\" | |
34 | +.\" DESCRIPTION part | |
35 | +.\" | |
36 | +.SH POPIS | |
37 | +.B Iwlist | |
38 | +se pou¾ívá k zobrazení doplòujících informací o bezdrátovém sí»ovém | |
39 | +rozhraní, které nejsou zobrazovány pøíkazem | |
40 | +.IR iwconfig (8). | |
41 | +Hlavní parametr urèuje typ informace, kterou | |
42 | +.B iwlist | |
43 | +zobrazí v detailní podobì, vèetnì informace, kterou poskytuje | |
44 | +.IR iwconfig (8). | |
45 | +.\" | |
46 | +.\" PARAMETER part | |
47 | +.\" | |
48 | +.SH PARAMETRY | |
49 | +.TP | |
50 | +.BR scan [ning] | |
51 | +Vypí¹e seznam pøístupových bodù a Ad-Hoc buòek v dosahu a | |
52 | +volitelnì i spoustu informací o nich (ESSID, kvalita, | |
53 | +frekvence, re¾im...). Typ zobrazené informace závisí na mo¾nostech karty. | |
54 | +.br | |
55 | +Spu¹tìní skenování je privilegovaná operace (mù¾e ji provést pouze | |
56 | +.RI root | |
57 | +) a normální u¾ivatel mù¾e pouze èíst zbylé výsledky skenování. | |
58 | +Jako výchozí je zpùsob, kterým je skenování provedeno (jeho rozsah) | |
59 | +ovlivnìn aktuálním nastavením ovladaèe. U tohoto pøíkazu se poèítá s dodateènými parametry | |
60 | +pro kontrolu zpùsobu skenování, to ale zatím není implementováno. | |
61 | +.TP | |
62 | +.BR freq [uency]/ channel | |
63 | +Vypí¹e seznam dostupných frekvencí pro zaøízení a poèet definovaných kanálù | |
64 | +Prosím vìnujte pozornost tomu, ¾e ovladaè obvykle vrací | |
65 | +celkový poèet kanálù a pouze frekvence dostupné v aktuálním locale, | |
66 | +tak¾e mezi zobrazenými frekvencemi a èísly kanálù není vztah "jedna k jedné". | |
67 | +.TP | |
68 | +.BR rate / bit [rate] | |
69 | +Vypí¹e pøenosové rychlosti podporované zaøízením. | |
70 | +.TP | |
71 | +.BR key / enc [ryption] | |
72 | +Vypí¹e podporované velikosti ¹ifrovacích klíèù a zobrazí v¹echny ¹ifrovací | |
73 | +klíèe dostupné v zaøízení. | |
74 | +.TP | |
75 | +.B power | |
76 | +Vypí¹e rùzné atributy a re¾imy øízení spotøeby zaøízení. | |
77 | +.TP | |
78 | +.B txpower | |
79 | +vypí¹e dostupné vysílací výkony zaøízení. | |
80 | +.TP | |
81 | +.B retry | |
82 | +vypí¹e limity pro transmit retry a retry lifetime na zaøízení. | |
83 | +.TP | |
84 | +.BR ap / accesspoint / peers | |
85 | +Vypí¹e pøístupové body v dosahu a volitelnì i kvalitu spoje | |
86 | +Tato volba je | |
87 | +.B zastaralá | |
88 | +a je nyní opu¹tìna ve prospìch skenování (viz vý¹e), vìt¹ina | |
89 | +ovladaèù ji nepodporuje. | |
90 | +.br | |
91 | +Nìkteré ovladaèe mohou s tímto pøíkazem vracet zvlá¹tní seznam peerù | |
92 | +nebo pøístupových bodù, jako napø. seznam peerù asociovaních s/registrovaných s | |
93 | +kartou. Více informací obsahuje dokumentace ovladaèù. | |
94 | +.TP | |
95 | +.B event | |
96 | +Vypí¹e bezdrátové události podporované zaøízením. | |
97 | +.TP | |
98 | +.B --version | |
99 | +Zobrazí verzi wireless tools a doporuèenou a aktuální verzi Wireless Extensions | |
100 | +s ohledem na bezdrátové rozhraní. | |
101 | +.\" | |
102 | +.\" TRANSLATION part | |
103 | +.\" | |
104 | +.SH PØEKLAD | |
105 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
106 | +.\" | |
107 | +.\" FILES part | |
108 | +.\" | |
109 | +.SH SOUBORY | |
110 | +.I /proc/net/wireless | |
111 | +.\" | |
112 | +.\" SEE ALSO part | |
113 | +.\" | |
114 | +.SH DAL©Í INFORMACE | |
115 | +.BR iwconfig (8), | |
116 | +.BR iwspy (8). | |
117 | +.BR iwevent (8), | |
118 | +.BR iwpriv (8), | |
119 | +.BR wireless (7). | |
120 | + |
@@ -0,0 +1,136 @@ | ||
1 | +.\" Jean II - HPLB - 96 | |
2 | +.\" iwpriv.8 | |
3 | +.\" | |
4 | +.TH IWPRIV 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iwpriv \- konfiguruje doplòkové (specifické) parametry bezdrátového | |
10 | +sí»ového rozhraní | |
11 | +.\" | |
12 | +.\" SYNOPSIS part | |
13 | +.\" | |
14 | +.SH SYNTAXE | |
15 | +.BI "iwpriv [" rozhraní ] | |
16 | +.br | |
17 | +.BI "iwpriv " "rozhraní specifický-pøíkaz " "[" specifické-parametry ] | |
18 | +.br | |
19 | +.BI "iwpriv " "rozhraní specifický-pøíkaz [I] " "[" specifické-parametry ] | |
20 | +.br | |
21 | +.BI "iwpriv " rozhraní " --all" | |
22 | +.br | |
23 | +.BI "iwpriv " rozhraní " roam " {on,off} | |
24 | +.br | |
25 | +.BI "iwpriv " rozhraní " port " {ad-hoc,managed,N} | |
26 | +.\" | |
27 | +.\" DESCRIPTION part | |
28 | +.\" | |
29 | +.SH POPIS | |
30 | +.B Iwpriv | |
31 | +je doprovodným nástrojem k | |
32 | +.IR iwconfig (8). | |
33 | +.B Iwpriv | |
34 | +pracuje s parametry a nastaveními specifickými pro ka¾dý ovladaè (na rozdíl od | |
35 | +.IR "iwconfig" , | |
36 | +který pracuje s obecnými). | |
37 | +.PP | |
38 | +Bez uvedení parametru | |
39 | +.B iwpriv | |
40 | +vypí¹e specifické pøikazy dostupné na ka¾dém rozhraní a | |
41 | +parametry, které vy¾adují. Pomocí této informace mù¾e u¾ivatel | |
42 | +pou¾ít tyto specifické pøíkazy na urèeném rozhraní. | |
43 | +.PP | |
44 | +Teoreticky by dokumentace ka¾dého ovladaèe mìla uvádìt, jak | |
45 | +pou¾ívat tyto pro rozhraní specifické pøíkazy a jejich úèinek. | |
46 | +.\" | |
47 | +.\" PARAMETER part | |
48 | +.\" | |
49 | +.SH PARAMETRY | |
50 | +.TP | |
51 | +.IR specifický-pøíkaz " [" specifické-parametry ] | |
52 | +Vykoná urèený | |
53 | +.I specifický-pøíkaz | |
54 | +na rozhraní. | |
55 | +.br | |
56 | +Pøíkaz mù¾e pou¾ít nebo vy¾adovat parametry a mù¾e zobrazit informaci. | |
57 | +Parametry tedy mohou i nemusejí být vy¾adovány a mìly by odpovídat tomu, co | |
58 | +pøíkaz oèekává. Seznam pøíkazù, které | |
59 | +.B iwpriv | |
60 | +zobrazí (kdy¾ je volán bez parametrù), by mìl napovìdìt, jak s parametry zacházet. | |
61 | +.br | |
62 | +Nicménì pro informaci o pøíkazech a jejich správném pou¾ití je nejlep¹í | |
63 | +se obrátit na dokumnetaci k ovladaèi zaøízení. | |
64 | +.TP | |
65 | +.I "specifický-pøíkaz [I]" "[" specifické-parametry ] | |
66 | +Viz vý¹e, pouze | |
67 | +.I I | |
68 | +(celé èíslo) je pøedáno pøíkazu jako | |
69 | +.IR "Token Index" . | |
70 | +Token Index pou¾ívají jen nìkteré pøíkazy (vìt¹ina jej ignoruje), kdy jej pou¾ít by | |
71 | +mìla øíci dokumnetace ovladaèe. | |
72 | +.TP | |
73 | +.BR -a / --all | |
74 | +Vykoná a zobrazí v¹echny specifické pøíkazy, které nemají ¾ádné parametry | |
75 | +(tj. pouze ètou). | |
76 | +.TP | |
77 | +.B roam | |
78 | +Povolí nebo zaká¾e roaming, je-li podporován. Volá specifický pøíkaz | |
79 | +.IR setroam , | |
80 | +který je obsa¾en v ovladaèi | |
81 | +.IR "wavelan_cs". | |
82 | +.TP | |
83 | +.B port | |
84 | +Pøeète nebo nastaví druh portu. Volá specifický pøíkaz | |
85 | +.IR gport_type ", " sport_type ", " get_port " nebo " set_port "," | |
86 | +obsa¾ený v ovladaèích | |
87 | +.IR wavelan2_cs " a " wvlan_cs "." | |
88 | +.\" | |
89 | +.\" DISPLAY part | |
90 | +.\" | |
91 | +.SH ZOBRAZENÍ | |
92 | +Pro ka¾dé zaøízení, které podporuje specifické pøíkazy, zobrazí | |
93 | +.I iwpriv | |
94 | +seznam dostupných specifických pøíkazù. | |
95 | +.PP | |
96 | +To zahrnuje název specifického pøíkazu, parametry, které mohou být nastaveny a jejich typ | |
97 | +a parametry které mohou být zobrazeny a jejich typ. | |
98 | +.PP | |
99 | +Napøíklad mù¾e zobrazit : | |
100 | +.br | |
101 | +.B "eth0 Available specific ioctl :" | |
102 | +.br | |
103 | +.B " setqualthr (89F0) : set 1 byte & get 0" | |
104 | +.br | |
105 | +.B " gethisto (89F7) : set 0 & get 16 int" | |
106 | +.PP | |
107 | +To znamená, ¾e je mo¾né nastavit quality threshold a zobrazit | |
108 | +histogram s a¾ 16 hodnotami pomocí tìchto pøíkazù: | |
109 | +.br | |
110 | +.I " iwpriv eth0 setqualthr 20" | |
111 | +.br | |
112 | +.I " iwpriv eth0 gethisto" | |
113 | +.\" | |
114 | +.\" AUTHOR part | |
115 | +.\" | |
116 | +.SH AUTOR | |
117 | +Jean Tourrilhes \- jt@hpl.hp.com | |
118 | +.\" | |
119 | +.\" TRANSLATION part | |
120 | +.\" | |
121 | +.SH PØEKLAD | |
122 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
123 | +.\" | |
124 | +.\" FILES part | |
125 | +.\" | |
126 | +.SH SOUBORY | |
127 | +.I /proc/net/wireless | |
128 | +.\" | |
129 | +.\" SEE ALSO part | |
130 | +.\" | |
131 | +.SH DAL©Í INFORMACE | |
132 | +.BR iwconfig (8), | |
133 | +.BR iwlist (8), | |
134 | +.BR iwevent (8), | |
135 | +.BR iwspy (8), | |
136 | +.BR wireless (7). |
@@ -0,0 +1,111 @@ | ||
1 | +.\" Jean II - HPLB - 96 | |
2 | +.\" iwspy.8 | |
3 | +.\" | |
4 | +.TH IWSPY 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +iwspy \- Získá bezdrátové statistiky o urèených nodech | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTYXE | |
14 | +.BI "iwspy " rozhraní | |
15 | +.br | |
16 | +.BI "iwspy " rozhraní " [+] " DNSNAME " | " IPADDR " | " HWADDR " [...]" | |
17 | +.br | |
18 | +.BI "iwspy " rozhraní " off" | |
19 | +.br | |
20 | +.BI "iwspy " rozhraní " setthr " "low high" | |
21 | +.br | |
22 | +.BI "iwspy " rozhraní " getthr" | |
23 | +.\" | |
24 | +.\" DESCRIPTION part | |
25 | +.\" | |
26 | +.SH POPIS | |
27 | +.B Iwspy | |
28 | +se pou¾ívá k nastavení seznamu sledovaných adres na bezdrátovém sí»ovém rozhraní a | |
29 | +k zpìtnému ètení informací o kvalitì spoje pro ka¾dou z nich. Tyto | |
30 | +informace jsou stejné jako ty uvedené v | |
31 | +.IR "/proc/net/wireless": | |
32 | +kvalita spoje, síla signálu, hladina ¹umu. | |
33 | +.PP | |
34 | +Tyto informace jsou aktualizovány poka¾dé, kdy¾ je pøijat nový paket, tak¾e | |
35 | +ka¾dá adresa na seznamu zvy¹uje zátì¾ ovladaèe. | |
36 | +.PP | |
37 | +Tato funkcionalita platí pouze pro nody v aktuální bezdrátové buòce, není mo¾né | |
38 | +sledovat pøístupové body, se kterými není zaøízení asociováno (k tomu slou¾í skenování) | |
39 | +, ani nody v jiných buòkách. V re¾imu Managed procházejí pakety vìt¹inou pøes pøístupový | |
40 | +bod a v tom pøípadì je získána síla signálu pøístupového bodu. Proto je tato funkce | |
41 | +u¾iteèná víceménì jen v re¾imu Ad-Hoc nebo Master. | |
42 | +.\" | |
43 | +.\" PARAMETER part | |
44 | +.\" | |
45 | +.SH PARAMETRY | |
46 | +Je mo¾né nastavit a¾ 8 adres. | |
47 | +.TP | |
48 | +.BR DNSNAME " | " IPADDR | |
49 | +Nastaví IP adresu nebo, v nìkterých pøípadech, DNS název (pomocí name | |
50 | +resolveru). Proto¾e hardware pracuje s hardwarovými adresami, | |
51 | +.B iwspy | |
52 | +pøelo¾í IP adresu pomocí | |
53 | +.IR ARP . | |
54 | +Mù¾e se stát, ¾e adresa není v ARP cache a | |
55 | +.B iwspy | |
56 | +neuspìje. V tom pøípadì pou¾ijte | |
57 | +.IR ping (8) | |
58 | +na toto jméno/adresu a zkuste to znovu. | |
59 | +.TP | |
60 | +.B HWADDR | |
61 | +Nastaví hardwarovou (MAC) adresu (tato adresa se nepøekládá ani nekontroluje, | |
62 | +na rozdíl od IP adresy). Adresa musí obsahuvat dvojteèky | |
63 | +.RB ( : ) | |
64 | +aby byla uznána za hardwarovou adresu. | |
65 | +.TP | |
66 | +.B + | |
67 | +Pøidá novou sadu adres na konec stávajícího seznamu, místo aby jej nahradil. | |
68 | +Seznam adres je pro ka¾dé zaøízení jedineèný, proto by tato volba mìla být u¾ívána, aby | |
69 | +se zabránilo konfliktùm. | |
70 | +.TP | |
71 | +.B off | |
72 | +Odstraní souèasný seznam adres a vypne sledovací funkci. | |
73 | +.TP | |
74 | +.B setthr | |
75 | +Nastaví | |
76 | +.I low | |
77 | +(spodní) a | |
78 | +.I high | |
79 | +(horní) práh síly signálu, pro spu¹tìní události iwspy (podporuje-li to ovladaè). | |
80 | +.br | |
81 | +Poka¾dé, kdy¾ síla signálu jakékoliv z adres sledované iwspy | |
82 | +poklesne pod spodní práh nebo pøehroèí horní práh, je vygenerována bezdrátová událost. | |
83 | +.br | |
84 | +To je mo¾né pou¾ít ke sledování výpadkù spoje bez nutnosti pravidelného spou¹tìní iwspy. | |
85 | +.TP | |
86 | +.B getthr | |
87 | +Získá aktuální | |
88 | +.I low | |
89 | +(spodní) a | |
90 | +.I high | |
91 | +(horní) práh síly signálu pro událost iwspy. | |
92 | +.\" | |
93 | +.\" TRANSLATION part | |
94 | +.\" | |
95 | +.SH PØEKLAD | |
96 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
97 | +\" | |
98 | +.\" FILES part | |
99 | +.\" | |
100 | +.SH SOUBORY | |
101 | +.I /proc/net/wireless | |
102 | +.\" | |
103 | +.\" SEE ALSO part | |
104 | +.\" | |
105 | +.SH DAL©Í INFORMACE | |
106 | +.BR iwconfig (8), | |
107 | +.BR iwlist (8), | |
108 | +.BR iwevent (8), | |
109 | +.BR iwpriv (8), | |
110 | +.BR wireless (7). | |
111 | + |
@@ -0,0 +1,129 @@ | ||
1 | +.\" Jean Tourrilhes - HPL - 2002 - 2004 | |
2 | +.\" wireless.7 | |
3 | +.\" | |
4 | +.TH WIRELESS 7 "4.duben 2004" "wireless-tools" "Linux - Manuál programátora" | |
5 | +.\" | |
6 | +.\" NAME part | |
7 | +.\" | |
8 | +.SH JMÉNO | |
9 | +wireless \- Wireless Tools a Wireless Extensions | |
10 | +.\" | |
11 | +.\" SYNOPSIS part | |
12 | +.\" | |
13 | +.SH SYNTAXE | |
14 | +.B iwconfig | |
15 | +.br | |
16 | +.B iwpriv \-a | |
17 | +.br | |
18 | +.\" | |
19 | +.\" DESCRIPTION part | |
20 | +.\" | |
21 | +.SH POPIS | |
22 | +.B Wireless Extensions | |
23 | +jsou API, které umo¾òují manipulovat s bezdrátovými sí»ovými rozhraními. | |
24 | +Skládají se ze souboru nástrojù a konfiguraèních souborù. Podrobnìji | |
25 | +jsou popsány v Linux Wireless LAN Howto. | |
26 | +.br | |
27 | +.B Wireless Tools | |
28 | +se pou¾ívají ke zmìnì konfigurace bezdrátových sí»ových rozhraní za bìhu, | |
29 | +k získání jejich aktuální konfigurace, statistik a diagnostice. | |
30 | +Popisují je jejich vlastní manuálové stránky, viz odkazy ní¾e. | |
31 | +.br | |
32 | +.B Nastavení bezdrátového pøipojení | |
33 | +se v ka¾dé distribuci linuxu li¹í. Tato manuálová stránka bude obsahovat | |
34 | +postup nastavení pro nìkolik bì¾ných distribucí. Prozatím se podívejte do | |
35 | +souboru DISTRIBUTIONS.txt, který je souèástí balíèku Wireless Tools. | |
36 | +.\" | |
37 | +.\" DEBIAN 3.0 part | |
38 | +.\" | |
39 | +.SH DEBIAN 3.0 | |
40 | +V Debianu 3.0 (a vy¹¹ím) je mo¾né nastavit bezdrátová sí»ová zaøízení | |
41 | +nástrojem pro nastavení sítì | |
42 | +.BR ifupdown (8). | |
43 | +.TP | |
44 | +.B Soubor: | |
45 | +.I /etc/network/interfaces | |
46 | +.TP | |
47 | +.B Forma: | |
48 | +.RI wireless\- "<funkce> <hodnota>" | |
49 | +.br | |
50 | +wireless\-essid Home | |
51 | +.br | |
52 | +wireless\-mode Ad\-Hoc | |
53 | +.TP | |
54 | +.B Dal¹í informace: | |
55 | +.I /etc/network/if\-pre\-up.d/wireless\-tools | |
56 | +.br | |
57 | +.I /usr/share/doc/wireless\-tools/README.Debian | |
58 | +.\" | |
59 | +.\" SuSE 8.0 part | |
60 | +.\" | |
61 | +.SH SuSE 8.0 | |
62 | +SuSE 8.0 (a vy¹¹í) integrovalo nastavení bezdrátového pøipojení do svých | |
63 | +sí»ových skriptù. | |
64 | +.TP | |
65 | +.B Nástroj: | |
66 | +.B Yast2 | |
67 | +.TP | |
68 | +.B Soubor: | |
69 | +.I /etc/sysconfig/network/wireless | |
70 | +.br | |
71 | +.I /etc/sysconfig/network/ifcfg\-* | |
72 | +.TP | |
73 | +.B Forma: | |
74 | +.RI WIRELESS_ "<funkce>" = "<hodnota>" | |
75 | +.br | |
76 | +WIRELESS_ESSID="Home" | |
77 | +.br | |
78 | +WIRELESS_MODE=Ad\-Hoc | |
79 | +.TP | |
80 | +.B Dal¹í informace: | |
81 | +man ifup | |
82 | +.br | |
83 | +info scpm | |
84 | +.\" | |
85 | +.\" PCMCIA part | |
86 | +.\" | |
87 | +.SH PÙVODNÍ PCMCIA SKRIPTY | |
88 | +Pokud pou¾íváte pùvodní konfiguraèní skripty z balíèku Pcmcia, | |
89 | +Mù¾ete pou¾ít tuto metodu. | |
90 | +.TP | |
91 | +.B Soubor: | |
92 | +.I /etc/pcmcia/wireless.opts | |
93 | +.TP | |
94 | +.B Forma: | |
95 | +*,*,*,*) | |
96 | +.br | |
97 | +ESSID="Home" | |
98 | +.br | |
99 | +MODE="Ad-Hoc" | |
100 | +.br | |
101 | +;; | |
102 | +.TP | |
103 | +.B Dal¹í informace: | |
104 | +.I /etc/pcmcia/wireless | |
105 | +.br | |
106 | +Soubor | |
107 | +.IR "PCMCIA.txt" , | |
108 | +který je souèástí balíèku Wireless Tools | |
109 | +.\" | |
110 | +.\" AUTHOR part | |
111 | +.\" | |
112 | +.SH AUTOR | |
113 | +Jean Tourrilhes \- jt@hpl.hp.com | |
114 | +.br | |
115 | +.I http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/ | |
116 | +.\" | |
117 | +.\" TRANSLATION part | |
118 | +.\" | |
119 | +.SH PØEKLAD | |
120 | +Pavel Heimlich \- tropikhajma@seznam.cz, bøezen 2005 (wireless_tools.28pre4). | |
121 | +.\" | |
122 | +.\" SEE ALSO part | |
123 | +.\" | |
124 | +.SH DAL©Í INFORMACE | |
125 | +.BR iwconfig (8), | |
126 | +.BR iwlist (8), | |
127 | +.BR iwspy (8), | |
128 | +.BR iwpriv (8), | |
129 | +.BR iwevent (8). |
@@ -88,8 +88,23 @@ printed. | ||
88 | 88 | When used with |
89 | 89 | .IR -i , |
90 | 90 | specify the new name of the interface. The list of mappings from the |
91 | -configuration file is bypassed. The new name may be a wildcard | |
92 | -containing a single '*'. | |
91 | +configuration file is bypassed, the interface specified with | |
92 | +.I -i | |
93 | +is renamed directly to | |
94 | +.IR newname . | |
95 | +The new name may be a wildcard containing a single '*'. | |
96 | +.br | |
97 | +When used without | |
98 | +.IR -i , | |
99 | +rename interfaces by using only mappings that would rename them to | |
100 | +.IR newname . | |
101 | +The new name may not be a wildcard. This use of ifrename is | |
102 | +discouraged, because inefficient | |
103 | +.RI ( -n " without " -i ). | |
104 | +All the interfaces of the system need to be processed at each | |
105 | +invocation, therefore in most case it is not faster than just letting | |
106 | +ifrename renaming all of them (without both | |
107 | +.IR -n " and " -i ). | |
93 | 108 | .TP |
94 | 109 | .B -t |
95 | 110 | Enable name takeover support. This allow interface name swapping |
@@ -22,21 +22,20 @@ | ||
22 | 22 | * Subject to the Gnu Public License, version 2. |
23 | 23 | * TODO: make it support token ring etc. |
24 | 24 | * $Id: nameif.c,v 1.3 2003/03/06 23:26:52 ecki Exp $ |
25 | - * Add hotplug compatibility : ifname -i eth0. Jean II - 03.12.03 | |
26 | - * Add MAC address wildcard : 01:23:45:*. Jean II - 03.12.03 | |
27 | - * Add interface name wildcard : wlan*. Jean II - 03.12.03 | |
28 | - * Add interface name probing for modular systems. Jean II - 18.02.03 | |
29 | 25 | * ------------------------------------------------------- |
30 | 26 | * |
31 | - * The last 4 patches never made it into the regular version of | |
32 | - * 'nameif', and had some 'issues', which is the reason of this rewrite. | |
27 | + * It started with a series of patches to nameif which never made | |
28 | + * into the regular version, and had some architecural 'issues' with | |
29 | + * those patches, which is the reason of this rewrite. | |
33 | 30 | * Difference with standard 'nameif' : |
34 | 31 | * o 'nameif' has only a single selector, the interface MAC address. |
35 | 32 | * o Modular selector architecture, easily add new selectors. |
33 | + * o Wide range of selector, including sysfs... | |
36 | 34 | * o hotplug invocation support. |
37 | 35 | * o module loading support. |
38 | 36 | * o MAC address wildcard. |
39 | 37 | * o Interface name wildcard ('eth*' or 'wlan*'). |
38 | + * o Non-Ethernet MAC addresses (any size, not just 48 bits) | |
40 | 39 | */ |
41 | 40 | |
42 | 41 | /***************************** INCLUDES *****************************/ |
@@ -81,11 +80,13 @@ const int SELECT_BASEADDR = 7; /* Select by HW Base Address */ | ||
81 | 80 | const int SELECT_IRQ = 8; /* Select by HW Irq line */ |
82 | 81 | const int SELECT_INTERRUPT = 9; /* Select by HW Irq line */ |
83 | 82 | const int SELECT_IWPROTO = 10; /* Select by Wireless Protocol */ |
84 | -const int SELECT_PCMCIASLOT = 11; /* Select by Wireless Protocol */ | |
85 | -#define SELECT_NUM 12 | |
83 | +const int SELECT_PCMCIASLOT = 11; /* Select by Pcmcia Slot */ | |
84 | +const int SELECT_SYSFS = 12; /* Select by sysfs file */ | |
85 | +#define SELECT_NUM 13 | |
86 | 86 | |
87 | 87 | #define HAS_MAC_EXACT 1 |
88 | 88 | #define HAS_MAC_FILTER 2 |
89 | +#define MAX_MAC_LEN 16 /* Maximum lenght of MAC address */ | |
89 | 90 | |
90 | 91 | const struct ether_addr zero_mac = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; |
91 | 92 |
@@ -107,6 +108,29 @@ const struct option long_opt[] = | ||
107 | 108 | #define PCMCIA_STAB1 "/var/lib/pcmcia/stab" |
108 | 109 | #define PCMCIA_STAB2 "/var/run/stab" |
109 | 110 | |
111 | +/* Max number of sysfs file we support */ | |
112 | +#define SYSFS_MAX_FILE 5 | |
113 | + | |
114 | +/* Userspace headers lag, fix that... */ | |
115 | +#ifndef ARPHRD_IEEE1394 | |
116 | +#define ARPHRD_IEEE1394 24 | |
117 | +#endif | |
118 | +#ifndef ARPHRD_EUI64 | |
119 | +#define ARPHRD_EUI64 27 | |
120 | +#endif | |
121 | +#ifndef ARPHRD_IRDA | |
122 | +#define ARPHRD_IRDA 783 | |
123 | +#endif | |
124 | + | |
125 | +/* Length of various non-standard MAC addresses */ | |
126 | +const int weird_mac_len[][2] = | |
127 | +{ | |
128 | + { ARPHRD_IEEE1394, 8 }, | |
129 | + { ARPHRD_EUI64, 8 }, | |
130 | + { ARPHRD_IRDA, 4 }, | |
131 | +}; | |
132 | +const int weird_mac_len_num = sizeof(weird_mac_len) / sizeof(weird_mac_len[0]); | |
133 | + | |
110 | 134 | /****************************** TYPES ******************************/ |
111 | 135 | |
112 | 136 | /* Cut'n'paste from ethtool.h */ |
@@ -141,8 +165,9 @@ typedef struct if_mapping | ||
141 | 165 | int active[SELECT_NUM]; /* Selectors active */ |
142 | 166 | |
143 | 167 | /* Selector data */ |
144 | - struct ether_addr mac; /* Exact MAC address, hex */ | |
145 | - char mac_filter[6*3 + 1]; /* WildCard, ascii */ | |
168 | + unsigned char mac[MAX_MAC_LEN]; /* Exact MAC address, hex */ | |
169 | + int mac_len; /* Length (usually 6) */ | |
170 | + char mac_filter[16*3 + 1]; /* WildCard, ascii */ | |
146 | 171 | unsigned short hw_type; /* Link/ARP type */ |
147 | 172 | char driver[32]; /* driver short name */ |
148 | 173 | char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */ |
@@ -151,13 +176,22 @@ typedef struct if_mapping | ||
151 | 176 | unsigned char irq; /* HW irq line */ |
152 | 177 | char iwproto[IFNAMSIZ + 1]; /* Wireless/protocol name */ |
153 | 178 | int pcmcia_slot; /* Pcmcia slot */ |
154 | -} if_mapping; | |
179 | + char * sysfs[SYSFS_MAX_FILE]; /* sysfs selectors */ | |
180 | +} if_mapping; | |
181 | + | |
182 | +/* Extra parsing information when adding a mapping */ | |
183 | +typedef struct add_extra | |
184 | +{ | |
185 | + char * modif_pos; /* Descriptor modifier */ | |
186 | + size_t modif_len; | |
187 | +} parsing_extra; | |
155 | 188 | |
156 | 189 | /* Prototype for adding a selector to a mapping. Return -1 if invalid value. */ |
157 | 190 | typedef int (*mapping_add)(struct if_mapping * ifnode, |
158 | 191 | int * active, |
159 | 192 | char * pos, |
160 | 193 | size_t len, |
194 | + struct add_extra * extra, | |
161 | 195 | int linenum); |
162 | 196 | |
163 | 197 | /* Prototype for comparing the selector of two mapping. Return 0 if matches. */ |
@@ -178,6 +212,15 @@ typedef struct mapping_selector | ||
178 | 212 | mapping_get get_fn; |
179 | 213 | } mapping_selector; |
180 | 214 | |
215 | +/* sysfs global data */ | |
216 | +typedef struct sysfs_metadata | |
217 | +{ | |
218 | + char * root; /* Root of the sysfs */ | |
219 | + int rlen; /* Size of it */ | |
220 | + int filenum; /* Number of files */ | |
221 | + char * filename[SYSFS_MAX_FILE]; /* Name of files */ | |
222 | +} sysfs_metadata; | |
223 | + | |
181 | 224 | /**************************** PROTOTYPES ****************************/ |
182 | 225 | |
183 | 226 | static int |
@@ -185,6 +228,7 @@ static int | ||
185 | 228 | int * active, |
186 | 229 | char * pos, |
187 | 230 | size_t len, |
231 | + struct add_extra * extra, | |
188 | 232 | int linenum); |
189 | 233 | static int |
190 | 234 | mapping_cmpmac(struct if_mapping * ifnode, |
@@ -199,6 +243,7 @@ static int | ||
199 | 243 | int * active, |
200 | 244 | char * pos, |
201 | 245 | size_t len, |
246 | + struct add_extra * extra, | |
202 | 247 | int linenum); |
203 | 248 | static int |
204 | 249 | mapping_cmparp(struct if_mapping * ifnode, |
@@ -213,6 +258,7 @@ static int | ||
213 | 258 | int * active, |
214 | 259 | char * pos, |
215 | 260 | size_t len, |
261 | + struct add_extra * extra, | |
216 | 262 | int linenum); |
217 | 263 | static int |
218 | 264 | mapping_cmpdriver(struct if_mapping * ifnode, |
@@ -222,6 +268,7 @@ static int | ||
222 | 268 | int * active, |
223 | 269 | char * pos, |
224 | 270 | size_t len, |
271 | + struct add_extra * extra, | |
225 | 272 | int linenum); |
226 | 273 | static int |
227 | 274 | mapping_cmpbusinfo(struct if_mapping * ifnode, |
@@ -231,6 +278,7 @@ static int | ||
231 | 278 | int * active, |
232 | 279 | char * pos, |
233 | 280 | size_t len, |
281 | + struct add_extra * extra, | |
234 | 282 | int linenum); |
235 | 283 | static int |
236 | 284 | mapping_cmpfirmware(struct if_mapping * ifnode, |
@@ -245,6 +293,7 @@ static int | ||
245 | 293 | int * active, |
246 | 294 | char * pos, |
247 | 295 | size_t len, |
296 | + struct add_extra * extra, | |
248 | 297 | int linenum); |
249 | 298 | static int |
250 | 299 | mapping_cmpbaseaddr(struct if_mapping * ifnode, |
@@ -254,6 +303,7 @@ static int | ||
254 | 303 | int * active, |
255 | 304 | char * pos, |
256 | 305 | size_t len, |
306 | + struct add_extra * extra, | |
257 | 307 | int linenum); |
258 | 308 | static int |
259 | 309 | mapping_cmpirq(struct if_mapping * ifnode, |
@@ -268,6 +318,7 @@ static int | ||
268 | 318 | int * active, |
269 | 319 | char * pos, |
270 | 320 | size_t len, |
321 | + struct add_extra * extra, | |
271 | 322 | int linenum); |
272 | 323 | static int |
273 | 324 | mapping_cmpiwproto(struct if_mapping * ifnode, |
@@ -282,6 +333,7 @@ static int | ||
282 | 333 | int * active, |
283 | 334 | char * pos, |
284 | 335 | size_t len, |
336 | + struct add_extra * extra, | |
285 | 337 | int linenum); |
286 | 338 | static int |
287 | 339 | mapping_cmppcmciaslot(struct if_mapping * ifnode, |
@@ -291,6 +343,21 @@ static int | ||
291 | 343 | const char * ifname, |
292 | 344 | struct if_mapping * target, |
293 | 345 | int flag); |
346 | +static int | |
347 | + mapping_addsysfs(struct if_mapping * ifnode, | |
348 | + int * active, | |
349 | + char * pos, | |
350 | + size_t len, | |
351 | + struct add_extra * extra, | |
352 | + int linenum); | |
353 | +static int | |
354 | + mapping_cmpsysfs(struct if_mapping * ifnode, | |
355 | + struct if_mapping * target); | |
356 | +static int | |
357 | + mapping_getsysfs(int skfd, | |
358 | + const char * ifname, | |
359 | + struct if_mapping * target, | |
360 | + int flag); | |
294 | 361 | |
295 | 362 | /**************************** VARIABLES ****************************/ |
296 | 363 |
@@ -321,6 +388,8 @@ const struct mapping_selector selector_list[] = | ||
321 | 388 | { "iwproto", &mapping_addiwproto, &mapping_cmpiwproto, &mapping_getiwproto }, |
322 | 389 | /* Pcmcia slot from cardmgr */ |
323 | 390 | { "pcmciaslot", &mapping_addpcmciaslot, &mapping_cmppcmciaslot, &mapping_getpcmciaslot }, |
391 | + /* sysfs file (udev emulation) */ | |
392 | + { "sysfs", &mapping_addsysfs, &mapping_cmpsysfs, &mapping_getsysfs }, | |
324 | 393 | /* The Terminator */ |
325 | 394 | { NULL, NULL, NULL, NULL }, |
326 | 395 | }; |
@@ -329,6 +398,17 @@ const int selector_num = sizeof(selector_list)/sizeof(selector_list[0]); | ||
329 | 398 | /* List of active selectors */ |
330 | 399 | int selector_active[SELECT_NUM]; /* Selectors active */ |
331 | 400 | |
401 | +/* | |
402 | + * All the following flags are controlled by the command line switches... | |
403 | + * It's a bit hackish to have them all as global, so maybe we should pass | |
404 | + * them in a big struct as function arguments... More complex and | |
405 | + * probably not worth it ? | |
406 | + */ | |
407 | + | |
408 | +/* Invocation type */ | |
409 | +int print_newname = 0; | |
410 | +char * new_name = NULL; | |
411 | + | |
332 | 412 | /* Takeover support */ |
333 | 413 | int force_takeover = 0; /* Takeover name from other interface */ |
334 | 414 | int num_takeover = 0; /* Number of takeover done */ |
@@ -339,6 +419,13 @@ int dry_run = 0; /* Just print new name, don't rename */ | ||
339 | 419 | /* Verbose support (i.e. debugging) */ |
340 | 420 | int verbose = 0; |
341 | 421 | |
422 | +/* sysfs global data */ | |
423 | +struct sysfs_metadata sysfs_global = | |
424 | +{ | |
425 | + NULL, 0, | |
426 | + 0, { NULL, NULL, NULL, NULL, NULL }, | |
427 | +}; | |
428 | + | |
342 | 429 | /******************** INTERFACE NAME MANAGEMENT ********************/ |
343 | 430 | /* |
344 | 431 | * Bunch of low level function for managing interface names. |
@@ -515,10 +602,14 @@ mapping_addmac(struct if_mapping * ifnode, | ||
515 | 602 | int * active, |
516 | 603 | char * string, |
517 | 604 | size_t len, |
605 | + struct add_extra * extra, | |
518 | 606 | int linenum) |
519 | 607 | { |
520 | 608 | size_t n; |
521 | 609 | |
610 | + /* Avoid "Unused parameter" warning */ | |
611 | + extra = extra; | |
612 | + | |
522 | 613 | /* Verify validity of string */ |
523 | 614 | if(len >= sizeof(ifnode->mac_filter)) |
524 | 615 | { |
@@ -547,7 +638,9 @@ mapping_addmac(struct if_mapping * ifnode, | ||
547 | 638 | else |
548 | 639 | { |
549 | 640 | /* Not a wildcard : "01:23:45:67:89:AB" */ |
550 | - if(iw_ether_aton(ifnode->mac_filter, &ifnode->mac) != 1) | |
641 | + ifnode->mac_len = iw_mac_aton(ifnode->mac_filter, | |
642 | + ifnode->mac, MAX_MAC_LEN); | |
643 | + if(ifnode->mac_len == 0) | |
551 | 644 | { |
552 | 645 | fprintf(stderr, "Error: Invalid MAC address `%s' at line %d\n", |
553 | 646 | ifnode->mac_filter, linenum); |
@@ -555,7 +648,7 @@ mapping_addmac(struct if_mapping * ifnode, | ||
555 | 648 | } |
556 | 649 | |
557 | 650 | /* Check that it's not NULL */ |
558 | - if(!memcmp(&ifnode->mac, &zero_mac, 6)) | |
651 | + if((ifnode->mac_len == 6) && (!memcmp(&ifnode->mac, &zero_mac, 6))) | |
559 | 652 | { |
560 | 653 | fprintf(stderr, |
561 | 654 | "Warning: MAC address is null at line %d, this is dangerous...\n", |
@@ -590,8 +683,8 @@ mapping_cmpmac(struct if_mapping * ifnode, | ||
590 | 683 | return(fnmatch(ifnode->mac_filter, target->mac_filter, FNM_CASEFOLD)); |
591 | 684 | else |
592 | 685 | /* Exact matching, in hex */ |
593 | - return(memcmp(&ifnode->mac.ether_addr_octet, &target->mac.ether_addr_octet, | |
594 | - 6)); | |
686 | + return((ifnode->mac_len != target->mac_len) || | |
687 | + memcmp(ifnode->mac, target->mac, ifnode->mac_len)); | |
595 | 688 | } |
596 | 689 | |
597 | 690 | /*------------------------------------------------------------------*/ |
@@ -604,10 +697,14 @@ mapping_getmac(int skfd, | ||
604 | 697 | struct if_mapping * target, |
605 | 698 | int flag) |
606 | 699 | { |
607 | - int ret; | |
700 | + struct ifreq ifr; | |
701 | + int ret; | |
702 | + int i; | |
608 | 703 | |
609 | - /* Extract MAC address */ | |
610 | - ret = iw_get_mac_addr(skfd, ifname, &target->mac, &target->hw_type); | |
704 | + /* Get MAC address */ | |
705 | + bzero(&ifr, sizeof(struct ifreq)); | |
706 | + strncpy(ifr.ifr_name, ifname, IFNAMSIZ); | |
707 | + ret = ioctl(skfd, SIOCGIFHWADDR, &ifr); | |
611 | 708 | if(ret < 0) |
612 | 709 | { |
613 | 710 | fprintf(stderr, "Error: Can't read MAC address on interface `%s' : %s\n", |
@@ -615,11 +712,25 @@ mapping_getmac(int skfd, | ||
615 | 712 | return(-1); |
616 | 713 | } |
617 | 714 | |
715 | + /* Extract ARP type */ | |
716 | + target->hw_type = ifr.ifr_hwaddr.sa_family; | |
717 | + /* Calculate address length */ | |
718 | + target->mac_len = 6; | |
719 | + for(i = 0; i < weird_mac_len_num; i++) | |
720 | + if(weird_mac_len[i][0] == ifr.ifr_hwaddr.sa_family) | |
721 | + { | |
722 | + target->mac_len = weird_mac_len[i][1]; | |
723 | + break; | |
724 | + } | |
725 | + /* Extract MAC address bytes */ | |
726 | + memcpy(target->mac, ifr.ifr_hwaddr.sa_data, target->mac_len); | |
727 | + | |
618 | 728 | /* Check the type of comparison */ |
619 | 729 | if((flag == HAS_MAC_FILTER) || verbose) |
620 | 730 | { |
621 | 731 | /* Convert to ASCII */ |
622 | - iw_ether_ntop(&target->mac, target->mac_filter); | |
732 | + iw_mac_ntop(target->mac, target->mac_len, | |
733 | + target->mac_filter, sizeof(target->mac_filter)); | |
623 | 734 | } |
624 | 735 | |
625 | 736 | target->active[SELECT_MAC] = flag; |
@@ -642,11 +753,15 @@ mapping_addarp(struct if_mapping * ifnode, | ||
642 | 753 | int * active, |
643 | 754 | char * string, |
644 | 755 | size_t len, |
756 | + struct add_extra * extra, | |
645 | 757 | int linenum) |
646 | 758 | { |
647 | 759 | size_t n; |
648 | 760 | unsigned int type; |
649 | 761 | |
762 | + /* Avoid "Unused parameter" warning */ | |
763 | + extra = extra; | |
764 | + | |
650 | 765 | /* Verify validity of string, convert to int */ |
651 | 766 | n = strspn(string, "0123456789"); |
652 | 767 | if((n < len) || (sscanf(string, "%d", &type) != 1)) |
@@ -705,12 +820,16 @@ mapping_adddriver(struct if_mapping * ifnode, | ||
705 | 820 | int * active, |
706 | 821 | char * string, |
707 | 822 | size_t len, |
823 | + struct add_extra * extra, | |
708 | 824 | int linenum) |
709 | 825 | { |
826 | + /* Avoid "Unused parameter" warning */ | |
827 | + extra = extra; | |
828 | + | |
710 | 829 | /* Plain string, minimal verification */ |
711 | 830 | if(len >= sizeof(ifnode->driver)) |
712 | 831 | { |
713 | - fprintf(stderr, "Driver name too long at line %d\n", linenum); | |
832 | + fprintf(stderr, "Error: Driver name too long at line %d\n", linenum); | |
714 | 833 | return(-1); |
715 | 834 | } |
716 | 835 |
@@ -750,12 +869,16 @@ mapping_addbusinfo(struct if_mapping * ifnode, | ||
750 | 869 | int * active, |
751 | 870 | char * string, |
752 | 871 | size_t len, |
872 | + struct add_extra * extra, | |
753 | 873 | int linenum) |
754 | 874 | { |
755 | 875 | #if 0 |
756 | 876 | size_t n; |
757 | 877 | #endif |
758 | 878 | |
879 | + /* Avoid "Unused parameter" warning */ | |
880 | + extra = extra; | |
881 | + | |
759 | 882 | /* Verify validity of string */ |
760 | 883 | if(len >= sizeof(ifnode->bus_info)) |
761 | 884 | { |
@@ -809,8 +932,12 @@ mapping_addfirmware(struct if_mapping * ifnode, | ||
809 | 932 | int * active, |
810 | 933 | char * string, |
811 | 934 | size_t len, |
935 | + struct add_extra * extra, | |
812 | 936 | int linenum) |
813 | 937 | { |
938 | + /* Avoid "Unused parameter" warning */ | |
939 | + extra = extra; | |
940 | + | |
814 | 941 | /* Verify validity of string */ |
815 | 942 | if(len >= sizeof(ifnode->fw_version)) |
816 | 943 | { |
@@ -913,11 +1040,15 @@ mapping_addbaseaddr(struct if_mapping * ifnode, | ||
913 | 1040 | int * active, |
914 | 1041 | char * string, |
915 | 1042 | size_t len, |
1043 | + struct add_extra * extra, | |
916 | 1044 | int linenum) |
917 | 1045 | { |
918 | 1046 | size_t n; |
919 | 1047 | unsigned int address; |
920 | 1048 | |
1049 | + /* Avoid "Unused parameter" warning */ | |
1050 | + extra = extra; | |
1051 | + | |
921 | 1052 | /* Verify validity of string */ |
922 | 1053 | n = strspn(string, "0123456789ABCDEFabcdefx"); |
923 | 1054 | if((n < len) || (sscanf(string, "0x%X", &address) != 1)) |
@@ -963,11 +1094,15 @@ mapping_addirq(struct if_mapping * ifnode, | ||
963 | 1094 | int * active, |
964 | 1095 | char * string, |
965 | 1096 | size_t len, |
1097 | + struct add_extra * extra, | |
966 | 1098 | int linenum) |
967 | 1099 | { |
968 | 1100 | size_t n; |
969 | 1101 | unsigned int irq; |
970 | 1102 | |
1103 | + /* Avoid "Unused parameter" warning */ | |
1104 | + extra = extra; | |
1105 | + | |
971 | 1106 | /* Verify validity of string */ |
972 | 1107 | n = strspn(string, "0123456789"); |
973 | 1108 | if((n < len) || (sscanf(string, "%d", &irq) != 1)) |
@@ -1068,8 +1203,12 @@ mapping_addiwproto(struct if_mapping * ifnode, | ||
1068 | 1203 | int * active, |
1069 | 1204 | char * string, |
1070 | 1205 | size_t len, |
1206 | + struct add_extra * extra, | |
1071 | 1207 | int linenum) |
1072 | 1208 | { |
1209 | + /* Avoid "Unused parameter" warning */ | |
1210 | + extra = extra; | |
1211 | + | |
1073 | 1212 | /* Verify validity of string */ |
1074 | 1213 | if(len >= sizeof(ifnode->iwproto)) |
1075 | 1214 | { |
@@ -1144,13 +1283,17 @@ mapping_getiwproto(int skfd, | ||
1144 | 1283 | */ |
1145 | 1284 | static int |
1146 | 1285 | mapping_addpcmciaslot(struct if_mapping * ifnode, |
1147 | - int * active, | |
1148 | - char * string, | |
1149 | - size_t len, | |
1150 | - int linenum) | |
1286 | + int * active, | |
1287 | + char * string, | |
1288 | + size_t len, | |
1289 | + struct add_extra * extra, | |
1290 | + int linenum) | |
1151 | 1291 | { |
1152 | 1292 | size_t n; |
1153 | 1293 | |
1294 | + /* Avoid "Unused parameter" warning */ | |
1295 | + extra = extra; | |
1296 | + | |
1154 | 1297 | /* Verify validity of string, convert to int */ |
1155 | 1298 | n = strspn(string, "0123456789"); |
1156 | 1299 | if((n < len) || (sscanf(string, "%d", &ifnode->pcmcia_slot) != 1)) |
@@ -1176,7 +1319,7 @@ mapping_addpcmciaslot(struct if_mapping * ifnode, | ||
1176 | 1319 | */ |
1177 | 1320 | static int |
1178 | 1321 | mapping_cmppcmciaslot(struct if_mapping * ifnode, |
1179 | - struct if_mapping * target) | |
1322 | + struct if_mapping * target) | |
1180 | 1323 | { |
1181 | 1324 | return(!(ifnode->pcmcia_slot == target->pcmcia_slot)); |
1182 | 1325 | } |
@@ -1290,10 +1433,259 @@ mapping_getpcmciaslot(int skfd, | ||
1290 | 1433 | |
1291 | 1434 | /* Cleanup */ |
1292 | 1435 | free(linebuf); |
1436 | + fclose(stream); | |
1293 | 1437 | |
1294 | 1438 | return(target->active[SELECT_PCMCIASLOT] ? 0 : -1); |
1295 | 1439 | } |
1296 | 1440 | |
1441 | +/*------------------------------------------------------------------*/ | |
1442 | +/* | |
1443 | + * Add a sysfs selector to a mapping | |
1444 | + */ | |
1445 | +static int | |
1446 | +mapping_addsysfs(struct if_mapping * ifnode, | |
1447 | + int * active, | |
1448 | + char * string, | |
1449 | + size_t len, | |
1450 | + struct add_extra * extra, | |
1451 | + int linenum) | |
1452 | +{ | |
1453 | + int findex; /* filename index */ | |
1454 | + char * sdup; | |
1455 | + | |
1456 | + /* Check if we have a modifier */ | |
1457 | + if((extra == NULL) || (extra->modif_pos == NULL)) | |
1458 | + { | |
1459 | + fprintf(stderr, "Error: No SYSFS filename at line %d\n", linenum); | |
1460 | + return(-1); | |
1461 | + } | |
1462 | + | |
1463 | + /* Search if the filename already exist */ | |
1464 | + for(findex = 0; findex < sysfs_global.filenum; findex++) | |
1465 | + { | |
1466 | + if(!strcmp(extra->modif_pos, sysfs_global.filename[findex])) | |
1467 | + break; | |
1468 | + } | |
1469 | + | |
1470 | + /* If filename does not exist, creates it */ | |
1471 | + if(findex == sysfs_global.filenum) | |
1472 | + { | |
1473 | + if(findex == SYSFS_MAX_FILE) | |
1474 | + { | |
1475 | + fprintf(stderr, "Error: Too many SYSFS filenames at line %d\n", linenum); | |
1476 | + return(-1); | |
1477 | + } | |
1478 | + sdup = strndup(extra->modif_pos, extra->modif_len); | |
1479 | + if(sdup == NULL) | |
1480 | + { | |
1481 | + fprintf(stderr, "Error: Can't allocate SYSFS file\n"); | |
1482 | + return(-1); | |
1483 | + } | |
1484 | + sysfs_global.filename[findex] = sdup; | |
1485 | + sysfs_global.filenum++; | |
1486 | + } | |
1487 | + | |
1488 | + /* Store value */ | |
1489 | + sdup = strndup(string, len); | |
1490 | + if(sdup == NULL) | |
1491 | + { | |
1492 | + fprintf(stderr, "Error: Can't allocate SYSFS value\n"); | |
1493 | + return(-1); | |
1494 | + } | |
1495 | + ifnode->sysfs[findex] = sdup; | |
1496 | + | |
1497 | + /* Activate */ | |
1498 | + ifnode->active[SELECT_SYSFS] = 1; | |
1499 | + active[SELECT_SYSFS] = 1; | |
1500 | + | |
1501 | + if(verbose) | |
1502 | + fprintf(stderr, | |
1503 | + "Parsing : Added SYSFS filename `%s' value `%s' from line %d.\n", | |
1504 | + sysfs_global.filename[findex], ifnode->sysfs[findex], linenum); | |
1505 | + | |
1506 | + return(0); | |
1507 | +} | |
1508 | + | |
1509 | +/*------------------------------------------------------------------*/ | |
1510 | +/* | |
1511 | + * Compare all the sysfs values of two mappings | |
1512 | + */ | |
1513 | +static int | |
1514 | +mapping_cmpsysfs(struct if_mapping * ifnode, | |
1515 | + struct if_mapping * target) | |
1516 | +{ | |
1517 | + int findex; /* filename index */ | |
1518 | + int match = 1; | |
1519 | + | |
1520 | + /* Loop on all sysfs selector */ | |
1521 | + for(findex = 0; findex < sysfs_global.filenum; findex++) | |
1522 | + { | |
1523 | + /* If the mapping defines this sysfs selector.. */ | |
1524 | + if(ifnode->sysfs[findex] != NULL) | |
1525 | + /* And if the sysfs values don't match */ | |
1526 | + if((target->sysfs[findex] == NULL) || | |
1527 | + (fnmatch(ifnode->sysfs[findex], target->sysfs[findex], | |
1528 | + FNM_CASEFOLD))) | |
1529 | + /* Then the sysfs selector doesn't match */ | |
1530 | + match = 0; | |
1531 | + } | |
1532 | + | |
1533 | + return(!match); | |
1534 | +} | |
1535 | + | |
1536 | +/*------------------------------------------------------------------*/ | |
1537 | +/* | |
1538 | + * Extract all the sysfs values of an interface | |
1539 | + */ | |
1540 | +static int | |
1541 | +mapping_getsysfs(int skfd, | |
1542 | + const char * ifname, | |
1543 | + struct if_mapping * target, | |
1544 | + int flag) | |
1545 | +{ | |
1546 | + FILE * stream; | |
1547 | + char * linebuf = NULL; | |
1548 | + size_t linelen = 0; | |
1549 | + char * sdup; | |
1550 | + int findex; /* filename index */ | |
1551 | + | |
1552 | + /* Avoid "Unused parameter" warning */ | |
1553 | + skfd = skfd; | |
1554 | + flag = flag; | |
1555 | + | |
1556 | + /* Check if we know the root of the sysfs filesystem */ | |
1557 | + if(sysfs_global.root == NULL) | |
1558 | + { | |
1559 | + /* Open the mount file for reading */ | |
1560 | + stream = fopen("/proc/mounts", "r"); | |
1561 | + if(!stream) | |
1562 | + { | |
1563 | + fprintf(stderr, "Error: Can't open /proc/mounts file: %s\n", | |
1564 | + strerror(errno)); | |
1565 | + return(-1); | |
1566 | + } | |
1567 | + | |
1568 | + /* Read each line of file | |
1569 | + * getline is a GNU extension :-( The buffer is recycled and increased | |
1570 | + * as needed by getline. */ | |
1571 | + while(getline(&linebuf, &linelen, stream) > 0) | |
1572 | + { | |
1573 | + char * p; | |
1574 | + size_t n; | |
1575 | + | |
1576 | + /* Get the line starting with sysfs */ | |
1577 | + p = linebuf; | |
1578 | + while(isspace(*p)) | |
1579 | + ++p; | |
1580 | + if(!strncasecmp(p, "sysfs ", 6)) | |
1581 | + { | |
1582 | + /* Find the mount point */ | |
1583 | + p += 6; | |
1584 | + while(isspace(*p)) | |
1585 | + ++p; | |
1586 | + n = strcspn(p, " \t\n"); | |
1587 | + sdup = strndup(p, n); | |
1588 | + if((n == 0) || (sdup == NULL)) | |
1589 | + { | |
1590 | + fprintf(stderr, "Error: Can't parse /proc/mounts file: %s\n", | |
1591 | + strerror(errno)); | |
1592 | + return(-1); | |
1593 | + } | |
1594 | + /* Store it */ | |
1595 | + sysfs_global.root = sdup; | |
1596 | + sysfs_global.rlen = n; | |
1597 | + break; | |
1598 | + } | |
1599 | + /* Finished -> next line */ | |
1600 | + } | |
1601 | + | |
1602 | + /* Cleanup */ | |
1603 | + fclose(stream); | |
1604 | + | |
1605 | + /* Check if we found it */ | |
1606 | + if(sysfs_global.root == NULL) | |
1607 | + { | |
1608 | + fprintf(stderr, "Error: Can't find sysfs in /proc/mounts file\n"); | |
1609 | + free(linebuf); | |
1610 | + return(-1); | |
1611 | + } | |
1612 | + } | |
1613 | + | |
1614 | + /* Loop on all sysfs selector */ | |
1615 | + for(findex = 0; findex < sysfs_global.filenum; findex++) | |
1616 | + { | |
1617 | + char * fname; | |
1618 | + int flen; | |
1619 | + char * p; | |
1620 | + ssize_t n; | |
1621 | + | |
1622 | + /* Construct complete filename for the sysfs selector */ | |
1623 | + flen = (sysfs_global.rlen + 11 + strlen(ifname) + 1 + | |
1624 | + strlen(sysfs_global.filename[findex]) + 1); | |
1625 | + fname = malloc(flen); | |
1626 | + if(fname == NULL) | |
1627 | + { | |
1628 | + fprintf(stderr, "Error: Can't allocate SYSFS filename\n"); | |
1629 | + free(linebuf); | |
1630 | + return(-1); | |
1631 | + } | |
1632 | + sprintf(fname, "%s/class/net/%s/%s", sysfs_global.root, ifname, | |
1633 | + sysfs_global.filename[findex]); | |
1634 | + | |
1635 | + /* Open the sysfs file for reading */ | |
1636 | + stream = fopen(fname, "r"); | |
1637 | + if(!stream) | |
1638 | + { | |
1639 | + /* Some sysfs attribute may no exist for some interface */ | |
1640 | + if(verbose) | |
1641 | + fprintf(stderr, "Error: Can't open file `%s': %s\n", fname, | |
1642 | + strerror(errno)); | |
1643 | + /* Next sysfs selector */ | |
1644 | + continue; | |
1645 | + } | |
1646 | + | |
1647 | + /* Read file. Only one line in file. */ | |
1648 | + n = getline(&linebuf, &linelen, stream); | |
1649 | + fclose(stream); | |
1650 | + if(n <= 0) | |
1651 | + { | |
1652 | + /* Some sysfs attribute are void for some interface */ | |
1653 | + if(verbose) | |
1654 | + fprintf(stderr, "Error: Can't read file `%s'\n", fname); | |
1655 | + /* Next sysfs selector */ | |
1656 | + continue; | |
1657 | + } | |
1658 | + | |
1659 | + /* Get content, remove trailing '/n', save it */ | |
1660 | + p = linebuf; | |
1661 | + if(p[n - 1] == '\n') | |
1662 | + n--; | |
1663 | + sdup = strndup(p, n); | |
1664 | + if(sdup == NULL) | |
1665 | + { | |
1666 | + fprintf(stderr, "Error: Can't allocate SYSFS value\n"); | |
1667 | + free(linebuf); | |
1668 | + return(-1); | |
1669 | + } | |
1670 | + target->sysfs[findex] = sdup; | |
1671 | + | |
1672 | + /* Activate */ | |
1673 | + target->active[SELECT_SYSFS] = 1; | |
1674 | + | |
1675 | + if(verbose) | |
1676 | + fprintf(stderr, | |
1677 | + "Querying %s : Got SYSFS filename `%s' value `%s'.\n", | |
1678 | + ifname, sysfs_global.filename[findex], target->sysfs[findex]); | |
1679 | + | |
1680 | + /* Finished : Next sysfs selector */ | |
1681 | + } | |
1682 | + | |
1683 | + /* Cleanup */ | |
1684 | + free(linebuf); | |
1685 | + | |
1686 | + return(target->active[SELECT_SYSFS] ? 0 : -1); | |
1687 | +} | |
1688 | + | |
1297 | 1689 | |
1298 | 1690 | /*********************** MAPPING MANAGEMENTS ***********************/ |
1299 | 1691 | /* |
@@ -1334,8 +1726,11 @@ mapping_create(char * pos, | ||
1334 | 1726 | memcpy(ifnode->ifname, pos, len); |
1335 | 1727 | ifnode->ifname[len] = '\0'; |
1336 | 1728 | |
1337 | - /* Check the interface name and issue various pedantic warnings */ | |
1338 | - if((!strcmp(ifnode->ifname, "eth0")) || (!strcmp(ifnode->ifname, "wlan0"))) | |
1729 | + /* Check the interface name and issue various pedantic warnings. | |
1730 | + * We assume people using takeover want to force interfaces to those | |
1731 | + * names and know what they are doing, so don't bother them... */ | |
1732 | + if((!force_takeover) && | |
1733 | + ((!strcmp(ifnode->ifname, "eth0")) || (!strcmp(ifnode->ifname, "wlan0")))) | |
1339 | 1734 | fprintf(stderr, |
1340 | 1735 | "Warning: Interface name is `%s' at line %d, can't be mapped reliably.\n", |
1341 | 1736 | ifnode->ifname, linenum); |
@@ -1433,10 +1828,11 @@ selector_find(const char * string, | ||
1433 | 1828 | static int |
1434 | 1829 | mapping_readfile(const char * filename) |
1435 | 1830 | { |
1436 | - FILE * stream; | |
1437 | - char * linebuf = NULL; | |
1438 | - size_t linelen = 0; | |
1439 | - int linenum = 0; | |
1831 | + FILE * stream; | |
1832 | + char * linebuf = NULL; | |
1833 | + size_t linelen = 0; | |
1834 | + int linenum = 0; | |
1835 | + struct add_extra extrainfo; | |
1440 | 1836 | |
1441 | 1837 | /* Reset the list of filters */ |
1442 | 1838 | bzero(selector_active, sizeof(selector_active)); |
@@ -1497,9 +1893,10 @@ mapping_readfile(const char * filename) | ||
1497 | 1893 | while(*p != '\0') |
1498 | 1894 | { |
1499 | 1895 | const struct mapping_selector * selector = NULL; |
1896 | + struct add_extra * extra = NULL; | |
1500 | 1897 | |
1501 | - /* Selector name length */ | |
1502 | - n = strcspn(p, " \t\n"); | |
1898 | + /* Selector name length - stop at modifier start */ | |
1899 | + n = strcspn(p, " \t\n{"); | |
1503 | 1900 | |
1504 | 1901 | /* Find it */ |
1505 | 1902 | selector = selector_find(p, n, linenum); |
@@ -1508,9 +1905,33 @@ mapping_readfile(const char * filename) | ||
1508 | 1905 | ret = -1; |
1509 | 1906 | break; |
1510 | 1907 | } |
1908 | + p += n; | |
1909 | + | |
1910 | + /* Check for modifier */ | |
1911 | + if(*p == '{') | |
1912 | + { | |
1913 | + p++; | |
1914 | + /* Find end of modifier */ | |
1915 | + e = strchr(p, '}'); | |
1916 | + if(e == NULL) | |
1917 | + { | |
1918 | + fprintf(stderr, | |
1919 | + "Error: unterminated selector modifier value on line %d\n", | |
1920 | + linenum); | |
1921 | + ret = -1; | |
1922 | + break; /* Line ended */ | |
1923 | + } | |
1924 | + /* Fill in struct and hook it */ | |
1925 | + extrainfo.modif_pos = p; | |
1926 | + extrainfo.modif_len = e - p; | |
1927 | + extra = &extrainfo; | |
1928 | + /* Terminate modifier value */ | |
1929 | + e[0] = '\0'; | |
1930 | + /* Skip it */ | |
1931 | + p = e + 1; | |
1932 | + } | |
1511 | 1933 | |
1512 | 1934 | /* Get to selector value */ |
1513 | - p += n; | |
1514 | 1935 | p += strspn(p, " \t\n"); |
1515 | 1936 | if(*p == '\0') |
1516 | 1937 | { |
@@ -1548,7 +1969,8 @@ mapping_readfile(const char * filename) | ||
1548 | 1969 | p[n] = '\0'; |
1549 | 1970 | |
1550 | 1971 | /* Add it to the mapping */ |
1551 | - ret = selector->add_fn(ifnode, selector_active, p, n, linenum); | |
1972 | + ret = selector->add_fn(ifnode, selector_active, p, n, | |
1973 | + extra, linenum); | |
1552 | 1974 | if(ret < 0) |
1553 | 1975 | break; |
1554 | 1976 |
@@ -1683,8 +2105,7 @@ static void | ||
1683 | 2105 | probe_mappings(int skfd) |
1684 | 2106 | { |
1685 | 2107 | struct if_mapping * ifnode; |
1686 | - struct ether_addr mac; /* Exact MAC address, hex */ | |
1687 | - unsigned short hw_type; | |
2108 | + struct ifreq ifr; | |
1688 | 2109 | |
1689 | 2110 | /* Look over all our mappings */ |
1690 | 2111 | for(ifnode = mapping_list; ifnode != NULL; ifnode = ifnode->next) |
@@ -1703,7 +2124,8 @@ probe_mappings(int skfd) | ||
1703 | 2124 | * Obviously, we expect this command to 'fail', as |
1704 | 2125 | * the interface will load with the old/wrong name. |
1705 | 2126 | */ |
1706 | - iw_get_mac_addr(skfd, ifnode->ifname, &mac, &hw_type); | |
2127 | + strncpy(ifr.ifr_name, ifnode->ifname, IFNAMSIZ); | |
2128 | + ioctl(skfd, SIOCGIFHWADDR, &ifr); | |
1707 | 2129 | } |
1708 | 2130 | } |
1709 | 2131 |
@@ -1720,8 +2142,7 @@ probe_debian(int skfd) | ||
1720 | 2142 | FILE * stream; |
1721 | 2143 | char * linebuf = NULL; |
1722 | 2144 | size_t linelen = 0; |
1723 | - struct ether_addr mac; /* Exact MAC address, hex */ | |
1724 | - unsigned short hw_type; | |
2145 | + struct ifreq ifr; | |
1725 | 2146 | |
1726 | 2147 | /* Open Debian config file */ |
1727 | 2148 | stream = fopen(DEBIAN_CONFIG_FILE, "r"); |
@@ -1769,8 +2190,9 @@ probe_debian(int skfd) | ||
1769 | 2190 | fprintf(stderr, "Probing : Trying to load interface [%s]\n", |
1770 | 2191 | p); |
1771 | 2192 | |
1772 | - /* Do it ! */ | |
1773 | - iw_get_mac_addr(skfd, p, &mac, &hw_type); | |
2193 | + /* Load interface */ | |
2194 | + strncpy(ifr.ifr_name, p, IFNAMSIZ); | |
2195 | + ioctl(skfd, SIOCGIFHWADDR, &ifr); | |
1774 | 2196 | |
1775 | 2197 | /* Go to next interface name */ |
1776 | 2198 | p = e; |
@@ -1824,7 +2246,6 @@ process_rename(int skfd, | ||
1824 | 2246 | star[1] = 'd'; |
1825 | 2247 | } |
1826 | 2248 | |
1827 | - | |
1828 | 2249 | /* Change the name of the interface */ |
1829 | 2250 | if(if_set_name(skfd, ifname, newname, retname) < 0) |
1830 | 2251 | { |
@@ -1869,6 +2290,11 @@ process_ifname(int skfd, | ||
1869 | 2290 | if(mapping == NULL) |
1870 | 2291 | return(-1); |
1871 | 2292 | |
2293 | + /* If user specified a new name, keep only interfaces that would | |
2294 | + * match the new name... */ | |
2295 | + if((new_name != NULL) && (if_match_ifname(mapping->ifname, new_name) != 0)) | |
2296 | + return(-1); | |
2297 | + | |
1872 | 2298 | /* Check if user want only dry-run. |
1873 | 2299 | * Note that, in the case of wildcard, we don't resolve the wildcard. |
1874 | 2300 | * That would be tricky to do... */ |
@@ -1888,7 +2314,7 @@ process_ifname(int skfd, | ||
1888 | 2314 | } |
1889 | 2315 | |
1890 | 2316 | /* Check if called with an explicit interface name */ |
1891 | - if(!count) | |
2317 | + if(print_newname) | |
1892 | 2318 | { |
1893 | 2319 | /* Always print out the *new* interface name so that |
1894 | 2320 | * the calling script can pick it up and know where its interface |
@@ -1953,7 +2379,6 @@ main(int argc, | ||
1953 | 2379 | { |
1954 | 2380 | const char * conf_file = DEFAULT_CONF; |
1955 | 2381 | char * ifname = NULL; |
1956 | - char * newname = NULL; | |
1957 | 2382 | int use_probe = 0; |
1958 | 2383 | int is_debian = 0; |
1959 | 2384 | int skfd; |
@@ -1984,7 +2409,7 @@ main(int argc, | ||
1984 | 2409 | ifname = optarg; |
1985 | 2410 | break; |
1986 | 2411 | case 'n': |
1987 | - newname = optarg; | |
2412 | + new_name = optarg; | |
1988 | 2413 | break; |
1989 | 2414 | case 'p': |
1990 | 2415 | use_probe = 1; |
@@ -2013,13 +2438,13 @@ main(int argc, | ||
2013 | 2438 | } |
2014 | 2439 | |
2015 | 2440 | /* Check if interface name was specified with -i. */ |
2016 | - if(ifname) | |
2441 | + if(ifname != NULL) | |
2017 | 2442 | { |
2018 | 2443 | /* Check is target name specified */ |
2019 | - if(newname != NULL) | |
2444 | + if(new_name != NULL) | |
2020 | 2445 | { |
2021 | 2446 | /* User want to simply rename an interface to a specified name */ |
2022 | - ret = process_rename(skfd, ifname, newname); | |
2447 | + ret = process_rename(skfd, ifname, new_name); | |
2023 | 2448 | } |
2024 | 2449 | else |
2025 | 2450 | { |
@@ -2028,6 +2453,7 @@ main(int argc, | ||
2028 | 2453 | * Process the network interface specified on the command line, |
2029 | 2454 | * and return the new name on stdout. |
2030 | 2455 | */ |
2456 | + print_newname = 1; | |
2031 | 2457 | ret = process_ifname(skfd, ifname, NULL, 0); |
2032 | 2458 | } |
2033 | 2459 | } |
@@ -2045,7 +2471,7 @@ main(int argc, | ||
2045 | 2471 | /* Rename all system interfaces |
2046 | 2472 | * Mostly used for boot time processing (from init scripts). |
2047 | 2473 | */ |
2048 | - ret = process_iflist(skfd, &newname, 1); | |
2474 | + ret = process_iflist(skfd, NULL, 0); | |
2049 | 2475 | } |
2050 | 2476 | |
2051 | 2477 | /* Cleanup */ |
@@ -66,11 +66,28 @@ attempt to change the name of the interface to the interface name | ||
66 | 66 | given by the mapping. |
67 | 67 | .PP |
68 | 68 | The interface name of a mapping is either a plain interface name (such as |
69 | -.IR eth2 " or " wlan0 ) | |
69 | +.IR eth2 " or " wlan1 ) | |
70 | 70 | or a interface name pattern containing a single wildcard (such as |
71 | 71 | .IR eth* " or " wlan* ). |
72 | 72 | In case of wildcard, the kernel replace the '*' with the lowest |
73 | -available integer making this interface name unique. | |
73 | +available integer making this interface name unique. Note that | |
74 | +wildcard is only supported for kernel 2.6.1 and 2.4.30 and later. | |
75 | +.PP | |
76 | +It is discouraged to try to map interfaces to default interfaces names | |
77 | +such as | |
78 | +.IR eth0 ", " wlan0 " or " ppp0 . | |
79 | +The kernel use those as the default name for any new interface, | |
80 | +therefore most likely an interface will already use this name and | |
81 | +prevent ifrename to use it. Even if you use takeover, the interface | |
82 | +may already be up in some cases. Not using those name will allow you | |
83 | +to immediately spot unconfigured or new interfaces. | |
84 | +.br | |
85 | +Good names are either totally unique and meaningfull, | |
86 | +such as | |
87 | +.IR mydsl " or " privatehub , | |
88 | +or use larger integer, such as | |
89 | +.IR eth5 " or " wlan5 . | |
90 | +The second type is usually easier to integrate in various network utilities. | |
74 | 91 | .\" |
75 | 92 | .\" DESCRIPTORS part |
76 | 93 | .\" |
@@ -156,6 +173,18 @@ using | ||
156 | 173 | This selector is usually only supported on 16 bits cards, for 32 bits |
157 | 174 | cards it is advised to use the selector |
158 | 175 | .BR businfo . |
176 | +.TP | |
177 | +.BI SYSFS{ filename } " value" | |
178 | +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 | |
179 | +.IR /sys/class/net/ . | |
180 | +For example, the filename | |
181 | +.I address | |
182 | +is the MAC address of the device and should be identical to the selector | |
183 | +.BR mac . | |
184 | +.br | |
185 | +The sysfs filesystem is only supported with 2.6.X kernel and need to | |
186 | +be mounted. sysfs selectors are not as efficient as other selectors, | |
187 | +therefore they should be avoided for maximum performance. | |
159 | 188 | .\" |
160 | 189 | .\" EXAMPLE part |
161 | 190 | .\" |
@@ -169,6 +198,8 @@ eth3 driver wavelan interrupt 15 baseaddress 0x390 | ||
169 | 198 | eth4 driver pcnet32 businfo 0000:02:05.0 |
170 | 199 | .br |
171 | 200 | air* mac 00:07:0E:* arp 1 |
201 | +.br | |
202 | +myvpn SYSFS{address} 00:10:83:* | |
172 | 203 | .\" |
173 | 204 | .\" AUTHOR part |
174 | 205 | .\" |
@@ -1,7 +1,7 @@ | ||
1 | 1 | .\" Jean II - HPLB - 1996 => HPL - 2004 |
2 | 2 | .\" iwconfig.8 |
3 | 3 | .\" |
4 | -.TH IWCONFIG 8 "22 June 2004" "wireless-tools" "Linux Programmer's Manual" | |
4 | +.TH IWCONFIG 8 "09 March 2006" "wireless-tools" "Linux Programmer's Manual" | |
5 | 5 | .\" |
6 | 6 | .\" NAME part |
7 | 7 | .\" |
@@ -13,9 +13,9 @@ iwconfig \- configure a wireless network interface | ||
13 | 13 | .SH SYNOPSIS |
14 | 14 | .BI "iwconfig [" interface ] |
15 | 15 | .br |
16 | -.BI "iwconfig " interface " [essid " X "] [nwid " N "] [freq " F "] [channel " C ] | |
16 | +.BI "iwconfig " interface " [essid " X "] [nwid " N "] [mode " M "] [freq " F "] | |
17 | 17 | .br |
18 | -.BI " [sens " S "] [mode " M "] [ap " A "] [nick " NN ] | |
18 | +.BI " [channel " C ] [sens " S "] [ap " A "] [nick " NN ] | |
19 | 19 | .br |
20 | 20 | .BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ] |
21 | 21 | .br |
@@ -64,11 +64,19 @@ promiscuous) with | ||
64 | 64 | .IR off " or " any " (and " on |
65 | 65 | to reenable it). |
66 | 66 | .br |
67 | +If the ESSID of your network is one of the special keywords | |
68 | +.RI ( off ", " on " or " any ), | |
69 | +you should use | |
70 | +.I -- | |
71 | +to escape it. | |
72 | +.br | |
67 | 73 | .B Examples : |
68 | 74 | .br |
69 | 75 | .I " iwconfig eth0 essid any" |
70 | 76 | .br |
71 | 77 | .I " iwconfig eth0 essid ""My Network"" |
78 | +.br | |
79 | +.I " iwconfig eth0 essid -- ""ANY"" | |
72 | 80 | .TP |
73 | 81 | .BR nwid / domain |
74 | 82 | Set the Network ID (in some products it may also be called Domain |
@@ -90,42 +98,15 @@ to reenable it). | ||
90 | 98 | .br |
91 | 99 | .I " iwconfig eth0 nwid off" |
92 | 100 | .TP |
93 | -.BR freq / channel | |
94 | -Set the operating frequency or channel in the device. A value below | |
95 | -1000 indicates a channel number, a value greater than 1000 is a | |
96 | -frequency in Hz. You may append the suffix k, M or G to the value (for | |
97 | -example, "2.46G" for 2.46 GHz frequency), or add enough '0'. | |
98 | -.br | |
99 | -Channels are usually numbered starting at 1, and you may use | |
100 | -.IR iwlist (8) | |
101 | -to get the total number of channels, list the available frequencies, | |
102 | -and display the current frequency as a channel. Depending on | |
103 | -regulations, some frequencies/channels may not be available. | |
104 | -.br | |
105 | -.B Examples : | |
106 | -.br | |
107 | -.I " iwconfig eth0 freq 2422000000" | |
108 | -.br | |
109 | -.I " iwconfig eth0 freq 2.422G" | |
110 | -.br | |
111 | -.I " iwconfig eth0 channel 3" | |
112 | -.TP | |
113 | -.B sens | |
114 | -Set the sensitivity threshold. This is the lowest signal level for | |
115 | -which the hardware attempt packet reception, signals weaker than this | |
116 | -are ignored. This is used to avoid receiving background noise, so you | |
117 | -should set it according to the average noise level. Positive values | |
118 | -are assumed to be the raw value used by the hardware or a percentage, | |
119 | -negative values are assumed to be dBm. | |
120 | -.br | |
121 | -With some hardware, this parameter also controls the defer threshold | |
122 | -(lowest signal level for which the hardware consider the channel busy) | |
123 | -and the handover threshold (signal level where the hardware start | |
124 | -looking for a new access point). | |
101 | +.BR nick [name] | |
102 | +Set the nickname, or the station name. Some 802.11 products do define | |
103 | +it, but this is not used as far as the protocols (MAC, IP, TCP) are | |
104 | +concerned and completely useless as far as configuration goes. Only | |
105 | +some wireless diagnostic tools may use it. | |
125 | 106 | .br |
126 | 107 | .B Example : |
127 | 108 | .br |
128 | -.I " iwconfig eth0 sens -80" | |
109 | +.I " iwconfig eth0 nickname ""My Linux Node"" | |
129 | 110 | .TP |
130 | 111 | .B mode |
131 | 112 | Set the operating mode of the device, which depends on the network |
@@ -141,7 +122,8 @@ topology. The mode can be | ||
141 | 122 | .I Secondary |
142 | 123 | (the node acts as a backup master/repeater), |
143 | 124 | .I Monitor |
144 | -(the node acts as a passive monitor and only receives packets) or | |
125 | +(the node is not associated with any cell and passively monitor all | |
126 | +packets on the frequency) or | |
145 | 127 | .IR Auto . |
146 | 128 | .br |
147 | 129 | .B Example : |
@@ -150,11 +132,50 @@ topology. The mode can be | ||
150 | 132 | .br |
151 | 133 | .I " iwconfig eth0 mode Ad-Hoc" |
152 | 134 | .TP |
135 | +.BR freq / channel | |
136 | +Set the operating frequency or channel in the device. A value below | |
137 | +1000 indicates a channel number, a value greater than 1000 is a | |
138 | +frequency in Hz. You may append the suffix k, M or G to the value (for | |
139 | +example, "2.46G" for 2.46 GHz frequency), or add enough '0'. | |
140 | +.br | |
141 | +Channels are usually numbered starting at 1, and you may use | |
142 | +.IR iwlist (8) | |
143 | +to get the total number of channels, list the available frequencies, | |
144 | +and display the current frequency as a channel. Depending on | |
145 | +regulations, some frequencies/channels may not be available. | |
146 | +.br | |
147 | +When using Managed mode, most often the Access Point dictates the | |
148 | +channel and the driver may refuse the setting of the frequency. In | |
149 | +Ad-Hoc mode, the frequency setting may only be used at initial cell | |
150 | +creation, and may be ignored when joining an existing cell. | |
151 | +.br | |
152 | +You may also use | |
153 | +.I off | |
154 | +or | |
155 | +.I auto | |
156 | +to let the card pick up the best channel (when supported). | |
157 | +.br | |
158 | +.B Examples : | |
159 | +.br | |
160 | +.I " iwconfig eth0 freq 2422000000" | |
161 | +.br | |
162 | +.I " iwconfig eth0 freq 2.422G" | |
163 | +.br | |
164 | +.I " iwconfig eth0 channel 3" | |
165 | +.br | |
166 | +.I " iwconfig eth0 channel auto" | |
167 | +.TP | |
153 | 168 | .B ap |
154 | 169 | Force the card to register to the Access Point given by the address, |
155 | -if it is possible. When the quality of the connection goes too low, | |
156 | -the driver may revert back to automatic mode (the card selects the | |
157 | -best Access Point in range). | |
170 | +if it is possible. This address is the cell identity of the Access | |
171 | +Point, as reported by wireless scanning, which may be different from | |
172 | +its network MAC address. If the wireless link is point to point, set | |
173 | +the address of the other end of the link. If the link is ad-hoc, set | |
174 | +the cell identity of the ad-hoc network. | |
175 | +.br | |
176 | +When the quality of the connection goes too low, the driver may revert | |
177 | +back to automatic mode (the card selects the best Access Point in | |
178 | +range). | |
158 | 179 | .br |
159 | 180 | You may also use |
160 | 181 | .I off |
@@ -173,16 +194,6 @@ to force the card to reassociate with the currently best Access Point. | ||
173 | 194 | .br |
174 | 195 | .I " iwconfig eth0 ap off" |
175 | 196 | .TP |
176 | -.BR nick [name] | |
177 | -Set the nickname, or the station name. Some 802.11 products do define | |
178 | -it, but this is not used as far as the protocols (MAC, IP, TCP) are | |
179 | -concerned and completely useless as far as configuration goes. Only | |
180 | -some diagnostic tools may use it. | |
181 | -.br | |
182 | -.B Example : | |
183 | -.br | |
184 | -.I " iwconfig eth0 nickname ""My Linux Node"" | |
185 | -.TP | |
186 | 197 | .BR rate / bit [rate] |
187 | 198 | For cards supporting multiple bit rates, set the bit-rate in b/s. The |
188 | 199 | 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. | ||
208 | 219 | .br |
209 | 220 | .I " iwconfig eth0 rate 5.5M auto" |
210 | 221 | .TP |
222 | +.BR txpower | |
223 | +For cards supporting multiple transmit powers, sets the transmit power | |
224 | +in dBm. If | |
225 | +.I W | |
226 | +is the power in Watt, the power in dBm is | |
227 | +.IR "P = 30 + 10.log(W)" . | |
228 | +If the value is postfixed by | |
229 | +.IR mW , | |
230 | +it will be automatically converted to dBm. | |
231 | +.br | |
232 | +In addition, | |
233 | +.IR on " and " off | |
234 | +enable and disable the radio, and | |
235 | +.IR auto " and " fixed | |
236 | +enable and disable power control (if those features are available). | |
237 | +.br | |
238 | +.B Examples : | |
239 | +.br | |
240 | +.I " iwconfig eth0 txpower 15" | |
241 | +.br | |
242 | +.I " iwconfig eth0 txpower 30mW" | |
243 | +.br | |
244 | +.I " iwconfig eth0 txpower auto" | |
245 | +.br | |
246 | +.I " iwconfig eth0 txpower off" | |
247 | +.TP | |
248 | +.B sens | |
249 | +Set the sensitivity threshold. This define how sensitive is the card | |
250 | +to poor operating conditions (low signal, interference). Positive | |
251 | +values are assumed to be the raw value used by the hardware or a | |
252 | +percentage, negative values are assumed to be dBm. Depending on the | |
253 | +hardware implementation, this parameter may control various functions. | |
254 | +.br | |
255 | +On modern cards, this parameter usually control handover/roaming | |
256 | +threshold, the lowest signal level for which the hardware remains | |
257 | +associated with the current Access Point. When the signal level goes | |
258 | +below this threshold the card starts looking for a new/better Access | |
259 | +Point. Some cards may use the number of missed beacons to trigger | |
260 | +this. For high density of Access Points, a higher threshold make sure | |
261 | +the card is always associated with the best AP, for low density of | |
262 | +APs, a lower threshold minimise the number of failed handoffs. | |
263 | +.br | |
264 | +On more ancient card this parameter usually controls the defer | |
265 | +threshold, the lowest signal level for which the hardware considers | |
266 | +the channel busy. Signal levels above this threshold make the hardware | |
267 | +inhibits its own transmission whereas signals weaker than this are | |
268 | +ignored and the hardware is free to transmit. This is usually strongly | |
269 | +linked to the receive threshold, the lowest signal level for which the | |
270 | +hardware attempts packet reception. Proper setting of these thresholds | |
271 | +prevent the card to waste time on background noise while still | |
272 | +receiving weak transmissions. Modern designs seems to control those | |
273 | +thresholds automatically. | |
274 | +.br | |
275 | +.br | |
276 | +.B Example : | |
277 | +.br | |
278 | +.I " iwconfig eth0 sens -80" | |
279 | +.br | |
280 | +.I " iwconfig eth0 sens 2" | |
281 | +.TP | |
282 | +.BR retry | |
283 | +Most cards have MAC retransmissions, and some allow to set the | |
284 | +behaviour of the retry mechanism. | |
285 | +.br | |
286 | +To set the maximum number of retries, enter | |
287 | +.IR "limit `value'" . | |
288 | +This is an absolute value (without unit). | |
289 | +To set the maximum length of time the MAC should retry, enter | |
290 | +.IR "lifetime `value'" . | |
291 | +By defaults, this value in in seconds, append the suffix m or u to | |
292 | +specify values in milliseconds or microseconds. | |
293 | +.br | |
294 | +You can also add the | |
295 | +.IR min " and " max | |
296 | +modifiers. If the card supports automatic mode, they define the bounds | |
297 | +of the limit or lifetime. Some other cards define different values | |
298 | +depending on packet size, for example in 802.11 | |
299 | +.I min limit | |
300 | +is the short retry limit (non RTS/CTS packets). | |
301 | +.br | |
302 | +.B Examples : | |
303 | +.br | |
304 | +.I " iwconfig eth0 retry 16" | |
305 | +.br | |
306 | +.I " iwconfig eth0 retry lifetime 300m" | |
307 | +.br | |
308 | +.I " iwconfig eth0 retry min limit 8" | |
309 | +.TP | |
211 | 310 | .BR rts [_threshold] |
212 | 311 | RTS/CTS adds a handshake before each packet transmission to make sure |
213 | 312 | that the channel is clear. This adds overhead, but increases |
214 | 313 | performance in case of hidden nodes or a large number of active |
215 | 314 | nodes. This parameter sets the size of the smallest packet for which |
216 | -the node sends RTS ; a value equal to the maximum packet size disable | |
315 | +the node sends RTS ; a value equal to the maximum packet size disables | |
217 | 316 | the mechanism. You may also set this parameter to |
218 | 317 | .IR auto ", " fixed " or " off . |
219 | 318 | .br |
@@ -228,8 +327,15 @@ Fragmentation allows to split an IP packet in a burst of smaller | ||
228 | 327 | fragments transmitted on the medium. In most cases this adds overhead, |
229 | 328 | but in a very noisy environment this reduces the error penalty and |
230 | 329 | allow packets to get through interference bursts. This parameter sets |
231 | -the maximum fragment size ; a value equal to the maximum packet size | |
232 | -disable the mechanism. You may also set this parameter to | |
330 | +the maximum fragment size which is always lower than the maximum | |
331 | +packet size. | |
332 | +.br | |
333 | +This parameter may also control Frame Bursting available on some | |
334 | +cards, the ability to send multiple IP packets together. This | |
335 | +mechanism would be enabled if the fragment size is larger than the | |
336 | +maximum packet size. | |
337 | +.br | |
338 | +You may also set this parameter to | |
233 | 339 | .IR auto ", " fixed " or " off . |
234 | 340 | .br |
235 | 341 | .B Examples : |
@@ -329,62 +435,9 @@ management mode to | ||
329 | 435 | .br |
330 | 436 | .I " iwconfig eth0 power min period 2 power max period 4" |
331 | 437 | .TP |
332 | -.BR txpower | |
333 | -For cards supporting multiple transmit powers, set the transmit power in dBm. If | |
334 | -.I W | |
335 | -is the power in Watt, the power in dBm is | |
336 | -.IR "P = 30 + 10.log(W)" . | |
337 | -If the value is postfixed by | |
338 | -.IR mW , | |
339 | -it will be automatically converted to dBm. | |
340 | -.br | |
341 | -In addition, | |
342 | -.IR on " and " off | |
343 | -enable and disable the radio, and | |
344 | -.IR auto " and " fixed | |
345 | -enable and disable power control (if those features are available). | |
346 | -.br | |
347 | -.B Examples : | |
348 | -.br | |
349 | -.I " iwconfig eth0 txpower 15" | |
350 | -.br | |
351 | -.I " iwconfig eth0 txpower 30mW" | |
352 | -.br | |
353 | -.I " iwconfig eth0 txpower auto" | |
354 | -.br | |
355 | -.I " iwconfig eth0 txpower off" | |
356 | -.TP | |
357 | -.BR retry | |
358 | -Most cards have MAC retransmissions, and some allow to set the | |
359 | -behaviour of the retry mechanism. | |
360 | -.br | |
361 | -To set the maximum number of retries, enter | |
362 | -.IR "limit `value'" . | |
363 | -This is an absolute value (without unit). | |
364 | -The set the maximum length of time the MAC should retry, enter | |
365 | -.IR "lifetime `value'" . | |
366 | -By defaults, this value in in seconds, append the suffix m or u to | |
367 | -specify values in milliseconds or microseconds. | |
368 | -.br | |
369 | -You can also add the | |
370 | -.IR min " and " max | |
371 | -modifiers. If the card supports automatic mode, they define the bounds | |
372 | -of the limit or lifetime. Some other cards define different values | |
373 | -depending on packet size, for example in 802.11 | |
374 | -.I min limit | |
375 | -is the short retry limit (non RTS/CTS packets). | |
376 | -.br | |
377 | -.B Examples : | |
378 | -.br | |
379 | -.I " iwconfig eth0 retry 16" | |
380 | -.br | |
381 | -.I " iwconfig eth0 retry lifetime 300m" | |
382 | -.br | |
383 | -.I " iwconfig eth0 retry min limit 8" | |
384 | -.TP | |
385 | 438 | .BR commit |
386 | 439 | Some cards may not apply changes done through Wireless Extensions |
387 | -immediately (they may wait to agregate the changes or apply it only | |
440 | +immediately (they may wait to aggregate the changes or apply it only | |
388 | 441 | when the card is brought up via ifconfig). This command (when |
389 | 442 | available) forces the card to apply all pending changes. |
390 | 443 | .br |
@@ -411,7 +464,7 @@ the | ||
411 | 464 | of operation, the |
412 | 465 | .B Access Point |
413 | 466 | address, the |
414 | -.B bit-rate | |
467 | +.BR bit-rate , | |
415 | 468 | the |
416 | 469 | .BR "RTS threshold" ", the " "fragmentation threshold" , |
417 | 470 | the |
@@ -421,10 +474,10 @@ and the | ||
421 | 474 | settings (depending on availability). |
422 | 475 | .PP |
423 | 476 | The parameters displayed have the same meaning and values as the |
424 | -parameter you can set, please refer to the previous part for a | |
477 | +parameters you can set, please refer to the previous part for a | |
425 | 478 | detailed explanation of them. |
426 | 479 | .br |
427 | -Some parameters are only displayed in short/abreviated form (such as | |
480 | +Some parameters are only displayed in short/abbreviated form (such as | |
428 | 481 | encryption). You may use |
429 | 482 | .IR iwlist (8) |
430 | 483 | to get all the details. |
@@ -22,22 +22,25 @@ | ||
22 | 22 | static void |
23 | 23 | iw_usage(void) |
24 | 24 | { |
25 | - fprintf(stderr, "Usage: iwconfig interface [essid {NN|on|off}]\n"); | |
26 | - fprintf(stderr, " [nwid {NN|on|off}]\n"); | |
27 | - fprintf(stderr, " [mode {managed|ad-hoc|...}\n"); | |
28 | - fprintf(stderr, " [freq N.NNNN[k|M|G]]\n"); | |
29 | - fprintf(stderr, " [channel N]\n"); | |
30 | - fprintf(stderr, " [ap {N|off|auto}]\n"); | |
31 | - fprintf(stderr, " [sens N]\n"); | |
32 | - fprintf(stderr, " [nick N]\n"); | |
33 | - fprintf(stderr, " [rate {N|auto|fixed}]\n"); | |
34 | - fprintf(stderr, " [rts {N|auto|fixed|off}]\n"); | |
35 | - fprintf(stderr, " [frag {N|auto|fixed|off}]\n"); | |
36 | - fprintf(stderr, " [enc {NNNN-NNNN|off}]\n"); | |
37 | - fprintf(stderr, " [power {period N|timeout N}]\n"); | |
38 | - fprintf(stderr, " [txpower N {mW|dBm}]\n"); | |
39 | - fprintf(stderr, " [commit]\n"); | |
40 | - fprintf(stderr, " Check man pages for more details.\n\n"); | |
25 | + fprintf(stderr, | |
26 | + "Usage: iwconfig interface [essid {NN|on|off}]\n" | |
27 | + " [nwid {NN|on|off}]\n" | |
28 | + " [mode {managed|ad-hoc|...}\n" | |
29 | + " [freq N.NNNN[k|M|G]]\n" | |
30 | + " [channel N]\n" | |
31 | + " [ap {N|off|auto}]\n" | |
32 | + " [sens N]\n" | |
33 | + " [nick N]\n" | |
34 | + " [rate {N|auto|fixed}]\n" | |
35 | + " [rts {N|auto|fixed|off}]\n" | |
36 | + " [frag {N|auto|fixed|off}]\n" | |
37 | + " [enc {NNNN-NNNN|off}]\n" | |
38 | + " [power {period N|timeout N}]\n" | |
39 | + " [retry {limit N|lifetime N}]\n" | |
40 | + " [txpower N {mW|dBm}]\n" | |
41 | + " [commit]\n" | |
42 | + " Check man pages for more details.\n\n" | |
43 | + ); | |
41 | 44 | } |
42 | 45 | |
43 | 46 |
@@ -154,6 +157,38 @@ get_info(int skfd, | ||
154 | 157 | info->has_stats = 1; |
155 | 158 | } |
156 | 159 | |
160 | +#ifdef DISPLAY_WPA | |
161 | + /* Note : currently disabled to not bloat iwconfig output. Also, | |
162 | + * if does not make total sense to display parameters that we | |
163 | + * don't allow (yet) to configure. | |
164 | + * For now, use iwlist instead... Jean II */ | |
165 | + | |
166 | + /* Get WPA/802.1x/802.11i security parameters */ | |
167 | + if((info->has_range) && (info->range.we_version_compiled > 17)) | |
168 | + { | |
169 | + wrq.u.param.flags = IW_AUTH_KEY_MGMT; | |
170 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
171 | + { | |
172 | + info->has_auth_key_mgmt = 1; | |
173 | + info->auth_key_mgmt = wrq.u.param.value; | |
174 | + } | |
175 | + | |
176 | + wrq.u.param.flags = IW_AUTH_CIPHER_PAIRWISE; | |
177 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
178 | + { | |
179 | + info->has_auth_cipher_pairwise = 1; | |
180 | + info->auth_cipher_pairwise = wrq.u.param.value; | |
181 | + } | |
182 | + | |
183 | + wrq.u.param.flags = IW_AUTH_CIPHER_GROUP; | |
184 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
185 | + { | |
186 | + info->has_auth_cipher_group = 1; | |
187 | + info->auth_cipher_group = wrq.u.param.value; | |
188 | + } | |
189 | + } | |
190 | +#endif | |
191 | + | |
157 | 192 | return(0); |
158 | 193 | } |
159 | 194 |
@@ -204,7 +239,7 @@ display_info(struct wireless_info * info, | ||
204 | 239 | /* Display Network ID */ |
205 | 240 | if(info->b.has_nwid) |
206 | 241 | { |
207 | - /* Note : should display proper number of digit according to info | |
242 | + /* Note : should display proper number of digits according to info | |
208 | 243 | * in range structure */ |
209 | 244 | if(info->b.nwid.disabled) |
210 | 245 | printf("NWID:off/any "); |
@@ -225,7 +260,7 @@ display_info(struct wireless_info * info, | ||
225 | 260 | { |
226 | 261 | double freq = info->b.freq; /* Frequency/channel */ |
227 | 262 | int channel = -1; /* Converted to channel */ |
228 | - /* Some driver insist of returning channel instead of frequency. | |
263 | + /* Some drivers insist of returning channel instead of frequency. | |
229 | 264 | * This fixes them up. Note that, driver should still return |
230 | 265 | * frequency, because other tools depend on it. */ |
231 | 266 | if(info->has_range && (freq < KILO)) |
@@ -252,7 +287,7 @@ display_info(struct wireless_info * info, | ||
252 | 287 | printf("Cell:"); |
253 | 288 | else |
254 | 289 | printf("Access Point:"); |
255 | - printf(" %s ", iw_pr_ether(buffer, info->ap_addr.sa_data)); | |
290 | + printf(" %s ", iw_sawap_ntop(&info->ap_addr, buffer)); | |
256 | 291 | } |
257 | 292 | |
258 | 293 | /* Display the currently used/set bit-rate */ |
@@ -397,7 +432,7 @@ display_info(struct wireless_info * info, | ||
397 | 432 | { |
398 | 433 | printf("Encryption key:"); |
399 | 434 | if((info->b.key_flags & IW_ENCODE_DISABLED) || (info->b.key_size == 0)) |
400 | - printf("off\n "); | |
435 | + printf("off"); | |
401 | 436 | else |
402 | 437 | { |
403 | 438 | /* Display the key */ |
@@ -412,9 +447,25 @@ display_info(struct wireless_info * info, | ||
412 | 447 | printf(" Security mode:restricted"); |
413 | 448 | if(info->b.key_flags & IW_ENCODE_OPEN) |
414 | 449 | printf(" Security mode:open"); |
415 | - printf("\n "); | |
416 | 450 | } |
451 | + printf("\n "); | |
452 | + } | |
453 | + | |
454 | +#ifdef DISPLAY_WPA | |
455 | + /* Display WPA/802.1x/802.11i security parameters */ | |
456 | + if(info->has_auth_key_mgmt || info->has_auth_cipher_pairwise || | |
457 | + info->has_auth_cipher_group) | |
458 | + { | |
459 | + printf("Auth params:"); | |
460 | + if(info->has_auth_key_mgmt) | |
461 | + printf(" key_mgmt:0x%X ", info->auth_key_mgmt); | |
462 | + if(info->has_auth_cipher_pairwise) | |
463 | + printf(" cipher_pairwise:0x%X ", info->auth_cipher_pairwise); | |
464 | + if(info->has_auth_cipher_group) | |
465 | + printf(" cipher_group:0x%X ", info->auth_cipher_group); | |
466 | + printf("\n "); | |
417 | 467 | } |
468 | +#endif | |
418 | 469 | |
419 | 470 | /* Display Power Management information */ |
420 | 471 | /* Note : we display only one parameter, period or timeout. If a device |
@@ -424,7 +475,7 @@ display_info(struct wireless_info * info, | ||
424 | 475 | printf("Power Management"); |
425 | 476 | /* Disabled ? */ |
426 | 477 | if(info->power.disabled) |
427 | - printf(":off\n "); | |
478 | + printf(":off"); | |
428 | 479 | else |
429 | 480 | { |
430 | 481 | /* Let's check the value and its type */ |
@@ -442,8 +493,8 @@ display_info(struct wireless_info * info, | ||
442 | 493 | /* Let's check if nothing (simply on) */ |
443 | 494 | if(info->power.flags == IW_POWER_ON) |
444 | 495 | printf(":on"); |
445 | - printf("\n "); | |
446 | 496 | } |
497 | + printf("\n "); | |
447 | 498 | } |
448 | 499 | |
449 | 500 | /* Display statistics */ |
@@ -812,6 +863,7 @@ set_info(int skfd, /* The socket */ | ||
812 | 863 | if(!strcasecmp(args[i], "essid")) |
813 | 864 | { |
814 | 865 | char essid[IW_ESSID_MAX_SIZE + 1]; |
866 | + int we_kernel_version; | |
815 | 867 | |
816 | 868 | i++; |
817 | 869 | if(i >= count) |
@@ -826,6 +878,7 @@ set_info(int skfd, /* The socket */ | ||
826 | 878 | if(!strcasecmp(args[i], "on")) |
827 | 879 | { |
828 | 880 | /* Get old essid */ |
881 | + memset(essid, '\0', sizeof(essid)); | |
829 | 882 | wrq.u.essid.pointer = (caddr_t) essid; |
830 | 883 | wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1; |
831 | 884 | wrq.u.essid.flags = 0; |
@@ -835,10 +888,10 @@ set_info(int skfd, /* The socket */ | ||
835 | 888 | } |
836 | 889 | else |
837 | 890 | { |
838 | - /* '-' allow to escape the ESSID string, allowing | |
891 | + /* '-' or '--' allow to escape the ESSID string, allowing | |
839 | 892 | * to set it to the string "any" or "off". |
840 | 893 | * This is a big ugly, but it will do for now */ |
841 | - if(!strcmp(args[i], "-")) | |
894 | + if((!strcmp(args[i], "-")) || (!strcmp(args[i], "--"))) | |
842 | 895 | { |
843 | 896 | i++; |
844 | 897 | if(i >= count) |
@@ -867,8 +920,14 @@ set_info(int skfd, /* The socket */ | ||
867 | 920 | } |
868 | 921 | } |
869 | 922 | |
923 | + /* Get version from kernel, device may not have range... */ | |
924 | + we_kernel_version = iw_get_kernel_we_version(); | |
925 | + | |
926 | + /* Finally set the ESSID value */ | |
870 | 927 | wrq.u.essid.pointer = (caddr_t) essid; |
871 | 928 | wrq.u.essid.length = strlen(essid) + 1; |
929 | + if(we_kernel_version > 20) | |
930 | + wrq.u.essid.length--; | |
872 | 931 | IW_SET_EXT_ERR(skfd, ifname, SIOCSIWESSID, &wrq, |
873 | 932 | "Set ESSID"); |
874 | 933 | continue; |
@@ -909,14 +968,20 @@ set_info(int skfd, /* The socket */ | ||
909 | 968 | /* ---------- Set NickName ---------- */ |
910 | 969 | if(!strncmp(args[i], "nick", 4)) |
911 | 970 | { |
971 | + int we_kernel_version; | |
972 | + | |
912 | 973 | i++; |
913 | 974 | if(i >= count) |
914 | 975 | ABORT_ARG_NUM("Set Nickname", SIOCSIWNICKN); |
915 | 976 | if(strlen(args[i]) > IW_ESSID_MAX_SIZE) |
916 | 977 | ABORT_ARG_SIZE("Set Nickname", SIOCSIWNICKN, IW_ESSID_MAX_SIZE); |
917 | 978 | |
979 | + we_kernel_version = iw_get_kernel_we_version(); | |
980 | + | |
918 | 981 | wrq.u.essid.pointer = (caddr_t) args[i]; |
919 | 982 | wrq.u.essid.length = strlen(args[i]) + 1; |
983 | + if(we_kernel_version > 20) | |
984 | + wrq.u.essid.length--; | |
920 | 985 | IW_SET_EXT_ERR(skfd, ifname, SIOCSIWNICKN, &wrq, |
921 | 986 | "Set Nickname"); |
922 | 987 | continue; |
@@ -1082,6 +1147,7 @@ set_info(int skfd, /* The socket */ | ||
1082 | 1147 | if(!strcasecmp(args[i], "on")) |
1083 | 1148 | { |
1084 | 1149 | /* Get old Power info */ |
1150 | + wrq.u.power.flags = 0; | |
1085 | 1151 | IW_GET_EXT_ERR(skfd, ifname, SIOCGIWPOWER, &wrq, |
1086 | 1152 | "Set Power Management"); |
1087 | 1153 | wrq.u.power.disabled = 0; |
@@ -1218,8 +1284,13 @@ set_info(int skfd, /* The socket */ | ||
1218 | 1284 | ABORT_ARG_TYPE("Set Tx Power", SIOCSIWTXPOW, |
1219 | 1285 | args[i]); |
1220 | 1286 | |
1221 | - /* Check if milliwatt */ | |
1222 | - ismwatt = (index(args[i], 'm') != NULL); | |
1287 | + /* Check if milliWatt | |
1288 | + * We authorise a single 'm' as a shorthand for 'mW', | |
1289 | + * on the other hand a 'd' probably means 'dBm'... */ | |
1290 | + ismwatt = ((index(args[i], 'm') != NULL) | |
1291 | + && (index(args[i], 'd') == NULL)); | |
1292 | + | |
1293 | + /* We could check 'W' alone... Another time... */ | |
1223 | 1294 | |
1224 | 1295 | /* Convert */ |
1225 | 1296 | if(range.txpower_capa & IW_TXPOW_RELATIVE) |
@@ -1374,15 +1445,24 @@ main(int argc, | ||
1374 | 1445 | iw_usage(); |
1375 | 1446 | else |
1376 | 1447 | /* Special case for version... */ |
1377 | - if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) | |
1448 | + if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) | |
1378 | 1449 | goterr = iw_print_version_info("iwconfig"); |
1379 | 1450 | else |
1380 | - /* The device name must be the first argument */ | |
1381 | - if(argc == 2) | |
1382 | - print_info(skfd, argv[1], NULL, 0); | |
1383 | - else | |
1384 | - /* The other args on the line specify options to be set... */ | |
1385 | - goterr = set_info(skfd, argv + 2, argc - 2, argv[1]); | |
1451 | + { | |
1452 | + /* '--' escape device name */ | |
1453 | + if((argc > 2) && !strcmp(argv[1], "--")) | |
1454 | + { | |
1455 | + argv++; | |
1456 | + argc--; | |
1457 | + } | |
1458 | + | |
1459 | + /* The device name must be the first argument */ | |
1460 | + if(argc == 2) | |
1461 | + print_info(skfd, argv[1], NULL, 0); | |
1462 | + else | |
1463 | + /* The other args on the line specify options to be set... */ | |
1464 | + goterr = set_info(skfd, argv + 2, argc - 2, argv[1]); | |
1465 | + } | |
1386 | 1466 | |
1387 | 1467 | /* Close the socket. */ |
1388 | 1468 | iw_sockets_close(skfd); |
@@ -18,8 +18,8 @@ iwevent \- Display Wireless Events generated by drivers and setting changes | ||
18 | 18 | .\" |
19 | 19 | .SH DESCRIPTION |
20 | 20 | .B iwevent |
21 | -display Wireless Events received through the RTNetlink socket. Each | |
22 | -line display the specific Wireless Event which describe what has | |
21 | +displays Wireless Events received through the RTNetlink socket. Each | |
22 | +line displays the specific Wireless Event which describes what has | |
23 | 23 | happened on the specified wireless interface. |
24 | 24 | .br |
25 | 25 | This command doesn't take any arguments. |
@@ -27,7 +27,7 @@ This command doesn't take any arguments. | ||
27 | 27 | .\" DISPLAY part |
28 | 28 | .\" |
29 | 29 | .SH DISPLAY |
30 | -There is two classes of Wireless Events. | |
30 | +There are two classes of Wireless Events. | |
31 | 31 | .PP |
32 | 32 | The first class is events related to a change of wireless settings on |
33 | 33 | the interface (typically done through |
@@ -57,7 +57,7 @@ something happens or a task has been finished. Those events include : | ||
57 | 57 | .TP |
58 | 58 | .B New Access Point/Cell address |
59 | 59 | The interface has joined a new Access Point or Ad-Hoc Cell, or lost |
60 | -its association with it. This is the same MAC address that is reported | |
60 | +its association with it. This is the same address that is reported | |
61 | 61 | by |
62 | 62 | .BR iwconfig . |
63 | 63 | .TP |
@@ -78,17 +78,17 @@ Event specific to the driver. Please check the driver documentation. | ||
78 | 78 | .TP |
79 | 79 | .B Registered node |
80 | 80 | The interface has successfully registered a new wireless |
81 | -client/peer. Will be generated mostly when the interface act as an | |
82 | -Access Point (mode master). | |
81 | +client/peer. Will be generated mostly when the interface acts as an | |
82 | +Access Point (mode Master). | |
83 | 83 | .TP |
84 | 84 | .B Expired node |
85 | 85 | The registration of the client/peer on this interface has |
86 | -expired. Will be generated mostly when the interface act as an Access | |
87 | -Point (mode master). | |
86 | +expired. Will be generated mostly when the interface acts as an Access | |
87 | +Point (mode Master). | |
88 | 88 | .TP |
89 | 89 | .B Spy threshold crossed |
90 | -The signal strength for one of the address in the spy list went under | |
91 | -the low threshold or went above than the high threshold. | |
90 | +The signal strength for one of the addresses in the spy list went | |
91 | +under the low threshold or went above the high threshold. | |
92 | 92 | .PP |
93 | 93 | Most wireless drivers generate only a subset of those events, not all |
94 | 94 | of them, the exact list depends on the specific hardware/driver |
@@ -106,7 +106,8 @@ static inline int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) | ||
106 | 106 | return -1; |
107 | 107 | } |
108 | 108 | addr_len = sizeof(rth->local); |
109 | - if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { | |
109 | + if (getsockname(rth->fd, (struct sockaddr*)&rth->local, | |
110 | + (socklen_t *) &addr_len) < 0) { | |
110 | 111 | perror("Cannot getsockname"); |
111 | 112 | return -1; |
112 | 113 | } |
@@ -271,6 +272,26 @@ iw_del_interface_data(int ifindex) | ||
271 | 272 | |
272 | 273 | /*------------------------------------------------------------------*/ |
273 | 274 | /* |
275 | + * Dump a buffer as a serie of hex | |
276 | + * Maybe should go in iwlib... | |
277 | + * Maybe we should have better formatting like iw_print_key... | |
278 | + */ | |
279 | +static char * | |
280 | +iw_hexdump(char * buf, | |
281 | + size_t buflen, | |
282 | + const unsigned char *data, | |
283 | + size_t datalen) | |
284 | +{ | |
285 | + size_t i; | |
286 | + char * pos = buf; | |
287 | + | |
288 | + for(i = 0; i < datalen; i++) | |
289 | + pos += snprintf(pos, buf + buflen - pos, "%02X", data[i]); | |
290 | + return buf; | |
291 | +} | |
292 | + | |
293 | +/*------------------------------------------------------------------*/ | |
294 | +/* | |
274 | 295 | * Print one element from the scanning results |
275 | 296 | */ |
276 | 297 | static inline int |
@@ -279,6 +300,7 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
279 | 300 | int has_range) |
280 | 301 | { |
281 | 302 | char buffer[128]; /* Temporary buffer */ |
303 | + char buffer2[30]; /* Temporary buffer */ | |
282 | 304 | char * prefix = (IW_IS_GET(event->cmd) ? "New" : "Set"); |
283 | 305 | |
284 | 306 | /* Now, let's decode the event */ |
@@ -320,9 +342,9 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
320 | 342 | case SIOCGIWESSID: |
321 | 343 | { |
322 | 344 | char essid[IW_ESSID_MAX_SIZE+1]; |
345 | + memset(essid, '\0', sizeof(essid)); | |
323 | 346 | if((event->u.essid.pointer) && (event->u.essid.length)) |
324 | 347 | memcpy(essid, event->u.essid.pointer, event->u.essid.length); |
325 | - essid[event->u.essid.length] = '\0'; | |
326 | 348 | if(event->u.essid.flags) |
327 | 349 | { |
328 | 350 | /* Does it have an ESSID index ? */ |
@@ -340,7 +362,7 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
340 | 362 | { |
341 | 363 | unsigned char key[IW_ENCODING_TOKEN_MAX]; |
342 | 364 | if(event->u.data.pointer) |
343 | - memcpy(key, event->u.essid.pointer, event->u.data.length); | |
365 | + memcpy(key, event->u.data.pointer, event->u.data.length); | |
344 | 366 | else |
345 | 367 | event->u.data.flags |= IW_ENCODE_NOKEY; |
346 | 368 | printf("Set Encryption key:"); |
@@ -368,31 +390,31 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
368 | 390 | /* Events generated by the driver when something important happens */ |
369 | 391 | case SIOCGIWAP: |
370 | 392 | printf("New Access Point/Cell address:%s\n", |
371 | - iw_pr_ether(buffer, event->u.ap_addr.sa_data)); | |
393 | + iw_sawap_ntop(&event->u.ap_addr, buffer)); | |
372 | 394 | break; |
373 | 395 | case SIOCGIWSCAN: |
374 | 396 | printf("Scan request completed\n"); |
375 | 397 | break; |
376 | 398 | case IWEVTXDROP: |
377 | 399 | printf("Tx packet dropped:%s\n", |
378 | - iw_pr_ether(buffer, event->u.addr.sa_data)); | |
400 | + iw_saether_ntop(&event->u.addr, buffer)); | |
379 | 401 | break; |
380 | 402 | case IWEVCUSTOM: |
381 | 403 | { |
382 | 404 | char custom[IW_CUSTOM_MAX+1]; |
405 | + memset(custom, '\0', sizeof(custom)); | |
383 | 406 | if((event->u.data.pointer) && (event->u.data.length)) |
384 | 407 | memcpy(custom, event->u.data.pointer, event->u.data.length); |
385 | - custom[event->u.data.length] = '\0'; | |
386 | 408 | printf("Custom driver event:%s\n", custom); |
387 | 409 | } |
388 | 410 | break; |
389 | 411 | case IWEVREGISTERED: |
390 | 412 | printf("Registered node:%s\n", |
391 | - iw_pr_ether(buffer, event->u.addr.sa_data)); | |
413 | + iw_saether_ntop(&event->u.addr, buffer)); | |
392 | 414 | break; |
393 | 415 | case IWEVEXPIRED: |
394 | 416 | printf("Expired node:%s\n", |
395 | - iw_pr_ether(buffer, event->u.addr.sa_data)); | |
417 | + iw_saether_ntop(&event->u.addr, buffer)); | |
396 | 418 | break; |
397 | 419 | case SIOCGIWTHRSPY: |
398 | 420 | { |
@@ -402,7 +424,7 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
402 | 424 | memcpy(&threshold, event->u.data.pointer, |
403 | 425 | sizeof(struct iw_thrspy)); |
404 | 426 | printf("Spy threshold crossed on address:%s\n", |
405 | - iw_pr_ether(buffer, threshold.addr.sa_data)); | |
427 | + iw_saether_ntop(&threshold.addr, buffer)); | |
406 | 428 | iw_print_stats(buffer, sizeof(buffer), |
407 | 429 | &threshold.qual, iw_range, has_range); |
408 | 430 | printf(" Link %s\n", buffer); |
@@ -411,6 +433,40 @@ print_event_token(struct iw_event * event, /* Extracted token */ | ||
411 | 433 | printf("Invalid Spy Threshold event\n"); |
412 | 434 | } |
413 | 435 | break; |
436 | + /* ----- driver WPA events ----- */ | |
437 | + /* Events generated by the driver, used for WPA operation */ | |
438 | + case IWEVMICHAELMICFAILURE: | |
439 | + if(event->u.data.length >= sizeof(struct iw_michaelmicfailure)) | |
440 | + { | |
441 | + struct iw_michaelmicfailure mf; | |
442 | + memcpy(&mf, event->u.data.pointer, sizeof(mf)); | |
443 | + printf("Michael MIC failure flags:0x%X src_addr:%s tsc:%s\n", | |
444 | + mf.flags, | |
445 | + iw_saether_ntop(&mf.src_addr, buffer2), | |
446 | + iw_hexdump(buffer, sizeof(buffer), | |
447 | + mf.tsc, IW_ENCODE_SEQ_MAX_SIZE)); | |
448 | + } | |
449 | + break; | |
450 | + case IWEVASSOCREQIE: | |
451 | + printf("Association Request IEs:%s\n", | |
452 | + iw_hexdump(buffer, sizeof(buffer), | |
453 | + event->u.data.pointer, event->u.data.length)); | |
454 | + break; | |
455 | + case IWEVASSOCRESPIE: | |
456 | + printf("Association Response IEs:%s\n", | |
457 | + iw_hexdump(buffer, sizeof(buffer), | |
458 | + event->u.data.pointer, event->u.data.length)); | |
459 | + break; | |
460 | + case IWEVPMKIDCAND: | |
461 | + if(event->u.data.length >= sizeof(struct iw_pmkid_cand)) | |
462 | + { | |
463 | + struct iw_pmkid_cand cand; | |
464 | + memcpy(&cand, event->u.data.pointer, sizeof(cand)); | |
465 | + printf("PMKID candidate flags:0x%X index:%d bssid:%s\n", | |
466 | + cand.flags, cand.index, | |
467 | + iw_saether_ntop(&cand.bssid, buffer)); | |
468 | + } | |
469 | + break; | |
414 | 470 | /* ----- junk ----- */ |
415 | 471 | /* other junk not currently in use */ |
416 | 472 | case SIOCGIWRATE: |
@@ -452,6 +508,7 @@ print_event_stream(int ifindex, | ||
452 | 508 | int ret; |
453 | 509 | char buffer[64]; |
454 | 510 | struct timeval recv_time; |
511 | + struct timezone tz; | |
455 | 512 | struct wireless_iface * wireless_data; |
456 | 513 | |
457 | 514 | /* Get data from cache */ |
@@ -460,8 +517,8 @@ print_event_stream(int ifindex, | ||
460 | 517 | return(-1); |
461 | 518 | |
462 | 519 | /* Print received time in readable form */ |
463 | - gettimeofday(&recv_time, NULL); | |
464 | - iw_print_timeval(buffer, sizeof(buffer), &recv_time); | |
520 | + gettimeofday(&recv_time, &tz); | |
521 | + iw_print_timeval(buffer, sizeof(buffer), &recv_time, &tz); | |
465 | 522 | |
466 | 523 | iw_init_event_stream(&stream, data, len); |
467 | 524 | do |
@@ -42,7 +42,7 @@ The default formatting output is pretty-print. | ||
42 | 42 | .SH OPTIONS |
43 | 43 | .TP |
44 | 44 | .B --raw |
45 | -This option disables pretty-printing of the information. This options | |
45 | +This option disables pretty-printing of the information. This option | |
46 | 46 | is orthogonal to the other options (except |
47 | 47 | .BR --scheme ), |
48 | 48 | 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 | ||
58 | 58 | .TP |
59 | 59 | .B --scheme |
60 | 60 | This option is similar to the previous one, it disables |
61 | -pretty-printing of the information and remove all characters that are | |
61 | +pretty-printing of the information and removes all characters that are | |
62 | 62 | not alphanumerics (like space, punctuation and control characters). |
63 | 63 | .br |
64 | 64 | The resulting output is a valid Pcmcia scheme identifier (that may be |
@@ -98,9 +98,8 @@ of the interface. | ||
98 | 98 | .B --protocol |
99 | 99 | Display the |
100 | 100 | .I protocol name |
101 | -of the interface. This allow to identify all the cards that are | |
102 | -compatible with each other and accept the same type of | |
103 | -configuration. | |
101 | +of the interface. This allows to identify all the cards that are | |
102 | +compatible with each other and accept the same type of configuration. | |
104 | 103 | .br |
105 | 104 | This can also be used to |
106 | 105 | .I check Wireless Extension support |
@@ -89,7 +89,7 @@ print_essid(int skfd, | ||
89 | 89 | unsigned int i; |
90 | 90 | unsigned int j; |
91 | 91 | |
92 | - /* Make shure ESSID is NULL terminated */ | |
92 | + /* Make sure ESSID is always NULL terminated */ | |
93 | 93 | memset(essid, 0, sizeof(essid)); |
94 | 94 | |
95 | 95 | /* Get ESSID */ |
@@ -177,7 +177,8 @@ iw_get_ifname(char * name, /* Where to store the name */ | ||
177 | 177 | memcpy(name, buf, (end - buf)); |
178 | 178 | name[end - buf] = '\0'; |
179 | 179 | |
180 | - return(end + 2); | |
180 | + /* Return value currently unused, just make sure it's non-NULL */ | |
181 | + return(end); | |
181 | 182 | } |
182 | 183 | |
183 | 184 | /*------------------------------------------------------------------*/ |
@@ -201,7 +202,7 @@ iw_enum_devices(int skfd, | ||
201 | 202 | int i; |
202 | 203 | |
203 | 204 | #ifndef IW_RESTRIC_ENUM |
204 | - /* Check if /proc/net/wireless is available */ | |
205 | + /* Check if /proc/net/dev is available */ | |
205 | 206 | fh = fopen(PROC_NET_DEV, "r"); |
206 | 207 | #else |
207 | 208 | /* Check if /proc/net/wireless is available */ |
@@ -222,16 +223,23 @@ iw_enum_devices(int skfd, | ||
222 | 223 | char name[IFNAMSIZ + 1]; |
223 | 224 | char *s; |
224 | 225 | |
226 | + /* Skip empty or almost empty lines. It seems that in some | |
227 | + * cases fgets return a line with only a newline. */ | |
228 | + if((buff[0] == '\0') || (buff[1] == '\0')) | |
229 | + continue; | |
230 | + | |
225 | 231 | /* Extract interface name */ |
226 | 232 | s = iw_get_ifname(name, sizeof(name), buff); |
227 | 233 | |
228 | 234 | if(!s) |
229 | - /* Failed to parse, complain and continue */ | |
235 | + { | |
236 | + /* Failed to parse, complain and continue */ | |
230 | 237 | #ifndef IW_RESTRIC_ENUM |
231 | - fprintf(stderr, "Cannot parse " PROC_NET_DEV "\n"); | |
238 | + fprintf(stderr, "Cannot parse " PROC_NET_DEV "\n"); | |
232 | 239 | #else |
233 | - fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n"); | |
240 | + fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n"); | |
234 | 241 | #endif |
242 | + } | |
235 | 243 | else |
236 | 244 | /* Got it, print info about this interface */ |
237 | 245 | (*fn)(skfd, name, args, count); |
@@ -510,7 +518,7 @@ iw_get_range_info(int skfd, | ||
510 | 518 | |
511 | 519 | /* We don't like future versions of WE, because we can't cope with |
512 | 520 | * the unknown */ |
513 | - if(range->we_version_compiled > WE_VERSION) | |
521 | + if(range->we_version_compiled > WE_MAX_VERSION) | |
514 | 522 | { |
515 | 523 | fprintf(stderr, "Warning: Driver for device %s has been compiled with version %d\n", ifname, range->we_version_compiled); |
516 | 524 | 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, | ||
790 | 798 | */ |
791 | 799 | if(info->has_essid) |
792 | 800 | { |
801 | + int we_kernel_version; | |
802 | + we_kernel_version = iw_get_kernel_we_version(); | |
803 | + | |
793 | 804 | wrq.u.essid.pointer = (caddr_t) info->essid; |
794 | 805 | wrq.u.essid.length = strlen(info->essid) + 1; |
795 | 806 | wrq.u.data.flags = info->essid_on; |
807 | + if(we_kernel_version > 20) | |
808 | + wrq.u.essid.length--; | |
796 | 809 | |
797 | 810 | if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0) |
798 | 811 | { |
@@ -1203,6 +1216,7 @@ iw_print_txpower(char * buffer, | ||
1203 | 1216 | /*------------------------------------------------------------------*/ |
1204 | 1217 | /* |
1205 | 1218 | * Read /proc/net/wireless to get the latest statistics |
1219 | + * Note : strtok not thread safe, not used in WE-12 and later. | |
1206 | 1220 | */ |
1207 | 1221 | int |
1208 | 1222 | iw_get_stats(int skfd, |
@@ -1308,10 +1322,12 @@ iw_print_stats(char * buffer, | ||
1308 | 1322 | * Relative/percent values are always encoded unsigned, between 0 and 255. |
1309 | 1323 | * Absolute/dBm values are always encoded negative, between -255 and 0. |
1310 | 1324 | * |
1311 | - * How do we separate relative from absolute values ? We use the | |
1312 | - * range to do that. The range allow to specify the real min/max | |
1313 | - * of the value. As the range struct only specify one bound of the | |
1314 | - * value, we assume that the other bound is 0 (zero). | |
1325 | + * How do we separate relative from absolute values ? | |
1326 | + * The old way is to use the range to do that. As of WE-19, we have | |
1327 | + * an explicit IW_QUAL_DBM flag in updated... | |
1328 | + * The range allow to specify the real min/max of the value. As the | |
1329 | + * range struct only specify one bound of the value, we assume that | |
1330 | + * the other bound is 0 (zero). | |
1315 | 1331 | * For relative values, range is [0 ; range->max]. |
1316 | 1332 | * For absolute values, range is [range->max ; 0]. |
1317 | 1333 | * |
@@ -1323,8 +1339,11 @@ iw_print_stats(char * buffer, | ||
1323 | 1339 | * Jean II |
1324 | 1340 | */ |
1325 | 1341 | |
1326 | - /* Just do it */ | |
1327 | - if(has_range && (qual->level != 0)) | |
1342 | + /* Just do it... | |
1343 | + * The old way to detect dBm require both the range and a non-null | |
1344 | + * level (which confuse the test). The new way can deal with level of 0 | |
1345 | + * because it does an explicit test on the flag. */ | |
1346 | + if(has_range && ((qual->level != 0) || (qual->updated & IW_QUAL_DBM))) | |
1328 | 1347 | { |
1329 | 1348 | /* Deal with quality : always a relative value */ |
1330 | 1349 | if(!(qual->updated & IW_QUAL_QUAL_INVALID)) |
@@ -1336,8 +1355,9 @@ iw_print_stats(char * buffer, | ||
1336 | 1355 | buflen -= len; |
1337 | 1356 | } |
1338 | 1357 | |
1339 | - /* If the statistics are in dBm or relative */ | |
1340 | - if(qual->level > range->max_qual.level) | |
1358 | + /* Check if the statistics are in dBm or relative */ | |
1359 | + if((qual->updated & IW_QUAL_DBM) | |
1360 | + || (qual->level > range->max_qual.level)) | |
1341 | 1361 | { |
1342 | 1362 | /* Deal with signal level in dBm (absolute power measurement) */ |
1343 | 1363 | if(!(qual->updated & IW_QUAL_LEVEL_INVALID)) |
@@ -1462,6 +1482,7 @@ iw_pass_key(const char * input, | ||
1462 | 1482 | /* |
1463 | 1483 | * Parse a key from the command line. |
1464 | 1484 | * Return size of the key, or 0 (no key) or -1 (error) |
1485 | + * If the key is too long, it's simply truncated... | |
1465 | 1486 | */ |
1466 | 1487 | int |
1467 | 1488 | iw_in_key(const char * input, |
@@ -1476,7 +1497,7 @@ iw_in_key(const char * input, | ||
1476 | 1497 | keylen = strlen(input + 2); /* skip "s:" */ |
1477 | 1498 | if(keylen > IW_ENCODING_TOKEN_MAX) |
1478 | 1499 | keylen = IW_ENCODING_TOKEN_MAX; |
1479 | - strncpy(key, input + 2, keylen); | |
1500 | + memcpy(key, input + 2, keylen); | |
1480 | 1501 | } |
1481 | 1502 | else |
1482 | 1503 | if(!strncmp(input, "p:", 2)) |
@@ -1486,56 +1507,66 @@ iw_in_key(const char * input, | ||
1486 | 1507 | } |
1487 | 1508 | else |
1488 | 1509 | { |
1489 | - char * buff; | |
1490 | - char * hex; | |
1491 | - char * out; | |
1492 | - char * p; | |
1510 | + const char * p; | |
1511 | + int dlen; /* Digits sequence length */ | |
1512 | + unsigned char out[IW_ENCODING_TOKEN_MAX]; | |
1493 | 1513 | |
1494 | 1514 | /* Third case : as hexadecimal digits */ |
1495 | - buff = malloc(IW_ENCODING_TOKEN_MAX + strlen(input) + 1); | |
1496 | - if(buff == NULL) | |
1497 | - { | |
1498 | - fprintf(stderr, "Malloc failed (string too long ?)\n"); | |
1499 | - return(-1); | |
1500 | - } | |
1501 | - /* Preserve original buffers (both in & out) */ | |
1502 | - hex = buff + IW_ENCODING_TOKEN_MAX; | |
1503 | - strcpy(hex, input); /* Size checked */ | |
1504 | - out = buff; | |
1505 | - | |
1506 | - /* Parse */ | |
1507 | - p = strtok(hex, "-:;.,"); | |
1508 | - while((p != (char *) NULL) && (keylen < IW_ENCODING_TOKEN_MAX)) | |
1515 | + p = input; | |
1516 | + dlen = -1; | |
1517 | + | |
1518 | + /* Loop until we run out of chars in input or overflow the output */ | |
1519 | + while(*p != '\0') | |
1509 | 1520 | { |
1510 | 1521 | int temph; |
1511 | 1522 | int templ; |
1512 | 1523 | int count; |
1513 | - int len; | |
1524 | + /* No more chars in this sequence */ | |
1525 | + if(dlen <= 0) | |
1526 | + { | |
1527 | + /* Skip separator */ | |
1528 | + if(dlen == 0) | |
1529 | + p++; | |
1530 | + /* Calculate num of char to next separator */ | |
1531 | + dlen = strcspn(p, "-:;.,"); | |
1532 | + } | |
1514 | 1533 | /* Get each char separatly (and not by two) so that we don't |
1515 | 1534 | * get confused by 'enc' (=> '0E'+'0C') and similar */ |
1516 | 1535 | count = sscanf(p, "%1X%1X", &temph, &templ); |
1517 | 1536 | if(count < 1) |
1518 | 1537 | return(-1); /* Error -> non-hex char */ |
1519 | 1538 | /* Fixup odd strings such as '123' is '01'+'23' and not '12'+'03'*/ |
1520 | - len = strlen(p); | |
1521 | - if(len % 2) | |
1539 | + if(dlen % 2) | |
1522 | 1540 | count = 1; |
1523 | - /* Put back two chars as one byte */ | |
1541 | + /* Put back two chars as one byte and output */ | |
1524 | 1542 | if(count == 2) |
1525 | 1543 | templ |= temph << 4; |
1526 | 1544 | else |
1527 | 1545 | templ = temph; |
1528 | 1546 | out[keylen++] = (unsigned char) (templ & 0xFF); |
1529 | - /* Check where to get next char from */ | |
1530 | - if(len > count) /* Token not finished yet */ | |
1531 | - p += count; | |
1532 | - else | |
1533 | - p = strtok((char *) NULL, "-:;.,"); | |
1547 | + /* Check overflow in output */ | |
1548 | + if(keylen >= IW_ENCODING_TOKEN_MAX) | |
1549 | + break; | |
1550 | + /* Move on to next chars */ | |
1551 | + p += count; | |
1552 | + dlen -= count; | |
1534 | 1553 | } |
1554 | + /* We use a temporary output buffer 'out' so that if there is | |
1555 | + * an error, we don't overwrite the original key buffer. | |
1556 | + * Because of the way iwconfig loop on multiple key/enc arguments | |
1557 | + * until it finds an error in here, this is necessary to avoid | |
1558 | + * silently corrupting the encryption key... */ | |
1535 | 1559 | memcpy(key, out, keylen); |
1536 | - free(buff); | |
1537 | 1560 | } |
1538 | 1561 | |
1562 | +#ifdef DEBUG | |
1563 | + { | |
1564 | + char buf[IW_ENCODING_TOKEN_MAX * 3]; | |
1565 | + iw_print_key(buf, sizeof(buf), key, keylen, 0); | |
1566 | + printf("Got key : %d [%s]\n", keylen, buf); | |
1567 | + } | |
1568 | +#endif | |
1569 | + | |
1539 | 1570 | return(keylen); |
1540 | 1571 | } |
1541 | 1572 |
@@ -1566,7 +1597,7 @@ iw_in_key_full(int skfd, | ||
1566 | 1597 | memcpy(key, input + 2, keylen); |
1567 | 1598 | |
1568 | 1599 | /* Separate the two strings */ |
1569 | - p = strchr(key, ':'); | |
1600 | + p = strchr((char *) key, ':'); | |
1570 | 1601 | if(p == NULL) |
1571 | 1602 | { |
1572 | 1603 | fprintf(stderr, "Error: Invalid login format\n"); |
@@ -1768,16 +1799,17 @@ iw_print_retry_value(char * buffer, | ||
1768 | 1799 | * Inspired from irdadump... |
1769 | 1800 | */ |
1770 | 1801 | void |
1771 | -iw_print_timeval(char * buffer, | |
1772 | - int buflen, | |
1773 | - const struct timeval * time) | |
1802 | +iw_print_timeval(char * buffer, | |
1803 | + int buflen, | |
1804 | + const struct timeval * timev, | |
1805 | + const struct timezone * tz) | |
1774 | 1806 | { |
1775 | 1807 | int s; |
1776 | 1808 | |
1777 | - s = (time->tv_sec) % 86400; | |
1778 | - snprintf(buffer, buflen, "%02d:%02d:%02d.%06u ", | |
1809 | + s = (timev->tv_sec - tz->tz_minuteswest * 60) % 86400; | |
1810 | + snprintf(buffer, buflen, "%02d:%02d:%02d.%06u", | |
1779 | 1811 | s / 3600, (s % 3600) / 60, |
1780 | - s % 60, (u_int32_t) time->tv_usec); | |
1812 | + s % 60, (u_int32_t) timev->tv_usec); | |
1781 | 1813 | } |
1782 | 1814 | |
1783 | 1815 | /*********************** ADDRESS SUBROUTINES ************************/ |
@@ -1793,14 +1825,15 @@ iw_print_timeval(char * buffer, | ||
1793 | 1825 | */ |
1794 | 1826 | int |
1795 | 1827 | iw_check_mac_addr_type(int skfd, |
1796 | - char * ifname) | |
1828 | + const char * ifname) | |
1797 | 1829 | { |
1798 | 1830 | struct ifreq ifr; |
1799 | 1831 | |
1800 | 1832 | /* Get the type of hardware address */ |
1801 | 1833 | strncpy(ifr.ifr_name, ifname, IFNAMSIZ); |
1802 | 1834 | if((ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) || |
1803 | - (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER)) | |
1835 | + ((ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) | |
1836 | + && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211))) | |
1804 | 1837 | { |
1805 | 1838 | /* Deep trouble... */ |
1806 | 1839 | fprintf(stderr, "Interface %s doesn't support MAC addresses\n", |
@@ -1809,8 +1842,11 @@ iw_check_mac_addr_type(int skfd, | ||
1809 | 1842 | } |
1810 | 1843 | |
1811 | 1844 | #ifdef DEBUG |
1812 | - printf("Hardware : %d - %s\n", ifr.ifr_hwaddr.sa_family, | |
1813 | - iw_ether_ntoa((struct ether_addr *) ifr.ifr_hwaddr.sa_data)); | |
1845 | + { | |
1846 | + char buf[20]; | |
1847 | + printf("Hardware : %d - %s\n", ifr.ifr_hwaddr.sa_family, | |
1848 | + iw_saether_ntop(&ifr.ifr_hwaddr, buf)); | |
1849 | + } | |
1814 | 1850 | #endif |
1815 | 1851 | |
1816 | 1852 | return(0); |
@@ -1823,7 +1859,7 @@ iw_check_mac_addr_type(int skfd, | ||
1823 | 1859 | */ |
1824 | 1860 | int |
1825 | 1861 | iw_check_if_addr_type(int skfd, |
1826 | - char * ifname) | |
1862 | + const char * ifname) | |
1827 | 1863 | { |
1828 | 1864 | struct ifreq ifr; |
1829 | 1865 |
@@ -1866,6 +1902,7 @@ iw_check_addr_type(int skfd, | ||
1866 | 1902 | } |
1867 | 1903 | #endif |
1868 | 1904 | |
1905 | +#if 0 | |
1869 | 1906 | /*------------------------------------------------------------------*/ |
1870 | 1907 | /* |
1871 | 1908 | * Ask the kernel for the MAC address of an interface. |
@@ -1890,13 +1927,40 @@ iw_get_mac_addr(int skfd, | ||
1890 | 1927 | *ptype = ifr.ifr_hwaddr.sa_family; |
1891 | 1928 | return(ret); |
1892 | 1929 | } |
1930 | +#endif | |
1931 | + | |
1932 | +/*------------------------------------------------------------------*/ | |
1933 | +/* | |
1934 | + * Display an arbitrary length MAC address in readable format. | |
1935 | + */ | |
1936 | +char * | |
1937 | +iw_mac_ntop(const unsigned char * mac, | |
1938 | + int maclen, | |
1939 | + char * buf, | |
1940 | + int buflen) | |
1941 | +{ | |
1942 | + int i; | |
1943 | + | |
1944 | + /* Overflow check (don't forget '\0') */ | |
1945 | + if(buflen < (maclen * 3 - 1 + 1)) | |
1946 | + return(NULL); | |
1947 | + | |
1948 | + /* First byte */ | |
1949 | + sprintf(buf, "%02X", mac[0]); | |
1950 | + | |
1951 | + /* Other bytes */ | |
1952 | + for(i = 1; i < maclen; i++) | |
1953 | + sprintf(buf + (i * 3) - 1, ":%02X", mac[i]); | |
1954 | + return(buf); | |
1955 | +} | |
1893 | 1956 | |
1894 | 1957 | /*------------------------------------------------------------------*/ |
1895 | 1958 | /* |
1896 | 1959 | * Display an Ethernet address in readable format. |
1897 | 1960 | */ |
1898 | 1961 | void |
1899 | -iw_ether_ntop(const struct ether_addr* eth, char* buf) | |
1962 | +iw_ether_ntop(const struct ether_addr * eth, | |
1963 | + char * buf) | |
1900 | 1964 | { |
1901 | 1965 | sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", |
1902 | 1966 | eth->ether_addr_octet[0], eth->ether_addr_octet[1], |
@@ -1906,70 +1970,111 @@ iw_ether_ntop(const struct ether_addr* eth, char* buf) | ||
1906 | 1970 | |
1907 | 1971 | /*------------------------------------------------------------------*/ |
1908 | 1972 | /* |
1909 | - * Display an Ethernet address in readable format. | |
1910 | - * Same with a static buffer | |
1973 | + * Display an Wireless Access Point Socket Address in readable format. | |
1974 | + * Note : 0x44 is an accident of history, that's what the Orinoco/PrismII | |
1975 | + * chipset report, and the driver doesn't filter it. | |
1911 | 1976 | */ |
1912 | 1977 | char * |
1913 | -iw_ether_ntoa(const struct ether_addr* eth) | |
1978 | +iw_sawap_ntop(const struct sockaddr * sap, | |
1979 | + char * buf) | |
1914 | 1980 | { |
1915 | - static char buf[20]; | |
1916 | - iw_ether_ntop(eth, buf); | |
1917 | - return buf; | |
1981 | + const struct ether_addr ether_zero = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; | |
1982 | + const struct ether_addr ether_bcast = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }}; | |
1983 | + const struct ether_addr ether_hack = {{ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }}; | |
1984 | + const struct ether_addr * ether_wap = (const struct ether_addr *) sap->sa_data; | |
1985 | + | |
1986 | + if(!iw_ether_cmp(ether_wap, ðer_zero)) | |
1987 | + sprintf(buf, "Not-Associated"); | |
1988 | + else | |
1989 | + if(!iw_ether_cmp(ether_wap, ðer_bcast)) | |
1990 | + sprintf(buf, "Invalid"); | |
1991 | + else | |
1992 | + if(!iw_ether_cmp(ether_wap, ðer_hack)) | |
1993 | + sprintf(buf, "None"); | |
1994 | + else | |
1995 | + iw_ether_ntop(ether_wap, buf); | |
1996 | + return(buf); | |
1918 | 1997 | } |
1919 | 1998 | |
1920 | 1999 | /*------------------------------------------------------------------*/ |
1921 | 2000 | /* |
1922 | - * Input an Ethernet address and convert to binary. | |
2001 | + * Input an arbitrary length MAC address and convert to binary. | |
2002 | + * Return address size. | |
1923 | 2003 | */ |
1924 | 2004 | int |
1925 | -iw_ether_aton(const char *orig, struct ether_addr *eth) | |
2005 | +iw_mac_aton(const char * orig, | |
2006 | + unsigned char * mac, | |
2007 | + int macmax) | |
1926 | 2008 | { |
1927 | - const char *bufp; | |
1928 | - int i; | |
1929 | - | |
1930 | - i = 0; | |
1931 | - for(bufp = orig; *bufp != '\0'; ++bufp) { | |
1932 | - unsigned int val; | |
1933 | - unsigned char c = *bufp++; | |
1934 | - if (isdigit(c)) val = c - '0'; | |
1935 | - else if (c >= 'a' && c <= 'f') val = c - 'a' + 10; | |
1936 | - else if (c >= 'A' && c <= 'F') val = c - 'A' + 10; | |
1937 | - else break; | |
1938 | - | |
1939 | - val <<= 4; | |
1940 | - c = *bufp++; | |
1941 | - if (isdigit(c)) val |= c - '0'; | |
1942 | - else if (c >= 'a' && c <= 'f') val |= c - 'a' + 10; | |
1943 | - else if (c >= 'A' && c <= 'F') val |= c - 'A' + 10; | |
1944 | - else break; | |
1945 | - | |
1946 | - eth->ether_addr_octet[i] = (unsigned char) (val & 0377); | |
1947 | - if(++i == ETH_ALEN) { | |
1948 | - /* That's it. Any trailing junk? */ | |
1949 | - if (*bufp != '\0') { | |
2009 | + const char * p = orig; | |
2010 | + int maclen = 0; | |
2011 | + | |
2012 | + /* Loop on all bytes of the string */ | |
2013 | + while(*p != '\0') | |
2014 | + { | |
2015 | + int temph; | |
2016 | + int templ; | |
2017 | + int count; | |
2018 | + /* Extract one byte as two chars */ | |
2019 | + count = sscanf(p, "%1X%1X", &temph, &templ); | |
2020 | + if(count != 2) | |
2021 | + break; /* Error -> non-hex chars */ | |
2022 | + /* Output two chars as one byte */ | |
2023 | + templ |= temph << 4; | |
2024 | + mac[maclen++] = (unsigned char) (templ & 0xFF); | |
2025 | + | |
2026 | + /* Check end of string */ | |
2027 | + p += 2; | |
2028 | + if(*p == '\0') | |
2029 | + { | |
1950 | 2030 | #ifdef DEBUG |
1951 | - fprintf(stderr, "iw_ether_aton(%s): trailing junk!\n", orig); | |
1952 | - errno = EINVAL; | |
1953 | - return(0); | |
2031 | + char buf[20]; | |
2032 | + iw_ether_ntop((const struct ether_addr *) mac, buf); | |
2033 | + fprintf(stderr, "iw_mac_aton(%s): %s\n", orig, buf); | |
1954 | 2034 | #endif |
1955 | - } | |
2035 | + return(maclen); /* Normal exit */ | |
2036 | + } | |
2037 | + | |
2038 | + /* Check overflow */ | |
2039 | + if(maclen >= macmax) | |
2040 | + { | |
1956 | 2041 | #ifdef DEBUG |
1957 | - fprintf(stderr, "iw_ether_aton(%s): %s\n", | |
1958 | - orig, ether_ntoa(eth)); | |
2042 | + fprintf(stderr, "iw_mac_aton(%s): trailing junk!\n", orig); | |
1959 | 2043 | #endif |
1960 | - return(1); | |
2044 | + errno = E2BIG; | |
2045 | + return(0); /* Error -> overflow */ | |
1961 | 2046 | } |
1962 | - if (*bufp != ':') | |
1963 | - break; | |
1964 | - } | |
1965 | 2047 | |
2048 | + /* Check separator */ | |
2049 | + if(*p != ':') | |
2050 | + break; | |
2051 | + p++; | |
2052 | + } | |
2053 | + | |
2054 | + /* Error... */ | |
1966 | 2055 | #ifdef DEBUG |
1967 | - fprintf(stderr, "iw_ether_aton(%s): invalid ether address!\n", orig); | |
2056 | + fprintf(stderr, "iw_mac_aton(%s): invalid ether address!\n", orig); | |
1968 | 2057 | #endif |
1969 | 2058 | errno = EINVAL; |
1970 | 2059 | return(0); |
1971 | 2060 | } |
1972 | 2061 | |
2062 | +/*------------------------------------------------------------------*/ | |
2063 | +/* | |
2064 | + * Input an Ethernet address and convert to binary. | |
2065 | + */ | |
2066 | +int | |
2067 | +iw_ether_aton(const char *orig, struct ether_addr *eth) | |
2068 | +{ | |
2069 | + int maclen; | |
2070 | + maclen = iw_mac_aton(orig, (unsigned char *) eth, ETH_ALEN); | |
2071 | + if((maclen > 0) && (maclen < ETH_ALEN)) | |
2072 | + { | |
2073 | + errno = EINVAL; | |
2074 | + maclen = 0; | |
2075 | + } | |
2076 | + return(maclen); | |
2077 | +} | |
1973 | 2078 | |
1974 | 2079 | /*------------------------------------------------------------------*/ |
1975 | 2080 | /* |
@@ -2015,7 +2120,7 @@ iw_in_inet(char *name, struct sockaddr *sap) | ||
2015 | 2120 | */ |
2016 | 2121 | int |
2017 | 2122 | iw_in_addr(int skfd, |
2018 | - char * ifname, | |
2123 | + const char * ifname, | |
2019 | 2124 | char * bufp, |
2020 | 2125 | struct sockaddr *sap) |
2021 | 2126 | { |
@@ -2062,8 +2167,11 @@ iw_in_addr(int skfd, | ||
2062 | 2167 | sizeof(struct sockaddr)); |
2063 | 2168 | |
2064 | 2169 | #ifdef DEBUG |
2065 | - printf("IP Address %s => Hw Address = %s\n", | |
2066 | - bufp, iw_ether_ntoa((struct ether_addr *) sap->sa_data)); | |
2170 | + { | |
2171 | + char buf[20]; | |
2172 | + printf("IP Address %s => Hw Address = %s\n", | |
2173 | + bufp, iw_saether_ntop(sap, buf)); | |
2174 | + } | |
2067 | 2175 | #endif |
2068 | 2176 | } |
2069 | 2177 | else /* If it's an hardware address */ |
@@ -2076,7 +2184,7 @@ iw_in_addr(int skfd, | ||
2076 | 2184 | } |
2077 | 2185 | |
2078 | 2186 | /* Get the hardware address */ |
2079 | - if(iw_in_ether(bufp, sap) < 0) | |
2187 | + if(iw_saether_aton(bufp, sap) == 0) | |
2080 | 2188 | { |
2081 | 2189 | fprintf(stderr, "Invalid hardware address %s\n", bufp); |
2082 | 2190 | return(-1); |
@@ -2084,7 +2192,10 @@ iw_in_addr(int skfd, | ||
2084 | 2192 | } |
2085 | 2193 | |
2086 | 2194 | #ifdef DEBUG |
2087 | - printf("Hw Address = %s\n", iw_ether_ntoa((struct ether_addr *) sap->sa_data)); | |
2195 | + { | |
2196 | + char buf[20]; | |
2197 | + printf("Hw Address = %s\n", iw_saether_ntop(sap, buf)); | |
2198 | + } | |
2088 | 2199 | #endif |
2089 | 2200 | |
2090 | 2201 | return(0); |
@@ -2125,6 +2236,8 @@ iw_get_priv_size(int args) | ||
2125 | 2236 | * this case. |
2126 | 2237 | */ |
2127 | 2238 | |
2239 | +/* -------------------------- CONSTANTS -------------------------- */ | |
2240 | + | |
2128 | 2241 | /* Type of headers we know about (basically union iwreq_data) */ |
2129 | 2242 | #define IW_HEADER_TYPE_NULL 0 /* Not available */ |
2130 | 2243 | #define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ |
@@ -2135,69 +2248,315 @@ iw_get_priv_size(int args) | ||
2135 | 2248 | #define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ |
2136 | 2249 | #define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ |
2137 | 2250 | |
2138 | -/* Headers for the various requests */ | |
2139 | -static const char standard_ioctl_hdr[] = { | |
2140 | - IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ | |
2141 | - IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ | |
2142 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ | |
2143 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ | |
2144 | - IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ | |
2145 | - IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ | |
2146 | - IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ | |
2147 | - IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ | |
2148 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ | |
2149 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ | |
2150 | - IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ | |
2151 | - IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ | |
2152 | - IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ | |
2153 | - IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ | |
2154 | - IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ | |
2155 | - IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ | |
2156 | - IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ | |
2157 | - IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ | |
2158 | - IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ | |
2159 | - IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ | |
2160 | - IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ | |
2161 | - IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ | |
2162 | - IW_HEADER_TYPE_NULL, /* -- hole -- */ | |
2163 | - IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ | |
2164 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ | |
2165 | - IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ | |
2166 | - IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ | |
2167 | - IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ | |
2168 | - IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ | |
2169 | - IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ | |
2170 | - IW_HEADER_TYPE_NULL, /* -- hole -- */ | |
2171 | - IW_HEADER_TYPE_NULL, /* -- hole -- */ | |
2172 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ | |
2173 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ | |
2174 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ | |
2175 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ | |
2176 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ | |
2177 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ | |
2178 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ | |
2179 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ | |
2180 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ | |
2181 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ | |
2182 | - IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ | |
2183 | - IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ | |
2184 | - IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ | |
2185 | - IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ | |
2251 | +/* Handling flags */ | |
2252 | +/* Most are not implemented. I just use them as a reminder of some | |
2253 | + * cool features we might need one day ;-) */ | |
2254 | +#define IW_DESCR_FLAG_NONE 0x0000 /* Obvious */ | |
2255 | +/* Wrapper level flags */ | |
2256 | +#define IW_DESCR_FLAG_DUMP 0x0001 /* Not part of the dump command */ | |
2257 | +#define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */ | |
2258 | +#define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */ | |
2259 | + /* SET : Omit payload from generated iwevent */ | |
2260 | +#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */ | |
2261 | +/* Driver level flags */ | |
2262 | +#define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */ | |
2263 | + | |
2264 | +/* ---------------------------- TYPES ---------------------------- */ | |
2265 | + | |
2266 | +/* | |
2267 | + * Describe how a standard IOCTL looks like. | |
2268 | + */ | |
2269 | +struct iw_ioctl_description | |
2270 | +{ | |
2271 | + __u8 header_type; /* NULL, iw_point or other */ | |
2272 | + __u8 token_type; /* Future */ | |
2273 | + __u16 token_size; /* Granularity of payload */ | |
2274 | + __u16 min_tokens; /* Min acceptable token number */ | |
2275 | + __u16 max_tokens; /* Max acceptable token number */ | |
2276 | + __u32 flags; /* Special handling of the request */ | |
2277 | +}; | |
2278 | + | |
2279 | +/* -------------------------- VARIABLES -------------------------- */ | |
2280 | + | |
2281 | +/* | |
2282 | + * Meta-data about all the standard Wireless Extension request we | |
2283 | + * know about. | |
2284 | + */ | |
2285 | +static const struct iw_ioctl_description standard_ioctl_descr[] = { | |
2286 | + [SIOCSIWCOMMIT - SIOCIWFIRST] = { | |
2287 | + .header_type = IW_HEADER_TYPE_NULL, | |
2288 | + }, | |
2289 | + [SIOCGIWNAME - SIOCIWFIRST] = { | |
2290 | + .header_type = IW_HEADER_TYPE_CHAR, | |
2291 | + .flags = IW_DESCR_FLAG_DUMP, | |
2292 | + }, | |
2293 | + [SIOCSIWNWID - SIOCIWFIRST] = { | |
2294 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2295 | + .flags = IW_DESCR_FLAG_EVENT, | |
2296 | + }, | |
2297 | + [SIOCGIWNWID - SIOCIWFIRST] = { | |
2298 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2299 | + .flags = IW_DESCR_FLAG_DUMP, | |
2300 | + }, | |
2301 | + [SIOCSIWFREQ - SIOCIWFIRST] = { | |
2302 | + .header_type = IW_HEADER_TYPE_FREQ, | |
2303 | + .flags = IW_DESCR_FLAG_EVENT, | |
2304 | + }, | |
2305 | + [SIOCGIWFREQ - SIOCIWFIRST] = { | |
2306 | + .header_type = IW_HEADER_TYPE_FREQ, | |
2307 | + .flags = IW_DESCR_FLAG_DUMP, | |
2308 | + }, | |
2309 | + [SIOCSIWMODE - SIOCIWFIRST] = { | |
2310 | + .header_type = IW_HEADER_TYPE_UINT, | |
2311 | + .flags = IW_DESCR_FLAG_EVENT, | |
2312 | + }, | |
2313 | + [SIOCGIWMODE - SIOCIWFIRST] = { | |
2314 | + .header_type = IW_HEADER_TYPE_UINT, | |
2315 | + .flags = IW_DESCR_FLAG_DUMP, | |
2316 | + }, | |
2317 | + [SIOCSIWSENS - SIOCIWFIRST] = { | |
2318 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2319 | + }, | |
2320 | + [SIOCGIWSENS - SIOCIWFIRST] = { | |
2321 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2322 | + }, | |
2323 | + [SIOCSIWRANGE - SIOCIWFIRST] = { | |
2324 | + .header_type = IW_HEADER_TYPE_NULL, | |
2325 | + }, | |
2326 | + [SIOCGIWRANGE - SIOCIWFIRST] = { | |
2327 | + .header_type = IW_HEADER_TYPE_POINT, | |
2328 | + .token_size = 1, | |
2329 | + .max_tokens = sizeof(struct iw_range), | |
2330 | + .flags = IW_DESCR_FLAG_DUMP, | |
2331 | + }, | |
2332 | + [SIOCSIWPRIV - SIOCIWFIRST] = { | |
2333 | + .header_type = IW_HEADER_TYPE_NULL, | |
2334 | + }, | |
2335 | + [SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */ | |
2336 | + .header_type = IW_HEADER_TYPE_NULL, | |
2337 | + }, | |
2338 | + [SIOCSIWSTATS - SIOCIWFIRST] = { | |
2339 | + .header_type = IW_HEADER_TYPE_NULL, | |
2340 | + }, | |
2341 | + [SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */ | |
2342 | + .header_type = IW_HEADER_TYPE_NULL, | |
2343 | + .flags = IW_DESCR_FLAG_DUMP, | |
2344 | + }, | |
2345 | + [SIOCSIWSPY - SIOCIWFIRST] = { | |
2346 | + .header_type = IW_HEADER_TYPE_POINT, | |
2347 | + .token_size = sizeof(struct sockaddr), | |
2348 | + .max_tokens = IW_MAX_SPY, | |
2349 | + }, | |
2350 | + [SIOCGIWSPY - SIOCIWFIRST] = { | |
2351 | + .header_type = IW_HEADER_TYPE_POINT, | |
2352 | + .token_size = sizeof(struct sockaddr) + | |
2353 | + sizeof(struct iw_quality), | |
2354 | + .max_tokens = IW_MAX_SPY, | |
2355 | + }, | |
2356 | + [SIOCSIWTHRSPY - SIOCIWFIRST] = { | |
2357 | + .header_type = IW_HEADER_TYPE_POINT, | |
2358 | + .token_size = sizeof(struct iw_thrspy), | |
2359 | + .min_tokens = 1, | |
2360 | + .max_tokens = 1, | |
2361 | + }, | |
2362 | + [SIOCGIWTHRSPY - SIOCIWFIRST] = { | |
2363 | + .header_type = IW_HEADER_TYPE_POINT, | |
2364 | + .token_size = sizeof(struct iw_thrspy), | |
2365 | + .min_tokens = 1, | |
2366 | + .max_tokens = 1, | |
2367 | + }, | |
2368 | + [SIOCSIWAP - SIOCIWFIRST] = { | |
2369 | + .header_type = IW_HEADER_TYPE_ADDR, | |
2370 | + }, | |
2371 | + [SIOCGIWAP - SIOCIWFIRST] = { | |
2372 | + .header_type = IW_HEADER_TYPE_ADDR, | |
2373 | + .flags = IW_DESCR_FLAG_DUMP, | |
2374 | + }, | |
2375 | + [SIOCSIWMLME - SIOCIWFIRST] = { | |
2376 | + .header_type = IW_HEADER_TYPE_POINT, | |
2377 | + .token_size = 1, | |
2378 | + .min_tokens = sizeof(struct iw_mlme), | |
2379 | + .max_tokens = sizeof(struct iw_mlme), | |
2380 | + }, | |
2381 | + [SIOCGIWAPLIST - SIOCIWFIRST] = { | |
2382 | + .header_type = IW_HEADER_TYPE_POINT, | |
2383 | + .token_size = sizeof(struct sockaddr) + | |
2384 | + sizeof(struct iw_quality), | |
2385 | + .max_tokens = IW_MAX_AP, | |
2386 | + .flags = IW_DESCR_FLAG_NOMAX, | |
2387 | + }, | |
2388 | + [SIOCSIWSCAN - SIOCIWFIRST] = { | |
2389 | + .header_type = IW_HEADER_TYPE_POINT, | |
2390 | + .token_size = 1, | |
2391 | + .min_tokens = 0, | |
2392 | + .max_tokens = sizeof(struct iw_scan_req), | |
2393 | + }, | |
2394 | + [SIOCGIWSCAN - SIOCIWFIRST] = { | |
2395 | + .header_type = IW_HEADER_TYPE_POINT, | |
2396 | + .token_size = 1, | |
2397 | + .max_tokens = IW_SCAN_MAX_DATA, | |
2398 | + .flags = IW_DESCR_FLAG_NOMAX, | |
2399 | + }, | |
2400 | + [SIOCSIWESSID - SIOCIWFIRST] = { | |
2401 | + .header_type = IW_HEADER_TYPE_POINT, | |
2402 | + .token_size = 1, | |
2403 | + .max_tokens = IW_ESSID_MAX_SIZE + 1, | |
2404 | + .flags = IW_DESCR_FLAG_EVENT, | |
2405 | + }, | |
2406 | + [SIOCGIWESSID - SIOCIWFIRST] = { | |
2407 | + .header_type = IW_HEADER_TYPE_POINT, | |
2408 | + .token_size = 1, | |
2409 | + .max_tokens = IW_ESSID_MAX_SIZE + 1, | |
2410 | + .flags = IW_DESCR_FLAG_DUMP, | |
2411 | + }, | |
2412 | + [SIOCSIWNICKN - SIOCIWFIRST] = { | |
2413 | + .header_type = IW_HEADER_TYPE_POINT, | |
2414 | + .token_size = 1, | |
2415 | + .max_tokens = IW_ESSID_MAX_SIZE + 1, | |
2416 | + }, | |
2417 | + [SIOCGIWNICKN - SIOCIWFIRST] = { | |
2418 | + .header_type = IW_HEADER_TYPE_POINT, | |
2419 | + .token_size = 1, | |
2420 | + .max_tokens = IW_ESSID_MAX_SIZE + 1, | |
2421 | + }, | |
2422 | + [SIOCSIWRATE - SIOCIWFIRST] = { | |
2423 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2424 | + }, | |
2425 | + [SIOCGIWRATE - SIOCIWFIRST] = { | |
2426 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2427 | + }, | |
2428 | + [SIOCSIWRTS - SIOCIWFIRST] = { | |
2429 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2430 | + }, | |
2431 | + [SIOCGIWRTS - SIOCIWFIRST] = { | |
2432 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2433 | + }, | |
2434 | + [SIOCSIWFRAG - SIOCIWFIRST] = { | |
2435 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2436 | + }, | |
2437 | + [SIOCGIWFRAG - SIOCIWFIRST] = { | |
2438 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2439 | + }, | |
2440 | + [SIOCSIWTXPOW - SIOCIWFIRST] = { | |
2441 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2442 | + }, | |
2443 | + [SIOCGIWTXPOW - SIOCIWFIRST] = { | |
2444 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2445 | + }, | |
2446 | + [SIOCSIWRETRY - SIOCIWFIRST] = { | |
2447 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2448 | + }, | |
2449 | + [SIOCGIWRETRY - SIOCIWFIRST] = { | |
2450 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2451 | + }, | |
2452 | + [SIOCSIWENCODE - SIOCIWFIRST] = { | |
2453 | + .header_type = IW_HEADER_TYPE_POINT, | |
2454 | + .token_size = 1, | |
2455 | + .max_tokens = IW_ENCODING_TOKEN_MAX, | |
2456 | + .flags = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT, | |
2457 | + }, | |
2458 | + [SIOCGIWENCODE - SIOCIWFIRST] = { | |
2459 | + .header_type = IW_HEADER_TYPE_POINT, | |
2460 | + .token_size = 1, | |
2461 | + .max_tokens = IW_ENCODING_TOKEN_MAX, | |
2462 | + .flags = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT, | |
2463 | + }, | |
2464 | + [SIOCSIWPOWER - SIOCIWFIRST] = { | |
2465 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2466 | + }, | |
2467 | + [SIOCGIWPOWER - SIOCIWFIRST] = { | |
2468 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2469 | + }, | |
2470 | + [SIOCSIWGENIE - SIOCIWFIRST] = { | |
2471 | + .header_type = IW_HEADER_TYPE_POINT, | |
2472 | + .token_size = 1, | |
2473 | + .max_tokens = IW_GENERIC_IE_MAX, | |
2474 | + }, | |
2475 | + [SIOCGIWGENIE - SIOCIWFIRST] = { | |
2476 | + .header_type = IW_HEADER_TYPE_POINT, | |
2477 | + .token_size = 1, | |
2478 | + .max_tokens = IW_GENERIC_IE_MAX, | |
2479 | + }, | |
2480 | + [SIOCSIWAUTH - SIOCIWFIRST] = { | |
2481 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2482 | + }, | |
2483 | + [SIOCGIWAUTH - SIOCIWFIRST] = { | |
2484 | + .header_type = IW_HEADER_TYPE_PARAM, | |
2485 | + }, | |
2486 | + [SIOCSIWENCODEEXT - SIOCIWFIRST] = { | |
2487 | + .header_type = IW_HEADER_TYPE_POINT, | |
2488 | + .token_size = 1, | |
2489 | + .min_tokens = sizeof(struct iw_encode_ext), | |
2490 | + .max_tokens = sizeof(struct iw_encode_ext) + | |
2491 | + IW_ENCODING_TOKEN_MAX, | |
2492 | + }, | |
2493 | + [SIOCGIWENCODEEXT - SIOCIWFIRST] = { | |
2494 | + .header_type = IW_HEADER_TYPE_POINT, | |
2495 | + .token_size = 1, | |
2496 | + .min_tokens = sizeof(struct iw_encode_ext), | |
2497 | + .max_tokens = sizeof(struct iw_encode_ext) + | |
2498 | + IW_ENCODING_TOKEN_MAX, | |
2499 | + }, | |
2500 | + [SIOCSIWPMKSA - SIOCIWFIRST] = { | |
2501 | + .header_type = IW_HEADER_TYPE_POINT, | |
2502 | + .token_size = 1, | |
2503 | + .min_tokens = sizeof(struct iw_pmksa), | |
2504 | + .max_tokens = sizeof(struct iw_pmksa), | |
2505 | + }, | |
2186 | 2506 | }; |
2187 | -static const unsigned int standard_ioctl_num = sizeof(standard_ioctl_hdr); | |
2507 | +static const unsigned int standard_ioctl_num = (sizeof(standard_ioctl_descr) / | |
2508 | + sizeof(struct iw_ioctl_description)); | |
2188 | 2509 | |
2189 | 2510 | /* |
2190 | 2511 | * Meta-data about all the additional standard Wireless Extension events |
2191 | 2512 | * we know about. |
2192 | 2513 | */ |
2193 | -static const char standard_event_hdr[] = { | |
2194 | - IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ | |
2195 | - IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ | |
2196 | - IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ | |
2197 | - IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ | |
2198 | - IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ | |
2514 | +static const struct iw_ioctl_description standard_event_descr[] = { | |
2515 | + [IWEVTXDROP - IWEVFIRST] = { | |
2516 | + .header_type = IW_HEADER_TYPE_ADDR, | |
2517 | + }, | |
2518 | + [IWEVQUAL - IWEVFIRST] = { | |
2519 | + .header_type = IW_HEADER_TYPE_QUAL, | |
2520 | + }, | |
2521 | + [IWEVCUSTOM - IWEVFIRST] = { | |
2522 | + .header_type = IW_HEADER_TYPE_POINT, | |
2523 | + .token_size = 1, | |
2524 | + .max_tokens = IW_CUSTOM_MAX, | |
2525 | + }, | |
2526 | + [IWEVREGISTERED - IWEVFIRST] = { | |
2527 | + .header_type = IW_HEADER_TYPE_ADDR, | |
2528 | + }, | |
2529 | + [IWEVEXPIRED - IWEVFIRST] = { | |
2530 | + .header_type = IW_HEADER_TYPE_ADDR, | |
2531 | + }, | |
2532 | + [IWEVGENIE - IWEVFIRST] = { | |
2533 | + .header_type = IW_HEADER_TYPE_POINT, | |
2534 | + .token_size = 1, | |
2535 | + .max_tokens = IW_GENERIC_IE_MAX, | |
2536 | + }, | |
2537 | + [IWEVMICHAELMICFAILURE - IWEVFIRST] = { | |
2538 | + .header_type = IW_HEADER_TYPE_POINT, | |
2539 | + .token_size = 1, | |
2540 | + .max_tokens = sizeof(struct iw_michaelmicfailure), | |
2541 | + }, | |
2542 | + [IWEVASSOCREQIE - IWEVFIRST] = { | |
2543 | + .header_type = IW_HEADER_TYPE_POINT, | |
2544 | + .token_size = 1, | |
2545 | + .max_tokens = IW_GENERIC_IE_MAX, | |
2546 | + }, | |
2547 | + [IWEVASSOCRESPIE - IWEVFIRST] = { | |
2548 | + .header_type = IW_HEADER_TYPE_POINT, | |
2549 | + .token_size = 1, | |
2550 | + .max_tokens = IW_GENERIC_IE_MAX, | |
2551 | + }, | |
2552 | + [IWEVPMKIDCAND - IWEVFIRST] = { | |
2553 | + .header_type = IW_HEADER_TYPE_POINT, | |
2554 | + .token_size = 1, | |
2555 | + .max_tokens = sizeof(struct iw_pmkid_cand), | |
2556 | + }, | |
2199 | 2557 | }; |
2200 | -static const unsigned int standard_event_num = sizeof(standard_event_hdr); | |
2558 | +static const unsigned int standard_event_num = (sizeof(standard_event_descr) / | |
2559 | + sizeof(struct iw_ioctl_description)); | |
2201 | 2560 | |
2202 | 2561 | /* Size (in bytes) of various events */ |
2203 | 2562 | static const int event_type_size[] = { |
@@ -2214,10 +2573,6 @@ static const int event_type_size[] = { | ||
2214 | 2573 | IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ |
2215 | 2574 | }; |
2216 | 2575 | |
2217 | -/* Forward compatibility with WE-19 */ | |
2218 | -#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ | |
2219 | - (char *) NULL) | |
2220 | - | |
2221 | 2576 | /*------------------------------------------------------------------*/ |
2222 | 2577 | /* |
2223 | 2578 | * 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 */ | ||
2245 | 2600 | struct iw_event * iwe, /* Extracted event */ |
2246 | 2601 | int we_version) |
2247 | 2602 | { |
2603 | + const struct iw_ioctl_description * descr = NULL; | |
2248 | 2604 | int event_type = 0; |
2249 | 2605 | unsigned int event_len = 1; /* Invalid */ |
2250 | 2606 | char * pointer; |
@@ -2258,7 +2614,7 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2258 | 2614 | if((stream->current + IW_EV_LCP_LEN) > stream->end) |
2259 | 2615 | return(0); |
2260 | 2616 | |
2261 | -#if 0 | |
2617 | +#if DEBUG | |
2262 | 2618 | printf("DBG - stream->current = %p, stream->value = %p, stream->end = %p\n", |
2263 | 2619 | stream->current, stream->value, stream->end); |
2264 | 2620 | #endif |
@@ -2267,7 +2623,7 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2267 | 2623 | * Note : the event may be unaligned, therefore copy... */ |
2268 | 2624 | memcpy((char *) iwe, stream->current, IW_EV_LCP_LEN); |
2269 | 2625 | |
2270 | -#if 0 | |
2626 | +#if DEBUG | |
2271 | 2627 | printf("DBG - iwe->cmd = 0x%X, iwe->len = %d\n", |
2272 | 2628 | iwe->cmd, iwe->len); |
2273 | 2629 | #endif |
@@ -2281,19 +2637,21 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2281 | 2637 | { |
2282 | 2638 | cmd_index = iwe->cmd - SIOCIWFIRST; |
2283 | 2639 | if(cmd_index < standard_ioctl_num) |
2284 | - event_type = standard_ioctl_hdr[cmd_index]; | |
2640 | + descr = &(standard_ioctl_descr[cmd_index]); | |
2285 | 2641 | } |
2286 | 2642 | else |
2287 | 2643 | { |
2288 | 2644 | cmd_index = iwe->cmd - IWEVFIRST; |
2289 | 2645 | if(cmd_index < standard_event_num) |
2290 | - event_type = standard_event_hdr[cmd_index]; | |
2646 | + descr = &(standard_event_descr[cmd_index]); | |
2291 | 2647 | } |
2648 | + if(descr != NULL) | |
2649 | + event_type = descr->header_type; | |
2292 | 2650 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ |
2293 | 2651 | event_len = event_type_size[event_type]; |
2294 | - /* Fixup for later version of WE */ | |
2295 | - if((we_version > 18) && (event_type == IW_HEADER_TYPE_POINT)) | |
2296 | - event_len -= IW_EV_POINT_OFF; | |
2652 | + /* Fixup for earlier version of WE */ | |
2653 | + if((we_version <= 18) && (event_type == IW_HEADER_TYPE_POINT)) | |
2654 | + event_len += IW_EV_POINT_OFF; | |
2297 | 2655 | |
2298 | 2656 | /* Check if we know about this event */ |
2299 | 2657 | if(event_len <= IW_EV_LCP_LEN) |
@@ -2310,7 +2668,7 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2310 | 2668 | else |
2311 | 2669 | pointer = stream->current + IW_EV_LCP_LEN; /* First value in event */ |
2312 | 2670 | |
2313 | -#if 0 | |
2671 | +#if DEBUG | |
2314 | 2672 | printf("DBG - event_type = %d, event_len = %d, pointer = %p\n", |
2315 | 2673 | event_type, event_len, pointer); |
2316 | 2674 | #endif |
@@ -2322,7 +2680,7 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2322 | 2680 | stream->current += iwe->len; |
2323 | 2681 | return(-2); |
2324 | 2682 | } |
2325 | - /* Fixup for later version of WE */ | |
2683 | + /* Fixup for WE-19 and later : pointer no longer in the stream */ | |
2326 | 2684 | if((we_version > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
2327 | 2685 | memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, |
2328 | 2686 | pointer, event_len); |
@@ -2336,9 +2694,40 @@ iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */ | ||
2336 | 2694 | if(event_type == IW_HEADER_TYPE_POINT) |
2337 | 2695 | { |
2338 | 2696 | /* Check the length of the payload */ |
2339 | - if((iwe->len - (event_len + IW_EV_LCP_LEN)) > 0) | |
2340 | - /* Set pointer on variable part (warning : non aligned) */ | |
2341 | - iwe->u.data.pointer = pointer; | |
2697 | + unsigned int extra_len = iwe->len - (event_len + IW_EV_LCP_LEN); | |
2698 | + if(extra_len > 0) | |
2699 | + { | |
2700 | + /* Set pointer on variable part (warning : non aligned) */ | |
2701 | + iwe->u.data.pointer = pointer; | |
2702 | + | |
2703 | + /* Check that we have a descriptor for the command */ | |
2704 | + if(descr == NULL) | |
2705 | + /* Can't check payload -> unsafe... */ | |
2706 | + iwe->u.data.pointer = NULL; /* Discard paylod */ | |
2707 | + else | |
2708 | + { | |
2709 | + /* Those checks are actually pretty hard to trigger, | |
2710 | + * because of the checks done in the kernel... */ | |
2711 | + | |
2712 | + /* Discard bogus events which advertise more tokens than | |
2713 | + * what they carry... */ | |
2714 | + unsigned int token_len = iwe->u.data.length * descr->token_size; | |
2715 | + if(token_len > extra_len) | |
2716 | + iwe->u.data.pointer = NULL; /* Discard paylod */ | |
2717 | + /* Check that the advertised token size is not going to | |
2718 | + * produce buffer overflow to our caller... */ | |
2719 | + if((iwe->u.data.length > descr->max_tokens) | |
2720 | + && !(descr->flags & IW_DESCR_FLAG_NOMAX)) | |
2721 | + iwe->u.data.pointer = NULL; /* Discard paylod */ | |
2722 | + /* Same for underflows... */ | |
2723 | + if(iwe->u.data.length < descr->min_tokens) | |
2724 | + iwe->u.data.pointer = NULL; /* Discard paylod */ | |
2725 | +#if DEBUG | |
2726 | + printf("DBG - extra_len = %d, token_len = %d, token = %d, max = %d, min = %d\n", | |
2727 | + extra_len, token_len, iwe->u.data.length, descr->max_tokens, descr->min_tokens); | |
2728 | +#endif | |
2729 | + } | |
2730 | + } | |
2342 | 2731 | else |
2343 | 2732 | /* No data */ |
2344 | 2733 | iwe->u.data.pointer = NULL; |
@@ -2439,9 +2828,9 @@ iw_process_scanning_token(struct iw_event * event, | ||
2439 | 2828 | case SIOCGIWESSID: |
2440 | 2829 | wscan->b.has_essid = 1; |
2441 | 2830 | wscan->b.essid_on = event->u.data.flags; |
2831 | + memset(wscan->b.essid, '\0', IW_ESSID_MAX_SIZE+1); | |
2442 | 2832 | if((event->u.essid.pointer) && (event->u.essid.length)) |
2443 | 2833 | memcpy(wscan->b.essid, event->u.essid.pointer, event->u.essid.length); |
2444 | - wscan->b.essid[event->u.essid.length] = '\0'; | |
2445 | 2834 | break; |
2446 | 2835 | case SIOCGIWENCODE: |
2447 | 2836 | wscan->b.has_key = 1; |
@@ -2455,7 +2844,7 @@ iw_process_scanning_token(struct iw_event * event, | ||
2455 | 2844 | case IWEVQUAL: |
2456 | 2845 | /* We don't get complete stats, only qual */ |
2457 | 2846 | wscan->has_stats = 1; |
2458 | - memcpy(&wscan->stats.qual, &event->u.qual, sizeof(iwstats)); | |
2847 | + memcpy(&wscan->stats.qual, &event->u.qual, sizeof(struct iw_quality)); | |
2459 | 2848 | break; |
2460 | 2849 | case SIOCGIWRATE: |
2461 | 2850 | /* Scan may return a list of bitrates. Should we really bother with |
@@ -2489,9 +2878,9 @@ iw_process_scan(int skfd, | ||
2489 | 2878 | int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */ |
2490 | 2879 | unsigned char * newbuf; |
2491 | 2880 | |
2492 | - /* Don't waste too much time on interfaces (50 * 100 = 5s) */ | |
2881 | + /* Don't waste too much time on interfaces (150 * 100 = 15s) */ | |
2493 | 2882 | context->retry++; |
2494 | - if(context->retry > 50) | |
2883 | + if(context->retry > 150) | |
2495 | 2884 | { |
2496 | 2885 | errno = ETIME; |
2497 | 2886 | return(-1); |
@@ -2570,7 +2959,7 @@ iw_process_scan(int skfd, | ||
2570 | 2959 | struct stream_descr stream; |
2571 | 2960 | struct wireless_scan * wscan = NULL; |
2572 | 2961 | int ret; |
2573 | -#if 0 | |
2962 | +#if DEBUG | |
2574 | 2963 | /* Debugging code. In theory useless, because it's debugged ;-) */ |
2575 | 2964 | int i; |
2576 | 2965 | printf("Scan result [%02X", buffer[0]); |
@@ -2580,7 +2969,7 @@ iw_process_scan(int skfd, | ||
2580 | 2969 | #endif |
2581 | 2970 | |
2582 | 2971 | /* Init */ |
2583 | - iw_init_event_stream(&stream, buffer, wrq.u.data.length); | |
2972 | + iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length); | |
2584 | 2973 | /* This is dangerous, we may leak user data... */ |
2585 | 2974 | context->result = NULL; |
2586 | 2975 |
@@ -45,8 +45,7 @@ | ||
45 | 45 | && __GLIBC__ == 2 \ |
46 | 46 | && __GLIBC_MINOR__ >= 2 \ |
47 | 47 | && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) |
48 | -//#define GLIBC22_HEADERS | |
49 | -#define GENERIC_HEADERS | |
48 | +#define HEADERS_GENERIC | |
50 | 49 | |
51 | 50 | /* Kernel headers 2.4.X + Glibc 2.1 - Debian 2.2 upgraded, RH 7.0 |
52 | 51 | * Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH 6.1 */ |
@@ -54,81 +53,42 @@ | ||
54 | 53 | && __GLIBC__ == 2 \ |
55 | 54 | && __GLIBC_MINOR__ == 1 \ |
56 | 55 | && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) |
57 | -//#define GLIBC_HEADERS | |
58 | -#define GENERIC_HEADERS | |
59 | - | |
60 | -/* Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 */ | |
61 | -#elif defined(__GLIBC__) \ | |
62 | - && __GLIBC__ == 2 \ | |
63 | - && __GLIBC_MINOR__ == 0 \ | |
64 | - && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0) \ | |
65 | - && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) | |
66 | -#define GLIBC_HEADERS | |
67 | -#define KLUDGE_HEADERS | |
68 | - | |
69 | -/* Note : is it really worth supporting kernel 2.0.X, knowing that | |
70 | - * we require WE v9, which is only available in 2.2.X and higher ? | |
71 | - * I guess one could use 2.0.x with an upgraded wireless.h... */ | |
72 | - | |
73 | -/* Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH 5 */ | |
74 | -#elif defined(__GLIBC__) \ | |
75 | - && __GLIBC__ == 2 \ | |
76 | - && __GLIBC_MINOR__ == 0 \ | |
77 | - && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) \ | |
78 | - && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0) | |
79 | -#define GLIBC_HEADERS | |
80 | - | |
81 | -/* Kernel headers 2.0.X + libc5 - old systems */ | |
82 | -#elif defined(_LINUX_C_LIB_VERSION_MAJOR) \ | |
83 | - && _LINUX_C_LIB_VERSION_MAJOR == 5 \ | |
84 | - && LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,0) \ | |
85 | - && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) | |
86 | -#define LIBC5_HEADERS | |
56 | +#define HEADERS_GENERIC | |
57 | +#define HEADERS_KERNEL | |
87 | 58 | |
88 | 59 | /* Unsupported combination */ |
89 | 60 | #else |
90 | 61 | #error "Your kernel/libc combination is not supported" |
91 | 62 | #endif |
92 | 63 | |
93 | -#ifdef GENERIC_HEADERS | |
64 | +#ifdef HEADERS_GENERIC | |
94 | 65 | /* Proposed by Dr. Michael Rietz <rietz@mail.amps.de>, 27.3.2 */ |
95 | -/* If this works for all, it might be more stable on the long term - Jean II */ | |
96 | 66 | #include <net/if_arp.h> /* For ARPHRD_ETHER */ |
97 | 67 | #include <sys/socket.h> /* For AF_INET & struct sockaddr */ |
98 | 68 | #include <netinet/in.h> /* For struct sockaddr_in */ |
99 | 69 | #include <netinet/if_ether.h> |
100 | -#endif /* GENERIC_HEADERS */ | |
101 | - | |
102 | -#ifdef GLIBC22_HEADERS | |
103 | -/* Added by Ross G. Miller <Ross_Miller@baylor.edu>, 3/28/01 */ | |
104 | -#include <linux/if_arp.h> /* For ARPHRD_ETHER */ | |
105 | -#include <linux/socket.h> /* For AF_INET & struct sockaddr */ | |
106 | -#include <sys/socket.h> | |
107 | -#endif /* GLIBC22_HEADERS */ | |
108 | - | |
109 | -#ifdef KLUDGE_HEADERS | |
110 | -#include <socketbits.h> | |
111 | -#endif /* KLUDGE_HEADERS */ | |
112 | - | |
113 | -#ifdef GLIBC_HEADERS | |
114 | -#include <linux/if_arp.h> /* For ARPHRD_ETHER */ | |
115 | -#include <linux/socket.h> /* For AF_INET & struct sockaddr */ | |
116 | -#include <linux/in.h> /* For struct sockaddr_in */ | |
117 | -#endif /* KLUDGE_HEADERS || GLIBC_HEADERS */ | |
118 | - | |
119 | -#ifdef LIBC5_HEADERS | |
120 | -#include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */ | |
121 | -#include <linux/if_arp.h> /* For ARPHRD_ETHER */ | |
122 | -#include <linux/in.h> /* For struct sockaddr_in */ | |
123 | -#endif /* LIBC5_HEADERS */ | |
124 | - | |
125 | -/* Those 3 headers were previously included in wireless.h */ | |
70 | +#endif /* HEADERS_GENERIC */ | |
71 | + | |
72 | +/* Fixup to be able to include kernel includes in userspace. | |
73 | + * Basically, kill the sparse annotations... Jean II */ | |
74 | +#ifndef __user | |
75 | +#define __user | |
76 | +#endif | |
77 | + | |
126 | 78 | #include <linux/types.h> /* for "caddr_t" et al */ |
79 | + | |
80 | +#ifdef HEADERS_KERNEL | |
81 | +/* Traditionally we have used kernel headers, included in wireless.h */ | |
127 | 82 | #include <linux/socket.h> /* for "struct sockaddr" et al */ |
128 | 83 | #include <linux/if.h> /* for IFNAMSIZ and co... */ |
84 | +#else /* !HEADERS_KERNEL */ | |
85 | +/* Glibc systems headers are supposedly less problematic than kernel ones */ | |
86 | +#include <sys/socket.h> /* for "struct sockaddr" et al */ | |
87 | +#include <net/if.h> /* for IFNAMSIZ and co... */ | |
88 | +#endif /* !HEADERS_KERNEL */ | |
129 | 89 | |
130 | -/* Private copy of Wireless extensions */ | |
131 | -#include <wireless.h> | |
90 | +/* Private copy of Wireless extensions (in this directoty) */ | |
91 | +#include "wireless.h" | |
132 | 92 | |
133 | 93 | /* Make gcc understant that when we say inline, we mean it. |
134 | 94 | * I really hate when the compiler is trying to be more clever than me, |
@@ -139,11 +99,26 @@ | ||
139 | 99 | * Fortunately, in gcc 3.4, they now automatically inline static functions |
140 | 100 | * with a single call site. Hurrah ! |
141 | 101 | * Jean II */ |
102 | +#undef IW_GCC_HAS_BROKEN_INLINE | |
142 | 103 | #if __GNUC__ == 3 |
143 | 104 | #if __GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 4 |
105 | +#define IW_GCC_HAS_BROKEN_INLINE 1 | |
106 | +#endif /* __GNUC_MINOR__ */ | |
107 | +#endif /* __GNUC__ */ | |
108 | +/* However, gcc 4.0 has introduce a new "feature", when compiling with | |
109 | + * '-Os', it does not want to inline iw_ether_cmp() and friends. | |
110 | + * So, we need to fix inline again ! | |
111 | + * Jean II */ | |
112 | +#if __GNUC__ == 4 | |
113 | +#define IW_GCC_HAS_BROKEN_INLINE 1 | |
114 | +#endif /* __GNUC__ */ | |
115 | +/* Now, really fix the inline */ | |
116 | +#ifdef IW_GCC_HAS_BROKEN_INLINE | |
117 | +#ifdef inline | |
118 | +#undef inline | |
119 | +#endif /* inline */ | |
144 | 120 | #define inline inline __attribute__((always_inline)) |
145 | -#endif | |
146 | -#endif /* __GNUC__ */ | |
121 | +#endif /* IW_GCC_HAS_BROKEN_INLINE */ | |
147 | 122 | |
148 | 123 | #ifdef __cplusplus |
149 | 124 | extern "C" { |
@@ -156,9 +131,11 @@ extern "C" { | ||
156 | 131 | |
157 | 132 | /* Various versions information */ |
158 | 133 | /* Recommended Wireless Extension version */ |
159 | -#define WE_VERSION 17 | |
134 | +#define WE_VERSION 20 | |
135 | +/* Maximum forward compatibility built in this version of WT */ | |
136 | +#define WE_MAX_VERSION 21 | |
160 | 137 | /* Version of Wireless Tools */ |
161 | -#define WT_VERSION 27 | |
138 | +#define WT_VERSION 28 | |
162 | 139 | |
163 | 140 | /* Paths */ |
164 | 141 | #define PROC_NET_WIRELESS "/proc/net/wireless" |
@@ -171,31 +148,10 @@ extern "C" { | ||
171 | 148 | /* For doing log10/exp10 without libm */ |
172 | 149 | #define LOG10_MAGIC 1.25892541179 |
173 | 150 | |
174 | -/* Backward compatibility for Wireless Extension 9 */ | |
175 | -#ifndef IW_POWER_MODIFIER | |
176 | -#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */ | |
177 | -#define IW_POWER_MIN 0x0001 /* Value is a minimum */ | |
178 | -#define IW_POWER_MAX 0x0002 /* Value is a maximum */ | |
179 | -#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */ | |
180 | -#endif /* IW_POWER_MODIFIER */ | |
181 | - | |
182 | -#ifndef IW_ENCODE_NOKEY | |
183 | -#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not here */ | |
184 | -#define IW_ENCODE_MODE 0xF000 /* Modes defined below */ | |
185 | -#endif /* IW_ENCODE_NOKEY */ | |
186 | -#ifndef IW_ENCODE_TEMP | |
187 | -#define IW_ENCODE_TEMP 0x0400 /* Temporary key */ | |
188 | -#endif /* IW_ENCODE_TEMP */ | |
189 | - | |
190 | -/* More backward compatibility */ | |
191 | -#ifndef SIOCSIWCOMMIT | |
192 | -#define SIOCSIWCOMMIT SIOCSIWNAME | |
193 | -#endif /* SIOCSIWCOMMIT */ | |
194 | - | |
195 | -/* Still more backward compatibility */ | |
196 | -#ifndef IW_FREQ_FIXED | |
197 | -#define IW_FREQ_FIXED 0x01 | |
198 | -#endif /* IW_FREQ_FIXED */ | |
151 | +/* Backward compatibility for network headers */ | |
152 | +#ifndef ARPHRD_IEEE80211 | |
153 | +#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */ | |
154 | +#endif /* ARPHRD_IEEE80211 */ | |
199 | 155 | |
200 | 156 | /****************************** TYPES ******************************/ |
201 | 157 |
@@ -261,6 +217,14 @@ typedef struct wireless_info | ||
261 | 217 | int has_stats; |
262 | 218 | iwrange range; |
263 | 219 | int has_range; |
220 | + | |
221 | + /* Auth params for WPA/802.1x/802.11i */ | |
222 | + int auth_key_mgmt; | |
223 | + int has_auth_key_mgmt; | |
224 | + int auth_cipher_pairwise; | |
225 | + int has_auth_cipher_pairwise; | |
226 | + int auth_cipher_group; | |
227 | + int has_auth_cipher_group; | |
264 | 228 | } wireless_info; |
265 | 229 | |
266 | 230 | /* Structure for storing an entry of a wireless scan. |
@@ -428,37 +392,51 @@ void | ||
428 | 392 | int flags); |
429 | 393 | /* ----------------------- TIME SUBROUTINES ----------------------- */ |
430 | 394 | void |
431 | - iw_print_timeval(char * buffer, | |
432 | - int buflen, | |
433 | - const struct timeval * time); | |
395 | + iw_print_timeval(char * buffer, | |
396 | + int buflen, | |
397 | + const struct timeval * time, | |
398 | + const struct timezone * tz); | |
434 | 399 | /* --------------------- ADDRESS SUBROUTINES ---------------------- */ |
435 | 400 | int |
436 | - iw_check_mac_addr_type(int skfd, | |
437 | - char * ifname); | |
401 | + iw_check_mac_addr_type(int skfd, | |
402 | + const char * ifname); | |
438 | 403 | int |
439 | - iw_check_if_addr_type(int skfd, | |
440 | - char * ifname); | |
404 | + iw_check_if_addr_type(int skfd, | |
405 | + const char * ifname); | |
441 | 406 | #if 0 |
442 | 407 | int |
443 | 408 | iw_check_addr_type(int skfd, |
444 | - char * ifname); | |
409 | + const char * ifname); | |
445 | 410 | #endif |
411 | +#if 0 | |
446 | 412 | int |
447 | 413 | iw_get_mac_addr(int skfd, |
448 | 414 | const char * name, |
449 | 415 | struct ether_addr * eth, |
450 | 416 | unsigned short * ptype); |
417 | +#endif | |
418 | +char * | |
419 | + iw_mac_ntop(const unsigned char * mac, | |
420 | + int maclen, | |
421 | + char * buf, | |
422 | + int buflen); | |
451 | 423 | void |
452 | - iw_ether_ntop(const struct ether_addr* eth, char* buf); | |
453 | -char* | |
454 | - iw_ether_ntoa(const struct ether_addr* eth); | |
424 | + iw_ether_ntop(const struct ether_addr * eth, | |
425 | + char * buf); | |
426 | +char * | |
427 | + iw_sawap_ntop(const struct sockaddr * sap, | |
428 | + char * buf); | |
429 | +int | |
430 | + iw_mac_aton(const char * orig, | |
431 | + unsigned char * mac, | |
432 | + int macmax); | |
455 | 433 | int |
456 | 434 | iw_ether_aton(const char* bufp, struct ether_addr* eth); |
457 | 435 | int |
458 | 436 | iw_in_inet(char *bufp, struct sockaddr *sap); |
459 | 437 | int |
460 | 438 | iw_in_addr(int skfd, |
461 | - char * ifname, | |
439 | + const char * ifname, | |
462 | 440 | char * bufp, |
463 | 441 | struct sockaddr * sap); |
464 | 442 | /* ----------------------- MISC SUBROUTINES ------------------------ */ |
@@ -545,21 +523,24 @@ iw_sockets_close(int skfd) | ||
545 | 523 | } |
546 | 524 | |
547 | 525 | /*------------------------------------------------------------------*/ |
548 | -/* Backwards compatability | |
549 | - * Actually, those form are much easier to use when dealing with | |
550 | - * struct sockaddr... */ | |
551 | -static inline char* | |
552 | -iw_pr_ether(char* bufp, const unsigned char* addr) | |
526 | +/* | |
527 | + * Display an Ethernet Socket Address in readable format. | |
528 | + */ | |
529 | +static inline char * | |
530 | +iw_saether_ntop(const struct sockaddr *sap, char* bufp) | |
553 | 531 | { |
554 | - iw_ether_ntop((const struct ether_addr *) addr, bufp); | |
532 | + iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp); | |
555 | 533 | return bufp; |
556 | 534 | } |
557 | -/* Backwards compatability */ | |
535 | +/*------------------------------------------------------------------*/ | |
536 | +/* | |
537 | + * Input an Ethernet Socket Address and convert to binary. | |
538 | + */ | |
558 | 539 | static inline int |
559 | -iw_in_ether(const char *bufp, struct sockaddr *sap) | |
540 | +iw_saether_aton(const char *bufp, struct sockaddr *sap) | |
560 | 541 | { |
561 | 542 | sap->sa_family = ARPHRD_ETHER; |
562 | - return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data) ? 0 : -1; | |
543 | + return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data); | |
563 | 544 | } |
564 | 545 | |
565 | 546 | /*------------------------------------------------------------------*/ |
@@ -584,6 +565,16 @@ iw_null_ether(struct sockaddr *sap) | ||
584 | 565 | memset((char *) sap->sa_data, 0x00, ETH_ALEN); |
585 | 566 | } |
586 | 567 | |
568 | +/*------------------------------------------------------------------*/ | |
569 | +/* | |
570 | + * Compare two ethernet addresses | |
571 | + */ | |
572 | +static inline int | |
573 | +iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2) | |
574 | +{ | |
575 | + return memcmp(eth1, eth2, sizeof(*eth1)); | |
576 | +} | |
577 | + | |
587 | 578 | #ifdef __cplusplus |
588 | 579 | } |
589 | 580 | #endif |
@@ -14,6 +14,19 @@ | ||
14 | 14 | #include "iwlib.h" /* Header */ |
15 | 15 | #include <sys/time.h> |
16 | 16 | |
17 | +/****************************** TYPES ******************************/ | |
18 | + | |
19 | +/* | |
20 | + * Scan state and meta-information, used to decode events... | |
21 | + */ | |
22 | +typedef struct iwscan_state | |
23 | +{ | |
24 | + /* State */ | |
25 | + int ap_num; /* Access Point number 1->N */ | |
26 | + int val_index; /* Value in table 0->(N-1) */ | |
27 | +} iwscan_state; | |
28 | + | |
29 | + | |
17 | 30 | /*********************** FREQUENCIES/CHANNELS ***********************/ |
18 | 31 | |
19 | 32 | /*------------------------------------------------------------------*/ |
@@ -143,13 +156,13 @@ print_ap_info(int skfd, | ||
143 | 156 | if(has_qual) |
144 | 157 | { |
145 | 158 | /* Print stats for this address */ |
146 | - printf(" %s : ", iw_pr_ether(temp, hwa[i].sa_data)); | |
159 | + printf(" %s : ", iw_saether_ntop(&hwa[i], temp)); | |
147 | 160 | iw_print_stats(temp, sizeof(buffer), &qual[i], &range, has_range); |
148 | 161 | printf("%s\n", temp); |
149 | 162 | } |
150 | 163 | else |
151 | 164 | /* Only print the address */ |
152 | - printf(" %s\n", iw_pr_ether(temp, hwa[i].sa_data)); | |
165 | + printf(" %s\n", iw_saether_ntop(&hwa[i], temp)); | |
153 | 166 | } |
154 | 167 | printf("\n"); |
155 | 168 | return(0); |
@@ -255,7 +268,7 @@ print_keys_info(int skfd, | ||
255 | 268 | wrq.u.data.flags = k; |
256 | 269 | if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0) |
257 | 270 | { |
258 | - fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno)); | |
271 | + fprintf(stderr, "Error reading wireless keys (SIOCGIWENCODE): %s\n", strerror(errno)); | |
259 | 272 | break; |
260 | 273 | } |
261 | 274 | if((wrq.u.data.flags & IW_ENCODE_DISABLED) || |
@@ -277,19 +290,60 @@ print_keys_info(int skfd, | ||
277 | 290 | wrq.u.data.pointer = (caddr_t) key; |
278 | 291 | wrq.u.data.length = IW_ENCODING_TOKEN_MAX; |
279 | 292 | wrq.u.data.flags = 0; /* Set index to zero to get current */ |
280 | - if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0) | |
293 | + if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) >= 0) | |
281 | 294 | { |
282 | - fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno)); | |
283 | - return(-1); | |
295 | + /* Note : if above fails, we have already printed an error | |
296 | + * message int the loop above */ | |
297 | + printf(" Current Transmit Key: [%d]\n", | |
298 | + wrq.u.data.flags & IW_ENCODE_INDEX); | |
299 | + if(wrq.u.data.flags & IW_ENCODE_RESTRICTED) | |
300 | + printf(" Security mode:restricted\n"); | |
301 | + if(wrq.u.data.flags & IW_ENCODE_OPEN) | |
302 | + printf(" Security mode:open\n"); | |
303 | + } | |
304 | + | |
305 | + /* Print WPA/802.1x/802.11i security parameters */ | |
306 | + if(range.we_version_compiled > 17) | |
307 | + { | |
308 | + /* Display advance encryption capabilities */ | |
309 | + if(range.enc_capa) | |
310 | + { | |
311 | + const char * auth_string[] = { "WPA", | |
312 | + "WPA2", | |
313 | + "CIPHER TKIP", | |
314 | + "CIPHER CCMP" }; | |
315 | + const int auth_num = (sizeof(auth_string) / | |
316 | + sizeof(auth_string[1])); | |
317 | + int i; | |
318 | + int mask = 0x1; | |
319 | + | |
320 | + printf(" Authentication capabilities :\n"); | |
321 | + for(i = 0; i < auth_num; i++) | |
322 | + { | |
323 | + if(range.enc_capa & mask) | |
324 | + printf("\t\t%s\n", auth_string[i]); | |
325 | + mask <<= 1; | |
326 | + } | |
327 | + } | |
328 | + | |
329 | + /* Current values for authentication */ | |
330 | + wrq.u.param.flags = IW_AUTH_KEY_MGMT; | |
331 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
332 | + printf(" Current key_mgmt:0x%X\n", | |
333 | + wrq.u.param.value); | |
334 | + | |
335 | + wrq.u.param.flags = IW_AUTH_CIPHER_PAIRWISE; | |
336 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
337 | + printf(" Current cipher_pairwise:0x%X\n", | |
338 | + wrq.u.param.value); | |
339 | + | |
340 | + wrq.u.param.flags = IW_AUTH_CIPHER_GROUP; | |
341 | + if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0) | |
342 | + printf(" Current cipher_group:0x%X\n", | |
343 | + wrq.u.param.value); | |
284 | 344 | } |
285 | - printf(" Current Transmit Key: [%d]\n", | |
286 | - wrq.u.data.flags & IW_ENCODE_INDEX); | |
287 | - if(wrq.u.data.flags & IW_ENCODE_RESTRICTED) | |
288 | - printf(" Security mode:restricted\n"); | |
289 | - if(wrq.u.data.flags & IW_ENCODE_OPEN) | |
290 | - printf(" Security mode:open\n"); | |
291 | - | |
292 | - printf("\n\n"); | |
345 | + | |
346 | + printf("\n\n"); | |
293 | 347 | } |
294 | 348 | return(0); |
295 | 349 | } |
@@ -305,7 +359,8 @@ get_pm_value(int skfd, | ||
305 | 359 | char * ifname, |
306 | 360 | struct iwreq * pwrq, |
307 | 361 | int flags, |
308 | - char * buffer) | |
362 | + char * buffer, | |
363 | + int buflen) | |
309 | 364 | { |
310 | 365 | /* Get Another Power Management value */ |
311 | 366 | pwrq->u.power.flags = flags; |
@@ -314,7 +369,7 @@ get_pm_value(int skfd, | ||
314 | 369 | /* Let's check the value and its type */ |
315 | 370 | if(pwrq->u.power.flags & IW_POWER_TYPE) |
316 | 371 | { |
317 | - iw_print_pm_value(buffer, sizeof(buffer), | |
372 | + iw_print_pm_value(buffer, buflen, | |
318 | 373 | pwrq->u.power.value, pwrq->u.power.flags); |
319 | 374 | printf("\n %s", buffer); |
320 | 375 | } |
@@ -436,7 +491,8 @@ print_pm_info(int skfd, | ||
436 | 491 | pm_mask = IW_POWER_MIN; |
437 | 492 | /* If we have something to ask for... */ |
438 | 493 | if(pm_mask) |
439 | - get_pm_value(skfd, ifname, &wrq, pm_mask, buffer); | |
494 | + get_pm_value(skfd, ifname, &wrq, pm_mask, | |
495 | + buffer, sizeof(buffer)); | |
440 | 496 | |
441 | 497 | /* And if we have both a period and a timeout, ask the other */ |
442 | 498 | pm_mask = (range.pm_capa & (~(wrq.u.power.flags) & |
@@ -444,7 +500,8 @@ print_pm_info(int skfd, | ||
444 | 500 | if(pm_mask) |
445 | 501 | { |
446 | 502 | int base_mask = pm_mask; |
447 | - flags = get_pm_value(skfd, ifname, &wrq, pm_mask, buffer); | |
503 | + flags = get_pm_value(skfd, ifname, &wrq, pm_mask, | |
504 | + buffer, sizeof(buffer)); | |
448 | 505 | pm_mask = 0; |
449 | 506 | |
450 | 507 | /* If we have been returned a MIN value, ask for the MAX */ |
@@ -455,7 +512,8 @@ print_pm_info(int skfd, | ||
455 | 512 | pm_mask = IW_POWER_MIN | base_mask; |
456 | 513 | /* If we have something to ask for... */ |
457 | 514 | if(pm_mask) |
458 | - get_pm_value(skfd, ifname, &wrq, pm_mask, buffer); | |
515 | + get_pm_value(skfd, ifname, &wrq, pm_mask, | |
516 | + buffer, sizeof(buffer)); | |
459 | 517 | } |
460 | 518 | } |
461 | 519 | } |
@@ -734,11 +792,279 @@ print_retry_info(int skfd, | ||
734 | 792 | |
735 | 793 | /*------------------------------------------------------------------*/ |
736 | 794 | /* |
795 | + * Parse, and display the results of a WPA or WPA2 IE. | |
796 | + * | |
797 | + */ | |
798 | +static void | |
799 | +iw_print_ie_unknown(unsigned char * iebuf, | |
800 | + int buflen) | |
801 | +{ | |
802 | + int ielen = iebuf[1] + 2; | |
803 | + int i; | |
804 | + | |
805 | + if(ielen > buflen) | |
806 | + ielen = buflen; | |
807 | + | |
808 | + printf("Unknown: "); | |
809 | + for(i = 0; i < ielen; i++) | |
810 | + printf("%02X", iebuf[i]); | |
811 | + printf("\n"); | |
812 | +} | |
813 | + | |
814 | +/*-----------------------------------------------------------------*/ | |
815 | +/* | |
816 | + * Display the cipher type for the value passed in. | |
817 | + * | |
818 | + */ | |
819 | +static inline void | |
820 | +iw_print_ie_cipher(unsigned char csuite) | |
821 | +{ | |
822 | + switch (csuite) | |
823 | + { | |
824 | + case 0x00: | |
825 | + printf("None or same as Group "); | |
826 | + break; | |
827 | + | |
828 | + case 0x01: | |
829 | + printf("WEP-40 "); | |
830 | + break; | |
831 | + | |
832 | + case 0x02: | |
833 | + printf("TKIP "); | |
834 | + break; | |
835 | + | |
836 | + case 0x03: | |
837 | + printf("WRAP "); | |
838 | + break; | |
839 | + | |
840 | + case 0x04: | |
841 | + printf("CCMP "); | |
842 | + break; | |
843 | + | |
844 | + case 0x05: | |
845 | + printf("WEP-104 "); | |
846 | + break; | |
847 | + | |
848 | + default: | |
849 | + printf("Unknown "); | |
850 | + break; | |
851 | + } | |
852 | + } | |
853 | + | |
854 | +/*------------------------------------------------------------------*/ | |
855 | +/* | |
856 | + * Parse, and display the results of a WPA or WPA2 IE. | |
857 | + * | |
858 | + */ | |
859 | +static inline void | |
860 | +iw_print_ie_wpa(unsigned char * iebuf, | |
861 | + int buflen) | |
862 | +{ | |
863 | + int ielen = iebuf[1] + 2; | |
864 | + int offset = 2; /* Skip the IE id, and the length. */ | |
865 | + unsigned char wpa1_oui[3] = {0x00, 0x50, 0xf2}; | |
866 | + unsigned char wpa2_oui[3] = {0x00, 0x0f, 0xac}; | |
867 | + unsigned char * wpa_oui; | |
868 | + int i; | |
869 | + uint16_t ver = 0; | |
870 | + uint16_t cnt = 0; | |
871 | + | |
872 | + if(ielen > buflen) | |
873 | + ielen = buflen; | |
874 | + | |
875 | + switch(iebuf[0]) | |
876 | + { | |
877 | + case 0x30: /* WPA2 */ | |
878 | + /* Check if we have enough data */ | |
879 | + if(ielen < 4) | |
880 | + { | |
881 | + iw_print_ie_unknown(iebuf, buflen); | |
882 | + return; | |
883 | + } | |
884 | + | |
885 | + wpa_oui = wpa2_oui; | |
886 | + break; | |
887 | + | |
888 | + case 0xdd: /* WPA or else */ | |
889 | + wpa_oui = wpa1_oui; | |
890 | + | |
891 | + /* Not all IEs that start with 0xdd are WPA. | |
892 | + * So check that the OUI is valid. */ | |
893 | + if((ielen < 8) | |
894 | + || ((memcmp(&iebuf[offset], wpa_oui, 3) != 0) | |
895 | + && (iebuf[offset+3] == 0x01))) | |
896 | + { | |
897 | + iw_print_ie_unknown(iebuf, buflen); | |
898 | + return; | |
899 | + } | |
900 | + | |
901 | + offset += 4; | |
902 | + break; | |
903 | + | |
904 | + default: | |
905 | + return; | |
906 | + } | |
907 | + | |
908 | + /* Pick version number (little endian) */ | |
909 | + ver = iebuf[offset] | (iebuf[offset + 1] << 8); | |
910 | + offset += 2; | |
911 | + | |
912 | + if(iebuf[0] == 0xdd) | |
913 | + printf("WPA Version %d\n", ver); | |
914 | + if(iebuf[0] == 0x30) | |
915 | + printf("IEEE 802.11i/WPA2 Version %d\n", ver); | |
916 | + | |
917 | + /* From here, everything is technically optional. */ | |
918 | + | |
919 | + /* Check if we are done */ | |
920 | + if(ielen < (offset + 4)) | |
921 | + { | |
922 | + /* We have a short IE. So we should assume TKIP/TKIP. */ | |
923 | + printf(" Group Cipher : TKIP\n"); | |
924 | + printf(" Pairwise Cipher : TKIP\n"); | |
925 | + return; | |
926 | + } | |
927 | + | |
928 | + /* Next we have our group cipher. */ | |
929 | + if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) | |
930 | + { | |
931 | + printf(" Group Cipher : Proprietary\n"); | |
932 | + } | |
933 | + else | |
934 | + { | |
935 | + printf(" Group Cipher : "); | |
936 | + iw_print_ie_cipher(iebuf[offset+3]); | |
937 | + printf("\n"); | |
938 | + } | |
939 | + offset += 4; | |
940 | + | |
941 | + /* Check if we are done */ | |
942 | + if(ielen < (offset + 2)) | |
943 | + { | |
944 | + /* We don't have a pairwise cipher, or auth method. Assume TKIP. */ | |
945 | + printf(" Pairwise Ciphers (1) : TKIP\n"); | |
946 | + return; | |
947 | + } | |
948 | + | |
949 | + /* Otherwise, we have some number of pairwise ciphers. */ | |
950 | + cnt = iebuf[offset] | (iebuf[offset + 1] << 8); | |
951 | + offset += 2; | |
952 | + printf(" Pairwise Ciphers (%d) : ", cnt); | |
953 | + | |
954 | + if(ielen < (offset + 4*cnt)) | |
955 | + return; | |
956 | + | |
957 | + for(i = 0; i < cnt; i++) | |
958 | + { | |
959 | + if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) | |
960 | + { | |
961 | + printf("Proprietary "); | |
962 | + } | |
963 | + else | |
964 | + { | |
965 | + iw_print_ie_cipher(iebuf[offset+3]); | |
966 | + } | |
967 | + offset+=4; | |
968 | + } | |
969 | + printf("\n"); | |
970 | + | |
971 | + /* Check if we are done */ | |
972 | + if(ielen < (offset + 2)) | |
973 | + return; | |
974 | + | |
975 | + /* Now, we have authentication suites. */ | |
976 | + cnt = iebuf[offset] | (iebuf[offset + 1] << 8); | |
977 | + offset += 2; | |
978 | + printf(" Authentication Suites (%d) : ", cnt); | |
979 | + | |
980 | + if(ielen < (offset + 4*cnt)) | |
981 | + return; | |
982 | + | |
983 | + for(i = 0; i < cnt; i++) | |
984 | + { | |
985 | + if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) | |
986 | + { | |
987 | + printf("Proprietary "); | |
988 | + } | |
989 | + else | |
990 | + { | |
991 | + switch(iebuf[offset+3]) | |
992 | + { | |
993 | + case 0x00: | |
994 | + printf("Reserved "); | |
995 | + break; | |
996 | + | |
997 | + case 0x01: | |
998 | + printf("802.1X "); | |
999 | + break; | |
1000 | + | |
1001 | + case 0x02: | |
1002 | + printf("PSK "); | |
1003 | + break; | |
1004 | + | |
1005 | + default: | |
1006 | + printf("Unknown "); | |
1007 | + break; | |
1008 | + } | |
1009 | + } | |
1010 | + offset+=4; | |
1011 | + } | |
1012 | + printf("\n"); | |
1013 | + | |
1014 | + /* Check if we are done */ | |
1015 | + if(ielen < (offset + 1)) | |
1016 | + return; | |
1017 | + | |
1018 | + /* Otherwise, we have capabilities bytes. | |
1019 | + * For now, we only care about preauth which is in bit position 1 of the | |
1020 | + * first byte. (But, preauth with WPA version 1 isn't supposed to be | |
1021 | + * allowed.) 8-) */ | |
1022 | + if(iebuf[offset] & 0x01) | |
1023 | + { | |
1024 | + printf(" Preauthentication Supported\n"); | |
1025 | + } | |
1026 | +} | |
1027 | + | |
1028 | +/*------------------------------------------------------------------*/ | |
1029 | +/* | |
1030 | + * Process a generic IE and display the info in human readable form | |
1031 | + * for some of the most interesting ones. | |
1032 | + * For now, we only decode the WPA IEs. | |
1033 | + */ | |
1034 | +static inline void | |
1035 | +iw_print_gen_ie(unsigned char * buffer, | |
1036 | + int buflen) | |
1037 | +{ | |
1038 | + int offset = 0; | |
1039 | + | |
1040 | + /* Loop on each IE, each IE is minimum 2 bytes */ | |
1041 | + while(offset <= (buflen - 2)) | |
1042 | + { | |
1043 | + printf(" IE: "); | |
1044 | + | |
1045 | + /* Check IE type */ | |
1046 | + switch(buffer[offset]) | |
1047 | + { | |
1048 | + case 0xdd: /* WPA1 (and other) */ | |
1049 | + case 0x30: /* WPA2 */ | |
1050 | + iw_print_ie_wpa(buffer + offset, buflen); | |
1051 | + break; | |
1052 | + default: | |
1053 | + iw_print_ie_unknown(buffer + offset, buflen); | |
1054 | + } | |
1055 | + /* Skip over this IE to the next one in the list. */ | |
1056 | + offset += buffer[offset+1] + 2; | |
1057 | + } | |
1058 | +} | |
1059 | + | |
1060 | +/*------------------------------------------------------------------*/ | |
1061 | +/* | |
737 | 1062 | * Print one element from the scanning results |
738 | 1063 | */ |
739 | -static inline int | |
740 | -print_scanning_token(struct iw_event * event, /* Extracted token */ | |
741 | - int ap_num, /* AP number */ | |
1064 | +static inline void | |
1065 | +print_scanning_token(struct stream_descr * stream, /* Stream of events */ | |
1066 | + struct iw_event * event, /* Extracted token */ | |
1067 | + struct iwscan_state * state, | |
742 | 1068 | struct iw_range * iw_range, /* Range info */ |
743 | 1069 | int has_range) |
744 | 1070 | { |
@@ -748,9 +1074,9 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
748 | 1074 | switch(event->cmd) |
749 | 1075 | { |
750 | 1076 | case SIOCGIWAP: |
751 | - printf(" Cell %02d - Address: %s\n", ap_num, | |
752 | - iw_pr_ether(buffer, event->u.ap_addr.sa_data)); | |
753 | - ap_num++; | |
1077 | + printf(" Cell %02d - Address: %s\n", state->ap_num, | |
1078 | + iw_saether_ntop(&event->u.ap_addr, buffer)); | |
1079 | + state->ap_num++; | |
754 | 1080 | break; |
755 | 1081 | case SIOCGIWNWID: |
756 | 1082 | if(event->u.nwid.disabled) |
@@ -781,9 +1107,9 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
781 | 1107 | case SIOCGIWESSID: |
782 | 1108 | { |
783 | 1109 | char essid[IW_ESSID_MAX_SIZE+1]; |
1110 | + memset(essid, '\0', sizeof(essid)); | |
784 | 1111 | if((event->u.essid.pointer) && (event->u.essid.length)) |
785 | 1112 | memcpy(essid, event->u.essid.pointer, event->u.essid.length); |
786 | - essid[event->u.essid.length] = '\0'; | |
787 | 1113 | if(event->u.essid.flags) |
788 | 1114 | { |
789 | 1115 | /* Does it have an ESSID index ? */ |
@@ -794,14 +1120,14 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
794 | 1120 | printf(" ESSID:\"%s\"\n", essid); |
795 | 1121 | } |
796 | 1122 | else |
797 | - printf(" ESSID:off/any\n"); | |
1123 | + printf(" ESSID:off/any/hidden\n"); | |
798 | 1124 | } |
799 | 1125 | break; |
800 | 1126 | case SIOCGIWENCODE: |
801 | 1127 | { |
802 | 1128 | unsigned char key[IW_ENCODING_TOKEN_MAX]; |
803 | 1129 | if(event->u.data.pointer) |
804 | - memcpy(key, event->u.essid.pointer, event->u.data.length); | |
1130 | + memcpy(key, event->u.data.pointer, event->u.data.length); | |
805 | 1131 | else |
806 | 1132 | event->u.data.flags |= IW_ENCODE_NOKEY; |
807 | 1133 | printf(" Encryption key:"); |
@@ -826,8 +1152,23 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
826 | 1152 | } |
827 | 1153 | break; |
828 | 1154 | case SIOCGIWRATE: |
1155 | + if(state->val_index == 0) | |
1156 | + printf(" Bit Rates:"); | |
1157 | + else | |
1158 | + if((state->val_index % 5) == 0) | |
1159 | + printf("\n "); | |
1160 | + else | |
1161 | + printf("; "); | |
829 | 1162 | iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value); |
830 | - printf(" Bit Rate:%s\n", buffer); | |
1163 | + printf("%s", buffer); | |
1164 | + /* Check for termination */ | |
1165 | + if(stream->value == NULL) | |
1166 | + { | |
1167 | + printf("\n"); | |
1168 | + state->val_index = 0; | |
1169 | + } | |
1170 | + else | |
1171 | + state->val_index++; | |
831 | 1172 | break; |
832 | 1173 | case IWEVQUAL: |
833 | 1174 | { |
@@ -836,6 +1177,10 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
836 | 1177 | printf(" %s\n", buffer); |
837 | 1178 | break; |
838 | 1179 | } |
1180 | + case IWEVGENIE: | |
1181 | + /* Informations Elements are complex, let's do only some of them */ | |
1182 | + iw_print_gen_ie(event->u.data.pointer, event->u.data.length); | |
1183 | + break; | |
839 | 1184 | case IWEVCUSTOM: |
840 | 1185 | { |
841 | 1186 | char custom[IW_CUSTOM_MAX+1]; |
@@ -849,9 +1194,6 @@ print_scanning_token(struct iw_event * event, /* Extracted token */ | ||
849 | 1194 | printf(" (Unknown Wireless Token 0x%04X)\n", |
850 | 1195 | event->cmd); |
851 | 1196 | } /* switch(event->cmd) */ |
852 | - | |
853 | - /* May have changed */ | |
854 | - return(ap_num); | |
855 | 1197 | } |
856 | 1198 | |
857 | 1199 | /*------------------------------------------------------------------*/ |
@@ -870,7 +1212,7 @@ print_scanning_info(int skfd, | ||
870 | 1212 | struct iw_range range; |
871 | 1213 | int has_range; |
872 | 1214 | struct timeval tv; /* Select timeout */ |
873 | - int timeout = 5000000; /* 5s */ | |
1215 | + int timeout = 15000000; /* 15s */ | |
874 | 1216 | |
875 | 1217 | /* Avoid "Unused parameter" warning */ |
876 | 1218 | args = args; count = count; |
@@ -1017,8 +1359,9 @@ print_scanning_info(int skfd, | ||
1017 | 1359 | { |
1018 | 1360 | struct iw_event iwe; |
1019 | 1361 | struct stream_descr stream; |
1020 | - int ap_num = 1; | |
1362 | + struct iwscan_state state = { .ap_num = 1, .val_index = 0 }; | |
1021 | 1363 | int ret; |
1364 | + | |
1022 | 1365 | #if 0 |
1023 | 1366 | /* Debugging code. In theory useless, because it's debugged ;-) */ |
1024 | 1367 | int i; |
@@ -1028,14 +1371,15 @@ print_scanning_info(int skfd, | ||
1028 | 1371 | printf("]\n"); |
1029 | 1372 | #endif |
1030 | 1373 | printf("%-8.16s Scan completed :\n", ifname); |
1031 | - iw_init_event_stream(&stream, buffer, wrq.u.data.length); | |
1374 | + iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length); | |
1032 | 1375 | do |
1033 | 1376 | { |
1034 | 1377 | /* Extract an event and print it */ |
1035 | 1378 | ret = iw_extract_event_stream(&stream, &iwe, |
1036 | 1379 | range.we_version_compiled); |
1037 | 1380 | if(ret > 0) |
1038 | - ap_num = print_scanning_token(&iwe, ap_num, &range, has_range); | |
1381 | + print_scanning_token(&stream, &iwe, &state, | |
1382 | + &range, has_range); | |
1039 | 1383 | } |
1040 | 1384 | while(ret > 0); |
1041 | 1385 | printf("\n"); |
@@ -1131,11 +1475,14 @@ print_event_capa_info(int skfd, | ||
1131 | 1475 | |
1132 | 1476 | /************************* COMMON UTILITIES *************************/ |
1133 | 1477 | /* |
1134 | - * This section was written by Michael Tokarev <mjt@tls.msk.ru> | |
1135 | - * But modified by me ;-) | |
1478 | + * This section was initially written by Michael Tokarev <mjt@tls.msk.ru> | |
1479 | + * but heavily modified by me ;-) | |
1136 | 1480 | */ |
1137 | 1481 | |
1138 | -/* command list */ | |
1482 | +/*------------------------------------------------------------------*/ | |
1483 | +/* | |
1484 | + * Map command line arguments to the proper procedure... | |
1485 | + */ | |
1139 | 1486 | typedef struct iwlist_entry { |
1140 | 1487 | const char *cmd; |
1141 | 1488 | iw_enum_handler fn; |
@@ -1244,14 +1591,13 @@ main(int argc, | ||
1244 | 1591 | if(argc == 1 || argc > 3) |
1245 | 1592 | iw_usage(1); |
1246 | 1593 | |
1247 | - if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) | |
1594 | + /* Those don't apply to all interfaces */ | |
1595 | + if((argc == 2) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) | |
1248 | 1596 | iw_usage(0); |
1249 | - | |
1250 | - /* This is also handled slightly differently */ | |
1251 | - if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) | |
1597 | + if((argc == 2) && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) | |
1252 | 1598 | return(iw_print_version_info("iwlist")); |
1253 | 1599 | |
1254 | - if (argc == 2) | |
1600 | + if(argc == 2) | |
1255 | 1601 | { |
1256 | 1602 | cmd = argv[1]; |
1257 | 1603 | dev = NULL; |
@@ -0,0 +1,135 @@ | ||
1 | +/* | |
2 | + * Wireless Tools | |
3 | + * | |
4 | + * Jean II - HPL 04 | |
5 | + * | |
6 | + * Main code for "iwmulticall". This is a wrapper for the multicall version | |
7 | + * of the wireless tools. | |
8 | + * You need to link this code against "-lm". | |
9 | + * Thanks to Ned Ludd <solar@gentoo.org> for the inspiration... | |
10 | + * | |
11 | + * This file is released under the GPL license. | |
12 | + * Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com> | |
13 | + */ | |
14 | + | |
15 | +/***************************** INCLUDES *****************************/ | |
16 | + | |
17 | +#include <libgen.h> /* Basename */ | |
18 | + | |
19 | +/**************************** PROTOTYPES ****************************/ | |
20 | + | |
21 | +/* Prototypes of the main of each tool */ | |
22 | +extern int | |
23 | + main_iwconfig(int argc, | |
24 | + char ** argv); | |
25 | +extern int | |
26 | + main_iwlist(int argc, | |
27 | + char ** argv); | |
28 | +extern int | |
29 | + main_iwspy(int argc, | |
30 | + char ** argv); | |
31 | +extern int | |
32 | + main_iwpriv(int argc, | |
33 | + char ** argv); | |
34 | +extern int | |
35 | + main_iwgetid(int argc, | |
36 | + char ** argv); | |
37 | + | |
38 | +/************************** MULTICALL HACK **************************/ | |
39 | +/* | |
40 | + * The idea for multicall is to put all the tools and the library in | |
41 | + * the same binary. This way, you can save the overhead of the library, | |
42 | + * of each tool, can better optimise the code and throw away the stuff | |
43 | + * you don't need from the library. | |
44 | + * This almost divide the size of the tools by two (without stripping). | |
45 | + * On the down side, you no longer have the libiw for other tools to | |
46 | + * use, but for the target systems (embedded), this doesn't matter | |
47 | + * much, as they just need to configure the card... | |
48 | + * Note that splitting the lib and the multicall tools would not | |
49 | + * make sense, as most gains are found in the inclusion of the lib... | |
50 | + * | |
51 | + * Our strategy is to include directly the *.c, rather than compile | |
52 | + * them separatly. This allow to simplify compilation and hide the | |
53 | + * multicall tweaks from the other tools. | |
54 | + * Yeah, this leads to a bit a preprocessor abuse... | |
55 | + * Jean II | |
56 | + */ | |
57 | + | |
58 | +/* We need the library */ | |
59 | +#include "iwlib.c" | |
60 | + | |
61 | +/* Get iwconfig in there. Mandatory. */ | |
62 | +#define main(args...) main_iwconfig(args) | |
63 | +#define iw_usage(args...) iwconfig_usage(args) | |
64 | +#include "iwconfig.c" | |
65 | +#undef iw_usage | |
66 | +#undef main | |
67 | + | |
68 | +/* Get iwlist in there. Scanning support is pretty sweet. */ | |
69 | +#define main(args...) main_iwlist(args) | |
70 | +#define iw_usage(args...) iwlist_usage(args) | |
71 | +#include "iwlist.c" | |
72 | +#undef iw_usage | |
73 | +#undef main | |
74 | + | |
75 | +/* Get iwspy in there, it's not that big. */ | |
76 | +#define main(args...) main_iwspy(args) | |
77 | +#include "iwspy.c" | |
78 | +#undef main | |
79 | + | |
80 | +/* Get iwpriv in there. Mandatory for HostAP and some other drivers. */ | |
81 | +#define main(args...) main_iwpriv(args) | |
82 | +#define iw_usage(args...) iwpriv_usage(args) | |
83 | +#include "iwpriv.c" | |
84 | +#undef iw_usage | |
85 | +#undef main | |
86 | + | |
87 | +/* Do we really need iwgetid ? Well, it's not like it's a big one */ | |
88 | +#define main(args...) main_iwgetid(args) | |
89 | +#define iw_usage(args...) iwgetid_usage(args) | |
90 | +#include "iwgetid.c" | |
91 | +#undef iw_usage | |
92 | +#undef main | |
93 | + | |
94 | +/* iwevent is useless for most people, don't grab it ? */ | |
95 | + | |
96 | +/* ifrename is big and useless for those systems */ | |
97 | + | |
98 | + | |
99 | +/******************************* MAIN ********************************/ | |
100 | + | |
101 | +/*------------------------------------------------------------------*/ | |
102 | +/* | |
103 | + * The main ! | |
104 | + */ | |
105 | +int | |
106 | +main(int argc, | |
107 | + char ** argv) | |
108 | +{ | |
109 | + char * call_name = basename(argv[0]); /* Strip path */ | |
110 | + | |
111 | + /* This is a testing hack */ | |
112 | + if(!strcmp(call_name, "iwmulticall") && (argc > 0)) | |
113 | + { | |
114 | + argv++; | |
115 | + argc--; | |
116 | + call_name = basename(argv[0]); | |
117 | + } | |
118 | + | |
119 | + /* Just check the name under which we were called... */ | |
120 | + | |
121 | + if(!strcmp(call_name, "iwconfig")) | |
122 | + return(main_iwconfig(argc, argv)); | |
123 | + if(!strcmp(call_name, "iwlist")) | |
124 | + return(main_iwlist(argc, argv)); | |
125 | + if(!strcmp(call_name, "iwspy")) | |
126 | + return(main_iwspy(argc, argv)); | |
127 | + if(!strcmp(call_name, "iwpriv")) | |
128 | + return(main_iwpriv(argc, argv)); | |
129 | + if(!strcmp(call_name, "iwgetid")) | |
130 | + return(main_iwgetid(argc, argv)); | |
131 | + | |
132 | + /* Uh oh... Not supposed to come here. */ | |
133 | + printf("iwmulticall : you are not supposed to call me this way...\n"); | |
134 | + return(0); | |
135 | +} |
@@ -241,8 +241,6 @@ static void | ||
241 | 241 | iw_usage(void) |
242 | 242 | { |
243 | 243 | fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n"); |
244 | - fprintf(stderr, " interface [roam {on|off}]\n"); | |
245 | - fprintf(stderr, " interface [port {ad-hoc|managed|N}]\n"); | |
246 | 244 | } |
247 | 245 | |
248 | 246 | /************************* SETTING ROUTINES **************************/ |
@@ -269,7 +267,7 @@ set_private_cmd(int skfd, /* Socket */ | ||
269 | 267 | int offset = 0; /* Space for sub-ioctl index */ |
270 | 268 | |
271 | 269 | /* Check if we have a token index. |
272 | - * Do it now so that sub-ioctl takes precendence, and so that we | |
270 | + * Do it now so that sub-ioctl takes precedence, and so that we | |
273 | 271 | * don't have to bother with it later on... */ |
274 | 272 | if((count >= 1) && (sscanf(args[0], "[%i]", &temp) == 1)) |
275 | 273 | { |
@@ -412,14 +410,14 @@ set_private_cmd(int skfd, /* Socket */ | ||
412 | 410 | break; |
413 | 411 | |
414 | 412 | default: |
415 | - fprintf(stderr, "Not yet implemented...\n"); | |
413 | + fprintf(stderr, "Not implemented...\n"); | |
416 | 414 | return(-1); |
417 | 415 | } |
418 | 416 | |
419 | 417 | if((priv[k].set_args & IW_PRIV_SIZE_FIXED) && |
420 | 418 | (wrq.u.data.length != (priv[k].set_args & IW_PRIV_SIZE_MASK))) |
421 | 419 | { |
422 | - printf("The command %s need exactly %d argument...\n", | |
420 | + printf("The command %s needs exactly %d argument(s)...\n", | |
423 | 421 | cmdname, priv[k].set_args & IW_PRIV_SIZE_MASK); |
424 | 422 | return(-1); |
425 | 423 | } |
@@ -453,7 +451,7 @@ set_private_cmd(int skfd, /* Socket */ | ||
453 | 451 | } |
454 | 452 | else |
455 | 453 | { |
456 | - /* Thirst case : args won't fit in wrq, or variable number of args */ | |
454 | + /* Third case : args won't fit in wrq, or variable number of args */ | |
457 | 455 | wrq.u.data.pointer = (caddr_t) buffer; |
458 | 456 | wrq.u.data.flags = subcmd; |
459 | 457 | } |
@@ -538,7 +536,7 @@ set_private_cmd(int skfd, /* Socket */ | ||
538 | 536 | if(j) |
539 | 537 | printf(" %.*s", |
540 | 538 | (int) strlen(cmdname), " "); |
541 | - printf("%s\n", iw_pr_ether(scratch, hwa->sa_data)); | |
539 | + printf("%s\n", iw_saether_ntop(hwa, scratch)); | |
542 | 540 | } |
543 | 541 | } |
544 | 542 | break; |
@@ -620,7 +618,7 @@ print_priv_info(int skfd, | ||
620 | 618 | } |
621 | 619 | else |
622 | 620 | { |
623 | - printf("%-8.16s Available private ioctl :\n", ifname); | |
621 | + printf("%-8.16s Available private ioctls :\n", ifname); | |
624 | 622 | /* Print them all */ |
625 | 623 | for(k = 0; k < n; k++) |
626 | 624 | if(priv[k].name[0] != '\0') |
@@ -25,17 +25,22 @@ iwspy \- Get wireless statistics from specific nodes | ||
25 | 25 | .\" |
26 | 26 | .SH DESCRIPTION |
27 | 27 | .B Iwspy |
28 | -is used to set a list of addresses in a wireless network interface and | |
29 | -to read back quality of link information for each of those. This | |
30 | -information is the same as the one available in | |
28 | +is used to set a list of addresses to monitor in a wireless network | |
29 | +interface and to read back quality of link information for each of | |
30 | +those. This information is the same as the one available in | |
31 | 31 | .I /proc/net/wireless |
32 | 32 | : quality of the link, signal strength and noise level. |
33 | 33 | .PP |
34 | 34 | This information is updated each time a new packet is received, so |
35 | -each address of the list add some overhead in the driver. | |
35 | +each address of the list adds some overhead in the driver. | |
36 | 36 | .PP |
37 | -Note the this functionality work only for node part of the current | |
38 | -wireless cells. | |
37 | +Note that this functionality works only for nodes part of the current | |
38 | +wireless cell, you can not monitor Access Points you are not | |
39 | +associated with (you can use Scanning for that) and nodes in other | |
40 | +cells. In Managed mode, in most case packets are relayed by the Access | |
41 | +Point, in this case you will get the signal strength of the Access | |
42 | +Point. For those reasons this functionality is mostly useful in Ad-Hoc | |
43 | +and Master mode. | |
39 | 44 | .\" |
40 | 45 | .\" PARAMETER part |
41 | 46 | .\" |
@@ -44,7 +49,7 @@ You may set any number of addresses up to 8. | ||
44 | 49 | .TP |
45 | 50 | .BR DNSNAME " | " IPADDR |
46 | 51 | Set an IP address, or in some cases a DNS name (using the name |
47 | -resolver). As the hardware work with hardware addresses, | |
52 | +resolver). As the hardware works with hardware addresses, | |
48 | 53 | .B iwspy |
49 | 54 | will translate this IP address through |
50 | 55 | .IR ARP . |
@@ -73,10 +78,10 @@ Set the | ||
73 | 78 | .I low |
74 | 79 | and |
75 | 80 | .I high |
76 | -signal strength threshold for the iwspy event (for driver that support | |
77 | -it). | |
81 | +signal strength threshold for the iwspy event (for drivers that | |
82 | +support it). | |
78 | 83 | .br |
79 | -Every time the signal strengh for any of the address monitored | |
84 | +Every time the signal strength for any of the address monitored | |
80 | 85 | with iwspy goes lower than the low threshold or goes higher than the |
81 | 86 | high threshold, a Wireless Event will be generated. |
82 | 87 | .br |
@@ -75,7 +75,7 @@ print_spy_info(int skfd, | ||
75 | 75 | for(i = 0; i < n; i++) |
76 | 76 | { |
77 | 77 | /* Print stats for each address */ |
78 | - printf(" %s : ", iw_pr_ether(temp, hwa[i].sa_data)); | |
78 | + printf(" %s : ", iw_saether_ntop(&hwa[i], temp)); | |
79 | 79 | iw_print_stats(temp, sizeof(temp), &qual[i], &range, has_range); |
80 | 80 | printf("%s\n", temp); |
81 | 81 | } |
@@ -26,6 +26,7 @@ int main(int argc, char** argv) | ||
26 | 26 | |
27 | 27 | int devsock; |
28 | 28 | struct ifreq ifbuffer; |
29 | + char buf[20]; | |
29 | 30 | |
30 | 31 | if ((argc != 2) || (argv[1][0] == '-')) { |
31 | 32 | printf("Usage: macaddr interface\n"); |
@@ -47,7 +48,7 @@ int main(int argc, char** argv) | ||
47 | 48 | } |
48 | 49 | close(devsock); |
49 | 50 | |
50 | - puts(iw_ether_ntoa((struct ether_addr *) ifbuffer.ifr_ifru.ifru_hwaddr.sa_data)); | |
51 | + puts(iw_saether_ntop(&ifbuffer.ifr_ifru.ifru_hwaddr, buf)); | |
51 | 52 | |
52 | 53 | exit(0); |
53 | 54 | } |
@@ -0,0 +1,1050 @@ | ||
1 | +/* | |
2 | + * This file define a set of standard wireless extensions | |
3 | + * | |
4 | + * Version : 18 12.3.05 | |
5 | + * | |
6 | + * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> | |
7 | + * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved. | |
8 | + */ | |
9 | + | |
10 | +#ifndef _LINUX_WIRELESS_H | |
11 | +#define _LINUX_WIRELESS_H | |
12 | + | |
13 | +/************************** DOCUMENTATION **************************/ | |
14 | +/* | |
15 | + * Initial APIs (1996 -> onward) : | |
16 | + * ----------------------------- | |
17 | + * Basically, the wireless extensions are for now a set of standard ioctl | |
18 | + * call + /proc/net/wireless | |
19 | + * | |
20 | + * The entry /proc/net/wireless give statistics and information on the | |
21 | + * driver. | |
22 | + * This is better than having each driver having its entry because | |
23 | + * its centralised and we may remove the driver module safely. | |
24 | + * | |
25 | + * Ioctl are used to configure the driver and issue commands. This is | |
26 | + * better than command line options of insmod because we may want to | |
27 | + * change dynamically (while the driver is running) some parameters. | |
28 | + * | |
29 | + * The ioctl mechanimsm are copied from standard devices ioctl. | |
30 | + * We have the list of command plus a structure descibing the | |
31 | + * data exchanged... | |
32 | + * Note that to add these ioctl, I was obliged to modify : | |
33 | + * # net/core/dev.c (two place + add include) | |
34 | + * # net/ipv4/af_inet.c (one place + add include) | |
35 | + * | |
36 | + * /proc/net/wireless is a copy of /proc/net/dev. | |
37 | + * We have a structure for data passed from the driver to /proc/net/wireless | |
38 | + * Too add this, I've modified : | |
39 | + * # net/core/dev.c (two other places) | |
40 | + * # include/linux/netdevice.h (one place) | |
41 | + * # include/linux/proc_fs.h (one place) | |
42 | + * | |
43 | + * New driver API (2002 -> onward) : | |
44 | + * ------------------------------- | |
45 | + * This file is only concerned with the user space API and common definitions. | |
46 | + * The new driver API is defined and documented in : | |
47 | + * # include/net/iw_handler.h | |
48 | + * | |
49 | + * Note as well that /proc/net/wireless implementation has now moved in : | |
50 | + * # net/core/wireless.c | |
51 | + * | |
52 | + * Wireless Events (2002 -> onward) : | |
53 | + * -------------------------------- | |
54 | + * Events are defined at the end of this file, and implemented in : | |
55 | + * # net/core/wireless.c | |
56 | + * | |
57 | + * Other comments : | |
58 | + * -------------- | |
59 | + * Do not add here things that are redundant with other mechanisms | |
60 | + * (drivers init, ifconfig, /proc/net/dev, ...) and with are not | |
61 | + * wireless specific. | |
62 | + * | |
63 | + * These wireless extensions are not magic : each driver has to provide | |
64 | + * support for them... | |
65 | + * | |
66 | + * IMPORTANT NOTE : As everything in the kernel, this is very much a | |
67 | + * work in progress. Contact me if you have ideas of improvements... | |
68 | + */ | |
69 | + | |
70 | +/***************************** INCLUDES *****************************/ | |
71 | + | |
72 | +/* To minimise problems in user space, I might remove those headers | |
73 | + * at some point. Jean II */ | |
74 | +#include <linux/types.h> /* for "caddr_t" et al */ | |
75 | +#include <linux/socket.h> /* for "struct sockaddr" et al */ | |
76 | +#include <linux/if.h> /* for IFNAMSIZ and co... */ | |
77 | + | |
78 | +/***************************** VERSION *****************************/ | |
79 | +/* | |
80 | + * This constant is used to know the availability of the wireless | |
81 | + * extensions and to know which version of wireless extensions it is | |
82 | + * (there is some stuff that will be added in the future...) | |
83 | + * I just plan to increment with each new version. | |
84 | + */ | |
85 | +#define WIRELESS_EXT 18 | |
86 | + | |
87 | +/* | |
88 | + * Changes : | |
89 | + * | |
90 | + * V2 to V3 | |
91 | + * -------- | |
92 | + * Alan Cox start some incompatibles changes. I've integrated a bit more. | |
93 | + * - Encryption renamed to Encode to avoid US regulation problems | |
94 | + * - Frequency changed from float to struct to avoid problems on old 386 | |
95 | + * | |
96 | + * V3 to V4 | |
97 | + * -------- | |
98 | + * - Add sensitivity | |
99 | + * | |
100 | + * V4 to V5 | |
101 | + * -------- | |
102 | + * - Missing encoding definitions in range | |
103 | + * - Access points stuff | |
104 | + * | |
105 | + * V5 to V6 | |
106 | + * -------- | |
107 | + * - 802.11 support (ESSID ioctls) | |
108 | + * | |
109 | + * V6 to V7 | |
110 | + * -------- | |
111 | + * - define IW_ESSID_MAX_SIZE and IW_MAX_AP | |
112 | + * | |
113 | + * V7 to V8 | |
114 | + * -------- | |
115 | + * - Changed my e-mail address | |
116 | + * - More 802.11 support (nickname, rate, rts, frag) | |
117 | + * - List index in frequencies | |
118 | + * | |
119 | + * V8 to V9 | |
120 | + * -------- | |
121 | + * - Support for 'mode of operation' (ad-hoc, managed...) | |
122 | + * - Support for unicast and multicast power saving | |
123 | + * - Change encoding to support larger tokens (>64 bits) | |
124 | + * - Updated iw_params (disable, flags) and use it for NWID | |
125 | + * - Extracted iw_point from iwreq for clarity | |
126 | + * | |
127 | + * V9 to V10 | |
128 | + * --------- | |
129 | + * - Add PM capability to range structure | |
130 | + * - Add PM modifier : MAX/MIN/RELATIVE | |
131 | + * - Add encoding option : IW_ENCODE_NOKEY | |
132 | + * - Add TxPower ioctls (work like TxRate) | |
133 | + * | |
134 | + * V10 to V11 | |
135 | + * ---------- | |
136 | + * - Add WE version in range (help backward/forward compatibility) | |
137 | + * - Add retry ioctls (work like PM) | |
138 | + * | |
139 | + * V11 to V12 | |
140 | + * ---------- | |
141 | + * - Add SIOCSIWSTATS to get /proc/net/wireless programatically | |
142 | + * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space | |
143 | + * - Add new statistics (frag, retry, beacon) | |
144 | + * - Add average quality (for user space calibration) | |
145 | + * | |
146 | + * V12 to V13 | |
147 | + * ---------- | |
148 | + * - Document creation of new driver API. | |
149 | + * - Extract union iwreq_data from struct iwreq (for new driver API). | |
150 | + * - Rename SIOCSIWNAME as SIOCSIWCOMMIT | |
151 | + * | |
152 | + * V13 to V14 | |
153 | + * ---------- | |
154 | + * - Wireless Events support : define struct iw_event | |
155 | + * - Define additional specific event numbers | |
156 | + * - Add "addr" and "param" fields in union iwreq_data | |
157 | + * - AP scanning stuff (SIOCSIWSCAN and friends) | |
158 | + * | |
159 | + * V14 to V15 | |
160 | + * ---------- | |
161 | + * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg | |
162 | + * - Make struct iw_freq signed (both m & e), add explicit padding | |
163 | + * - Add IWEVCUSTOM for driver specific event/scanning token | |
164 | + * - Add IW_MAX_GET_SPY for driver returning a lot of addresses | |
165 | + * - Add IW_TXPOW_RANGE for range of Tx Powers | |
166 | + * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points | |
167 | + * - Add IW_MODE_MONITOR for passive monitor | |
168 | + * | |
169 | + * V15 to V16 | |
170 | + * ---------- | |
171 | + * - Increase the number of bitrates in iw_range to 32 (for 802.11g) | |
172 | + * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a) | |
173 | + * - Reshuffle struct iw_range for increases, add filler | |
174 | + * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses | |
175 | + * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support | |
176 | + * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy" | |
177 | + * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index | |
178 | + * | |
179 | + * V16 to V17 | |
180 | + * ---------- | |
181 | + * - Add flags to frequency -> auto/fixed | |
182 | + * - Document (struct iw_quality *)->updated, add new flags (INVALID) | |
183 | + * - Wireless Event capability in struct iw_range | |
184 | + * - Add support for relative TxPower (yick !) | |
185 | + * | |
186 | + * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>) | |
187 | + * ---------- | |
188 | + * - Add support for WPA/WPA2 | |
189 | + * - Add extended encoding configuration (SIOCSIWENCODEEXT and | |
190 | + * SIOCGIWENCODEEXT) | |
191 | + * - Add SIOCSIWGENIE/SIOCGIWGENIE | |
192 | + * - Add SIOCSIWMLME | |
193 | + * - Add SIOCSIWPMKSA | |
194 | + * - Add struct iw_range bit field for supported encoding capabilities | |
195 | + * - Add optional scan request parameters for SIOCSIWSCAN | |
196 | + * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA | |
197 | + * related parameters (extensible up to 4096 parameter values) | |
198 | + * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE, | |
199 | + * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND | |
200 | + */ | |
201 | + | |
202 | +/**************************** CONSTANTS ****************************/ | |
203 | + | |
204 | +/* -------------------------- IOCTL LIST -------------------------- */ | |
205 | + | |
206 | +/* Wireless Identification */ | |
207 | +#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */ | |
208 | +#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */ | |
209 | +/* SIOCGIWNAME is used to verify the presence of Wireless Extensions. | |
210 | + * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"... | |
211 | + * Don't put the name of your driver there, it's useless. */ | |
212 | + | |
213 | +/* Basic operations */ | |
214 | +#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */ | |
215 | +#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */ | |
216 | +#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */ | |
217 | +#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */ | |
218 | +#define SIOCSIWMODE 0x8B06 /* set operation mode */ | |
219 | +#define SIOCGIWMODE 0x8B07 /* get operation mode */ | |
220 | +#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */ | |
221 | +#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */ | |
222 | + | |
223 | +/* Informative stuff */ | |
224 | +#define SIOCSIWRANGE 0x8B0A /* Unused */ | |
225 | +#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */ | |
226 | +#define SIOCSIWPRIV 0x8B0C /* Unused */ | |
227 | +#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */ | |
228 | +#define SIOCSIWSTATS 0x8B0E /* Unused */ | |
229 | +#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */ | |
230 | +/* SIOCGIWSTATS is strictly used between user space and the kernel, and | |
231 | + * is never passed to the driver (i.e. the driver will never see it). */ | |
232 | + | |
233 | +/* Spy support (statistics per MAC address - used for Mobile IP support) */ | |
234 | +#define SIOCSIWSPY 0x8B10 /* set spy addresses */ | |
235 | +#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */ | |
236 | +#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */ | |
237 | +#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */ | |
238 | + | |
239 | +/* Access Point manipulation */ | |
240 | +#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */ | |
241 | +#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */ | |
242 | +#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */ | |
243 | +#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */ | |
244 | +#define SIOCGIWSCAN 0x8B19 /* get scanning results */ | |
245 | + | |
246 | +/* 802.11 specific support */ | |
247 | +#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */ | |
248 | +#define SIOCGIWESSID 0x8B1B /* get ESSID */ | |
249 | +#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */ | |
250 | +#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */ | |
251 | +/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit | |
252 | + * within the 'iwreq' structure, so we need to use the 'data' member to | |
253 | + * point to a string in user space, like it is done for RANGE... */ | |
254 | + | |
255 | +/* Other parameters useful in 802.11 and some other devices */ | |
256 | +#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */ | |
257 | +#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */ | |
258 | +#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */ | |
259 | +#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */ | |
260 | +#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */ | |
261 | +#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */ | |
262 | +#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */ | |
263 | +#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */ | |
264 | +#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */ | |
265 | +#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */ | |
266 | + | |
267 | +/* Encoding stuff (scrambling, hardware security, WEP...) */ | |
268 | +#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */ | |
269 | +#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */ | |
270 | +/* Power saving stuff (power management, unicast and multicast) */ | |
271 | +#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */ | |
272 | +#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */ | |
273 | + | |
274 | +/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). | |
275 | + * This ioctl uses struct iw_point and data buffer that includes IE id and len | |
276 | + * fields. More than one IE may be included in the request. Setting the generic | |
277 | + * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers | |
278 | + * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers | |
279 | + * are required to report the used IE as a wireless event, e.g., when | |
280 | + * associating with an AP. */ | |
281 | +#define SIOCSIWGENIE 0x8B30 /* set generic IE */ | |
282 | +#define SIOCGIWGENIE 0x8B31 /* get generic IE */ | |
283 | + | |
284 | +/* WPA : IEEE 802.11 MLME requests */ | |
285 | +#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses | |
286 | + * struct iw_mlme */ | |
287 | +/* WPA : Authentication mode parameters */ | |
288 | +#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */ | |
289 | +#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */ | |
290 | + | |
291 | +/* WPA : Extended version of encoding configuration */ | |
292 | +#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */ | |
293 | +#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */ | |
294 | + | |
295 | +/* WPA2 : PMKSA cache management */ | |
296 | +#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */ | |
297 | + | |
298 | +/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */ | |
299 | + | |
300 | +/* These 32 ioctl are wireless device private, for 16 commands. | |
301 | + * Each driver is free to use them for whatever purpose it chooses, | |
302 | + * however the driver *must* export the description of those ioctls | |
303 | + * with SIOCGIWPRIV and *must* use arguments as defined below. | |
304 | + * If you don't follow those rules, DaveM is going to hate you (reason : | |
305 | + * it make mixed 32/64bit operation impossible). | |
306 | + */ | |
307 | +#define SIOCIWFIRSTPRIV 0x8BE0 | |
308 | +#define SIOCIWLASTPRIV 0x8BFF | |
309 | +/* Previously, we were using SIOCDEVPRIVATE, but we now have our | |
310 | + * separate range because of collisions with other tools such as | |
311 | + * 'mii-tool'. | |
312 | + * We now have 32 commands, so a bit more space ;-). | |
313 | + * Also, all 'odd' commands are only usable by root and don't return the | |
314 | + * content of ifr/iwr to user (but you are not obliged to use the set/get | |
315 | + * convention, just use every other two command). More details in iwpriv.c. | |
316 | + * And I repeat : you are not forced to use them with iwpriv, but you | |
317 | + * must be compliant with it. | |
318 | + */ | |
319 | + | |
320 | +/* ------------------------- IOCTL STUFF ------------------------- */ | |
321 | + | |
322 | +/* The first and the last (range) */ | |
323 | +#define SIOCIWFIRST 0x8B00 | |
324 | +#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */ | |
325 | + | |
326 | +/* Even : get (world access), odd : set (root access) */ | |
327 | +#define IW_IS_SET(cmd) (!((cmd) & 0x1)) | |
328 | +#define IW_IS_GET(cmd) ((cmd) & 0x1) | |
329 | + | |
330 | +/* ----------------------- WIRELESS EVENTS ----------------------- */ | |
331 | +/* Those are *NOT* ioctls, do not issue request on them !!! */ | |
332 | +/* Most events use the same identifier as ioctl requests */ | |
333 | + | |
334 | +#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */ | |
335 | +#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */ | |
336 | +#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */ | |
337 | +#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */ | |
338 | +#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */ | |
339 | +#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..) | |
340 | + * (scan results); This includes id and | |
341 | + * length fields. One IWEVGENIE may | |
342 | + * contain more than one IE. Scan | |
343 | + * results may contain one or more | |
344 | + * IWEVGENIE events. */ | |
345 | +#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure | |
346 | + * (struct iw_michaelmicfailure) | |
347 | + */ | |
348 | +#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request. | |
349 | + * The data includes id and length | |
350 | + * fields and may contain more than one | |
351 | + * IE. This event is required in | |
352 | + * Managed mode if the driver | |
353 | + * generates its own WPA/RSN IE. This | |
354 | + * should be sent just before | |
355 | + * IWEVREGISTERED event for the | |
356 | + * association. */ | |
357 | +#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association | |
358 | + * Response. The data includes id and | |
359 | + * length fields and may contain more | |
360 | + * than one IE. This may be sent | |
361 | + * between IWEVASSOCREQIE and | |
362 | + * IWEVREGISTERED events for the | |
363 | + * association. */ | |
364 | +#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN | |
365 | + * pre-authentication | |
366 | + * (struct iw_pmkid_cand) */ | |
367 | + | |
368 | +#define IWEVFIRST 0x8C00 | |
369 | + | |
370 | +/* ------------------------- PRIVATE INFO ------------------------- */ | |
371 | +/* | |
372 |