• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/wireless-tools


Commit MetaInfo

Revision37268af80055faf826140ff0c255f495df34b616 (tree)
Time2016-10-12 05:54:07
Authorchris-kirby <chris.kirby@hpe....>
Commiterchris-kirby

Log Message

v21

Change Summary

Incremental Difference

--- /dev/null
+++ b/wireless_tools/COPYING
@@ -0,0 +1,340 @@
1+ GNU GENERAL PUBLIC LICENSE
2+ Version 2, June 1991
3+
4+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6+ Everyone is permitted to copy and distribute verbatim copies
7+ of this license document, but changing it is not allowed.
8+
9+ Preamble
10+
11+ The licenses for most software are designed to take away your
12+freedom to share and change it. By contrast, the GNU General Public
13+License is intended to guarantee your freedom to share and change free
14+software--to make sure the software is free for all its users. This
15+General Public License applies to most of the Free Software
16+Foundation's software and to any other program whose authors commit to
17+using it. (Some other Free Software Foundation software is covered by
18+the GNU Library General Public License instead.) You can apply it to
19+your programs, too.
20+
21+ When we speak of free software, we are referring to freedom, not
22+price. Our General Public Licenses are designed to make sure that you
23+have the freedom to distribute copies of free software (and charge for
24+this service if you wish), that you receive source code or can get it
25+if you want it, that you can change the software or use pieces of it
26+in new free programs; and that you know you can do these things.
27+
28+ To protect your rights, we need to make restrictions that forbid
29+anyone to deny you these rights or to ask you to surrender the rights.
30+These restrictions translate to certain responsibilities for you if you
31+distribute copies of the software, or if you modify it.
32+
33+ For example, if you distribute copies of such a program, whether
34+gratis or for a fee, you must give the recipients all the rights that
35+you have. You must make sure that they, too, receive or can get the
36+source code. And you must show them these terms so they know their
37+rights.
38+
39+ We protect your rights with two steps: (1) copyright the software, and
40+(2) offer you this license which gives you legal permission to copy,
41+distribute and/or modify the software.
42+
43+ Also, for each author's protection and ours, we want to make certain
44+that everyone understands that there is no warranty for this free
45+software. If the software is modified by someone else and passed on, we
46+want its recipients to know that what they have is not the original, so
47+that any problems introduced by others will not reflect on the original
48+authors' reputations.
49+
50+ Finally, any free program is threatened constantly by software
51+patents. We wish to avoid the danger that redistributors of a free
52+program will individually obtain patent licenses, in effect making the
53+program proprietary. To prevent this, we have made it clear that any
54+patent must be licensed for everyone's free use or not licensed at all.
55+
56+ The precise terms and conditions for copying, distribution and
57+modification follow.
58+
59+ GNU GENERAL PUBLIC LICENSE
60+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61+
62+ 0. This License applies to any program or other work which contains
63+a notice placed by the copyright holder saying it may be distributed
64+under the terms of this General Public License. The "Program", below,
65+refers to any such program or work, and a "work based on the Program"
66+means either the Program or any derivative work under copyright law:
67+that is to say, a work containing the Program or a portion of it,
68+either verbatim or with modifications and/or translated into another
69+language. (Hereinafter, translation is included without limitation in
70+the term "modification".) Each licensee is addressed as "you".
71+
72+Activities other than copying, distribution and modification are not
73+covered by this License; they are outside its scope. The act of
74+running the Program is not restricted, and the output from the Program
75+is covered only if its contents constitute a work based on the
76+Program (independent of having been made by running the Program).
77+Whether that is true depends on what the Program does.
78+
79+ 1. You may copy and distribute verbatim copies of the Program's
80+source code as you receive it, in any medium, provided that you
81+conspicuously and appropriately publish on each copy an appropriate
82+copyright notice and disclaimer of warranty; keep intact all the
83+notices that refer to this License and to the absence of any warranty;
84+and give any other recipients of the Program a copy of this License
85+along with the Program.
86+
87+You may charge a fee for the physical act of transferring a copy, and
88+you may at your option offer warranty protection in exchange for a fee.
89+
90+ 2. You may modify your copy or copies of the Program or any portion
91+of it, thus forming a work based on the Program, and copy and
92+distribute such modifications or work under the terms of Section 1
93+above, provided that you also meet all of these conditions:
94+
95+ a) You must cause the modified files to carry prominent notices
96+ stating that you changed the files and the date of any change.
97+
98+ b) You must cause any work that you distribute or publish, that in
99+ whole or in part contains or is derived from the Program or any
100+ part thereof, to be licensed as a whole at no charge to all third
101+ parties under the terms of this License.
102+
103+ c) If the modified program normally reads commands interactively
104+ when run, you must cause it, when started running for such
105+ interactive use in the most ordinary way, to print or display an
106+ announcement including an appropriate copyright notice and a
107+ notice that there is no warranty (or else, saying that you provide
108+ a warranty) and that users may redistribute the program under
109+ these conditions, and telling the user how to view a copy of this
110+ License. (Exception: if the Program itself is interactive but
111+ does not normally print such an announcement, your work based on
112+ the Program is not required to print an announcement.)
113+
114+These requirements apply to the modified work as a whole. If
115+identifiable sections of that work are not derived from the Program,
116+and can be reasonably considered independent and separate works in
117+themselves, then this License, and its terms, do not apply to those
118+sections when you distribute them as separate works. But when you
119+distribute the same sections as part of a whole which is a work based
120+on the Program, the distribution of the whole must be on the terms of
121+this License, whose permissions for other licensees extend to the
122+entire whole, and thus to each and every part regardless of who wrote it.
123+
124+Thus, it is not the intent of this section to claim rights or contest
125+your rights to work written entirely by you; rather, the intent is to
126+exercise the right to control the distribution of derivative or
127+collective works based on the Program.
128+
129+In addition, mere aggregation of another work not based on the Program
130+with the Program (or with a work based on the Program) on a volume of
131+a storage or distribution medium does not bring the other work under
132+the scope of this License.
133+
134+ 3. You may copy and distribute the Program (or a work based on it,
135+under Section 2) in object code or executable form under the terms of
136+Sections 1 and 2 above provided that you also do one of the following:
137+
138+ a) Accompany it with the complete corresponding machine-readable
139+ source code, which must be distributed under the terms of Sections
140+ 1 and 2 above on a medium customarily used for software interchange; or,
141+
142+ b) Accompany it with a written offer, valid for at least three
143+ years, to give any third party, for a charge no more than your
144+ cost of physically performing source distribution, a complete
145+ machine-readable copy of the corresponding source code, to be
146+ distributed under the terms of Sections 1 and 2 above on a medium
147+ customarily used for software interchange; or,
148+
149+ c) Accompany it with the information you received as to the offer
150+ to distribute corresponding source code. (This alternative is
151+ allowed only for noncommercial distribution and only if you
152+ received the program in object code or executable form with such
153+ an offer, in accord with Subsection b above.)
154+
155+The source code for a work means the preferred form of the work for
156+making modifications to it. For an executable work, complete source
157+code means all the source code for all modules it contains, plus any
158+associated interface definition files, plus the scripts used to
159+control compilation and installation of the executable. However, as a
160+special exception, the source code distributed need not include
161+anything that is normally distributed (in either source or binary
162+form) with the major components (compiler, kernel, and so on) of the
163+operating system on which the executable runs, unless that component
164+itself accompanies the executable.
165+
166+If distribution of executable or object code is made by offering
167+access to copy from a designated place, then offering equivalent
168+access to copy the source code from the same place counts as
169+distribution of the source code, even though third parties are not
170+compelled to copy the source along with the object code.
171+
172+ 4. You may not copy, modify, sublicense, or distribute the Program
173+except as expressly provided under this License. Any attempt
174+otherwise to copy, modify, sublicense or distribute the Program is
175+void, and will automatically terminate your rights under this License.
176+However, parties who have received copies, or rights, from you under
177+this License will not have their licenses terminated so long as such
178+parties remain in full compliance.
179+
180+ 5. You are not required to accept this License, since you have not
181+signed it. However, nothing else grants you permission to modify or
182+distribute the Program or its derivative works. These actions are
183+prohibited by law if you do not accept this License. Therefore, by
184+modifying or distributing the Program (or any work based on the
185+Program), you indicate your acceptance of this License to do so, and
186+all its terms and conditions for copying, distributing or modifying
187+the Program or works based on it.
188+
189+ 6. Each time you redistribute the Program (or any work based on the
190+Program), the recipient automatically receives a license from the
191+original licensor to copy, distribute or modify the Program subject to
192+these terms and conditions. You may not impose any further
193+restrictions on the recipients' exercise of the rights granted herein.
194+You are not responsible for enforcing compliance by third parties to
195+this License.
196+
197+ 7. If, as a consequence of a court judgment or allegation of patent
198+infringement or for any other reason (not limited to patent issues),
199+conditions are imposed on you (whether by court order, agreement or
200+otherwise) that contradict the conditions of this License, they do not
201+excuse you from the conditions of this License. If you cannot
202+distribute so as to satisfy simultaneously your obligations under this
203+License and any other pertinent obligations, then as a consequence you
204+may not distribute the Program at all. For example, if a patent
205+license would not permit royalty-free redistribution of the Program by
206+all those who receive copies directly or indirectly through you, then
207+the only way you could satisfy both it and this License would be to
208+refrain entirely from distribution of the Program.
209+
210+If any portion of this section is held invalid or unenforceable under
211+any particular circumstance, the balance of the section is intended to
212+apply and the section as a whole is intended to apply in other
213+circumstances.
214+
215+It is not the purpose of this section to induce you to infringe any
216+patents or other property right claims or to contest validity of any
217+such claims; this section has the sole purpose of protecting the
218+integrity of the free software distribution system, which is
219+implemented by public license practices. Many people have made
220+generous contributions to the wide range of software distributed
221+through that system in reliance on consistent application of that
222+system; it is up to the author/donor to decide if he or she is willing
223+to distribute software through any other system and a licensee cannot
224+impose that choice.
225+
226+This section is intended to make thoroughly clear what is believed to
227+be a consequence of the rest of this License.
228+
229+ 8. If the distribution and/or use of the Program is restricted in
230+certain countries either by patents or by copyrighted interfaces, the
231+original copyright holder who places the Program under this License
232+may add an explicit geographical distribution limitation excluding
233+those countries, so that distribution is permitted only in or among
234+countries not thus excluded. In such case, this License incorporates
235+the limitation as if written in the body of this License.
236+
237+ 9. The Free Software Foundation may publish revised and/or new versions
238+of the General Public License from time to time. Such new versions will
239+be similar in spirit to the present version, but may differ in detail to
240+address new problems or concerns.
241+
242+Each version is given a distinguishing version number. If the Program
243+specifies a version number of this License which applies to it and "any
244+later version", you have the option of following the terms and conditions
245+either of that version or of any later version published by the Free
246+Software Foundation. If the Program does not specify a version number of
247+this License, you may choose any version ever published by the Free Software
248+Foundation.
249+
250+ 10. If you wish to incorporate parts of the Program into other free
251+programs whose distribution conditions are different, write to the author
252+to ask for permission. For software which is copyrighted by the Free
253+Software Foundation, write to the Free Software Foundation; we sometimes
254+make exceptions for this. Our decision will be guided by the two goals
255+of preserving the free status of all derivatives of our free software and
256+of promoting the sharing and reuse of software generally.
257+
258+ NO WARRANTY
259+
260+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268+REPAIR OR CORRECTION.
269+
270+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278+POSSIBILITY OF SUCH DAMAGES.
279+
280+ END OF TERMS AND CONDITIONS
281+
282+ How to Apply These Terms to Your New Programs
283+
284+ If you develop a new program, and you want it to be of the greatest
285+possible use to the public, the best way to achieve this is to make it
286+free software which everyone can redistribute and change under these terms.
287+
288+ To do so, attach the following notices to the program. It is safest
289+to attach them to the start of each source file to most effectively
290+convey the exclusion of warranty; and each file should have at least
291+the "copyright" line and a pointer to where the full notice is found.
292+
293+ <one line to give the program's name and a brief idea of what it does.>
294+ Copyright (C) <year> <name of author>
295+
296+ This program is free software; you can redistribute it and/or modify
297+ it under the terms of the GNU General Public License as published by
298+ the Free Software Foundation; either version 2 of the License, or
299+ (at your option) any later version.
300+
301+ This program is distributed in the hope that it will be useful,
302+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304+ GNU General Public License for more details.
305+
306+ You should have received a copy of the GNU General Public License
307+ along with this program; if not, write to the Free Software
308+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309+
310+
311+Also add information on how to contact you by electronic and paper mail.
312+
313+If the program is interactive, make it output a short notice like this
314+when it starts in an interactive mode:
315+
316+ Gnomovision version 69, Copyright (C) year name of author
317+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318+ This is free software, and you are welcome to redistribute it
319+ under certain conditions; type `show c' for details.
320+
321+The hypothetical commands `show w' and `show c' should show the appropriate
322+parts of the General Public License. Of course, the commands you use may
323+be called something other than `show w' and `show c'; they could even be
324+mouse-clicks or menu items--whatever suits your program.
325+
326+You should also get your employer (if you work as a programmer) or your
327+school, if any, to sign a "copyright disclaimer" for the program, if
328+necessary. Here is a sample; alter the names:
329+
330+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
332+
333+ <signature of Ty Coon>, 1 April 1989
334+ Ty Coon, President of Vice
335+
336+This General Public License does not permit incorporating your program into
337+proprietary programs. If your program is a subroutine library, you may
338+consider it more useful to permit linking proprietary applications with the
339+library. If this is what you want to do, use the GNU Library General
340+Public License instead of this License.
--- a/wireless_tools/INSTALL
+++ b/wireless_tools/INSTALL
@@ -5,9 +5,7 @@ Very important note :
55 Kernels that support this version of the Wireless Tools are listed
66 below. For all kernels before that, please use the version v19 of
77 the Wireless Tools.
8- If your kernel has the relevant Wireless Extensions but the tools
9- refuse to compile, then your kernel headers in /usr/include are
10- pointing to the wrong place (very common with Debian).
8+ You might have headers troubles and it doesn't compile, see below...
119
1210 You need :
1311 --------
@@ -16,13 +14,17 @@ You need :
1614 -> from 2.2.14 onward
1715 -> from 2.3.24 onward
1816 Note : CONFIG_NET_RADIO must be enabled
17+ o (Optional) A Pcmcia package supporting Wireless Extension
1918 o A driver supporting wireless extensions
20- -> Wavelan isa from kernels above
21- -> Wavelan pcmcia from pcmcia 3.1.2 onward
22- -> Netwave pcmcia from pcmcia 3.1.2 onward
19+ -> Wavelan isa
20+ -> Wavelan pcmcia
21+ -> Netwave pcmcia
2322 -> Wavelan IEEE pcmcia drivers
23+ -> Aironet MPL driver
2424 -> Proxim RangeLan2/Symphony driver
25- -> Patch your favourite driver
25+ -> Raylink/WegGear2.4 driver
26+ -> Check my web page for latest list of drivers,
27+ otherwise patch your favourite driver...
2628 Note : more recent kernels and drivers are likely to support
2729 more wireless extension features...
2830
@@ -32,35 +34,55 @@ Recommended versions :
3234 o Kernel (wireless extension definition) :
3335 -> Kernel 2.2.14 onward
3436 -> Kernel 2.3.24 onward
37+ o Pcmcia package :
38+ -> Pcmcia 3.1.15 onward
3539 o Drivers with wireless extension support :
3640 -> Wavelan isa from kernels above
3741 -> Wavelan pcmcia from pcmcia 3.1.1 onward
3842 -> Netwave pcmcia from pcmcia 3.1.2 onward
39- -> Wavelan IEEE pcmcia GPL driver (wvlan) 1.0.1 onward
40- -> Wavelan IEEE pcmcia binary driver (wavelan2) v4.00 onward
43+ -> Wavelan IEEE pcmcia GPL driver (wvlan_cs) 1.0.5 onward
44+ -> Aironet MPL driver (airo_cs.c) 1.4 onward
4145 -> Proxim RangeLan2/Symphony driver 1.4.3 onward
46+ -> Raylink/WegGear2.4 driver 1.70 (note : read only)
4247
4348 Compile wireless tools :
4449 ----------------------
45- In theory, a "make" should suffice.
46- In practice, there is big troubles with the headers. If you
47-have glibc and kernel 2.2.X headers, that should be all
48-right. Depending on which version of the kernel headers (might be
49-different from kernel) and library headers you have, you need to play
50-with the options buried in iwcommon.h.
50+ In theory, a "make" should suffice to create the tools.
51+ In practice, there is big troubles with the kernel
52+headers. See below for how to fix that.
5153 Note : as some internal data structures change from kernel to
52-kernel, you are advised to not use the precompiled version but to
53-recompile your own.
54- "xwireless" is not currently in a compilable state.
54+kernel, you are advised to not use the precompiled version of the
55+tools but to recompile your own.
5556
5657 Installation :
5758 ------------
59+ If I were you, I would not trust a "make install". If you feel
60+courageous, just do "make install". It may even do the right thing.
5861 I advise to copy the executable (iwconfig, iwspy and iwpriv)
59-in /usr/local/bin or /usr/local/sbin. The man pages (iwconfig.8,
60-iwspy.8 and iwpriv.8) should be copied in /usr/local/man/man8 or
62+in /usr/local/sbin or /usr/sbin. The man pages (iwconfig.8, iwspy.8
63+and iwpriv.8) should be copied in /usr/local/man/man8 or
6164 /usr/man/man8.
65+ In fact, if you want to use Pcmcia wireless.opts, this step is
66+mandatory...
6267
68+Kernel headers (why it doesn't compile) :
69+---------------------------------------
70+ Some changes in the kernel headers and glibc headers are
71+making my life difficult.
72+ If you have glibc and kernel 2.2.X headers (or greater), that
73+should be all right. This is the default for most modern distributions.
74+ In the other cases, depending on which version of the kernel
75+headers (might be different from kernel) and library headers you have,
76+you need to play with the options at the top of the Makefile.
6377
64-List of contributors and changelog is in iwcommon.h.
78+ The second issue is that some distributions install some
79+independant kernel headers in /usr/include. If you upgrade your
80+kernel, those headers become out of sync and you don't benefit from
81+the latest Wireless Extensions. Even worse, it can sometimes prevent
82+the tools from compiling.
83+ The trick is to copy the file .../include/linux/wireless.h
84+from the kernel to the /usr/include headers.
85+ A similar procedure may be used to update Wireless Extensions
86+in an older kernel...
6587
6688 Jean <jt@hpl.hp.com>
--- a/wireless_tools/Makefile
+++ b/wireless_tools/Makefile
@@ -1,11 +1,47 @@
1+#
2+# Basic and crude Makefile...
3+#
4+
5+# Targets to build
6+PROGS= iwconfig iwlist iwpriv iwspy iwgetid
7+
8+# Installation directory. By default, go in local.
9+# Distributions should probably use /usr/sbin, but they probably know better...
10+INSTALL_DIR= /usr/local/sbin
11+
12+# This is our header selection. Try to hide the mess and the misery :-(
13+# Please choose *only one* of the define...
14+
15+# Kernel headers 2.4.X + Glibc 2.2 - Mandrake 8.0 */
16+#HEADERS= -DGLIBC22_HEADERS
17+
18+# Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH 5
19+# Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH 6.1
20+# Kernel headers 2.4.X + Glibc 2.1 - Debian 2.2 upgraded, RH 7.0
21+HEADERS= -DGLIBC_HEADERS
22+
23+# Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1
24+#HEADERS= -DKLUDGE_HEADERS
25+
26+# Kernel headers 2.0.X + libc5 - old systems
27+#HEADERS= -DLIBC5_HEADERS
28+
29+# Use private copy of Wireless Extension definition instead of the
30+# system wide one in /usr/include/linux. Use with care.
31+# Can be used to create multiple versions of the tools on the same system
32+# for multiple kernels or get around broken distributions.
33+#WE_HEADER= -DPRIVATE_WE_HEADER
34+WE_HEADER=
35+
36+# ------------ End of config --------------
37+
138 CC = gcc
239 RM = rm -f
340
441 RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a
542
6-CFLAGS=-O2 -Wall
43+CFLAGS=-O2 -Wall $(HEADERS) $(WE_HEADER)
744
8-PROGS=iwconfig iwpriv iwspy
945 LIBS=-lm
1046
1147 all:: $(PROGS)
@@ -14,17 +50,31 @@ all:: $(PROGS)
1450 $(CC) $(CFLAGS) -c $<
1551
1652 iwconfig: iwconfig.o iwcommon.o
17- gcc -O2 -o $@ $^ $(LIBS)
53+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
54+
55+iwlist: iwlist.o iwcommon.o
56+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
1857
1958 iwpriv: iwpriv.o iwcommon.o
20- gcc -O2 -o $@ $^ $(LIBS)
59+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
2160
2261 iwspy: iwspy.o iwcommon.o
23- gcc -O2 -o $@ $^ $(LIBS)
62+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
63+
64+iwgetid: iwgetid.o
65+ $(CC) $(CFLAGS) -o $@ $^
66+
67+# So crude but so effective ;-)
68+install::
69+ cp $(PROGS) $(INSTALL_DIR)
2470
2571 clean::
2672 $(RM_CMD)
2773
74+realclean::
75+ $(RM_CMD)
76+ $(RM) $(PROGS)
77+
2878 depend::
2979 makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS)
3080 # DO NOT DELETE
--- /dev/null
+++ b/wireless_tools/PCMCIA.txt
@@ -0,0 +1,135 @@
1+ One of the most exciting thing having happen after release 20
2+is the addition of Wireless Extension support in the Pcmcia init
3+scripts. Here is a quick intro on the subject...
4+
5+Pre-requisite :
6+-------------
7+ o Pcmcia package with Wireless Extension support : 3.1.15 onward
8+ o A driver with Wireless Extension support
9+ o The tools (iwconfig and co.) installed in the /usr/local/sbin
10+ or /usr/sbin
11+
12+Raylink driver :
13+--------------
14+ The Raylink driver as of 1.70 doesn't support yet writable
15+Wireless Extensions, so enabling wireless.opts on this driver will
16+make thing worse.
17+
18+Pcmcia precompiled package :
19+--------------------------
20+ The Pcmcia package part of many distributions, especially
21+those from Red-Hat, include some weird init scripts. Because of this,
22+the present feature won't work.
23+ On the other hand, the Pcmcia package in source form from the
24+official Linux-Pcmcia web site will install the proper init scripts.
25+
26+Basic support :
27+-------------
28+ The file /etc/pcmcia/wireless.opts contain some templates for
29+the most common drivers. Just fill in your card configuration in the
30+template corresponding to your driver configuration.
31+ Then, to activate it, you just need to remove or comment the 4
32+lines at the top of wireless.opts and restart the Pcmcia package.
33+
34+ Things to take care of :
35+ The options of wireless.opts will be used directly as
36+arguments of iwconfig. So, you need iwconfig, and you need to check
37+the man page of iwconfig to know how to format them.
38+ A quick way to determine the correct options without
39+restarting Pcmcia is to play a bit with iwconfig directly to see what
40+is possible and what is the proper setup of the card and to copy that
41+in wireless.opts.
42+ At the end of wireless.opts, there is also a generic template
43+containing all the possible options and explaining their meaning. Not
44+all of them are supported by all cards (actually, most cards support a
45+limited subset of it).
46+ The current card templates are designed to match the MAC
47+address of the card. Please check that this matches with your card.
48+ Also, sample describe the most common/useful options available
49+with the card, for more advance option, borrow options from the
50+template. You can also remove some options, the card will usually
51+initialise with a sane value.
52+
53+ Alternatively, you can also discard the current wireless.opts
54+and replace it with a file looking like this :
55+----------- wireless.opts ---------------------
56+case "$ADDRESS" in
57+*,*,*,*)
58+ ESSID="MY_ESSID"
59+ MODE="Managed"
60+ ;;
61+esac
62+-----------------------------------------------
63+
64+
65+Scheme support :
66+--------------
67+ The file wireless.opts fully support schemes. This allow you
68+to define different configurations (home, work...) and to switch on
69+the fly between them.
70+ The best way to explain it is to show an example.
71+ Let's say you have an infrastructured setup at work (MY_WORK)
72+and an adhoc network at home (MY_HOME). Moreover, when a specific card
73+is inserted, you want it to be in adhoc mode (TEST). The work setup
74+will be the default...
75+
76+ Each Wireless LAN will have the following configuration :
77+--------- wireless.opts --------------------
78+# Lucent Wavelan IEEE - Ad-Hoc mode for test card
79+*,*,*,00:60:1D:03:9F:2D)
80+ ESSID="TEST"
81+ MODE="Ad-Hoc"
82+ FREQ="10"
83+ RATE="1M"
84+ ;;
85+
86+# Lucent Wavelan IEEE - Ad-Hoc mode at home
87+home,*,*,00:60:1D:*|home,*,*,00:02:2D:*)
88+ ESSID="MY_HOME"
89+ MODE="Ad-Hoc"
90+ FREQ="5"
91+ ;;
92+
93+# Lucent Wavelan IEEE - infrastructured mode at work
94+*,*,*,00:60:1D:*|*,*,*,00:02:2D:*)
95+ ESSID="MY_WORK"
96+ MODE="Managed"
97+ KEY="s:verysecurekey"
98+ ;;
99+--------------------------------------------
100+
101+ Don't forget the IP configuration :
102+--------- network.opts ---------------------
103+# Wavelan IEEE : ad-hoc mode for test card
104+*,*,*,00:60:1D:03:9F:2D)
105+ DHCP="n"
106+ IPADDR="10.0.0.1"
107+ NETMASK="255.255.255.0"
108+ NETWORK="10.0.0.0"
109+ BROADCAST="10.0.0.255"
110+ ;;
111+
112+# Wavelan IEEE : ad-hoc mode at home
113+home,*,*,00:60:1D:*|home,*,*,00:02:2D:*)
114+ DHCP="n"
115+ IPADDR="10.0.1.19"
116+ NETMASK="255.255.255.0"
117+ NETWORK="10.0.1.0"
118+ BROADCAST="10.0.1.255"
119+ GATEWAY="15.0.1.1"
120+ ;;
121+
122+# Wavelan IEEE : infrastructured mode at work
123+*,*,*,00:60:1D:*|*,*,*,00:02:2D:*)
124+ DHCP="y"
125+ ;;
126+--------------------------------------------
127+
128+ Now, when you are at work you do :
129+> cardctl scheme default
130+ And at home, you do :
131+> cardctl scheme home
132+
133+ I guess you get the idea ;-)
134+
135+ Jean <jt@hpl.hp.com>
--- a/wireless_tools/README
+++ b/wireless_tools/README
@@ -1,45 +1,82 @@
1+ Wireless Tools
2+ --------------
3+
14 This package contain the Wireless tools, used to manipulate
25 the Wireless Extensions. The Wireless Extension is an interface
36 allowing you to set Wireless LAN specific parameters and get the
47 specific stats.
58
9+web page
10+--------
11+ You'll find a lot of useful info on :
12+ http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
13+ http://web.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
14+
615 INSTALL
716 -------
8- Installation instruction and requirements.
17+ This file contains installation instruction and requirements.
918
10-man pages (iwconfig.8, iwpriv.8, iwspy.8)
19+PCMCIA.txt
20+----------
21+ This file describes how to use Pcmcia init script to configure
22+Wireless Extensions and how to use Pcmcia schemes.
23+
24+man pages (iwconfig.8, iwlist.8, iwpriv.8, iwspy.8)
1125 ---------
12- As far as I know, the man pages are the most complete, up to
13-date and accurate documentation of the wireless tools, and you really
14-should read them.
15- They can either be copied in a location where the command
16-"man" will find them, or can be read with the command :
17- nroff -man xxx.8 | more
26+ VERY IMPORTANT : I try to keep the man page up to date, so
27+you'd better read them before asking questions.
28+ ALSO IMPORTANT : Those man pages describe the capacity of the
29+tools, no device implement the full range (and driver usually
30+implement even less).
1831
19-web page
20---------
21- You'll find a lot of useful info on :
22- http://web.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
32+ As far as I know, the man pages are the most complete, up to
33+date and accurate documentation of the wireless tools. An update of
34+the web page related to Wireless Extension is long overdue. Send
35+feedback to me.
36+ The man pages can either be copied in a location where the
37+command "man" will find them, such as /usr/local/man/man8, or can be
38+read locally with the command :
39+ nroff -man xxx.8 | less
2340
2441 iwconfig.c
2542 ----------
2643 The main wireless tool. Used for device configuration and to see
27- the most common parameters.
44+the most common wireless parameters.
45+
46+iwlist.c
47+--------
48+ Display some large chunk of information not displayed by iwconfig.
49+ For example, all bit rates, all frequencies, all keys...
2850
2951 iwspy.c
3052 -------
3153 Mobile IP support test and allow get get stats per MAC address
32- (instead of globally). Also display available bit rates and
33- frequencies.
54+(instead of globally). Also, for some driver/device, this is the only
55+way to get stats in Ad-Hoc mode.
3456
3557 iwpriv.c
3658 --------
37- Manipulate driver private ioctls (all that is not available in
38- iwconfig). These are device specific parameters.
59+ Manipulate driver private ioctls : all parameters that are
60+specific to a driver or a device and therefore not part of iwconfig.
61+
62+iwgetid.c
63+---------
64+ Output the ESSID or NWID of the specified device.
65+ Can also output it in a form that can be used as a Pcmcia Scheme.
66+
67+Changelog, contributions
68+------------------------
69+ See iwcommon.h
70+
71+wireless.h
72+----------
73+ Definition of the Wireless Extensions. You may drop this file
74+in your kernel headers to update the Wireless Extensions.
3975
40-xwireless.c
76+Other tools :
4177 -----------
42- Graphical tool for the Netwave created by Dag Brattli <dagb@cs.uit.no>
78+ My web page above list many other tools using Wireless
79+Extensions that you may find useful...
4380
4481
4582 The list of changes, credits and errata notes are in
--- a/wireless_tools/iwcommon.c
+++ b/wireless_tools/iwcommon.c
@@ -1,9 +1,11 @@
11 /*
22 * Wireless Tools
33 *
4- * Jean II - HPLB '99
4+ * Jean II - HPLB 97->99 - HPL 99->00
55 *
66 * Common subroutines to all the wireless tools...
7+ *
8+ * This file is released under the GPL license.
79 */
810
911 #include "iwcommon.h" /* Header */
@@ -56,14 +58,55 @@ get_range_info(int skfd,
5658 iwrange * range)
5759 {
5860 struct iwreq wrq;
61+ char buffer[sizeof(iwrange) * 2]; /* Large enough */
62+
63+ /* Cleanup */
64+ memset(buffer, 0, sizeof(range));
5965
6066 strcpy(wrq.ifr_name, ifname);
61- wrq.u.data.pointer = (caddr_t) range;
67+ wrq.u.data.pointer = (caddr_t) buffer;
6268 wrq.u.data.length = 0;
6369 wrq.u.data.flags = 0;
6470 if(ioctl(skfd, SIOCGIWRANGE, &wrq) < 0)
6571 return(-1);
6672
73+ /* Copy stuff at the right place, ignore extra */
74+ memcpy((char *) range, buffer, sizeof(iwrange));
75+
76+ /* Lot's of people have driver and tools out of sync as far as Wireless
77+ * Extensions are concerned. It's because /usr/include/linux/wireless.h
78+ * and /usr/src/linux/include/linux/wireless.h are different.
79+ * We try to catch this stuff here... */
80+
81+ /* For new versions, we can check the version directly, for old versions
82+ * we use magic. 300 bytes is a also magic number, don't touch... */
83+ if((WIRELESS_EXT > 10) && (wrq.u.data.length >= 300))
84+ {
85+#if WIRELESS_EXT > 10
86+ /* Version verification - for new versions */
87+ if(range->we_version_compiled != WIRELESS_EXT)
88+ {
89+ fprintf(stderr, "Warning : Device %s has been compiled with version %d\n", ifname, range->we_version_compiled);
90+ fprintf(stderr, "of Wireless Extension, while we are using version %d.\n", WIRELESS_EXT);
91+ fprintf(stderr, "Some things may be broken...\n\n");
92+ }
93+#endif /* WIRELESS_EXT > 10 */
94+ }
95+ else
96+ {
97+ /* Version verification - for old versions */
98+ if(wrq.u.data.length != sizeof(iwrange))
99+ {
100+ fprintf(stderr, "Warning : Device %s has been compiled with a different version\n", ifname);
101+ fprintf(stderr, "of Wireless Extension than ours (we are using version %d).\n", WIRELESS_EXT);
102+ fprintf(stderr, "Some things may be broken...\n\n");
103+ }
104+ }
105+
106+ /* Note : we are only trying to catch compile difference, not source.
107+ * If the driver source has not been updated to the latest, it doesn't
108+ * matter because the new fields are set to zero */
109+
67110 return(0);
68111 }
69112
@@ -126,6 +169,224 @@ freq2float(iwfreq * in)
126169 return ((double) in->m) * pow(10,in->e);
127170 }
128171
172+/************************ POWER SUBROUTINES *************************/
173+
174+/*------------------------------------------------------------------*/
175+/*
176+ * Convert a value in dBm to a value in milliWatt.
177+ */
178+int
179+dbm2mwatt(int in)
180+{
181+ return((int) (floor(pow(10.0, (((double) in) / 10.0)))));
182+}
183+
184+/*------------------------------------------------------------------*/
185+/*
186+ * Convert a value in milliWatt to a value in dBm.
187+ */
188+int
189+mwatt2dbm(int in)
190+{
191+ return((int) (ceil(10.0 * log10((double) in))));
192+}
193+
194+/********************** STATISTICS SUBROUTINES **********************/
195+
196+/*------------------------------------------------------------------*/
197+/*
198+ * Output the link statistics, taking care of formating
199+ */
200+void
201+print_stats(FILE * stream,
202+ iwqual * qual,
203+ iwrange * range,
204+ int has_range)
205+{
206+ /* Just do it */
207+ if(has_range && (qual->level != 0))
208+ {
209+ /* If the statistics are in dBm */
210+ if(qual->level > range->max_qual.level)
211+ {
212+ /* Statistics are in dBm (absolute power measurement) */
213+ fprintf(stream,
214+ "Quality:%d/%d Signal level:%d dBm Noise level:%d dBm%s\n",
215+ qual->qual, range->max_qual.qual,
216+ qual->level - 0x100, qual->noise - 0x100,
217+ (qual->updated & 0x7) ? " (updated)" : "");
218+ }
219+ else
220+ {
221+ /* Statistics are relative values (0 -> max) */
222+ fprintf(stream,
223+ "Quality:%d/%d Signal level:%d/%d Noise level:%d/%d%s\n",
224+ qual->qual, range->max_qual.qual,
225+ qual->level, range->max_qual.level,
226+ qual->noise, range->max_qual.noise,
227+ (qual->updated & 0x7) ? " (updated)" : "");
228+ }
229+ }
230+ else
231+ {
232+ /* We can't read the range, so we don't know... */
233+ fprintf(stream, "Quality:%d Signal level:%d Noise level:%d%s\n",
234+ qual->qual, qual->level, qual->noise,
235+ (qual->updated & 0x7) ? " (updated)" : "");
236+ }
237+}
238+
239+/*********************** ENCODING SUBROUTINES ***********************/
240+
241+/*------------------------------------------------------------------*/
242+/*
243+ * Output the encoding key, with a nice formating
244+ */
245+void
246+print_key(FILE * stream,
247+ unsigned char * key,
248+ int key_size,
249+ int key_flags)
250+{
251+ int i;
252+
253+ /* Is the key present ??? */
254+ if(key_flags & IW_ENCODE_NOKEY)
255+ {
256+ /* Nope : print dummy */
257+ printf("**");
258+ for(i = 1; i < key_size; i++)
259+ {
260+ if((i & 0x1) == 0)
261+ printf("-");
262+ printf("**");
263+ }
264+ }
265+ else
266+ {
267+ /* Yes : print the key */
268+ printf("%.2X", key[0]);
269+ for(i = 1; i < key_size; i++)
270+ {
271+ if((i & 0x1) == 0)
272+ printf("-");
273+ printf("%.2X", key[i]);
274+ }
275+ }
276+}
277+
278+
279+/******************* POWER MANAGEMENT SUBROUTINES *******************/
280+
281+/*------------------------------------------------------------------*/
282+/*
283+ * Output a power management value with all attributes...
284+ */
285+void
286+print_pm_value(FILE * stream,
287+ int value,
288+ int flags)
289+{
290+ /* Modifiers */
291+ if(flags & IW_POWER_MIN)
292+ fprintf(stream, " min");
293+ if(flags & IW_POWER_MAX)
294+ fprintf(stream, " max");
295+
296+ /* Type */
297+ if(flags & IW_POWER_TIMEOUT)
298+ fprintf(stream, " timeout:");
299+ else
300+ fprintf(stream, " period:");
301+
302+ /* Display value without units */
303+ if(flags & IW_POWER_RELATIVE)
304+ fprintf(stream, "%g ", ((double) value) / MEGA);
305+ else
306+ {
307+ /* Display value with units */
308+ if(value >= (int) MEGA)
309+ fprintf(stream, "%gs ", ((double) value) / MEGA);
310+ else
311+ if(value >= (int) KILO)
312+ fprintf(stream, "%gms ", ((double) value) / KILO);
313+ else
314+ fprintf(stream, "%dus ", value);
315+ }
316+}
317+
318+/*------------------------------------------------------------------*/
319+/*
320+ * Output a power management mode
321+ */
322+void
323+print_pm_mode(FILE * stream,
324+ int flags)
325+{
326+ /* Print the proper mode... */
327+ switch(flags & IW_POWER_MODE)
328+ {
329+ case IW_POWER_UNICAST_R:
330+ fprintf(stream, " mode:Unicast only received");
331+ break;
332+ case IW_POWER_MULTICAST_R:
333+ fprintf(stream, " mode:Multicast only received");
334+ break;
335+ case IW_POWER_ALL_R:
336+ fprintf(stream, " mode:All packets received");
337+ break;
338+ case IW_POWER_FORCE_S:
339+ fprintf(stream, " mode:Force sending");
340+ break;
341+ case IW_POWER_REPEATER:
342+ fprintf(stream, " mode:Repeat multicasts");
343+ break;
344+ default:
345+ }
346+}
347+
348+/***************** RETRY LIMIT/LIFETIME SUBROUTINES *****************/
349+
350+#if WIRELESS_EXT > 10
351+/*------------------------------------------------------------------*/
352+/*
353+ * Output a retry value with all attributes...
354+ */
355+void
356+print_retry_value(FILE * stream,
357+ int value,
358+ int flags)
359+{
360+ /* Modifiers */
361+ if(flags & IW_RETRY_MIN)
362+ fprintf(stream, " min");
363+ if(flags & IW_RETRY_MAX)
364+ fprintf(stream, " max");
365+
366+ /* Type lifetime of limit */
367+ if(flags & IW_RETRY_LIFETIME)
368+ {
369+ fprintf(stream, " lifetime:");
370+
371+ /* Display value without units */
372+ if(flags & IW_POWER_RELATIVE)
373+ fprintf(stream, "%g", ((double) value) / MEGA);
374+ else
375+ {
376+ /* Display value with units */
377+ if(value >= (int) MEGA)
378+ fprintf(stream, "%gs", ((double) value) / MEGA);
379+ else
380+ if(value >= (int) KILO)
381+ fprintf(stream, "%gms", ((double) value) / KILO);
382+ else
383+ fprintf(stream, "%dus", value);
384+ }
385+ }
386+ else
387+ fprintf(stream, " limit:%d", value);
388+}
389+#endif /* WIRELESS_EXT > 10 */
129390
130391 /*********************** ADDRESS SUBROUTINES ************************/
131392 /*
--- a/wireless_tools/iwcommon.h
+++ b/wireless_tools/iwcommon.h
@@ -1,9 +1,11 @@
11 /*
22 * Wireless Tools
33 *
4- * Jean II - HPLB '99
4+ * Jean II - HPLB 97->99 - HPL 99->00
55 *
66 * Common header for the wireless tools...
7+ *
8+ * This file is released under the GPL license.
79 */
810
911 #ifndef IWCOMMON_H
@@ -89,6 +91,43 @@
8991 * - set timeout or period and its value
9092 * - Reception mode (unicast/multicast/all)
9193 * o Updated man pages with all that ;-)
94+ *
95+ * wireless 21 :
96+ * -----------
97+ * (from Alan McReynolds <alan_mcreynolds@hpl.hp.com>)
98+ * o Use proper macros for compilation directives [Makefile]
99+ * (From Jean Tourrilhes)
100+ * o Put licensing info everywhere (almost). Yes, it's GPL !
101+ * o Document the use of /etc/pcmcia/wireless.opts
102+ * o Add min/max modifiers to power management parameters [iwconfig]
103+ * -> requested by Lee Keyser-Allen for the Spectrum24 driver
104+ * o Optionally output a second power management parameter [iwconfig]
105+ * ---
106+ * o Common subroutines to display stats & power saving info [iwcommon]
107+ * o Display all power management info, capability and values [iwspy]
108+ * ---
109+ * o Optional index for ESSID (for Aironet driver) [iwcommon]
110+ * o IW_ENCODE_NOKEY for write only keys [iwconfig/iwspy]
111+ * o Common subrouting to print encoding keys [iwspy]
112+ * ---
113+ * o Transmit Power stuff (dBm + mW) [iwconfig/iwspy]
114+ * o Cleaner formatting algorithm when displaying params [iwconfig]
115+ * ---
116+ * o Fix get_range_info() and use it everywhere - Should fix core dumps.
117+ * o Catch WE version differences between tools and driver and
118+ * warn user. Thanks to Tobias Ringstrom for the tip... [iwcommon]
119+ * o Add Retry limit and lifetime support. [iwconfig/iwlist]
120+ * o Display "Cell:" instead of "Access Point:" in ad-hoc mode [iwconfig]
121+ * o Header fix for glibc2.2 by Ross G. Miller <Ross_Miller@baylor.edu>
122+ * o Move header selection flags in Makefile [iwcommon/Makefile]
123+ * o Spin-off iwlist.c from iwspy.c. iwspy is now much smaller
124+ * After moving this bit of code all over the place, from iwpriv
125+ * to iwconfig to iwspy, it now has a home of its own... [iwspy/iwlist]
126+ * o Wrote quick'n'dirty iwgetid.
127+ * o Remove output of second power management parameter [iwconfig]
128+ * Please use iwlist, I don't want to bloat iwconfig
129+ * ---
130+ * o Fix bug in display ints - "Allen Miu" <aklmiu@mit.edu> [iwpriv]
92131 */
93132
94133 /* ----------------------------- TODO ----------------------------- */
@@ -99,8 +138,6 @@
99138 * --------
100139 * Make disable a per encryption key modifier if some hardware
101140 * requires it.
102- * Should not mention "Access Point" but something different when
103- * in ad-hoc mode.
104141 *
105142 * iwpriv :
106143 * ------
@@ -108,7 +145,7 @@
108145 *
109146 * iwspy :
110147 * -----
111- * ?
148+ * -
112149 *
113150 * Doc & man pages :
114151 * ---------------
@@ -135,17 +172,8 @@
135172 #include <netdb.h> /* gethostbyname, getnetbyname */
136173
137174 /* This is our header selection. Try to hide the mess and the misery :-(
138- * Please choose only one of the define...
139- */
140-/* Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH5
141- * Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH6.1 */
142-#define GLIBC_HEADERS
143-
144-/* Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 */
145-#undef KLUDGE_HEADERS
146-
147-/* Kernel headers 2.0.X + libc5 - old systems */
148-#undef LIBC5_HEADERS
175+ * The selection has been moved in the Makefile, here we have only
176+ * the ugly part. Don't look, you would go blind ;-) */
149177
150178 #ifdef KLUDGE_HEADERS
151179 #include <socketbits.h>
@@ -157,19 +185,35 @@
157185 #include <linux/in.h> /* For struct sockaddr_in */
158186 #endif /* KLUDGE_HEADERS || GLIBC_HEADERS */
159187
188+#ifdef GLIBC22_HEADERS
189+/* Added by Ross G. Miller <Ross_Miller@baylor.edu>, 3/28/01 */
190+#include <linux/if_arp.h> /* For ARPHRD_ETHER */
191+#include <linux/socket.h> /* For AF_INET & struct sockaddr */
192+#include <sys/socket.h>
193+#endif /* GLIBC22_HEADERS */
194+
160195 #ifdef LIBC5_HEADERS
161196 #include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */
162197 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
163198 #include <linux/in.h> /* For struct sockaddr_in */
164199 #endif /* LIBC5_HEADERS */
165200
166-/* Wireless extensions */
201+#ifdef PRIVATE_WE_HEADER
202+/* Private copy of Wireless extensions */
203+#include "wireless.h"
204+#else /* PRIVATE_WE_HEADER */
205+/* System wide Wireless extensions */
167206 #include <linux/wireless.h>
207+#endif /* PRIVATE_WE_HEADER */
168208
169-#if WIRELESS_EXT < 8
170-#error "Wireless Extension v9 or newer required :-(\n\
209+#if WIRELESS_EXT < 9
210+#error "Wireless Extension v9 or newer required :-(\
171211 Use Wireless Tools v19 or update your kernel headers"
172212 #endif
213+#if WIRELESS_EXT < 11
214+#warning "Wireless Extension v11 recommended...\
215+You may update your kernel and/or system headers to get the new features..."
216+#endif
173217
174218 /****************************** DEBUG ******************************/
175219
@@ -181,6 +225,19 @@ Use Wireless Tools v19 or update your kernel headers"
181225 #define MEGA 1e6
182226 #define GIGA 1e9
183227
228+/* Backward compatibility for Wireless Extension 9 */
229+#ifndef IW_POWER_MODIFIER
230+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
231+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
232+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
233+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
234+#endif IW_POWER_MODIFIER
235+
236+#ifndef IW_ENCODE_NOKEY
237+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not here */
238+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
239+#endif IW_ENCODE_NOKEY
240+
184241 /****************************** TYPES ******************************/
185242
186243 /* Shortcuts */
@@ -188,6 +245,7 @@ typedef struct iw_statistics iwstats;
188245 typedef struct iw_range iwrange;
189246 typedef struct iw_param iwparam;
190247 typedef struct iw_freq iwfreq;
248+typedef struct iw_quality iwqual;
191249 typedef struct iw_priv_args iwprivargs;
192250 typedef struct sockaddr sockaddr;
193251
@@ -222,6 +280,10 @@ typedef struct wireless_info
222280 int mode; /* Operation mode */
223281 int has_power;
224282 iwparam power; /* Power management parameters */
283+ int has_txpower;
284+ iwparam txpower; /* Transmit Power in dBm */
285+ int has_retry;
286+ iwparam retry; /* Retry limit or lifetime */
225287
226288 /* Stats */
227289 iwstats stats;
@@ -252,6 +314,38 @@ void
252314 iwfreq * out);
253315 double
254316 freq2float(iwfreq * in);
317+/* ---------------------- POWER SUBROUTINES ----------------------- */
318+int
319+ dbm2mwatt(int in);
320+int
321+ mwatt2dbm(int in);
322+/* -------------------- STATISTICS SUBROUTINES -------------------- */
323+void
324+ print_stats(FILE * stream,
325+ iwqual * qual,
326+ iwrange * range,
327+ int has_range);
328+/* --------------------- ENCODING SUBROUTINES --------------------- */
329+void
330+ print_key(FILE * stream,
331+ unsigned char * key,
332+ int key_size,
333+ int key_flags);
334+/* ----------------- POWER MANAGEMENT SUBROUTINES ----------------- */
335+void
336+ print_pm_value(FILE * stream,
337+ int value,
338+ int flags);
339+void
340+ print_pm_mode(FILE * stream,
341+ int flags);
342+/* --------------- RETRY LIMIT/LIFETIME SUBROUTINES --------------- */
343+#if WIRELESS_EXT > 10
344+void
345+ print_retry_value(FILE * stream,
346+ int value,
347+ int flags);
348+#endif
255349 /* --------------------- ADDRESS SUBROUTINES ---------------------- */
256350 int
257351 check_addr_type(int skfd,
--- a/wireless_tools/iwconfig.8
+++ b/wireless_tools/iwconfig.8
@@ -17,9 +17,9 @@ iwconfig \- configure a wireless network interface
1717 .br
1818 .BI " [sens " S "] [mode " M "] [ap " A "] [nick " NN ]
1919 .br
20-.BI " [rate " R "] [rts " RT "] [frag " FT ]
20+.BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
2121 .br
22-.BI " [enc " E "] [key " K "] [power " P ]
22+.BI " [enc " E "] [key " K "] [power " P "] [retry " R ]
2323 .\"
2424 .\" DESCRIPTION part
2525 .\"
@@ -243,8 +243,12 @@ To set the period between wake up, enter
243243 .IR "period `value'" .
244244 To set the timeout before going back to sleep, enter
245245 .IR "timeout `value'" .
246-By defaults, those values are in seconds, append the suffix m or u to
247-specify values un milliseconds or microseconds.
246+You can also add the
247+.IR min " and " max
248+modifiers. By defaults, those values are in seconds, append the
249+suffix m or u to specify values un milliseconds or
250+microseconds. Sometimes, those values are without units (number of
251+dwell or the like).
248252 .br
249253 .IR off " and " on
250254 disable and reenable power management. Finally, you may set the power
@@ -265,6 +269,61 @@ management mode to
265269 .I " iwconfig eth0 power timeout 300u all"
266270 .br
267271 .I " iwconfig eth0 power off"
272+.br
273+.I " iwconfig eth0 power min period 2 power max period 4"
274+.TP
275+.BR txpower
276+For cards supporting multiple transmit powers, set the transmit power in dBm. If
277+.I W
278+is the power in Watt, the power in dBm is
279+.IR "P = 30 + 10.log(W)" .
280+If the value is postfixed by
281+.IR mW ,
282+it will be automatically converted to dBm.
283+.br
284+In addition,
285+.IR on " and " off
286+enable and disable the radio, and
287+.IR auto " and " fixed
288+enable and disable power control (if those features are available).
289+.br
290+.B Examples :
291+.br
292+.I " iwconfig eth0 txpower 15"
293+.br
294+.I " iwconfig eth0 txpower 30mW"
295+.br
296+.I " iwconfig eth0 txpower auto"
297+.br
298+.I " iwconfig eth0 txpower off"
299+.TP
300+.BR retry
301+Most cards have MAC retransmissions, and some allow to set the
302+behaviour of the retry mechanism.
303+.br
304+To set the maximum number of retries, enter
305+.IR "limit `value'" .
306+This is an absolute value (without unit).
307+The set the maximum length of time the MAC should retry, enter
308+.IR "lifetime `value'" .
309+By defaults, this value in in seconds, append the suffix m or u to
310+specify values un milliseconds or microseconds.
311+.br
312+You can also add the
313+.IR min " and " max
314+modifiers. If the card support automatic mode, they define the bounds
315+of the limit or lifetime. Some other cards define different values
316+depending on packet size, for example in 802.11
317+.I min limit
318+is the short retry limit (non RTS/CTS packets).
319+.br
320+.B Examples :
321+.br
322+.I " iwconfig eth0 retry 16"
323+.br
324+.I " iwconfig eth0 retry lifetime 300m"
325+.br
326+.I " iwconfig eth0 retry min limit 8"
268327 .\"
269328 .\" DISPLAY part
270329 .\"
@@ -345,7 +404,9 @@ Jean Tourrilhes \- jt@hpl.hp.com
345404 .SH SEE ALSO
346405 .BR ifconfig (8),
347406 .BR iwspy (8),
407+.BR iwlist (8),
348408 .BR iwpriv (8),
349409 .BR wavelan (4),
350410 .BR wavelan_cs (4),
351-.BR xircnw_cs (4).
411+.BR wvlan_cs (4),
412+.BR netwave_cs (4).
--- a/wireless_tools/iwconfig.c
+++ b/wireless_tools/iwconfig.c
@@ -1,11 +1,13 @@
11 /*
22 * Wireless Tools
33 *
4- * Jean II - HPLB '99
4+ * Jean II - HPLB 97->99 - HPL 99->01
55 *
66 * Main code for "iwconfig". This is the generic tool for most
77 * manipulations...
88 * You need to link this code against "iwcommon.c" and "-lm".
9+ *
10+ * This file is released under the GPL license.
911 */
1012
1113 #include "iwcommon.h" /* Header */
@@ -37,6 +39,8 @@ iw_usage(void)
3739 fprintf(stderr, " [rts {N|auto|fixed|off}]\n");
3840 fprintf(stderr, " [frag {N|auto|fixed|off}]\n");
3941 fprintf(stderr, " [enc NNNN-NNNN]\n");
42+ fprintf(stderr, " [power { period N|timeout N}]\n");
43+ fprintf(stderr, " [txpower N {mW|dBm}]\n");
4044 exit(1);
4145 }
4246
@@ -129,6 +133,10 @@ get_info(int skfd,
129133 else
130134 strcpy(info->name, wrq.u.name);
131135
136+ /* Get ranges */
137+ if(get_range_info(skfd, ifname, &(info->range)) >= 0)
138+ info->has_range = 1;
139+
132140 /* Get network ID */
133141 strcpy(wrq.ifr_name, ifname);
134142 if(ioctl(skfd, SIOCGIWNWID, &wrq) >= 0)
@@ -228,22 +236,39 @@ get_info(int skfd,
228236
229237 /* Get Power Management settings */
230238 strcpy(wrq.ifr_name, ifname);
239+ wrq.u.power.flags = 0;
231240 if(ioctl(skfd, SIOCGIWPOWER, &wrq) >= 0)
232241 {
233242 info->has_power = 1;
234243 memcpy(&(info->power), &(wrq.u.power), sizeof(iwparam));
235244 }
236245
246+#if WIRELESS_EXT > 9
247+ /* Get Transmit Power */
248+ strcpy(wrq.ifr_name, ifname);
249+ if(ioctl(skfd, SIOCGIWTXPOW, &wrq) >= 0)
250+ {
251+ info->has_txpower = 1;
252+ memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
253+ }
254+#endif
255+
256+#if WIRELESS_EXT > 10
257+ /* Get retry limit/lifetime */
258+ strcpy(wrq.ifr_name, ifname);
259+ if(ioctl(skfd, SIOCGIWRETRY, &wrq) >= 0)
260+ {
261+ info->has_retry = 1;
262+ memcpy(&(info->retry), &(wrq.u.retry), sizeof(iwparam));
263+ }
264+#endif /* WIRELESS_EXT > 10 */
265+
237266 /* Get stats */
238267 if(iw_getstats(ifname, &(info->stats)) >= 0)
239268 {
240269 info->has_stats = 1;
241270 }
242271
243- /* Get ranges */
244- if(get_range_info(skfd, ifname, &(info->range)) >= 0)
245- info->has_range = 1;
246-
247272 return(0);
248273 }
249274
@@ -256,6 +281,9 @@ static void
256281 display_info(struct wireless_info * info,
257282 char * ifname)
258283 {
284+ /* One token is more of less 5 character, 14 tokens per line */
285+ int tokens = 3; /* For name */
286+
259287 /* Display device name and wireless name (name of the protocol used) */
260288 printf("%-8.8s %s ", ifname, info->name);
261289
@@ -263,7 +291,14 @@ display_info(struct wireless_info * info,
263291 if(info->has_essid)
264292 {
265293 if(info->essid_on)
266- printf("ESSID:\"%s\" ", info->essid);
294+ {
295+ /* Does it have an ESSID index ? */
296+ if((info->essid_on & IW_ENCODE_INDEX) > 1)
297+ printf("ESSID:\"%s\" [%d] ", info->essid,
298+ (info->essid_on & IW_ENCODE_INDEX));
299+ else
300+ printf("ESSID:\"%s\" ", info->essid);
301+ }
267302 else
268303 printf("ESSID:off ");
269304 }
@@ -274,7 +309,10 @@ display_info(struct wireless_info * info,
274309
275310 /* Formatting */
276311 if(info->has_essid || info->has_nickname)
277- printf("\n ");
312+ {
313+ printf("\n ");
314+ tokens = 0;
315+ }
278316
279317 /* Display Network ID */
280318 if(info->has_nwid)
@@ -285,6 +323,14 @@ display_info(struct wireless_info * info,
285323 printf("NWID:off/any ");
286324 else
287325 printf("NWID:%X ", info->nwid.value);
326+ tokens +=2;
327+ }
328+
329+ /* Display the current mode of operation */
330+ if(info->has_mode)
331+ {
332+ printf("Mode:%s ", operation_mode[info->mode]);
333+ tokens +=3;
288334 }
289335
290336 /* Display frequency / channel */
@@ -304,54 +350,39 @@ display_info(struct wireless_info * info,
304350 printf("Frequency:%gkHz ", info->freq / KILO);
305351 }
306352 }
307- }
308-
309- /* Display sensitivity */
310- if(info->has_sens)
311- {
312- /* Fixed ? */
313- if(info->sens.fixed)
314- printf("Sensitivity=");
315- else
316- printf("Sensitivity:");
317-
318- if(info->has_range)
319- /* Display in dBm ? */
320- if(info->sens.value < 0)
321- printf("%d dBm ", info->sens.value);
322- else
323- printf("%d/%d ", info->sens.value, info->range.sensitivity);
324- else
325- printf("%d ", info->sens.value);
326- }
327-
328- /* Display the current mode of operation */
329- if(info->has_mode)
330- {
331- /* A bit of clever formatting */
332- if((info->has_nwid + 2*info->has_freq + 2*info->has_sens
333- + !info->has_essid) > 4)
334- printf("\n ");
335-
336- printf("Mode:%s ", operation_mode[info->mode]);
353+ tokens +=4;
337354 }
338355
339356 /* Display the address of the current Access Point */
340357 if(info->has_ap_addr)
341358 {
342359 /* A bit of clever formatting */
343- if((info->has_nwid + 2*info->has_freq + 2*info->has_sens
344- + info->has_mode + !info->has_essid) > 3)
345- printf("\n ");
360+ if(tokens > 8)
361+ {
362+ printf("\n ");
363+ tokens = 0;
364+ }
365+ tokens +=6;
346366
347- printf("Access Point: %s", pr_ether(info->ap_addr.sa_data));
367+ /* Oups ! No Access Point in Ad-Hoc mode */
368+ if((info->has_mode) && (info->mode == IW_MODE_ADHOC))
369+ printf("Cell:");
370+ else
371+ printf("Access Point:");
372+ printf(" %s", pr_ether(info->ap_addr.sa_data));
348373 }
349374
350- printf("\n ");
351-
352375 /* Display the currently used/set bit-rate */
353376 if(info->has_bitrate)
354377 {
378+ /* A bit of clever formatting */
379+ if(tokens > 11)
380+ {
381+ printf("\n ");
382+ tokens = 0;
383+ }
384+ tokens +=3;
385+
355386 /* Fixed ? */
356387 if(info->bitrate.fixed)
357388 printf("Bit Rate=");
@@ -368,6 +399,96 @@ display_info(struct wireless_info * info,
368399 printf(" ");
369400 }
370401
402+#if WIRELESS_EXT > 9
403+ /* Display the Transmit Power */
404+ if(info->has_txpower)
405+ {
406+ /* A bit of clever formatting */
407+ if(tokens > 11)
408+ {
409+ printf("\n ");
410+ tokens = 0;
411+ }
412+ tokens +=3;
413+
414+ /* Disabled ? */
415+ if(info->txpower.disabled)
416+ printf("Tx-Power:off ");
417+ else
418+ {
419+ int dbm;
420+
421+ /* Fixed ? */
422+ if(info->txpower.fixed)
423+ printf("Tx-Power=");
424+ else
425+ printf("Tx-Power:");
426+
427+ /* Convert everything to dBm */
428+ if(info->txpower.flags & IW_TXPOW_MWATT)
429+ dbm = mwatt2dbm(info->txpower.value);
430+ else
431+ dbm = info->txpower.value;
432+
433+ /* Display */
434+ printf("%d dBm ", dbm);
435+ }
436+ }
437+#endif
438+
439+ /* Display sensitivity */
440+ if(info->has_sens)
441+ {
442+ /* A bit of clever formatting */
443+ if(tokens > 10)
444+ {
445+ printf("\n ");
446+ tokens = 0;
447+ }
448+ tokens +=4;
449+
450+ /* Fixed ? */
451+ if(info->sens.fixed)
452+ printf("Sensitivity=");
453+ else
454+ printf("Sensitivity:");
455+
456+ if(info->has_range)
457+ /* Display in dBm ? */
458+ if(info->sens.value < 0)
459+ printf("%d dBm ", info->sens.value);
460+ else
461+ printf("%d/%d ", info->sens.value, info->range.sensitivity);
462+ else
463+ printf("%d ", info->sens.value);
464+ }
465+
466+ printf("\n ");
467+ tokens = 0;
468+
469+#if WIRELESS_EXT > 10
470+ /* Display retry limit/lifetime information */
471+ if(info->has_retry)
472+ {
473+ printf("Retry");
474+ /* Disabled ? */
475+ if(info->retry.disabled)
476+ printf(":off");
477+ else
478+ {
479+ /* Let's check the value and its type */
480+ if(info->retry.flags & IW_RETRY_TYPE)
481+ print_retry_value(stdout, info->retry.value, info->retry.flags);
482+
483+ /* Let's check if nothing (simply on) */
484+ if(info->retry.flags == IW_RETRY_ON)
485+ printf(":on");
486+ }
487+ printf(" ");
488+ tokens += 5; /* Between 3 and 5, depend on flags */
489+ }
490+#endif /* WIRELESS_EXT > 10 */
491+
371492 /* Display the RTS threshold */
372493 if(info->has_rts)
373494 {
@@ -384,14 +505,23 @@ display_info(struct wireless_info * info,
384505
385506 printf("%d B ", info->rts.value);
386507 }
508+ tokens += 3;
387509 }
388510
389511 /* Display the fragmentation threshold */
390512 if(info->has_frag)
391513 {
514+ /* A bit of clever formatting */
515+ if(tokens > 10)
516+ {
517+ printf("\n ");
518+ tokens = 0;
519+ }
520+ tokens +=4;
521+
392522 /* Disabled ? */
393523 if(info->frag.disabled)
394- printf("Fragment thr:off ");
524+ printf("Fragment thr:off");
395525 else
396526 {
397527 /* Fixed ? */
@@ -405,11 +535,11 @@ display_info(struct wireless_info * info,
405535 }
406536
407537 /* Formating */
408- if((info->has_bitrate) || (info->has_rts) || (info->has_bitrate))
538+ if(tokens > 0)
409539 printf("\n ");
410540
411541 /* Display encryption information */
412- /* Note : we display only the "current" key, use iwspy to list all keys */
542+ /* Note : we display only the "current" key, use iwlist to list all keys */
413543 if(info->has_key)
414544 {
415545 printf("Encryption key:");
@@ -417,15 +547,8 @@ display_info(struct wireless_info * info,
417547 printf("off\n ");
418548 else
419549 {
420- int i;
421-
422- printf("%.2X", info->key[0]);
423- for(i = 1; i < info->key_size; i++)
424- {
425- if((i & 0x1) == 0)
426- printf("-");
427- printf("%.2X", info->key[i]);
428- }
550+ /* Display the key */
551+ print_key(stdout, info->key, info->key_size, info->key_flags);
429552
430553 /* Other info... */
431554 if((info->key_flags & IW_ENCODE_INDEX) > 1)
@@ -440,7 +563,7 @@ display_info(struct wireless_info * info,
440563
441564 /* Display Power Management information */
442565 /* Note : we display only one parameter, period or timeout. If a device
443- * (such as HiperLan) has both, we would need to be a bit more clever... */
566+ * (such as HiperLan) has both, the user need to use iwlist... */
444567 if(info->has_power) /* I hope the device has power ;-) */
445568 {
446569 printf("Power Management");
@@ -451,43 +574,10 @@ display_info(struct wireless_info * info,
451574 {
452575 /* Let's check the value and its type */
453576 if(info->power.flags & IW_POWER_TYPE)
454- {
455- /* Type */
456- if(info->power.flags & IW_POWER_TIMEOUT)
457- printf(" timeout:");
458- else
459- printf(" period:");
460-
461- /* Display value with units */
462- if(info->power.value >= (int) MEGA)
463- printf("%gs ", ((double) info->power.value) / MEGA);
464- else
465- if(info->power.value >= (int) KILO)
466- printf("%gms ", ((double) info->power.value) / KILO);
467- else
468- printf("%dus ", info->power.value);
469- }
577+ print_pm_value(stdout, info->power.value, info->power.flags);
470578
471579 /* Let's check the mode */
472- switch(info->power.flags & IW_POWER_MODE)
473- {
474- case IW_POWER_UNICAST_R:
475- printf(" mode:Unicast received");
476- break;
477- case IW_POWER_MULTICAST_R:
478- printf(" mode:Multicast received");
479- break;
480- case IW_POWER_ALL_R:
481- printf(" mode:All packets received");
482- break;
483- case IW_POWER_FORCE_S:
484- printf(" mode:Force sending");
485- break;
486- case IW_POWER_REPEATER:
487- printf(" mode:Repeat multicasts");
488- break;
489- default:
490- }
580+ print_pm_mode(stdout, info->power.flags);
491581
492582 /* Let's check if nothing (simply on) */
493583 if(info->power.flags == IW_POWER_ON)
@@ -496,27 +586,12 @@ display_info(struct wireless_info * info,
496586 }
497587 }
498588
589+ /* Display statistics */
499590 if(info->has_stats)
500591 {
501- if(info->has_range && (info->stats.qual.level != 0))
502- /* If the statistics are in dBm */
503- if(info->stats.qual.level > info->range.max_qual.level)
504- printf("Link quality:%d/%d Signal level:%d dBm Noise level:%d dBm\n",
505- info->stats.qual.qual, info->range.max_qual.qual,
506- info->stats.qual.level - 0x100,
507- info->stats.qual.noise - 0x100);
508- else
509- /* Statistics are relative values (0 -> max) */
510- printf("Link quality:%d/%d Signal level:%d/%d Noise level:%d/%d\n",
511- info->stats.qual.qual, info->range.max_qual.qual,
512- info->stats.qual.level, info->range.max_qual.level,
513- info->stats.qual.noise, info->range.max_qual.noise);
514- else
515- /* We can't read the range, so we don't know... */
516- printf("Link quality:%d Signal level:%d Noise level:%d\n",
517- info->stats.qual.qual,
518- info->stats.qual.level,
519- info->stats.qual.noise);
592+ info->stats.qual.updated = 0x0; /* Not that reliable, disable */
593+ printf("Link ");
594+ print_stats(stdout, &info->stats.qual, &info->range, info->has_range);
520595
521596 printf(" Rx invalid nwid:%d invalid crypt:%d invalid misc:%d\n",
522597 info->stats.discard.nwid,
@@ -837,8 +912,19 @@ set_info(int skfd, /* The socket */
837912 }
838913 else
839914 {
915+ int temp;
916+
840917 wrq.u.essid.flags = 1;
841918 strcpy(essid, args[i]);
919+
920+ /* Check for ESSID index */
921+ if(((i+1) < count) &&
922+ (sscanf(args[i+1], "[%d]", &temp) == 1) &&
923+ (temp > 0) && (temp < IW_ENCODE_INDEX))
924+ {
925+ wrq.u.essid.flags = temp;
926+ ++i;
927+ }
842928 }
843929
844930 wrq.u.essid.pointer = (caddr_t) essid;
@@ -942,6 +1028,12 @@ set_info(int skfd, /* The socket */
9421028 wrq.u.bitrate.fixed = 0;
9431029 ++i;
9441030 }
1031+ if(((i+1) < count) &&
1032+ (!strcasecmp(args[i+1], "fixed")))
1033+ {
1034+ wrq.u.bitrate.fixed = 1;
1035+ ++i;
1036+ }
9451037 }
9461038 }
9471039
@@ -1076,7 +1168,7 @@ set_info(int skfd, /* The socket */
10761168 /* Get old Power info */
10771169 if(ioctl(skfd, SIOCGIWPOWER, &wrq) < 0)
10781170 {
1079- fprintf(stderr, "SIOCGIWFRAG: %s\n", strerror(errno));
1171+ fprintf(stderr, "SIOCGIWPOWER: %s\n", strerror(errno));
10801172 return(-1);
10811173 }
10821174 strcpy(wrq.ifr_name, ifname);
@@ -1091,16 +1183,31 @@ set_info(int skfd, /* The socket */
10911183 wrq.u.power.disabled = 0;
10921184
10931185 /* Check value modifier */
1186+ if(!strcasecmp(args[i], "min"))
1187+ {
1188+ wrq.u.power.flags |= IW_POWER_MIN;
1189+ if(++i >= count)
1190+ iw_usage();
1191+ }
1192+ else
1193+ if(!strcasecmp(args[i], "max"))
1194+ {
1195+ wrq.u.power.flags |= IW_POWER_MAX;
1196+ if(++i >= count)
1197+ iw_usage();
1198+ }
1199+
1200+ /* Check value type */
10941201 if(!strcasecmp(args[i], "period"))
10951202 {
1096- wrq.u.power.flags = IW_POWER_PERIOD;
1203+ wrq.u.power.flags |= IW_POWER_PERIOD;
10971204 if(++i >= count)
10981205 iw_usage();
10991206 }
11001207 else
11011208 if(!strcasecmp(args[i], "timeout"))
11021209 {
1103- wrq.u.power.flags = IW_POWER_TIMEOUT;
1210+ wrq.u.power.flags |= IW_POWER_TIMEOUT;
11041211 if(++i >= count)
11051212 iw_usage();
11061213 }
@@ -1112,8 +1219,8 @@ set_info(int skfd, /* The socket */
11121219 if(index(args[i], 'u')) temp /= MEGA;
11131220 if(index(args[i], 'm')) temp /= KILO;
11141221 wrq.u.power.value = (long) temp;
1115- if(wrq.u.power.flags == IW_POWER_ON)
1116- wrq.u.power.flags = IW_POWER_PERIOD;
1222+ if((wrq.u.power.flags & IW_POWER_TYPE) == 0)
1223+ wrq.u.power.flags |= IW_POWER_PERIOD;
11171224 ++i;
11181225 gotone = 1;
11191226 }
@@ -1151,6 +1258,166 @@ set_info(int skfd, /* The socket */
11511258 continue;
11521259 }
11531260
1261+#if WIRELESS_EXT > 9
1262+ /* ---------- Set Transmit-Power ---------- */
1263+ if(!strncmp(args[i], "txpower", 3))
1264+ {
1265+ struct iw_range range;
1266+
1267+ if(++i >= count)
1268+ iw_usage();
1269+
1270+ /* Extract range info */
1271+ if(get_range_info(skfd, ifname, &range) < 0)
1272+ memset(&range, 0, sizeof(range));
1273+
1274+ /* Prepare the request */
1275+ strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
1276+ wrq.u.txpower.value = -1;
1277+ wrq.u.txpower.fixed = 1;
1278+ wrq.u.txpower.disabled = 0;
1279+ wrq.u.data.flags = IW_TXPOW_DBM;
1280+ if(!strcasecmp(args[i], "off"))
1281+ wrq.u.txpower.disabled = 1; /* i.e. turn radio off */
1282+ else
1283+ if(!strcasecmp(args[i], "auto"))
1284+ wrq.u.txpower.fixed = 0; /* i.e. use power control */
1285+ else
1286+ {
1287+ if(!strcasecmp(args[i], "fixed"))
1288+ {
1289+ /* Get old tx-power */
1290+ if(ioctl(skfd, SIOCGIWTXPOW, &wrq) < 0)
1291+ {
1292+ fprintf(stderr, "SIOCGIWTXPOW: %s\n", strerror(errno));
1293+ return(-1);
1294+ }
1295+ strcpy(wrq.ifr_name, ifname);
1296+ wrq.u.txpower.fixed = 1;
1297+ }
1298+ else /* Should be a numeric value */
1299+ {
1300+ int power;
1301+ int ismwatt = 0;
1302+
1303+ /* Get the value */
1304+ if(sscanf(args[i], "%ld",
1305+ (unsigned long *) &(power)) != 1)
1306+ iw_usage();
1307+
1308+ /* Check if milliwatt */
1309+ ismwatt = (index(args[i], 'm') != NULL);
1310+
1311+ /* Convert */
1312+ if(!ismwatt && (range.txpower_capa & IW_TXPOW_MWATT))
1313+ {
1314+ power = dbm2mwatt(power);
1315+ wrq.u.data.flags = IW_TXPOW_MWATT;
1316+ }
1317+ if(ismwatt && !(range.txpower_capa & IW_TXPOW_MWATT))
1318+ power = mwatt2dbm(power);
1319+ wrq.u.bitrate.value = power;
1320+
1321+ /* Check for an additional argument */
1322+ if(((i+1) < count) &&
1323+ (!strcasecmp(args[i+1], "auto")))
1324+ {
1325+ wrq.u.txpower.fixed = 0;
1326+ ++i;
1327+ }
1328+ if(((i+1) < count) &&
1329+ (!strcasecmp(args[i+1], "fixed")))
1330+ {
1331+ wrq.u.txpower.fixed = 1;
1332+ ++i;
1333+ }
1334+ }
1335+ }
1336+
1337+ if(ioctl(skfd, SIOCSIWTXPOW, &wrq) < 0)
1338+ {
1339+ fprintf(stderr, "SIOCSIWTXPOW: %s\n", strerror(errno));
1340+ return(-1);
1341+ }
1342+ continue;
1343+ }
1344+#endif
1345+
1346+#if WIRELESS_EXT > 10
1347+ /* ---------- Set Power Management ---------- */
1348+ if(!strncmp(args[i], "retry", 3))
1349+ {
1350+ double temp;
1351+ int gotone = 0;
1352+
1353+ if(++i >= count)
1354+ iw_usage();
1355+
1356+ /* Default - nope */
1357+ wrq.u.retry.flags = IW_RETRY_LIMIT;
1358+ wrq.u.retry.disabled = 0;
1359+
1360+ /* Check value modifier */
1361+ if(!strcasecmp(args[i], "min"))
1362+ {
1363+ wrq.u.retry.flags |= IW_RETRY_MIN;
1364+ if(++i >= count)
1365+ iw_usage();
1366+ }
1367+ else
1368+ if(!strcasecmp(args[i], "max"))
1369+ {
1370+ wrq.u.retry.flags |= IW_RETRY_MAX;
1371+ if(++i >= count)
1372+ iw_usage();
1373+ }
1374+
1375+ /* Check value type */
1376+ if(!strcasecmp(args[i], "limit"))
1377+ {
1378+ wrq.u.retry.flags |= IW_RETRY_LIMIT;
1379+ if(++i >= count)
1380+ iw_usage();
1381+ }
1382+ else
1383+ if(!strncasecmp(args[i], "lifetime", 4))
1384+ {
1385+ wrq.u.retry.flags |= IW_RETRY_LIFETIME;
1386+ if(++i >= count)
1387+ iw_usage();
1388+ }
1389+
1390+ /* Is there any value to grab ? */
1391+ if(sscanf(args[i], "%lg", &(temp)) == 1)
1392+ {
1393+ /* Limit is absolute, on the other hand lifetime is seconds */
1394+ if(!(wrq.u.retry.flags & IW_RETRY_LIMIT))
1395+ {
1396+ /* Normalise lifetime */
1397+ temp *= MEGA; /* default = s */
1398+ if(index(args[i], 'u')) temp /= MEGA;
1399+ if(index(args[i], 'm')) temp /= KILO;
1400+ }
1401+ wrq.u.retry.value = (long) temp;
1402+ ++i;
1403+ gotone = 1;
1404+ }
1405+
1406+ if(!gotone)
1407+ iw_usage();
1408+ --i;
1409+
1410+ if(ioctl(skfd, SIOCSIWRETRY, &wrq) < 0)
1411+ {
1412+ fprintf(stderr, "SIOCSIWRETRY(%d): %s\n",
1413+ errno, strerror(errno));
1414+ return(-1);
1415+ }
1416+ continue;
1417+ }
1418+
1419+#endif /* WIRELESS_EXT > 10 */
1420+
11541421 /* ---------- Other ---------- */
11551422 /* Here we have an unrecognised arg... */
11561423 fprintf(stderr, "Invalid argument : %s\n", args[i]);
@@ -1213,5 +1480,3 @@ main(int argc,
12131480
12141481 return(goterr);
12151482 }
1216-
1217-
--- /dev/null
+++ b/wireless_tools/iwgetid.c
@@ -0,0 +1,384 @@
1+/*
2+ * Wireless Tools
3+ *
4+ * Jean II - HPL '01
5+ *
6+ * Just print the ESSID or NWID...
7+ *
8+ * This file is released under the GPL license.
9+ */
10+
11+#include "iwcommon.h" /* Header */
12+
13+#define FORMAT_DEFAULT 0 /* Nice looking display for the user */
14+#define FORMAT_SCHEME 1 /* To be used as a Pcmcia Scheme */
15+
16+/*
17+ * Note on Pcmcia Schemes :
18+ * ----------------------
19+ * The purpose of this tool is to use the ESSID discovery mechanism
20+ * to select the appropriate Pcmcia Scheme. The card tell us which
21+ * ESSID it has found, and we can then select the appropriate Pcmcia
22+ * Scheme for this ESSID (Wireless config (encrypt keys) and IP config).
23+ * The way to do it is as follows :
24+ * cardctl scheme "essidany"
25+ * delay 100
26+ * $scheme = iwgetid --scheme
27+ * cardctl scheme $scheme
28+ * Of course, you need to add a scheme called "essidany" with the
29+ * following setting :
30+ * essidany,*,*,*)
31+ * ESSID="any"
32+ * IPADDR="10.0.0.1"
33+ *
34+ * This can also be integrated int he Pcmcia scripts.
35+ * Some drivers don't activate the card up to "ifconfig up".
36+ * Therefore, they wont scan ESSID up to this point, so we can't
37+ * read it reliably in Pcmcia scripts.
38+ * I guess the proper way to write the network script is as follows :
39+ * if($scheme == "iwgetid") {
40+ * iwconfig $name essid any
41+ * iwconfig $name nwid any
42+ * ifconfig $name up
43+ * delay 100
44+ * $scheme = iwgetid $name --scheme
45+ * ifconfig $name down
46+ * }
47+ *
48+ * This is pseudo code, but you get an idea...
49+ * The "ifconfig up" activate the card.
50+ * The "delay" is necessary to let time for the card scan the
51+ * frequencies and associate with the AP.
52+ * The "ifconfig down" is necessary to allow the driver to optimise
53+ * the wireless parameters setting (minimise number of card resets).
54+ *
55+ * Another cute idea is to have a list of Pcmcia Schemes to try
56+ * and to keep the first one that associate (AP address != 0). This
57+ * would be necessary for closed networks and cards that can't
58+ * discover essid...
59+ *
60+ * Jean II - 29/3/01
61+ */
62+
63+/************************ DISPLAY ESSID/NWID ************************/
64+
65+/*------------------------------------------------------------------*/
66+/*
67+ * Display the ESSID if possible
68+ */
69+static int
70+print_essid(int skfd,
71+ char * ifname,
72+ int format)
73+{
74+ struct iwreq wrq;
75+ char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID */
76+ char pessid[IW_ESSID_MAX_SIZE + 1]; /* Pcmcia format */
77+ int i;
78+ int j;
79+
80+ /* Get ESSID */
81+ strcpy(wrq.ifr_name, ifname);
82+ wrq.u.essid.pointer = (caddr_t) essid;
83+ wrq.u.essid.length = 0;
84+ wrq.u.essid.flags = 0;
85+ if(ioctl(skfd, SIOCGIWESSID, &wrq) < 0)
86+ return(-1);
87+
88+ switch(format)
89+ {
90+ case FORMAT_SCHEME:
91+ /* Stip all white space and stuff */
92+ j = 0;
93+ for(i = 0; i < strlen(essid); i++)
94+ if(isalnum(essid[i]))
95+ pessid[j++] = essid[i];
96+ pessid[j] = '\0';
97+ if((j == 0) || (j > 32))
98+ return(-2);
99+ printf("%s\n", pessid);
100+ fflush(stdout);
101+ break;
102+ default:
103+ printf("%-8.8s ESSID:\"%s\"\n", ifname, essid);
104+ break;
105+ }
106+
107+ return(0);
108+}
109+
110+/*------------------------------------------------------------------*/
111+/*
112+ * Display the NWID if possible
113+ */
114+static int
115+print_nwid(int skfd,
116+ char * ifname,
117+ int format)
118+{
119+ struct iwreq wrq;
120+
121+ /* Get network ID */
122+ strcpy(wrq.ifr_name, ifname);
123+ if(ioctl(skfd, SIOCGIWNWID, &wrq) < 0)
124+ return(-1);
125+
126+ switch(format)
127+ {
128+ case FORMAT_SCHEME:
129+ /* Prefix with nwid to avoid name space collisions */
130+ printf("nwid%X\n", wrq.u.nwid.value);
131+ fflush(stdout);
132+ break;
133+ default:
134+ printf("%-8.8s NWID:%X\n", ifname, wrq.u.nwid.value);
135+ break;
136+ }
137+
138+ return(0);
139+}
140+
141+/*------------------------------------------------------------------*/
142+/*
143+ * Try the various devices until one return something we can use
144+ */
145+static int
146+scan_devices(int skfd,
147+ int format)
148+{
149+ char buff[1024];
150+ struct ifconf ifc;
151+ struct ifreq *ifr;
152+ int i;
153+ int ret;
154+
155+ /* Get list of active devices */
156+ ifc.ifc_len = sizeof(buff);
157+ ifc.ifc_buf = buff;
158+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
159+ {
160+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
161+ return(-1);
162+ }
163+ ifr = ifc.ifc_req;
164+
165+ /* Print the first match */
166+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
167+ {
168+ /* Try to print an ESSID */
169+ ret = print_essid(skfd, ifr->ifr_name, format);
170+ if(ret == 0)
171+ return(0); /* Success */
172+
173+ /* Try to print a nwid */
174+ ret = print_nwid(skfd, ifr->ifr_name, format);
175+ if(ret == 0)
176+ return(0); /* Success */
177+ }
178+ return(-1);
179+}
180+
181+/*************************** SUBROUTINES ***************************/
182+
183+/*------------------------------------------------------------------*/
184+/*
185+ * Display an Ethernet address in readable format.
186+ */
187+char *
188+pr_ether(unsigned char *ptr)
189+{
190+ static char buff[64];
191+
192+ sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X",
193+ (ptr[0] & 0xFF), (ptr[1] & 0xFF), (ptr[2] & 0xFF),
194+ (ptr[3] & 0xFF), (ptr[4] & 0xFF), (ptr[5] & 0xFF)
195+ );
196+ return(buff);
197+}
198+
199+/*------------------------------------------------------------------*/
200+/*
201+ * Open a socket.
202+ * Depending on the protocol present, open the right socket. The socket
203+ * will allow us to talk to the driver.
204+ */
205+int
206+sockets_open(void)
207+{
208+ int ipx_sock = -1; /* IPX socket */
209+ int ax25_sock = -1; /* AX.25 socket */
210+ int inet_sock = -1; /* INET socket */
211+ int ddp_sock = -1; /* Appletalk DDP socket */
212+
213+ inet_sock=socket(AF_INET, SOCK_DGRAM, 0);
214+ ipx_sock=socket(AF_IPX, SOCK_DGRAM, 0);
215+ ax25_sock=socket(AF_AX25, SOCK_DGRAM, 0);
216+ ddp_sock=socket(AF_APPLETALK, SOCK_DGRAM, 0);
217+ /*
218+ * Now pick any (exisiting) useful socket family for generic queries
219+ */
220+ if(inet_sock!=-1)
221+ return inet_sock;
222+ if(ipx_sock!=-1)
223+ return ipx_sock;
224+ if(ax25_sock!=-1)
225+ return ax25_sock;
226+ /*
227+ * If this is -1 we have no known network layers and its time to jump.
228+ */
229+
230+ return ddp_sock;
231+}
232+
233+/**************************** AP ADDRESS ****************************/
234+
235+/*------------------------------------------------------------------*/
236+/*
237+ * Display the NWID if possible
238+ */
239+static int
240+print_ap(int skfd,
241+ char * ifname,
242+ int format)
243+{
244+ struct iwreq wrq;
245+
246+ /* Get network ID */
247+ strcpy(wrq.ifr_name, ifname);
248+ if(ioctl(skfd, SIOCGIWAP, &wrq) < 0)
249+ return(-1);
250+
251+ /* Print */
252+ printf("%-8.8s Access Point: %s\n", ifname,
253+ pr_ether(wrq.u.ap_addr.sa_data));
254+
255+ return(0);
256+}
257+
258+/*------------------------------------------------------------------*/
259+/*
260+ * Try the various devices until one return something we can use
261+ */
262+static inline int
263+scan_ap(int skfd,
264+ int format)
265+{
266+ char buff[1024];
267+ struct ifconf ifc;
268+ struct ifreq *ifr;
269+ int i;
270+ int ret;
271+
272+ /* Get list of active devices */
273+ ifc.ifc_len = sizeof(buff);
274+ ifc.ifc_buf = buff;
275+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
276+ {
277+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
278+ return(-1);
279+ }
280+ ifr = ifc.ifc_req;
281+
282+ /* Print the first match */
283+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
284+ {
285+ /* Try to print an ESSID */
286+ ret = print_ap(skfd, ifr->ifr_name, format);
287+ if(ret == 0)
288+ return(0); /* Success */
289+ }
290+ return(-1);
291+}
292+
293+/******************************* MAIN ********************************/
294+
295+/*------------------------------------------------------------------*/
296+/*
297+ * The main !
298+ */
299+int
300+main(int argc,
301+ char ** argv)
302+{
303+ int skfd = -1; /* generic raw socket desc. */
304+ int format = FORMAT_DEFAULT;
305+ int ret = -1;
306+
307+ /* Create a channel to the NET kernel. */
308+ if((skfd = sockets_open()) < 0)
309+ {
310+ perror("socket");
311+ return(-1);
312+ }
313+
314+ /* No argument */
315+ if(argc == 1)
316+ {
317+ /* Look on all devices */
318+ ret = scan_devices(skfd, format);
319+ close(skfd);
320+ return(ret);
321+ }
322+
323+ /* Only ask for first AP address */
324+ if((!strcmp(argv[1], "--ap")) || (!strcmp(argv[1], "-a")))
325+ {
326+ /* Look on all devices */
327+ ret = scan_ap(skfd, format);
328+ close(skfd);
329+ return(ret);
330+ }
331+
332+ /* Only the format, no interface name */
333+ if((!strncmp(argv[1], "--scheme", 4)) || (!strcmp(argv[1], "-s")))
334+ {
335+ /* Look on all devices */
336+ format = FORMAT_SCHEME;
337+ ret = scan_devices(skfd, format);
338+ close(skfd);
339+ return(ret);
340+ }
341+
342+ /* Help */
343+ if((argc > 3) ||
344+ (!strncmp(argv[1], "-h", 9)) || (!strcmp(argv[1], "--help")))
345+ {
346+ fprintf(stderr, "Usage: iwgetid [interface]\n");
347+ fprintf(stderr, " [interface] --scheme\n");
348+ return(-1);
349+ }
350+
351+ /* If at least a device name */
352+ if(argc > 1)
353+ {
354+ /* Check extra format argument */
355+ if(argc > 2)
356+ {
357+ /* Only ask for first AP address */
358+ if((!strcmp(argv[2], "--ap")) || (!strcmp(argv[2], "-a")))
359+ {
360+ ret = print_ap(skfd, argv[1], format);
361+ close(skfd);
362+ return(ret);
363+ }
364+
365+ /* Want scheme format */
366+ if((!strncmp(argv[2], "--scheme", 4)) || (!strcmp(argv[2], "-s")))
367+ format = FORMAT_SCHEME;
368+ }
369+
370+ /* Try to print an ESSID */
371+ ret = print_essid(skfd, argv[1], format);
372+
373+ if(ret == -1)
374+ {
375+ /* Try to print a nwid */
376+ ret = print_nwid(skfd, argv[1], format);
377+ }
378+ }
379+
380+ /* Close the socket. */
381+ close(skfd);
382+
383+ return(ret);
384+}
--- /dev/null
+++ b/wireless_tools/iwlist.8
@@ -0,0 +1,79 @@
1+.\" Jean II - HPLB - 96
2+.\" iwlist.8
3+.\"
4+.TH IWLIST 8 "31 October 1996" "net-tools" "Linux Programmer's Manual"
5+.\"
6+.\" NAME part
7+.\"
8+.SH NAME
9+iwlist \- Get wireless statistics from specific nodes
10+.\"
11+.\" SYNOPSIS part
12+.\"
13+.SH SYNOPSIS
14+.BI "iwlist " interface " freq"
15+.br
16+.BI "iwlist " interface " ap"
17+.br
18+.BI "iwlist " interface " rate"
19+.br
20+.BI "iwlist " interface " keys"
21+.br
22+.BI "iwlist " interface " power"
23+.br
24+.BI "iwlist " interface " txpower"
25+.br
26+.BI "iwlist " interface " retry"
27+.\"
28+.\" DESCRIPTION part
29+.\"
30+.SH DESCRIPTION
31+.B Iwlist
32+is used to display some large chunk of information from a wireless
33+network interface that is not displayed by iwconfig. This is typically
34+list of parameters.
35+.\"
36+.\" PARAMETER part
37+.\"
38+.SH PARAMETERS
39+.TP
40+.B freq
41+Give the list of available frequencies in the device and the number of
42+defined channels. Please note that usually the driver returns the
43+total number of channels and only the frequencies available in the
44+present locale, so there is no one to one mapping between frequencies
45+displayed and channel numbers.
46+.TP
47+.B ap
48+Give the list of Access Points in range, and optionally the quality of
49+link to them.
50+.TP
51+.BR rate / bit [rate]
52+List the bit-rates supported by the device.
53+.TP
54+.BR keys / enc [ryption]
55+List the encryption key sizes supported and display all the encryption
56+keys availables in the device.
57+.TP
58+.B power
59+List the various Power Management attributes and modes of the device.
60+.TP
61+.B txpower
62+List the various Transmit Power available on the device.
63+.TP
64+.B retry
65+List the transmit retry limits and retry lifetime on the device.
66+.\"
67+.\" FILES part
68+.\"
69+.SH FILES
70+.I /proc/net/wireless
71+.\"
72+.\" SEE ALSO part
73+.\"
74+.SH SEE ALSO
75+.BR iwconfig (8),
76+.BR ifconfig (8),
77+.BR iwspy (8).
78+.BR iwpriv (8).
79+
--- /dev/null
+++ b/wireless_tools/iwlist.c
@@ -0,0 +1,951 @@
1+/*
2+ * Wireless Tools
3+ *
4+ * Jean II - HPLB '99 - HPL 99->01
5+ *
6+ * This tool can access various piece of information on the card
7+ * not part of iwconfig...
8+ * You need to link this code against "iwcommon.c" and "-lm".
9+ *
10+ * This file is released under the GPL license.
11+ */
12+
13+#include "iwcommon.h" /* Header */
14+
15+/*********************** FREQUENCIES/CHANNELS ***********************/
16+
17+/*------------------------------------------------------------------*/
18+/*
19+ * Print the number of channels and available frequency for the device
20+ */
21+static void
22+print_freq_info(int skfd,
23+ char * ifname)
24+{
25+ float freq;
26+ struct iw_range range;
27+ int k;
28+
29+ if(get_range_info(skfd, ifname, &range) < 0)
30+ fprintf(stderr, "%-8.8s no frequency information.\n\n",
31+ ifname);
32+ else
33+ {
34+ if(range.num_frequency > 0)
35+ {
36+ printf("%-8.8s %d channels in total; available frequencies :\n",
37+ ifname, range.num_channels);
38+ /* Print them all */
39+ for(k = 0; k < range.num_frequency; k++)
40+ {
41+ printf("\t Channel %.2d : ", range.freq[k].i);
42+ freq = freq2float(&(range.freq[k]));
43+ if(freq >= GIGA)
44+ printf("%g GHz\n", freq / GIGA);
45+ else
46+ if(freq >= MEGA)
47+ printf("%g MHz\n", freq / MEGA);
48+ else
49+ printf("%g kHz\n", freq / KILO);
50+ }
51+ printf("\n\n");
52+ }
53+ else
54+ printf("%-8.8s %d channels\n\n",
55+ ifname, range.num_channels);
56+ }
57+}
58+
59+/*------------------------------------------------------------------*/
60+/*
61+ * Get frequency info on all devices and print it on the screen
62+ */
63+static void
64+print_freq_devices(int skfd)
65+{
66+ char buff[1024];
67+ struct ifconf ifc;
68+ struct ifreq *ifr;
69+ int i;
70+
71+ /* Get list of active devices */
72+ ifc.ifc_len = sizeof(buff);
73+ ifc.ifc_buf = buff;
74+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
75+ {
76+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
77+ return;
78+ }
79+ ifr = ifc.ifc_req;
80+
81+ /* Print them */
82+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
83+ print_freq_info(skfd, ifr->ifr_name);
84+}
85+
86+/************************ ACCESS POINT LIST ************************/
87+
88+/*------------------------------------------------------------------*/
89+/*
90+ * Display the list of ap addresses and the associated stats
91+ * Exacly the same as the spy list, only with different IOCTL and messages
92+ */
93+static void
94+print_ap_info(int skfd,
95+ char * ifname)
96+{
97+ struct iwreq wrq;
98+ char buffer[(sizeof(struct iw_quality) +
99+ sizeof(struct sockaddr)) * IW_MAX_AP];
100+ struct sockaddr * hwa;
101+ struct iw_quality * qual;
102+ iwrange range;
103+ int has_range = 0;
104+ int has_qual = 0;
105+ int n;
106+ int i;
107+
108+ /* Collect stats */
109+ strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
110+ wrq.u.data.pointer = (caddr_t) buffer;
111+ wrq.u.data.length = 0;
112+ wrq.u.data.flags = 0;
113+ if(ioctl(skfd, SIOCGIWAPLIST, &wrq) < 0)
114+ {
115+ fprintf(stderr, "%-8.8s Interface doesn't have a list of Access Points\n\n", ifname);
116+ return;
117+ }
118+
119+ /* Number of addresses */
120+ n = wrq.u.data.length;
121+ has_qual = wrq.u.data.flags;
122+
123+ /* The two lists */
124+ hwa = (struct sockaddr *) buffer;
125+ qual = (struct iw_quality *) (buffer + (sizeof(struct sockaddr) * n));
126+
127+ /* Check if we have valid address types */
128+ if(check_addr_type(skfd, ifname) < 0)
129+ {
130+ fprintf(stderr, "%-8.8s Interface doesn't support MAC & IP addresses\n\n", ifname);
131+ return;
132+ }
133+
134+ /* Get range info if we can */
135+ if(get_range_info(skfd, ifname, &(range)) >= 0)
136+ has_range = 1;
137+
138+ /* Display it */
139+ if(n == 0)
140+ printf("%-8.8s No Access Point in range\n", ifname);
141+ else
142+ printf("%-8.8s Access Points in range:\n", ifname);
143+ for(i = 0; i < n; i++)
144+ {
145+ if(has_qual)
146+ {
147+ /* Print stats for this address */
148+ printf(" %s : ", pr_ether(hwa[i].sa_data));
149+ print_stats(stdout, &qual[i], &range, has_range);
150+ }
151+ else
152+ /* Only print the address */
153+ printf(" %s\n", pr_ether(hwa[i].sa_data));
154+ }
155+ printf("\n");
156+}
157+
158+/*------------------------------------------------------------------*/
159+/*
160+ * Get list of AP on all devices and print it on the screen
161+ */
162+static void
163+print_ap_devices(int skfd)
164+{
165+ char buff[1024];
166+ struct ifconf ifc;
167+ struct ifreq *ifr;
168+ int i;
169+
170+ /* Get list of active devices */
171+ ifc.ifc_len = sizeof(buff);
172+ ifc.ifc_buf = buff;
173+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
174+ {
175+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
176+ return;
177+ }
178+ ifr = ifc.ifc_req;
179+
180+ /* Print them */
181+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
182+ print_ap_info(skfd, ifr->ifr_name);
183+}
184+
185+/***************************** BITRATES *****************************/
186+
187+/*------------------------------------------------------------------*/
188+/*
189+ * Print the number of available bitrates for the device
190+ */
191+static void
192+print_bitrate_info(int skfd,
193+ char * ifname)
194+{
195+ float bitrate;
196+ struct iw_range range;
197+ int k;
198+
199+ /* Extract range info */
200+ if(get_range_info(skfd, ifname, &range) < 0)
201+ fprintf(stderr, "%-8.8s no bit-rate information.\n\n",
202+ ifname);
203+ else
204+ {
205+ if((range.num_bitrates > 0) && (range.num_bitrates < IW_MAX_BITRATES))
206+ {
207+ printf("%-8.8s %d available bit-rates :\n",
208+ ifname, range.num_bitrates);
209+ /* Print them all */
210+ for(k = 0; k < range.num_bitrates; k++)
211+ {
212+ printf("\t ");
213+ bitrate = range.bitrate[k];
214+ if(bitrate >= GIGA)
215+ printf("%g Gb/s\n", bitrate / GIGA);
216+ else
217+ if(bitrate >= MEGA)
218+ printf("%g Mb/s\n", bitrate / MEGA);
219+ else
220+ printf("%g kb/s\n", bitrate / KILO);
221+ }
222+ printf("\n\n");
223+ }
224+ else
225+ printf("%-8.8s No bit-rates ? Please update driver...\n\n", ifname);
226+ }
227+}
228+
229+/*------------------------------------------------------------------*/
230+/*
231+ * Get bit-rate info on all devices and print it on the screen
232+ */
233+static void
234+print_bitrate_devices(int skfd)
235+{
236+ char buff[1024];
237+ struct ifconf ifc;
238+ struct ifreq *ifr;
239+ int i;
240+
241+ /* Get list of active devices */
242+ ifc.ifc_len = sizeof(buff);
243+ ifc.ifc_buf = buff;
244+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
245+ {
246+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
247+ return;
248+ }
249+ ifr = ifc.ifc_req;
250+
251+ /* Print them */
252+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
253+ print_bitrate_info(skfd, ifr->ifr_name);
254+}
255+
256+/************************* ENCRYPTION KEYS *************************/
257+
258+/*------------------------------------------------------------------*/
259+/*
260+ * Print the number of available encryption key for the device
261+ */
262+static void
263+print_keys_info(int skfd,
264+ char * ifname)
265+{
266+ struct iwreq wrq;
267+ struct iw_range range;
268+ unsigned char key[IW_ENCODING_TOKEN_MAX];
269+ int k;
270+
271+ /* Extract range info */
272+ if(get_range_info(skfd, ifname, &range) < 0)
273+ fprintf(stderr, "%-8.8s no encryption keys information.\n\n",
274+ ifname);
275+ else
276+ {
277+ printf("%-8.8s ", ifname);
278+ /* Print key sizes */
279+ if((range.num_encoding_sizes > 0) &&
280+ (range.num_encoding_sizes < IW_MAX_ENCODING_SIZES))
281+ {
282+ printf("%d key sizes : %d", range.num_encoding_sizes,
283+ range.encoding_size[0] * 8);
284+ /* Print them all */
285+ for(k = 1; k < range.num_encoding_sizes; k++)
286+ printf(", %d", range.encoding_size[k] * 8);
287+ printf("bits\n ");
288+ }
289+ /* Print the keys and associate mode */
290+ printf("%d keys available :\n", range.max_encoding_tokens);
291+ for(k = 1; k <= range.max_encoding_tokens; k++)
292+ {
293+ strcpy(wrq.ifr_name, ifname);
294+ wrq.u.data.pointer = (caddr_t) key;
295+ wrq.u.data.length = 0;
296+ wrq.u.data.flags = k;
297+ if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0)
298+ {
299+ fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno));
300+ break;
301+ }
302+ if((wrq.u.data.flags & IW_ENCODE_DISABLED) ||
303+ (wrq.u.data.length == 0))
304+ printf("\t\t[%d]: off\n", k);
305+ else
306+ {
307+ /* Display the key */
308+ printf("\t\t[%d]: ", k);
309+ print_key(stdout, key, wrq.u.data.length, wrq.u.data.flags);
310+
311+ /* Other info... */
312+ printf(" (%d bits)", wrq.u.data.length * 8);
313+ printf("\n");
314+ }
315+ }
316+ /* Print current key and mode */
317+ strcpy(wrq.ifr_name, ifname);
318+ wrq.u.data.pointer = (caddr_t) key;
319+ wrq.u.data.length = 0;
320+ wrq.u.data.flags = 0; /* Set index to zero to get current */
321+ if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0)
322+ {
323+ fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno));
324+ return;
325+ }
326+ printf(" Current Transmit Key: [%d]\n",
327+ wrq.u.data.flags & IW_ENCODE_INDEX);
328+ if(wrq.u.data.flags & IW_ENCODE_RESTRICTED)
329+ printf(" Encryption mode:restricted\n");
330+ if(wrq.u.data.flags & IW_ENCODE_OPEN)
331+ printf(" Encryption mode:open\n");
332+
333+ printf("\n\n");
334+ }
335+}
336+
337+/*------------------------------------------------------------------*/
338+/*
339+ * Get encryption info on all devices and print it on the screen
340+ */
341+static void
342+print_keys_devices(int skfd)
343+{
344+ char buff[1024];
345+ struct ifconf ifc;
346+ struct ifreq *ifr;
347+ int i;
348+
349+ /* Get list of active devices */
350+ ifc.ifc_len = sizeof(buff);
351+ ifc.ifc_buf = buff;
352+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
353+ {
354+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
355+ return;
356+ }
357+ ifr = ifc.ifc_req;
358+
359+ /* Print them */
360+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
361+ print_keys_info(skfd, ifr->ifr_name);
362+}
363+
364+/************************* POWER MANAGEMENT *************************/
365+
366+/*------------------------------------------------------------------*/
367+/*
368+ * Print Power Management info for each device
369+ */
370+static inline int
371+get_pm_value(int skfd,
372+ char * ifname,
373+ struct iwreq * pwrq,
374+ int flags)
375+{
376+ /* Get Another Power Management value */
377+ strcpy(pwrq->ifr_name, ifname);
378+ pwrq->u.power.flags = flags;
379+ if(ioctl(skfd, SIOCGIWPOWER, pwrq) >= 0)
380+ {
381+ /* Let's check the value and its type */
382+ if(pwrq->u.power.flags & IW_POWER_TYPE)
383+ {
384+ printf("\n ");
385+ print_pm_value(stdout, pwrq->u.power.value, pwrq->u.power.flags);
386+ }
387+ }
388+ return(pwrq->u.power.flags);
389+}
390+
391+/*------------------------------------------------------------------*/
392+/*
393+ * Print Power Management info for each device
394+ */
395+static void
396+print_pm_info(int skfd,
397+ char * ifname)
398+{
399+ struct iwreq wrq;
400+ struct iw_range range;
401+
402+ /* Extract range info */
403+ if(get_range_info(skfd, ifname, &range) < 0)
404+ fprintf(stderr, "%-8.8s no power management information.\n\n",
405+ ifname);
406+ else
407+ {
408+ printf("%-8.8s ", ifname);
409+#if WIRELESS_EXT > 9
410+ /* Display modes availables */
411+ if(range.pm_capa & IW_POWER_MODE)
412+ {
413+ printf("Supported modes :\n ");
414+ if(range.pm_capa & (IW_POWER_UNICAST_R | IW_POWER_MULTICAST_R))
415+ printf("\t\to Receive all packets (unicast & multicast)\n ");
416+ if(range.pm_capa & IW_POWER_UNICAST_R)
417+ printf("\t\to Receive Unicast only (discard multicast)\n ");
418+ if(range.pm_capa & IW_POWER_MULTICAST_R)
419+ printf("\t\to Receive Multicast only (discard unicast)\n ");
420+ if(range.pm_capa & IW_POWER_FORCE_S)
421+ printf("\t\to Force sending using Power Management\n ");
422+ if(range.pm_capa & IW_POWER_REPEATER)
423+ printf("\t\to Repeat multicast\n ");
424+ }
425+ /* Display min/max period availables */
426+ if(range.pmp_flags & IW_POWER_PERIOD)
427+ {
428+ int flags = (range.pmp_flags & ~(IW_POWER_MIN | IW_POWER_MAX));
429+ /* Display if auto or fixed */
430+ if(range.pmp_flags & IW_POWER_MIN)
431+ printf("Auto period ; ");
432+ else
433+ printf("Fixed period ; ");
434+ /* Print the range */
435+ print_pm_value(stdout, range.min_pmp, flags | IW_POWER_MIN);
436+ printf("\n ");
437+ print_pm_value(stdout, range.max_pmp, flags | IW_POWER_MAX);
438+ printf("\n ");
439+
440+ }
441+ /* Display min/max timeout availables */
442+ if(range.pmt_flags & IW_POWER_TIMEOUT)
443+ {
444+ int flags = (range.pmt_flags & ~(IW_POWER_MIN | IW_POWER_MAX));
445+ /* Display if auto or fixed */
446+ if(range.pmt_flags & IW_POWER_MIN)
447+ printf("Auto timeout ; ");
448+ else
449+ printf("Fixed timeout ; ");
450+ /* Print the range */
451+ print_pm_value(stdout, range.min_pmt, flags | IW_POWER_MIN);
452+ printf("\n ");
453+ print_pm_value(stdout, range.max_pmt, flags | IW_POWER_MAX);
454+ printf("\n ");
455+
456+ }
457+#endif /* WIRELESS_EXT > 9 */
458+
459+ /* Get current Power Management settings */
460+ strcpy(wrq.ifr_name, ifname);
461+ wrq.u.power.flags = 0;
462+ if(ioctl(skfd, SIOCGIWPOWER, &wrq) >= 0)
463+ {
464+ int flags = wrq.u.power.flags;
465+
466+ /* Is it disabled ? */
467+ if(wrq.u.power.disabled)
468+ printf("Current mode:off\n ");
469+ else
470+ {
471+ int pm_mask = 0;
472+
473+ /* Let's check the mode */
474+ printf("Current");
475+ print_pm_mode(stdout, flags);
476+
477+ /* Let's check if nothing (simply on) */
478+ if((flags & IW_POWER_MODE) == IW_POWER_ON)
479+ printf(" mode:on");
480+ printf("\n ");
481+
482+ /* Let's check the value and its type */
483+ if(wrq.u.power.flags & IW_POWER_TYPE)
484+ print_pm_value(stdout, wrq.u.power.value, wrq.u.power.flags);
485+
486+ /* If we have been returned a MIN value, ask for the MAX */
487+ if(flags & IW_POWER_MIN)
488+ pm_mask = IW_POWER_MAX;
489+ /* If we have been returned a MAX value, ask for the MIN */
490+ if(flags & IW_POWER_MAX)
491+ pm_mask = IW_POWER_MIN;
492+ /* If we have something to ask for... */
493+ if(pm_mask)
494+ get_pm_value(skfd, ifname, &wrq, pm_mask);
495+
496+#if WIRELESS_EXT > 9
497+ /* And if we have both a period and a timeout, ask the other */
498+ pm_mask = (range.pm_capa & (~(wrq.u.power.flags) &
499+ IW_POWER_TYPE));
500+ if(pm_mask)
501+ {
502+ int base_mask = pm_mask;
503+ flags = get_pm_value(skfd, ifname, &wrq, pm_mask);
504+ pm_mask = 0;
505+
506+ /* If we have been returned a MIN value, ask for the MAX */
507+ if(flags & IW_POWER_MIN)
508+ pm_mask = IW_POWER_MAX | base_mask;
509+ /* If we have been returned a MAX value, ask for the MIN */
510+ if(flags & IW_POWER_MAX)
511+ pm_mask = IW_POWER_MIN | base_mask;
512+ /* If we have something to ask for... */
513+ if(pm_mask)
514+ get_pm_value(skfd, ifname, &wrq, pm_mask);
515+ }
516+#endif /* WIRELESS_EXT > 9 */
517+ }
518+ }
519+ printf("\n");
520+ }
521+}
522+
523+/*------------------------------------------------------------------*/
524+/*
525+ * Get Power Management info on all devices and print it on the screen
526+ */
527+static void
528+print_pm_devices(int skfd)
529+{
530+ char buff[1024];
531+ struct ifconf ifc;
532+ struct ifreq *ifr;
533+ int i;
534+
535+ /* Get list of active devices */
536+ ifc.ifc_len = sizeof(buff);
537+ ifc.ifc_buf = buff;
538+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
539+ {
540+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
541+ return;
542+ }
543+ ifr = ifc.ifc_req;
544+
545+ /* Print them */
546+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
547+ print_pm_info(skfd, ifr->ifr_name);
548+}
549+
550+/************************** TRANSMIT POWER **************************/
551+
552+/*------------------------------------------------------------------*/
553+/*
554+ * Print the number of available transmit powers for the device
555+ */
556+static void
557+print_txpower_info(int skfd,
558+ char * ifname)
559+{
560+ struct iw_range range;
561+ int dbm;
562+ int mwatt;
563+ int k;
564+
565+#if WIRELESS_EXT > 9
566+ /* Extract range info */
567+ if(get_range_info(skfd, ifname, &range) < 0)
568+ fprintf(stderr, "%-8.8s no transmit-power information.\n\n",
569+ ifname);
570+ else
571+ {
572+ if((range.num_txpower > 0) && (range.num_txpower < IW_MAX_TXPOWER))
573+ {
574+ printf("%-8.8s %d available transmit-powers :\n",
575+ ifname, range.num_txpower);
576+ /* Print them all */
577+ for(k = 0; k < range.num_txpower; k++)
578+ {
579+ if(range.txpower_capa & IW_TXPOW_MWATT)
580+ {
581+ dbm = mwatt2dbm(range.txpower[k]);
582+ mwatt = range.txpower[k];
583+ }
584+ else
585+ {
586+ dbm = range.txpower[k];
587+ mwatt = dbm2mwatt(range.txpower[k]);
588+ }
589+ printf("\t %d dBm \t(%d mW)\n", dbm, mwatt);
590+ }
591+ printf("\n\n");
592+ }
593+ else
594+ printf("%-8.8s No transmit-powers ? Please update driver...\n\n", ifname);
595+ }
596+#endif /* WIRELESS_EXT > 9 */
597+}
598+
599+/*------------------------------------------------------------------*/
600+/*
601+ * Get tx-power info on all devices and print it on the screen
602+ */
603+static void
604+print_txpower_devices(int skfd)
605+{
606+ char buff[1024];
607+ struct ifconf ifc;
608+ struct ifreq *ifr;
609+ int i;
610+
611+ /* Get list of active devices */
612+ ifc.ifc_len = sizeof(buff);
613+ ifc.ifc_buf = buff;
614+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
615+ {
616+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
617+ return;
618+ }
619+ ifr = ifc.ifc_req;
620+
621+ /* Print them */
622+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
623+ print_txpower_info(skfd, ifr->ifr_name);
624+}
625+
626+/*********************** RETRY LIMIT/LIFETIME ***********************/
627+
628+#if WIRELESS_EXT > 10
629+/*------------------------------------------------------------------*/
630+/*
631+ * Print one retry value
632+ */
633+static inline int
634+get_retry_value(int skfd,
635+ char * ifname,
636+ struct iwreq * pwrq,
637+ int flags)
638+{
639+ /* Get Another retry value */
640+ strcpy(pwrq->ifr_name, ifname);
641+ pwrq->u.retry.flags = flags;
642+ if(ioctl(skfd, SIOCGIWRETRY, pwrq) >= 0)
643+ {
644+ /* Let's check the value and its type */
645+ if(pwrq->u.retry.flags & IW_RETRY_TYPE)
646+ {
647+ printf("\n ");
648+ print_retry_value(stdout, pwrq->u.retry.value, pwrq->u.retry.flags);
649+ }
650+ }
651+ return(pwrq->u.retry.flags);
652+}
653+
654+/*------------------------------------------------------------------*/
655+/*
656+ * Print Retry info for each device
657+ */
658+static void
659+print_retry_info(int skfd,
660+ char * ifname)
661+{
662+ struct iwreq wrq;
663+ struct iw_range range;
664+
665+ /* Extract range info */
666+ if(get_range_info(skfd, ifname, &range) < 0)
667+ fprintf(stderr, "%-8.8s no retry limit/lifetime information.\n\n",
668+ ifname);
669+ else
670+ {
671+ printf("%-8.8s ", ifname);
672+
673+ /* Display min/max limit availables */
674+ if(range.retry_flags & IW_RETRY_LIMIT)
675+ {
676+ int flags = (range.retry_flags & ~(IW_RETRY_MIN | IW_RETRY_MAX));
677+ /* Display if auto or fixed */
678+ if(range.retry_flags & IW_RETRY_MIN)
679+ printf("Auto limit ; ");
680+ else
681+ printf("Fixed limit ; ");
682+ /* Print the range */
683+ print_retry_value(stdout, range.min_retry, flags | IW_RETRY_MIN);
684+ printf("\n ");
685+ print_retry_value(stdout, range.max_retry, flags | IW_RETRY_MAX);
686+ printf("\n ");
687+
688+ }
689+ /* Display min/max lifetime availables */
690+ if(range.r_time_flags & IW_RETRY_LIFETIME)
691+ {
692+ int flags = (range.r_time_flags & ~(IW_RETRY_MIN | IW_RETRY_MAX));
693+ /* Display if auto or fixed */
694+ if(range.r_time_flags & IW_RETRY_MIN)
695+ printf("Auto lifetime ; ");
696+ else
697+ printf("Fixed lifetime ; ");
698+ /* Print the range */
699+ print_retry_value(stdout, range.min_r_time, flags | IW_RETRY_MIN);
700+ printf("\n ");
701+ print_retry_value(stdout, range.max_r_time, flags | IW_RETRY_MAX);
702+ printf("\n ");
703+
704+ }
705+
706+ /* Get current retry settings */
707+ strcpy(wrq.ifr_name, ifname);
708+ wrq.u.retry.flags = 0;
709+ if(ioctl(skfd, SIOCGIWRETRY, &wrq) >= 0)
710+ {
711+ int flags = wrq.u.retry.flags;
712+
713+ /* Is it disabled ? */
714+ if(wrq.u.retry.disabled)
715+ printf("Current mode:off\n ");
716+ else
717+ {
718+ int retry_mask = 0;
719+
720+ /* Let's check the mode */
721+ printf("Current mode:on\n ");
722+
723+ /* Let's check the value and its type */
724+ if(wrq.u.retry.flags & IW_RETRY_TYPE)
725+ print_retry_value(stdout, wrq.u.retry.value, wrq.u.retry.flags);
726+
727+ /* If we have been returned a MIN value, ask for the MAX */
728+ if(flags & IW_RETRY_MIN)
729+ retry_mask = IW_RETRY_MAX;
730+ /* If we have been returned a MAX value, ask for the MIN */
731+ if(flags & IW_RETRY_MAX)
732+ retry_mask = IW_RETRY_MIN;
733+ /* If we have something to ask for... */
734+ if(retry_mask)
735+ get_retry_value(skfd, ifname, &wrq, retry_mask);
736+
737+ /* And if we have both a period and a timeout, ask the other */
738+ retry_mask = (range.retry_capa & (~(wrq.u.retry.flags) &
739+ IW_RETRY_TYPE));
740+ if(retry_mask)
741+ {
742+ int base_mask = retry_mask;
743+ flags = get_retry_value(skfd, ifname, &wrq, retry_mask);
744+ retry_mask = 0;
745+
746+ /* If we have been returned a MIN value, ask for the MAX */
747+ if(flags & IW_RETRY_MIN)
748+ retry_mask = IW_RETRY_MAX | base_mask;
749+ /* If we have been returned a MAX value, ask for the MIN */
750+ if(flags & IW_RETRY_MAX)
751+ retry_mask = IW_RETRY_MIN | base_mask;
752+ /* If we have something to ask for... */
753+ if(retry_mask)
754+ get_retry_value(skfd, ifname, &wrq, retry_mask);
755+ }
756+ }
757+ }
758+ printf("\n");
759+ }
760+}
761+
762+/*------------------------------------------------------------------*/
763+/*
764+ * Get retry info on all devices and print it on the screen
765+ */
766+static void
767+print_retry_devices(int skfd)
768+{
769+ char buff[1024];
770+ struct ifconf ifc;
771+ struct ifreq *ifr;
772+ int i;
773+
774+ /* Get list of active devices */
775+ ifc.ifc_len = sizeof(buff);
776+ ifc.ifc_buf = buff;
777+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
778+ {
779+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
780+ return;
781+ }
782+ ifr = ifc.ifc_req;
783+
784+ /* Print them */
785+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
786+ print_retry_info(skfd, ifr->ifr_name);
787+}
788+#endif /* WIRELESS_EXT > 10 */
789+
790+/******************************* MAIN ********************************/
791+
792+/*------------------------------------------------------------------*/
793+/*
794+ * The main !
795+ */
796+int
797+main(int argc,
798+ char ** argv)
799+{
800+ int skfd = -1; /* generic raw socket desc. */
801+
802+ /* Create a channel to the NET kernel. */
803+ if((skfd = sockets_open()) < 0)
804+ {
805+ perror("socket");
806+ exit(-1);
807+ }
808+
809+ /* Help */
810+ if((argc == 1) || (argc > 3) ||
811+ (!strncmp(argv[1], "-h", 9)) || (!strcmp(argv[1], "--help")))
812+ {
813+ fprintf(stderr, "Usage: iwlist [interface] freq\n");
814+ fprintf(stderr, " [interface] ap\n");
815+ fprintf(stderr, " [interface] bitrate\n");
816+ fprintf(stderr, " [interface] keys\n");
817+ fprintf(stderr, " [interface] power\n");
818+ fprintf(stderr, " [interface] txpower\n");
819+ fprintf(stderr, " [interface] retries\n");
820+ close(skfd);
821+ exit(0);
822+ }
823+
824+ /* Frequency list */
825+ if((!strncmp(argv[1], "freq", 4)) ||
826+ (!strncmp(argv[1], "channel", 7)))
827+ {
828+ print_freq_devices(skfd);
829+ close(skfd);
830+ exit(0);
831+ }
832+
833+ /* Access Point list */
834+ if(!strcasecmp(argv[1], "ap"))
835+ {
836+ print_ap_devices(skfd);
837+ close(skfd);
838+ exit(0);
839+ }
840+
841+ /* Bit-rate list */
842+ if((!strncmp(argv[1], "bit", 3)) ||
843+ (!strcmp(argv[1], "rate")))
844+ {
845+ print_bitrate_devices(skfd);
846+ close(skfd);
847+ exit(0);
848+ }
849+
850+ /* Encryption key list */
851+ if((!strncmp(argv[1], "enc", 3)) ||
852+ (!strncmp(argv[1], "key", 3)))
853+ {
854+ print_keys_devices(skfd);
855+ close(skfd);
856+ exit(0);
857+ }
858+
859+ /* Power Management list */
860+ if(!strncmp(argv[1], "power", 3))
861+ {
862+ print_pm_devices(skfd);
863+ close(skfd);
864+ exit(0);
865+ }
866+
867+ /* Transmit Power list */
868+ if(!strncmp(argv[1], "txpower", 3))
869+ {
870+ print_txpower_devices(skfd);
871+ close(skfd);
872+ exit(0);
873+ }
874+
875+#if WIRELESS_EXT > 10
876+ /* Retry limit/lifetime */
877+ if(!strncmp(argv[1], "retry", 4))
878+ {
879+ print_retry_devices(skfd);
880+ close(skfd);
881+ exit(0);
882+ }
883+#endif
884+
885+ /* Special cases take two... */
886+ /* Frequency list */
887+ if((!strncmp(argv[2], "freq", 4)) ||
888+ (!strncmp(argv[2], "channel", 7)))
889+ {
890+ print_freq_info(skfd, argv[1]);
891+ close(skfd);
892+ exit(0);
893+ }
894+
895+ /* Access Point list */
896+ if(!strcasecmp(argv[2], "ap"))
897+ {
898+ print_ap_info(skfd, argv[1]);
899+ close(skfd);
900+ exit(0);
901+ }
902+
903+ /* Bit-rate list */
904+ if((!strncmp(argv[2], "bit", 3)) ||
905+ (!strcmp(argv[2], "rate")))
906+ {
907+ print_bitrate_info(skfd, argv[1]);
908+ close(skfd);
909+ exit(0);
910+ }
911+
912+ /* Encryption key list */
913+ if((!strncmp(argv[2], "enc", 3)) ||
914+ (!strncmp(argv[2], "key", 3)))
915+ {
916+ print_keys_info(skfd, argv[1]);
917+ close(skfd);
918+ exit(0);
919+ }
920+
921+ /* Power Management list */
922+ if(!strncmp(argv[2], "power", 3))
923+ {
924+ print_pm_info(skfd, argv[1]);
925+ close(skfd);
926+ exit(0);
927+ }
928+
929+ /* Transmit Power list */
930+ if(!strncmp(argv[2], "txpower", 3))
931+ {
932+ print_txpower_info(skfd, argv[1]);
933+ close(skfd);
934+ exit(0);
935+ }
936+
937+#if WIRELESS_EXT > 10
938+ /* Retry limit/lifetime */
939+ if(!strncmp(argv[2], "retry", 4))
940+ {
941+ print_retry_info(skfd, argv[1]);
942+ close(skfd);
943+ exit(0);
944+ }
945+#endif
946+
947+ /* Close the socket. */
948+ close(skfd);
949+
950+ return(1);
951+}
--- a/wireless_tools/iwpriv.8
+++ b/wireless_tools/iwpriv.8
@@ -95,7 +95,7 @@ histogram of up to 16 values with the following commands :
9595 .\" AUTHOR part
9696 .\"
9797 .SH AUTHOR
98-Jean Tourrilhes \- jt@hplb.hpl.hp.com
98+Jean Tourrilhes \- jt@hpl.hp.com
9999 .\"
100100 .\" FILES part
101101 .\"
@@ -107,7 +107,9 @@ Jean Tourrilhes \- jt@hplb.hpl.hp.com
107107 .SH SEE ALSO
108108 .BR ifconfig (8),
109109 .BR iwconfig (8),
110+.BR iwlist (8),
110111 .BR iwspy (8),
111112 .BR wavelan (4),
112113 .BR wavelan_cs (4),
113-.BR xircnw_cs (4).
114+.BR wvlan_cs (4),
115+.BR netwave_cs (4).
--- a/wireless_tools/iwpriv.c
+++ b/wireless_tools/iwpriv.c
@@ -1,11 +1,13 @@
11 /*
22 * Wireless Tools
33 *
4- * Jean II - HPLB '99
4+ * Jean II - HPLB 97->99 - HPL 99->00
55 *
66 * Main code for "iwconfig". This is the generic tool for most
77 * manipulations...
88 * You need to link this code against "iwcommon.c" and "-lm".
9+ *
10+ * This file is released under the GPL license.
911 */
1012
1113 #include "iwcommon.h" /* Header */
@@ -253,7 +255,7 @@ set_private(int skfd, /* Socket */
253255 case IW_PRIV_TYPE_INT:
254256 /* Display args */
255257 for(j = 0; j < n; j++)
256- printf("%d ", ((u_int *) buffer)[i]);
258+ printf("%d ", ((u_int *) buffer)[j]);
257259 printf("\n");
258260 break;
259261
--- a/wireless_tools/iwspy.8
+++ b/wireless_tools/iwspy.8
@@ -16,14 +16,6 @@ iwspy \- Get wireless statistics from specific nodes
1616 .BI "iwspy " interface " [+] " IPADDR " | " HWADDR " [...]"
1717 .br
1818 .BI "iwspy " interface " off"
19-.br
20-.BI "iwspy " interface " freq"
21-.br
22-.BI "iwspy " interface " ap"
23-.br
24-.BI "iwspy " interface " rate"
25-.br
26-.BI "iwspy " interface " keys"
2719 .\"
2820 .\" DESCRIPTION part
2921 .\"
@@ -38,9 +30,8 @@ information is the same as the one available in
3830 This information is updated each time a new packet is received, so
3931 each address of the list add some overhead in the driver.
4032 .PP
41-.B Iwspy
42-Can also display the list of frequencies available for the device or the
43-list of Access Points in range.
33+Note the this functionality work only for node part of the current
34+wireless cells.
4435 .\"
4536 .\" PARAMETER part
4637 .\"
@@ -72,24 +63,6 @@ should use this option to avoid conflicts.
7263 .TP
7364 .B off
7465 Remove the current list of addresses and disable the spy functionality
75-.TP
76-.B freq
77-Give the list of available frequencies in the device and the number of
78-defined channels. Please note that usually the driver returns the
79-total number of channels and only the frequencies available in the
80-present locale, so there is no one to one mapping between frequencies
81-displayed and channel numbers.
82-.TP
83-.B ap
84-Give the list of Access Points in range, and optionally the quality of
85-link to them.
86-.TP
87-.BR rate / bit [rate]
88-List the bit-rates supported by the device.
89-.TP
90-.BR keys / enc [ryption]
91-List the encryption key sizes supported and display all the encryption
92-keys availables in the device.
9366 .\"
9467 .\" FILES part
9568 .\"
@@ -101,5 +74,6 @@ keys availables in the device.
10174 .SH SEE ALSO
10275 .BR iwconfig (8),
10376 .BR ifconfig (8),
77+.BR iwlist (8).
10478 .BR iwpriv (8).
10579
--- a/wireless_tools/iwspy.c
+++ b/wireless_tools/iwspy.c
@@ -3,9 +3,10 @@
33 *
44 * Jean II - HPLB '99
55 *
6- * Main code for "iwconfig". This is the generic tool for most
7- * manipulations...
6+ * This tool can manipulate the spy list : add addresses and display stat
87 * You need to link this code against "iwcommon.c" and "-lm".
8+ *
9+ * This file is released under the GPL license.
910 */
1011
1112 #include "iwcommon.h" /* Header */
@@ -70,26 +71,9 @@ print_spy_info(int skfd,
7071
7172 for(i = 0; i < n; i++)
7273 {
73- if(has_range && (qual[i].level != 0))
74- /* If the statistics are in dBm */
75- if(qual[i].level > range.max_qual.level)
76- printf(" %s : Quality %d/%d ; Signal %d dBm ; Noise %d dBm %s\n",
77- pr_ether(hwa[i].sa_data),
78- qual[i].qual, range.max_qual.qual,
79- qual[i].level - 0x100, qual[i].noise - 0x100,
80- qual[i].updated & 0x7 ? "(updated)" : "");
81- else
82- printf(" %s : Quality %d/%d ; Signal %d/%d ; Noise %d/%d %s\n",
83- pr_ether(hwa[i].sa_data),
84- qual[i].qual, range.max_qual.qual,
85- qual[i].level, range.max_qual.level,
86- qual[i].noise, range.max_qual.noise,
87- qual[i].updated & 0x7 ? "(updated)" : "");
88- else
89- printf(" %s : Quality %d ; Signal %d ; Noise %d %s\n",
90- pr_ether(hwa[i].sa_data),
91- qual[i].qual, qual[i].level, qual[i].noise,
92- qual[i].updated & 0x7 ? "(updated)" : "");
74+ /* Print stats for each address */
75+ printf(" %s : ", pr_ether(hwa[i].sa_data));
76+ print_stats(stdout, &qual[i], &range, has_range);
9377 }
9478 printf("\n");
9579 }
@@ -121,361 +105,6 @@ print_spy_devices(int skfd)
121105 print_spy_info(skfd, ifr->ifr_name);
122106 }
123107
124-/*------------------------------------------------------------------*/
125-/*
126- * Print the number of channels and available frequency for the device
127- */
128-static void
129-print_freq_info(int skfd,
130- char * ifname)
131-{
132- struct iwreq wrq;
133- float freq;
134- struct iw_range range;
135- int k;
136-
137- strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
138- wrq.u.data.pointer = (caddr_t) &range;
139- wrq.u.data.length = 0;
140- wrq.u.data.flags = 0;
141- if(ioctl(skfd, SIOCGIWRANGE, &wrq) < 0)
142- fprintf(stderr, "%-8.8s no frequency information.\n\n",
143- ifname);
144- else
145- {
146- if(range.num_frequency > 0)
147- {
148- printf("%-8.8s %d channels in total; available frequencies :\n",
149- ifname, range.num_channels);
150- /* Print them all */
151- for(k = 0; k < range.num_frequency; k++)
152- {
153- printf("\t Channel %.2d : ", range.freq[k].i);
154- freq = freq2float(&(range.freq[k]));
155- if(freq >= GIGA)
156- printf("%g GHz\n", freq / GIGA);
157- else
158- if(freq >= MEGA)
159- printf("%g MHz\n", freq / MEGA);
160- else
161- printf("%g kHz\n", freq / KILO);
162- }
163- printf("\n\n");
164- }
165- else
166- printf("%-8.8s %d channels\n\n",
167- ifname, range.num_channels);
168- }
169-}
170-
171-/*------------------------------------------------------------------*/
172-/*
173- * Get frequency info on all devices and print it on the screen
174- */
175-static void
176-print_freq_devices(int skfd)
177-{
178- char buff[1024];
179- struct ifconf ifc;
180- struct ifreq *ifr;
181- int i;
182-
183- /* Get list of active devices */
184- ifc.ifc_len = sizeof(buff);
185- ifc.ifc_buf = buff;
186- if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
187- {
188- fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
189- return;
190- }
191- ifr = ifc.ifc_req;
192-
193- /* Print them */
194- for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
195- print_freq_info(skfd, ifr->ifr_name);
196-}
197-
198-/*------------------------------------------------------------------*/
199-/*
200- * Display the list of ap addresses and the associated stats
201- * Exacly the same as the spy list, only with different IOCTL and messages
202- */
203-static void
204-print_ap_info(int skfd,
205- char * ifname)
206-{
207- struct iwreq wrq;
208- char buffer[(sizeof(struct iw_quality) +
209- sizeof(struct sockaddr)) * IW_MAX_AP];
210- struct sockaddr * hwa;
211- struct iw_quality * qual;
212- iwrange range;
213- int has_range = 0;
214- int has_qual = 0;
215- int n;
216- int i;
217-
218- /* Collect stats */
219- strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
220- wrq.u.data.pointer = (caddr_t) buffer;
221- wrq.u.data.length = 0;
222- wrq.u.data.flags = 0;
223- if(ioctl(skfd, SIOCGIWAPLIST, &wrq) < 0)
224- {
225- fprintf(stderr, "%-8.8s Interface doesn't have a list of Access Points\n\n", ifname);
226- return;
227- }
228-
229- /* Number of addresses */
230- n = wrq.u.data.length;
231- has_qual = wrq.u.data.flags;
232-
233- /* The two lists */
234- hwa = (struct sockaddr *) buffer;
235- qual = (struct iw_quality *) (buffer + (sizeof(struct sockaddr) * n));
236-
237- /* Check if we have valid address types */
238- if(check_addr_type(skfd, ifname) < 0)
239- {
240- fprintf(stderr, "%-8.8s Interface doesn't support MAC & IP addresses\n\n", ifname);
241- return;
242- }
243-
244- /* Get range info if we can */
245- if(get_range_info(skfd, ifname, &(range)) >= 0)
246- has_range = 1;
247-
248- /* Display it */
249- if(n == 0)
250- printf("%-8.8s No Access Point in range\n", ifname);
251- else
252- printf("%-8.8s Access Points in range:\n", ifname);
253- for(i = 0; i < n; i++)
254- {
255- if(has_qual)
256- if(has_range)
257- /* If the statistics are in dBm */
258- if(qual[i].level > range.max_qual.level)
259- printf(" %s : Quality %d/%d ; Signal %d dBm ; Noise %d dBm %s\n",
260- pr_ether(hwa[i].sa_data),
261- qual[i].qual, range.max_qual.qual,
262- qual[i].level - 0x100, qual[i].noise - 0x100,
263- qual[i].updated & 0x7 ? "(updated)" : "");
264- else
265- printf(" %s : Quality %d/%d ; Signal %d/%d ; Noise %d/%d %s\n",
266- pr_ether(hwa[i].sa_data),
267- qual[i].qual, range.max_qual.qual,
268- qual[i].level, range.max_qual.level,
269- qual[i].noise, range.max_qual.noise,
270- qual[i].updated & 0x7 ? "(updated)" : "");
271- else
272- printf(" %s : Quality %d ; Signal %d ; Noise %d %s\n",
273- pr_ether(hwa[i].sa_data),
274- qual[i].qual, qual[i].level, qual[i].noise,
275- qual[i].updated & 0x7 ? "(updated)" : "");
276- else
277- printf(" %s\n", pr_ether(hwa[i].sa_data));
278- }
279- printf("\n");
280-}
281-
282-/*------------------------------------------------------------------*/
283-/*
284- * Get list of AP on all devices and print it on the screen
285- */
286-static void
287-print_ap_devices(int skfd)
288-{
289- char buff[1024];
290- struct ifconf ifc;
291- struct ifreq *ifr;
292- int i;
293-
294- /* Get list of active devices */
295- ifc.ifc_len = sizeof(buff);
296- ifc.ifc_buf = buff;
297- if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
298- {
299- fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
300- return;
301- }
302- ifr = ifc.ifc_req;
303-
304- /* Print them */
305- for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
306- print_ap_info(skfd, ifr->ifr_name);
307-}
308-
309-/*------------------------------------------------------------------*/
310-/*
311- * Print the number of available bitrates for the device
312- */
313-static void
314-print_bitrate_info(int skfd,
315- char * ifname)
316-{
317- struct iwreq wrq;
318- float bitrate;
319- struct iw_range range;
320- int k;
321-
322- strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
323- wrq.u.data.pointer = (caddr_t) &range;
324- wrq.u.data.length = 0;
325- wrq.u.data.flags = 0;
326- if(ioctl(skfd, SIOCGIWRANGE, &wrq) < 0)
327- fprintf(stderr, "%-8.8s no bit-rate information.\n\n",
328- ifname);
329- else
330- {
331- if((range.num_bitrates > 0) && (range.num_bitrates < IW_MAX_BITRATES))
332- {
333- printf("%-8.8s %d available bit-rates :\n",
334- ifname, range.num_bitrates);
335- /* Print them all */
336- for(k = 0; k < range.num_bitrates; k++)
337- {
338- printf("\t ");
339- bitrate = range.bitrate[k];
340- if(bitrate >= GIGA)
341- printf("%g Gb/s\n", bitrate / GIGA);
342- else
343- if(bitrate >= MEGA)
344- printf("%g Mb/s\n", bitrate / MEGA);
345- else
346- printf("%g kb/s\n", bitrate / KILO);
347- }
348- printf("\n\n");
349- }
350- else
351- printf("%-8.8s No bit-rates ? Please update driver...\n\n", ifname);
352- }
353-}
354-
355-/*------------------------------------------------------------------*/
356-/*
357- * Get bit-rate info on all devices and print it on the screen
358- */
359-static void
360-print_bitrate_devices(int skfd)
361-{
362- char buff[1024];
363- struct ifconf ifc;
364- struct ifreq *ifr;
365- int i;
366-
367- /* Get list of active devices */
368- ifc.ifc_len = sizeof(buff);
369- ifc.ifc_buf = buff;
370- if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
371- {
372- fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
373- return;
374- }
375- ifr = ifc.ifc_req;
376-
377- /* Print them */
378- for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
379- print_bitrate_info(skfd, ifr->ifr_name);
380-}
381-
382-/*------------------------------------------------------------------*/
383-/*
384- * Print the number of available bitrates for the device
385- */
386-static void
387-print_keys_info(int skfd,
388- char * ifname)
389-{
390- struct iwreq wrq;
391- struct iw_range range;
392- unsigned char key[IW_ENCODING_TOKEN_MAX];
393- int k;
394-
395- strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
396- wrq.u.data.pointer = (caddr_t) &range;
397- wrq.u.data.length = 0;
398- wrq.u.data.flags = 0;
399- if(ioctl(skfd, SIOCGIWRANGE, &wrq) < 0)
400- fprintf(stderr, "%-8.8s no encryption keys information.\n\n",
401- ifname);
402- else
403- {
404- printf("%-8.8s ", ifname);
405- if((range.num_encoding_sizes > 0) &&
406- (range.num_encoding_sizes < IW_MAX_ENCODING_SIZES))
407- {
408- printf("%d key sizes : %d", range.num_encoding_sizes,
409- range.encoding_size[0] * 8);
410- /* Print them all */
411- for(k = 1; k < range.num_encoding_sizes; k++)
412- printf(", %d", range.encoding_size[k] * 8);
413- printf("bits\n ");
414- }
415- printf("%d keys available :\n", range.max_encoding_tokens);
416- for(k = 1; k <= range.max_encoding_tokens; k++)
417- {
418- strcpy(wrq.ifr_name, ifname);
419- wrq.u.data.pointer = (caddr_t) key;
420- wrq.u.data.length = 0;
421- wrq.u.data.flags = k;
422- if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0)
423- {
424- fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno));
425- break;
426- }
427- if((wrq.u.data.flags & IW_ENCODE_DISABLED) ||
428- (wrq.u.data.length == 0))
429- printf("\t\t[%d]: off\n", k);
430- else
431- {
432- int i;
433-
434- printf("\t\t[%d]: %.2X", k, key[0]);
435- for(i = 1; i < wrq.u.data.length; i++)
436- {
437- if((i & 0x1) == 0)
438- printf("-");
439- printf("%.2X", key[i]);
440- }
441-
442- /* Other info... */
443- printf(" (%d bits)", wrq.u.data.length * 8);
444- printf("\n");
445- }
446- }
447-
448- printf("\n\n");
449- }
450-}
451-
452-/*------------------------------------------------------------------*/
453-/*
454- * Get bit-rate info on all devices and print it on the screen
455- */
456-static void
457-print_keys_devices(int skfd)
458-{
459- char buff[1024];
460- struct ifconf ifc;
461- struct ifreq *ifr;
462- int i;
463-
464- /* Get list of active devices */
465- ifc.ifc_len = sizeof(buff);
466- ifc.ifc_buf = buff;
467- if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
468- {
469- fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
470- return;
471- }
472- ifr = ifc.ifc_req;
473-
474- /* Print them */
475- for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
476- print_keys_info(skfd, ifr->ifr_name);
477-}
478-
479108 /************************* SETTING ROUTINES **************************/
480109
481110 /*------------------------------------------------------------------*/
@@ -608,41 +237,6 @@ main(int argc,
608237 exit(0);
609238 }
610239
611- /* Frequency list */
612- if((!strncmp(argv[1], "freq", 4)) ||
613- (!strncmp(argv[1], "channel", 7)))
614- {
615- print_freq_devices(skfd);
616- close(skfd);
617- exit(0);
618- }
619-
620- /* Access Point list */
621- if(!strcasecmp(argv[1], "ap"))
622- {
623- print_ap_devices(skfd);
624- close(skfd);
625- exit(0);
626- }
627-
628- /* Bit-rate list */
629- if((!strncmp(argv[1], "bit", 3)) ||
630- (!strcmp(argv[1], "rate")))
631- {
632- print_bitrate_devices(skfd);
633- close(skfd);
634- exit(0);
635- }
636-
637- /* Encryption key list */
638- if((!strncmp(argv[1], "enc", 3)) ||
639- (!strncmp(argv[1], "key", 3)))
640- {
641- print_keys_devices(skfd);
642- close(skfd);
643- exit(0);
644- }
645-
646240 /* The device name must be the first argument */
647241 /* Name only : show spy list for that device only */
648242 if(argc == 2)
@@ -652,42 +246,6 @@ main(int argc,
652246 exit(0);
653247 }
654248
655- /* Special cases take two... */
656- /* Frequency list */
657- if((!strncmp(argv[2], "freq", 4)) ||
658- (!strncmp(argv[2], "channel", 7)))
659- {
660- print_freq_info(skfd, argv[1]);
661- close(skfd);
662- exit(0);
663- }
664-
665- /* Access Point list */
666- if(!strcasecmp(argv[2], "ap"))
667- {
668- print_ap_info(skfd, argv[1]);
669- close(skfd);
670- exit(0);
671- }
672-
673- /* Access Point list */
674- if((!strncmp(argv[2], "bit", 3)) ||
675- (!strcmp(argv[2], "rate")))
676- {
677- print_bitrate_info(skfd, argv[1]);
678- close(skfd);
679- exit(0);
680- }
681-
682- /* Access Point list */
683- if((!strncmp(argv[2], "enc", 3)) ||
684- (!strncmp(argv[2], "key", 3)))
685- {
686- print_keys_info(skfd, argv[1]);
687- close(skfd);
688- exit(0);
689- }
690-
691249 /* Otherwise, it's a list of address to set in the spy list */
692250 goterr = set_spy_info(skfd, argv + 2, argc - 2, argv[1]);
693251
--- a/wireless_tools/sample_enc_cs.c
+++ b/wireless_tools/sample_enc_cs.c
@@ -1,3 +1,8 @@
1+/* Note : this particular snipset of code is available under
2+ * the LGPL, MPL or BSD license (at your choice).
3+ * Jean II
4+ */
5+
16 #define MAX_KEY_SIZE 16
27 #define MAX_KEYS 8
38 int key_on = 0;
--- /dev/null
+++ b/wireless_tools/sample_pm_cs.c
@@ -0,0 +1,146 @@
1+/* Note : this particular snipset of code is available under
2+ * the LGPL, MPL or BSD license (at your choice).
3+ * Jean II
4+ */
5+
6+/* Backward compatibility for Wireless Extension 9 */
7+#ifndef IW_POWER_MODIFIER
8+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
9+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
10+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
11+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
12+#endif IW_POWER_MODIFIER
13+
14+struct net_local {
15+ int pm_on; // Power Management enabled
16+ int pm_multi; // Receive multicasts
17+ int pm_period; // Power Management period
18+ int pm_period_auto; // Power Management auto mode
19+ int pm_max_period; // Power Management max period
20+ int pm_min_period; // Power Management min period
21+ int pm_timeout; // Power Management timeout
22+};
23+
24+ /* Set the desired Power Management mode */
25+ case SIOCSIWPOWER:
26+ /* Disable it ? */
27+ if(wrq->u.power.disabled)
28+ {
29+ local->pm_on = 0;
30+ local->need_commit = 1;
31+ }
32+ else
33+ {
34+ /* Check mode */
35+ switch(wrq->u.power.flags & IW_POWER_MODE)
36+ {
37+ case IW_POWER_UNICAST_R:
38+ local->pm_multi = 0;
39+ local->need_commit = 1;
40+ break;
41+ case IW_POWER_ALL_R:
42+ local->pm_multi = 1;
43+ local->need_commit = 1;
44+ break;
45+ case IW_POWER_ON: /* None = ok */
46+ break;
47+ default: /* Invalid */
48+ rc = -EINVAL;
49+ }
50+ /* Set period */
51+ if(wrq->u.power.flags & IW_POWER_PERIOD)
52+ {
53+ int period = wrq->u.power.value/1000000;
54+ /* Hum: check if within bounds... */
55+
56+ /* Activate PM */
57+ local->pm_on = 1;
58+ local->need_commit = 1;
59+
60+ /* Check min value */
61+ if(wrq->u.power.flags & IW_POWER_MIN)
62+ {
63+ local->pm_min_period = period;
64+ local->pm_period_auto = 1;
65+ }
66+ else
67+ /* Check max value */
68+ if(wrq->u.power.flags & IW_POWER_MAX)
69+ {
70+ local->pm_max_period = period;
71+ local->pm_period_auto = 1;
72+ }
73+ else
74+ {
75+ /* Fixed value */
76+ local->pm_period = period;
77+ local->pm_period_auto = 0;
78+ }
79+ }
80+ /* Set timeout */
81+ if(wrq->u.power.flags & IW_POWER_TIMEOUT)
82+ {
83+ /* Activate PM */
84+ local->pm_on = 1;
85+ local->need_commit = 1;
86+ /* Fixed value in ms */
87+ local->pm_timeout = wrq->u.power.value/1000;
88+ }
89+ }
90+ break;
91+
92+ /* Get the power management settings */
93+ case SIOCGIWPOWER:
94+ wrq->u.power.disabled = !local->pm_on;
95+ /* By default, display the period */
96+ if(!(wrq->u.power.flags & IW_POWER_TIMEOUT))
97+ {
98+ int inc_flags = wrq->u.power.flags;
99+ wrq->u.power.flags = IW_POWER_PERIOD | IW_POWER_RELATIVE;
100+ /* Check if auto */
101+ if(local->pm_period_auto)
102+ {
103+ /* By default, the min */
104+ if(!(inc_flags & IW_POWER_MAX))
105+ {
106+ wrq->u.power.value = local->pm_min_period * 1000000;
107+ wrq->u.power.flags |= IW_POWER_MIN;
108+ }
109+ else
110+ {
111+ wrq->u.power.value = local->pm_max_period * 1000000;
112+ wrq->u.power.flags |= IW_POWER_MAX;
113+ }
114+ }
115+ else
116+ {
117+ /* Fixed value. Check the flags */
118+ if(inc_flags & (IW_POWER_MIN | IW_POWER_MAX))
119+ rc = -EINVAL;
120+ else
121+ wrq->u.power.value = local->pm_period * 1000000;
122+ }
123+ }
124+ else
125+ {
126+ /* Deal with the timeout - always fixed */
127+ wrq->u.power.flags = IW_POWER_TIMEOUT;
128+ wrq->u.power.value = local->pm_timeout * 1000;
129+ }
130+ if(local->pm_multi)
131+ wrq->u.power.flags |= IW_POWER_ALL_R;
132+ else
133+ wrq->u.power.flags |= IW_POWER_UNICAST_R;
134+ break;
135+#endif /* WIRELESS_EXT > 8 */
136+
137+#if WIRELESS_EXT > 9
138+ range.min_pmp = 1000000; /* 1 units */
139+ range.max_pmp = 12000000; /* 12 units */
140+ range.min_pmt = 1000; /* 1 ms */
141+ range.max_pmt = 1000000; /* 1 s */
142+ range.pmp_flags = IW_POWER_PERIOD | IW_POWER_RELATIVE |
143+ IW_POWER_MIN | IW_POWER_MAX;
144+ range.pmt_flags = IW_POWER_TIMEOUT;
145+ range.pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
146+#endif /* WIRELESS_EXT > 9 */
--- /dev/null
+++ b/wireless_tools/wireless.10.h
@@ -0,0 +1,479 @@
1+/*
2+ * This file define a set of standard wireless extensions
3+ *
4+ * Version : 9 16.10.99
5+ *
6+ * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7+ */
8+
9+#ifndef _LINUX_WIRELESS_H
10+#define _LINUX_WIRELESS_H
11+
12+/************************** DOCUMENTATION **************************/
13+/*
14+ * Basically, the wireless extensions are for now a set of standard ioctl
15+ * call + /proc/net/wireless
16+ *
17+ * The entry /proc/net/wireless give statistics and information on the
18+ * driver.
19+ * This is better than having each driver having its entry because
20+ * its centralised and we may remove the driver module safely.
21+ *
22+ * Ioctl are used to configure the driver and issue commands. This is
23+ * better than command line options of insmod because we may want to
24+ * change dynamically (while the driver is running) some parameters.
25+ *
26+ * The ioctl mechanimsm are copied from standard devices ioctl.
27+ * We have the list of command plus a structure descibing the
28+ * data exchanged...
29+ * Note that to add these ioctl, I was obliged to modify :
30+ * net/core/dev.c (two place + add include)
31+ * net/ipv4/af_inet.c (one place + add include)
32+ *
33+ * /proc/net/wireless is a copy of /proc/net/dev.
34+ * We have a structure for data passed from the driver to /proc/net/wireless
35+ * Too add this, I've modified :
36+ * net/core/dev.c (two other places)
37+ * include/linux/netdevice.h (one place)
38+ * include/linux/proc_fs.h (one place)
39+ *
40+ * Do not add here things that are redundant with other mechanisms
41+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
42+ * wireless specific.
43+ *
44+ * These wireless extensions are not magic : each driver has to provide
45+ * support for them...
46+ *
47+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
48+ * work in progress. Contact me if you have ideas of improvements...
49+ */
50+
51+/***************************** INCLUDES *****************************/
52+
53+#include <linux/types.h> /* for "caddr_t" et al */
54+#include <linux/socket.h> /* for "struct sockaddr" et al */
55+#include <linux/if.h> /* for IFNAMSIZ and co... */
56+
57+/**************************** CONSTANTS ****************************/
58+
59+/* --------------------------- VERSION --------------------------- */
60+/*
61+ * This constant is used to know the availability of the wireless
62+ * extensions and to know which version of wireless extensions it is
63+ * (there is some stuff that will be added in the future...)
64+ * I just plan to increment with each new version.
65+ */
66+#define WIRELESS_EXT 10
67+
68+/*
69+ * Changes :
70+ *
71+ * V2 to V3
72+ * --------
73+ * Alan Cox start some incompatibles changes. I've integrated a bit more.
74+ * - Encryption renamed to Encode to avoid US regulation problems
75+ * - Frequency changed from float to struct to avoid problems on old 386
76+ *
77+ * V3 to V4
78+ * --------
79+ * - Add sensitivity
80+ *
81+ * V4 to V5
82+ * --------
83+ * - Missing encoding definitions in range
84+ * - Access points stuff
85+ *
86+ * V5 to V6
87+ * --------
88+ * - 802.11 support (ESSID ioctls)
89+ *
90+ * V6 to V7
91+ * --------
92+ * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
93+ *
94+ * V7 to V8
95+ * --------
96+ * - Changed my e-mail address
97+ * - More 802.11 support (nickname, rate, rts, frag)
98+ * - List index in frequencies
99+ *
100+ * V8 to V9
101+ * --------
102+ * - Support for 'mode of operation' (ad-hoc, managed...)
103+ * - Support for unicast and multicast power saving
104+ * - Change encoding to support larger tokens (>64 bits)
105+ * - Updated iw_params (disable, flags) and use it for NWID
106+ * - Extracted iw_point from iwreq for clarity
107+ *
108+ * V9 to V10
109+ * ---------
110+ * - Add PM capability to range structure
111+ * - Add PM modifier : MAX/MIN/RELATIVE
112+ * - Add encoding option : IW_ENCODE_NOKEY
113+ * - Add TxPower ioctls (work like TxRate)
114+ */
115+
116+/* -------------------------- IOCTL LIST -------------------------- */
117+
118+/* Basic operations */
119+#define SIOCSIWNAME 0x8B00 /* Unused */
120+#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
121+#define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
122+#define SIOCGIWNWID 0x8B03 /* get network id */
123+#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
124+#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
125+#define SIOCSIWMODE 0x8B06 /* set operation mode */
126+#define SIOCGIWMODE 0x8B07 /* get operation mode */
127+#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
128+#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
129+
130+/* Informative stuff */
131+#define SIOCSIWRANGE 0x8B0A /* Unused */
132+#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
133+#define SIOCSIWPRIV 0x8B0C /* Unused */
134+#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
135+
136+/* Mobile IP support */
137+#define SIOCSIWSPY 0x8B10 /* set spy addresses */
138+#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
139+
140+/* Access Point manipulation */
141+#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
142+#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
143+#define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
144+
145+/* 802.11 specific support */
146+#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
147+#define SIOCGIWESSID 0x8B1B /* get ESSID */
148+#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
149+#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
150+/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
151+ * within the 'iwreq' structure, so we need to use the 'data' member to
152+ * point to a string in user space, like it is done for RANGE...
153+ * The "flags" member indicate if the ESSID is active or not (promiscuous).
154+ */
155+
156+/* Other parameters usefull in 802.11 and some other devices */
157+#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
158+#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
159+#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
160+#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
161+#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
162+#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
163+#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
164+#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
165+
166+/* Encoding stuff (scrambling, hardware security, WEP...) */
167+#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
168+#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
169+/* Power saving stuff (power management, unicast and multicast) */
170+#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
171+#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
172+
173+/* ------------------------- IOCTL STUFF ------------------------- */
174+
175+/* The first and the last (range) */
176+#define SIOCIWFIRST 0x8B00
177+#define SIOCIWLAST 0x8B30
178+
179+/* Even : get (world access), odd : set (root access) */
180+#define IW_IS_SET(cmd) (!((cmd) & 0x1))
181+#define IW_IS_GET(cmd) ((cmd) & 0x1)
182+
183+/* ------------------------- PRIVATE INFO ------------------------- */
184+/*
185+ * The following is used with SIOCGIWPRIV. It allow a driver to define
186+ * the interface (name, type of data) for its private ioctl.
187+ * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
188+ */
189+
190+#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
191+#define IW_PRIV_TYPE_NONE 0x0000
192+#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
193+#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
194+#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
195+#define IW_PRIV_TYPE_FLOAT 0x5000
196+
197+#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
198+
199+#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
200+
201+/*
202+ * Note : if the number of args is fixed and the size < 16 octets,
203+ * instead of passing a pointer we will put args in the iwreq struct...
204+ */
205+
206+/* ----------------------- OTHER CONSTANTS ----------------------- */
207+
208+/* Maximum frequencies in the range struct */
209+#define IW_MAX_FREQUENCIES 16
210+/* Note : if you have something like 80 frequencies,
211+ * don't increase this constant and don't fill the frequency list.
212+ * The user will be able to set by channel anyway... */
213+
214+/* Maximum bit rates in the range struct */
215+#define IW_MAX_BITRATES 8
216+
217+/* Maximum tx powers in the range struct */
218+#define IW_MAX_TXPOWER 8
219+
220+/* Maximum of address that you may set with SPY */
221+#define IW_MAX_SPY 8
222+
223+/* Maximum of address that you may get in the
224+ list of access points in range */
225+#define IW_MAX_AP 8
226+
227+/* Maximum size of the ESSID and NICKN strings */
228+#define IW_ESSID_MAX_SIZE 32
229+
230+/* Modes of operation */
231+#define IW_MODE_AUTO 0 /* Let the driver decides */
232+#define IW_MODE_ADHOC 1 /* Single cell network */
233+#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
234+#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
235+#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
236+#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
237+
238+/* Maximum number of size of encoding token available
239+ * they are listed in the range structure */
240+#define IW_MAX_ENCODING_SIZES 8
241+
242+/* Maximum size of the encoding token in bytes */
243+#define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
244+
245+/* Flags for encoding (along with the token) */
246+#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
247+#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
248+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
249+#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
250+#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
251+#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
252+#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
253+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
254+
255+/* Power management flags available (along with the value, if any) */
256+#define IW_POWER_ON 0x0000 /* No details... */
257+#define IW_POWER_TYPE 0xF000 /* Type of parameter */
258+#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
259+#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
260+#define IW_POWER_MODE 0x0F00 /* Power Management mode */
261+#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
262+#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
263+#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
264+#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
265+#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
266+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
267+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
268+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
269+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
270+
271+/* Transmit Power flags available */
272+#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
273+#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
274+
275+/****************************** TYPES ******************************/
276+
277+/* --------------------------- SUBTYPES --------------------------- */
278+/*
279+ * Generic format for most parameters that fit in an int
280+ */
281+struct iw_param
282+{
283+ __s32 value; /* The value of the parameter itself */
284+ __u8 fixed; /* Hardware should not use auto select */
285+ __u8 disabled; /* Disable the feature */
286+ __u16 flags; /* Various specifc flags (if any) */
287+};
288+
289+/*
290+ * For all data larger than 16 octets, we need to use a
291+ * pointer to memory alocated in user space.
292+ */
293+struct iw_point
294+{
295+ caddr_t pointer; /* Pointer to the data (in user space) */
296+ __u16 length; /* number of fields or size in bytes */
297+ __u16 flags; /* Optional params */
298+};
299+
300+/*
301+ * A frequency
302+ * For numbers lower than 10^9, we encode the number in 'm' and
303+ * set 'e' to 0
304+ * For number greater than 10^9, we divide it by the lowest power
305+ * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
306+ * The power of 10 is in 'e', the result of the division is in 'm'.
307+ */
308+struct iw_freq
309+{
310+ __u32 m; /* Mantissa */
311+ __u16 e; /* Exponent */
312+ __u8 i; /* List index (when in range struct) */
313+};
314+
315+/*
316+ * Quality of the link
317+ */
318+struct iw_quality
319+{
320+ __u8 qual; /* link quality (%retries, SNR or better...) */
321+ __u8 level; /* signal level */
322+ __u8 noise; /* noise level */
323+ __u8 updated; /* Flags to know if updated */
324+};
325+
326+/*
327+ * Packet discarded in the wireless adapter due to
328+ * "wireless" specific problems...
329+ */
330+struct iw_discarded
331+{
332+ __u32 nwid; /* Wrong nwid */
333+ __u32 code; /* Unable to code/decode */
334+ __u32 misc; /* Others cases */
335+};
336+
337+/* ------------------------ WIRELESS STATS ------------------------ */
338+/*
339+ * Wireless statistics (used for /proc/net/wireless)
340+ */
341+struct iw_statistics
342+{
343+ __u16 status; /* Status
344+ * - device dependent for now */
345+
346+ struct iw_quality qual; /* Quality of the link
347+ * (instant/mean/max) */
348+ struct iw_discarded discard; /* Packet discarded counts */
349+};
350+
351+/* ------------------------ IOCTL REQUEST ------------------------ */
352+/*
353+ * The structure to exchange data for ioctl.
354+ * This structure is the same as 'struct ifreq', but (re)defined for
355+ * convenience...
356+ *
357+ * Note that it should fit on the same memory footprint !
358+ * You should check this when increasing the above structures (16 octets)
359+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
360+ */
361+struct iwreq
362+{
363+ union
364+ {
365+ char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
366+ } ifr_ifrn;
367+
368+ /* Data part */
369+ union
370+ {
371+ /* Config - generic */
372+ char name[IFNAMSIZ];
373+ /* Name : used to verify the presence of wireless extensions.
374+ * Name of the protocol/provider... */
375+
376+ struct iw_point essid; /* Extended network name */
377+ struct iw_param nwid; /* network id (or domain - the cell) */
378+ struct iw_freq freq; /* frequency or channel :
379+ * 0-1000 = channel
380+ * > 1000 = frequency in Hz */
381+
382+ struct iw_param sens; /* signal level threshold */
383+ struct iw_param bitrate; /* default bit rate */
384+ struct iw_param txpower; /* default transmit power */
385+ struct iw_param rts; /* RTS threshold threshold */
386+ struct iw_param frag; /* Fragmentation threshold */
387+ __u32 mode; /* Operation mode */
388+
389+ struct iw_point encoding; /* Encoding stuff : tokens */
390+ struct iw_param power; /* PM duration/timeout */
391+
392+ struct sockaddr ap_addr; /* Access point address */
393+
394+ struct iw_point data; /* Other large parameters */
395+ } u;
396+};
397+
398+/* -------------------------- IOCTL DATA -------------------------- */
399+/*
400+ * For those ioctl which want to exchange mode data that what could
401+ * fit in the above structure...
402+ */
403+
404+/*
405+ * Range of parameters
406+ */
407+
408+struct iw_range
409+{
410+ /* Informative stuff (to choose between different interface) */
411+ __u32 throughput; /* To give an idea... */
412+ /* In theory this value should be the maximum benchmarked
413+ * TCP/IP throughput, because with most of these devices the
414+ * bit rate is meaningless (overhead an co) to estimate how
415+ * fast the connection will go and pick the fastest one.
416+ * I suggest people to play with Netperf or any benchmark...
417+ */
418+
419+ /* NWID (or domain id) */
420+ __u32 min_nwid; /* Minimal NWID we are able to set */
421+ __u32 max_nwid; /* Maximal NWID we are able to set */
422+
423+ /* Frequency */
424+ __u16 num_channels; /* Number of channels [0; num - 1] */
425+ __u8 num_frequency; /* Number of entry in the list */
426+ struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
427+ /* Note : this frequency list doesn't need to fit channel numbers */
428+
429+ /* signal level threshold range */
430+ __s32 sensitivity;
431+
432+ /* Quality of link & SNR stuff */
433+ struct iw_quality max_qual; /* Quality of the link */
434+
435+ /* Rates */
436+ __u8 num_bitrates; /* Number of entries in the list */
437+ __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
438+
439+ /* RTS threshold */
440+ __s32 min_rts; /* Minimal RTS threshold */
441+ __s32 max_rts; /* Maximal RTS threshold */
442+
443+ /* Frag threshold */
444+ __s32 min_frag; /* Minimal frag threshold */
445+ __s32 max_frag; /* Maximal frag threshold */
446+
447+ /* Power Management duration & timeout */
448+ __s32 min_pmp; /* Minimal PM period */
449+ __s32 max_pmp; /* Maximal PM period */
450+ __s32 min_pmt; /* Minimal PM timeout */
451+ __s32 max_pmt; /* Maximal PM timeout */
452+ __u16 pmp_flags; /* How to decode max/min PM period */
453+ __u16 pmt_flags; /* How to decode max/min PM timeout */
454+ __u16 pm_capa; /* What PM options are supported */
455+
456+ /* Encoder stuff */
457+ __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
458+ __u8 num_encoding_sizes; /* Number of entry in the list */
459+ __u8 max_encoding_tokens; /* Max number of tokens */
460+
461+ /* Transmit power */
462+ __u16 txpower_capa; /* What options are supported */
463+ __u8 num_txpower; /* Number of entries in the list */
464+ __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
465+};
466+
467+/*
468+ * Private ioctl interface information
469+ */
470+
471+struct iw_priv_args
472+{
473+ __u32 cmd; /* Number of the ioctl to issue */
474+ __u16 set_args; /* Type and number of args */
475+ __u16 get_args; /* Type and number of args */
476+ char name[IFNAMSIZ]; /* Name of the extension */
477+};
478+
479+#endif /* _LINUX_WIRELESS_H */
--- /dev/null
+++ b/wireless_tools/wireless.h
@@ -0,0 +1,510 @@
1+/*
2+ * This file define a set of standard wireless extensions
3+ *
4+ * Version : 11 28.3.01
5+ *
6+ * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7+ */
8+
9+#ifndef _LINUX_WIRELESS_H
10+#define _LINUX_WIRELESS_H
11+
12+/************************** DOCUMENTATION **************************/
13+/*
14+ * Basically, the wireless extensions are for now a set of standard ioctl
15+ * call + /proc/net/wireless
16+ *
17+ * The entry /proc/net/wireless give statistics and information on the
18+ * driver.
19+ * This is better than having each driver having its entry because
20+ * its centralised and we may remove the driver module safely.
21+ *
22+ * Ioctl are used to configure the driver and issue commands. This is
23+ * better than command line options of insmod because we may want to
24+ * change dynamically (while the driver is running) some parameters.
25+ *
26+ * The ioctl mechanimsm are copied from standard devices ioctl.
27+ * We have the list of command plus a structure descibing the
28+ * data exchanged...
29+ * Note that to add these ioctl, I was obliged to modify :
30+ * net/core/dev.c (two place + add include)
31+ * net/ipv4/af_inet.c (one place + add include)
32+ *
33+ * /proc/net/wireless is a copy of /proc/net/dev.
34+ * We have a structure for data passed from the driver to /proc/net/wireless
35+ * Too add this, I've modified :
36+ * net/core/dev.c (two other places)
37+ * include/linux/netdevice.h (one place)
38+ * include/linux/proc_fs.h (one place)
39+ *
40+ * Do not add here things that are redundant with other mechanisms
41+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
42+ * wireless specific.
43+ *
44+ * These wireless extensions are not magic : each driver has to provide
45+ * support for them...
46+ *
47+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
48+ * work in progress. Contact me if you have ideas of improvements...
49+ */
50+
51+/***************************** INCLUDES *****************************/
52+
53+#include <linux/types.h> /* for "caddr_t" et al */
54+#include <linux/socket.h> /* for "struct sockaddr" et al */
55+#include <linux/if.h> /* for IFNAMSIZ and co... */
56+
57+/**************************** CONSTANTS ****************************/
58+
59+/* --------------------------- VERSION --------------------------- */
60+/*
61+ * This constant is used to know the availability of the wireless
62+ * extensions and to know which version of wireless extensions it is
63+ * (there is some stuff that will be added in the future...)
64+ * I just plan to increment with each new version.
65+ */
66+#define WIRELESS_EXT 11
67+
68+/*
69+ * Changes :
70+ *
71+ * V2 to V3
72+ * --------
73+ * Alan Cox start some incompatibles changes. I've integrated a bit more.
74+ * - Encryption renamed to Encode to avoid US regulation problems
75+ * - Frequency changed from float to struct to avoid problems on old 386
76+ *
77+ * V3 to V4
78+ * --------
79+ * - Add sensitivity
80+ *
81+ * V4 to V5
82+ * --------
83+ * - Missing encoding definitions in range
84+ * - Access points stuff
85+ *
86+ * V5 to V6
87+ * --------
88+ * - 802.11 support (ESSID ioctls)
89+ *
90+ * V6 to V7
91+ * --------
92+ * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
93+ *
94+ * V7 to V8
95+ * --------
96+ * - Changed my e-mail address
97+ * - More 802.11 support (nickname, rate, rts, frag)
98+ * - List index in frequencies
99+ *
100+ * V8 to V9
101+ * --------
102+ * - Support for 'mode of operation' (ad-hoc, managed...)
103+ * - Support for unicast and multicast power saving
104+ * - Change encoding to support larger tokens (>64 bits)
105+ * - Updated iw_params (disable, flags) and use it for NWID
106+ * - Extracted iw_point from iwreq for clarity
107+ *
108+ * V9 to V10
109+ * ---------
110+ * - Add PM capability to range structure
111+ * - Add PM modifier : MAX/MIN/RELATIVE
112+ * - Add encoding option : IW_ENCODE_NOKEY
113+ * - Add TxPower ioctls (work like TxRate)
114+ *
115+ * V10 to V11
116+ * ----------
117+ * - Add WE version in range (help backward/forward compatibility)
118+ * - Add retry ioctls (work like PM)
119+ */
120+
121+/* -------------------------- IOCTL LIST -------------------------- */
122+
123+/* Basic operations */
124+#define SIOCSIWNAME 0x8B00 /* Unused */
125+#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
126+#define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
127+#define SIOCGIWNWID 0x8B03 /* get network id */
128+#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
129+#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
130+#define SIOCSIWMODE 0x8B06 /* set operation mode */
131+#define SIOCGIWMODE 0x8B07 /* get operation mode */
132+#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
133+#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
134+
135+/* Informative stuff */
136+#define SIOCSIWRANGE 0x8B0A /* Unused */
137+#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
138+#define SIOCSIWPRIV 0x8B0C /* Unused */
139+#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
140+
141+/* Mobile IP support */
142+#define SIOCSIWSPY 0x8B10 /* set spy addresses */
143+#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
144+
145+/* Access Point manipulation */
146+#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
147+#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
148+#define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
149+
150+/* 802.11 specific support */
151+#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
152+#define SIOCGIWESSID 0x8B1B /* get ESSID */
153+#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
154+#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
155+/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
156+ * within the 'iwreq' structure, so we need to use the 'data' member to
157+ * point to a string in user space, like it is done for RANGE...
158+ * The "flags" member indicate if the ESSID is active or not (promiscuous).
159+ */
160+
161+/* Other parameters usefull in 802.11 and some other devices */
162+#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
163+#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
164+#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
165+#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
166+#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
167+#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
168+#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
169+#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
170+#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
171+#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
172+
173+/* Encoding stuff (scrambling, hardware security, WEP...) */
174+#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
175+#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
176+/* Power saving stuff (power management, unicast and multicast) */
177+#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
178+#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
179+
180+/* ------------------------- IOCTL STUFF ------------------------- */
181+
182+/* The first and the last (range) */
183+#define SIOCIWFIRST 0x8B00
184+#define SIOCIWLAST 0x8B30
185+
186+/* Even : get (world access), odd : set (root access) */
187+#define IW_IS_SET(cmd) (!((cmd) & 0x1))
188+#define IW_IS_GET(cmd) ((cmd) & 0x1)
189+
190+/* ------------------------- PRIVATE INFO ------------------------- */
191+/*
192+ * The following is used with SIOCGIWPRIV. It allow a driver to define
193+ * the interface (name, type of data) for its private ioctl.
194+ * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
195+ */
196+
197+#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
198+#define IW_PRIV_TYPE_NONE 0x0000
199+#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
200+#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
201+#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
202+#define IW_PRIV_TYPE_FLOAT 0x5000
203+
204+#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
205+
206+#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
207+
208+/*
209+ * Note : if the number of args is fixed and the size < 16 octets,
210+ * instead of passing a pointer we will put args in the iwreq struct...
211+ */
212+
213+/* ----------------------- OTHER CONSTANTS ----------------------- */
214+
215+/* Maximum frequencies in the range struct */
216+#define IW_MAX_FREQUENCIES 16
217+/* Note : if you have something like 80 frequencies,
218+ * don't increase this constant and don't fill the frequency list.
219+ * The user will be able to set by channel anyway... */
220+
221+/* Maximum bit rates in the range struct */
222+#define IW_MAX_BITRATES 8
223+
224+/* Maximum tx powers in the range struct */
225+#define IW_MAX_TXPOWER 8
226+
227+/* Maximum of address that you may set with SPY */
228+#define IW_MAX_SPY 8
229+
230+/* Maximum of address that you may get in the
231+ list of access points in range */
232+#define IW_MAX_AP 8
233+
234+/* Maximum size of the ESSID and NICKN strings */
235+#define IW_ESSID_MAX_SIZE 32
236+
237+/* Modes of operation */
238+#define IW_MODE_AUTO 0 /* Let the driver decides */
239+#define IW_MODE_ADHOC 1 /* Single cell network */
240+#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
241+#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
242+#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
243+#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
244+
245+/* Maximum number of size of encoding token available
246+ * they are listed in the range structure */
247+#define IW_MAX_ENCODING_SIZES 8
248+
249+/* Maximum size of the encoding token in bytes */
250+#define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
251+
252+/* Flags for encoding (along with the token) */
253+#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
254+#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
255+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
256+#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
257+#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
258+#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
259+#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
260+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
261+
262+/* Power management flags available (along with the value, if any) */
263+#define IW_POWER_ON 0x0000 /* No details... */
264+#define IW_POWER_TYPE 0xF000 /* Type of parameter */
265+#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
266+#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
267+#define IW_POWER_MODE 0x0F00 /* Power Management mode */
268+#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
269+#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
270+#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
271+#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
272+#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
273+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
274+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
275+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
276+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
277+
278+/* Transmit Power flags available */
279+#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
280+#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
281+
282+/* Retry limits and lifetime flags available */
283+#define IW_RETRY_ON 0x0000 /* No details... */
284+#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
285+#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
286+#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
287+#define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
288+#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
289+#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
290+#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
291+
292+/****************************** TYPES ******************************/
293+
294+/* --------------------------- SUBTYPES --------------------------- */
295+/*
296+ * Generic format for most parameters that fit in an int
297+ */
298+struct iw_param
299+{
300+ __s32 value; /* The value of the parameter itself */
301+ __u8 fixed; /* Hardware should not use auto select */
302+ __u8 disabled; /* Disable the feature */
303+ __u16 flags; /* Various specifc flags (if any) */
304+};
305+
306+/*
307+ * For all data larger than 16 octets, we need to use a
308+ * pointer to memory alocated in user space.
309+ */
310+struct iw_point
311+{
312+ caddr_t pointer; /* Pointer to the data (in user space) */
313+ __u16 length; /* number of fields or size in bytes */
314+ __u16 flags; /* Optional params */
315+};
316+
317+/*
318+ * A frequency
319+ * For numbers lower than 10^9, we encode the number in 'm' and
320+ * set 'e' to 0
321+ * For number greater than 10^9, we divide it by the lowest power
322+ * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
323+ * The power of 10 is in 'e', the result of the division is in 'm'.
324+ */
325+struct iw_freq
326+{
327+ __u32 m; /* Mantissa */
328+ __u16 e; /* Exponent */
329+ __u8 i; /* List index (when in range struct) */
330+};
331+
332+/*
333+ * Quality of the link
334+ */
335+struct iw_quality
336+{
337+ __u8 qual; /* link quality (%retries, SNR or better...) */
338+ __u8 level; /* signal level */
339+ __u8 noise; /* noise level */
340+ __u8 updated; /* Flags to know if updated */
341+};
342+
343+/*
344+ * Packet discarded in the wireless adapter due to
345+ * "wireless" specific problems...
346+ */
347+struct iw_discarded
348+{
349+ __u32 nwid; /* Wrong nwid */
350+ __u32 code; /* Unable to code/decode */
351+ __u32 misc; /* Others cases */
352+};
353+
354+/* ------------------------ WIRELESS STATS ------------------------ */
355+/*
356+ * Wireless statistics (used for /proc/net/wireless)
357+ */
358+struct iw_statistics
359+{
360+ __u16 status; /* Status
361+ * - device dependent for now */
362+
363+ struct iw_quality qual; /* Quality of the link
364+ * (instant/mean/max) */
365+ struct iw_discarded discard; /* Packet discarded counts */
366+};
367+
368+/* ------------------------ IOCTL REQUEST ------------------------ */
369+/*
370+ * The structure to exchange data for ioctl.
371+ * This structure is the same as 'struct ifreq', but (re)defined for
372+ * convenience...
373+ *
374+ * Note that it should fit on the same memory footprint !
375+ * You should check this when increasing the above structures (16 octets)
376+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
377+ */
378+struct iwreq
379+{
380+ union
381+ {
382+ char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
383+ } ifr_ifrn;
384+
385+ /* Data part */
386+ union
387+ {
388+ /* Config - generic */
389+ char name[IFNAMSIZ];
390+ /* Name : used to verify the presence of wireless extensions.
391+ * Name of the protocol/provider... */
392+
393+ struct iw_point essid; /* Extended network name */
394+ struct iw_param nwid; /* network id (or domain - the cell) */
395+ struct iw_freq freq; /* frequency or channel :
396+ * 0-1000 = channel
397+ * > 1000 = frequency in Hz */
398+
399+ struct iw_param sens; /* signal level threshold */
400+ struct iw_param bitrate; /* default bit rate */
401+ struct iw_param txpower; /* default transmit power */
402+ struct iw_param rts; /* RTS threshold threshold */
403+ struct iw_param frag; /* Fragmentation threshold */
404+ __u32 mode; /* Operation mode */
405+ struct iw_param retry; /* Retry limits & lifetime */
406+
407+ struct iw_point encoding; /* Encoding stuff : tokens */
408+ struct iw_param power; /* PM duration/timeout */
409+
410+ struct sockaddr ap_addr; /* Access point address */
411+
412+ struct iw_point data; /* Other large parameters */
413+ } u;
414+};
415+
416+/* -------------------------- IOCTL DATA -------------------------- */
417+/*
418+ * For those ioctl which want to exchange mode data that what could
419+ * fit in the above structure...
420+ */
421+
422+/*
423+ * Range of parameters
424+ */
425+
426+struct iw_range
427+{
428+ /* Informative stuff (to choose between different interface) */
429+ __u32 throughput; /* To give an idea... */
430+ /* In theory this value should be the maximum benchmarked
431+ * TCP/IP throughput, because with most of these devices the
432+ * bit rate is meaningless (overhead an co) to estimate how
433+ * fast the connection will go and pick the fastest one.
434+ * I suggest people to play with Netperf or any benchmark...
435+ */
436+
437+ /* NWID (or domain id) */
438+ __u32 min_nwid; /* Minimal NWID we are able to set */
439+ __u32 max_nwid; /* Maximal NWID we are able to set */
440+
441+ /* Frequency */
442+ __u16 num_channels; /* Number of channels [0; num - 1] */
443+ __u8 num_frequency; /* Number of entry in the list */
444+ struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
445+ /* Note : this frequency list doesn't need to fit channel numbers */
446+
447+ /* signal level threshold range */
448+ __s32 sensitivity;
449+
450+ /* Quality of link & SNR stuff */
451+ struct iw_quality max_qual; /* Quality of the link */
452+
453+ /* Rates */
454+ __u8 num_bitrates; /* Number of entries in the list */
455+ __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
456+
457+ /* RTS threshold */
458+ __s32 min_rts; /* Minimal RTS threshold */
459+ __s32 max_rts; /* Maximal RTS threshold */
460+
461+ /* Frag threshold */
462+ __s32 min_frag; /* Minimal frag threshold */
463+ __s32 max_frag; /* Maximal frag threshold */
464+
465+ /* Power Management duration & timeout */
466+ __s32 min_pmp; /* Minimal PM period */
467+ __s32 max_pmp; /* Maximal PM period */
468+ __s32 min_pmt; /* Minimal PM timeout */
469+ __s32 max_pmt; /* Maximal PM timeout */
470+ __u16 pmp_flags; /* How to decode max/min PM period */
471+ __u16 pmt_flags; /* How to decode max/min PM timeout */
472+ __u16 pm_capa; /* What PM options are supported */
473+
474+ /* Encoder stuff */
475+ __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
476+ __u8 num_encoding_sizes; /* Number of entry in the list */
477+ __u8 max_encoding_tokens; /* Max number of tokens */
478+
479+ /* Transmit power */
480+ __u16 txpower_capa; /* What options are supported */
481+ __u8 num_txpower; /* Number of entries in the list */
482+ __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
483+
484+ /* Wireless Extension version info */
485+ __u8 we_version_compiled; /* Must be WIRELESS_EXT */
486+ __u8 we_version_source; /* Last update of source */
487+
488+ /* Retry limits and lifetime */
489+ __u16 retry_capa; /* What retry options are supported */
490+ __u16 retry_flags; /* How to decode max/min retry limit */
491+ __u16 r_time_flags; /* How to decode max/min retry life */
492+ __s32 min_retry; /* Minimal number of retries */
493+ __s32 max_retry; /* Maximal number of retries */
494+ __s32 min_r_time; /* Minimal retry lifetime */
495+ __s32 max_r_time; /* Maximal retry lifetime */
496+};
497+
498+/*
499+ * Private ioctl interface information
500+ */
501+
502+struct iw_priv_args
503+{
504+ __u32 cmd; /* Number of the ioctl to issue */
505+ __u16 set_args; /* Type and number of args */
506+ __u16 get_args; /* Type and number of args */
507+ char name[IFNAMSIZ]; /* Name of the extension */
508+};
509+
510+#endif /* _LINUX_WIRELESS_H */
--- a/wireless_tools/xwireless.c
+++ /dev/null
@@ -1,241 +0,0 @@
1-/* Xwireless.c, status: experimental, do not distribute!! */
2-#include <stdio.h>
3-#include <getopt.h>
4-#include <sys/types.h>
5-
6-#include <stdlib.h>
7-#include <string.h>
8-#include <unistd.h>
9-#include <ctype.h>
10-
11-#include <X11/Intrinsic.h>
12-#include <X11/StringDefs.h>
13-#include <X11/cursorfont.h>
14-#include <X11/Xaw/Form.h>
15-#include <X11/Xaw/Label.h>
16-#include <X11/Xaw/Scrollbar.h>
17-
18-#include <linux/wireless.h>
19-
20-char* status[] = { "Scanning","Registering","Best AP","Good AP",
21- "Poor AP","Active Beacon Search","Static Load Balance",
22- "Balance Search" };
23-
24-typedef struct privateData {
25- char *ifname;
26- Pixel currentColor;
27- Pixel highColor;
28- Pixel lowColor;
29- Pixel criticalColor;
30- Pixel foreground;
31- int highValue;
32- int lowValue;
33- int delay;
34- String geometry;
35- struct iw_statistics stats;
36- struct iw_range range;
37-} privateData;
38-
39-static XtAppContext app_context;
40-static Widget scrollbar;
41-static Widget topLevel;
42-static Widget label;
43-static XtIntervalId timerId;
44-static privateData priv;
45-
46-static int getstats(char *ifname, struct iw_statistics *stats)
47-{
48- struct iwreq wrq;
49- FILE *f=fopen("/proc/net/wireless","r");
50- char buf[256];
51- char *bp;
52- if(f==NULL)
53- return -1;
54- while(fgets(buf,255,f))
55- {
56- bp=buf;
57- while(*bp&&isspace(*bp))
58- bp++;
59- if( strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':') {
60- bp=strchr(bp,':');
61- bp++;
62- bp = strtok(bp, " .");
63- sscanf(bp, "%X", &stats->status);
64- bp = strtok(NULL, " .");
65- sscanf(bp, "%d", &stats->qual.qual);
66- bp = strtok(NULL, " .");
67- sscanf(bp, "%d", &stats->qual.level);
68- bp = strtok(NULL, " .");
69- sscanf(bp, "%d", &stats->qual.noise);
70- bp = strtok(NULL, " .");
71- sscanf(bp, "%d", &stats->discard.nwid);
72- bp = strtok(NULL, " .");
73- sscanf(bp, "%d", &stats->discard.code);
74- bp = strtok(NULL, " .");
75- sscanf(bp, "%d", &stats->discard.misc);
76- fclose(f);
77- return 0;
78- } else {
79- stats->status = -1;
80- stats->qual.qual = 0;
81- stats->qual.level = 0;
82- stats->qual.noise = 0;
83- }
84- }
85- fclose(f);
86-
87- /*strcpy(wrq.ifr_name, ifname);
88- wrq.u.data.pointer = (caddr_t) &range;
89- wrq.u.data.length = 0;
90- wrq.u.data.flags = 0;
91- if(ioctl(skfd, SIOCGIWRANGE, &wrq) >= 0) {
92- info->has_range = 1;
93- }*/
94-
95- return 0;
96-}
97-
98-static void update( XtPointer client_data, XtIntervalId *id )
99-{
100- char buf[128];
101- static int pixel = -1;
102- static int lpixel = -1;
103- static int bpixel = -1;
104-
105- getstats( priv.ifname, &(priv.stats));
106-
107- if(status < 8)
108- sprintf( buf, "%s", status[priv.stats.status] );
109- else
110- sprintf( buf, "%s", "buggy" );
111- XtVaSetValues( label, XtNlabel, buf, NULL );
112-
113- if (priv.stats.qual.qual <= priv.lowValue) {
114- if (pixel != priv.criticalColor)
115- XtVaSetValues( scrollbar, XtNforeground,
116- pixel = priv.criticalColor, NULL );
117- if (bpixel != priv.criticalColor)
118- XtVaSetValues( scrollbar, XtNborderColor,
119- bpixel = priv.criticalColor, NULL );
120- } else if (priv.stats.qual.qual <= priv.highValue) {
121- if (pixel != priv.lowColor)
122- XtVaSetValues( scrollbar,
123- XtNforeground, pixel = priv.lowColor, NULL );
124- if (bpixel != priv.foreground)
125- XtVaSetValues( scrollbar, XtNborderColor,
126- bpixel = priv.foreground, NULL );
127- } else {
128- if (pixel != priv.highColor )
129- XtVaSetValues( scrollbar,
130- XtNforeground, pixel = priv.highColor, NULL );
131- }
132-
133- XawScrollbarSetThumb( scrollbar, 0.0, priv.stats.qual.qual / 255.0 );
134-
135- timerId = XtAppAddTimeOut( app_context, 1000 , update, app_context );
136-}
137-
138-#define offset(field) XtOffsetOf( privateData, field )
139-static XtResource resources[] = {
140- { "highColor", XtCForeground, XtRPixel, sizeof(Pixel),
141- offset(highColor), XtRString, "green" },
142- { "lowColor", XtCForeground, XtRPixel, sizeof(Pixel),
143- offset(lowColor), XtRString, "orange" },
144- { "criticalColor", XtCForeground, XtRPixel, sizeof(Pixel),
145- offset(criticalColor), XtRString, "red" },
146- { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
147- offset(foreground), XtRString, XtDefaultForeground },
148- { "highValue", XtCValue, XtRInt, sizeof(int),
149- offset(highValue), XtRImmediate, (XtPointer)50 },
150- { "lowValue", XtCValue, XtRInt, sizeof(int),
151- offset(lowValue), XtRImmediate, (XtPointer)10 },
152- { "geometry", XtCString, XtRString, sizeof( String ),
153- offset(geometry), XtRString, (XtPointer)"10x100" },
154- { "delay", XtCValue, XtRInt, sizeof(int),
155- offset(delay), XtRImmediate, (XtPointer)1 },
156-};
157-
158-int main( int argc, char **argv ) {
159- Cursor cursor;
160- int c;
161- Widget form;
162- XFontStruct *fs;
163- int fontWidth, fontHeight;
164- int width = 120;
165-
166- /* The device name must be the first argument */
167- if(argc < 2) {
168- printf("Hmm\n");
169- }
170- priv.ifname = argv[1];
171-
172- if( priv.ifname == (char *) NULL) {
173- printf("Usage: xwireless <interface>\n");
174- exit(-1);
175- }
176-
177- topLevel = XtVaAppInitialize( &app_context, "Xwireless",
178- NULL, 0,
179- &argc, argv, NULL, NULL );
180-
181- XtGetApplicationResources( topLevel,
182- &priv,
183- resources,
184- XtNumber( resources ),
185- NULL, 0 );
186- priv.lowValue = 85;
187- priv.highValue = 170;
188-
189-/* printf( "highColor = %ld\n", priv.highColor );
190- printf( "lowColor = %ld\n", priv.lowColor );
191- printf( "criticalColor = %ld\n", priv.criticalColor );
192- printf( "foreground = %ld\n", priv.foreground );
193- printf( "highValue = %d\n", priv.highValue );
194- printf( "lowValue = %d\n", priv.lowValue );
195- printf( "geometry = %s\n", priv.geometry );*/
196-
197- cursor = XCreateFontCursor( XtDisplay( topLevel ), XC_top_left_arrow );
198-
199- form = XtVaCreateManagedWidget( "form",
200- formWidgetClass, topLevel,
201- XtNorientation, XtorientHorizontal,
202- XtNborderWidth, 0,
203- XtNdefaultDistance, 2,
204- NULL );
205-
206- label = XtVaCreateManagedWidget( "label",
207- labelWidgetClass, form,
208- XtNleft, XtChainLeft,
209- XtNinternalHeight, 0,
210- XtNinternalWidth, 0,
211- XtNborderWidth, 0,
212- XtNlabel, "Status",
213- NULL );
214-
215- XtVaGetValues( label, XtNfont, &fs, NULL );
216- fontWidth = fs->max_bounds.width;
217- fontHeight = fs->max_bounds.ascent + fs->max_bounds.descent;
218- XtVaSetValues( label, XtNwidth, fontWidth * 8, NULL );
219-
220- scrollbar = XtVaCreateManagedWidget( "scrollbar",
221- scrollbarWidgetClass, form,
222- XtNhorizDistance, 3,
223- XtNfromHoriz, label,
224- XtNorientation, XtorientHorizontal,
225- XtNscrollHCursor, cursor,
226- XtNthickness, fontHeight,
227- XtNlength, (width > fontWidth*4 - 6)
228- ? width - fontWidth * 4 - 6
229- : fontWidth * 4,
230- NULL );
231-
232- XawScrollbarSetThumb( scrollbar, 0.0, 0.0 );
233-/* XtVaSetValues( scrollbar,
234- XtNtranslations, XtParseTranslationTable( "" ), NULL );
235- */
236- XtRealizeWidget( topLevel );
237- timerId = XtAppAddTimeOut( app_context, 0, update, app_context );
238- XtAppMainLoop( app_context );
239-
240- return 0;
241-}
--- a/wireless_tools/xwireless.make
+++ /dev/null
@@ -1,53 +0,0 @@
1-# Makefile for Xwireless
2-CC = gcc
3-RM = rm -f
4-
5-RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a
6-
7-INCLUDES = $(SYS_INCLUDES) $(LOCAL_INCLUDES)
8-LIBRARIES = $(LOCAL_LIBRARIES) $(SYS_LIBRARIES)
9-LIBPATH = $(SYS_LIBPATH) $(LOCAL_LIBPATH)
10-
11-#
12-# System stuff
13-#
14-SYS_INCLUDES = -I/usr/include -I/usr/X11R6/include
15-SYS_LIBRARIES = -lXaw -lXmu -lXt -lXext -lSM -lICE -lX11
16-SYS_LIBPATH = -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib
17-
18-#
19-# Local stuff
20-#
21-LOCAL_INCLUDES =
22-LOCAL_LIBRARIES =
23-LOCAL_LIBPATH =
24-
25-XTRACFLAGS=-Wall -pipe -I.
26-
27-# Uncomment these lines for a production compile
28-#CFLAGS=-O3 -m486 -fomit-frame-pointer
29-#LDFLAGS=-s
30-CFLAGS=-g
31-
32-#
33-# Files to make
34-#
35-PROGS=xwireless
36-
37-SRCS = $(PROGS).c
38-OBJS = $(PROGS).o
39-
40-all:: $(PROGS)
41-
42-xwireless: $(OBJS)
43- $(CC) $(CFLAGS) -o $@ $(OBJS) $(INCLUDES) $(LIBPATH) $(LIBRARIES)
44-
45-.c.o:
46- $(CC) $(CFLAGS) $(XTRACFLAGS) -c $(INCLUDES) -DNARROWPROTO $<
47-
48-clean::
49- $(RM_CMD)
50-
51-depend::
52- makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS)
53-# DO NOT DELETE