Codebase list reaver / 24d8511
New upstream version 1.6.1 Sophie Brun 6 years ago
79 changed file(s) with 228 addition(s) and 28463 deletion(s). Raw diff Collapse all Expand all
66 src/wash
77 src/reaver
88 src/config.log
9 src/config.mak
910 src/config.status
1011 src/config.h
1112 src/autom4te.cache
12 src/Makefile
1313
7070
7171 ## Deprecated and temporary left behind options
7272
73 **- n** (reaver): Automatically enabled, no need to invocate it.
74 **- W** (reaver): Temporary left behind. Integration of the default PIN generators was unstable, leading to many warnings at compilation time. It was also an issue to use a PIN attempt (risk of AP rating limit) in order to get a BSSID and an ESSID. For the moment PIN generation has to be done externally using the scripts provided in "doc"
75 - a (reaver): This option was the only option which required sqlite3 adding an extra dependency. It was only designed for automation scripts and this task (execute the last reaver command again) can be easily done internally by the script that calls reaver
76 - p1 and -p2 (reaver): Too much warnings and bugs.
77 - H (reaver): There is a need to find a way to perform it more cleanly, work is in progress
78 - vvv (reaver): The highest level of verbose is temporary removed for the same reason.
79 - g (wash): Option was broken in latest release and need to be seriously rethought.
73 * **- n** (reaver): Automatically enabled, no need to invocate it.
74 * **- W** (reaver): Temporary left behind. Integration of the default PIN generators was unstable, leading to many warnings at compilation time. It was also an issue to use a PIN attempt (risk of AP rating limit) in order to get a BSSID and an ESSID. For the moment PIN generation has to be done externally using the scripts provided in "doc".
75 * **- a** (reaver): This option was the only option which required sqlite3 adding an extra dependency. It was only designed for automation scripts and this task (execute the last reaver command again) can be easily done internally by the script that calls reaver
76 * **- p1** and **-p2** (reaver): Too much warnings and bugs.
77 * **-H** (reaver): There is a need to find a way to perform it more cleanly, work is in progress.
78 * **- vvv** (reaver): The highest level of verbose is temporary removed for the same reason.
79 * **- g** (wash): Option was broken in latest release and need to be seriously rethought.
8080
8181 ## Options repaired/solved issues
8282
83 Issues with -g and -p (and their crossed usage) are left behind.
84 Code is much more clean, robust and has less dependencies.
85 We know that it looks like at first time as a regression but it is not!
83 Issues with -g and -p (and their crossed usage) are left behind.
84 Code is much more clean, robust and has less dependencies.
85 We know that it looks like at first time as a regression but it is not!
8686 We were stuck with issues for years due the dificulty of the task and the lack of global direction.
87 Now we have a much healthier base and it will be worth it.
88
87 Now we have a much healthier base and it will be worth it.
88
8989 # Acknowledgements
9090
9191 ## Contribution
92 Creator of reaver-wps-fork-t6x "community edition":
93 `t6x`
94
95 Main developer since version 1.6b:
96 `rofl0r`
9297
93 Main developer since version 1.6b
94 `rofl0r`
95
96 Credits for previous reaver community versions:
9798 Modifications made by:
98 `t6_x`, `DataHead`, `Soxrok2212`, `Wiire`, `AAnarchYY`, `kib0rg`, `KokoSoft`, `rofl0r`, `horrorho`
99 `t6_x`, `DataHead`, `Soxrok2212`, `Wiire`, `AAnarchYY`, `kib0rg`, `KokoSoft`, `rofl0r`, `horrorho`, `binarymaster`, `Ǹotaz`
99100
100101 Some ideas made by:
101102 `nuroo`, `kcdtv`
9898 __cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON))
9999 {
100100 beacon = (struct beacon_management_frame *) (packet + rt_header_len + sizeof(struct dot11_frame_header));
101 set_ap_capability(beacon->capability);
101 set_ap_capability(__le16_to_cpu(beacon->capability));
102102
103103 /* Obtain the SSID and channel number from the beacon packet */
104104 tag_offset = rt_header_len + sizeof(struct dot11_frame_header) + sizeof(struct beacon_management_frame);
131131 int8_t ssi = 0;
132132 int offset = sizeof(struct radio_tap_header);
133133 struct radio_tap_header *header = NULL;
134 uint32_t flags, flags2;
134135
135136 if(has_rt_header() && (len > (sizeof(struct radio_tap_header) + TSFT_SIZE + FLAGS_SIZE + RATE_SIZE + CHANNEL_SIZE + FHSS_FLAG)))
136137 {
137138 header = (struct radio_tap_header *) packet;
138139
139 uint32_t flags = __le32_to_cpu(header->flags);
140
140 flags = flags2 = __le32_to_cpu(header->flags);
141 while ((flags2 & (1u << 31)) && offset <= len - 4)
142 {
143 flags2 = __le32_to_cpu(*(uint32_t *)(packet + offset));
144 offset += sizeof(flags2);
145 }
146
141147 if((flags & SSI_FLAG) == SSI_FLAG)
142148 {
143149 if((flags & TSFT_FLAG) == TSFT_FLAG)
144150 {
151 RADIOTAP_ALIGN(offset, TSFT_ALIGNMENT);
145152 offset += TSFT_SIZE;
146153 }
147154
157164
158165 if((flags & CHANNEL_FLAG) == CHANNEL_FLAG)
159166 {
167 RADIOTAP_ALIGN(offset, CHANNEL_ALIGNMENT);
160168 offset += CHANNEL_SIZE;
161169 }
162170
163171 if((flags & FHSS_FLAG) == FHSS_FLAG)
164172 {
165 offset += FHSS_FLAG;
173 offset += FHSS_SIZE;
166174 }
167175
168176 if(offset < len)
0 -include config.mak
1
2 LIBWPS_DIR=libwps
3 INC=-Ilibwps -I. -Ilwe
4
5 DISABLED_WARNINGS= \
6 -Wno-unused-variable \
7 -Wno-unused-but-set-variable \
8 -Wno-unused-function \
9 -Wno-pointer-sign
10
11 CFLAGS=-DCONF_DIR='"$(CONFDIR)"' $(CFLAGS_USER) $(DISABLED_WARNINGS)
12 CFLAGS += $(INC)
13
14 WPS_OBJS=wps/wps_attr_build.o wps/wps_attr_parse.o wps/wps_attr_process.o \
15 wps/wps.o wps/wps_common.o wps/wps_dev_attr.o wps/wps_enrollee.o \
16 wps/wps_registrar.o wps/wps_ufd.o
17
18 LWE_OBJS=lwe/iwlib.o
19
20 LIB_OBJS=libwps/libwps.o $(WPS_OBJS) utils/libutils.a \
21 crypto/libcrypto.a tls/libtls.a $(LWE_OBJS)
22
23 WASH_OBJS=globule.o init.o misc.o 80211.o iface.o \
24 builder.o crc.o pixie.o
25 REAVER_OBJS=argsparser.o globule.o init.o sigint.o iface.o sigalrm.o \
26 misc.o cracker.o session.o send.o pins.o 80211.o exchange.o builder.o \
27 keys.o crc.o pixie.o
28
29 # Version of the Wireless Tools
30 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < lwe/iwlib.h )
31 # Version of Wireless Extensions.
32 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < lwe/iwlib.h )
33 # Always use local header for wireless extensions
34 WEXT_HEADER = lwe/wireless.$(WE_VERSION).h
35
36
37 all: wash reaver
38
39 $(WPS_OBJS): CFLAGS+=-I. -Iutils
40
41 wash: $(WASH_OBJS) $(LIB_OBJS)
42 $(CC) $(CFLAGS) $(INC) wpsmon.c $(WASH_OBJS) $(LIB_OBJS) $(LDFLAGS) -o wash
43
44 reaver: $(REAVER_OBJS) $(LIB_OBJS)
45 $(CC) $(CFLAGS) $(INC) wpscrack.c $(REAVER_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
46
47 utils/libutils.a:
48 (cd utils && make)
49
50 crypto/libcrypto.a: tls/libtls.a
51 (cd crypto && make)
52
53 tls/libtls.a:
54 (cd tls && make)
55
56 lwe/wireless.h: $(WEXT_HEADER)
57 cp $(WEXT_HEADER) lwe/wireless.h
58
59 $(WASH_OBJS) $(REAVER_OBJS) $(LWE_OBJS): lwe/wireless.h
60
61 install: wash reaver
62 install -D -m 755 wash $(DESTDIR)$(exec_prefix)/bin/wash
63 install -D -m 755 reaver $(DESTDIR)$(exec_prefix)/bin/reaver
64 @# create directory used to store *.wpc files;
65 @# if not found defaults to "." i.e. current dir
66 install -d $(DESTDIR)$(CONFDIR)
67
68 clean:
69 rm -f *~ *.o reaver wash
70 rm -rf *.cache config.status config.log
71 rm -f $(LIB_OBJS)
72 (cd utils && make clean)
73 (cd tls && make clean)
74 (cd crypto && make clean)
75 rm -f lwe/wireless.h
76
77 cleanbin:
78 rm -f @bindir@/reaver @bindir@/wash @bindir@/walsh
79
80 distclean: cleanbin clean
81 rm -rf $(CONFDIR)
82
83 .PHONY: all clean cleanbin distclean install
84
+0
-126
src/Makefile.in less more
0 CC=@CC@
1 LIBWPS_DIR=libwps
2 INC=-Ilibwps -I.
3 prefix=@prefix@
4 exec_prefix=@exec_prefix@
5 CONFDIR=@sysconfdir@/@target@
6
7 DISABLED_WARNINGS= \
8 -Wno-unused-variable \
9 -Wno-unused-but-set-variable \
10 -Wno-unused-function \
11 -Wno-pointer-sign
12
13 CFLAGS=-DCONF_DIR='"$(CONFDIR)"' @CFLAGS@ $(DISABLED_WARNINGS)
14
15 WPS_OBJS=wps/wps_attr_build.o wps/wps_attr_parse.o wps/wps_attr_process.o \
16 wps/wps.o wps/wps_common.o wps/wps_dev_attr.o wps/wps_enrollee.o \
17 wps/wps_registrar.o wps/wps_ufd.o
18
19
20 LIB_OBJS=libwps/libwps.o $(WPS_OBJS) utils/libutils.a \
21 crypto/libcrypto.a tls/libtls.a
22
23 LDFLAGS=@LDFLAGS@
24
25 LIB_OBJS+=lwe/libiw.a
26 LIBIWNAME=libiw
27
28 WASH_OBJS=globule.o init.o misc.o 80211.o iface.o \
29 builder.o crc.o pixie.o
30 REAVER_OBJS=argsparser.o globule.o init.o sigint.o iface.o sigalrm.o \
31 misc.o cracker.o session.o send.o pins.o 80211.o exchange.o builder.o \
32 keys.o crc.o pixie.o
33
34 all: wash reaver
35
36 $(WPS_OBJS): CFLAGS+=-I. -Iutils
37
38 wash: $(LIBIWNAME) $(WASH_OBJS) $(LIB_OBJS)
39 $(CC) $(CFLAGS) $(INC) wpsmon.c $(WASH_OBJS) $(LIB_OBJS) $(LDFLAGS) -o wash
40
41 reaver: $(LIBIWNAME) $(REAVER_OBJS) $(LIB_OBJS)
42 $(CC) $(CFLAGS) $(INC) wpscrack.c $(REAVER_OBJS) $(LIB_OBJS) $(LDFLAGS) -o reaver
43
44 utils/libutils.a:
45 (cd utils && make)
46
47 crypto/libcrypto.a: tls/libtls.a
48 (cd crypto && make)
49
50 tls/libtls.a:
51 (cd tls && make)
52
53 libiw:
54 (cd lwe && make BUILD_STATIC=y libiw.a)
55
56 init.o:
57 $(CC) $(CFLAGS) init.c -c
58
59 crc.o:
60 $(CC) $(CFLAGS) crc.c -c
61
62 keys.o:
63 $(CC) $(CFLAGS) keys.c -c
64
65 argsparser.o: globule.o
66 $(CC) $(CFLAGS) $(INC) argsparser.c -c
67
68 sigint.o: globule.o
69 $(CC) $(CFLAGS) $(INC) sigint.c -c
70
71 exchange.o: globule.o send.o sigalrm.o 80211.o
72 $(CC) $(CFLAGS) $(INC) exchange.c -c
73
74 send.o: globule.o builder.o sigalrm.o
75 $(CC) $(CFLAGS) send.c -c
76
77 session.o: globule.o
78 $(CC) $(CFLAGS) $(INC) session.c -c
79
80 80211.o: globule.o builder.o crc.o
81 $(CC) $(CFLAGS) $(INC) 80211.c -c
82
83 iface.o: globule.o
84 $(CC) $(CFLAGS) iface.c -c
85
86 sigalrm.o: globule.o
87 $(CC) $(CFLAGS) sigalrm.c -c
88
89 misc.o: globule.o
90 $(CC) $(CFLAGS) misc.c -c
91
92 builder.o: globule.o
93 $(CC) $(CFLAGS) builder.c -c
94
95 pins.o: globule.o keys.o
96 $(CC) $(CFLAGS) pins.c -c
97
98 cracker.o: globule.o init.o pins.o iface.o exchange.o session.o 80211.o
99 $(CC) $(CFLAGS) $(INC) cracker.c -c
100
101 globule.o:
102 $(CC) $(CFLAGS) globule.c -c
103
104 install: wash reaver
105 install -D -m 755 wash $(DESTDIR)$(exec_prefix)/bin/wash
106 install -D -m 755 reaver $(DESTDIR)$(exec_prefix)/bin/reaver
107
108 clean:
109 rm -f *~ *.o reaver wash
110 rm -rf *.cache config.status config.log
111 rm -f $(LIB_OBJS)
112 (cd utils && make clean)
113 (cd tls && make clean)
114 (cd crypto && make clean)
115 (cd lwe && make realclean)
116 rm -f Makefile config.h
117
118 cleanbin:
119 rm -f @bindir@/reaver @bindir@/wash @bindir@/walsh
120
121 distclean: cleanbin clean
122 rm -rf $(CONFDIR)
123
124 .PHONY: libiw clean cleanbin distclean install
125
200200 set_oo_send_nack(1);
201201 set_wifi_band(BG_BAND);
202202 pixie.do_pixie = 0;
203 set_pin_string_mode(0);
203204 }
204205
205206 /* Parses the recurring delay optarg */
222223 free(x);
223224 }
224225
226 int is_valid_pin(char *pin)
227 {
228 if(!pin)
229 return 0;
230
231 int i;
232 for (i = 0; i < strlen(pin); i++)
233 {
234 if(!isdigit(pin[i]))
235 return 0;
236 }
237 if(strlen(pin) == 8)
238 {
239 char pin7[8] = { 0 };
240 char pin8[9] = { 0 };
241 memcpy((void *) &pin7, pin, sizeof(pin7)-1);
242 snprintf(pin8, 9, "%s%d", pin7, wps_pin_checksum(atoi(pin7)));
243 if (strcmp(pin, pin8) != 0)
244 return 0;
245 }
246 return 1;
247 }
248
225249 /* Parse the WPS pin to use into p1 and p2 */
226250 void parse_static_pin(char *pin)
227251 {
233257 {
234258 len = strlen(pin);
235259
236 if(len == 4 || len == 7 || len == 8)
260 if((len == 4 || len == 7 || len == 8) && is_valid_pin(pin) != 0)
237261 {
238262 memcpy((void *) &p1, pin, sizeof(p1)-1);
239263 set_static_p1((char *) &p1);
247271 }
248272 else
249273 {
250 cprintf(CRITICAL, "[X] ERROR: Invalid pin specified! Ignoring '%s'.\n", pin);
274 //cprintf(CRITICAL, "[X] ERROR: Invalid pin specified! Ignoring '%s'.\n", pin);
275 set_max_pin_attempts(1);
276 set_pin_string_mode(1);
277 set_static_p1(pin);
251278 }
252279 }
253280 }
0 prefix=@prefix@
1 exec_prefix=@exec_prefix@
2 CONFDIR=@localstatedir@/lib/@target@
3
4 CC=@CC@
5 CFLAGS_USER=@CFLAGS@
6 LDFLAGS=@LDFLAGS@
7
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for reaver 1.6b.
2 # Generated by GNU Autoconf 2.69 for reaver 1.6.1.
33 #
44 #
55 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
576576 # Identity of this package.
577577 PACKAGE_NAME='reaver'
578578 PACKAGE_TARNAME='reaver'
579 PACKAGE_VERSION='1.6b'
580 PACKAGE_STRING='reaver 1.6b'
579 PACKAGE_VERSION='1.6.1'
580 PACKAGE_STRING='reaver 1.6.1'
581581 PACKAGE_BUGREPORT=''
582582 PACKAGE_URL=''
583583
12221222 # Omit some internal or obsolete options to make the list less imposing.
12231223 # This message is too long to be a string in the A/UX 3.1 sh.
12241224 cat <<_ACEOF
1225 \`configure' configures reaver 1.6b to adapt to many kinds of systems.
1225 \`configure' configures reaver 1.6.1 to adapt to many kinds of systems.
12261226
12271227 Usage: $0 [OPTION]... [VAR=VALUE]...
12281228
12831283
12841284 if test -n "$ac_init_help"; then
12851285 case $ac_init_help in
1286 short | recursive ) echo "Configuration of reaver 1.6b:";;
1286 short | recursive ) echo "Configuration of reaver 1.6.1:";;
12871287 esac
12881288 cat <<\_ACEOF
12891289
13711371 test -n "$ac_init_help" && exit $ac_status
13721372 if $ac_init_version; then
13731373 cat <<\_ACEOF
1374 reaver configure 1.6b
1374 reaver configure 1.6.1
13751375 generated by GNU Autoconf 2.69
13761376
13771377 Copyright (C) 2012 Free Software Foundation, Inc.
16691669 This file contains any messages produced by compilers while
16701670 running configure, to aid debugging if configure makes a mistake.
16711671
1672 It was created by reaver $as_me 1.6b, which was
1672 It was created by reaver $as_me 1.6.1, which was
16731673 generated by GNU Autoconf 2.69. Invocation command line was
16741674
16751675 $ $0 $@
20172017 ac_compiler_gnu=$ac_cv_c_compiler_gnu
20182018
20192019
2020 ac_config_files="$ac_config_files config.mak"
20202021
20212022 ac_ext=c
20222023 ac_cpp='$CPP $CPPFLAGS'
33013302 cp confdefs.h config.h
33023303
33033304 target=$PACKAGE_NAME
3304
3305 ac_config_files="$ac_config_files Makefile"
33063305
33073306 cat >confcache <<\_ACEOF
33083307 # This file is a shell script that caches the results of configure
38463845 # report actual input values of CONFIG_FILES etc. instead of their
38473846 # values after options handling.
38483847 ac_log="
3849 This file was extended by reaver $as_me 1.6b, which was
3848 This file was extended by reaver $as_me 1.6.1, which was
38503849 generated by GNU Autoconf 2.69. Invocation command line was
38513850
38523851 CONFIG_FILES = $CONFIG_FILES
38993898 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
39003899 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
39013900 ac_cs_version="\\
3902 reaver config.status 1.6b
3901 reaver config.status 1.6.1
39033902 configured by $0, generated by GNU Autoconf 2.69,
39043903 with options \\"\$ac_cs_config\\"
39053904
40094008 for ac_config_target in $ac_config_targets
40104009 do
40114010 case $ac_config_target in
4012 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
4011 "config.mak") CONFIG_FILES="$CONFIG_FILES config.mak" ;;
40134012
40144013 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
40154014 esac
0 AC_INIT(reaver, 1.6b)
1
0 AC_INIT(reaver, 1.6.1)
1 AC_CONFIG_FILES([config.mak])
22 AC_PROG_CC
33 AC_LANG(C)
44
1717 cp confdefs.h config.h
1818
1919 AC_SUBST(target, $PACKAGE_NAME)
20 AC_OUTPUT(Makefile)
20 AC_OUTPUT()
160160 }
161161 else
162162 {
163 cprintf(WARNING, "[+] Trying pin %s\n", pin);
163 cprintf(WARNING, "[+] Trying pin \"%s\"\n", pin);
164164 }
165165
166166 /*
9292 #define RATE_SIZE 1
9393 #define CHANNEL_SIZE 4
9494 #define FHSS_SIZE 2
95
96 #define TSFT_ALIGNMENT 8
97 #define CHANNEL_ALIGNMENT 2
98
99 #define RADIOTAP_ALIGN(offset, a) \
100 offset = (offset + (a) - 1) & ~((a) - 1)
95101
96102 #define WPS_DEVICE_NAME "Glau"
97103 #define WPS_MANUFACTURER "Microsoft"
464464 return globule->static_p2;
465465 }
466466
467 void set_pin_string_mode(int value)
468 {
469 globule->use_pin_string = value;
470 }
471
472 int get_pin_string_mode(void)
473 {
474 return globule->use_pin_string;
475 }
476
467477 void set_win7_compat(int value)
468478 {
469479 globule->win7_compat = value;
5050 char *static_p1; /* Static P1, as supplied by the user */
5151
5252 char *static_p2; /* Static P2, as supplied by the user */
53
54 int use_pin_string; /* Use arbitrary string pin */
5355
5456 enum key_state key_status; /* Indicates the status of the key cracking: KEY1_WIP | KEY2_WIP | KEY_DONE */
5557
215217 char *get_static_p1(void);
216218 void set_static_p2(char *value);
217219 char *get_static_p2(void);
220 void set_pin_string_mode(int value);
221 int get_pin_string_mode(void);
218222 void set_win7_compat(int value);
219223 int get_win7_compat(void);
220224 void set_dh_small(int value);
4343 data = (packet + offset);
4444 data_len = (len - offset);
4545
46 ret_val = parse_wps_tag(data, len, wps);
46 ret_val = parse_wps_tag(data, data_len, wps);
4747 }
4848 }
4949
+0
-13
src/lwe/19-udev-ifrename.rules less more
0 # udev rules to properly integrate ifrename.
1 # Renaming is done using /etc/iftab, with full ifrename functionality.
2 # Require udev version 107 or later.
3 # Please double check the path to ifrename, and make sure its available
4 # when udev runs (i.e. on boot partition).
5
6 # Enable this rule to test with udevtest.
7 #ENV{UDEV_LOG}=="6", SUBSYSTEM=="net", ACTION=="add", IMPORT="/sbin/ifrename -D -V -u -i %k", NAME:="%k"
8
9 # Main ifrename rule.
10 # If interface is found in /etc/iftab, subsequent rename rules are bypassed.
11 # If interface is not found in /etc/iftab, subsequent rename rules applies.
12 SUBSYSTEM=="net", ACTION=="add", IMPORT="/sbin/ifrename -u -i %k", NAME:="%k"
+0
-771
src/lwe/CHANGELOG.h less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPLB 97->99 - HPL 99->07
4 *
5 * The changelog...
6 *
7 * This files is released under the GPL license.
8 * Copyright (c) 1997-2002 Jean Tourrilhes <[email protected]>
9 */
10
11 /* --------------------------- HISTORY --------------------------- */
12 /*
13 * wireless 16 : (Jean Tourrilhes)
14 * -----------
15 * o iwconfig, iwpriv & iwspy
16 *
17 * wireless 17 : (Justin Seger)
18 * -----------
19 * o Compile under glibc fix
20 * o merge iwpriv in iwconfig
21 * o Add Wavelan roaming support
22 * o Update man page of iwconfig
23 *
24 * wireless 18 :
25 * -----------
26 * (From Andreas Neuhaus <[email protected]>)
27 * o Many fix to remove "core dumps" in iwconfig
28 * o Remove useless headers in iwconfig
29 * o CHAR wide private ioctl
30 * (From Jean Tourrilhes)
31 * o Create iwcommon.h and iwcommon.c
32 * o Separate iwpriv again for user interface issues
33 * The folllowing didn't make sense and crashed :
34 * iwconfig eth0 priv sethisto 12 15 nwid 100
35 * o iwspy no longer depend on net-tools-1.2.0
36 * o Reorganisation of the code, cleanup
37 * o Add ESSID stuff in iwconfig
38 * o Add display of level & noise in dBm (stats in iwconfig)
39 * o Update man page of iwconfig and iwpriv
40 * o Add xwireless (didn't check if it compiles)
41 * (From Dean W. Gehnert <[email protected]>)
42 * o Minor fixes
43 * (Jan Rafaj <[email protected]>)
44 * o Cosmetic changes (sensitivity relative, freq list)
45 * o Frequency computation on double
46 * o Compile clean on libc5
47 * (From Jean Tourrilhes)
48 * o Move listing of frequencies to iwspy
49 * o Add AP address stuff in iwconfig
50 * o Add AP list stuff in iwspy
51 *
52 * wireless 19 :
53 * -----------
54 * (From Jean Tourrilhes)
55 * o Allow for sensitivity in dBm (if < 0) [iwconfig]
56 * o Formatting changes in displaying ap address in [iwconfig]
57 * o Slightly improved man pages and usage display
58 * o Add channel number for each frequency in list [iwspy]
59 * o Add nickname... [iwconfig]
60 * o Add "port" private ioctl shortcut [iwpriv]
61 * o If signal level = 0, no range or dBms [iwconfig]
62 * o I think I now got set/get char strings right in [iwpriv]
63 * (From Thomas Ekstrom <[email protected]>)
64 * o Fix a very obscure bug in [iwspy]
65 *
66 * wireless 20 :
67 * -----------
68 * (From Jean Tourrilhes)
69 * o Remove all #ifdef WIRELESS ugliness, but add a #error :
70 * we require Wireless Extensions 9 or nothing ! [all]
71 * o Switch to new 'nwid' definition (specific -> iw_param) [iwconfig]
72 * o Rewriten totally the encryption support [iwconfig]
73 * - Multiple keys, through key index
74 * - Flexible/multiple key size, and remove 64bits upper limit
75 * - Open/Restricted modes
76 * - Enter keys as ASCII strings
77 * o List key sizes supported and all keys in [iwspy]
78 * o Mode of operation support (ad-hoc, managed...) [iwconfig]
79 * o Use '=' to indicate fixed instead of ugly '(f)' [iwconfig]
80 * o Ability to disable RTS & frag (off), now the right way [iwconfig]
81 * o Auto as an input modifier for bitrate [iwconfig]
82 * o Power Management support [iwconfig]
83 * - set timeout or period and its value
84 * - Reception mode (unicast/multicast/all)
85 * o Updated man pages with all that ;-)
86 *
87 * wireless 21 :
88 * -----------
89 * (from Alan McReynolds <[email protected]>)
90 * o Use proper macros for compilation directives [Makefile]
91 * (From Jean Tourrilhes)
92 * o Put licensing info everywhere (almost). Yes, it's GPL !
93 * o Document the use of /etc/pcmcia/wireless.opts [PCMCIA]
94 * o Add min/max modifiers to power management parameters [iwconfig]
95 * -> requested by Lee Keyser-Allen for the Spectrum24 driver
96 * o Optionally output a second power management parameter [iwconfig]
97 * ---
98 * o Common subroutines to display stats & power saving info [iwcommon]
99 * o Display all power management info, capability and values [iwspy]
100 * ---
101 * o Optional index for ESSID (for Aironet driver) [iwcommon]
102 * o IW_ENCODE_NOKEY for write only keys [iwconfig/iwspy]
103 * o Common subrouting to print encoding keys [iwspy]
104 * ---
105 * o Transmit Power stuff (dBm + mW) [iwconfig/iwspy]
106 * o Cleaner formatting algorithm when displaying params [iwconfig]
107 * ---
108 * o Fix get_range_info() and use it everywhere - Should fix core dumps.
109 * o Catch WE version differences between tools and driver and
110 * warn user. Thanks to Tobias Ringstrom for the tip... [iwcommon]
111 * o Add Retry limit and lifetime support. [iwconfig/iwlist]
112 * o Display "Cell:" instead of "Access Point:" in ad-hoc mode [iwconfig]
113 * o Header fix for glibc2.2 by Ross G. Miller <[email protected]>
114 * o Move header selection flags in Makefile [iwcommon/Makefile]
115 * o Spin-off iwlist.c from iwspy.c. iwspy is now much smaller
116 * After moving this bit of code all over the place, from iwpriv
117 * to iwconfig to iwspy, it now has a home of its own... [iwspy/iwlist]
118 * o Wrote quick'n'dirty iwgetid.
119 * o Remove output of second power management parameter [iwconfig]
120 * Please use iwlist, I don't want to bloat iwconfig
121 * ---
122 * o Fix bug in display ints - "Allen Miu" <[email protected]> [iwpriv]
123 *
124 * wireless 22 :
125 * -----------
126 * (From Jim Kaba <[email protected]>)
127 * o Fix socket_open to not open all types of sockets [iwcommon]
128 * (From Michael Tokarev <[email protected]>)
129 * o Rewrite main (top level) + command line parsing of [iwlist]
130 * (From Jean Tourrilhes)
131 * o Set commands should return proper success flag [iwspy/iwpriv]
132 * requested by Michael Tokarev
133 * ---
134 * (From Torgeir Hansen <[email protected]>)
135 * o Replace "strcpy(wrq.ifr_name," with strncpy to avoid buffer
136 * overflows. This is OK because the kernel use strncmp...
137 * ---
138 * o Move operation_mode in iwcommon and add NUM_OPER_MODE [iwconfig]
139 * o print_stats, print_key, ... use char * instead if FILE * [iwcommon]
140 * o Add `iw_' prefix to avoid namespace pollution [iwcommon]
141 * o Add iw_get_basic_config() and iw_set_basic_config() [iwcommon]
142 * o Move iw_getstats from iwconfig to iwcommon [iwcommon]
143 * o Move changelog to CHANGELOG.h [iwcommon]
144 * o Rename iwcommon.* into iwlib.* [iwcommon->iwlib]
145 * o Compile iwlib. as a dynamic or static library [Makefile]
146 * o Allow the tools to be compiled with the dynamic library [Makefile]
147 * --- Update to Wireless Extension 12 ---
148 * o Show typical/average quality in iwspy [iwspy]
149 * o Get Wireless Stats through ioctl instead of /proc [iwlib]
150 *
151 * wireless 23 :
152 * -----------
153 * o Split iw_check_addr_type() into two functions mac/if [iwlib]
154 * o iw_in_addr() does appropriate iw_check_xxx itself [iwlib]
155 * o Allow iwspy on MAC address even if IP doesn't check [iwspy]
156 * o Allow iwconfig ap on MAC address even if IP doesn't check [iwconfig]
157 * ---
158 * o Fix iwlist man page about extra commands [iwlist]
159 * ---
160 * o Fix Makefile rules for library compile (more generic) [Makefile]
161 * ---
162 * o Set max length for all GET request with a iw_point [various]
163 * o Fix set IW_PRIV_TYPE_BYTE to be endian/align clean [iwpriv]
164 * ---
165 * (From Kernel Jake <[email protected]>)
166 * o Add '/' at the end of directories to create them [Makefile]
167 * (From Pavel Roskin <[email protected]>)
168 * o Replace "cp" with "install" to get permissions proper [Makefile]
169 * o Install Man-Pages at the proper location [Makefile]
170 * o Add automatic header selection based on libc/kernel [iwlib.h]
171 * ---
172 * o Add "commit" to force parameters on the card [iwconfig]
173 * o Wrap ioctl() in iw_set/get_ext() wrappers [all]
174 * o Beautify set request error messages [iwconfig]
175 *
176 * wireless 24 :
177 * -----------
178 * o Added common function to display frequency [iwlib]
179 * o Added handler to parse Wireless Events [iwlib]
180 * o Added tool to display Wireless Events [iwevent]
181 * o Pass command line to subroutines [iwlist]
182 * o Scanning support through SIOCSIWSCAN [iwlist]
183 * ---
184 * o Added common function to display bitrate [iwlib]
185 * o Add bitrate/encoding scanning support [iwlist]
186 * o Allow to read scan results for non-root users [iwlist]
187 * o Set 5s timeout on waiting for scan results [iwlist]
188 * o Cleanup iwgetid & support ap+scheme display [iwgetid]
189 * o iwevent man page [iwevent]
190 * (From Guus Sliepen <[email protected]>)
191 * o iwgetid man page [iwgetid]
192 * ---
193 * o Add "#define WIRELESS_EXT > 13" around event code [iwlib]
194 * o Move iw_enum_devices() from iwlist.c to iwlib.c [iwlib]
195 * o Use iw_enum_devices() everywhere [iwconfig/iwspy/iwpriv]
196 * (From Pavel Roskin <[email protected]>, rewrite by me)
197 * o Return proper error message on non existent interfaces [iwconfig]
198 * o Read interface list in /proc/net/wireless and not SIOCGIFCONF [iwlib]
199 * ---
200 * (From Pavel Roskin <[email protected]> - again !!!)
201 * o Don't loose flags when setting encryption key [iwconfig]
202 * o Add <time.h> [iwevent]
203 * ---
204 * (From Casey Carter <[email protected]>)
205 * o Improved compilations directives, stricter warnings [Makefile]
206 * o Fix strict warnings (static func, unused args...) [various]
207 * o New routines to display/input Ethernet MAC addresses [iwlib]
208 * o Correct my english & spelling [various]
209 * o Get macaddr to compile [macaddr]
210 * o Fix range checking in max number of args [iwlist]
211 * ---
212 * o Display time when we receive event [iwevent]
213 * ---
214 * o Display time before event, easier to read [iwevent]
215 * (From "Dr. Michael Rietz" <[email protected]>)
216 * o Use a generic set of header, may end header mess [iwlib]
217 * (From Casey Carter <[email protected]>)
218 * o Zillions cleanups, small fixes and code reorg [all over]
219 * o Proper usage/help printout [iwevent, iwgetid, ...]
220 * ---
221 * o Send broadcast address for iwconfig ethX ap auto/any [iwconfig]
222 * ---
223 * o Send NULL address for iwconfig ethX ap off [iwconfig]
224 * o Add iw_in_key() helper (and use it) [iwlib]
225 * o Create symbolink link libiw.so to libiw.so.XX [Makefile]
226 * (From Javier Achirica <[email protected]>)
227 * o Always send TxPower flags to the driver [iwconfig]
228 * (From John M. Choi <[email protected]>)
229 * o Header definition for Slackware (kernel 2.2/glibc 2.2) [iwlib]
230 *
231 * wireless 25 :
232 * -----------
233 * o Remove library symbolic link before creating it [Makefile]
234 * o Display error and exit if WE < 14 [iwevent]
235 * (From Sander Jonkers <[email protected]>)
236 * o Fix iwconfig usage display to show "enc off" [iwconfig]
237 * (From Pavel Roskin <[email protected]>)
238 * o Formating : add spaces after cell/ap addr [iwconfig]
239 * ---
240 * o Do driver WE source version verification [iwlib]
241 * (From Pavel Roskin <[email protected]>)
242 * o Cleanup user configurable options [Makefile]
243 * o add FORCE_WEXT_VERSION [Makefile]
244 * o Add uninstall directived [Makefile]
245 * o Cleanup version warnings [iwlib]
246 * o Fix iwconfig usage display to show "mode MODE" [iwconfig]
247 * o Replace "rm -f + ln -s" with "ln -sfn" in install [Makefile]
248 * ---
249 * o Add various documentation in source code of [iwpriv]
250 * o Allow to get more than 16 private ioctl description [iwlib]
251 * o Ignore ioctl descriptions with null name [iwpriv]
252 * o Implement sub-ioctls (simple/iw_point) [iwpriv]
253 * ---
254 * o Add DISTRIBUTIONS file with call for help [README]
255 * o Change iw_byte_size in iw_get_priv_size [iwlib]
256 * o Document various bugs of new driver API with priv ioctls [iwpriv]
257 * o Implement float/addr priv data types [iwpriv]
258 * o Fix off-by-one bug (priv_size <= IFNAMSIZ) [iwpriv]
259 * o Reformat/beautify ioctl list display [iwpriv]
260 * o Add "-a" command line to dump all read-only priv ioctls [iwpriv]
261 * o Add a sample showing new priv features [sample_priv_addr.c]
262 * o Update other samples with new driver API [sample_enc.c/sample_pm.c]
263 * ---
264 * o Fix "iwpriv -a" to not call ioctls not returning anything [iwpriv]
265 * o Use IW_MAX_GET_SPY in increase number of addresses read [iwspy]
266 * o Finish fixing the mess of off-by-one on IW_ESSID_MAX_SIZE [iwconfig]
267 * o Do interface enumeration using /proc/net/dev [iwlib]
268 * ---
269 * o Display various --version information [iwlib, iwconfig, iwlist]
270 * o Filled in Debian 2.3 & Red-Hat 7.3 sections in [DISTRIBUTIONS]
271 * o Filled in Red-Hat 7.2, Mandrake 8.2 and SuSE 8.0 in [DISTRIBUTIONS]
272 * o Display current freq/channel after the iwrange list [iwlist]
273 * o Display current rate after the iwrange list [iwlist]
274 * o Display current txpower after the iwrange list [iwlist]
275 * o Add BUILD_NOLIBM to build without libm [Makefile]
276 * o Fix infinite loop on unknown events/scan elements [iwlib]
277 * o Add IWEVCUSTOM support [iwevent, iwlist]
278 * o Add IWEVREGISTERED & IWEVEXPIRED support [iwevent]
279 * (From Pavel Roskin <[email protected]>)
280 * o Make $(DYNAMIC_LINK) relative (and not absolute) [Makefile]
281 * ---
282 * o Replace all float occurence with double [iwlib, iwlist]
283 * o Implement iwgetid --mode [iwgetid]
284 * o Convert frequency to channel [iwlist, iwlib]
285 * (Suggested by Pavel Roskin <[email protected]> - always him !)
286 * o Implement --version across the board [iwspy, iwevent, iwpriv]
287 * o Implement iwgetid --freq [iwgetid]
288 * o Display "Access Point/Cell" [iwgetid]
289 * ---
290 * o New manpage about configuration (placeholder) [wireless.7]
291 * o Catch properly invalid arg to "iwconfig ethX key" [iwconfig]
292 * o Put placeholder for Passphrase to key conversion [iwlib]
293 * o Allow args of "iwconfig ethX key" in any order [iwconfig]
294 * o Implement token index for private commands [iwpriv]
295 * o Add IW_MODE_MONITOR for passive monitoring [iwlib]
296 * I wonder why nobody bothered to ask for it before ;-)
297 * o Mention distribution specific document in [PCMCIA]
298 * o Create directories before installing stuff in it [Makefile]
299 * ---
300 * o Add Debian 3.0 and PCMCIA in [wireless.7]
301 * o Add iw_protocol_compare() in [iwlib]
302 * ---
303 * o Complain about version mistmatch at runtime only once [iwlib]
304 * o Fix IWNAME null termination [iwconfig, iwlib]
305 * o "iwgetid -p" to display protocol name and check WE support [iwgetid]
306 *
307 * wireless 26 :
308 * -----------
309 * o #define IFLA_WIRELESS if needed [iwlib]
310 * o Update man page with SuSE intruction (see below) [wireless.7]
311 * (From Alexander Pevzner <[email protected]>)
312 * o Allow to display all 8 bit rates instead of 7 [iwlist]
313 * o Fix retry lifetime to not set IW_RETRY_LIMIT flag [iwconfig]
314 * (From Christian Zoz <[email protected]>)
315 * o Update SuSE configuration instructions [DISTRIBUTIONS]
316 * ---
317 * o Update man page with regards to /proc/net/wireless [iwconfig.8]
318 * o Add NOLIBM version of iw_dbm2mwatt()/iw_mwatt2dbm() [iwlib]
319 * ---
320 * o Fix "iwconfig ethX enc on" on WE-15 : set buffer size [iwconfig]
321 * o Display /proc/net/wireless before "typical data" [iwspy]
322 * (From Pavel Roskin <[email protected]>)
323 * o Fix uninstall [Makefile]
324 * o Change "Encryption mode" to "Security mode" [iwconfig/iwlist]
325 * ---
326 * o Add kernel headers that will be removed from wireless.h [iwlib]
327 * o Remove IW_MAX_GET_SPY, people should use AP-List [iwspy]
328 * o Re-word List of "Access Points" to "Peers/Access-Points" [iwlist]
329 * o Add support for SIOCGIWTHRSPY event [iwevent/iwlib]
330 * o Add support for SIOCSIWTHRSPY/SIOCGIWTHRSPY ioctls [iwspy]
331 * ---
332 * o Add SIOCGIWNAME/Protocol event display [iwlist scan/iwevent]
333 * o Add temporary encoding flag setting [iwconfig]
334 * o Add login encoding setting [iwlib/iwconfig]
335 * ---
336 * o Fix corruption of encryption key setting when followed by another
337 * setting starting with a valid hex char ('essid' -> 'E') [iwlib]
338 * o Fix iw_in_key() so that it parses every char and not bundle of
339 * two so that 'enc' is not the valid key '0E0C' [iwlib]
340 * o Fix parsing of odd keys '123' is '0123' instead of '1203' [iwlib]
341 * ---
342 * o Implement WE version tool redirector (need WE-16) [iwredir]
343 * o Add "make vinstall" to use redirector [Makefile]
344 * o Fix compilation warning in WE < 16 [iwlib, iwspy]
345 * o Allow to specify PREFIX on make command line [Makefile]
346 * ---
347 * o Update wireless.h (more frequencies) [wireless.h]
348 * o Allow to escape ESSID="any" using "essid - any" [iwconfig]
349 * o Updated Red-Hat 9 wireless config instructions [DISTRIBUTIONS]
350 * (From Pavel Roskin <[email protected]>)
351 * o Replace all %d into %i so we can input hex/oct [iwlib, iwpriv]
352 * ---
353 * o If >= WE-16, display kernel version in "iwconfig --version" [iwlib]
354 * (From Antonio Vilei <[email protected]>)
355 * o Fix "wrq.u.bitrate.value = power;" => txpower [iwconfig]
356 * (From Casey Carter <[email protected]>)
357 * o Make iwlib.h header C++ friendly. [iwlib]
358 * ---
359 * (From Pavel Roskin <[email protected]>)
360 * o Make sure that KERNEL_SRC point to a valid directory [Makefile]
361 * o Print message if card support WE but has no version info [iwlib]
362 * (From Simon Kelley <[email protected]>)
363 * o If power has no mode, don't print garbage [iwlib]
364 * ---
365 * (Bug reported by Guus Sliepen <[email protected]>)
366 * o Don't cast "int power" to unsigned long in sscanf [iwconfig]
367 * (From Pavel Roskin <[email protected]>)
368 * o Add $(LDFLAGS) for final linking [Makefile]
369 *
370 * wireless 27 :
371 * -----------
372 * o Add 'sed' magic to automatically get WT/WE versions [Makefile]
373 * o Change soname of iwlib to libiwWE.so.WT [Makefile]
374 * Now dynamicaly linked versioned install can work
375 * o Default to dynamic build, don't build static lib [Makefile]
376 * o Update installation instructions [INSTALL]
377 * o fflush(stdout), so that redirect to file/pipe works [iwevent]
378 * (From Pavel Roskin <[email protected]>)
379 * o Display properly interface name larger than 8 char [all]
380 * ---
381 * o Implement auto/fixed frequencies [iwconfig]
382 * (From Pavel Roskin <[email protected]>)
383 * o Don't fail is ldconfig fails [Makefile]
384 * ---
385 * o Fix one forgotten strcpy(ifname) -> strncpy change [iwconfig]
386 * o Fix all dangerous sprintf, replace with snprintf [iwlib]
387 * o Change iw_print_xxx() API to take buffer length [iwlib]
388 * ---
389 * o "iwspy ethX +" did not work, fix wrq.u.data.length [iwspy]
390 * o Fix stupid bug in displaying link/ap/cell stats [iwspy]
391 * o Fix display of fixed length char private args [iwpriv]
392 * o Add raw output for shell scripts, options -r [iwgetid]
393 * o Tweak scheme output for freq and mode [iwgetid]
394 * (From Andreas Mohr)
395 * o Spelling fixes in README and man page
396 * ---
397 * o Add definitions for older version of W-Ext [iwlib]
398 * o Always force compile with latest local version of wext [Makefile]
399 * o Change soname of iwlib back to libiw.so.WT [Makefile]
400 * o Get rid of redirector and "make vinstall" [Makefile/iwredir]
401 * o Convert any struct iw_range to latest version [iwlib]
402 * o Change run-time version warning to reflect new reality [iwlib]
403 * o Remove compile-time version warning [iwlib]
404 * o Add iw_get_kernel_we_version() to guess kernel WE version [iwlib]
405 * o Remove all #ifdef WIRELESS_EXT, use dynamic iwrange version [all]
406 * o Get/display wireless stats based on iwrange version [iwlib]
407 * o Get power and retry settings based on iwrange version [iwconfig]
408 * o Display power and retry settings based on iwrange version [iwlist]
409 * o Optimise use of iwrange : read on demand [iwevent]
410 * ---
411 * o #include <wireless.h>, instead of using a #define [iwlib.h]
412 * o Copy latest wireless.XX.h as wireless.h and install it [Makefile]
413 * ---
414 * o Fix various iwlist retry display bugs [iwlist]
415 * o Fix dynamic link to libiw back to be libiw.so (doh !) [Makefile]
416 * ---
417 * o Trivial cleanups and docs updates
418 * ---
419 * o Implement "iwconfig XXX txpower on" and fix "fixed" [iwconfig]
420 * o Always properly initialise sanlen before recvfrom() [iwevent]
421 * o Zero buffer so we don't print garbage after essid [iwgetid]
422 * o Document that 00:00:00:00:00:00 == no association [iwconfig.8]
423 * (From Guus Sliepen <[email protected]>)
424 * o Fix doc typo : ad_hoc => ad-hoc [wireless.7/DISTRIBUTIONS.txt]
425 * ---
426 * (From vda <[email protected]>)
427 * o Accept arbitrary number of private definitions [iwlib/iwpriv]
428 * ---
429 * o Added Hotplug documentation [HOTPLUG.txt]
430 * o Add dependancies (gcc way), remove makedepend [Makefile]
431 * (From Maxime Charpenne <[email protected]>)
432 * o Traduction en francais des pages manuel [fr/*]
433 * o Fix some incorrect/ambiguous sentences [iwconfig.8/iwevent.8]
434 * (From Joshua Kwan <[email protected]>)
435 * o Add 'const' qualifier to iwlib API [iwlib.c/iwlib.h]
436 * (From Joey Hess <[email protected]>)
437 * o Add Debian schemes scripts [debian/ifscheme*]
438 * ---
439 * o Add 'ifrename', complete rewrite of nameif [ifrename]
440 * o Update documentation about ifrename [HOTPLUG.txt]
441 * (From Joshua Kwan <[email protected]>)
442 * o Fix disabling of key/enc with iw_set_basic_config() & WE<13 [iwlib.c]
443 * ---
444 * o Various bug fixes and improvements [ifrename]
445 * ---
446 * o Man pages for ifrename [ifrename.8/iftab.5]
447 * o Update hotplug/ifrename documentation [HOTPLUG.txt]
448 * ---
449 * o Read configuration from stdin [ifrename]
450 * (From Thomas Hood <[email protected]>)
451 * o Spell check and updated man page [wireless.7]
452 * (From Pavel Roskin <[email protected]>)
453 * o Update and spellcheck documentation [HOTPLUG.txt]
454 * ---
455 * o Spin-off 'ifscheme' in a separate package to please Guus Sliepen
456 * o Update documentation on 'ifscheme' [DISTRIBUTIONS.txt/README]
457 * (From dann frazier <[email protected]>)
458 * o Spell check and updated man page [iwlist.8]
459 * ---
460 * o Cache interface static data (ifname/iwrange) [iwevent.c]
461 * ---
462 * o Change the policy to delete entry from cache [iwevent.c]
463 * o If no TxPower in iwrange, still print current TxPower [iwlist.c]
464 * o Use iw_get_basic_config() in iwconfig, bloat-- [iwconfig.c/iwlib.h]
465 * ---
466 * (From Pavel Roskin <[email protected]>)
467 * o Fix mode boundary checking in iw_get_basic_config() [iwlib.c]
468 * ---
469 * o Improved priv documentation [iwpriv.c]
470 * (From Pavel Roskin <[email protected]>)
471 * o Fix token index bug : allow zero args [iwpriv.c]
472 * o Grammar fixes in priv documentation [iwpriv.c]
473 * ---
474 * o Make iw_protocol_compare() smarter [iwlib.c]
475 * o Display freq->channel conversion in scan results [iwlist]
476 * o Display freq->channel conversion in events [iwevent]
477 * o Interface name takeover support [ifrename]
478 * o Update docu for Debian Sarge, various improvements [HOTPLUG.txt]
479 * o Set wireless parameters in the proper order [iwlib]
480 * ---
481 * (Suggested by Pavel Roskin <[email protected]>)
482 * o Be less dramatic is driver doesn't export txpower info [iwlist]
483 * o Be less dramatic is driver doesn't export bitrate info [iwlist]
484 * o Use 'updated' bits to disable printing some qual [iwlib]
485 * o Change the way we show 'updated' bits -> '=' vs. ':' [iwlib]
486 * o Cosmetic update to channel display [iwlist/iwevent]
487 * ---
488 * o Easy scanning API (blocking & non-blocking) [iwlib]
489 * o Add channel only support to iwgetid [iwgetid]
490 * o Compile iwgetid with iwlib for above [Makefile/iwgetid]
491 * (From Loic Minier <[email protected]> via Guus Sliepen)
492 * o Fix french man pages to not use special 'oe' char [fr/*.8]
493 * (From Thomas Hood <[email protected]>)
494 * o Use hyphens instead of underscores in Debian docs [*.txt/*.7]
495 * ---
496 * o Update for WE-17 (wrq.u.freq.flags, IW_QUAL_*) [all]
497 * o Use iw_get_ext() instead of ioctl() [iwgetid]
498 * o Retry getting scan results with larger buffer [iwlist/iwlib]
499 * o Display wireless event capabilities [iwlist]
500 * o Add support for relative TxPower (yick !) [iwconfig/iwlist]
501 * o Create iw_print_txpower() [iwlib]
502 * o Add "Set" prefix for all SET wireless events [iwevent]
503 * (Suggested by Pavel Roskin <[email protected]>)
504 * o Add support for get_freq and get_essid events [iwevent]
505 * ---
506 * o Reorganise iw_print_freq() => create iw_print_freq_value() [iwlib]
507 * o Create iw_channel_to_freq() and use it [iwlib/iwconfig/iwevent]
508 * o Fixup for WE-18 : Set scan takes an iw_point [iwlist/iwlib]
509 * o Fixup for WE-19 : Take care of IW_EV_POINT_OFF [iwlib]
510 * ---
511 * o Introduces iw_sockets_close() [all]
512 * o Set proper size on SIOCGIWSTATS requests [iwlib]
513 * o Use iw_print_freq_value() in iwlist [iwlist]
514 * o Optimise iw_print_bitrate() [iwlib]
515 * o Fix wrq.u.data.flags => wrq.u.txpower.flags [iwconfig]
516 * (From Denis Ovsienko <[email protected]>)
517 * o Add dry-run support (only print name changes) [ifrename]
518 * ---
519 * o Move WE_VERSION/WT_VERSION to iwlib.h [iwlib/Makefile]
520 * o Add support for new selector pcmciaslot [ifrename]
521 * o Improve/cleanup DEBUG/verbose output [ifrename]
522 * o Minor documentation updates [HOTPLUG.txt/DISTRIBUTIONS.txt]
523 * (From Francesco Potorti` <[email protected]>)
524 * o Allow iwgetid to accept '-c' options [iwgetid]
525 * (From Ian Gulliver <[email protected]>)
526 * o Transform #define DEBUG into verbose command line switch [ifrename]
527 * ---
528 * (From Dan Williams <[email protected]>)
529 * o Fix buffer memory leak in scanning [iwlib/iwlist]
530 * ---
531 * o Make sure gcc inline stuff properly [iwlib.h]
532 * o Update Hotplug documentation [HOTPLUG.txt]
533 * o Add support for new selector firmware [ifrename]
534 *
535 * wireless 28 :
536 * -----------
537 * o Fix gcc inline hack when using kernel headers [iwlib.h]
538 * (From Denis Ovsienko <[email protected]>)
539 * o Allow '-n' without '-i', even though inefficient [ifrename]
540 * (From Thomas Hood <[email protected]>)
541 * o Fix technical and spelling errors in Hotplug doc [HOTPLUG.txt]
542 * ---
543 * o Include wireless.h as a local file, not a system file [iwlib.h]
544 * o Split install targets [Makefile]
545 * (Suggested by Jost Diederichs <[email protected]>)
546 * o Increase scanning timeout for MadWifi [iwlib/iwlist]
547 * (Suggested by Ned Ludd <[email protected]>)
548 * o Multicall version of the tools for embedded [iwmulticall]
549 * ---
550 * o Fix some install Makefile targets broken in pre2 [Makefile]
551 * ---
552 * o Add option for stripping symbols on tools [Makefile]
553 * o Add escaping of essid keyworks with -- in manpage [iwconfig.8]
554 * o Update sensitivity description [iwconfig.8]
555 * o Fix iw_print_timeval() for timezone [iwlib/iwevent]
556 * (Suggested by Jan Minar <[email protected]>)
557 * o Escape interface name for --help/--version with -- [iwconfig]
558 * o Allow --help/--version to be interface names [iwlist]
559 * (From Martynas Dubauskis <[email protected]>)
560 * o Fix invalid sizeof for stat memcpy in easy scanning API [iwlib.c]
561 * (From Andreas Mohr <[email protected]>)
562 * o Fix my horrendous spelling [HOTPLUG.txt/PCMCIA.txt/README/*.8]
563 * ---
564 * o Make static lib use PIC objects [Makefile]
565 * o Add SYSFS selector support to ifrename [ifrename]
566 * o Fix a fd leak in pcmciaslot selector [ifrename]
567 * o Don't complain about eth0/wlan0 if takeover enabled [ifrename]
568 * o Update man pages for sysfs and eth0/wlan0 [ifrename.8]
569 * o Update man pages for frequ auto/off [iwconfig.8]
570 * o More clever manual loading and docking tricks [HOTPLUG.txt]
571 * (From Pavel Heimlich [email protected])
572 * o Czech (cs) man pages [cs/*]
573 * ---
574 * o Fudge patch below for better integration [iwconfig/iwevent/iwlist]
575 * (From Jouni Malinen <[email protected]>)
576 * o WE-18/WPA event display [iwevent]
577 * o WE-18/WPA parameter display [iwconfig]
578 * ---
579 * o Replace iw_pr_ether() with iw_saether_ntop() [iwlib]
580 * o Replace iw_in_ether() with iw_saether_aton() [iwlib]
581 * o Remove iw_get_mac_addr() -> unused and bad API [iwlib]
582 * o Add iw_mac_ntop() and iw_mac_aton() for any-len mac addr [iwlib]
583 * o Slim down iw_ether_aton() using iw_mac_ntop() [iwlib]
584 * o Slim down iw_in_key(), avoid memcpy [iwlib]
585 * o Add support for any-len mac addr selector [ifrename]
586 * ---
587 * o Re-add temp output buffer in iw_in_key() to avoid corruptions [iwlib]
588 * ---
589 * o Add WE-19 headers, compile with that as default
590 * o IW_EV_POINT_LEN has shrunk, so invert IW_EV_POINT_OFF fixup [iwlib]
591 * o Remove WE backward compat from iwlib.h header [iwlib]
592 * o Add support for IW_QUAL_DBM in iw_print_stats() [iwlib]
593 * o Add support for ARPHRD_IEEE80211 in iw_check_mac_addr_type() [iwlib]
594 * -> iwspy work on wifi0 netdev from airo.c
595 * ---
596 * o Set flags to 0 before asking old power settings for 'on' [iwconfig]
597 * (Suggested by Denis Ovsienko <[email protected]>)
598 * o Ignore empty lines in iface enumeration iw_enum_devices() [iwlib]
599 * (From Pavel Roskin <[email protected]>)
600 * o Fix invalid buffer size in 'iwlist power' [iwlist]
601 * (Suggested by Francesco Potorti` <[email protected]>)
602 * o Remove kernel headers, use glibc headers [iwlib]
603 * ---
604 * o Show explicit state for SIOCSIWAP, not numbers [iwconfig/iwevent]
605 * o Add WE-18 ioctls to the stream parser in standard_ioctl_hdr [iwlib]
606 * (From Chris Hessing <[email protected]>)
607 * o Add GENIE parsing support in scan resuls [iwlist]
608 * ---
609 * o Change iw_extract_event_stream() API to add value index [iwlib]
610 * o Scan : display bitrate values on a single line [iwlist]
611 * ---
612 * o Revert to previous iw_extract_event_stream() API, debloat [iwlib]
613 * o Keep track of value index in [iwlist]
614 * ---
615 * o Check event stream 'point' payload size to avoid overflow [iwlib]
616 * o Make all users of event stream 'point' safe to NULL [iwlist/iwevent]
617 * o 'iwconfig txpower 1dBm' should not be 'mW' [iwconfig]
618 * o Forward compat. to WE-21 : essid len is strlen, not +1 [iwconfig]
619 * ---
620 * o Forgot one place where essid len was strlen+1 [iwlib]
621 * o Update definition of 'ap' and 'sens' to reflect reality [man]
622 * ---
623 * o Introduce WE_MAX_VERSION to take into account forward compat [iwlib]
624 * o Add WE-20 headers, compile with that as default
625 * ---
626 * o Fix 'inline' for gcc-4 as well. Grrr... [iwlib]
627 *
628 * wireless 29 :
629 * -----------
630 * o Add new power value : 'power saving' [iwconfig/iwlist/iwlib]
631 * o Optimise getting iwrange when setting TxPower [iwconfig]
632 * o Optimise displaying current power values (better loop) [iwlist]
633 * ---
634 * o Add modulation bitmasks ioctls [iwconfig/iwlist]
635 * o Add short and long retries [iwconfig/iwlist/iwlib]
636 * o Fix 'relative' power saving to not be *1000 [iwconfig/iwlib]
637 * o iw_print_pm_value() require we_version [iwlib]
638 * o Optimise displaying range power values (subroutine) [iwlist]
639 * ---
640 * o Fix 'relative' retry to not be *1000 [iwconfig/iwlib]
641 * o iw_print_retry_value() require we_version [iwlib]
642 * o Optimise getting iwrange when setting PowerSaving [iwconfig]
643 * o Optimise displaying current retry values (better loop) [iwlist]
644 * o Optimise displaying range retry values (subroutine) [iwlist]
645 * ---
646 * o Fix stupid bug in displaying range retry values [iwlist]
647 * ---
648 * o Add support for unicast and broadcast bitrates [iwconfig/iwlist]
649 * ---
650 * o Replace spaghetti code with real dispatcher in set_info() [iwconfig]
651 * Code is more readable, maintainable, and save 700 bytes...
652 * o Drop 'domain' alias for 'nwid'. Obsolete. [iwconfig]
653 * o Make iw_usage() use dispatcher data instead of hardcoded [iwconfig]
654 * o Factor out modifier parsing for retry/power [iwconfig]
655 * o Fix iwmulticall to compile with new dispatcher above [iwmulticall]
656 * o Add WE_ESSENTIAL compile option to drop 10kB [Makefile]
657 * ---
658 * o Update manpages with new features above [man]
659 * ---
660 * o Add temp variable to sscanf() to fix 64 bits issues [iwconfig]
661 * o De-inline get_pm_value/get_retry_value to reduce footprint [iwlist]
662 * o Optimise iw_print_ie_cipher/iw_print_ie_auth [iwlist]
663 * o Add "Memory footprint reduction" section in doc [README]
664 * o Add 'last' scan option for left-over scan [iwlist]
665 * (From Stavros Markou <[email protected]>)
666 * o Add 'essid' scan option for directed scan [iwlist]
667 * ---
668 * (Bug reported by Henrik Brix Andersen <[email protected]>)
669 * o Fix segfault on setting bitrate (parse wrong arg) [iwconfig]
670 * ---
671 * o Revert 'CC=gcc' to normal [Makefile]
672 * o Integrate properly patch below [iwlist]
673 * (From Brian Eaton <[email protected]>)
674 * o More WPA support : iwlist auth/wpakeys/genie [iwlist]
675 * ---
676 * o Tweak man pages : interface is often optional [iwlist.8/iwspy.8]
677 * o Drop obsolete port/roam code from [iwpriv]
678 * (From Pavel Roskin <[email protected]>)
679 * o Fix bug where all auth masks use iw_auth_capa_name [iwlist]
680 * (From Dima Ryazanov <[email protected]>)
681 * o Fix iw_scan()/iw_process_scan() for non-root -> EPERM [iwlib]
682 * (Bug reported by Arkadiusz Miskiewicz <[email protected]>)
683 * o Fix "iwconfig nickname" (was abreviated) [iwconfig]
684 * (Bug reported by Charles Plessy)
685 * o Invalid mode from driver segfault iwlist scan [iwlist]
686 * (From Aurelien Jacobs <[email protected]>)
687 * o Replace index() with strchr() [iwlib/iwconfig/iwpriv]
688 * (From Jens Thoms Toerring)
689 * o Parser/printf/sscanf fixes and optimisation [iwconfig]
690 * ---
691 * (From Pavel Roskin <[email protected]>)
692 * o Fix bug extracting mountpoint of sysfs (wrong field) [ifrename]
693 * (Suggested by Pavel Roskin <[email protected]>)
694 * o Read sysfs symlinks transparently [ifrename]
695 * ---
696 * o Fix README header to talk about ifrename [README]
697 * o Add 'prevname' selector for udev compatibility [ifrename]
698 * o Read parent directory names in SYSFS selector [ifrename]
699 * o Make dry-run output compatible with udev [ifrename]
700 * o Update man page with useful SYSFS selectors [iftab.5]
701 * ---
702 * o Factorise wildcard rewrite '*'->'%d' to hide it from -D -V [ifrename]
703 * o Reorganise sysfs description, better wording [iftab.5]
704 * (Suggested by Pavel Roskin <[email protected]>)
705 * o Enhance explanation of arp and iwproto [iftab.5]
706 * ---
707 * (Bug reported by Johannes Berg <[email protected]>)
708 * o Band-aid for the 64->32bit iwevent/iwscan issues [iwlib]
709 * ---
710 * o Better band-aid for the 64->32bit iwevent/iwscan issues [iwlib]
711 * (Suggested by Kay Sievers <[email protected]>)
712 * o Add udev compatible output, print new DEVPATH [ifrename]
713 * ---
714 * o Fix DEVPATH output to use the real devpath from udev [ifrename]
715 * o Add udev rules for ifrename integration [19-udev-ifrename.rules]
716 * ---
717 * o Add largest bitrate in easy scan API [iwlib]
718 * ---
719 * o Debug version : output IW_EV_LCP_LEN [iwlist]
720 * ---
721 * (Bug reported by Santiago Gala/Roy Marples)
722 * o Fix 64->32bit band-aid on 64 bits, target is local aligned [iwlib]
723 * ---
724 * (Bug reported by Santiago Gala/Roy Marples)
725 * o More fix to the 64->32bit band-aid on 64 bits [iwlib]
726 * ---
727 * (Bug reported by Dimitris Kogias)
728 * o Fix GENIE parsing os chipher/key_mngt [iwlist]
729 * (Bug reported by Guus Sliepen <[email protected]>)
730 * o Compiler warning on DEBUG code [iwlist]
731 * ---
732 * o --version output WE_MAX_VERSION instead of WE_VERSION [iwlib]
733 * o Change iwstats dBm range to [-192;63] in iw_print_stats() [iwlib.c]
734 * o Implement iwstats IW_QUAL_RCPI in iw_print_stats() [iwlib.c]
735 * (Bug reported by Guus Sliepen <[email protected]>)
736 * o LINUX_VERSION_CODE removed, only use GENERIC_HEADERS [iwlib.h]
737 * (Bug reported by Johan Danielsson <[email protected]>)
738 * o Fix OUI type check for WPA 1 IE [iwlist.c]
739 * ---
740 * (Bug reported by Florent Daignière)
741 * o Don't look for "fixed" out of array in set_txpower_info() [iwconfig]
742 */
743
744 /* ----------------------------- TODO ----------------------------- */
745 /*
746 * One day, maybe...
747 *
748 * iwconfig :
749 * --------
750 * Make disable a per encryption key modifier if some hardware
751 * requires it.
752 * IW_QUAL_RCPI
753 *
754 * iwspy :
755 * -----
756 * Add an "auto" flag to have the driver cache the last n results
757 *
758 * iwlist :
759 * ------
760 * Add scanning command line modifiers
761 * More scan types support
762 *
763 * ifrename :
764 * --------
765 * Link Type should use readable form instead of numeric value
766 *
767 * Doc & man pages :
768 * ---------------
769 * Update main doc.
770 */
+0
-377
src/lwe/DISTRIBUTIONS.txt less more
0 Distribution specific notes on Wireless Configuration
1 -----------------------------------------------------
2
3 ***** HELP *****
4 If people send me information about the specifics of each
5 distribution, I'll try to collect that here. Don't forget to mention
6 to which distribution those instructions apply, the tool used (if any)
7 and the files modified.
8 Actually, the people packaging my tools for a specific
9 distribution have a moral obligation to send me the exact detailed
10 instructions of what they have done. I will list in the wireless.7
11 man page only distributions that give me an official answer.
12 ***** HELP *****
13
14 -----
15
16 INTRODUCTION
17 ------------
18 The tools enable users to change the card settings at run time
19 (when running iwconfig, for example). However, most users want the
20 card to be configured either at boot time or when the card is
21 activated in the system.
22 Each distribution has its own configuration scripts, and
23 therefore is slightly different. Some distributions even add some
24 graphical setup tool (nice). This file describe the procedure for a
25 few of them.
26 Note : if you install the Pcmcia package in source form from
27 the official Linux-Pcmcia web site (as opposed to precompiled by a
28 distribution, please use the PCMCIA method).
29
30 Please remember : I don't use your distribution, and I have
31 absolutely no clue about how your distribution works. I'm just
32 collecting random information here without beeing able to verify it.
33
34 -----
35
36 WIRELESS DRIVERS
37 ----------------
38 Most Linux wireless drivers support Wireless Extensions, and
39 therefore may be configure via Wireless Tools and the methods
40 described in this file.
41
42 However, a few drivers have no support or limited support for
43 Wireless Extensions (like read only). In those cases, these are your
44 options :
45 o read the driver documentation.
46 o use the driver specific interface or tools to
47 configure the card, and try to integrate that in your distribution.
48 o implement Wireless Extension support in the driver.
49 In some cases, there are easier workaround. Different version
50 of the driver may add Wireless Extension (often alongside the
51 proprietary method). In some other case, there may be another driver
52 supporting the same card and with support for Wireless Extensions.
53
54 Some Linux wireless drivers don't export all wireless settings
55 via Wireless Extensions, not even through iwpriv. Those setting may be
56 available through the driver specific interface. Refer to previous
57 section for workarounds.
58
59 ---------------------------------------------------------------------
60
61 PCMCIA METHOD
62 -------------
63 (Contributed by Jean Tourrilhes <[email protected]>)
64 This method work for *all* distributions.
65 For Pcmcia cards, it is possible to overwrite the Pcmcia
66 configuration files of the distribution with the original Pcmcia
67 configuration files from the Pcmcia package (/etc/pcmcia/*). If you
68 install the Pcmcia package in source form from the official
69 Linux-Pcmcia web site, this will be done automatically.
70 Once this is done, you can no longer use the specific tools
71 and configuration files of the distribution, and are required to use
72 Pcmcia style of configuration (see Pcmcia Howto).
73 In such a case, Wireless configuration is done through
74 wireless.opts, and documented in the file PCMCIA.txt.
75
76 ---------------------------------------------------------------------
77
78 DEBIAN 2.2 (and earlier)
79 ----------
80 (Contributed by Jean Tourrilhes <[email protected]>)
81 Debian 2.2 (and earlier) doesn't support any Wireless
82 Configuration. You are required to use the Pcmcia method. Also, the
83 Wireless Tools package is not part of the standard packages.
84
85 ---------------------------------------------------------------------
86
87 DEBIAN 3.0 (and later)
88 ----------
89 (Contributed by Guus Sliepen <[email protected]>)
90 Debian also has another way of configuring network devices,
91 controlled by /etc/network/interfaces. Users can add a wireless
92 interface to /etc/network/interfaces, using the standard options to
93 set the address and such, but the wireless-tools package adds new
94 option statements that can be used to configure keys, channel,
95 etcetera.
96 From the README.Debian script that comes with wireless-tools:
97
98 /etc/network/interfaces
99 -----------------------
100
101 You can now add extra statements to the iface sections of the files in
102 /etc/network/interfaces that are specific for wireless interfaces. They
103 are of the form:
104
105 wireless-<function> <value>
106
107 Before the interface is brought up, such a statement will result in the
108 execution of the following command:
109
110 iwconfig <interface> <function> <value>
111
112 Example:
113
114 iface eth0 inet static
115 address 192.168.1.2
116 network 192.168.1.0
117 netmask 255.255.255.0
118 broadcast 192.168.1.255
119 wireless-essid Home
120 wireless-mode ad-hoc
121
122 The current Debian script support all arguments present in
123 wireless.opts apart from Nickname. You can check this in the script
124 /etc/network/if-pre-up.d/wireless-tool.
125 You will need of course to install the Wireless Tools package
126 if it's not already done, which is part of the standard package list
127 (use dselect, dpkg, apt or anything you like to get it).
128
129 -----
130
131 (Contributed by Joey Hess <[email protected]>)
132 /etc/network/interfaces is much more flexible than it appears. It can probably
133 do everything pcmcia schemes can do, and more. Here is part of mine:
134
135 auto wlan0
136 mapping wlan0
137 script /usr/local/bin/ifscheme-mapping
138
139 iface wlan0-home inet static
140 address 192.168.1.5
141 gateway 192.168.1.1
142 netmask 255.255.255.0
143 wireless-mode ad-hoc
144 wireless-essid wortroot
145 wireless-nick dragon
146 wireless-channel 1
147
148 iface wlan0-away inet dhcp
149 wireless-mode managed
150
151 Now I can type 'ifscheme -s away' when I leave home, rather like
152 cardctl scheme.
153
154 The ifscheme script is at http://bugs.debian.org/154444. If the request in
155 bug #154442 is implemented, it will become very flexible indeed..
156
157 Debian will hopefully be using this same file eventually for pcmcia network
158 devices too. It's already doable but takes a little work. This is all rather
159 rough and badly documented so far.
160
161 You can also do mapping based on the MAC address, if you want specific
162 configuration on specific card. See
163 /usr/share/doc/ifupdown/examples/get-mac-address.sh and the stanza in
164 /usr/share/doc/ifupdown/examples/network-interfaces.gz that uses it.
165 This comes back to the problem I alluded to with mapping scripts not
166 being "nestable" yet, and bug #154442. You can do what you want today,
167 but you may need to write your own mapping script which uses a
168 combination of MAC address and scheme info to return a stanza name to
169 ifupdown.
170
171 -----
172
173 (Contributed by Jean Tourrilhes <[email protected]>)
174 The 'ifscheme' scripts mentionned above are now available in
175 Debian Sarge, in the 'ifscheme' package.
176 The MAC address based mapping mentioned above is deprecated,
177 you should use 'ifrename' to assign a consistent interface name to
178 each of your network interface. This is documented in
179 HOTPLUG.txt. This enable the combination of MAC address identification
180 of interfaces with scheme multi-configuration.
181
182 -----
183
184 If you need automatic wireless configuration, you can look at
185 the following packages :
186 o ifupdown-roaming :
187 http://panopticon.csustan.edu/thood/ifupdown-roaming.html
188 o waproamd
189 http://0pointer.de/lennart/projects/waproamd/
190
191 ---------------------------------------------------------------------
192
193 SuSE 8.0 and later
194 --------
195 (Contributed by Christian Zoz <[email protected]>)
196 All network configuration is done in the directory
197 /etc/sysconfig/network. It does not matter if it's a build in NIC or
198 PCMCIA, USB, etc. The files network.opts and wireless.opts in
199 /etc/pcmcia are not used any longer. There is /sbin/ifup to set up all
200 kind of network interface.
201 There is a file /etc/sysconfig/network/wireless where you may
202 set most of the options of iwconfig in seperate variables (they are
203 named like the options). Additionally you may use
204 WIRELESS_IWCONFIG_OPTIONS e.g. for setting key 2, 3 or 4 or
205 unsupported iwconfig commands. This file is documented and its
206 settings are used for any wlan NIC.
207 Configuration of wireless variable looks like :
208 WIRELESS_ESSID="<essid>"
209 Every variable from file wireless may be used in the interface
210 configuration files /etc/sysconfig/network/ifcfg-* as well. As
211 expectable this overwrites the global setting in wireless. For
212 sophisticated use of the ifcfg-* files read 'man ifup'.
213
214 Hint for PCMCIA and USB users:
215 You need not to use the iterface name for the configuration as
216 this may vary from one plugin to another. You may use a description of
217 your hardware instead (ifcfg-<MACADDRESS> or ifcfg-pcmcia-1 for card
218 in Slot 1)
219
220 Some of the variables can be set with YaST2 as well.
221
222 If you miss the 'schemes' functionality from the pcmcia-cs
223 packages use the tool SCPM (System Configuration Profile Management)
224 instead. This extends the pcmcia schemes to the whole system
225 configuration. Read 'info scpm'. Since SuSE 8.1 there also is a YaST2
226 modul for SCPM.
227
228 ---------------------------------------------------------------------
229
230 RED-HAT 7.2
231 -----------
232 (Grabbed from various source - Google is your friend)
233 Configuration is done in the file :
234 /etc/sysconfig/network-scripts/ifcfg-ethN
235 Where 'ethN' is the name of the wireless interface (such as
236 eth0, eth1, ...).
237 The following lines may be added in this file :
238 MODE=<mode>
239 ESSID="<essid>"
240 RATE=<rate>
241 TXPOWER=<txpower>
242 KEY="<key>"
243 The full list of configuration can be found in the file :
244 /etc/sysconfig/network-scripts/ifup-wireless
245
246 Note that Brad Allison has other tips for 7.2 :
247 http://jackal.dnsalias.com:8080/public/misc/wireless/wireless.html
248
249 ---------------------------------------------------------------------
250
251 RED-HAT 7.3 and later
252 -----------
253 (Cut'n'pasted from Brad Allison web page)
254 http://jackal.dnsalias.com:8080/public/misc/wireless/wireless.html
255
256 If you are running RedHat 7.3, I would tell you to simply run
257 /usr/bin/redhat-config-network and click "Devices", Click "Add", then
258 select "Wireless Connection". You can find the full instructions in
259 RedHat's Customization Guide for RH7.3 in Chapter 6, Network
260 Configuration: Wireless Connection.
261 http://www.redhat.com/docs/manuals/linux/
262 http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/s1-network-config-wireless.html
263
264 However, according to the Errata: The version of the Red Hat
265 Network Administration Tool that shipped with Red Hat Linux 7.3 did
266 not include wireless connection in the configuration wizard. An
267 enhancement errata will be released soon with this feature. You can
268 download the newest version of redhat-config-network from rpmfind.net.
269 http://www.redhat.com/docs/errata/RHL-7.3-Manual/
270 http://www.rpmfind.net/linux/rpm2html/search.php?query=redhat-config-network&submit=Search+...
271
272 -----
273
274 (Grabbed from various source - Google is your friend)
275 The current graphical user interface support :
276 ESSID, Mode, Freq, Channel, Rate, Key
277
278 Compared to Red-Hat 7.2, the Wireless Setting in the
279 configuration file have change to include the WIRELESS_ prefix :
280 WIRELESS_MODE=<mode>
281 WIRELESS_ESSID='<essid>'
282 WIRELESS_ENC_KEY='<key>'
283 The underlying configuration files and configurations options
284 seems to be indentical to what is done in Mandrake 8.2 (or vice
285 versa), so please check the section below. This allow configuration of
286 additional wireless settings not available in the GUI.
287
288 -----
289
290 (Extrapolated from web page of Martin Pot <[email protected]>)
291 http://ii.net/~mpot/wireless/router.cgi
292 Red-Hat 7.3 also seem to support configuration in
293 wireless.opts to some extent. But for compatibility with the network
294 admin tools, I would still recommend to use the above method.
295 Red-Hat 7.3 seems to load wvlan_cs for Orinoco cards and
296 friends. The above web page explain how to switch it to orinoco_cs.
297
298 ---------------------------------------------------------------------
299
300 RED-HAT 9.0 and later
301 -----------
302 (Cut'n'pasted from Dax Kelson web page)
303 http://www.gurulabs.com/RedHatLinux9-review.html
304
305 A little known fact is that newer versions of RHL support
306 multiple network profiles. This is useful for machines that commonly
307 plug into different networks (think laptops). The easy way to create
308 network profiles is to use the redhat-config-network command. The
309 question then becomes, what happens when you type "ifup eth0"? The
310 behavior wasn't defined in previous versions, however, now in RHL 9
311 the following behavior is defined;
312
313 search path for:
314 # ifup $DEV
315 is:
316 /etc/sysconfig/networking/profiles/$CURRENT_PROFILE/ifcfg-$DEV
317 /etc/sysconfig/networking/profiles/default/ifcfg-$DEV
318 /etc/sysconfig/network-scripts/ifcfg-$DEV
319
320 A cool trick is to boot your RHL box directly into a profile
321 from the GRUB boot screen. To do this, create a separate
322 /etc/boot/grub.conf entry for each network profile, and in each entry
323 add the kernel argument netprofile=profilename.
324
325 -----
326
327 I'm pretty certain the profile scheme above also apply to
328 wireless settings, which is good news...
329
330 ---------------------------------------------------------------------
331
332 MANDRAKE 8.2 and later
333 ------------
334 (Grabbed from various source - Google is your friend)
335 Configuration is done in the file :
336 /etc/sysconfig/network-scripts/ifcfg-ethN
337 Where 'ethN' is the name of the wireless interface (such as
338 eth0, eth1, ...).
339 The following lines may be added in this file :
340 WIRELESS_MODE=<mode>
341 WIRELESS_ESSID=<essid>
342 WIRELESS_NWID=<nwid>
343 WIRELESS_FREQ=<freq/channel>
344 WIRELESS_SENS=<sensitivity>
345 WIRELESS_RATE=<rate>
346 WIRELESS_ENC_KEY=<keys>
347 WIRELESS_RTS=<rts>
348 WIRELESS_FRAG=<frag>
349 WIRELESS_IWCONFIG=<iwconfig command>
350 WIRELESS_IWSPY=<iwspy command>
351 WIRELESS_IWPRIV=<iwpriv command>
352 Most likely, you only need to add a few of those lines and not
353 all of them. The script doing the configuration and where you can
354 check the details is :
355 /etc/network/network-scripts/ifup-wireless
356 You will of course need the Wireless Tools package :
357 rpm -Uvh wireless-tools-XX-Xmdk.XXX.rpm
358
359 Mandrake can also have wireless setting added to its
360 Auto-Install procedure :
361 http://members.shaw.ca/mandrake/drakx/8.2/HTML/section4-13.html
362
363 -----
364
365 (in e-mail from Thierry Vignaud <[email protected]>)
366 You may use the following tool :
367 o drakconnect
368 You may read the following documentation :
369 o ifcfg
370
371 ---------------------------------------------------------------------
372
373
374 Have fun...
375
376 Jean
+0
-1062
src/lwe/HOTPLUG.txt less more
0 Sane network interface management with Hotplug
1 ----------------------------------------------
2
3 INTRODUCTION
4 ------------
5 In the old days all wireless cards were managed by the
6 excellent Pcmcia subsystem and its rich configuration scripts, and
7 life was good. Then came the wireless PCI cards, then the wireless
8 USB dongles. Some unification was needed, and rather than adapt the
9 Pcmcia subsystem for PCI and USB, it was decided to create the much
10 simpler Hotplug system.
11 The USB subsystem already uses Hotplug. The Pcmcia subsystem
12 is migrating to it : CardBus cards (32 bits) already use Hotplug,
13 whereas Pcmcia cards (16 bits) still use the old Pcmcia scripts.
14 The Hotplug system is still in its infancy, but already shows
15 some good promise. Most users are disappointed at first by its
16 apparent lack of features compared to the Pcmcia scripts. In this
17 document, we will show how to fully exploit the Hotplug system and try
18 to implement the equivalent of all the functionality of the Pcmcia
19 scripts.
20
21 ASSUMPTIONS
22 -----------
23 The target audience of this document is mostly power users and
24 distribution maintainers, but it should give enough clues to help
25 newbies. You should have read and understood DISTRIBUTIONS.txt. The
26 procedures described here are more advanced than the simple
27 configuration described in DISTRIBUTIONS.txt.
28 The main focus is of course on removable wireless interfaces,
29 but we will to talk about network interface management in general, so
30 this should apply also to built-in Ethernet cards.
31
32 PROBLEM STATEMENT
33 -----------------
34 Let's assume a Linux system and two or more network devices,
35 Device A and Device B. Those devices may be built-in or removable,
36 they may be present or absent from the system at any time, and they
37 may activated in any particular order.
38 The user wants to assign Configuration A to Device A and
39 Configuration B to Device B, without the possibility that Device A
40 gets assigned Configuration B.
41 Different users may have different definitions of what is
42 Device A. For some, it's a specific instance of a specific hardware,
43 for others any hardware that meets some criteria (a wireless card, an
44 Ethernet card).
45 The user may also want to have multiple configurations for a
46 given device such that the chosen configuration depends on various
47 factors, just as with the old Pcmcia schemes. Device A may need
48 Configuration A1 or Configuration A2 depending on those factors.
49 By default, all network interfaces are created using default
50 interface names (starting at "eth0" and going up). I call that the
51 "all my cards are eth0" problem : im most distributions, "eth0" points
52 to a single fixed configuration in the configuration
53 database. Clearly, this won't satisfy our requirements.
54
55 EXAMPLE SYSTEM
56 --------------
57 The distribution I use is Debian 3.0, and some parts of what I
58 say here will be specific to it. However, it should be easy to
59 translate this material to other distributions and I welcome additions
60 to this document.
61
62 The example system is as follows :
63 o Linux 2.6.X SMP kernel with hotplug support
64 o Fully modular system (all network drivers as modules)
65 o PCI Ethernet card : AMD PCnet LANCE (pcnet32 - eth4)
66 o PCI Ethernet card : HP 100VG J2585B (hp100 - eth2)
67 o ISA Wireless card : Old AT&T Wavelan (wavelan - eth3)
68 o ISA-Pcmcia bridge : VADEM VG-469 (i82365 - slot 0)
69 o PCI-CardBus bridge : Ricoh RL5c475 (yenta_socket - slot 2)
70 o Pcmcia 802.11 card : Aironet 350 (airo_cs - eth0)
71 o Pcmcia 802.11 card : Lucent Orinoco (orinoco_cs - eth0)
72 o CardBus 802.11 card : SMC 2835W (prism54 - prism0)
73
74 This system just happens to be my Linux development box. It
75 has enough interfaces to make it interesting. All the examples I
76 present in this document are extracted from this system.
77
78 BASIC CONCEPTS
79 --------------
80 Most of the concept and tricks presented here are not really
81 new. The main contribution is to integrate them.
82
83 1) Removable network interfaces are managed by Hotplug
84 (Pcmcia, CardBus, USB...). We can't assume that those interfaces are
85 always present in this system and available at boot time (Pcmcia cards
86 were not made to be soldered in the Pcmcia slot). Therefore Hotplug is
87 the way to go.
88 2) Built-in PCI and ISA cards are managed by the init scripts,
89 as they have always been. The ISA subsystem will never have Hotplug
90 support, and hotplug is not necessary for PCI cards.
91 3) Built-in devices that are disable most of the time should
92 be enabled manually by the user. Therefore both Hotplug and the init
93 scripts should ignore those devices by default.
94 4) (1), (2) and (3) must be compatible on the same system and
95 play nice with each other.
96
97 5) A well defined and consistent network interface name is
98 assigned to each network hardware interface using 'ifrename'. Device A
99 is always named 'ethA' (or whatever name you like such as
100 'mynetworkcard').
101 6) No interface is called 'eth0' (or 'wlan0'). Any unknown
102 device would be 'eth0', so known devices should be called something
103 else.
104 7) Multiple configurations for a single interface (schemes)
105 are managed by the ifup/ifdown subsystem.
106
107 CONFIGURATION FROM INIT SCRIPTS
108 -------------------------------
109 It may seem paradoxical, but before setting up Hotplug, we
110 need to make sure that the initialisation of network cards via init
111 scripts is done properly and doesn't get in the way of the Hotplug
112 subsystem.
113 The configuration of network cards via init scripts is the
114 traditional way networking is initialised in Linux. The advantage of
115 this method is that it's very well documented and understood, and has
116 not changed much over the years. Unfortunately, it doesn't adequately
117 support removable cards.
118
119 The init scripts perform the following 3 functions in order :
120 1) Load necessary driver modules
121 2) Rename interface to name chosen by the user
122 3) Configure those network interfaces
123
124 1) Applicability
125 ----------------
126 Configuration from init scripts is applicable to any built-in
127 network interface (ISA, PCI...), i.e., interfaces available at boot
128 time and that will never be removed from the system.
129 The Hotplug subsystem also has the ability to configure some
130 of the built-in network interfaces, such as PCI cards. However, there
131 is a class of devices that will never have Hotplug support, such as
132 ISA and EISA cards.
133
134 2) Loading driver modules (if/as needed)
135 ----------------------------------------
136 Most distributions build the kernel drivers as modules. This
137 modular setup allows to minimise the amount of memory used by the
138 system and the flexible loading/unloading of drivers.
139 You can also compile your kernel with static drivers
140 (non-modular). In that case, the driver will always be available in
141 the kernel, you don't need to configure the module subsystem, so you
142 can skip directly to the next section.
143
144 There are 3 alternatives to manage device drivers as
145 modules.
146 1) Some distributions have an explicit list of modules
147 that are loaded at boot time. If you want to use that feature you need
148 to check the documentation of your distribution.
149 2) Some system, such as Hotplug, Discover or Kudzu,
150 can scan the various buses of the PC and load the appropriate
151 drivers. This is mostly configuration-free, but may not support all
152 devices and may load unnecessary modules.
153 3) The module subsystem also allows to load modules
154 'on-demand'. When an application try to access or configure a network
155 interface, the corresponding module is loaded.
156
157 I personally prefer to use the 'on-demand' feature of the
158 module subsystem, as this allow you to not have to specify a static
159 list of modules that need to be loaded, and only modules really needed
160 are loaded which saves kernel memory. You can also choose which module
161 to load when there are multiple modules available that support your
162 hardware (which happens quite often).
163
164 With kernel 2.6.X the module subsystem is configured in the
165 file /etc/modprobe.conf or files in the directory /etc/modprobe.d/. To
166 configure 'on-demand' module loading, on my test system I need to add
167 to the following lines to the configuration :
168
169 --------- /etc/modprobe.d/local or /etc/modprobe.conf ------
170 # HP 100VG J2585B PCI card
171 alias eth2 hp100
172
173 # AMD AMD PCnet LANCE PCI card
174 alias eth4 pcnet32
175
176 # Old AT&T Wavelan ISA card
177 alias eth3 wavelan
178 options wavelan io=0x390 irq=15
179 ------------------------------------------------------------
180
181 Your distribution may already have lines for your interfaces,
182 either replace these or make sure they are correct (some distributions
183 are notorious for picking the wrong driver name in some cases). This
184 file also contains configuration for lot of other subsystems,
185 obviously you don't want to touch that.
186 In this file, you put the name you would like the interface to
187 have (we'll fix that in a minute). Note that for modern PCI cards this
188 is much more straightforward than for old ISA cards.
189
190 3) Installing 'ifrename'
191 ------------------------
192 You will need to install ifrename on your system. 'ifrename'
193 is part of the Wireless Tools package (version 27 and later) and is a
194 complete rewrite of the now obsolete 'nameif'.
195 Some distributions, such as Debian Sarge, offer a separate
196 package for 'ifrename', and in this case you should just install this
197 package. Other distributions may include ifrename as part of their
198 'wireless-tools' package (this should be the case for Gentoo, Fedora
199 and Mandrake). Other distributions, such as Debian 3.0, don't include
200 ifrename at all, so you should compile yourself a recent version of
201 Wireless Tools (v27 or later) and install it.
202
203 In any case, you should verify that 'ifrename' is properly
204 installed and check the path needed to call it :
205 --------------------------
206 > which ifrename
207 /sbin/ifrename
208 --------------------------
209 Most distributions will install 'ifrename' in '/sbin', while if
210 you compile your own wireless tools, it will be in '/usr/local/sbin'.
211
212 4) Making the boot scripts call 'ifrename'
213 ------------------------------------------
214 You need to make sure 'ifrename' is run at boot time. Most
215 distributions don't do that yet by default.
216 This is a part that is distribution-specific, so you will need
217 to look into your own init files, or ask people familiar with your
218 distribution. It will need to run just before the call to 'ifup' or
219 'ifconfig' command.
220
221 In Debian 3.0 and Debian Sarge, it needs to be run from
222 /etc/init.d/networking, which is not the default. The necessary patch
223 is below :
224
225 ----------------------------------------------------------------
226 --- networking-orig Wed Feb 18 13:56:23 2004
227 +++ networking Fri Feb 20 14:51:06 2004
228 @@ -120,6 +120,15 @@ case "$1" in
229 doopt syncookies no
230 doopt ip_forward no
231
232 + # Optionally remap interface names based on MAC address.
233 + # '/sbin/ifrename' is part of wireless-tools package.
234 + # /etc/iftab is currently not created by default. Jean II
235 + if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then
236 + echo -n "Remapping network interfaces name: "
237 + ifrename -p
238 + echo "done."
239 + fi
240 +
241 echo -n "Configuring network interfaces: "
242 ifup -a
243 echo "done."
244 ----------------------------------------------------------------
245 Don't forget to set the appropriate path to the ifrename
246 command (see step (3) above).
247
248 You may also want to also set the proper options for ifrename
249 (check the man page).
250 The option '-p' enables module autoloading compatibility.
251 The default version of 'ifrename' also includes some special
252 Debian support : using "ifrename -p -d", only the proper modules are
253 loaded. If you are using Debian, you should use this option.
254
255 5) Renaming interfaces
256 ----------------------
257 As stated above, we use 'ifrename' to assign names to
258 interfaces.
259
260 First, you need to get the MAC address of each of your
261 interfaces. You can read the MAC address on the label of the card, or
262 display it using the 'ifconfig -a' command. Remember that the
263 interface won't load yet with the proper name, so you may need to do a
264 bit looking around :
265
266 -----------------------------
267 # modprobe pcnet32
268 # ifconfig eth0
269 eth0 Link encap:Ethernet HWaddr 00:10:83:34:BA:E5
270 [...]
271 -----------------------------
272
273 The configuration of 'ifrename' is simple, you just specify
274 which name should be used for each MAC address in the file
275 /etc/iftab :
276
277 --------- /etc/iftab ------------------------
278 # HP 100VG J2585B PCI card
279 eth2 mac 08:00:09:*
280
281 # Old AT&T Wavelan ISA card
282 eth3 mac 08:00:0E:*
283
284 # AMD AMD PCnet LANCE PCI card
285 eth4 mac 00:10:83:*
286 ---------------------------------------------
287
288 The '*' in the MAC address is a wildcard and allows me to
289 replicate my configuration between multiple identical computers. If
290 you have to manage large number of computers (like a rack of servers
291 or clusters), then you may want to look at other selectors offered by
292 'ifrename'.
293
294 To test that ifrename works, do the following :
295 o Load all your drivers, see section (2)
296 o Check /proc/net/dev to see which interface exist
297 o Bring all interfaces down : ifconfig ethX down
298 o Run ifrename
299 o Check each interface with ifconfig
300 o Bring all interfaces up : ifconfig ethX up
301
302 6) Configuring interfaces
303 -------------------------
304 Most likely, your distribution is already doing this part
305 properly. Just assign the proper IP and wireless configuration to each
306 of the interface names you have chosen.
307 This part is distribution specific, and I already document it
308 in the file DISTRIBUTIONS.txt.
309
310 In Debian, you would need to modify the file
311 /etc/network/interfaces so that it looks something like this :
312
313 --------- /etc/network/interfaces -----------
314 # AMD PCnet LANCE PCI card
315 auto eth4
316 iface eth4 inet dhcp
317
318 # HP 100VG J2585B PCI card
319 auto eth2
320 iface eth2 inet static
321 address 10.0.0.2
322 netmask 255.255.255.0
323 broadcast 10.0.0.255
324 gateway 10.0.0.1
325 ---------------------------------------------
326
327 This was the last part. Now, at your next boot, all your
328 interfaces should be assigned the proper name and the proper
329 configuration.
330
331 CONFIGURATION VIA HOTPLUG
332 -------------------------
333 Dealing with removable interfaces is similar to dealing with
334 built-in interfaces, the main difference is that we will use the
335 Hotplug scripts instead of the init scripts. Another difference is
336 that it will likely require more work on your part because most
337 distributions are not fully ready for it.
338
339 1) Applicability
340 ----------------
341 The Hotplug configuration method is the best choice for any
342 removable network interface, such as :
343 o Pcmcia (16 bits) network cards
344 o CardBus (32 bits) network cards
345 o USB network dongles
346 o Hot-PCI network cards
347 It may also be used to manage other types of network
348 interfaces, although it may not be the best choice for them.
349
350 2) How Hotplug works
351 --------------------
352 Conceptually, Hotplug is very simple. When something
353 interesting happens, the Linux kernel generates an Hotplug event. This
354 runs the proper script from the /etc/hotplug directory.
355 There are 3 types of Hotplug events we care about :
356 o PCI event : a CardBus device is added or removed
357 from the system. The script /etc/hotplug/pci.agent is run.
358 o USB event : a USB device is added or removed
359 from the system. The script /etc/hotplug/usb.agent is run.
360 o Network event : a network interface is added or
361 removed from the system. The script /etc/hotplug/net.agent is run.
362
363 If we insert a CardBus network card in the system, the
364 following happens :
365 1) Kernel detects new CardBus device
366 2) Kernel generates PCI Hotplug event
367 3) /etc/hotplug/pci.agent runs, finds proper driver module
368 4) /etc/hotplug/pci.agent loads driver module
369 5) Driver module initialises, creates new network device
370 6) Kernel detects new network device
371 7) Kernel generates Network Hotplug event
372 8) /etc/hotplug/net.agent runs, configures network device
373 The sequence of events is similar for removals and USB devices.
374
375 3) Make sure ifup does not deadlock
376 -----------------------------------
377 <Most people should ignore this part>
378 The first problem is that we need to make sure the command
379 'ifup' does not deadlock by calling itself re-entrantly. If the system
380 has built-in interfaces, the 'ifup' may reenter itself at boot time
381 via Hotplug :
382 1) Init scripts start running
383 2) Init script calls 'ifup -a' to initialise built-in
384 network interfaces
385 3) 'ifup' auto-loads driver module for built-in network
386 interface 'eth4'
387 4) Driver module initialises, creates new network device
388 5) Kernel generates Network hotplug event
389 6) /etc/hotplug/net.agent runs, call 'ifup eth4'
390 Note that you can produce the same reentrancy if you call ifup
391 manually on an interface which module is not yet loaded.
392
393 The default version of 'ifup' for Debian 3.0 and Debian Sarge
394 is not reentrant and can therefore deadlock if not used properly. The
395 patch to make 'ifup' properly reentrant is available here :
396 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231197
397 Contemporary versions of Debian (Sarge and later) have a
398 net.agent script that contains workarounds to prevents deadlock
399 situations, so for normal use the default 'ifup' should work fine.
400
401 Other distributions have very different ifup programs and I
402 have not tried those (tell me about it !).
403
404 4) Installing Hotplug for Debian Sarge (testing/unstable)
405 ---------------------------------------------------------
406 Thanks to the great work of many people, Debian Sarge has all
407 the necessary packages and hotplug support, and will work mostly 'out
408 of the box'.
409 You will need to install the following packages :
410 o hotplug
411 o ifrename
412
413 While the installation of Hotplug is simple, its configuration
414 may seem complex. The current network Hotplug script has 3 modes :
415 'all', 'auto' and 'hotplug'. However for our purpose they all produce
416 the same results when configured. This mode is controlled by the
417 variable NET_AGENT_POLICY in /etc/default/hotplug.
418
419 In the mode "all", Hotplug will run ifup for all network
420 events. This will result in failure messages if some interfaces have
421 already been configured by the init scripts. This mode is not
422 recommended.
423
424 In the mode "auto", Hotplug will run ifup only for those
425 interfaces listed in a auto stanza in /etc/network/interfaces. If
426 you choose this mode, you need to put in /etc/network/interfaces a
427 "auto" line for the interfaces you want to control with hotplug.
428 --------- /etc/network/interfaces -----------
429 # Enable Hotplug support for "auto" mode (Sarge and later)
430 auto eth0 eth1 eth2 eth3 eth4 wlan0 wlan1 prism0 prism1 airo0 airo1
431 ---------------------------------------------
432 This will result in some failure message at boot time, the
433 init script will attempt to enable all those interfaces, and generate
434 an error for all those not available at this time. It will also
435 generate an error messages for interface which have already been
436 configured by the init scripts. This mode is also not recommended.
437
438 In the mode "hotplug", hotplug network events are ignored by
439 ifup by default. To enable them you will need to add the following
440 lines to /etc/network/interfaces :
441 --------- /etc/network/interfaces -----------
442 # Enable Hotplug support for "hotplug" mode (Sarge and later)
443 mapping hotplug
444 script echo
445 ---------------------------------------------
446
447 To enable them for only selected interfaces, e.g., ethA, make
448 /etc/network/interfaces look like this :
449 --------- /etc/network/interfaces -----------
450 # Enable Hotplug support for "hotplug" mode (Sarge and later)
451 mapping hotplug
452 script grep
453 map ethA
454 ---------------------------------------------
455
456 5) Installing Hotplug for Debian 3.0
457 ------------------------------------
458 Debian 3.0 doesn't come by default with hotplug, but the
459 hotplug package is available as regular Debian package (on the CD or
460 downloadable in Debian archive), so you can just install that.
461
462 Unfortunately, this version of hotplug is not fully compatible
463 with kernel 2.6.X. You will need to do the following modifications to
464 the file /etc/hotplug/net.agent.
465
466 ------- /etc/hotplug/net.agent ------------------
467 --- net.agent-d1 Fri Feb 20 18:18:05 2004
468 +++ net.agent Fri Feb 20 18:22:50 2004
469 @@ -26,7 +26,7 @@ if [ "$INTERFACE" = "" ]; then
470 fi
471
472 case $ACTION in
473 -register)
474 +add|register)
475
476 case $INTERFACE in
477 # interfaces that are registered after being "up" (?)
478 @@ -52,7 +52,7 @@ register)
479 mesg $1 $ACTION event not handled
480 ;;
481
482 -unregister)
483 +remove|unregister)
484 # Assume that we want to run ifdown no matter what,
485 # because it is not going to remove the data from the
486 # ifstate database otherwise.
487 -------------------------------------------------
488
489 Compared to the version in Sarge, this older version of
490 hotplug is much more basic, and doesn't have any scanning at boot time
491 and doesn't need to be enabled in /etc/network/interfaces.
492
493 6) Installing hotplug on other distributions
494 --------------------------------------------
495 The canonical version of hotplug is available at :
496 http://linux-hotplug.sourceforge.net/
497
498 Most distributions have customized hotplug packages and
499 chances are that the canonical version won't completely work on your
500 system. All these various changing versions make it difficult for me
501 to tell what exactly needs to be changed in the hotplug scripts to
502 make them work. However, most should work out of the box.
503
504 My guess is that in a few releases, all these problems will
505 sort themselves out. Just be patient.
506
507 7) Dealing with 'init' hotplug
508 ------------------------------
509 In addition to the standard kernel Hotplug events, modern
510 versions of the Hotplug scripts add init scripts that scan the system
511 buses and generate pseudo Hotplug events at boot time. For the PCI
512 buses, the script /etc/hotplug/pci.rc is run, for the USB bus,
513 /etc/hotplug/usb.rc is run.
514 The end result is that the Hotplug subsystem will also attempt
515 to configure built-in devices :
516 1) Kernel boots
517 2) Init runs, start to initialise the OS
518 3) /etc/hotplug/pci.rc runs, generates pseudo Hotplug event
519 4) /etc/hotplug/pci.agent loads driver module
520 5) Driver module initialises, creates new network device
521 6) Kernel generates Network Hotplug event
522 7) /etc/hotplug/net.agent runs, configures network device
523
524 At this point, you realise that at initialisation, both
525 Hotplug and the regular init scripts (see "CONFIGURATION FROM INIT
526 SCRIPTS") are trying to configure the same devices in parallel. This
527 may create problems and is totally redundant.
528 Another reason I don't like this mechanism is that it blindly
529 attempts to load drivers for all hardware present on the system and
530 doesn't use the module loader configuration files to select preferred
531 drivers. It's fairly common to have multiple drivers for a given
532 hardware, and because of Murphy's law, Hotplug will usually load the
533 wrong one. It's also fairly common to have hardware on the system that
534 doesn't need enabling (for example, the IDE controller on my SCSI
535 machine), not loading the driver makes your kernel smaller and boot
536 faster.
537
538 Hotplug does have a way of disabling the loading of drivers
539 on a case by case basis. Drivers listed in /etc/hotplug/blacklist
540 will not be loaded.
541 Hotplug can be disabled for a whole subsystem by editing the
542 appropriate .rc script in /etc/hotplug, or just deleting/renaming
543 those files.
544
545 8) Making hotplug scripts call ifrename
546 ---------------------------------------
547 The last hotplug step is to make sure that 'ifrename' is run
548 by the hotplug subsystem at the right time. As before, we want to run
549 it just before calling 'ifup'.
550 The latest version of the hotplug scripts have this feature
551 integrated. However, you need to check that the path used for calling
552 'ifrename' is the proper one on your system. And, for older versions
553 of hotplug scripts, you will need to add this support yourself.
554
555 Check the path for ifrename :
556 --------------------------
557 > which ifrename
558 /sbin/ifrename
559 --------------------------
560
561 The patch to add 'ifrename' to hotplug looks like :
562
563 ------- /etc/hotplug/net.agent ------------------
564 --- net.agent-s2 Fri Feb 20 17:18:46 2004
565 +++ net.agent Fri Feb 20 17:32:43 2004
566 @@ -40,6 +40,21 @@ add|register)
567 # we can't do much here without distro-specific knowledge
568 # such as whether/how to invoke DHCP, set up bridging, etc.
569
570 + # Run ifrename as needed - Jean II
571 + # Remap interface names based on MAC address. This works around
572 + # the dreaded configuration problem "all my cards are 'eth0'"...
573 + # This needs to be done before ifup, otherwise ifup will get
574 + # confused by the name change and because iface needs to be
575 + # down to change its name.
576 + if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then
577 + debug_mesg invoke ifrename for $INTERFACE
578 + NEWNAME=`/sbin/ifrename -i $INTERFACE`
579 + if [ -n "$NEWNAME" ]; then
580 + debug_mesg iface $INTERFACE is remapped to $NEWNAME
581 + INTERFACE=$NEWNAME
582 + fi;
583 + fi
584 +
585 # RedHat and similar
586 export IN_HOTPLUG=1
587 if [ -x /sbin/ifup ]; then
588 -------------------------------------------------
589
590 If your hotplug scripts already include ifrename support then
591 you should find a section in /etc/hotplug/net.agent looking like the
592 patch above. Otherwise, just cut'n'paste the patch above in the right
593 place.
594 The path for 'ifrename' is used twice above, so don't forget
595 to modify both occurences.
596
597
598 9) Loading driver modules
599 -------------------------
600 Wow ! The most difficult part is done.
601 In theory, you don't need to do any specific configuration for
602 the driver modules to be loaded. The 'pci.agent' and 'usb.agent'
603 should load the right driver module for you.
604 Also, you don't need to define aliases in /etc/modprobe.d/* or
605 in /etc/modprobe.conf, it's useless and may be counterproductive.
606
607 If you use a driver compiled statically in the kernel, you
608 also have nothing to do.
609
610 10) Renaming interfaces
611 -----------------------
612 We still use ifrename to assign names to interfaces. The
613 configuration of 'ifrename' is the same. To keep the possibility of
614 having multiple wireless cards (one in each CardBus slot), we use
615 wildcards in both the MAC address and the name :
616
617 --------- /etc/iftab -----------------------
618 # SMC 2835W wireless CardBus card
619 prism* mac 00:30:B4:*
620 ---------------------------------------------
621
622 If you insert two cards, they would be named prism0 and
623 prism1. Note that 'name wildcarding' is a feature only available in
624 2.6.X and 2.4.30 and later, so if you use older version of 2.4.X you
625 will need to be explicit and list each card separatly :
626
627 --------- /etc/iftab -----------------------
628 # SMC 2835W wireless CardBus card
629 prism0 mac 00:30:B4:64:27:8B
630 prism1 mac 00:30:B4:64:27:8D
631 ---------------------------------------------
632
633 11) Configuring interfaces
634 -------------------------
635 At this point, configuration of Hotplug interfaces is done
636 just like their built-in counterparts. This part is still distribution
637 specific, and still already documented in the file DISTRIBUTIONS.txt.
638
639 In Debian, you would need to modify the file
640 /etc/network/interfaces like this :
641
642 --------- /etc/network/interfaces -----------
643 # Enable Hotplug support (Sarge and later)
644 mapping hotplug
645 script grep
646 map prism0
647
648 # SMC 2835W wireless CardBus card
649 iface prism0 inet static
650 address 10.0.1.2
651 netmask 255.255.255.0
652 broadcast 10.0.1.255
653 wireless-essid THE_ESSID
654 wireless-mode ad-hoc
655 wireless-channel 5
656 ---------------------------------------------
657
658 Note that you should not have wireless-* lines if you are
659 using waproamd to set these parameters.
660
661 Now, just cross your fingers and plug the card in the slot...
662
663 PCMCIA INTERFACES (16 bits)
664 ---------------------------
665 The Pcmcia subsystem has quite some legacy, and can use
666 various configuration procedures. The Pcmcia subsystem exclusively
667 uses hotplug for 32 bits cards (if you are using the kernel Pcmcia
668 modules, which is the only option for 2.6.X). For 16 bit cards cardmgr
669 is still required for managing the sockets and loading
670 modules. Cardmgr is configured by files in the /etc/pcmcia directory.
671
672 To use Hotplug network configuration with 16 bits Pcmcia
673 cards, first make sure the Pcmcia subsystem is properly configured and
674 that cardmgr loads the right driver module (in most case, it
675 should). Then, make sure that you don't have any configuration entries
676 in /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Make sure
677 that none of the entries in your system network configuration use
678 'eth0' or 'wlan0' (in /etc/network/interfaces for Debian users).
679 Then, just follow the procedure described above for
680 "Configuration Using Hotplug" to configure your network cards.
681
682 You might want a little bit of explanation on why this magic
683 will work (which would help in case it doesn't work).
684 There are two types of Pcmcia network configuration scripts,
685 available as /etc/pcmcia/network. The original Pcmcia script
686 configures network cards using options found in
687 /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. Most
688 distributions replace it with a script calling 'ifup'. By making sure
689 that network.opts and wireless.opts are "empty", we neutralise the
690 first set of scripts. By making sure no system configuration uses
691 'eth0' or 'wlan0', we neutralise the second set of scripts, the script
692 would call 'ifup' with the default interface name, which is usually
693 'eth0', ifup would not find a configuration for it and would just
694 ignore it.
695 The card would still be configured because hotplug network
696 events are generated for every interfaces, not only for devices
697 managed by hotplug. So, net.agent would receive an event and perform
698 the necessary steps to configure it.
699
700 Personally, I'm still using the original Pcmcia scripts for my
701 Pcmcia cards as described in the file PCMCIA.txt, because it still
702 works and I will migrate my complex configurations over time.
703 You can also decide to not use Hotplug for Pcmcia cards and
704 modify the distribution Pcmcia scripts in /etc/pcmcia/* to handle
705 Pcmcia cards with ifrename. You would need to modify
706 /etc/pcmcia/network to add 'ifrename' before 'ifup' the same way it
707 was done for /etc/hotplug/net.agent. But, as in the long term Pcmcia
708 will migrate to Hotplug, I would not bother...
709
710 MANUAL LOADING, DOCKING STATIONS
711 --------------------------------
712 Manual loading is used for built-in network interfaces that
713 are only use at specific time, and that you want disabled the rest of
714 the time. We assume that you still use modules so that when the
715 interface is not used you can remove the driver from the kernel.
716
717 First, you need to set the configuration for those interfaces,
718 the same way it's done for other network interfaces. The main
719 difference is that you need to specify that those interfaces should
720 not be enabled at boot time. It's also a good idea to disable Hotplug
721 init scripts.
722 With Debian, you just need to make sure that the 'auto"
723 keyword doesn't apply to this interface.
724
725 If you use drivers statically built in the kernel, make sure
726 that ifrename runs at boot time (see CONFIGURATION FROM INIT
727 SCRIPTS). Once it's done, you can just enable and disable those
728 interfaces with 'ifup ethX' and 'ifdown ethX'.
729
730 If you use both a modular system, make sure that the
731 'on-demand' module loading is properly configured :
732
733 --------- /etc/modprobe.d/local or /etc/modprobe.conf ------
734 # HP 100VG J2585B PCI card
735 alias eth2 hp100
736
737 # AMD AMD PCnet LANCE PCI card
738 alias eth4 pcnet32
739 ------------------------------------------------------------
740
741 Then, you should instruct 'ifup' to load module and use
742 ifrename prior to configuring the interface, and remove the module
743 when going down. With Debian, this is done with :
744
745 --------- /etc/network/interfaces -----------
746 # AMD AMD PCnet LANCE PCI card
747 # noauto
748 iface eth4 inet dhcp
749 pre-up /sbin/ifrename -p -n eth4
750 post-down /sbin/modprobe -r eth4
751
752 # HP 100VG J2585B PCI card
753 # noauto
754 iface eth2 inet static
755 address 10.0.0.2
756 netmask 255.255.255.0
757 broadcast 10.0.0.255
758 gateway 10.0.0.1
759 pre-up /sbin/ifrename -p -n eth2
760 post-down /sbin/modprobe -r eth2
761 ---------------------------------------------
762
763 We use the '-n' option of ifrename to specify the name of the
764 interface after renaming. This assume that the mapping for those
765 interfaces don't use wildcards. The '-p' option make sure ifrename
766 probes the module prior to using it.
767 Using "modprobe -r" make sure that if the driver is composed
768 of multiple module all the modules are unloaded.
769
770 To enable the interface, just use :
771 -----------------------------------
772 ifup eth4
773 -----------------------------------
774 And to disable the interface :
775 -----------------------------------
776 ifdown eth4
777 -----------------------------------
778
779 This solution is obviously Debian specific, but could be
780 adapted to other distributions. If you can't manage to get your
781 distributions to use those tricks, you can do things manually.
782 If you don't use Hotplug, you enable an interface with :
783 -----------------------------------
784 modprobe eth4
785 ifrename
786 ifup eth4
787 -----------------------------------
788 If you use hotplug, you only need to do :
789 -----------------------------------
790 modprobe eth4
791 -----------------------------------
792 On the other hand, disabling the interface is done with :
793 -----------------------------------
794 ifdown eth4
795 modprobe -r eth4
796 -----------------------------------
797
798
799 Docking stations for laptops may contain built-in
800 interfaces. My previous laptop had one, and Linux had no support for
801 it. After docking, I was able to bring up the network ISA card in the
802 docking station.
803 However, with most laptops and version of Linux, the issue is
804 that after docking, the new devices are not seen. The solutions is to
805 force a rescan of the PCI bus. Documentation is unclear on that, maybe
806 'scanpci' may help.
807
808 To be able to simply manage my docking station, I had created
809 two little scripts to enable and disable my network interface.
810 After docking, you would run :
811 -------- /sbin/dock ----------------------------
812 #!/bin/sh
813 modprobe eth4
814 ifrename
815 ifup eth4
816 ------------------------------------------------
817 And prior to undocking, you would run :
818 -------- /sbin/undock ----------------------------
819 #!/bin/sh
820 ifdown eth4
821 modprobe -r eth4
822 ------------------------------------------------
823 Thanks to 'ifrename', the network interface in your dock will
824 always be properly configured regardless of if you have a Pcmcia
825 network card in the Pcmcia slot or not.
826
827
828 SCHEMES (MULTI-CONFIG)
829 ----------------------
830 Most Ethernet cards will only connect to a single network, or
831 can use DHCP to be auto-configured. With Wireless Cards, it's much
832 more likely that you will need multiple configurations, for example at
833 work, at home and on-the-go.
834
835 Most distributions have various level of support for such
836 schemes. Some distributions offer simple network schemes, while other
837 offer "overall" schemes changing the whole configuration. I document
838 the support for schemes in various distributions in the file
839 DISTRIBUTIONS.txt.
840
841 You can also use tools such as ifplugd, waproamd or
842 wlandetect. Those tools are a kind of "wireless-DHCP", they attempt to
843 automatically detect the proper wireless configuration and apply
844 it. Most will also attempt to detect network changes.
845 The main limitation of those tools is that they offer very
846 little manual control. If two valid alternatives are possible, you
847 can't switch between them. If a configuration can't be detected, they
848 usually fail.
849 That's the same concept as using DHCP versus Static IP
850 addresses. Some people are very happy with DHCP, my style is Static IP
851 addresses.
852
853 If you use Debian and want to use simple manual schemes, these
854 are the things you need to do.
855 1) Make sure that 'ifscheme' and 'ifscheme-mapping' are
856 installed on the system. You may find them in a separate tar file on
857 my web site.
858 2) Check the path for 'ifscheme-mapping' (using whereis).
859 3) Modify you /etc/network/interface to add proper mapping and
860 configuration.
861
862 ------- /etc/network/interfaces ----------------------
863 # Enable Hotplug support (Sarge and later)
864 mapping hotplug
865 script echo
866
867 # SMC 2835W wireless CardBus card
868 mapping prism0
869 script /sbin/ifscheme-mapping
870
871 iface prism0-any inet dhcp
872 wireless-essid any
873 wireless-mode managed
874
875 iface prism0-adhoc inet static
876 address 10.0.1.2
877 network 10.0.1.0
878 netmask 255.255.255.0
879 broadcast 10.0.1.255
880 wireless-essid THE_ESSID
881 wireless-mode ad-hoc
882 wireless-channel 5
883
884 iface prism0-other inet static
885 address 10.10.10.2
886 network 10.10.10.0
887 netmask 255.255.255.0
888 broadcast 10.10.10.255
889 wireless-essid ANOTHER_ESSID
890 wireless-mode ad-hoc
891 wireless-key "s:secure"
892 ------------------------------------------------------
893
894 FIRMWARE LOADING
895 ----------------
896 A lot of modern wireless card don't have built in firmware and
897 need firmware loading. Recent kernels (2.6.X) have a firmware
898 loader. These are a few notes on how to use it.
899
900 First, read the documentation coming with your driver, because
901 each driver has specificities (like the name of the firmware file it
902 requires). Some drivers may offer additional ways to load the
903 firmware, but in the long term things should be standardised around
904 the hotplug method to simplify packaging in distributions.
905
906 You need to compile your kernel with firmware loading
907 (CONFIG_FW_LOADER in "Generic Driver Options"). If your driver was
908 built from the kernel, chances are that it enabled this feature
909 already. Make sure you boot from this new kernel.
910
911 The 'sysfs' file system must be mounted. The easiest is to
912 mount it at boot time, add a line for it in /etc/fstab :
913
914 -------- /etc/fstab ------------------------------
915 sysfs /sys sysfs defaults 0 0
916 --------------------------------------------------
917
918 Then, you add the firmware file in the directory where it's
919 expected, which is /usr/lib/hotplug/firmware/ in most cases.
920
921 Most distributions nowadays have a version of the Hotplug
922 scripts that knows how to deal with firmware. If it is not the case,
923 just grab the 'firmware.agent' file from an alternate source and copy
924 it into your /etc/hotplug directory (make sure it's executable).
925 You can try the canonical version :
926 http://linux-hotplug.sourceforge.net/
927 Or Debian's version :
928 http://packages.debian.org/unstable/admin/hotplug
929
930 Note that firmware loading will usually only work with
931 interfaces that are fully managed by Hotplug. This is the only way to
932 ensure the that proper sequence of action is happening in the right
933 order every time. Firmware loading may not work properly for
934 interfaces configured in the init scripts.
935 This means that if you have a built-in interface that require
936 firmware loading, you should just use manage those interfaces like
937 removable interfaces (see section above). However, interface
938 configuration need to be explicitly triggered at boot time.
939
940 One possibility is to set-up Hotplug to be run from the init
941 script at boot time. This is usually an option for recent
942 distributions (it's not the case for Hotplug in Debian 3.0). But, we
943 have seen that this has some issues.
944 The other possibility is to use an hybrid between the init
945 script method and the hotplug method. First, you need to add an alias
946 for the driver in /etc/modprobe.conf. Then, you need to specify a
947 mapping for this interface in /etc/iftab, and specify a configuration
948 for this interface and that it is enabled at boot time. Lastly,
949 you make sure that the network init scripts run 'ifrename
950 -p'. 'ifrename' will trigger the module to load, and all the Hotplug
951 events will be generated properly to configure the interface.
952
953 DEVICES WITH MULTIPLE NAMES
954 ---------------------------
955 Some wireless drivers offer multiple network interfaces for
956 the same device. A classical example is the Aironet driver that
957 creates a 'ethX' and 'wifiY' for each card.
958
959 'ifrename' allows you a finer selection of interfaces than
960 'nameif'. For example, to only rename the pseudo-Ethernet network
961 interface name of the Aironet driver, you would do :
962
963 --------- /etc/iftab -----------------------
964 # Cisco Aironet 350 wireless Pcmcia card
965 airo* mac 00:07:0E:* arp 1
966 ---------------------------------------------
967
968 After that, your device would be available through 'eth0' and
969 'wifi0'.
970
971 You can rename both interfaces. You just need to remember that
972 'ifrename' starts matching from the last line of the file, so you
973 would do :
974 --------- /etc/iftab -----------------------
975 # Cisco Aironet 350 wireless Pcmcia card
976 wifi* mac 00:07:0E:*
977 airo* mac 00:07:0E:* arp 1
978 ---------------------------------------------
979
980 The current version of 'ifrename' supports only the most useful
981 selectors, but it is architectured such as adding selectors is relatively
982 trivial. If you find a case that 'ifrename' can't handle, you should
983 just extend it.
984
985 DEVICES WITHOUT MAC ADDRESSES
986 -----------------------------
987 Most Ethernet and Wireless devices have a fixed and unique MAC
988 address, and it is therefore advised to name them based on this
989 criteria. However, there are also network interfaces that don't have a
990 fixed and unique MAC address, for example Ethernet over USB, IP over
991 FireWire, PPP and tunnel interfaces.
992 The driver for those devices creates the interface with a name
993 specific to the driver, such as ppp* for PPP interfaces and usb* for
994 Ethernet over USB, and therefore they are easy to identify and
995 configure, and few users feel the need to rename them. Moreover, some
996 of them, such as PPP, have their own configuration scripts and
997 methodology addressing their unique needs.
998
999 There are a few cases where you might want to rename
1000 interfaces without MAC addresses. One example is two Ethernet over USB
1001 dongles. The way to do this is to use alternate ifrename
1002 selectors. Choosing the right selector depends on what you want to
1003 achieve.
1004 A quick theoretical example to illustrate :
1005 --------- /etc/iftab -----------------------
1006 # All other usbnet devices
1007 usb* driver usbnet
1008 # Specific usbnet devices
1009 usb-p firmware "Prolific PL-2301/PL-2302"
1010 usb-4 bus-info usb-00:02.0-1.4
1011 ---------------------------------------------
1012
1013 TROUBLESHOOTING
1014 ---------------
1015 If your interface doesn't show up as expected with ifconfig,
1016 you will need to find out why. First, you need to be familiar with the
1017 sequence of actions in the system and find which one did not happen.
1018
1019 You need to check that the driver module(s) was loaded using
1020 'lsmod'.
1021
1022 You need to check if the interface was properly renamed with
1023 'ifrename'. You can use 'ifrename -D -V' to debug your /etc/iftab.
1024 Get the list of interfaces on your system with 'ifconfig -a'
1025 or 'cat /proc/net/dev', and check if an interface is using the name
1026 you assigned or 'eth0'. Check any suspicious interfaces with 'ifconfig
1027 eth0', and check its MAC address. Note that some rare drivers don't
1028 have a proper MAC address before brought up, which fools ifrename.
1029 Verify that no line in /etc/iftab matches the all-zero MAC
1030 address. The all-zero MAC address matches the loopback interface 'lo'
1031 and various pseudo network devices, renaming the loopback interface is
1032 highly discouraged.
1033
1034 You need to check which configuration was given to the
1035 interface using 'ifconfig' and 'iwconfig'.
1036
1037 The Hotplug subsystem has also good debugging facilities.
1038 To enable Hotplug debugging, just make sure the variable DEBUG
1039 is defined in /sbin/hotplug :
1040 --------- /sbin/hotplug ------------------------------
1041 --- /sbin/hotplug-old Tue Mar 26 09:00:20 2002
1042 +++ /sbin/hotplug Fri Feb 20 18:40:38 2004
1043 @@ -22,7 +22,7 @@
1044 cd /etc/hotplug
1045 . hotplug.functions
1046
1047 -# DEBUG=yes export DEBUG
1048 +DEBUG=yes export DEBUG
1049
1050 if [ "$DEBUG" != "" ]; then
1051 mesg "arguments ($*) env (`env`)"
1052 ------------------------------------------------------
1053 Then, you can check your message logs for Hotplug events with
1054 'tail -f /var/log/messages'. Verify that the various Hotplug events
1055 happen as expected (pci, firmware, net...), and verify the log
1056 messages from 'net.agent'.
1057
1058
1059 Have fun...
1060
1061 Jean
+0
-141
src/lwe/IFRENAME-VS-XXX.txt less more
0 Network interface renaming comparison
1 -------------------------------------
2
3 INTRODUCTION
4 ------------
5 The Wireless Tools package includes 'ifrename', a tool to
6 rename network interfaces. However, this is not the only solution to
7 the problem of renaming network interfaces. This document explain the
8 differences between ifrename and the various alternatives.
9 The subject of interface renaming may look simple at first
10 glance, and is simple in 95% of the cases, however there are many
11 complex scenario and those tools have many features, which explain why
12 we need to go in more details than just saying 'tool X is better'.
13
14 NAMEIF
15 ------
16 The tool 'nameif' was designed to rename network
17 interfaces. It either loads mapping from the file /etc/mactab or
18 accept mapping on the command line.
19 It is part of the net-tools package :
20 http://www.tazenda.demon.co.uk/phil/net-tools/
21
22 Advantages over 'ifrename' :
23 + More widespread, available in very old distributions
24 + simpler/smaller
25 Drawbacks compared to 'ifrename' :
26 - Only support MAC address selector
27 - Does not support hotplug invocation
28 - Does not support module on-demand loading
29 Comments :
30 o The fact that nameif does not support selector other
31 than the MAC address is problematic, as USB-NET devices may not have
32 MAC addresses and some ethernet/wireless drivers can't query the MAC
33 address before 'ifconfig up'.
34 o 'ifrename' was designed as a better 'nameif', and
35 its concept is very similar.
36
37 IPROUTE
38 -------
39 The tool 'ip' can rename network interfaces with the following
40 syntax :
41 > ip link set <oldname> name <newname>
42 It is part of the 'iproute' package :
43 http://developer.osdl.org/dev/iproute2/
44
45 Advantages over 'ifrename' :
46 + integrated in 'iproute', which most people need anyway
47 Drawbacks compared to 'ifrename' :
48 - Do not support any selector, must use old interface name
49 - No 'batch' mode, must rename each interface manually
50 Comments :
51 o 'ip' only provide the most basic facility. To use it
52 automatically, like in init/hotplug scripts, wrappers adding some
53 rules/selector must be written.
54
55 DRIVER MODULE PARAMETERS
56 ------------------------
57 Some network driver have module parameters enabling to specify
58 the network name of all the devices created by the driver. This is
59 driver specific, so you will need to check your driver.
60
61 Advantages over 'ifrename' :
62 + very simple to get configured and running
63 Drawbacks compared to 'ifrename' :
64 - Not universally supported : few drivers do it
65 - Fragmented : each driver does it differently
66 - The only selector available is the driver
67 Comments :
68 o This method was never popular with the kernel
69 people, and this feature is being removed from driver that use to
70 include it.
71
72 UDEV
73 ----
74 The package 'udev' include facility to rename network
75 interfaces, with rules such as :
76 KERNEL="eth*", SYSFS{address}="00:52:8b:d5:04:48", NAME="lan"
77 This is part of the udev package :
78 http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
79
80 Advantages over 'ifrename' :
81 + simpler to setup if 'udev' is already properly setup
82 + automatically generates persistent rules
83 Drawbacks compared to 'ifrename' :
84 - Less selectors that 'ifrename'
85 - Require kernel 2.6.X or later with sysfs support
86 - Do no support non-hotplug interfaces
87 - Require 'udev', not everybody uses it (static /dev, devfs)
88 Comments :
89 o 'udev' support many selectors, basically all those
90 present in 'sysfs' (excluding symlinks), even if the documentation
91 only show instructions to use the MAC address (which is problematic
92 with virtual devices some drivers - see above). 'ifrename' can also
93 use all selectors present in 'sysfs' (like 'udev'), can use sysfs
94 symlinks and parent directories, plus some other selectors not present
95 in sysfs that were found to be useful.
96 o Not all interfaces are managed by hotplug. All
97 virtual devices, such as tunnels and loopbacks, are not associated
98 with a hardware bus, and therefore are not managed by hotplug. All
99 driver compiled statically into the kernel are not managed by
100 hotplug. 'udev' can't deal with those devices.
101 o It is common practice on embedded system to use a
102 static /dev and not 'udev' to save space and boot time. And to not use
103 hotplug for the same reasons.
104 o 'ifrename' has now a udev compatiblity mode that
105 enables to trivially integrate it into 'udev' as an IMPORT rule. This
106 requires udev version 107 or better and ifrename 29-pre17 or better.
107
108 SELECTOR AWARE NETWORK SCRIPTS
109 ------------------------------
110 Another method is to not rename the interface at all, and make
111 the various network script selector aware. The basic idea is to simply
112 ignore the interface name and have all the network scripts based on
113 selectors.
114 The main example is the original Pcmcia network scripts. They
115 allow you to configure an interface directly based on MAC address and
116 Pcmcia socket. Another example is the script get-mac-address.sh used
117 as a mapping in some Debian configuration. On the other hand, Red-Hat
118 and Fedora scripts don't apply, as they wrap around 'nameif'.
119
120 Advantages over 'ifrename' :
121 + usually simpler to setup and understand
122 Drawbacks compared to 'ifrename' :
123 - Less selectors that 'ifrename'
124 - Only work for the scripts, other tools left confused
125 Comments :
126 o This method is conceptually simpler, and works
127 well. It eliminates the two steps process of other methods (renaming ;
128 configuring).
129 o Unfortunately, this method only apply to the
130 specific scripts, and not to the majority of the networking tools
131 which are still based on interface name. This means that when the user
132 use those other tools, he is left guessing which interface is which.
133 o Distributions never never really embraced this
134 method, as they all replaced the original Pcmcia scripts with one
135 using the interfacename.
136
137 Have fun...
138
139 Jean
140
+0
-151
src/lwe/INSTALL less more
0 Very important note :
1 -------------------
2 This release of the Wireless Tools is not compatible with
3 Wireless Extensions earlier than 9. Version 9 and 10 should work fine
4 but are not recommended. Version 8 and earlier will not work.
5 Kernels that support this version of the Wireless Tools are
6 listed below. For all kernels before that, see at the end.
7
8 You need :
9 --------
10 o Compiler and development environment
11 o A kernel supporting wireless extensions version 11 or higher
12 -> from 2.4.4 onward (including 2.6.X)
13 Note : CONFIG_NET_RADIO must be enabled
14 o (Optional) A Pcmcia package supporting Wireless Extension
15 o A driver supporting wireless extensions
16 -> Check my web pages for status of various drivers.
17 Note : more recent kernels and drivers are likely to support
18 more wireless extension features...
19
20 Compile wireless tools :
21 ----------------------
22 In theory, a "make" should suffice to create the tools.
23
24 Installation :
25 ------------
26 "make install" should do the right thing for you, and install
27 the tools, their library and the man pages. You can also uninstall the
28 tools via "make uninstall".
29 Note that the default installation is in the directory
30 '/usr/local/sbin'. This may not be in your path. Also, other version
31 of the tools may exist on the system, so double check which version is
32 the default and adjust your path as necessary.
33
34 Create a local copy of the tools :
35 --------------------------------
36 By default, the package is built with iwlib as a dynamic
37 library, and the tool will expect to use the default version of libiw
38 on the system. This means you can't use the tools until they are
39 properly installed.
40 If you just want to experiment with a "local" version of the
41 tools, you may want to pass the BUILD_STATIC flag to Makefile. It will
42 create a self contained version of the tools.
43 -------------
44 make clean
45 make BUILD_STATIC='y'
46 -------------
47 The resulting binary can be used in the compilation directory
48 or installed in any place you like.
49
50 Other useful Makefile options :
51 -----------------------------
52 PREFIX : where the tools will be installed (default : /usr/local)
53 CC : Compiler to use (defaul : gcc)
54 BUILD_STATIC : build tools with a static version of the wireless lib
55 BUILD_NOLIBM : build tools without mathematical lib (slower)
56 BUILD_STRIPPING : strip symbols from tools/lib.
57 BUILD_WE_ESSENTIAL : remove less used and obsolete features.
58
59 You can pass those options on the command line of make, or
60 modify the top of the Makefile. You can also set them as environment
61 variable, but this is not recommended.
62 If you pass those options on the command line, you should pass
63 the same command line options for all invocations of make ("make" and
64 "make install").
65
66 Memory footprint reduction :
67 --------------------------
68 The Wireless Tools are used in various embedded systems where
69 memory footprint is a great concern. The Wireless Tools package offer
70 multiple options to customise the compilation depending on the level
71 of features you want.
72 The list below details the must useful combinations of these
73 options, from the largest footprint to the smallest. Footprint depend
74 on lot's of factor and is purely indicative (version 29-pre7+, i386,
75 glibc, gcc 3.3.5).
76
77 1) Static build
78 Command line : make BUILD_STATIC='y'
79 - : Largest footprint
80 - : libiw not included (other third party tools may depend on it)
81 Size : ~280 kB
82
83 2) Default build
84 Command line : make
85 + : Fully featured version of the tools
86 - : Largest footprint (except for static version of tools)
87 Size : ~190 kB (libiw : ~29 kB ; ifrename : ~29 kB)
88
89 3) Stripping (remove function symbols)
90 Command line : make BUILD_STRIPPING='y'
91 + : Fully featured version of the tools
92 - : Still quite large
93 Size : ~110 kB (libiw : ~23 kB ; ifrename : ~17 kB)
94
95 4) Multicall version (include stripping)
96 Command line : make iwmulticall ; make install-iwmulticall
97 + : Fully featured version of the tools
98 + : Small
99 - : libiw not included (other third party tools may depend on it)
100 - : ifrename is not included
101 Size : ~55 kB
102
103 5) Multicall + Essential
104 Command line : make BUILD_WE_ESSENTIAL='y' iwmulticall
105 + : Smaller
106 - : Some less used features are left out
107 - : libiw not included (other third party tools may depend on it)
108 - : ifrename is not included
109 Size : ~44 kB
110
111 6) iwconfig only + essential + static
112 Command line : make BUILD_WE_ESSENTIAL='y' BUILD_STATIC='y' BUILD_STRIPPING='y' iwconfig
113 + : Very small
114 - : Very limited functionality : no scanning, no event, no iwpriv
115 - : libiw not included (other third party tools may depend on it)
116 - : ifrename is not included
117 Size : ~28 kB
118
119 Wireless headers (past history) :
120 -------------------------------
121 Previous version of the Wireless Tools had to be compiled with
122 the same version of Wireless Extension that the kernel was using, and
123 that was a major source of troubles.
124 Starting with version 27, Wireless Tools include all the ugly
125 code to deal with any version of Wireless Extensions, so now you can
126 compile a single "generic" version of the tools for any kernel.
127 Well, there are some limits, Wireless Extensions earlier than
128 v11 are not supported (v9 and v10 should work fine), and versions
129 later than the latest definition in the package are not
130 supported. Once compile, the command "iwconfig --version" should tell
131 you that.
132 Note that the previous option to make versioned installed of
133 the tools no longer make sense and therefore is gone.
134
135 Old kernel with older Wireless Extensions :
136 -----------------------------------------
137 Kernel prior to 2.2.14 : Those kernels include Wireless
138 Extensions v8 or earlier. Those versions don't have proper support for
139 802.11b, so are not very useful. You may want to consider upgrading.
140 Kernel 2.2.19 to 2.2.25 : Those kernels include Wireless
141 Extensions v10. The tools should mostly work with it, but many drivers
142 won't. You can upgrade those kernel to WE v15 with a patch on my web
143 page.
144 Kernel 2.2.14 to 2.2.18 : Those kernels include Wireless
145 Extensions v9. Same as above, you may want to upgrade to a later 2.2.X
146 kernel and then apply the patch.
147 Kernel 2.0.X : Those kernels include very old version of
148 Wireless Extensions. Same deal as old 2.2.X kernels.
149
150 Jean <[email protected]>
+0
-229
src/lwe/Makefile less more
0 ##
1 ## Please check the configurion parameters below
2 ##
3
4 ## Installation directory. By default, go in /usr/local.
5 ## Distributions should probably use /, but they probably know better...
6 ifndef PREFIX
7 PREFIX = /usr/local
8 endif
9
10 ## Compiler to use (modify this for cross compile).
11 CC = gcc
12 ## Other tools you need to modify for cross compile (static lib only).
13 AR = ar
14 RANLIB = ranlib
15
16 ## Uncomment this to build tools using static version of the library.
17 ## Mostly useful for embedded platforms without ldd, or to create
18 ## a local version (non-root).
19 # BUILD_STATIC = y
20
21 ## Uncomment this to build without using libm (less efficient).
22 ## This is mostly useful for embedded platforms without maths.
23 # BUILD_NOLIBM = y
24
25 ## Uncomment this to strip binary from symbols. This reduce binary size.
26 ## by a few percent but make debug worse...
27 # BUILD_STRIPPING = y
28
29 ## Uncomment this to build with only essential functionality.
30 ## This leaves out the less used features and cut in half the tools.
31 ## This is mostly useful for embedded platforms without limited feature needs.
32 # BUILD_WE_ESSENTIAL = y
33
34 # ***************************************************************************
35 # ***** Most users should not need to change anything beyond this point *****
36 # ***************************************************************************
37
38 # Version of the Wireless Tools
39 WT_VERSION := $(shell sed -ne "/WT_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
40
41 # Version of Wireless Extensions.
42 WE_VERSION := $(shell sed -ne "/WE_VERSION/{s:\([^0-9]*\)::;p;q;}" < iwlib.h )
43
44 # Always use local header for wireless extensions
45 WEXT_HEADER = wireless.$(WE_VERSION).h
46
47 # Targets to build
48 STATIC=libiw.a
49 DYNAMIC=libiw.so.$(WT_VERSION)
50 PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
51 MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
52 MANPAGES7=wireless.7
53 MANPAGES5=iftab.5
54 EXTRAPROGS= macaddr iwmulticall
55
56 # Composition of the library :
57 OBJS = iwlib.o
58
59 # Select which library to build and to link tool with
60 ifdef BUILD_STATIC
61 IWLIB=$(STATIC)
62 IWLIB_INSTALL=install-static
63 else
64 IWLIB=$(DYNAMIC)
65 IWLIB_INSTALL=install-dynamic
66 endif
67
68 # Standard name for dynamic library so that the dynamic linker can pick it.
69 # We will just create a symbolic link to the real thing.
70 DYNAMIC_LINK= libiw.so
71
72 # Install directories
73 INSTALL_DIR= $(PREFIX)/sbin/
74 INSTALL_LIB= $(PREFIX)/lib/
75 INSTALL_INC= $(PREFIX)/include/
76 INSTALL_MAN= $(PREFIX)/man/
77
78 # Various commands
79 RM = rm -f
80 RM_CMD = $(RM) *.BAK *.bak *.d *.o *.so ,* *~ *.a *.orig *.rej *.out
81 LDCONFIG = ldconfig
82
83 # Do we want to build with or without libm ?
84 ifdef BUILD_NOLIBM
85 LIBS=
86 WELIB_FLAG= -DWE_NOLIBM=y
87 else
88 LIBS= -lm
89 endif
90
91 # Stripping or not ?
92 ifdef BUILD_STRIPPING
93 STRIPFLAGS= -Wl,-s
94 else
95 STRIPFLAGS=
96 endif
97
98 # Do we want to build with only essential functionality ?
99 ifdef BUILD_WE_ESSENTIAL
100 WEDEF_FLAG= -DWE_ESSENTIAL=y
101 endif
102
103 # Other flags
104 CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
105 -Wpointer-arith -Wcast-qual -Winline -I.
106 #CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
107 DEPFLAGS=-MMD
108 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
109 PICFLAG=-fPIC
110
111 # Standard compilation targets
112 all:: $(IWLIB) $(PROGS)
113
114 %: %.o
115 $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
116 %.o: %.c wireless.h
117 $(CC) $(XCFLAGS) -c $<
118 %.so: %.c wireless.h
119 $(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
120
121 iwconfig: iwconfig.o $(IWLIB)
122
123 iwlist: iwlist.o $(IWLIB)
124
125 iwpriv: iwpriv.o $(IWLIB)
126
127 iwspy: iwspy.o $(IWLIB)
128
129 iwgetid: iwgetid.o $(IWLIB)
130
131 iwevent: iwevent.o $(IWLIB)
132
133 ifrename: ifrename.o $(IWLIB)
134
135 macaddr: macaddr.o $(IWLIB)
136
137 # Always do symbol stripping here
138 iwmulticall: iwmulticall.o
139 $(CC) $(LDFLAGS) -Wl,-s $(XCFLAGS) -o $@ $^ $(LIBS)
140
141 # It's a kind of magic...
142 wireless.h:
143 cp $(WEXT_HEADER) wireless.h
144
145 # Compilation of the dynamic library
146 $(DYNAMIC): $(OBJS:.o=.so)
147 $(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
148
149 # Compilation of the static library
150 $(STATIC): $(OBJS:.o=.so)
151 $(RM) $@
152 $(AR) cru $@ $^
153 $(RANLIB) $@
154
155 # Installation : So crude but so effective ;-)
156 # Less crude thanks to many contributions ;-)
157 install:: $(IWLIB_INSTALL) install-bin install-hdr install-man
158
159 # Install the dynamic library
160 install-dynamic:: $(DYNAMIC)
161 install -m 755 -d $(INSTALL_LIB)
162 install -m 755 $(DYNAMIC) $(INSTALL_LIB)
163 ln -sfn $(DYNAMIC) $(INSTALL_LIB)/$(DYNAMIC_LINK)
164 @echo "*** Don't forget to add $(INSTALL_LIB) to /etc/ld.so.conf, and run ldconfig as root. ***"
165 @$(LDCONFIG) || echo "*** Could not run ldconfig ! ***"
166
167 # Install the static library
168 install-static:: $(STATIC)
169 install -m 755 -d $(INSTALL_LIB)
170 install -m 644 $(STATIC) $(INSTALL_LIB)
171
172 # All the binaries. Careful, no dependancy on install-dynamic
173 install-bin:: all
174 install -m 755 -d $(INSTALL_DIR)
175 install -m 755 $(PROGS) $(INSTALL_DIR)
176
177 # Headers to go with the wireless lib (dev)
178 install-hdr:: wireless.h
179 install -m 755 -d $(INSTALL_INC)
180 install -m 644 iwlib.h $(INSTALL_INC)
181 install -m 644 wireless.h $(INSTALL_INC)
182
183 # How could you live without those manapages ?
184 install-man::
185 install -m 755 -d $(INSTALL_MAN)/man8/
186 install -m 644 $(MANPAGES8) $(INSTALL_MAN)/man8/
187 install -m 755 -d $(INSTALL_MAN)/man7/
188 install -m 644 $(MANPAGES7) $(INSTALL_MAN)/man7/
189 install -m 755 -d $(INSTALL_MAN)/man5/
190 install -m 644 $(MANPAGES5) $(INSTALL_MAN)/man5/
191
192 install-iwmulticall:: iwmulticall
193 install -m 755 -d $(INSTALL_DIR)
194 install -m 755 $< $(INSTALL_DIR)/iwconfig
195 ( cd $(INSTALL_DIR) ; \
196 ln -f -s iwconfig iwlist ; \
197 ln -f -s iwconfig iwspy ; \
198 ln -f -s iwconfig iwpriv ; \
199 ln -f -s iwconfig iwgetid )
200
201 clean::
202 $(RM_CMD)
203
204 realclean::
205 $(RM_CMD)
206 $(RM) $(STATIC) $(DYNAMIC) $(PROGS) $(EXTRAPROGS) libiw* wireless.h
207
208 uninstall::
209 for f in $(PROGS); do \
210 $(RM) $(INSTALL_DIR)/$$f; \
211 done
212 $(RM) $(INSTALL_LIB)/$(STATIC)
213 $(RM) $(INSTALL_LIB)/$(DYNAMIC)
214 $(RM) $(INSTALL_LIB)/$(DYNAMIC_LINK)
215 $(RM) $(INSTALL_INC)/iwlib.h
216 $(RM) $(INSTALL_INC)/wireless.h
217 for f in $(MANPAGES8); do \
218 $(RM) $(INSTALL_MAN)/man8/$$f; \
219 done
220 for f in $(MANPAGES7); do \
221 $(RM) $(INSTALL_MAN)/man7/$$f; \
222 done
223 for f in $(MANPAGES5); do \
224 $(RM) $(INSTALL_MAN)/man5/$$f; \
225 done
226
227 # Include dependancies
228 -include *.d
+0
-160
src/lwe/PCMCIA.txt less more
0 Pcmcia Wireless configuration
1 -----------------------------
2
3 One of the most exciting things having happen after release 20
4 is the addition of Wireless Tools support in the Pcmcia init
5 scripts. Here is a quick intro on the subject...
6
7 Pre-requisite :
8 -------------
9 o Pcmcia package with Wireless Extension support : 3.1.15 onward
10 o A driver with Wireless Extension support
11 o The tools (iwconfig and co.) installed in the /usr/local/sbin
12 or /usr/sbin
13
14 Raylink driver :
15 --------------
16 The Raylink driver as of 1.70 doesn't support writable
17 Wireless Extensions, so enabling wireless.opts on this driver will
18 make things worse.
19 On the other hand, the latest version of the Raylink driver
20 accepts Wireless Extensions at boot time, so the procedure described
21 below will work.
22
23 Distribution specific notes :
24 ---------------------------
25 Most modern distributions don't use wireless.opts and have
26 their own procedure for wireless configuration, which is usually
27 compatible with their configuration tools and work for non-Pcmcia
28 devices. This is documented in DISTRIBUTIONS.txt.
29 The procedure described here will work only with the original
30 Pcmcia configuration scripts. If you use a precompiled package part of
31 a distributions, this is usually not the case (see above).
32 On the other hand, if you install the Pcmcia package in source
33 form from the official Linux-Pcmcia web site, it will install the
34 proper init scripts and those instructions will apply.
35
36 Basic support :
37 -------------
38 The file /etc/pcmcia/wireless.opts contains some templates for
39 the most common drivers. Just fill in your card configuration in the
40 template corresponding to your driver configuration.
41 Then, to activate it, you just need to remove or comment the 4
42 lines at the top of wireless.opts and restart the Pcmcia package.
43
44 Things to take care of :
45 The options of wireless.opts will be used directly as
46 arguments of iwconfig. So, you need iwconfig, and you need to check
47 the man page of iwconfig to know how to format them.
48 A quick way to determine the correct options without
49 restarting Pcmcia is to play a bit with iwconfig directly to see what
50 is possible and what is the proper setup of the card and to copy that
51 in wireless.opts.
52 At the end of wireless.opts, there is also a generic template
53 containing all the possible options and explaining their meaning. Not
54 all of them are supported by all cards (actually, most cards support a
55 limited subset of it).
56 The current card templates are designed to match the MAC
57 address of the card. Please check that this matches with your card.
58 Also, sample describe the most common/useful options available
59 with the card, for more advance option, borrow options from the
60 template. You can also remove some options, the card will usually
61 initialise with a sane value.
62
63 Alternatively, you can also discard the current wireless.opts
64 and replace it with a file looking like this :
65 ----------- wireless.opts ---------------------
66 case "$ADDRESS" in
67 *,*,*,*)
68 ESSID="MY_ESSID"
69 MODE="Managed"
70 ;;
71 esac
72 -----------------------------------------------
73
74
75 Scheme support :
76 --------------
77 The file wireless.opts fully supports schemes. This allow you
78 to define different configurations (home, work...) and to switch on
79 the fly between them.
80 The best way to explain it is to show an example.
81 Let's say you have an infrastructured setup at work (MY_WORK)
82 and an Ad-Hoc network at home (MY_HOME). Moreover, when a specific card
83 is inserted, you want it to be in Ad-Hoc mode (TEST). The work setup
84 will be the default...
85
86 Each Wireless LAN will have the following configuration :
87 --------- wireless.opts --------------------
88 # Lucent Wavelan IEEE - Ad-Hoc mode for test card
89 *,*,*,00:60:1D:03:9F:2D)
90 ESSID="TEST"
91 MODE="Ad-Hoc"
92 FREQ="10"
93 RATE="1M"
94 ;;
95
96 # Lucent Wavelan IEEE - Ad-Hoc mode at home
97 home,*,*,00:60:1D:*|home,*,*,00:02:2D:*)
98 ESSID="MY_HOME"
99 MODE="Ad-Hoc"
100 FREQ="5"
101 ;;
102
103 # Lucent Wavelan IEEE - infrastructured mode at work
104 *,*,*,00:60:1D:*|*,*,*,00:02:2D:*)
105 ESSID="MY_WORK"
106 MODE="Managed"
107 KEY="s:verysecurekey"
108 ;;
109 --------------------------------------------
110
111 Don't forget the IP configuration :
112 --------- network.opts ---------------------
113 # Wavelan IEEE : ad-hoc mode for test card
114 *,*,*,00:60:1D:03:9F:2D)
115 DHCP="n"
116 IPADDR="10.0.0.1"
117 NETMASK="255.255.255.0"
118 NETWORK="10.0.0.0"
119 BROADCAST="10.0.0.255"
120 ;;
121
122 # Wavelan IEEE : ad-hoc mode at home
123 home,*,*,00:60:1D:*|home,*,*,00:02:2D:*)
124 DHCP="n"
125 IPADDR="10.0.1.19"
126 NETMASK="255.255.255.0"
127 NETWORK="10.0.1.0"
128 BROADCAST="10.0.1.255"
129 GATEWAY="15.0.1.1"
130 ;;
131
132 # Wavelan IEEE : infrastructured mode at work
133 *,*,*,00:60:1D:*|*,*,*,00:02:2D:*)
134 DHCP="y"
135 ;;
136 --------------------------------------------
137
138 Now, when you are at work you do :
139 > cardctl scheme default
140 And at home, you do :
141 > cardctl scheme home
142
143 I guess you get the idea ;-)
144
145 More elaborated configurations :
146 ------------------------------
147 Some people may need some more complex configurations. For
148 example, you might want to do one of the following thing :
149 o cycle through a set of schemes
150 o autodetect the proper scheme
151 There is currently no support to do that. However, the
152 Wireless Tools package contains a tool called "iwgetid" that can help
153 in this job. The source code contains some hints on how to achieve the
154 above thing.
155 If you ever write such a package, please send me the URL.
156 Good luck !
157
158
159 Jean <[email protected]>
+0
-162
src/lwe/README less more
0 Wireless Tools & IfRename
1 -------------------------
2
3 This package contains the Wireless tools, used to manipulate
4 the Wireless Extensions. The Wireless Extensions is an interface
5 allowing you to set Wireless LAN specific parameters and get the
6 specific stats.
7 It also contains the IfRename package, used for advance
8 renaming of network interfaces.
9
10 web page :
11 --------
12 You'll find a lot of useful info on :
13 http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
14 http://web.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
15
16 Precompiled version :
17 -------------------
18 Most Linux distributions offer precompiled package containing
19 these tools. And many of them preinstall them by default. On the other
20 hand, installation of this package is (now) easy and allows you to get
21 a more up-to-date version.
22
23 INSTALL
24 -------
25 This file contains installation instructions and requirements.
26 A *must*-read.
27
28 DISTRIBUTION.txt
29 ----------------
30 This file documents how to configure wireless cards at
31 boot time with various Linux distributions (using Wireless
32 Extensions). Please read it carefully before asking questions.
33 In this file, I try to collect all the specifics of Wireless
34 Extensions integration in the most common Linux distributions. I need
35 your help to complete this file.
36
37 HOTPLUG.txt
38 -----------
39 This file documents how to manage and configure removable
40 wireless cards using Hotplug. This is more advanced than the simple
41 procedures of DISTRIBUTION.txt. This is currently mostly Debian
42 specific, but I hope you will contribute for other distributions.
43
44 PCMCIA.txt
45 ----------
46 This file describes how to use PCMCIA init script to configure
47 Wireless Extensions and how to use PCMCIA schemes.
48
49 man pages (iwconfig.8, iwlist.8, iwpriv.8, iwspy.8)
50 ---------
51 VERY IMPORTANT : I try to keep the man pages up to date, so
52 you'd better read them before asking questions.
53 ALSO IMPORTANT : Those man pages describe the capacities of
54 the tools, no device implements the full range (and drivers usually
55 implement even less).
56
57 As far as I know, the man pages are the most complete, up to
58 date and accurate documentation of the wireless tools. An update of
59 the web page related to Wireless Extensions is long overdue. Send
60 feedback to me.
61 The man pages can either be copied into a location where the
62 command "man" will find them, such as /usr/local/man/man8, or can be
63 read locally with the command :
64 nroff -man xxx.8 | less
65
66 localised man pages (fr/*)
67 -------------------
68 Localised man pages are not made by me, therefore the only
69 localisations available are those sent to me by courageous volonteers,
70 and I expect those man pages to 'lag' compared to the english
71 version (i.e. not have all the latest updates). Translating man pages
72 is not a very gratifying task, especially due to my broken english,
73 and many technical terms don't translate well to other languages, so
74 refer to the english version when in doubt.
75
76 iwconfig.c
77 ----------
78 The main wireless tool. Used for device configuration and to see
79 the most common wireless parameters.
80
81 iwlist.c
82 --------
83 Display some large chunk of information not displayed by iwconfig.
84 For example, all bit rates, all frequencies, all keys...
85
86 iwspy.c
87 -------
88 Mobile IP support test and allows to get stats per MAC
89 address (instead of globally). Also, for some drivers/devices, this is
90 the only way to get stats in Ad-Hoc mode.
91
92 iwpriv.c
93 --------
94 Manipulate driver private ioctls : all parameters that are
95 specific to a driver or a device and therefore not part of iwconfig.
96
97 iwgetid.c
98 ---------
99 Output the ESSID or NWID of the specified device.
100 Can also output it in a form that can be used as a PCMCIA Scheme.
101
102 iwevent.c
103 ---------
104 Display Wireless Events. Most recent drivers will support this
105 relatively new feature, but some older drivers may not support it.
106
107 ifrename.c :
108 ----------
109 Rename network interfaces based on various selectors.
110
111 iwlib.c
112 -------
113 The Wireless Tools helper library. May be useful if you want
114 to create your own applications using Wireless Extensions.
115
116 iwmulticall.c
117 -------------
118 Multicall version of the tools for embedded systems.
119
120 Changelog, contributions :
121 ------------------------
122 See CHANGELOG.h
123
124 wireless.h
125 ----------
126 Definition of the Wireless Extensions. Remember that the
127 definition used by the drivers and the tools must match, otherwise
128 funny things may happen. The tools try to check for that.
129 Since Wireless Extensions v12, you can no longer drop this
130 file into your kernel headers to update the Wireless Extensions, you
131 need to use the full patches available on my web page. So, the use is
132 more if you plan to do some cross compile or something similar.
133 Just for your enjoyment, there are various releases of it. If
134 your kernel/drivers are old, you may want to try the older releases...
135
136 sample_xxx.c :
137 ------------
138 Various samples of code showing how to implement some of the
139 more tricky features of Wireless Extensions in your driver.
140 Note that there is no guarantee that this code compiles, let
141 alone works, but it should point you in the proper direction.
142 Also, have a look at existing drivers in the Linux kernel.
143
144 19-udev-ifrename.rules :
145 ----------------------
146 udev rules to integrate properly ifrename (udev >= 107).
147
148 Other tools :
149 -----------
150 My web page lists many other tools using Wireless
151 Extensions that you may find useful...
152 http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html#links
153
154 Other questions :
155 ---------------
156 You have the source, and it is documented. In 99% of cases,
157 you will find your answer there.
158
159 Good luck...
160
161 Jean <[email protected]>
+0
-162
src/lwe/README.fr less more
0 Wireless Tools
1 --------------
2
3 Ce paquetage contient les Wireless Tools (Outils Wireless), utilisé pour
4 manipuler les Wireless Extensions. Les Wireless Extensions sont une interface
5 vous permettant de manier les paramètres spécifiques aux Wireless LAN (réseaux
6 sans fil) et d'obtenir les statistiques spécifiques.
7
8 page web :
9 --------
10 Vous trouverez beaucoup d'informations utiles sur :
11 http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
12 http://web.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
13
14 version pré compilée
15 --------------------
16 La plupart des distributions Linux fournit un paquetage pré compilé
17 contenant ces outils. Et beaucoup d'entre elles les pré installent par défaut.
18 Par ailleurs, l'installation de ce paquetage est (maintenant) facile et vous
19 permet d'obtenir une version plus à jour.
20
21 INSTALL
22 -------
23 Ce fichier contient les instructions et les requis pour l'installation.
24 *Doit* être lu.
25
26 DISTRIBUTION.txt
27 ----------------
28 Ce fichier documente la manière de configurer les cartes wireless au
29 démarrage avec différentes distributions Linux (en utilisant les Wireless
30 Extensions). Veuillez le lire attentivement avant de poser des questions.
31 Dans ce fichier, j'essaye de rassembler toutes les spécificités de
32 l'intégration des Wireless Extensions dans les ditributions Linux les plus
33 courantes. J'ai besoin de votre aide pour compléter ce fichier.
34
35 HOTPLUG.txt
36 -----------
37 Ce fichier documente la manière de gérer et configurer les cartes
38 wireless éjectables utilisant Hotplug. Il est plus avancé que les simples
39 procédures de DISTRIBUTIONS.txt. Pour l'instant, il est principalement orienté
40 Debian, mais j'espère que vous contribuerez pour d'autres distributions.
41
42 PCMCIA.txt
43 ----------
44 Ce fichier décrit comment utiliser le script init PCMCIA pour configurer
45 les Wireless Extensions et comment utiliser les schemes PCMCIA (NDT : procédures
46 automatiques).
47
48 pages man (iwconfig.8, iwlist.8, iwpriv.8, iwspy.8)
49 ---------
50 TRÈS IMPORTANT : J'essaye de garder les pages man à jour, ainsi vous
51 devriez les lire avant de poser des questions.
52 TRÈS IMPORTANT : Ces pages man décrivent les fonctionnalités des outils,
53 pas un périphérique n'en implémente toute l'étendue (et les pilotes en
54 implémentent souvent encore moins).
55
56 Pour autant que je sache, les pages man constituent la plus complète, la
57 plus à jour et la plus précise des documentations des Wireless Tools. Une mise
58 à jour de la page web concernant les Wireless Extensions a été faite il y a fort
59 longtemps. Envoyez-moi vos retours.
60
61 Les pages man peuvent aussi bien être copiées dans un endroit où la
62 commande « man » les trouvera, comme /usr/local/man/man8, ou peut être lue
63 localement avec la commande :
64 nroff -man xxx.8 | less
65 (NDT : ou plus simplement avec « man ./xxx.8 »)
66
67 pages man localisées (fr/*)
68 --------------------
69 Les pages de man localisées ne sont pas écrites par moi (NDT\ : ainsi
70 que ce document), par conséquent les seules disponibles sont celles qui me sont
71 envoyées par de courageux volontaires et il faut s'attendre à ce que ces pages
72 man soient en décalage par rapport à la version anglaise (c.-à-d. qu'elles
73 n'aient pas toutes les mises à jour). La traduction des pages man n'est pas une
74 tâche très gratifiante, sans compter mon anglais bancal et un certain nombre
75 de termes techniques difficilement traduisibles vers d'autres langues, donc
76 référez-vous à la version anglaise en cas de doute.
77
78 iwconfig.c
79 ----------
80 L'outil wireless principal. Utilisé pour la configuration du matériel et
81 pour voir les paramètres wireless les plus communs.
82
83 iwlist.c
84 --------
85 Affiche une grosse quantité d'information qui ne l'est pas par iwconfig.
86 Par exemple, tous les débits, toutes les fréquences, toutes les clefs...
87
88 iwspy.c
89 -------
90 Test de support Mobile IP et autorise la récupération de statistiques
91 par adresse MAC (au lieu des stats globales). Aussi, pour certains
92 pilotes/périphériques, c'est la seule manière d'obtenir des stats en mode
93 Ad-Hoc.
94
95 iwpriv.c
96 --------
97 Manipule les ioctls privées des pilotes (« driver private ioctls ») :
98 tous les paramètres qui sont spécifiques à un pilote ou à un périphérique et
99 qui, par conséquent, ne font pas partie de iwconfig.
100
101 iwgetid.c
102 ---------
103 Affiche l'ESSID ou le NWID du périphérique spécifié.
104 Peut aussi l'afficher dans un format pouvant être utilisé comme un
105 « PCMCIA Scheme ».
106
107 iwevent.c
108 ---------
109 Affiche les « Wireless Events » (Événements Wireless). Cela est
110 nouveau, il n'y a donc pas encore beaucoup de pilotes qui le supportent...
111
112 ifrename.c :
113 ----------
114 Renomme les interfaces réseau basées sur différents attributs.
115
116 iwlib.c
117 -------
118 Les librairies « helper » Wireless Tools. Peuvent être utiles si vous
119 voulez créer votre propre application en utilisant les Wireless Extensions.
120
121 Changelog, contributions :
122 ------------------------
123 Voir CHANGELOG.h
124
125 wireless.h
126 ----------
127 Définition des Wireless Extensions. Gardez à l'esprit que la définition
128 utilisée par les pilotes et les outils (Wireless Tools) doivent correspondre,
129 sinon de drôles de choses peuvent arriver. Les outils essayent de le vérifier.
130 Depuis les Wireless Extensions v12, vous ne pouvez plus mettre ce
131 fichier dans les entêtes de votre noyau pour mettre à jour les Wireless
132 Extensions, vous avez besoin d'utiliser les patches complets disponibles sur ma
133 page web. Donc, son utilité est plus pour le cas où vous prévoyez de faire de
134 la compilation transverse (if you plan to do some « cross compile ») ou quelque
135 chose de similaire.
136 Juste pour votre plaisir, il y en a différentes versions. Si vos noyau/pilotes
137 sont anciens, vous voudrez peut-être essayer les anciennes versions...
138
139 sample_xxx.c :
140 ------------
141 Différents échantillons de code montrant comment implémenter quelques
142 unes des caractéristiques les plus intéressantes des Wireless Extensions dans
143 votre pilote.
144 Notez qu'il n'y a pas d'assurance que ce code compile, laissez-le tel
145 quel, mais cela devrait vous orienter dans la bonne direction.
146 Aussi, jetez un ½il aux pilotes existant dans le noyau Linux.
147
148 Autres outils :
149 -------------
150 Ma page web liste bien d'autres outils utilisant les Wireless
151 Extensions que vous pourriez trouver utiles...
152 http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html#links
153
154 Autres questions :
155 ----------------
156 Vous avez le source, et il est documenté. Dans 99% des cas, vous y
157 trouverez votre réponse.
158
159 Bonne chance...
160
161 Jean <[email protected]>
+0
-158
src/lwe/cs/ifrename.8 less more
0 .\" Jean II - HPL - 2004
1 .\" ifrename.8
2 .\"
3 .TH IFRENAME 8 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 ifrename \- Pøejmenuje sí»ová rozhraní v závislosti na rùzných statických kritériích
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTAXE
13 .B "ifrename [-c configfile] [-p] [-d] [-v] [-V] [-D]"
14 .br
15 .B "ifrename [-c configfile] [-i interface] [-n newname]"
16 .\"
17 .\" DESCRIPTION part
18 .\"
19 .SH POPIS
20 .B Ifrename
21 je nástroj, který umo¾òuje pøiøadit stálý název pro ka¾dé
22 sí»ové rozhraní.
23 .PP
24 Ve výchozím stavu jsou názvy rozhraní dynamické a ka¾dému sí»ovému rozhraní
25 je pøiøazen první dostupný název
26 .RI ( eth0 ", " eth1 "...)."
27 Poøadí, v kterém jsou sí»ová rozhraní vytváøena, se mù¾e li¹it. U zabudovaných
28 rozhraní závisí na jejich rozpoznání kernelem pøi spou¹tìní. Výmìnná zaøízení mù¾e
29 u¾ivatel pøipojit v jakémkoliv poøadí.
30 .PP
31 .B Ifrename
32 umo¾òuje u¾ivateli rozhodnout, jaký název bude sí»ové rozhraní mít.
33 .B Ifrename
34 mù¾e vyu¾ít celou øadu
35 .IR voleb ", "
36 aby urèil, jak jsou názvy rozhraní pøiøazovány sí»ovým rozhraním v systému.
37 Nejbì¾nìj¹í volbou je
38 .IR "MAC adresa"
39 rozhraní.
40 .PP
41 .B Ifrename
42 musí být spu¹tìn pøedtím, ne¾ jsou rozhraní aktivována, proto je vìt¹inou pou¾íván
43 v rùznıch skriptech (init, hotplug), ale jen zøídka pøímo u¾ivatelem.
44 Jako výchozí,
45 .B ifrename
46 pøejmenuje v¹echna rozhraní pøítomná v systému pou¾itím namapování definovaného v
47 .IR /etc/iftab .
48 .\"
49 .\" PARAMETER part
50 .\"
51 .SH PARAMETRY
52 .TP
53 .BI "-c " konfiguracni_soubor
54 Nastaví konfiguraèní soubor, který bude pou¾it (výchozí je
55 .IR /etc/iftab ).
56 Konfiguraèní soubor definuje namapování voleb a názvù rozhraní
57 a je popsán v
58 .IR iftab (5).
59 .br
60 Pokud je
61 .I konfiguracni_soubor
62 urèen jako "-", je konfigurace naètena ze stdin.
63 .TP
64 .B -p
65 Pokusí se zavést moduly jádra pøed pøejmenováním rozhraní. Jako výchozí
66 prochází
67 .B ifrename
68 pouze rozhraní, která jsou ji¾ zavedena a nezavádí automaticky po¾adované
69 jaderné moduly. Tento pøepínaè umo¾òuje hladkou integraci se systémem, který
70 nezavádí moduly pøed voláním
71 .BR ifrename .
72 .TP
73 .B -d
74 Povolí rùzné úpravy specifické pro
75 .B Debian.
76 V kombinaci s
77 .BR -p
78 budou zavedeny pouze moduly pro rozhraní urèená v
79 .I /etc/network/interface
80 .
81 .TP
82 .BI "-i " rozhraní
83 Pøejmenuje pouze urèené
84 .IR rozhraní ,
85 místo v¹ech rozhraní v systému. Vypí¹e nový název rozhraní.
86 .TP
87 .BI "-n " novy_nazev
88 Kdy¾ je pou¾ito spolu s
89 .IR -i ,
90 urèí nový název rozhraní. Seznam namapování z konfiguraèního
91 souboru je ignorován, rozhraní urèené pomocí
92 .I -i
93 je rovnou pøejmenováno na
94 .IR novy_nazev
95 Nový název mù¾e být ¾olík (wildcard), ale mù¾e obsahovat pouze jedinou "*".
96 .br
97 Pokud je pou¾it bez
98 .IR -i ,
99 pøejmenuje rozhraní s pou¾itím pouze tìch namapování, která by je pøejmenovala na
100 .IR novy_nazev .
101 Nový název nesmí být ¾olík. Tento zpùsob pou¾ití ifrename
102 .RI ( -n " bez " -i )
103 není doporuèen, proto¾e je neefektivní. Musejí být zpracována v¹echna rozhraní systému,
104 a proto není ve vìt¹inì pøípadù rychlej¹í ne¾ kdyby je ifrename pøejmenovalo v¹echny (bez
105 .IR -n " a zároveò bez " -i ).
106 .TP
107 .B -t
108 Povolí podporu pøevzetí názvù. To umo¾ní výmìnu názvù rozhraní
109 mezi dvìma èi více rozhraními.
110 .br
111 Pøevzetí umo¾òuje rozhraní "ukrást" název jinému rozhraní.
112 To funguje pouze s jádrem 2.6.x a pokud druhé rozhraní nebì¾í.
113 Tímpádem není kompatibilní s Hotplug. Druhému rozhraní je pøiøazen
114 náhodný název, který lze pozdìji pomocí "ifrename" zmìnit.
115 .br
116 Poèet pøevzetí je omezen, aby se zabránilo nekoneèným smyèkám,
117 a proto nemusejí být nìkteré komplexní vícecestné situace správnì zpracovány.
118 .br
119 V ka¾dém pøípadì není pøevod názvù a ani pou¾ívání této mo¾nosti doporuèeno,
120 je lep¹í zvolit pro rozhraní jedineèné a jednoznaèné názvy...
121 .TP
122 .B -D
123 Re¾im dry-run ("naneèisto"). Ifrename nezmìní ¾ádné rozhraní, pouze vypí¹e
124 nový název rozhraní, pokud je to mo¾né, a skonèí.
125 .br
126 V re¾imu dry-run nejsou øe¹eny wildcards. Nový název rozhraní je vyti¹tìn
127 i v pøípadì, ¾e je stejnı jako pùvodní název.
128 .TP
129 .B -V
130 U¾vanìný re¾im. Ifrename zobrazí interní výsledky prùchodu svým
131 konfiguraèním souborem a dotazy na volby rozhraní. V kombinaci s
132 pøepínaèem
133 .I dry-run
134 pøedstavuje dobrý zpùsob debugování komplexních nastavení nebo triviálních
135 problémù.
136 .\"
137 .\" AUTHOR part
138 .\"
139 .SH AUTOR
140 Jean Tourrilhes \- [email protected]
141 .\"
142 .\" TRANSLATION part
143 .\"
144 .SH PØEKLAD
145 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
146 .\"
147 .\" FILES part
148 .\"
149 .SH SOUBORY
150 .I /etc/iftab
151 .\"
152 .\" SEE ALSO part
153 .\"
154 .SH DAL©Í INFORMACE
155 .BR ifconfig (8),
156 .BR ip (8),
157 .BR iftab (5).
+0
-189
src/lwe/cs/iftab.5 less more
0 .\" Jean II - HPL - 2004
1 .\" iftab.5
2 .\"
3 .TH IFTAB 5 "1.bøezen 2004" "wireless-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iftab \- statické informace o sí»ových rozhraních
9 .\"
10 .\" DESCRIPTION part
11 .\"
12 .SH POPIS
13 Soubor
14 .B /etc/iftab
15 obsahuje popisnou informaci o rùzných sí»ových rozhraních.
16 .B iftab
17 je pou¾íván pouze programem
18 .IR ifrename (8)
19 k pøiøazení stálých názvù sí»ových rozhraní ka¾dému sí»ovému rozhraní.
20 .PP
21 .B /etc/iftab
22 definuje sadu
23 .IR namapování .
24 Ka¾dé namapování obsahuje název rozhraní a sadu deskriptorù.
25 Deskriptory umo¾òují
26 .B ifrename
27 identifikovat ka¾dé sí»ové rozhraní v systému. Pokud sí»ové rozhraní odpovídá
28 v¹em deskriptorùm z namapování,
29 .B ifrename
30 se pokusí zmìnit název rozhraní na název urèený v namapování.
31 .\"
32 .\" MAPPINGS part
33 .\"
34 .SH NAMAPOVÁNÍ
35 Ka¾dé namapování je popsáno na zvlá¹tní øádce, zaèínající
36 .IR "interface name" ,
37 (názvem rozhraní) a obsahuje sadu
38 .IR deskriptorù ,
39 oddìlených mezerami nebo tabulátory.
40 .PP
41 Vztah mezi deskriptory v namapování je
42 .IR "logické a" .
43 Namapování odpovídá sí»ovému rozhraní, pouze kdy¾ odpovídají v¹echny deskriptory.
44 Pokud sí»ové rozhraní nepodporuje urèitý deskriptor, nebude vyhovovat ¾ádnému
45 namapování pou¾ívajícímu tento deskriptor.
46 .PP
47 Pokud je potøeba pou¾ít alternativní deskriptory pro název rozhraní
48 (logické nebo), vytvoøte dvì rùzná namapování se stejným názvem rozhraní
49 (na ka¾dém øádku jednu).
50 .B Ifrename
51 v¾dycky pou¾ije první odpovídající namapování od
52 .I konce
53 .BR iftab ,
54 proto by restriktivnìj¹í namapování mìla být uvedena naposled.
55 .\"
56 .\" INTERFACE NAME part
57 .\"
58 .SH NÁZEV ROZHRANÍ
59 První èástí ka¾dého namapování je název rozhraní. Pokud sí»ové rozhraní
60 odpovídá v¹em deskriptorùm v namapování,
61 .B ifrename
62 se pokusí zmìnit název rozhraní na název urèený v namapování.
63 .PP
64 Název rozhraní v namapování je buïto pouhý název rozhraní (jako tøeba
65 .IR eth2 " nebo " wlan0 )
66 nebo ¹ablona obsahující jediného ¾olíka (wildcard) (napø.
67 .IR eth* " nebo " wlan* ).
68 V pøípadì ¾olíka nahradí jádro znak "*" za nejni¾¹í dostupné
69 celé èíslo, které zajistí jedineènost názvu rozhraní.
70 .\"
71 .\" DESCRIPTORS part
72 .\"
73 .SH DESKRIPTORY
74 Ka¾dý deskriptor je slo¾en z názvu deskriptoru a hodnoty deskriptoru.
75 Deskriptory urèují statické vlastnosti sí»ového rozhraní, jejich
76 cílem je jednoznaènì identifikovat ka¾dý kus hardware.
77 .PP
78 Vìt¹ina u¾ivatelù pou¾ije pouze volbu
79 .B mac
80 , ostatní volby jsou urèeny k zvlá¹tním nastavením.
81 .TP
82 .BI mac " MAC adresa"
83 Porovná MAC adresu rozhraní se zadanou MAC adresou. MAC adresu
84 rozhraní je mo¾né zobrazit pomocí
85 .IR ifconfig (8)
86 nebo
87 .IR ip (8).
88 Zadaná MAC adresa mù¾e
89 obsahovat "*" pro výbìr ¾olíkù (wildcards).
90 .br
91 Je to nejbì¾nìj¹í volba, proto¾e vìt¹ina rozhraní má unikátní MAC
92 adresu, která umo¾òuje sí»ové rozhraní jednoznaènì identifikovat.
93 Nicménì nìkterá rozhraní nemají MAC adresu, dokud nejsou aktivována
94 a v takovém pøípadì je u¾ití tohoto selektoru o¹idné.
95 .TP
96 .BI arp " typ arp"
97 Porovná typ ARP (ARP Type)(také zvané "Link Type") rozhraní se zadaným typem ARP.
98 Typ ARP u rozhraní je mo¾né zobrazit pomocí
99 .IR ifconfig (8)
100 nebo
101 .IR ip (8).
102 .br
103 Tento selektor je u¾iteènı pokud ovladaè vytváøí více sí»ovıch rozhraní
104 pro jedinou sí»ovou kartu.
105 .TP
106 .BI driver " název ovladaèe"
107 Porovná název ovladaèe rozhraní se zadaným názvem ovladaèe.
108 Název ovladaèe rozhraní je mo¾né zobrazit pomocí
109 .IR "ethtool -i" (8).
110 .TP
111 .BI businfo " informace o sbìrnici"
112 Porovná informaci o sbìrnici rozhraní rozhraní se zadanou informací
113 o sbìrnici. Informaci o sbìrnici rozhraní je mo¾né zobrazit pomocí
114 .IR "ethtool -i" (8).
115 .TP
116 .BI firmware " verze firmware"
117 Porovná verzi firmware rozhraní s informací o verzi firmware.
118 Revizi firmware rozhraní je mo¾né zobrazit pomocí
119 .IR "ethtool -i" (8).
120 .TP
121 .BI baseaddress " port"
122 Porovná port rozhraní se zadaným portem. Port rozhraní je mo¾né zobrazit pomocí
123 .IR ifconfig (8).
124 .br
125 Proto¾e vìt¹ina karet pou¾ívá dynamické pøidìlování portù, je
126 tato volba u¾iteèná pouze pro ISA a EISA karty.
127 .TP
128 .BI irq " èíslo pøeru¹ení"
129 Porovná èíslo pøeru¹ení (IRQ) rozhraní se zadanım
130 èíslem pøeru¹ení. Èíslo pøeru¹ení rozhraní je mo¾né zobrazit pomocí
131 .IR ifconfig (8).
132 .br
133 Proto¾e pøeru¹ení mohou být sdílená, obvykle tento selektor nestaèí
134 k jednoznaèné identifikaci rozhraní.
135 .TP
136 .BI iwproto " bezdrátový protokol"
137 Porovná bezdrátový protokol rozhraní se zadaným
138 bezdrátovým protokolem. Bezdrátový protokol rozhraní je mo¾né zobrazit pomocí
139 .IR iwconfig (8).
140 .br
141 Tato volba je podporována pouze na bezdrátových rozhraních a nestaèí
142 k jednoznaèné identifikaci rozhraní.
143 .TP
144 .BI pcmciaslot " pcmcia slot"
145 Porovná èíslo Pcmcia socketu rozhraní se zadanım èíslem slotu. Èíslo Pcmcia socketu
146 rozhraní je mo¾né zobrazit pomocí
147 .IR "cardctl ident" (8).
148 .br
149 Tato volba je obvykle podporována pouze na 16 bitových kartách, pro 32 bitové
150 karty je lep¹í pou¾ít selektor
151 .BR businfo .
152 .\"
153 .\" EXAMPLE part
154 .\"
155 .SH PьмKLAD
156 # Toto je komentáø
157 .br
158 eth2 mac 08:00:09:DE:82:0E
159 .br
160 eth3 driver wavelan irq 15 baseaddress 0x390
161 .br
162 eth4 driver pcnet32 businfo 0000:02:05.0
163 .br
164 air* mac 00:07:0E:* arp 1
165 .\"
166 .\" AUTHOR part
167 .\"
168 .SH AUTOR
169 Jean Tourrilhes \- [email protected]
170 .\"
171 .\" TRANSLATION part
172 .\"
173 .SH PØEKLAD
174 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
175 .\"
176 .\" FILES part
177 .\"
178 .SH SOUBORY
179 .I /etc/iftab
180 .\"
181 .\" SEE ALSO part
182 .\"
183 .SH DAL©Í INFORMACE
184 .BR ifrename (8),
185 .BR ifconfig (8),
186 .BR ip (8),
187 .BR ethtool (8),
188 .BR iwconfig (8).
+0
-535
src/lwe/cs/iwconfig.8 less more
0 .\" Jean II - HPLB - 1996 => HPL - 2004
1 .\" iwconfig.8
2 .\"
3 .TH IWCONFIG 8 "22.èervna 2004" "wireless-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iwconfig \- nastavuje rozhraní bezdrátové sítì
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTAXE
13 .BI "iwconfig [" rozhraní ]
14 .br
15 .BI "iwconfig " rozhraní " [essid " X "] [nwid " N "] [mode " M "] [freq " F "]
16 .br
17 .BI " [channel " C ] [sens " S "] [ap " A "] [nick " NN ]
18 .br
19 .BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
20 .br
21 .BI " [enc " E "] [key " K "] [power " P "] [retry " R ]
22 .br
23 .BI " [commit]
24 .br
25 .BI "iwconfig --help"
26 .br
27 .BI "iwconfig --version"
28 .\"
29 .\" DESCRIPTION part
30 .\"
31 .SH POPIS
32 .B Iwconfig
33 je podobnı pøíkazu
34 .IR ifconfig (8),
35 ale je vìnovaný bezdrátovým rozhraním. Je pou¾íván k nastavení tìch parametrù
36 sí»ových rozhraní, které jsou specifické pro bezdrátový provoz (napø. frekvence).
37 .B Iwconfig
38 mù¾e být také pou¾it k zobrazení tìchto parametrù a bezdrátových
39 statistik (získaných z
40 .IR /proc/net/wireless ).
41 .PP
42 V¹echny tyto parametry a statistiky jsou závislé na zaøízení. Ka¾dý ovladaè
43 poskytuje, v závislosti na hardwarové podpoøe, jen nìkteré z nich
44 a rozsah hodnot se mù¾e mìnit. Prosím obracejte se na manuálové stránky
45 jednotlivıch zaøízení pro dal¹í detaily.
46 .\"
47 .\" PARAMETER part
48 .\"
49 .SH PARAMETRY
50 .TP
51 .B essid
52 Nastaví ESSID (nebo Network Name - u nìkterých produktù mù¾e být nazváno
53 Domain ID). ESSID se pou¾ívá k identifikaci bunìk, které jsou
54 souèástí stejné virtuální sítì.
55 .br
56 Na rozdíl od adresy AP nebo NWID, která urèuje jedinou buòku, ESSID
57 urèuje skupinu bunìk, spojených opakovaèi (repeater) nebo infrastrukturou,
58 mezi kterými mù¾e u¾ivatel transparentnì pøecházet.
59 .br
60 U nìkterých karet je mo¾né vypnout kontrolu ESSID (promiskuitní ESSID)
61 pomocí
62 .IR off " nebo " any " (a " on
63 k opìtovnému zapnutí).
64 .br
65 Pokud je ESSID sítì jedním z klíèových slov
66 .RI ( off ", " on " nebo " any ),
67 pou¾ije se
68 .I --
69 .br
70 .B Pøíklady:
71 .br
72 .I " iwconfig eth0 essid any"
73 .br
74 .I " iwconfig eth0 essid ""Moje sit""
75 .br
76 .I " iwconfig eth0 essid -- ""ANY""
77 .TP
78 .BR nwid / domain
79 Nastaví Network ID (u nìkterých produktù mù¾e být nazváno Domain ID).
80 Proto¾e v¹echny sousedící bezdrátové sítì sdílejí stejné médium, je
81 tento parametr pou¾íván k jejich rozli¹ení (tvorbì logických kolokovaných
82 sítí) a identifikaci nodù patøících do stejné buòky.
83 .br
84 Tento parametr se pou¾ívá pouze u pre-802.11 zaøízení. Protokol 802.11
85 pou¾ívá pro tuto funkci ESSID a adresu AP.
86 .br
87 U nìkterých karet je mo¾né vypnout kontrolu Network ID (promiskuitní NWID)
88 pomocí
89 .IR off " (a " on
90 k opìtovnému zapnutí).
91 .br
92 .B Pøíklady:
93 .br
94 .I " iwconfig eth0 nwid AB34
95 .br
96 .I " iwconfig eth0 nwid off"
97 .TP
98 .BR freq / channel
99 Nastaví pracovní frekvenci nebo kanál zaøízení. Hodnota ni¾¹í ne¾ 1000
100 znamená èíslo kanálu, hodnota vy¹¹í ne¾ 1000 je frekvence v Hz.
101 Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (napøíklad "2.46G" pro
102 frekvenci 2,46 GHz), nebo doplnit dostateèný poèet nul.
103 .br
104 Kanály jsou obvykle èíslovány od 1, je mo¾né pou¾ít
105 .IR iwlist (8)
106 k získání celkového poètu kanálù, seznamu dostupných frekvencí a zobrazení souèasné
107 frekvence jako kanálu. V závislosti na pøedpisech mohou být nìkteré frekvence/kanály
108 nedostupné.
109 .br
110 .B Pøíklady:
111 .br
112 .I " iwconfig eth0 freq 2422000000"
113 .br
114 .I " iwconfig eth0 freq 2.422G"
115 .br
116 .I " iwconfig eth0 channel 3"
117 .TP
118 .B sens
119 Nastaví práh citlivosti. To je nejni¾¹í úroveò síly signálu pøi které
120 hardware pova¾uje pøijaté pakety za pou¾itelné. Kladné hodnoty jsou
121 interpretovány jako hodnota pou¾ívaná hardwarem nebo jako procenta,
122 negativní hodnoty jako dBm. V závislosti na hardwarové implementaci mù¾e
123 mít tento parametr dal¹í funkce.
124 .br
125 Tento parametr mù¾e ovládat práh pøíjmu (receive threshold) - nejni¾¹í úroveò signálu
126 pøi které se hardware pokusí o pøíjem paketu, slab¹í signál je ignorován. Mù¾e také
127 nastavovat práh ústupu (defer threshold) - nejni¾¹í úroveò signálu, od které hardware
128 pova¾uje kanál za obsazený. Pøi správném nastavení tìchto prahù karta neztrácí èas
129 pøíjmen ¹umu. U moderních zaøízení se zdá, ¾e tyto prahy regulují automaticky.
130 .br
131 U moderních karet mù¾e tento parametr ovládat práh pøedání (handover/roaming
132 threshold) - nejni¾¹í úroveò signálu pøi které hardware je¹tì zùstane asociováno se
133 souèasným pøístupovým bodem. Pokud úroveò signálu poklesne pod tuto hodnotu,
134 zaène karta hledat novı/lep¹í pøístupovı bod.
135 .br
136 .B Pøíklad:
137 .br
138 .I " iwconfig eth0 sens -80"
139 .TP
140 .B mode
141 nastaví pracovní re¾im zaøízení, co¾ závisí na topologii sítì.
142 Re¾im mù¾e být
143 .I Ad-Hoc
144 (sí» slo¾ená pouze z jedné buòky a bez pøístupového bodu),
145 .I Managed
146 (node se pøipojuje do sítì slo¾ené z mnoha pøístupových bodù, s roamingem),
147 .I Master
148 (node je synchronisation master nebo slou¾í jako pøístupový bod),
149 .I Repeater
150 (node pøedává pakety mezi ostatními bezdrátovými nody),
151 .I Secondary
152 (node slou¾í jako zálo¾ní master/repeater),
153 .I Monitor
154 (node není asociován s ¾ádnou buòkou a pasivnì monitoruje pakety na frekvenci) nebo
155 .IR Auto .
156 .br
157 .B pøíklad:
158 .br
159 .I " iwconfig eth0 mode Managed"
160 .br
161 .I " iwconfig eth0 mode Ad-Hoc"
162 .TP
163 .B ap
164 Naøídí kartì pøipojit se k pøístupovému bodu urèenému adresou,
165 pokud je to mo¾né. Pokud se kvalita spojení pøíli¹ sní¾í,
166 mù¾e se ovladaè vrátit do automatického módu (karta vybere
167 nejlep¹í pøístupovı bod v dosahu).
168 .br
169 Je také mo¾né pou¾ít
170 .I off
171 k opìtovnému zapnutí automatického módu beze zmìny souèasného pøístupového bodu
172 nebo
173 .I any
174 èi
175 .I auto
176 k vynucení opìtovné asociace karty s momentálnì nejlep¹ím pøístupovým bodem.
177 .br
178 .B Pøíklad :
179 .br
180 .I " iwconfig eth0 ap 00:60:1D:01:23:45"
181 .br
182 .I " iwconfig eth0 ap any"
183 .br
184 .I " iwconfig eth0 ap off"
185 .TP
186 .BR nick [name]
187 Nastaví pøezdívku neboli station name. Nìkteré 802.11 produkty ji definují,
188 ale co se týká protokolù (MAC, IP, TCP), není pou¾ívána a pøi konfiguraci je
189 zcela nepotøebná. Pou¾ívají ji pouze nìkteré diagnostické nástroje.
190 .br
191 .B Pøíklad:
192 .br
193 .I " iwconfig eth0 nickname ""Muj linuxovy node""
194 .TP
195 .BR rate / bit [rate]
196 U karet, které podporují více pøenosových rychlostí, nastaví rychlost pøenosu v b/s.
197 Rychlost pøenosu je rychlost, kterou jsou bity pøená¹eny médiem,
198 rychlost pro u¾ivatele je ni¾¹í kvùli sdílení média a rùzné re¾ii.
199 .br
200 Je mo¾né pøipojit k hodnotì pøíponu k, M nebo G (dekadický násobitel:
201 10^3, 10^6 a 10^9 b/s), nebo doplnit dostateèný poèet nul. Význam hodnoty ni¾¹í ne¾
202 1000 závisí na pou¾ité kartì, obvykle znamená index v seznamu pøenosových rychlostí.
203 Je mo¾né pou¾ít
204 .I auto
205 ke zvolení re¾imu automatické pøenosové rychlosti (ústup na ni¾¹í rychlost v za¹umìných
206 kanálech), co¾ je u vìt¹iny karet výchozí nastavení, a
207 .I fixed
208 k návratu k pevnému nastavení. Pokud je urèena pøenosová rychlost a
209 .IR auto ,
210 mù¾e ovladaè pou¾ít v¹echny pøenosové rychlosti rovné této hodnotì a ni¾¹í.
211 .br
212 .B Pøíklady:
213 .br
214 .I " iwconfig eth0 rate 11M"
215 .br
216 .I " iwconfig eth0 rate auto"
217 .br
218 .I " iwconfig eth0 rate 5.5M auto"
219 .TP
220 .BR rts [_threshold]
221 RTS/CTS pøidá handshake pøed ka¾dým pøenosem paketù, aby se zajistilo,
222 ¾e je kanál volný. To zvý¹í re¾ii, ale také výkon v pøípadì skrytých nodù
223 nebo velkého poètu aktivních nodù. Tento parametr nastavuje velikost nejmen¹ího
224 paketu, pro který node vysílá RTS; hodnota rovná maximální velikosti paketu
225 tento mechanismus vypne. Je také mo¾né nastavit tento parametr na
226 .IR auto ", " fixed " nebo " off .
227 .br
228 .B Pøíklady:
229 .br
230 .I " iwconfig eth0 rts 250"
231 .br
232 .I " iwconfig eth0 rts off"
233 .TP
234 .BR frag [mentation_threshold]
235 Fragmentace dovoluje rozdìlit IP paket na dávku nìkolika men¹ích èástí
236 pøenesených médiem. To ve vìt¹inì pøípadù zvìt¹í re¾ii, ale ve velmi za¹umìnìm
237 prostøedí sní¾í ztráty zpùsobené chybami a umo¾ní paketùm projít
238 pøi zaru¹ení. Tento parametr nastaví maximální velikost fragmentu; hodnota
239 rovná maximální velikosti paketu tento mechanismus vypne. Je také
240 mo¾né nastavit tento mechanismus na
241 .IR auto ", " fixed " nebo " off .
242 .br
243 .B Pøíklady:
244 .br
245 .I " iwconfig eth0 frag 512"
246 .br
247 .I " iwconfig eth0 frag off"
248 .TP
249 .BR key / enc [ryption]
250 Pou¾ívá se k nastavení ¹ifrovacích klíèù a bezpeènostního re¾imu.
251 .br
252 Pro nastavení aktuálního ¹ifrovacího klíèe se pouze zadá klíè v hexadecimální podobì jako
253 .IR XXXX-XXXX-XXXX-XXXX " nebo " XXXXXXXX .
254 Pro nastavení jiného ne¾ aktuálního klíèe pøidejte pøed nebo za vlastní klíè
255 .I [index]
256 (tím se nezmìní aktuální klíè). Je také mo¾né zadat klíè
257 jako øetìzec ASCII znakù pomocí pøedpony
258 .I s:
259 . Passphrase není v souèasnosti podporovaná.
260 .br
261 Pro urèení, kterı klíè má bıt aktivní, se vlo¾í
262 .I [index]
263 (bez zadбnн hodnoty klниe).
264 .br
265 .IR off " a " on
266 Vypnou a znovu zapnou ¹ifrování.
267 .br
268 Bezpeènostní re¾im mù¾e být
269 .I open
270 (otevøený) nebo
271 .IR restricted ,
272 (uzavøený) a jeho význam závisí na pou¾ité kartì. Vìt¹ina karet nepou¾ívá v
273 .I open
274 (otevøeném) re¾imu ¾ádnou autentizaci a karta mù¾e také pøijímat
275 neza¹ifrované relace, zatímco v
276 .I restricted
277 (uzavøeném) re¾imu jsou akceptovány pouze za¹ifrované relace a karta pou¾ije autentizaci,
278 pokud je k dispozici.
279 .br
280 Pokud je tøeba nastavit více klíèù, nebo nastavit klíè a urèit aktivní klíè,
281 je nutné pou¾ít více pøepínaèù
282 .B key
283 . Parametry mohou být v jakémkoliv poøadí, poslední má pøednost.
284 .br
285 .B Pøíklady:
286 .br
287 .I " iwconfig eth0 key 0123-4567-89"
288 .br
289 .I " iwconfig eth0 key [3] 0123-4567-89"
290 .br
291 .I " iwconfig eth0 key s:password [2]"
292 .br
293 .I " iwconfig eth0 key [2]"
294 .br
295 .I " iwconfig eth0 key open"
296 .br
297 .I " iwconfig eth0 key off"
298 .br
299 .I " iwconfig eth0 key restricted [3] 0123456789"
300 .br
301 .I " iwconfig eth0 key 01-23 key 45-67 [4] key [4]"
302 .TP
303 .BR power
304 Nastavuje re¾im øízení spotøeby a jeho parametry.
305 .br
306 Pro nastavení èasu mezi probuzeními se vlo¾í
307 .IR "period `hodnota'" .
308 Pro nastavení prodlevy pøed návratem do spánku se vlo¾í
309 .IR "timeout `hodnota'" .
310 Je také mo¾né pøidat modifikátory
311 .IR min " a " max
312 . Hodnoty znamenají poèet sekund, pro urèení v milisekundách
313 nebo mikrosekundách se pou¾ije pøípona m nebo u. Nìkdy jsou
314 tyto hodnoty bez jednotek (poèet období mezi beacons a podobnì).
315 .br
316 .IR off " a " on
317 vypne a novu zapne øízení spotøeby. Je také mo¾né nastavit
318 re¾im øízení spotøeby na
319 .I all
320 (pøijímá v¹echny pakety),
321 .I unicast
322 (pøijímá pouze unicast pakety, zahazuje multicast a broadcast) a
323 .I multicast
324 (pøijímá pouze multicast a broadcast, zahazuje unicast pakety).
325 .br
326 .B Pøíklady:
327 .br
328 .I " iwconfig eth0 power period 2"
329 .br
330 .I " iwconfig eth0 power 500m unicast"
331 .br
332 .I " iwconfig eth0 power timeout 300u all"
333 .br
334 .I " iwconfig eth0 power off"
335 .br
336 .I " iwconfig eth0 power min period 2 power max period 4"
337 .TP
338 .BR txpower
339 U karet podporujících rozdílné vysílací výkony nastavuje vysílací výkon v dBm. Je-li dán výkon
340 .I W
341 ve Wattech, je výkon v dBm roven
342 .IR "P = 30 + 10.log(W)" .
343 Pokud je hodnota doplnìna pøíponou
344 .IR mW ,
345 je automaticky pøevedena na dBm.
346 .br
347 Navíc volby
348 .IR on " a " off
349 povolí a zaká¾ou vysílání,
350 .IR auto " a " fixed
351 povolí a zaká¾ou mo¾nost mìnit výkon (pokud je tato vlastnost k dispozici).
352 .br
353 .B Pøíklady:
354 .br
355 .I " iwconfig eth0 txpower 15"
356 .br
357 .I " iwconfig eth0 txpower 30mW"
358 .br
359 .I " iwconfig eth0 txpower auto"
360 .br
361 .I " iwconfig eth0 txpower off"
362 .TP
363 .BR retry
364 Vìt¹ina karet umí MAC retransmisi a nìkteré umo¾òují nastavit
365 chování tohoto mechanismu.
366 .br
367 pro nastavení maximálního poètu pokusù o zaslání se zadá
368 .IR "limit `hodnota'" .
369 Toto je absolutní hodnota (bez jednotky).
370 Pro nastavení nejdel¹ího období, ve kterém se má MAC pokou¹et o zaslání, se zadá
371 .IR "lifetime `hodnota'" .
372 Hodnoty znamenají poèet sekund, pro urèení v milisekundách
373 nebo mikrosekundách se pou¾ije pøípona m nebo u.
374 .br
375 je také mo¾né pøidat modifikátory
376 .IR min " a " max
377 . Pokud karta podporuje automatický re¾im, urèují tyto modifikátory rozmezí pro limit nebo lifetime.
378 Nìkteré karty definují rùzné hodnoty v závislosti na velikosti
379 paketù, napø. v 802.11 urèuje
380 .I min limit
381 tzv. "short retry limit" - limit pro pakety, na které není aplikováno RTS/CTS.
382 .br
383 .B Pøíklady:
384 .br
385 .I " iwconfig eth0 retry 16"
386 .br
387 .I " iwconfig eth0 retry lifetime 300m"
388 .br
389 .I " iwconfig eth0 retry min limit 8"
390 .TP
391 .BR commit
392 Nìkteré karty nemusí provést zmìny zadané pøes Wireless Extensions
393 okam¾itì (mohou èekat na nashromá¾dìní zmìn a pøijmout je
394 a¾ kdy¾ je karta aktivována pomocí ifconfig). Tento pøíkaz (pokud
395 je dostupnı) pøinutí kartu k pøijetí v¹ech nevyøízenıch zmìn.
396 .br
397 To není vìt¹inou potøeba, proto¾e karta èasem zmìny pøijme, ale mù¾e to
398 být u¾iteèné pøi ladìní.
399 .\"
400 .\" DISPLAY part
401 .\"
402 .SH ZOBRAZENÍ
403 Pro ka¾dé zaøízení, které podporuje wireless extensions, zobrazí
404 .I iwconfig
405 název pou¾itého
406 .B MAC protokolu
407 (název zaøízení u proprietárních protokolù),
408 .B ESSID
409 (Network Name),
410 .BR NWID ,
411 .B frekvenci
412 (nebo kanál),
413 .BR sensitivity
414 (citlivost),
415 .B mode
416 (pracovní re¾im),
417 .B Access Point
418 (adresu pøístupového bodu),
419 .B bit-rate
420 (pøenosovou rychlost),
421 .BR "RTS threshold"
422 (práh RTS),
423 .BR "fragmentation threshold"
424 (práh fragmentace),
425 .B encryption key
426 (¹ifrovací klíè) a nastavení
427 .B power management
428 (øízení spotøeby)(pokud je k dispozici).
429 .PP
430 Zobrazené parametry mají stejný význam a hodnoty jako parametry,
431 které mohou být nastaveny, pro jejich podrobnìj¹í vysvìtlení se prosím
432 obra»te se na pøedchozí èást.
433 .br
434 Nìkteré parametry jsou zobrazeny pouze ve své krátké/zkrácené podobì
435 (napø. ¹ifrování). Je mo¾né pou¾ít
436 .IR iwlist (8)
437 k získání detailù.
438 .br
439 Nìkteré parametry mají dva re¾imy (napø. pøenosová rychlost). Pokud
440 hodnotu uvozuje
441 .RB ` = ',
442 znamená to, ¾e parametr je pevný a daný touto hodnotou, pokud
443 ji uvozuje
444 .RB ` : ',
445 je parametr v automatickém re¾imu a je zobrazena aktuální hodnota (a
446 mù¾e se zmìnit).
447 .TP
448 .BR "Access Point" / Cell
449 Adresa rovná 00:00:00:00:00:00 znamená, ¾e se karta nedokázala asociovat
450 s pøístupovım bodem (nejspí¹e problém v nastavení).
451 Parametr
452 .B Access Point
453 bude zobrazen jako
454 .B Cell
455 v re¾imu ad-hoc (ze zøejmých dùvodù), ale jinak znamená to samé.
456 .PP
457 Pokud existuje
458 .IR "/proc/net/wireless" ,
459 .I iwconfig
460 se také pokusí zobrazit jeho obsah. Nicménì tyto hodnoty závisí na
461 ovladaèi a zvlá¹tnostech hardware, tak¾e pro jejich správnou interpretaci je nutné obrátit se na
462 dokumentaci ovladaèe.
463 .TP
464 .B Link quality
465 Celková kvalita spoje. Mù¾e být zalo¾ena na úrovni ru¹ení
466 èi interference, poètu chyb na úrovni bitù nebo rámcù, síle pøijímaného
467 signálu, synchronizaci èasování nebo dal¹ích hardwarových mìøeních. Je to
468 celková hodnota a zcela zále¾í na ovladaèi a hardware.
469 .TP
470 .B Signal level
471 Received signal strength (RSSI - indikátor síly pøijímaného signálu).
472 Mù¾e být v libovolných jednotkách nebo dBm,
473 .I iwconfig
474 pou¾ívá informace z ovladaèe k interpretaci surových dat v
475 .I /proc/net/wireless
476 a zobrazení správné jednotky nebo maximální hodnoty (pomocí 8 bitových výpoètù). V
477 .I Ad-Hoc
478 re¾imu mù¾e být nedefinovaná a mìl by být pou¾it
479 .IR iwspy .
480 .TP
481 .B Noise level
482 Úroveò ¹umu pozadí (kdy¾ není pøená¹en ¾ádný paket). Platí stejné poznámky
483 jako pro
484 .BR "Signal level" .
485 .TP
486 .B Rx invalid nwid
487 Poèet pøijatých paketù s odli¹ným NWID nebo ESSID. Pou¾ívá se
488 k detekci problémù v nastavení nebo existence sousední sítì
489 (na stejné frekvuenci).
490 .TP
491 .B Rx invalid crypt
492 Poèet paketù, které hardware nedokázal de¹ifrovat. Mù¾e indikovat
493 neplatné nastavení ¹ifrování.
494 .TP
495 .B Rx invalid frag
496 Poèet paketù, pro které hardware nedokázal správnì znovu sestavit
497 jednotlivé fragmenty na fyzické vrstvì (nejspí¹e jeden chybìl).
498 .TP
499 .B Tx excessive retries
500 Poèet paketù, které hardware nedokázal odeslat. Vìt¹ina MAC
501 protokolù zkusí poslat paket nìkolikrát, ne¾ to vzdá.
502 .TP
503 .B Invalid misc
504 Ostatní pakety ztracené v souvislosti s urèitými bezdrátovými operacemi.
505 .TP
506 .B Missed beacon
507 Poèet pravidelných beacons z buòky nebo pøístupového bodu, které nebyly zachyceny.
508 Beacons jsou vysílány v pravidelných intervalech pro udr¾ení koordinace a
509 pokud nejsou zachyceny, vìt¹inou to znamená, ¾e je karta mimo dosah.
510 .\"
511 .\" AUTHOR part
512 .\"
513 .SH AUTOR
514 Jean Tourrilhes \- [email protected]
515 .\"
516 .\" TRANSLATION part
517 .\"
518 .SH PØEKLAD
519 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
520 .\"
521 .\" FILES part
522 .\"
523 .SH SOUBORY
524 .I /proc/net/wireless
525 .\"
526 .\" SEE ALSO part
527 .\"
528 .SH DAL©Í INFORMACE
529 .BR ifconfig (8),
530 .BR iwspy (8),
531 .BR iwlist (8),
532 .BR iwevent (8),
533 .BR iwpriv (8),
534 .BR wireless (7).
+0
-118
src/lwe/cs/iwevent.8 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" iwevent.8
2 .\"
3 .TH IWEVENT 8 "23.èerven 2004" "net-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iwevent \- Zobrazí bezdrátové události vyvolané ovladaèi a zmìnami nastavení
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTAXE
13 .BI "iwevent "
14 .br
15 .\"
16 .\" DESCRIPTION part
17 .\"
18 .SH POPIS
19 .B iwevent
20 zobrazí bezdrátové události pøijaté prostøednictvím socketu RTNetlink. Ka¾dý
21 øádek zobrazuje jednotlivou bezdrátovou událost popisující, co se stalo
22 na urèeném bezdrátovém rozhraní.
23 .br
24 Tento pøíkaz nemá ¾ádné parametry.
25 .\"
26 .\" DISPLAY part
27 .\"
28 .SH ZOBRAZENÍ
29 Jsou dva typy bezdrátových událostí.
30 .PP
31 První typ jsou události vztahující se ke zmìnì bezdrátových nastavení na
32 rozhraní (typicky prostøednictvím
33 .B iwconfig
34 nebo skriptu volajícího
35 .BR iwconfig ).
36 Jsou oznamována pouze nastavení, která mohou vést k naru¹ení spojení.
37 V souèasnosti jsou oznamovány události mìnící jedno z následujících
38 nastavení:
39 .br
40 .I " Network ID"
41 .br
42 .I " ESSID"
43 .br
44 .I " Frequency"
45 .br
46 .I " Mode"
47 .br
48 .I " Encryption"
49 .br
50 V¹echny tyto události jsou generovány na v¹ech bezdrátových rozhraních
51 bezdrátovým subsystémem jádra (ale jen kdy¾ byl ovladaè pøeveden na
52 novι API ovladaθω).
53 .PP
54 Dal¹ím typem jsou události generované hardwarem, kdy¾ se nìco stane
55 nebo byl byla dokonèena úloha. Tyto události zahrnují:
56 .TP
57 .B New Access Point/Cell address
58 (nová adresa pøístupového bodu/buòky) Rozhraní se pøipojilo k novému
59 pøístupovému bodu èi AD-Hoc buòce nebo s ním ztratilo spojení. Je to
60 stejná MAC adresa, jako hlásí
61 .BR iwconfig .
62 .TP
63 .B Scan request completed
64 (po¾adavek na skenování dokonèen) Po¾adavek na skenování byl dokonèen,
65 výsledek je k dispozici (viz
66 .BR iwlist
67 ).
68 .TP
69 .B Tx packet dropped
70 (vyslaný paket zahozen) Paket smìrovaný na tuto adresu byl zahozen, proto¾e rozhraní se
71 domnívá, ¾e tento node u¾ neodpovídá (obvykle pokud bylo pøekroèeno maximum
72 pokusù na úrovni MAC). Toto je obvykle prvotní známka toho, ¾e
73 node mohl opustit buòku nebo se ocitl mimo dosah, ale mù¾e to být i
74 zeslabením signálu nebo nadmìrným ru¹ením.
75 .TP
76 .B Custom driver event
77 (Zvlá¹tní událost ovladaèe) Událost specifická pro ovladaè. Prosím prozkoumejte dokumentaci ovladaèe.
78 .TP
79 .B Registered node
80 Rozhraní úspì¹nì zaregistrovalo nového bezdrátového klienta/peer.
81 Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod
82 (re¾im master).
83 .TP
84 .B Expired node
85 Registrace klienta/peer na tomto rozhraní vypr¹ela.
86 Vìt¹inou je generována, pokud rozhraní pracuje jako pøístupový bod
87 (re¾im master).
88 .TP
89 .B Spy threshold crossed
90 (pøekroèen práh pro sledování) Síla signálu u jedné z adres v seznamu iwspy poklesla pod spodní práh nebo
91 pøekroèila horní práh.
92 .PP
93 Vìt¹ina bezdrátovıch ovladaèù generuje pouze èást z tìchto událostí, nikoli
94 v¹echny. Jejich seznam zále¾í na konkrétní kombinaci hardware a ovladaèe.
95 Pro více informací o vytváøení událostí prosím prozkoumejte dokumentaci
96 ovladaèe a pou¾ijte
97 .IR iwlist (8)
98 k zji¹tìní, co ovladaè podporuje.
99 .\"
100 .\" AUTHOR part
101 .\"
102 .SH AUTOR
103 Jean Tourrilhes \- [email protected]
104 .\"
105 .\" TRANSLATION part
106 .\"
107 .SH PØEKLAD
108 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
109 .\"
110 .\" SEE ALSO part
111 .\"
112 .SH DAL©Í INFORMACE
113 .BR iwconfig (8),
114 .BR iwlist (8),
115 .BR iwspy (8),
116 .BR iwpriv (8),
117 .BR wireless (7).
+0
-118
src/lwe/cs/iwgetid.8 less more
0 .\" Guus Sliepen - 2001
1 .\" Doplnil a opravil Jean Tourrilhes - 2002-2003
2 .\" iwgetid.8
3 .\"
4 .TH IWGETID 8 "2.prosinec 2003" "wireless-tools" "Linux - Manuál programátora"
5 .\"
6 .\" NAME part
7 .\"
8 .SH JMÉNO
9 iwgetid \- Zobrazí ESSID, NWID nebo adresu AP/Cell (pøístupového bodu/buòky) v bezdrátové síti
10 .\"
11 .\" SYNOPSIS part
12 .\"
13 .SH SYNTAXE
14 .BI "iwgetid " [interface] " [--raw] [--scheme] [--ap] [--freq]"
15 .br
16 .BI " [--mode] [--protocol] [--channel]
17 .br
18 .\"
19 .\" DESCRIPTION part
20 .\"
21 .SH POPIS
22 .B iwgetid
23 se pou¾ívá k zji¹tìní NWID, ESSID nebo adresy AP/Cell (pøístupového bodu/buòky)
24 v bezdrátové síti, která je právì vyu¾ívána. Zobrazená informace je stejná jako
25 ta, kterou ukazuje
26 .BR iwconfig ", ale " iwgetid
27 se snadnìji integruje do skriptù.
28 .br
29 Jako výchozí,
30 .B iwgetid
31 vypí¹e
32 .I ESSID
33 zaшнzenн, pokud zaшнzenн nemб ѕбdnй ESSID, vytiskne jeho
34 .IR NWID .
35 .br
36 Výchozí formát pro výstup je pretty-printing (èlovìkem èitelný).
37 .\"
38 .\" OPTIONS part
39 .\"
40 .SH VOLBY
41 .TP
42 .B --raw
43 Tento pøepínaè vypne pretty-printing.
44 Je mo¾né jej kombinovat s ostatními pøepínaèi (s výjimkou
45 .BR --scheme ),
46 tak¾e se správnou kombinací pøepínaèù lze vytisknout surové
47 ESSID, adresu AP nebo Mode.
48 .br
49 Tento formát je ideální pro ulo¾ení výsledku iwgetid jako promìnné ve skriptech
50 .I Shellu
51 nebo
52 .I Perlu
53 nebo pro pøedání vısledku jako parametru pøíkazové øádky pro
54 .BR iwconfig .
55 .TP
56 .B --scheme
57 Tento pøepínaè je podobný pøedchozímu, vypne pretty-printing
58 a odstraní v¹echny znaky, které nejsou alfanumerické
59 (jako mezery, interpunkci a kontrolní znaky).
60 .br
61 Výsledný výstup je validní <<\ Pcmcia scheme identifer\ >> (který mù¾e být
62 pou¾it jako parametr pøíkazu
63 .BR "cardctl scheme" ).
64 Tento formát je také ideální, pokud je výsledek iwgetid pou¾it jako volba ve skriptech
65 .I Shellu
66 nebo
67 .I Perlu
68 nebo jako název souboru.
69 .TP
70 .B --ap
71 Zobrazí MAC adresu bezdrátového
72 .I Access Point
73 (pøístupového bodu) nebo
74 .IR Cell .
75 (buòky)
76 .TP
77 .B --freq
78 Zobrazí aktuální
79 .I frequency
80 (frekvenci) nebo
81 .I channel
82 (kanál), pou¾ívaný rozhraním.
83 .TP
84 .B --channel
85 Zobrazí aktuální
86 .I channel
87 (kanál), pou¾ívaný rozhraním. Kanál je získán z aktuální frekvence
88 a seznamu frekvencí dodaného rozhraním.
89 .TP
90 .B --mode
91 Zobrazí aktuální
92 .I mode
93 (re¾im) rozhraní.
94 .TP
95 .B --protocol
96 Zobrazí
97 .I protocol name
98 (název protokolu) rozhraní. Tak je mo¾né identifikovat v¹echny karty, které
99 jsou vzájemnì kompatibilní a akceptují stejný typ nastavení.
100 .br
101 Je to také mo¾nost jak
102 .I ovìøit podporu Wireless Extensions
103 na rozhraní, proto¾e je to jediný atribut,
104 který v¹echny ovladaèe podporující Wireless Extensions musejí podporovat.
105 .\"
106 .\" TRANSLATION part
107 .\"
108 .SH PØEKLAD
109 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
110 .\"
111 .\" SEE ALSO part
112 .\"
113 .SH DAL©Í INFORMACE
114 .BR iwconfig (8),
115 .BR ifconfig (8),
116 .BR iwspy (8),
117 .BR iwpriv (8).
+0
-120
src/lwe/cs/iwlist.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwlist.8
2 .\"
3 .TH IWLIST 8 "23.èerven 2004" "wireless-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iwlist \- Získá podrobnìj¹í bezdrátové informace o bezdrátovém rozhraní
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTAXE
13 .BI "iwlist " rozhraní " scanning"
14 .br
15 .BI "iwlist " rozhraní " frequency"
16 .br
17 .BI "iwlist " rozhraní " rate"
18 .br
19 .BI "iwlist " rozhraní " key"
20 .br
21 .BI "iwlist " rozhraní " power"
22 .br
23 .BI "iwlist " rozhraní " txpower"
24 .br
25 .BI "iwlist " rozhraní " retry"
26 .br
27 .BI "iwlist " rozhraní " event"
28 .br
29 .BI "iwlist --help"
30 .br
31 .BI "iwlist --version"
32 .\"
33 .\" DESCRIPTION part
34 .\"
35 .SH POPIS
36 .B Iwlist
37 se pou¾ívá k zobrazení doplòujících informací o bezdrátovém sí»ovém
38 rozhraní, které nejsou zobrazovány pøíkazem
39 .IR iwconfig (8).
40 Hlavní parametr urèuje typ informace, kterou
41 .B iwlist
42 zobrazí v detailní podobì, vèetnì informace, kterou poskytuje
43 .IR iwconfig (8).
44 .\"
45 .\" PARAMETER part
46 .\"
47 .SH PARAMETRY
48 .TP
49 .BR scan [ning]
50 Vypí¹e seznam pøístupových bodù a Ad-Hoc buòek v dosahu a
51 volitelnì i spoustu informací o nich (ESSID, kvalita,
52 frekvence, re¾im...). Typ zobrazené informace závisí na mo¾nostech karty.
53 .br
54 Spu¹tìní skenování je privilegovaná operace (mù¾e ji provést pouze
55 .RI root
56 ) a normální u¾ivatel mù¾e pouze èíst zbylé výsledky skenování.
57 Jako výchozí je zpùsob, kterým je skenování provedeno (jeho rozsah)
58 ovlivnìn aktuálním nastavením ovladaèe. U tohoto pøíkazu se poèítá s dodateènımi parametry
59 pro kontrolu zpùsobu skenování, to ale zatím není implementováno.
60 .TP
61 .BR freq [uency]/ channel
62 Vypí¹e seznam dostupných frekvencí pro zaøízení a poèet definovaných kanálù
63 Prosím vìnujte pozornost tomu, ¾e ovladaè obvykle vrací
64 celkový poèet kanálù a pouze frekvence dostupné v aktuálním locale,
65 tak¾e mezi zobrazenými frekvencemi a èísly kanálù není vztah "jedna k jedné".
66 .TP
67 .BR rate / bit [rate]
68 Vypí¹e pøenosové rychlosti podporované zaøízením.
69 .TP
70 .BR key / enc [ryption]
71 Vypí¹e podporované velikosti ¹ifrovacích klíèù a zobrazí v¹echny ¹ifrovací
72 klíèe dostupné v zaøízení.
73 .TP
74 .B power
75 Vypí¹e rùzné atributy a re¾imy øízení spotøeby zaøízení.
76 .TP
77 .B txpower
78 vypí¹e dostupné vysílací výkony zaøízení.
79 .TP
80 .B retry
81 vypí¹e limity pro transmit retry a retry lifetime na zaøízení.
82 .TP
83 .BR ap / accesspoint / peers
84 Vypí¹e pøístupové body v dosahu a volitelnì i kvalitu spoje
85 Tato volba je
86 .B zastaralá
87 a je nyní opu¹tìna ve prospìch skenování (viz vý¹e), vìt¹ina
88 ovladaèù ji nepodporuje.
89 .br
90 Nìkteré ovladaèe mohou s tímto pøíkazem vracet zvlá¹tní seznam peerù
91 nebo pøístupových bodù, jako napø. seznam peerù asociovaních s/registrovaných s
92 kartou. Více informací obsahuje dokumentace ovladaèù.
93 .TP
94 .B event
95 Vypí¹e bezdrátové události podporované zaøízením.
96 .TP
97 .B --version
98 Zobrazí verzi wireless tools a doporuèenou a aktuální verzi Wireless Extensions
99 s ohledem na bezdrátové rozhraní.
100 .\"
101 .\" TRANSLATION part
102 .\"
103 .SH PØEKLAD
104 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
105 .\"
106 .\" FILES part
107 .\"
108 .SH SOUBORY
109 .I /proc/net/wireless
110 .\"
111 .\" SEE ALSO part
112 .\"
113 .SH DAL©Í INFORMACE
114 .BR iwconfig (8),
115 .BR iwspy (8).
116 .BR iwevent (8),
117 .BR iwpriv (8),
118 .BR wireless (7).
119
+0
-136
src/lwe/cs/iwpriv.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwpriv.8
2 .\"
3 .TH IWPRIV 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iwpriv \- konfiguruje doplòkové (specifické) parametry bezdrátového
9 sí»ového rozhraní
10 .\"
11 .\" SYNOPSIS part
12 .\"
13 .SH SYNTAXE
14 .BI "iwpriv [" rozhraní ]
15 .br
16 .BI "iwpriv " "rozhraní specifický-pøíkaz " "[" specifické-parametry ]
17 .br
18 .BI "iwpriv " "rozhraní specifický-pøíkaz [I] " "[" specifické-parametry ]
19 .br
20 .BI "iwpriv " rozhraní " --all"
21 .br
22 .BI "iwpriv " rozhraní " roam " {on,off}
23 .br
24 .BI "iwpriv " rozhraní " port " {ad-hoc,managed,N}
25 .\"
26 .\" DESCRIPTION part
27 .\"
28 .SH POPIS
29 .B Iwpriv
30 je doprovodným nástrojem k
31 .IR iwconfig (8).
32 .B Iwpriv
33 pracuje s parametry a nastaveními specifickými pro ka¾dý ovladaè (na rozdíl od
34 .IR "iwconfig" ,
35 který pracuje s obecnými).
36 .PP
37 Bez uvedení parametru
38 .B iwpriv
39 vypí¹e specifické pøikazy dostupné na ka¾dém rozhraní a
40 parametry, které vy¾adují. Pomocí této informace mù¾e u¾ivatel
41 pou¾ít tyto specifické pøíkazy na urèeném rozhraní.
42 .PP
43 Teoreticky by dokumentace ka¾dého ovladaèe mìla uvádìt, jak
44 pou¾ívat tyto pro rozhraní specifické pøíkazy a jejich úèinek.
45 .\"
46 .\" PARAMETER part
47 .\"
48 .SH PARAMETRY
49 .TP
50 .IR specifický-pøíkaz " [" specifické-parametry ]
51 Vykoná urèený
52 .I specifickı-pøíkaz
53 na rozhraní.
54 .br
55 Pøíkaz mù¾e pou¾ít nebo vy¾adovat parametry a mù¾e zobrazit informaci.
56 Parametry tedy mohou i nemusejí být vy¾adovány a mìly by odpovídat tomu, co
57 pøíkaz oèekává. Seznam pøíkazù, které
58 .B iwpriv
59 zobrazí (kdy¾ je volán bez parametrù), by mìl napovìdìt, jak s parametry zacházet.
60 .br
61 Nicménì pro informaci o pøíkazech a jejich správném pou¾ití je nejlep¹í
62 se obrátit na dokumnetaci k ovladaèi zaøízení.
63 .TP
64 .I "specifický-pøíkaz [I]" "[" specifické-parametry ]
65 Viz vý¹e, pouze
66 .I I
67 (celé èíslo) je pøedáno pøíkazu jako
68 .IR "Token Index" .
69 Token Index pou¾ívají jen nìkteré pøíkazy (vìt¹ina jej ignoruje), kdy jej pou¾ít by
70 mìla øíci dokumnetace ovladaèe.
71 .TP
72 .BR -a / --all
73 Vykoná a zobrazí v¹echny specifické pøíkazy, které nemají ¾ádné parametry
74 (tj. pouze ètou).
75 .TP
76 .B roam
77 Povolí nebo zaká¾e roaming, je-li podporován. Volá specifický pøíkaz
78 .IR setroam ,
79 který je obsa¾en v ovladaèi
80 .IR "wavelan_cs".
81 .TP
82 .B port
83 Pøeète nebo nastaví druh portu. Volá specifickı pøíkaz
84 .IR gport_type ", " sport_type ", " get_port " nebo " set_port ","
85 obsa¾enı v ovladaèích
86 .IR wavelan2_cs " a " wvlan_cs "."
87 .\"
88 .\" DISPLAY part
89 .\"
90 .SH ZOBRAZENÍ
91 Pro ka¾dé zaøízení, které podporuje specifické pøíkazy, zobrazí
92 .I iwpriv
93 seznam dostupnıch specifickıch pøíkazù.
94 .PP
95 To zahrnuje název specifického pøíkazu, parametry, které mohou být nastaveny a jejich typ
96 a parametry které mohou být zobrazeny a jejich typ.
97 .PP
98 Napøíklad mù¾e zobrazit :
99 .br
100 .B "eth0 Available specific ioctl :"
101 .br
102 .B " setqualthr (89F0) : set 1 byte & get 0"
103 .br
104 .B " gethisto (89F7) : set 0 & get 16 int"
105 .PP
106 To znamená, ¾e je mo¾né nastavit quality threshold a zobrazit
107 histogram s a¾ 16 hodnotami pomocí tìchto pøíkazù:
108 .br
109 .I " iwpriv eth0 setqualthr 20"
110 .br
111 .I " iwpriv eth0 gethisto"
112 .\"
113 .\" AUTHOR part
114 .\"
115 .SH AUTOR
116 Jean Tourrilhes \- [email protected]
117 .\"
118 .\" TRANSLATION part
119 .\"
120 .SH PØEKLAD
121 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
122 .\"
123 .\" FILES part
124 .\"
125 .SH SOUBORY
126 .I /proc/net/wireless
127 .\"
128 .\" SEE ALSO part
129 .\"
130 .SH DAL©Í INFORMACE
131 .BR iwconfig (8),
132 .BR iwlist (8),
133 .BR iwevent (8),
134 .BR iwspy (8),
135 .BR wireless (7).
+0
-111
src/lwe/cs/iwspy.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwspy.8
2 .\"
3 .TH IWSPY 8 "31.øíjen 1996" "net-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 iwspy \- Získá bezdrátové statistiky o urèených nodech
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTYXE
13 .BI "iwspy " rozhraní
14 .br
15 .BI "iwspy " rozhraní " [+] " DNSNAME " | " IPADDR " | " HWADDR " [...]"
16 .br
17 .BI "iwspy " rozhraní " off"
18 .br
19 .BI "iwspy " rozhraní " setthr " "low high"
20 .br
21 .BI "iwspy " rozhraní " getthr"
22 .\"
23 .\" DESCRIPTION part
24 .\"
25 .SH POPIS
26 .B Iwspy
27 se pou¾ívá k nastavení seznamu sledovaných adres na bezdrátovém sí»ovém rozhraní a
28 k zpìtnému ètení informací o kvalitì spoje pro ka¾dou z nich. Tyto
29 informace jsou stejné jako ty uvedené v
30 .IR "/proc/net/wireless":
31 kvalita spoje, síla signálu, hladina ¹umu.
32 .PP
33 Tyto informace jsou aktualizovány poka¾dé, kdy¾ je pøijat nový paket, tak¾e
34 ka¾dá adresa na seznamu zvy¹uje zátì¾ ovladaèe.
35 .PP
36 Tato funkcionalita platí pouze pro nody v aktuální bezdrátové buòce, není mo¾né
37 sledovat pøístupové body, se kterımi není zaøízení asociováno (k tomu slou¾í skenování)
38 , ani nody v jiných buòkách. V re¾imu Managed procházejí pakety vìt¹inou pøes pøístupový
39 bod a v tom pøípadì je získána síla signálu pøístupového bodu. Proto je tato funkce
40 u¾iteèná víceménì jen v re¾imu Ad-Hoc nebo Master.
41 .\"
42 .\" PARAMETER part
43 .\"
44 .SH PARAMETRY
45 Je mo¾né nastavit a¾ 8 adres.
46 .TP
47 .BR DNSNAME " | " IPADDR
48 Nastaví IP adresu nebo, v nìkterıch pøípadech, DNS název (pomocí name
49 resolveru). Proto¾e hardware pracuje s hardwarovými adresami,
50 .B iwspy
51 pøelo¾í IP adresu pomocí
52 .IR ARP .
53 Mù¾e se stát, ¾e adresa není v ARP cache a
54 .B iwspy
55 neuspìje. V tom pøípadì pou¾ijte
56 .IR ping (8)
57 na toto jméno/adresu a zkuste to znovu.
58 .TP
59 .B HWADDR
60 Nastaví hardwarovou (MAC) adresu (tato adresa se nepøekládá ani nekontroluje,
61 na rozdíl od IP adresy). Adresa musí obsahuvat dvojteèky
62 .RB ( : )
63 aby byla uznána za hardwarovou adresu.
64 .TP
65 .B +
66 Pøidá novou sadu adres na konec stávajícího seznamu, místo aby jej nahradil.
67 Seznam adres je pro ka¾dé zaøízení jedineèný, proto by tato volba mìla být u¾ívána, aby
68 se zabránilo konfliktùm.
69 .TP
70 .B off
71 Odstraní souèasný seznam adres a vypne sledovací funkci.
72 .TP
73 .B setthr
74 Nastaví
75 .I low
76 (spodní) a
77 .I high
78 (horní) práh síly signálu, pro spu¹tìní události iwspy (podporuje-li to ovladaè).
79 .br
80 Poka¾dé, kdy¾ síla signálu jakékoliv z adres sledované iwspy
81 poklesne pod spodní práh nebo pøehroèí horní práh, je vygenerována bezdrátová událost.
82 .br
83 To je mo¾né pou¾ít ke sledování výpadkù spoje bez nutnosti pravidelného spou¹tìní iwspy.
84 .TP
85 .B getthr
86 Získá aktuální
87 .I low
88 (spodní) a
89 .I high
90 (horní) práh síly signálu pro událost iwspy.
91 .\"
92 .\" TRANSLATION part
93 .\"
94 .SH PØEKLAD
95 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
96 \"
97 .\" FILES part
98 .\"
99 .SH SOUBORY
100 .I /proc/net/wireless
101 .\"
102 .\" SEE ALSO part
103 .\"
104 .SH DAL©Í INFORMACE
105 .BR iwconfig (8),
106 .BR iwlist (8),
107 .BR iwevent (8),
108 .BR iwpriv (8),
109 .BR wireless (7).
110
+0
-129
src/lwe/cs/wireless.7 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" wireless.7
2 .\"
3 .TH WIRELESS 7 "4.duben 2004" "wireless-tools" "Linux - Manuál programátora"
4 .\"
5 .\" NAME part
6 .\"
7 .SH JMÉNO
8 wireless \- Wireless Tools a Wireless Extensions
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNTAXE
13 .B iwconfig
14 .br
15 .B iwpriv \-a
16 .br
17 .\"
18 .\" DESCRIPTION part
19 .\"
20 .SH POPIS
21 .B Wireless Extensions
22 jsou API, které umo¾òují manipulovat s bezdrátovými sí»ovými rozhraními.
23 Skládají se ze souboru nástrojù a konfiguraèních souborù. Podrobnìji
24 jsou popsány v Linux Wireless LAN Howto.
25 .br
26 .B Wireless Tools
27 se pou¾ívají ke zmìnì konfigurace bezdrátových sí»ových rozhraní za bìhu,
28 k získání jejich aktuální konfigurace, statistik a diagnostice.
29 Popisují je jejich vlastní manuálové stránky, viz odkazy ní¾e.
30 .br
31 .B Nastavení bezdrátového pøipojení
32 se v ka¾dé distribuci linuxu li¹í. Tato manuálová stránka bude obsahovat
33 postup nastavení pro nìkolik bì¾ných distribucí. Prozatím se podívejte do
34 souboru DISTRIBUTIONS.txt, kterı je souèástí balíèku Wireless Tools.
35 .\"
36 .\" DEBIAN 3.0 part
37 .\"
38 .SH DEBIAN 3.0
39 V Debianu 3.0 (a vy¹¹ím) je mo¾né nastavit bezdrátová sí»ová zaøízení
40 nástrojem pro nastavení sítì
41 .BR ifupdown (8).
42 .TP
43 .B Soubor:
44 .I /etc/network/interfaces
45 .TP
46 .B Forma:
47 .RI wireless\- "<funkce> <hodnota>"
48 .br
49 wireless\-essid Home
50 .br
51 wireless\-mode Ad\-Hoc
52 .TP
53 .B Dal¹í informace:
54 .I /etc/network/if\-pre\-up.d/wireless\-tools
55 .br
56 .I /usr/share/doc/wireless\-tools/README.Debian
57 .\"
58 .\" SuSE 8.0 part
59 .\"
60 .SH SuSE 8.0
61 SuSE 8.0 (a vy¹¹í) integrovalo nastavení bezdrátového pøipojení do svých
62 sí»ových skriptù.
63 .TP
64 .B Nástroj:
65 .B Yast2
66 .TP
67 .B Soubor:
68 .I /etc/sysconfig/network/wireless
69 .br
70 .I /etc/sysconfig/network/ifcfg\-*
71 .TP
72 .B Forma:
73 .RI WIRELESS_ "<funkce>" = "<hodnota>"
74 .br
75 WIRELESS_ESSID="Home"
76 .br
77 WIRELESS_MODE=Ad\-Hoc
78 .TP
79 .B Dal¹í informace:
80 man ifup
81 .br
82 info scpm
83 .\"
84 .\" PCMCIA part
85 .\"
86 .SH PÙVODNÍ PCMCIA SKRIPTY
87 Pokud pou¾íváte pùvodní konfiguraèní skripty z balíèku Pcmcia,
88 Mù¾ete pou¾ít tuto metodu.
89 .TP
90 .B Soubor:
91 .I /etc/pcmcia/wireless.opts
92 .TP
93 .B Forma:
94 *,*,*,*)
95 .br
96 ESSID="Home"
97 .br
98 MODE="Ad-Hoc"
99 .br
100 ;;
101 .TP
102 .B Dal¹í informace:
103 .I /etc/pcmcia/wireless
104 .br
105 Soubor
106 .IR "PCMCIA.txt" ,
107 kterı je souèástí balíèku Wireless Tools
108 .\"
109 .\" AUTHOR part
110 .\"
111 .SH AUTOR
112 Jean Tourrilhes \- [email protected]
113 .br
114 .I http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
115 .\"
116 .\" TRANSLATION part
117 .\"
118 .SH PØEKLAD
119 Pavel Heimlich \- [email protected], bøezen 2005 (wireless_tools.28pre4).
120 .\"
121 .\" SEE ALSO part
122 .\"
123 .SH DAL©Í INFORMACE
124 .BR iwconfig (8),
125 .BR iwlist (8),
126 .BR iwspy (8),
127 .BR iwpriv (8),
128 .BR iwevent (8).
+0
-147
src/lwe/fr/ifrename.8 less more
0 .\" Jean II - HPL - 2004
1 .\" ifrename.8
2 .\"
3 .\" Traduction 2004/08/25 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 27-pre25
6 .TH IFRENAME 8 "01 mars 2004" "wireless-tools" "Manuel du programmeur Linux"
7 .\"
8 .\" NAME part
9 .\"
10 .SH NOM
11 ifrename \- renomme les interfaces réseau basées sur différents critères
12 statiques
13 .\"
14 .\" SYNOPSIS part
15 .\"
16 .SH SYNOPSIS
17 .B "ifrename [-c configfile] [-p] [-d]"
18 .br
19 .B "ifrename [-c configfile] [-i interface] [-n newname]"
20 .\"
21 .\" DESCRIPTION part
22 .\"
23 .SH DESCRIPTION
24 .B Ifrename
25 est un outil vous permettant d'assigner un nom cohérent à chacune de vos
26 interfaces réseau.
27 .PP
28 Par défaut, les noms d'interface sont dynamiques, et à chaque interface réseau
29 est assigné le premier nom disponible
30 .RI ( eth0 ", " eth1 "...)."
31 L'ordre dans lequel les interfaces réseau sont créées peut varier. Pour les
32 interfaces fixes («\ built-in interfaces\ »), l'énumération du noyau au
33 démarrage peut varier. Pour les interfaces débranchables, l'utilisateur peut les
34 brancher dans n'importe quel ordre.
35 .PP
36 .B Ifrename
37 permet à l'utilisateur de décider quel nom une interface réseau aura.
38 .B Ifrename
39 peut utiliser différents sélecteurs
40 .RI "(«\ " selectors "\ »)"
41 pour spécifier comment les noms d'interface correspondent aux interfaces réseau
42 du système, le plus commun des sélecteurs étant
43 .RI "l'" "adresse MAC"
44 de l'interface.
45 .PP
46 .B Ifrename
47 doit être lancé avant que les interfaces ne soient démarrées, raison pour
48 laquelle il est surtout utile dans divers scripts (init, hotplug), mais il est
49 rarement utilisé directement par l'utilisateur. Par défaut,
50 .B ifrename
51 renomme toutes les interfaces système présentes en utilisant les correspondances
52 définies dans
53 .IR /etc/iftab .
54 .\"
55 .\" PARAMETER part
56 .\"
57 .SH PARAMÈTRES
58 .TP
59 .BI "-c " configfile
60 Fixe le fichier de configuration à utiliser (par défaut
61 .IR /etc/iftab ).
62 Le fichier de configuration définit la correspondance entre les sélecteurs et
63 les noms d'interface, et il est décrit dans
64 .IR iftab (5).
65 .br
66 Si
67 .I configfile
68 est «\ -\ », la configuration est lue depuis stdin.
69 .TP
70 .B -p
71 Sonde (charge) les modules noyau avant de renommer les interfaces. Par
72 défaut,
73 .B ifrename
74 vérifie seulement les interfaces déjà chargées, et ne charge pas
75 automatiquement les modules noyau requis. Cette option autorise une intégration
76 en douceur dans les systèmes qui ne chargent pas les modules avant d'appeler
77 .BR ifrename .
78 .TP
79 .B -d
80 Active divers bidouillages spécifiques à la
81 .BR Debian .
82 Combiné avec
83 .BR -p ,
84 seuls les modules pour les interfaces spécifiées dans
85 .I /etc/network/interface
86 sont chargés.
87 .TP
88 .BI "-i " interface
89 Renomme seulement
90 .RI "l'" interface
91 spécifiée, par opposition à toutes les interfaces présentes sur le système. Le
92 nouveau nom de l'interface est affiché.
93 .TP
94 .BI "-n " newname
95 Si utilisé avec
96 .IR -i ,
97 spécifie le nouveau nom de l'interface. La liste des correspondances depuis le
98 fichier de configuration est ignorée. Le nouveau nom peut être un joker
99 («\ wildcard\ ») qui contient une seule '*'.
100 .TP
101 .B -t
102 Active l'absorption («\ takover\ ») de nom. Cela permet d'échanger un nom
103 d'interface entre deux interfaces ou plus.
104 .br
105 L'absorption permet à une interface de «\ voler\ » le nom d'une autre
106 interface. Cela fonctionne seulement avec le noyau 2.6.X et si l'autre
107 interface est désactivée. En conséquence, ce n'est pas compatible avec Hotplug.
108 L'autre interface se voit assigner un nom aléatoire, mais peut être renommée
109 plus tard avec 'ifrename'.
110 .br
111 Le nombre d'absorptions est limité pour éviter les boucles circulaires, et donc
112 certaines situations d'échanges de noms complexes ne seront pas complètement
113 traitées.
114 .br
115 Dans tous les cas, l'échange de noms et l'utilisation de cette caractéristique
116 sont découragés, et vous êtes invités à choisir des noms uniques et sans
117 ambiguïté pour vos interfaces...
118 .\"
119 .\" AUTHOR part
120 .\"
121 .SH AUTEUR
122 Jean Tourrilhes \- [email protected]
123 .\"
124 .\" TRADUCTION part
125 .\"
126 .SH TRADUCTION
127 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
128 .\"
129 .\" AVERTISSEMENT part
130 .\"
131 .SH AVERTISSEMENT SUR LA TRADUCTION
132 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
133 doute, veuillez vous reporter au document original en langue anglaise fourni
134 avec le programme.
135 .\"
136 .\" FILES part
137 .\"
138 .SH FICHIERS
139 .I /etc/iftab
140 .\"
141 .\" SEE ALSO part
142 .\"
143 .SH VOIR AUSSI
144 .BR ifconfig (8),
145 .BR ip (8),
146 .BR iftab (5).
+0
-196
src/lwe/fr/iftab.5 less more
0 .\" Jean II - HPL - 2004
1 .\" iftab.5
2 .\"
3 .\" Traduction 2004/08/25 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 27-pre25
6 .\"
7 .TH IFTAB 5 "01 mars 2004" "wireless-tools" "Manuel du Programmeur Linux"
8 .\"
9 .\" NAME part
10 .\"
11 .SH NOM
12 iftab \- informations statiques sur les interfaces réseau
13 .\"
14 .\" DESCRIPTION part
15 .\"
16 .SH DESCRIPTION
17 Le fichier
18 .B /etc/iftab
19 contient de l'information descriptive à propos des diverses interfaces réseau.
20 .B iftab
21 n'est utilisé que par le programme
22 .IR ifrename (8)
23 pour assigner un nom d'interface réseau cohérent à chaque interface réseau.
24 .PP
25 .B /etc/iftab
26 définit un ensemble de
27 .RI "correspondances («\ " mappings "\ »)."
28 Chaque correspondance contient un nom d'interface et un ensemble de sélecteurs
29 («\ selectors\ »). Les sélecteurs permettent à
30 .B ifrename
31 d'identifier chaque interface réseau du système. Si une interface réseau
32 correspond à tous les descripteurs d'une correspondance,
33 .B ifrename
34 essaye de changer le nom de l'interface par le nom de l'interface donné dans la
35 correspondance.
36 .\"
37 .\" MAPPINGS part
38 .\"
39 .SH CORRESPONDANCES («\ MAPPINGS\ »)
40 Chaque correspondance est décrite sur une ligne distincte, elle commence avec
41 .IR "interface name" " (nom d'interface),"
42 et contient un ensemble de
43 .RI "descripteurs («\ " descriptors "\ »),"
44 séparés par des espaces ou des tabulations.
45 .PP
46 La relation entre les descripteurs d'une correspondance est un
47 .IR "et logique" .
48 Une correspondance s'applique à une interface réseau seulement si tous les
49 descripteurs s'appliquent. Si une interface réseau ne supporte pas un
50 descripteur particulier, elle ne s'appliquera à aucune correspondance qui
51 utilise ce descripteur.
52 .PP
53 Si vous voulez utiliser des descripteurs alternatifs pour un nom d'interface
54 (ou logique), spécifiez deux correspondances différentes avec le même nom
55 d'interface (une par ligne).
56 .B Ifrename
57 utilise toujours la première correspondance en commençant par la
58 .I fin
59 de
60 .BR iftab ,
61 donc les correspondances les plus restrictives devraient être définies en
62 dernier.
63 .\"
64 .\" INTERFACE NAME part
65 .\"
66 .SH NOM D'INTERFACE
67 La première partie de chaque correspondance est un nom d'interface. Si une
68 interface réseau correspond à tous les descripteurs d'une correspondance,
69 .B ifrename
70 essaye de changer le nom de l'interface par le nom de l'interface donné dans la
71 correspondance.
72 .PP
73 Le nom de l'interface d'une correspondance est soit un nom d'interface complet
74 (comme
75 .IR eth2 " ou " wlan0 )
76 ou un motif de nom d'interface contenant un seul caractère joker (comme
77 .IR eth* " ou " wlan* ).
78 Dans le cas d'un caractère joker («\ wildcard\ »), le noyau remplace le
79 caractère '*' par le plus petit entier disponible faisant un nom d'interface
80 unique.
81 .\"
82 .\" DESCRIPTORS part
83 .\"
84 .SH DESCRIPTEURS («\ DESCRIPTORS\ »)
85 Chaque descripteur est composé d'un nom de descripteur et d'une valeur de
86 descripteur. Les descripteurs définissent un attribut statique d'une interface
87 réseau, le but étant d'identifier de manière unique chaque périphérique.
88 .PP
89 La plupart des utilisateurs n'utiliseront que le sélecteur
90 .BR mac ,
91 les autres sélecteurs étant pour une configuration plus spécialisée.
92 .TP
93 .BI mac " adresse mac"
94 Correspond à l'Adresse MAC de l'interface avec l'adresse MAC spécifiée.
95 L'adresse MAC de l'interface peut être montrée en utilisant
96 .IR ifconfig (8)
97 ou
98 .IR ip (8).
99 L'adresse MAC spécifiée peut contenir une '*' pour la correspondance joker
100 («\ wildcard matching\ »).
101 .br
102 C'est le plus commun des sélecteurs, vu que chaque interface possède une
103 adresse MAC unique, ce qui permet de les identifier sans ambiguïté.
104 .TP
105 .BI arp " arp type"
106 Fait correspondre le Type ARP («\ ARP Type\ ») (aussi appelé «\ Link Type\ »)
107 de l'interface avec le type ARP spécifié. Le Type ARP de l'interface peut être
108 montré en utilisant
109 .IR ifconfig (8)
110 ou
111 .IR ip (8).
112 .br
113 Ce sélecteur est utile quand un pilote crée plusieurs interfaces réseau pour
114 une seule carte réseau.
115 .TP
116 .BI driver " driver name"
117 Fait correspondre le Nom de Pilote («\ Driver Name\ ») de l'interface avec le
118 nom de pilote spécifié. Le Nom de Pilote de l'interface peut être montré en
119 utilisant
120 .IR "ethtool -i" (8).
121 .TP
122 .BI businfo " bus information"
123 Fait correspondre l'Information de Bus («\ Bus Information\ ») de l'interface
124 avec l'information de bus spécifiée. L'Information de Bus de l'interface peut
125 être montrée en utilisant
126 .IR "ethtool -i" (8).
127 .TP
128 .BI baseaddress " base address"
129 Fait correspondre l'Adresse de Base («\ Base Address\ ») de l'interface avec
130 l'adresse de base spécifiée. L'Adresse de Base de l'interface peut être montrée
131 en utilisant
132 .IR ifconfig (8).
133 .br
134 Ce sélecteur n'est utile que pour les cartes ISA et EISA car la plupart des
135 cartes utilisent l'allocation dynamique pour l'Adresse de Base.
136 .TP
137 .BI irq " irq line"
138 Fait correspondre la Ligne IRQ (interruption) de l'interface avec la ligne IRQ
139 spécifiée. La Ligne IRQ de l'interface peut être montrée en utilisant
140 .IR ifconfig (8).
141 .br
142 Ce sélecteur n'est habituellement pas suffisant pour identifier de manière
143 unique une interface, car les Lignes IRQ peuvent être partagées.
144 .TP
145 .BI iwproto " wireless protocol"
146 Fait correspondre le Protocole Wireless de l'interface avec le protocole
147 wireless spécifié. Le Protocole Wireless de l'interface peut être montré
148 en utilisant
149 .IR iwconfig (8).
150 .br
151 Ce sélecteur n'est valable que pour les interfaces wireless et n'est pas
152 suffisant pour en identifier une de manière unique.
153 .\"
154 .\" EXAMPLE part
155 .\"
156 .SH EXEMPLE
157 # Ceci est un commentaire
158 .br
159 eth2 mac 08:00:09:DE:82:0E
160 .br
161 eth3 driver wavelan interrupt 15 baseaddress 0x390
162 .br
163 eth4 driver pcnet32 businfo 0000:02:05.0
164 .br
165 air* mac 00:07:0E:* arp 1
166 .\"
167 .\" AUTHOR part
168 .\"
169 .SH AUTEUR
170 Jean Tourrilhes \- [email protected]
171 .\"
172 .\" TRADUCTION part
173 .\"
174 .SH TRADUCTION
175 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
176 .\"
177 .\" AVERTISSEMENT part
178 .\"
179 .SH AVERTISSEMENT SUR LA TRADUCTION
180 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
181 doute, veuillez vous reporter au document original en langue anglaise fourni
182 avec le programme.
183 .\"
184 .\" FILES part
185 .\"
186 .SH FICHIERS
187 .I /etc/iftab
188 .\"
189 .\" SEE ALSO part
190 .\"
191 .SH VOIR AUSSI
192 .BR ifrename (8),
193 .BR ifconfig (8),
194 .BR ip (8),
195 .BR iwconfig (8).
+0
-569
src/lwe/fr/iwconfig.8 less more
0 .\" Jean II - HPLB - 1996 => HPL - 2004
1 .\" iwconfig.8
2 .\"
3 .\" Traduction 2003/07/15 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 26
6 .\" Mise à jour 2004/01/28 : version 27-pre9 (beta)
7 .\" Mise à jour 2004/02/26 : version 27-pre11 (alpha)
8 .\" Mise à jour 2004/08/23 : version 27-pre25
9 .\"
10 .TH IWCONFIG 8 "22 juin 2004" "wireless-tools" "Manuel du programmeur Linux"
11 .\"
12 .\" NAME part
13 .\"
14 .SH NOM
15 iwconfig \- configure une interface réseau sans-fil (wireless)
16 .\"
17 .\" SYNOPSIS part
18 .\"
19 .SH SYNOPSIS
20 .BI "iwconfig [" interface ]
21 .br
22 .BI "iwconfig " interface " [essid " X "] [nwid " N "] [freq " F "] [channel " C ]
23 .br
24 .BI " [sens " S "] [mode " M "] [ap " A "] [nick " NN ]
25 .br
26 .BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
27 .br
28 .BI " [enc " E "] [key " K "] [power " P "] [retry " R ]
29 .br
30 .BI " [commit]
31 .br
32 .BI "iwconfig --help"
33 .br
34 .BI "iwconfig --version"
35 .\"
36 .\" DESCRIPTION part
37 .\"
38 .SH DESCRIPTION
39 .B Iwconfig
40 est similaire à
41 .IR ifconfig (8),
42 mais est dédié aux interfaces wireless. Il est utilisé pour manier les
43 paramètres des interfaces réseaux qui sont spécifiques aux opérations wireless
44 (par exemple\ : la fréquence).
45 .B Iwconfig
46 peut aussi être utilisé pour afficher ces paramètres, et les statistiques
47 concernant le sans fil (extraites de
48 .IR /proc/net/wireless ).
49 .PP
50 Tous ces paramètres et statistiques dépendent du matériel. Chaque pilote ne
51 fournira que quelques uns d'entre eux en fonction du support matériel, et
52 l'étendue des valeurs peut changer. Veuillez vous référer aux pages man de
53 chaque matériel pour plus de détails.
54 .\"
55 .\" PARAMETER part
56 .\"
57 .SH PARAMÈTRES
58 .TP
59 .B essid
60 Positionne le ESSID ( ou Network Name - pour certains produits, il peut aussi
61 être désigné comme Domain ID). L'ESSID est utilisé pour identifier les cellules
62 qui font partie du même réseau virtuel.
63 .br
64 Par opposition à l'adresse de l'AP ou au NWID qui définissent une seule cellule,
65 l'ESSID définit un groupe de cellules connectées via des répéteurs ou via
66 l'infrastructure, où l'utilisateur peut «\ roamer\ » ou errer de manière
67 transprente (c.-à-d. changer de cellule sans perdre sa connexion).
68 .br
69 Avec certaines cartes, vous pouvez désactiver le contrôle du ESSID (ESSID
70 promiscuous) avec
71 .IR off " ou " any " (et " on
72 pour le réactiver).
73 .br
74 .B Exemples :
75 .br
76 .I " iwconfig eth0 essid any"
77 .br
78 .I " iwconfig eth0 essid ""Mon Reseau""
79 .TP
80 .BR nwid / domain
81 Positionne le Network ID (pour certains produits, il peut aussi être appelé
82 Domain ID). Comme tous les réseaux sans fil adjacents partagent le même médium,
83 ce paramètre est utilisé pour les différencier (créer des réseaux logiques
84 colocalisés) et pour identifier des noeuds appartenant à la même cellule.
85 .br
86 Ce paramètre est seulement utilisé par les matériels antérieurs à 802.11, la
87 norme 802.11 se servant du ESSID et de l'adresse de l'AP pour cette fonction.
88 .br
89 Avec certaines cartes, vous pouvez désactiver le contrôle du Network ID (NWID
90 promiscuous) avec
91 .IR off " (et " on
92 pour le réactiver).
93 .br
94 .B Exemples :
95 .br
96 .I " iwconfig eth0 nwid AB34
97 .br
98 .I " iwconfig eth0 nwid off"
99 .TP
100 .BR freq / channel
101 Positionne la fréquence d'exploitation ou canal du périphérique. Une valeur
102 inférieure à 1\ 000 indique un numéro de canal, une valeur supérieure à 1\ 000
103 est une fréquence en Hz. Vous pouvez ajouter le suffixe k, M ou G à la valeur
104 (par exemple, «\ 2.46G\ » pour la fréquence 2,46\ GHz), ou ajouter suffisamment
105 de «\ 0\ ».
106 .br
107 Les canaux sont habituellement numérotés à partir de 1, et vous pouvez utiliser
108 .IR iwlist (8)
109 pour obtenir le nombre total de canaux, lister les fréquences disponibles, et
110 afficher le fréquence courante comme un canal.
111 Suivants les réglementations, certaines fréquences/canaux peuvent ne pas
112 être disponibles.
113 .br
114 .B Exemples :
115 .br
116 .I " iwconfig eth0 freq 2422000000"
117 .br
118 .I " iwconfig eth0 freq 2.422G"
119 .br
120 .I " iwconfig eth0 channel 3"
121 .TP
122 .B sens
123 Positionne le seuil de sensibilité. C'est le niveau de signal le plus bas pour
124 lequel le matériel essaye de réceptionner un paquet, les signaux plus bas sont
125 ignorés. Ceci est utilisé pour éviter de recevoir le bruit de fond, donc vous
126 devriez le positionner en fonction du niveau de bruit moyen. Les valeurs
127 positives sont supposées être les valeurs brutes utilisées par le matériel ou
128 un pourcentage, les valeurs négatives sont supposées être des dBm.
129 .br
130 Avec certains matériels, ce paramètre contrôle aussi le seuil de report
131 (defer threshold) (signal le plus faible pour lequel le matériel considère le
132 canal occupé) et le seuil de cession (handover threshold) (niveau de signal pour
133 lequel le matériel commence à chercher un nouveau Point d'Accès).
134 .br
135 .B Exemple :
136 .br
137 .I " iwconfig eth0 sens -80"
138 .TP
139 .B mode
140 Positionne le mode de fonctionnement du matériel, qui dépend de la topologie du
141 réseau. Le mode peut être
142 .I Ad-Hoc
143 (réseau composé d'une seule cellule et sans Point d'Accès),
144 .I Managed
145 (un noeud se connecte à un réseau composé de plusieurs Points d'Accès, avec
146 roaming ou errance),
147 .I Master
148 (le noeud est le maître qui synchronise ou agit comme un Point d'Accès),
149 .I Repeater
150 (le noeud transmet les paquets entre les autres n½uds wireless),
151 .I Secondary
152 (le noeud agit comme un maître/répéteur supplémentaire),
153 .I Monitor
154 (le noeud agit comme un moniteur passif et ne fait que recevoir des paquets) ou
155 .IR Auto .
156 .br
157 .B Exemple :
158 .br
159 .I " iwconfig eth0 mode Managed"
160 .br
161 .I " iwconfig eth0 mode Ad-Hoc"
162 .TP
163 .B ap
164 Force la carte à s'enregistrer auprès du Point d'Accès donné par l'adresse,
165 si c'est possible. Quand la qualité de la connexion devient trop mauvaise,
166 le pilote peut revenir en mode automatique (la carte sélectionne le meilleur
167 Point d'Accès à portée).
168 .br
169 Vous pouvez aussi utiliser
170 .I off
171 pour réactiver le mode automatique sans changer le Point d'Accès courant,
172 ou vous pouvez utiliser
173 .I any
174 ou
175 .I auto
176 pour forcer la carte à se ré associer avec le meilleur Point d'Accès courant.
177 .br
178 .B Exemple :
179 .br
180 .I " iwconfig eth0 ap 00:60:1D:01:23:45"
181 .br
182 .I " iwconfig eth0 ap any"
183 .br
184 .I " iwconfig eth0 ap off"
185 .TP
186 .BR nick [name]
187 Positionne le surnom (nickname), ou nom de station. Quelques produits
188 802.11 le définissent, mais il n'est pas utilisé dans la mesure où les
189 protocoles les plus usités (MAC, IP, TCP) ne s'en servent pas en l'état.
190 Seuls quelques outils de diagnostic peuvent l'utiliser.
191 .br
192 .B Exemple :
193 .br
194 .I " iwconfig eth0 nickname ""My Linux Node""
195 .TP
196 .BR rate / bit [rate]
197 Pour les cartes supportant plusieurs débits, positionne le débit en b/s. Le
198 débit est la vitesse à laquelle les bits sont transmis sur le médium, la
199 vitesse du lien pour l'utilisateur est inférieure à cause du partage du médium
200 et des diverses entêtes.
201 .br
202 Vous pouvez ajouter le suffixe k, M ou G à la valeur (multiplicateur décimal\ :
203 10^3, 10^6 et 10^9\ b/s), ou ajouter suffisamment de «\ 0\ ». Les valeurs
204 en-dessous de 1000 sont spécifiques à la carte, habituellement un index de la
205 liste des débit supportés. Utilisez
206 .I auto
207 pour sélectionner le mode débit automatique (repli à un débit moindre pour
208 les canaux bruités), ce qui est le mode par défaut pour la plupart des cartes,
209 et
210 .I fixed
211 pour revenir à des paramètres fixes. Si vous spécifiez une valeur de débit
212 et ajoutez
213 .IR auto ,
214 le driver utilisera tous les débits inférieurs et égaux à cette valeur.
215 .br
216 .B Exemples :
217 .br
218 .I " iwconfig eth0 rate 11M"
219 .br
220 .I " iwconfig eth0 rate auto"
221 .br
222 .I " iwconfig eth0 rate 5.5M auto"
223 .TP
224 .BR rts [_threshold]
225 RTS/CTS ajoute une «\ poignée de main\ » avant chaque transmission de paquet
226 pour être sûr que le canal est libre. Cela ajoute des entêtes (NDT\ : données de
227 gestion), mais augmente les performances en cas de n½uds cachés ou
228 d'un grand nombre de noeuds actifs. Ce paramètre fixe la taille du plus petit
229 paquet pour lequel le noeud envoie un RTS\ ; une valeur égale à la taille
230 maximale des paquets inhibe ce mécanisme. Vous pouvez aussi positionner
231 ce paramètre sur
232 .IR auto ", " fixed " ou " off .
233 .br
234 .B Exemples :
235 .br
236 .I " iwconfig eth0 rts 250"
237 .br
238 .I " iwconfig eth0 rts off"
239 .TP
240 .BR frag [mentation_threshold]
241 La fragmentation permet de découper un paquet IP en une série de plus petits
242 fragments transmis par le médium. Dans la plupart des cas, cela ajoute des
243 entêtes, mais dans un environnement très bruité, cela réduit les coûts de
244 transmission dus aux erreurs et permet aux paquets d'être acheminés malgré
245 des séries d'interférences. Ce paramètre fixe la taille de fragment maximale\ ;
246 une valeur égale à la taille maximale de paquet désactive ce procédé. Vous
247 pouvez aussi mettre ce paramètre à
248 .IR auto ", " fixed " ou " off .
249 .br
250 .B Exemples :
251 .br
252 .I " iwconfig eth0 frag 512"
253 .br
254 .I " iwconfig eth0 frag off"
255 .TP
256 .BR key / enc [ryption]
257 Utilisé pour manipuler les clefs de cryptage ou brouillage et le mode de
258 sécurité.
259 .br
260 Pour mettre la clef courante de cryptage, il suffit d'entrer la clef
261 en hexadécimal telle que
262 .IR XXXX-XXXX-XXXX-XXXX " ou " XXXXXXXX .
263 Pour entrer une autre clef que la clef courante, ajoutez (au début ou à la
264 fin)
265 .I [index]
266 à la clef elle-même (cela ne changera pas la clef active). Vous pouvez aussi
267 entrer la clef comme une chaîne ASCII en utilisant le préfixe
268 .IR s: .
269 Les phrases en tant que mot de passe ne sont actuellement pas supportées.
270 .br
271 Pour changer la clef active parmi les clefs déjà entrées, il suffit d'entrer
272 .RI l' "[index]"
273 (sans entrer de valeur de clef).
274 .br
275 .IR off " et " on
276 désactive et réactive le cryptage.
277 .br
278 Le mode de sécurité peut être
279 .I open
280 ou
281 .IR restricted ,
282 et sa signification dépend de la carte utilisée. Avec la plupart des cartes,
283 le mode
284 .I open
285 n'utilise pas d'authentification et la carte accepte des sessions non cryptées,
286 alors que le mode
287 .I restricted
288 n'accepte que des sessions cryptées et la carte utilisera l'authentification
289 si disponible.
290 .br
291 Si vous avez besoin de mettre plusieurs clefs, ou de mettre une clef et de
292 changer la clef active, vous avez besoin d'utiliser des instructions à clefs
293 .RB ( "key" )
294 multiples. Les arguments peuvent être mis dans n'importe quel ordre, le
295 dernier sera prioritaire.
296 .br
297 .B Exemples :
298 .br
299 .I " iwconfig eth0 key 0123-4567-89"
300 .br
301 .I " iwconfig eth0 key [3] 0123-4567-89"
302 .br
303 .I " iwconfig eth0 key s:password [2]"
304 .br
305 .I " iwconfig eth0 key [2]"
306 .br
307 .I " iwconfig eth0 key open"
308 .br
309 .I " iwconfig eth0 key off"
310 .br
311 .I " iwconfig eth0 key restricted [3] 0123456789"
312 .br
313 .I " iwconfig eth0 key 01-23 key 45-67 [4] key [4]"
314 .TP
315 .BR power
316 Utilisé pour manipuler les paramètres et le mode du procédé de gestion
317 d'énergie.
318 .br
319 Pour fixer la période entre les éveils, entrez la
320 .IR "period `valeur'" .
321 Pour fixer la temporisation avant le retour en veille, entrez la
322 .IR "timeout `valeur'" .
323 Vous pouvez aussi ajouter les modificateurs
324 .IR min " et " max ".
325 Par défaut, ces valeurs sont exprimées en secondes, ajoutez le suffixe m ou u
326 pour spécifier les valeurs en millisecondes ou microsecondes. Parfois, ces
327 valeurs sont sans unité (nombre de périodes de beacon, dwell ou similaire).
328 .br
329 .IR off " et " on
330 désactive et réactive la gestion d'énergie. Enfin, vous pouvez mettre la
331 gestion d'énergie en mode
332 .I all
333 (reçoit tous les paquets),
334 .I unicast
335 (reçoit seulement les paquets unicast, ignore les paquets multicast et de
336 broadcast) et
337 .I multicast
338 (reçoit seulement les paquets multicast et de broadcast, ignore l'unicast).
339 .br
340 .B Exemples :
341 .br
342 .I " iwconfig eth0 power period 2"
343 .br
344 .I " iwconfig eth0 power 500m unicast"
345 .br
346 .I " iwconfig eth0 power timeout 300u all"
347 .br
348 .I " iwconfig eth0 power off"
349 .br
350 .I " iwconfig eth0 power min period 2 power max period 4"
351 .TP
352 .BR txpower
353 Pour les cartes supportant plusieurs puissances de transmission, règle la
354 puissance de transmission en dBm. Si
355 .I W
356 est la puissance en Watt, la puissance en dBm est
357 .IR "P\ =\ 30\ +\ 10.log(W)" .
358 Si la valeur est post fixée par
359 .IR mW ,
360 elle sera automatiquement convertie en dBm.
361 .br
362 De plus,
363 .IR on " et " off
364 active et désactive la radio, et
365 .IR auto " et " fixed
366 active et désactive le contrôle de puissance (si ces fonctions sont
367 disponibles).
368 .br
369 .B Exemples :
370 .br
371 .I " iwconfig eth0 txpower 15"
372 .br
373 .I " iwconfig eth0 txpower 30mW"
374 .br
375 .I " iwconfig eth0 txpower auto"
376 .br
377 .I " iwconfig eth0 txpower off"
378 .TP
379 .BR retry
380 La plupart des cartes supportent les retransmissions MAC (contrôle d'accès
381 au médium), et certaines permettent le paramétrage du mécanisme des tentatives
382 (en cas d'échec).
383 .br
384 Pour fixer le nombre maximum d'essais, entrez
385 .IR "limit `valeur'" .
386 C'est une valeur absolue (sans unité).
387 Pour fixer le temps maximum autorisé au mécanisme MAC pour ses tentatives,
388 entrez
389 .IR "lifetime `valeur'" .
390 Par défaut, cette valeur est en secondes, ajouter le suffixe m ou u pour
391 spécifier les valeurs en millisecondes ou microsecondes.
392 .br
393 Vous pouvez aussi ajouter les modificateurs
394 .IR min " et " max ".
395 Si la carte supporte le mode automatique, ils définissent les limites du
396 lifetime, ou les limites inférieure et supérieure (NDT\ : de l'intervalle
397 temporel dans lequel le mécanisme MAC est autorisé à réitérer ses tentatives).
398 D'autres cartes définissent des valeurs différentes en fonction de la taille
399 des paquets, par exemple la norme 802.11 définit une
400 .I min limit
401 qui est la limite inférieure d'essai (paquets non RTS/CTS).
402 .br
403 .B Exemples :
404 .br
405 .I " iwconfig eth0 retry 16"
406 .br
407 .I " iwconfig eth0 retry lifetime 300m"
408 .br
409 .I " iwconfig eth0 retry min limit 8"
410 .TP
411 .BR commit
412 Certaines cartes peuvent ne pas appliquer immédiatement les changements
413 effectués par les Wireless Extensions (elles peuvent attendre pour prendre en
414 compte les changements ou les appliquer seulement quand la carte est montée via
415 ifconfig). Cette commande (si disponible) force la carte à appliquer les
416 changements en suspens.
417 .br
418 Cela n'est normalement pas nécessaire, car la carte appliquera éventuellement
419 les changements, mais peut être utile pour débuggage.
420 .\"
421 .\" DISPLAY part
422 .\"
423 .SH AFFICHAGE
424 Pour chaque matériel qui supporte les extensions wireless,
425 .I iwconfig
426 affiche le nom du
427 .B protocole MAC
428 utilisé (nom du matériel pour les protocoles propriétaires),
429 .RB l' ESSID
430 (Network Name), le
431 .BR NWID ,
432 la
433 .B fréquence
434 (ou canal), la
435 .BR sensibilité ,
436 le
437 .B mode
438 d'exploitation, l'adresse du
439 .BR "Point d'Accès",
440 le
441 .BR débit ,
442 le
443 .BR "seuil RTS" " (" "RTS threshold" "), le "
444 .BR "seuil de fragmentation" " (" "fragmentation threshold" "), la
445 .B clef de cryptage
446 et les paramètres de
447 .BR "gestion de l'énergie" " (" "power management" ")"
448 (en fonction de la disponibilité).
449 .PP
450 Les paramètres affichés ont la même signification et la même valeur que ceux
451 que vous pouvez régler, veuillez vous reporter à la précédente partie pour
452 leur explication détaillée.
453 .br
454 Quelques paramètres sont affichés seulement dans une forme abrégée (comme le
455 cryptage). Vous devez utiliser
456 .IR iwlist (8)
457 pour avoir tous les détails.
458 .br
459 Certains paramètres ont deux modes (comme le débit). Si la valeur est préfixée
460 par
461 .RB «\ =\ »,
462 cela veut dire que le paramètre est fixé et forcé à cette valeur, s'il est
463 préfixé par
464 .RB «\ :\ »,
465 le paramètre est en mode automatique et la valeur courante est montrée (et peut
466 changer).
467 .TP
468 .BR "Access Point" / Cell
469 Une adresse égale à 00:00:00:00:00:00 signifie que la carte n'a pas réussi à
470 s'associer avec un Point d'Accès (le plus souvent une question de
471 configuration).
472 Le paramètre
473 .B Access Point
474 sera montré comme une cellule
475 .RB ( Cell )
476 en mode ad hoc (pour des raisons évidentes), mais il fonctionne néanmoins
477 de la même manière.
478 .PP
479 Si
480 .I /proc/net/wireless
481 existe,
482 .I iwconfig
483 affichera aussi son contenu. Il faut noter que ces valeurs dépendent des
484 spécifications du pilote et de la carte, vous devrez donc vous référez à la
485 documentation du pilote pour une interprétation correcte de ces valeurs.
486 .TP
487 .B Link quality
488 Qualité globale du lien. Peut être basé sur le niveau de contention ou des
489 interférences, le taux d'erreur de trame ou de bit, la qualité du signal reçu,
490 des synchronisations temporelles, ou autre métrique matérielle. C'est une valeur
491 agrégat, et dépend totalement du pilote et du matériel.
492 .TP
493 .B Signal level
494 Force du signal reçu (RSSI - force du signal reçu). Cela peut être des unités
495 arbitraires ou des dBm,
496 .I iwconfig
497 utilise des méta-informations du pilote pour interpréter les valeurs
498 brutes données par
499 .I /proc/net/wireless
500 et affiche l'unité ou la valeur maximale correspondante (utilise l'arithmétique
501 8 bits). En mode
502 .I Ad-Hoc
503 cela peut être indéfini et vous devriez utiliser
504 .IR iwspy .
505 .TP
506 .B Noise level
507 Niveau du bruit de fond (quand aucun paquet n'est transmis). Commentaires
508 similaires à ceux de
509 .BR "Signal level" .
510 .TP
511 .B Rx invalid nwid
512 Nombre de paquets reçus avec un NWID ou ESSID différent. Utilisé pour détecter
513 des problèmes de configuration ou l'existence de réseau adjacent (sur la même
514 fréquence).
515 .TP
516 .B Rx invalid crypt
517 Nombre de paquets que le matériel a été incapable de décrypter. Cela peut être
518 utilisé pour détecter des mauvais paramètres de cryptage.
519 .TP
520 .B Rx invalid frag
521 Nombre de paquets pour lesquels le matériel a été incapable de ré-assembler
522 correctement les fragments de la couche liaison (le plus souvent, il en manque
523 un).
524 .TP
525 .B Tx excessive retries
526 Nombre de paquets que la carte n'a pas réussi à envoyer. La plupart des
527 protocoles MAC réessaient un certain nombre de fois avant d'abandonner.
528 .TP
529 .B invalid misc
530 Autres paquets perdus en relation avec les opérations spécifiques au sans fil.
531 .TP
532 .B Missed beacon
533 Nombre de beacons périodiques émis par la Cellule ou le Point d'Accès que nous
534 avons manqué. Les beacons sont envoyés à intervalles réguliers pour maintenir la
535 coordination de la cellule, l'impossibilité de les recevoir indiquant souvent
536 que la carte est hors de portée.
537 .\"
538 .\" AUTHOR part
539 .\"
540 .SH AUTEUR
541 Jean Tourrilhes \- [email protected]
542 .\"
543 .\" TRADUCTION part
544 .\"
545 .SH TRADUCTION
546 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
547 .\"
548 .\" AVERTISSEMENT part
549 .\"
550 .SH AVERTISSEMENT SUR LA TRADUCTION
551 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
552 doute, veuillez vous reporter au document original en langue anglaise fourni
553 avec le programme.
554 .\"
555 .\" FILES part
556 .\"
557 .SH FICHIERS
558 .I /proc/net/wireless
559 .\"
560 .\" SEE ALSO part
561 .\"
562 .SH VOIR AUSSI
563 .BR ifconfig (8),
564 .BR iwspy (8),
565 .BR iwlist (8),
566 .BR iwevent (8),
567 .BR iwpriv (8),
568 .BR wireless (7).
+0
-131
src/lwe/fr/iwevent.8 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" iwevent.8
2 .\"
3 .\" Traduction 2003/08/17 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 26
6 .\" Manuel identique pour la version 27-pre9 (beta)
7 .\" Mise à jour 2004/02/26 : version 27-pre11 (alpha)
8 .\" Mise à jour 2004/08/23 : version 27-pre25
9 .\"
10 .TH IWEVENT 8 "23 juin 2004" "net-tools" "Manuel du Programmeur Linux"
11 .\"
12 .\" NAME part
13 .\"
14 .SH NOM
15 iwevent \- Affiche les Événements Wireless (Wireless Events) générés par les
16 pilotes et les changements de paramètres.
17 .\"
18 .\" SYNOPSIS part
19 .\"
20 .SH SYNOPSIS
21 .BI "iwevent "
22 .br
23 .\"
24 .\" DESCRIPTION part
25 .\"
26 .SH DESCRIPTION
27 .B iwevent
28 affiche les «\ Wireless Events\ » (événements du système Wireless) reçu par le
29 socket RTNetlink. Chaque ligne affiche le Wireless Event spécifique qui décrit
30 ce qui s'est passé sur l'interface sans fil spécifiée.
31 .br
32 Cette commande ne prend aucun argument.
33 .\"
34 .\" DISPLAY part
35 .\"
36 .SH AFFICHAGE
37 Il y a deux classes de Wireless Events.
38 .PP
39 La première classe regroupe les événements relatifs à un changement des
40 paramètres du sans fil sur l'interface (typiquement fait par
41 .B iwconfig
42 ou un script appelant
43 .BR iwconfig ).
44 Seuls les paramètres qui peuvent entraîner une perturbation de la connectivité
45 sont rapportés. Les événements actuellement rapportés changent un des paramètres
46 suivants\ :
47 .br
48 .I " Network ID"
49 .br
50 .I " ESSID"
51 .br
52 .I " Frequency"
53 .br
54 .I " Mode"
55 .br
56 .I " Encryption"
57 .br
58 Tous ces événements seront générer sur toutes les interfaces sans fil par le
59 sous-système «\ wireless\ » du noyau (mais seulement si le pilote a été converti
60 àl'API du nouveau pilote).
61 .PP
62 La deuxième classe d'événements concerne ceux générés par le matériel, lorsque
63 quelque chose arrive ou qu'une tâche s'est terminée. Ces événements incluent\ :
64 .TP
65 .B New Access Point/Cell address
66 L'interface a joint un nouveau point d'accès ou cellule ad hoc, ou perdu son
67 association avec. Il s'agit de la même adresse MAC affiché par
68 .BR iwconfig .
69 .TP
70 .B Scan request completed
71 Une requête de balayage (scanning) a été achevée, les résultats du «\ scan\ »
72 sont disponibles (voir
73 .BR iwlist ).
74 .TP
75 .B Tx packet dropped
76 Un paquet à destination de cette adresse a été rejeté car l'interface croit que
77 ce noeud ne répond plus (habituellement, le seuil maximum des émissions de la
78 couche MAC est atteint). C'est habituellement la première indication pouvant
79 révéler que le noeud a quitté la cellule ou est hors de portée, mais cela peut
80 être due à une atténuation ou une contention excessive.
81 .TP
82 .B Custom driver event
83 Événement spécifique au pilote. Veuillez consulter la documentation du pilote.
84 .TP
85 .B Registered node
86 L'interface a réussi à enregistrer un nouveau client/paire sans fil. Sera
87 généré la plupart du temps quand l'interface agit comme un point d'accès (mode
88 master).
89 .TP
90 .B Expired node
91 L'enregistrement d'un client/paire sur cette interface a expiré. Sera généré la
92 plupart du temps quand l'interface agit comme un point d'accès (mode master).
93 .TP
94 .B Spy threshold crossed
95 La force du signal pour une des adresses de la «\ spy list\ » (NDT\ : voir
96 iwspy(8)) est passé en-dessous du seuil bas, ou est passé au-dessus du seuil
97 haut.
98 .PP
99 La plupart des pilotes wireless génèrent seulement un sous-ensemble de ces
100 événements, pas tous, la liste exacte dépendant de la combinaison spécifique
101 matériel/pilote. Veuillez consulter la documentation du pilote pour les détails
102 de ce qui les génèrent, et utilisez
103 .IR iwlist (8)
104 pour vérifier ce que le pilote supporte.
105 .\"
106 .\" AUTHOR part
107 .\"
108 .SH AUTEUR
109 Jean Tourrilhes \- [email protected]
110 .\"
111 .\" TRADUCTION part
112 .\"
113 .SH TRADUCTION
114 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
115 .\"
116 \" AVERTISSEMENT part
117 .\"
118 .SH AVERTISSEMENT SUR LA TRADUCTION
119 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
120 doute, veuillez vous reporter au document original en langue anglaise fourni
121 avec le programme.
122 .\"
123 .\" SEE ALSO part
124 .\"
125 .SH VOIR AUSSI
126 .BR iwconfig (8),
127 .BR iwlist (8),
128 .BR iwspy (8),
129 .BR iwpriv (8),
130 .BR wireless (7).
+0
-136
src/lwe/fr/iwgetid.8 less more
0 .\" Guus Sliepen - 2001
1 .\" Completed and fixed up by Jean Tourrilhes - 2002-2003
2 .\" iwgetid.8
3 .\"
4 .\" Traduction 2003/08/17 Maxime CHARPENNE (voir
5 .\" http://www.delafond.org/traducmanfr/)
6 .\" 1ère traduction : version 26
7 .\" Mise à jour 2004/01/29 : version 27-pre9 (beta)
8 .\" Manuel identique pour la version 27-pre11 (alpha)
9 .\" Mise à jour 2004/08/23 : version 27-pre25
10 .\"
11 .TH IWGETID 8 "02 décembre 2003" "wireless-tools" "Manuel du Programmeur Linux"
12 .\"
13 .\" NAME part
14 .\"
15 .SH NOM
16 iwgetid \- Rapporte le ESSID, NWID ou l'Adresse de l'AP/Cell (Point d'Accès/\
17 Cellule) du réseau sans fil.
18 .\"
19 .\" SYNOPSIS part
20 .\"
21 .SH SYNOPSIS
22 .BI "iwgetid " [interface] " [--raw] [--scheme] [--ap] [--freq]"
23 .br
24 .BI " [--mode] [--protocol] [--channel]
25 .br
26 .\"
27 .\" DESCRIPTION part
28 .\"
29 .SH DESCRIPTION
30 .B iwgetid
31 est utilisé pour trouver le NWID, ESSID ou l'adresse de l'AP ou cellule du
32 réseau sans fil utilisé présentement. L'information rapportée est la même
33 que celle montrée par
34 .BR iwconfig ", mais " iwgetid
35 est plus facile à intégrer dans les scripts.
36 .br
37 Par défaut,
38 .B iwgetid
39 affichera
40 .RI l' ESSID
41 de la carte, et si la carte n'a pas d'ESSID, il affichera son
42 .IR NWID .
43 .br
44 Le formatage par défaut de la sortie est embelli.
45 .\"
46 .\" OPTIONS part
47 .\"
48 .SH OPTIONS
49 .TP
50 .B --raw
51 Cette option désactive l'embellissement de l'affichage de l'information. Cette
52 option est orthogonale aux autres options (sauf
53 .BR --scheme ),
54 donc, avec la combinaison appropriée des options, il est possible d'afficher
55 en brut l'ESSID, l'Adresse de l'AP ou le Mode.
56 .br
57 Ce format est idéal quand on stocke le résultat de iwgetid comme une variable
58 dans les scripts
59 .I Shell
60 ou
61 .IR Perl ,
62 ou pour passer le résultat comme argument sur la ligne de commande de
63 .BR iwconfig .
64 .TP
65 .B --scheme
66 Cette option est similaire à la précédente, elle désactive l'embellissement de
67 l'affichage des données et supprime tous les caractères non alphanumériques
68 (comme les caractères d'espacement, la ponctuation et les caractères de
69 contrôle).
70 .br
71 La sortie résultante est un identifiant Pcmcia valide («\ Pcmcia scheme
72 identifer\ ») (qui peut être utilisé comme argument de la commande
73 .BR "cardctl scheme" ).
74 Ce format est aussi idéal quand on utilise le résultat de iwgetid comme un
75 sélecteur («\ selector\ ») dans les scripts
76 .I Shell
77 ou
78 .IR Perl ,
79 ou comme un nom de fichier.
80 .TP
81 .B --ap
82 Affiche l'adresse MAC du
83 .I Point d'Access
84 ou de la
85 .I Cellule
86 sans fil.
87 .TP
88 .B --freq
89 Affiche la
90 .I fréquence
91 ou le
92 .I canal
93 courant utilisé par l'interface.
94 .TP
95 .B --channel
96 Affiche le canal
97 .RI ( channel )
98 courant utilisé par l'interface. Le canal est déterminé en utilisant la
99 fréquence courante et la liste de fréquence fournie par l'interface.
100 .TP
101 .B --mode
102 Affiche le
103 .I mode
104 courant de l'interface.
105 .TP
106 .B --protocol
107 Affiche le
108 .I nom de protocole
109 de l'interface. Il permet d'identifer toutes les cartes qui sont compatibles
110 entre elles et qui acceptent le même type de configuration.
111 .br
112 Cela peut aussi être utilisé pour
113 .I vérifier la compatibilité de Wireless Extension
114 sur l'interface, car c'est le seul attribut que tous les pilotes supportant
115 Wireless Extension doivent avoir.
116 .\"
117 .\" TRADUCTION part
118 .\"
119 .SH TRADUCTION
120 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
121 .\"
122 \" AVERTISSEMENT part
123 .\"
124 .SH AVERTISSEMENT SUR LA TRADUCTION
125 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
126 doute, veuillez vous reporter au document original en langue anglaise fourni
127 avec le programme.
128 .\"
129 .\" SEE ALSO part
130 .\"
131 .SH VOIR AUSSI
132 .BR iwconfig (8),
133 .BR ifconfig (8),
134 .BR iwspy (8),
135 .BR iwpriv (8).
+0
-145
src/lwe/fr/iwlist.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwlist.8
2 .\"
3 .\" Traduction 2003/08/17 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 26
6 .\" Mise à jour 2004/01/29 : version 27-pre9 (beta)
7 .\" Manuel identique pour la version 27-pre11 (alpha)
8 .\" Mise à jour 2004/08/23 : version 27-pre25
9 .\"
10 .TH IWLIST 8 "23 juin 2004" "wireless-tools" "Manuel du Programmeur Linux"
11 .\"
12 .\" NAME part
13 .\"
14 .SH NOM
15 iwlist \- Obtient plus d'informations wireless détaillées depuis une interface wireless
16 .\"
17 .\" SYNOPSIS part
18 .\"
19 .SH SYNOPSIS
20 .BI "iwlist " interface " scanning"
21 .br
22 .BI "iwlist " interface " frequency"
23 .br
24 .BI "iwlist " interface " rate"
25 .br
26 .BI "iwlist " interface " key"
27 .br
28 .BI "iwlist " interface " power"
29 .br
30 .BI "iwlist " interface " txpower"
31 .br
32 .BI "iwlist " interface " retry"
33 .br
34 .BI "iwlist " interface " event"
35 .br
36 .BI "iwlist --help"
37 .br
38 .BI "iwlist --version"
39 .\"
40 .\" DESCRIPTION part
41 .\"
42 .SH DESCRIPTION
43 .B Iwlist
44 est utilisé pour afficher de l'information additionnelle d'une interface réseau
45 wireless qui n'est pas affichée par
46 .IR iwconfig (8)
47 L'argument principal est utilisé pour sélectionner une catégorie d'information,
48 .B iwlist
49 affiche dans une forme détaillée toute information relative à cette catégorie,
50 y compris les informations déjà montrées par
51 .IR iwconfig (8).
52 .\"
53 .\" PARAMETER part
54 .\"
55 .SH PARAMÈTRES
56 .TP
57 .BR scan [ning]
58 Donne la liste des Points d'Accès et des cellules Ad-Hoc à portée, et
59 optionnellement plein d'autres informations à leur propos (ESSID, Quality,
60 Frequency, Mode...). Le type d'information retourné dépend de ce que la carte
61 supporte.
62 .br
63 Le «\ Triggering scanning\ » est une opération nécessitant les privilèges
64 de
65 .I root
66 et les utilisateurs normaux peuvent juste lire les résultats («\ letf-over scan
67 results\ »). Par défaut, les paramètres courants du pilote auront une grande
68 incidence sur la manière dont le scan est réalisé (la boucle du scan). Aussi,
69 cette commande est supposée prendre des arguments supplémentaires pour contrôler
70 le comportement du scan, mais cela n'est actuellement pas implémenté.
71 .TP
72 .BR freq [uency]/ channel
73 Donne la liste des fréquences disponibles du périphérique et le nombre de canaux
74 définis. Veuillez noter que, habituellement, le pilote retourne le nombre total
75 de canaux et seulement les fréquences disponibles dans la région considérée,
76 donc il n'y a pas correspondance entre le nombre de fréquences affichées et le
77 nombre de canaux.
78 .TP
79 .BR rate / bit [rate]
80 Liste les débits supportés par le périphérique (en b/s).
81 .TP
82 .BR key / enc [ryption]
83 Liste les tailles des clefs de cryptage supportées et affiche toutes
84 les clefs de cryptage disponibles dans le périphérique.
85 .TP
86 .B power
87 Liste les divers attributs et modes d'économie d'énergie («\ Power
88 Management\ ») du périphérique.
89 .TP
90 .B txpower
91 Liste les différentes puissances d'émission («\ Transmit Powers\ »)
92 disponibles dans le périphérique.
93 .TP
94 .B retry
95 Liste les limites des tentatives de transmissions («\ transmit retry limits\ »)
96 et la durée de vie des tentatives («\ retry lifetime\ ») du périphériques
97 (NDT\ : voir la section
98 .B retry
99 de iwconfig(8)).
100 .TP
101 .BR ap / accesspoint / peers
102 Donne la liste des Points d'Accès à portée, et optionnellement la qualié de leur
103 lien. Cette option est
104 .B obsolète
105 et est maintenant dépréciée en faveur du support scan (voir ci-dessus), et la
106 plupart des pilotes ne le supporte pas.
107 .br
108 Quelques pilotes peuvent utiliser cette commande pour retourner une
109 liste spécifique de Paires («\ Peers\ ») ou de Points d'Accès, telle que la
110 liste des Paires associés/enregistrés avec la carte. Voir la documentation du
111 pilote pour plus de détails.
112 .TP
113 .B event
114 Liste les événements wireless supportés par le périphérique.
115 .TP
116 .B --version
117 Affiche la version des outils, ainsi que la version courante et recommandée des
118 Wireless Extensions pour l'outil et les diverses interfaces sans fil.
119 .\"
120 .\" TRADUCTION part
121 .\"
122 .SH TRADUCTION
123 Maxime CHARPENNE, août 2004 (wireless_tools.27-pre25).
124 .\"
125 \" AVERTISSEMENT part
126 .\"
127 .SH AVERTISSEMENT SUR LA TRADUCTION
128 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
129 doute, veuillez vous reporter au document original en langue anglaise fourni
130 avec le programme.
131 .\"
132 .\" FILES part
133 .\"
134 .SH FICHIERS
135 .I /proc/net/wireless
136 .\"
137 .\" SEE ALSO part
138 .\"
139 .SH VOIR AUSSI
140 .BR iwconfig (8),
141 .BR iwspy (8).
142 .BR iwevent (8),
143 .BR iwpriv (8),
144 .BR wireless (7).
+0
-156
src/lwe/fr/iwpriv.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwpriv.8
2 .\"
3 .\" Traduction 2003/08/17 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 26
6 .\" Manuel identique pour version 27-pre9 (beta)
7 .\" Manuel identique pour version 27-pre11 (alpha)
8 .\"
9 .TH IWPRIV 8 "31 octobre 1996" "net-tools" "Manuel du programmeur Linux"
10 .\"
11 .\" NAME part
12 .\"
13 .SH NOM
14 iwpriv \- configure les paramètres optionnels (privés) d'une interface réseau
15 sans fil
16 .\"
17 .\" SYNOPSIS part
18 .\"
19 .SH SYNOPSIS
20 .BI "iwpriv [" interface ]
21 .br
22 .BI "iwpriv " "interface private-command " "[" private-parameters ]
23 .br
24 .BI "iwpriv " "interface private-command [I] " "[" private-parameters ]
25 .br
26 .BI "iwpriv " interface " --all"
27 .br
28 .BI "iwpriv " interface " roam " {on,off}
29 .br
30 .BI "iwpriv " interface " port " {ad-hoc,managed,N}
31 .\"
32 .\" DESCRIPTION part
33 .\"
34 .SH DESCRIPTION
35 .B Iwpriv
36 est l'outil à utiliser avec
37 .IR iwconfig (8).
38 .B Iwpriv
39 traite les paramètres et attributs spécifiques à chaque pilote (contrairement
40 à
41 .I iwconfig
42 qui ne s'occupe que des génériques).
43 .PP
44 Sans argument,
45 .B iwpriv
46 liste les commandes privées disponibles sur chaque interface, ainsi que les
47 paramètres qu'elles requièrent. En utilisant ces informations, l'utilisateur
48 peut appliquer ces commandes particulières sur les interfaces spécifiées.
49 .PP
50 En théorie, la documentation de chaque pilote devrait indiquer comment utiliser
51 ces commandes spécifiques et leurs effets.
52 .\"
53 .\" PARAMETER part
54 .\"
55 .SH PARAMÈTRES
56 .TP
57 .IR private-command " [" private-parameters ]
58 Exécute la
59 .I private-command
60 (commande privée) spécifiée sur l'interface.
61 .br
62 La commande peut éventuellement prendre ou nécessiter des arguments, et peut
63 afficher de l'information. En conséquent, les paramètres de la ligne de
64 commande peuvent ou peuvent ne pas être nécessaires et doivent correspondre
65 aux besoins de la commande. La liste des commandes que
66 .B iwpriv
67 affiche (quand il est appelé sans paramètre) doit vous donner des indications
68 sur ces paramètres.
69 .br
70 Cependant, vous devriez vous reporter à la documentation du pilote du
71 périphérique pour utiliser les commandes correctement, ainsi que connaître
72 leurs effets.
73 .TP
74 .I "private-command [I]" "[" private-parameters ]
75 Idem, sauf que
76 .I I
77 (un entier) est passé à la commande en tant que
78 .I "Token Index"
79 (indication d'index). Seules quelques commandes utiliseront ce «\ Token
80 Index\ » (la plupart l'ignoreront), et la documentation du pilote devrait
81 préciser quand il est nécessaire.
82 .TP
83 .BR -a / --all
84 Exécute et affiche toutes les commandes privées qui ne prennent aucun argument
85 (c.-à-d. en lecture seule).
86 .TP
87 .B roam
88 Active ou désactive le «\ roaming\ », s'il est supporté. Appelle la commande
89 privée
90 .IR setroam .
91 Trouvé dans le pilote
92 .I wavelan_cs
93 .TP
94 .B port
95 Lit ou configure le type de port. Appelle les commandes privées
96 .IR gport_type ", " sport_type ", " get_port " ou " set_port
97 trouvées dans les pilotes
98 .IR wavelan2_cs " et " wvlan_cs .
99 .\"
100 .\" DISPLAY part
101 .\"
102 .SH AFFICHAGE
103 Pour chaque matériel qui supporte les commandes privées,
104 .I iwpriv
105 affichera la liste des commandes privées disponibles.
106 .PP
107 Cela inclut le nom de la commande privée, le nombre d'arguments qui peuvent
108 être entrés et leur type, ainsi que le nombre d'arguments qui peuvent être
109 affichés et leur type.
110 .PP
111 Par exemple, vous pouvez avoir l'affichage suivant\ :
112 .br
113 .B "eth0 Available private ioctl :"
114 .br
115 .B " setqualthr (89F0) : set 1 byte & get 0"
116 .br
117 .B " gethisto (89F7) : set 0 & get 16 int"
118 .PP
119 Cela veut dire que vous pouvez fixer le seuil de qualité et afficher un
120 histogramme jusqu'à 16 valeurs avec les commandes suivantes\ :
121 .br
122 .I " iwpriv eth0 setqualthr 20"
123 .br
124 .I " iwpriv eth0 gethisto"
125 .\"
126 .\" AUTHOR part
127 .\"
128 .SH AUTHOR
129 Jean Tourrilhes \- [email protected]
130 .\"
131 .\" TRADUCTION part
132 .\"
133 .SH TRADUCTION
134 Maxime CHARPENNE, août 2003.
135 .\"
136 \" AVERTISSEMENT part
137 .\"
138 .SH AVERTISSEMENT SUR LA TRADUCTION
139 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
140 doute, veuillez vous reporter au document original en langue anglaise fourni
141 avec le programme.
142 .\"
143 .\" FILES part
144 .\"
145 .SH FILES
146 .I /proc/net/wireless
147 .\"
148 .\" SEE ALSO part
149 .\"
150 .SH SEE ALSO
151 .BR iwconfig (8),
152 .BR iwlist (8),
153 .BR iwevent (8),
154 .BR iwspy (8),
155 .BR wireless (7).
+0
-116
src/lwe/fr/iwspy.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwspy.8
2 .\"
3 .\" Traduction 2003/08/18 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 26
6 .\" Manuel identique pour la version 27-pre9 (beta)
7 .\" Manuel identique pour la version 27-pre11 (alpha)
8 .\"
9 .TH IWSPY 8 "31 octobre 1996" "net-tools" "Manuel du Programmeur Linux"
10 .\"
11 .\" NAME part
12 .\"
13 .SH NOM
14 iwspy \- Obtenir des statistiques wireless depuis des n½uds donnés
15 .\"
16 .\" SYNOPSIS part
17 .\"
18 .SH SYNOPSIS
19 .BI "iwspy " interface
20 .br
21 .BI "iwspy " interface " [+] " DNSNAME " | " IPADDR " | " HWADDR " [...]"
22 .br
23 .BI "iwspy " interface " off"
24 .br
25 .BI "iwspy " interface " setthr " "low high"
26 .br
27 .BI "iwspy " interface " getthr"
28 .\"
29 .\" DESCRIPTION part
30 .\"
31 .SH DESCRIPTION
32 .B Iwspy
33 est utilisé pour fixer une liste d'adresses sur une interface réseau sans fil,
34 et obtenir des informations sur la qualité du lien pour chacune d'elles. Ces
35 informations sont les mêmes que celles disponibles dans
36 .IR /proc/net/wireless "\ :"
37 qualité du lien, force du signal et niveau du bruit.
38 .PP
39 Ces informations sont mises à jour à chaque fois qu'un nouveau paquet est reçu,
40 donc chaque adresse de la liste ajoute quelques précisions en plus.
41 .PP
42 Remarquez que cette fonctionnalité ne marche que pour les n½uds faisant partie
43 des cellules sans fil courantes.
44 .\"
45 .\" PARAMETER part
46 .\"
47 .SH PARAMÈTRES
48 Vous pouvez fixer jusqu'à 8 adresses.
49 .TP
50 .BR DNSNAME " | " IPADDR
51 Paramètre une adresse IP, ou dans certains cas un nom DNS (en utilisant le
52 «\ resolver\ » de nom). Comme le matériel fonctionne avec des adresses
53 matérielles,
54 .B iwspy
55 traduira les adresses IP grâce à
56 .IR ARP .
57 Dans certains cas, cette adresse peut ne pas être dans le cache ARP et
58 .B iwspy
59 échouera. Dans cette situation, exécuter
60 .IR ping (8)
61 vers ces noms/adresses et réessayer.
62 .TP
63 .B HWADDR
64 Paramètre une adresse matérielle (MAC) (cette adresse n'est pas traduite et
65 vérifer comme le sont les adresses IP). L'adresse doit contenir deux-points
66 .RB ( : )
67 pour être reconnue comme une adresse matérielle.
68 .TP
69 .B +
70 Ajoute un nouveau jeu d'adresses à la fin de la liste courante au lieu de la
71 remplacer. La liste d'adresses est unique pour chaque carte, donc chaque
72 utilisateur devrait utiliser cette option pour éviter les conflits.
73 .TP
74 .B off
75 Enlève la liste d'adresses courante et désactive la fonctionnalité de
76 scrutation.
77 .TP
78 .B setthr
79 Fixe les seuils de force de signal
80 .IR low " (bas) et " high " (haut)"
81 pour les événements iwspy (pour les pilotes qui le supportent).
82 .br
83 Chaque fois que la force du signal, pour une des adresses contrôlées avec
84 iwspy, passe au-dessous du seuil bas ou au-dessus du seuil haut, un Wireless
85 Event est généré.
86 .br
87 Ceci peut être utilisé pour surveiller la qualité du lien sans avoir à lancer
88 iwspy périodiquement.
89 .TP
90 .B getthr
91 Récupère les seuils
92 .IR low " (bas) et " high " (haut)"
93 de la force du signal pour l'événement iwspy.
94 .\"
95 \" AVERTISSEMENT part
96 .\"
97 .SH AVERTISSEMENT SUR LA TRADUCTION
98 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
99 doute, veuillez vous reporter au document original en langue anglaise fourni
100 avec le programme.
101 \"
102 .\" FILES part
103 .\"
104 .SH FICHIERS
105 .I /proc/net/wireless
106 .\"
107 .\" SEE ALSO part
108 .\"
109 .SH VOIR AUSSI
110 .BR iwconfig (8),
111 .BR iwlist (8),
112 .BR iwevent (8),
113 .BR iwpriv (8),
114 .BR wireless (7).
115
+0
-145
src/lwe/fr/wireless.7 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" wireless.7
2 .\"
3 .\" Traduction 2004/02/26 Maxime CHARPENNE (voir
4 .\" http://www.delafond.org/traducmanfr/)
5 .\" 1ère traduction : version 27-pre11 (alpha)
6 .\" Mise à jour 2004/08/24 : version 27-pre25
7 .TH WIRELESS 7 "04 mars 2004" "wireless-tools" "Manuel du Programmeur Linux"
8 .\"
9 .\" NAME part
10 .\"
11 .SH NOM
12 wireless \- Wireless Tools et Wireless Extensions
13 .\"
14 .\" SYNOPSIS part
15 .\"
16 .SH SYNOPSIS
17 .B iwconfig
18 .br
19 .B iwpriv \-a
20 .br
21 .\"
22 .\" DESCRIPTION part
23 .\"
24 .SH DESCRIPTION
25 Les
26 .B Wireless Extensions
27 sont une API vous permettant de manipuler les interfaces réseaux Wireless LAN.
28 Ils sont composés d'une gamme d'outils et de fichiers de configuration. Ils sont
29 plus amplement détaillés dans le Linux Wireless LAN Howto.
30 .br
31 Les
32 .B Wireless Tools
33 sont utilisés pour changer la configuration des interfaces réseau LAN wireless
34 à la volée, pour obtenir leur configuration courante, pour avoir des
35 statistiques et pour les diagnostiquer. Ils sont décrits dans leur propre page
36 man, voir ci-dessous pour les références.
37 .br
38 La
39 .B configuration Wireless
40 est propre à chaque distribution Linux. Cette page man contiendra à l'avenir
41 la procédure de configuration pour quelques distributions les plus communes.
42 (quand j'en ai les informations nécessaires). Pour le moment, consultez le
43 fichier DISTRIBUTIONS.txt inclus avec le paquetage Wireless Tools.
44 .\"
45 .\" DEBIAN 3.0 part
46 .\"
47 .SH DEBIAN 3.0
48 Dans la Debian 3.0 (et suivante) vous pouvez configurer les périphériques
49 réseaux LAN wireless en utilisant l'outil de configuration réseau
50 .BR ifupdown (8).
51 .TP
52 .B Fichier :
53 .I /etc/network/interfaces
54 .TP
55 .B Format :
56 .RI wireless\- "<fonction> <valeur>"
57 .br
58 wireless\-essid Maison
59 .br
60 wireless\-mode Ad\-Hoc
61 .TP
62 .B Voir aussi :
63 .I /etc/network/if\-pre\-up.d/wireless\-tools
64 .br
65 .I /usr/share/doc/wireless\-tools/README.Debian
66 .\"
67 .\" SuSE 8.0 part
68 .\"
69 .SH SuSE 8.0
70 La SuSE 8.0 (et suivante) a intégré la configuration wireless dans ses
71 scripts réseaux.
72 .TP
73 .B Outils :
74 .B Yast2
75 .TP
76 .B Fichiers :
77 .I /etc/sysconfig/network/wireless
78 .br
79 .I /etc/sysconfig/network/ifcfg\-*
80 .TP
81 .B Format :
82 .RI WIRELESS_ "<fonction>" = "<valeur>"
83 .br
84 WIRELESS_ESSID="Maison"
85 .br
86 WIRELESS_MODE=Ad\-Hoc
87 .TP
88 .B Voir aussi :
89 man ifup
90 .br
91 info scpm
92 .\"
93 .\" PCMCIA part
94 .\"
95 .SH SCRIPTS ORIGINAUX PCMCIA
96 Si vous utilisez les scripts originaux de configuration du paquetage Pcmcia,
97 vous pouvez utiliser cette méthode.
98 .TP
99 .B Fichier :
100 .I /etc/pcmcia/wireless.opts
101 .TP
102 .B Format :
103 *,*,*,*)
104 .br
105 ESSID="Maison"
106 .br
107 MODE="Ad-Hoc"
108 .br
109 ;;
110 .TP
111 .B Voir aussi :
112 .I /etc/pcmcia/wireless
113 .br
114 Le fichier
115 .I PCMCIA.txt
116 qui fait partie du paquetage Wireless Tools.
117 .\"
118 .\" AUTHOR part
119 .\"
120 .SH AUTEUR
121 Jean Tourrilhes \- [email protected]
122 .br
123 .I http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
124 .\"
125 .\" TRADUCTION part
126 .\"
127 .SH TRADUCTION
128 Maxime CHARPENNE, août 2004 (wireless-tools.27-pre25).
129 .\"
130 .\" AVERTISSEMENT part
131 .\"
132 .SH AVERTISSEMENT SUR LA TRADUCTION
133 Il est possible que cette traduction soit imparfaite ou périmée. En cas de
134 doute, veuillez vous reporter au document original en langue anglaise fourni
135 avec le programme.
136 .\"
137 .\" SEE ALSO part
138 .\"
139 .SH VOIR AUSSI
140 .BR iwconfig (8),
141 .BR iwlist (8),
142 .BR iwspy (8),
143 .BR iwpriv (8),
144 .BR iwevent (8).
+0
-183
src/lwe/ifrename.8 less more
0 .\" Jean II - HPL - 2004-2007
1 .\" ifrename.8
2 .\"
3 .TH IFRENAME 8 "26 February 2007" "wireless-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 ifrename \- rename network interfaces based on various static criteria
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .B "ifrename [-c configfile] [-p] [-d] [-u] [-v] [-V] [-D]"
14 .br
15 .B "ifrename [-c configfile] [-i interface] [-n newname]"
16 .\"
17 .\" DESCRIPTION part
18 .\"
19 .SH DESCRIPTION
20 .B Ifrename
21 is a tool allowing you to assign a consistent name to each of your
22 network interface.
23 .PP
24 By default, interface names are dynamic, and each network interface is
25 assigned the first available name
26 .RI ( eth0 ", " eth1 "...)."
27 The order network interfaces are created may vary. For built-in
28 interfaces, the kernel boot time enumeration may vary. For removable
29 interface, the user may plug them in any order.
30 .PP
31 .B Ifrename
32 allow the user to decide what name a network interface will have.
33 .B Ifrename
34 can use a variety of
35 .I selectors
36 to specify how interface names match the network interfaces on the
37 system, the most common selector is the interface
38 .IR "MAC address" .
39 .PP
40 .B Ifrename
41 must be run before interfaces are brought up, which is why it's mostly
42 useful in various scripts (init, hotplug) but is seldom used directly
43 by the user. By default,
44 .B ifrename
45 renames all present system interfaces using mappings defined in
46 .IR /etc/iftab .
47 .\"
48 .\" PARAMETER part
49 .\"
50 .SH PARAMETERS
51 .TP
52 .BI "-c " configfile
53 Set the configuration file to be used (by default
54 .IR /etc/iftab ).
55 The configuration file define the mapping between selectors and
56 interface names, and is described in
57 .IR iftab (5).
58 .br
59 If
60 .I configfile
61 is "-", the configuration is read from stdin.
62 .TP
63 .B -p
64 Probe (load) kernel modules before renaming interfaces. By default
65 .B ifrename
66 only check interfaces already loaded, and doesn't auto-load the
67 required kernel modules. This option enables smooth integration with
68 system not loading modules before calling
69 .BR ifrename .
70 .TP
71 .B -d
72 Enable various
73 .B Debian
74 specific hacks. Combined with
75 .BR -p ,
76 only modules for interfaces specified in
77 .I /etc/network/interface
78 are loaded.
79 .TP
80 .BI "-i " interface
81 Only rename the specified
82 .I interface
83 as opposed to all interfaces on the system. The new interface name is
84 printed.
85 .TP
86 .BI "-n " newname
87 When used with
88 .IR -i ,
89 specify the new name of the interface. The list of mappings from the
90 configuration file is bypassed, the interface specified with
91 .I -i
92 is renamed directly to
93 .IR newname .
94 The new name may be a wildcard containing a single '*'.
95 .br
96 When used without
97 .IR -i ,
98 rename interfaces by using only mappings that would rename them to
99 .IR newname .
100 The new name may not be a wildcard. This use of ifrename is
101 discouraged, because inefficient
102 .RI ( -n " without " -i ).
103 All the interfaces of the system need to be processed at each
104 invocation, therefore in most case it is not faster than just letting
105 ifrename renaming all of them (without both
106 .IR -n " and " -i ).
107 .TP
108 .B -t
109 Enable name takeover support. This allow interface name swapping
110 between two or more interfaces.
111 .br
112 Takeover enable an interface to 'steal' the name of another
113 interface. This works only with kernel 2.6.X and if the other
114 interface is down. Consequently, this is not compatible with
115 Hotplug. The other interface is assigned a random name, but may be
116 renamed later with 'ifrename'.
117 .br
118 The number of takeovers is limited to avoid circular loops, and
119 therefore some complex multi-way name swapping situations may not be
120 fully processed.
121 .br
122 In any case, name swapping and the use of this feature is discouraged,
123 and you are invited to choose unique and unambiguous names for your
124 interfaces...
125 .TP
126 .B -u
127 Enable
128 .I udev
129 output mode. This enables proper integration of
130 .B ifrename
131 in the
132 .I udev
133 framework,
134 .BR udevd (8)
135 will use
136 .B ifrename
137 to assign interface names present in
138 .IR /etc/iftab .
139 In this mode the output of ifrename can be parsed
140 directly by
141 .BR udevd (8)
142 as an IMPORT action. This requires
143 .I udev
144 version 107 or later.
145 .TP
146 .B -D
147 Dry-run mode. Ifrename won't change any interface, it will only print
148 new interface name, if applicable, and return.
149 .br
150 In dry-run mode, interface name wildcards are not resolved. New
151 interface name is printed, even if it is the same as the old name.
152 .br
153 Be also aware that some selectors can only be read by root, for
154 example those based on
155 .BR ethtool ),
156 and will fail silently if run by a normal user. In other words,
157 dry-run mode under a standard user may not give the expected result.
158 .TP
159 .B -V
160 Verbose mode. Ifrename will display internal results of parsing its
161 configuration file and querying the interfaces selectors. Combined
162 with the
163 .I dry-run
164 option, this is a good way to debug complex configurations or trivial
165 problems.
166 .\"
167 .\" AUTHOR part
168 .\"
169 .SH AUTHOR
170 Jean Tourrilhes \- [email protected]
171 .\"
172 .\" FILES part
173 .\"
174 .SH FILES
175 .I /etc/iftab
176 .\"
177 .\" SEE ALSO part
178 .\"
179 .SH SEE ALSO
180 .BR ifconfig (8),
181 .BR ip (8),
182 .BR iftab (5).
+0
-2721
src/lwe/ifrename.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPL 04 -> 07
4 *
5 * Main code for "ifrename". This is tool allows to rename network
6 * interfaces based on various criteria (not only wireless).
7 * You need to link this code against "iwlib.c" and "-lm".
8 *
9 * This file is released under the GPL license.
10 * Copyright (c) 2007 Jean Tourrilhes <[email protected]>
11 */
12
13 /*
14 * The changelog for ifrename is in the file CHANGELOG.h ;-)
15 *
16 * This work is a nearly complete rewrite of 'nameif.c'.
17 * Original CopyRight of version of 'nameif' I used is :
18 * -------------------------------------------------------
19 * Name Interfaces based on MAC address.
20 * Writen 2000 by Andi Kleen.
21 * Subject to the Gnu Public License, version 2.
22 * TODO: make it support token ring etc.
23 * $Id: nameif.c,v 1.3 2003/03/06 23:26:52 ecki Exp $
24 * -------------------------------------------------------
25 *
26 * It started with a series of patches to nameif which never made
27 * into the regular version, and had some architecural 'issues' with
28 * those patches, which is the reason of this rewrite.
29 * Difference with standard 'nameif' :
30 * o 'nameif' has only a single selector, the interface MAC address.
31 * o Modular selector architecture, easily add new selectors.
32 * o Wide range of selector, including sysfs and sysfs symlinks...
33 * o hotplug invocation support.
34 * o module loading support.
35 * o MAC address wildcard.
36 * o Interface name wildcard ('eth*' or 'wlan*').
37 * o Non-Ethernet MAC addresses (any size, not just 48 bits)
38 */
39
40 /***************************** INCLUDES *****************************/
41
42 /* This is needed to enable GNU extensions such as getline & FNM_CASEFOLD */
43 #ifndef _GNU_SOURCE
44 #define _GNU_SOURCE
45 #endif
46
47 #include <getopt.h> /* getopt_long() */
48 #include <linux/sockios.h> /* SIOCSIFNAME */
49 #include <fnmatch.h> /* fnmatch() */
50 //#include <sys/syslog.h>
51
52 #include "iwlib.h" /* Wireless Tools library */
53
54 // This would be cool, unfortunately...
55 //#include <linux/ethtool.h> /* Ethtool stuff -> struct ethtool_drvinfo */
56
57 /************************ CONSTANTS & MACROS ************************/
58
59 /* Our default configuration file */
60 const char DEFAULT_CONF[] = "/etc/iftab";
61
62 /* Debian stuff */
63 const char DEBIAN_CONFIG_FILE[] = "/etc/network/interfaces";
64
65 /* Backward compatibility */
66 #ifndef ifr_newname
67 #define ifr_newname ifr_ifru.ifru_slave
68 #endif
69
70 /* Types of selector we support. Must match selector_list */
71 const int SELECT_MAC = 0; /* Select by MAC address */
72 const int SELECT_ETHADDR = 1; /* Select by MAC address */
73 const int SELECT_ARP = 2; /* Select by ARP type */
74 const int SELECT_LINKTYPE = 3; /* Select by ARP type */
75 const int SELECT_DRIVER = 4; /* Select by Driver name */
76 const int SELECT_BUSINFO = 5; /* Select by Bus-Info */
77 const int SELECT_FIRMWARE = 6; /* Select by Firmware revision */
78 const int SELECT_BASEADDR = 7; /* Select by HW Base Address */
79 const int SELECT_IRQ = 8; /* Select by HW Irq line */
80 const int SELECT_INTERRUPT = 9; /* Select by HW Irq line */
81 const int SELECT_IWPROTO = 10; /* Select by Wireless Protocol */
82 const int SELECT_PCMCIASLOT = 11; /* Select by Pcmcia Slot */
83 const int SELECT_SYSFS = 12; /* Select by sysfs file */
84 const int SELECT_PREVNAME = 13; /* Select by previous interface name */
85 #define SELECT_NUM 14
86
87 #define HAS_MAC_EXACT 1
88 #define HAS_MAC_FILTER 2
89 #define MAX_MAC_LEN 16 /* Maximum lenght of MAC address */
90
91 const struct ether_addr zero_mac = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
92
93 const struct option long_opt[] =
94 {
95 {"config-file", 1, NULL, 'c' },
96 {"debian", 0, NULL, 'd' },
97 {"dry-run", 0, NULL, 'D' },
98 {"help", 0, NULL, '?' },
99 {"interface", 1, NULL, 'i' },
100 {"newname", 1, NULL, 'n' },
101 {"takeover", 0, NULL, 't' },
102 {"udev", 0, NULL, 'u' },
103 {"version", 0, NULL, 'v' },
104 {"verbose", 0, NULL, 'V' },
105 {NULL, 0, NULL, '\0' },
106 };
107
108 /* Pcmcia stab files */
109 #define PCMCIA_STAB1 "/var/lib/pcmcia/stab"
110 #define PCMCIA_STAB2 "/var/run/stab"
111
112 /* Max number of sysfs file types we support */
113 #define SYSFS_MAX_FILE 8
114
115 /* Userspace headers lag, fix that... */
116 #ifndef ARPHRD_IEEE1394
117 #define ARPHRD_IEEE1394 24
118 #endif
119 #ifndef ARPHRD_EUI64
120 #define ARPHRD_EUI64 27
121 #endif
122 #ifndef ARPHRD_IRDA
123 #define ARPHRD_IRDA 783
124 #endif
125
126 /* Length of various non-standard MAC addresses */
127 const int weird_mac_len[][2] =
128 {
129 { ARPHRD_IEEE1394, 8 },
130 { ARPHRD_EUI64, 8 },
131 { ARPHRD_IRDA, 4 },
132 };
133 const int weird_mac_len_num = sizeof(weird_mac_len) / sizeof(weird_mac_len[0]);
134
135 /****************************** TYPES ******************************/
136
137 /* Cut'n'paste from ethtool.h */
138 #define ETHTOOL_BUSINFO_LEN 32
139 /* these strings are set to whatever the driver author decides... */
140 struct ethtool_drvinfo {
141 __u32 cmd;
142 char driver[32]; /* driver short name, "tulip", "eepro100" */
143 char version[32]; /* driver version string */
144 char fw_version[32]; /* firmware version string, if applicable */
145 char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
146 /* For PCI devices, use pci_dev->slot_name. */
147 char reserved1[32];
148 char reserved2[16];
149 __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
150 __u32 testinfo_len;
151 __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
152 __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
153 };
154 #define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
155
156 /* Description of an interface mapping */
157 typedef struct if_mapping
158 {
159 /* Linked list */
160 struct if_mapping * next;
161
162 /* Name of this interface */
163 char ifname[IFNAMSIZ+1];
164 char * sysfs_devpath;
165 int sysfs_devplen;
166
167 /* Selectors for this interface */
168 int active[SELECT_NUM]; /* Selectors active */
169
170 /* Selector data */
171 unsigned char mac[MAX_MAC_LEN]; /* Exact MAC address, hex */
172 int mac_len; /* Length (usually 6) */
173 char mac_filter[16*3 + 1]; /* WildCard, ascii */
174 unsigned short hw_type; /* Link/ARP type */
175 char driver[32]; /* driver short name */
176 char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
177 char fw_version[32]; /* Firmware revision */
178 unsigned short base_addr; /* HW Base I/O address */
179 unsigned char irq; /* HW irq line */
180 char iwproto[IFNAMSIZ + 1]; /* Wireless/protocol name */
181 int pcmcia_slot; /* Pcmcia slot */
182 char * sysfs[SYSFS_MAX_FILE]; /* sysfs selectors */
183 char prevname[IFNAMSIZ+1]; /* previous interface name */
184 } if_mapping;
185
186 /* Extra parsing information when adding a mapping */
187 typedef struct add_extra
188 {
189 char * modif_pos; /* Descriptor modifier */
190 size_t modif_len;
191 } parsing_extra;
192
193 /* Prototype for adding a selector to a mapping. Return -1 if invalid value. */
194 typedef int (*mapping_add)(struct if_mapping * ifnode,
195 int * active,
196 char * pos,
197 size_t len,
198 struct add_extra * extra,
199 int linenum);
200
201 /* Prototype for comparing the selector of two mapping. Return 0 if matches. */
202 typedef int (*mapping_cmp)(struct if_mapping * ifnode,
203 struct if_mapping * target);
204 /* Prototype for extracting selector value from live interface */
205 typedef int (*mapping_get)(int skfd,
206 const char * ifname,
207 struct if_mapping * target,
208 int flag);
209
210 /* How to handle a selector */
211 typedef struct mapping_selector
212 {
213 char * name;
214 mapping_add add_fn;
215 mapping_cmp cmp_fn;
216 mapping_get get_fn;
217 } mapping_selector;
218
219 /* sysfs global data */
220 typedef struct sysfs_metadata
221 {
222 char * root; /* Root of the sysfs */
223 int rlen; /* Size of it */
224 int filenum; /* Number of files */
225 char * filename[SYSFS_MAX_FILE]; /* Name of files */
226 } sysfs_metadata;
227
228 /**************************** PROTOTYPES ****************************/
229
230 static int
231 mapping_addmac(struct if_mapping * ifnode,
232 int * active,
233 char * pos,
234 size_t len,
235 struct add_extra * extra,
236 int linenum);
237 static int
238 mapping_cmpmac(struct if_mapping * ifnode,
239 struct if_mapping * target);
240 static int
241 mapping_getmac(int skfd,
242 const char * ifname,
243 struct if_mapping * target,
244 int flag);
245 static int
246 mapping_addarp(struct if_mapping * ifnode,
247 int * active,
248 char * pos,
249 size_t len,
250 struct add_extra * extra,
251 int linenum);
252 static int
253 mapping_cmparp(struct if_mapping * ifnode,
254 struct if_mapping * target);
255 static int
256 mapping_getarp(int skfd,
257 const char * ifname,
258 struct if_mapping * target,
259 int flag);
260 static int
261 mapping_adddriver(struct if_mapping * ifnode,
262 int * active,
263 char * pos,
264 size_t len,
265 struct add_extra * extra,
266 int linenum);
267 static int
268 mapping_cmpdriver(struct if_mapping * ifnode,
269 struct if_mapping * target);
270 static int
271 mapping_addbusinfo(struct if_mapping * ifnode,
272 int * active,
273 char * pos,
274 size_t len,
275 struct add_extra * extra,
276 int linenum);
277 static int
278 mapping_cmpbusinfo(struct if_mapping * ifnode,
279 struct if_mapping * target);
280 static int
281 mapping_addfirmware(struct if_mapping * ifnode,
282 int * active,
283 char * pos,
284 size_t len,
285 struct add_extra * extra,
286 int linenum);
287 static int
288 mapping_cmpfirmware(struct if_mapping * ifnode,
289 struct if_mapping * target);
290 static int
291 mapping_getdriverbusinfo(int skfd,
292 const char * ifname,
293 struct if_mapping * target,
294 int flag);
295 static int
296 mapping_addbaseaddr(struct if_mapping * ifnode,
297 int * active,
298 char * pos,
299 size_t len,
300 struct add_extra * extra,
301 int linenum);
302 static int
303 mapping_cmpbaseaddr(struct if_mapping * ifnode,
304 struct if_mapping * target);
305 static int
306 mapping_addirq(struct if_mapping * ifnode,
307 int * active,
308 char * pos,
309 size_t len,
310 struct add_extra * extra,
311 int linenum);
312 static int
313 mapping_cmpirq(struct if_mapping * ifnode,
314 struct if_mapping * target);
315 static int
316 mapping_getbaseaddrirq(int skfd,
317 const char * ifname,
318 struct if_mapping * target,
319 int flag);
320 static int
321 mapping_addiwproto(struct if_mapping * ifnode,
322 int * active,
323 char * pos,
324 size_t len,
325 struct add_extra * extra,
326 int linenum);
327 static int
328 mapping_cmpiwproto(struct if_mapping * ifnode,
329 struct if_mapping * target);
330 static int
331 mapping_getiwproto(int skfd,
332 const char * ifname,
333 struct if_mapping * target,
334 int flag);
335 static int
336 mapping_addpcmciaslot(struct if_mapping * ifnode,
337 int * active,
338 char * pos,
339 size_t len,
340 struct add_extra * extra,
341 int linenum);
342 static int
343 mapping_cmppcmciaslot(struct if_mapping * ifnode,
344 struct if_mapping * target);
345 static int
346 mapping_getpcmciaslot(int skfd,
347 const char * ifname,
348 struct if_mapping * target,
349 int flag);
350 static int
351 mapping_addsysfs(struct if_mapping * ifnode,
352 int * active,
353 char * pos,
354 size_t len,
355 struct add_extra * extra,
356 int linenum);
357 static int
358 mapping_cmpsysfs(struct if_mapping * ifnode,
359 struct if_mapping * target);
360 static int
361 mapping_getsysfs(int skfd,
362 const char * ifname,
363 struct if_mapping * target,
364 int flag);
365 static int
366 mapping_addprevname(struct if_mapping * ifnode,
367 int * active,
368 char * pos,
369 size_t len,
370 struct add_extra * extra,
371 int linenum);
372 static int
373 mapping_cmpprevname(struct if_mapping * ifnode,
374 struct if_mapping * target);
375 static int
376 mapping_getprevname(int skfd,
377 const char * ifname,
378 struct if_mapping * target,
379 int flag);
380
381 /**************************** VARIABLES ****************************/
382
383 /* List of mapping read for config file */
384 struct if_mapping * mapping_list = NULL;
385
386 /* List of selectors we can handle */
387 const struct mapping_selector selector_list[] =
388 {
389 /* MAC address and ARP/Link type from ifconfig */
390 { "mac", &mapping_addmac, &mapping_cmpmac, &mapping_getmac },
391 { "ethaddr", &mapping_addmac, &mapping_cmpmac, &mapping_getmac },
392 { "arp", &mapping_addarp, &mapping_cmparp, &mapping_getarp },
393 { "linktype", &mapping_addarp, &mapping_cmparp, &mapping_getarp },
394 /* Driver name, Bus-Info and firmware rev from ethtool -i */
395 { "driver", &mapping_adddriver, &mapping_cmpdriver,
396 &mapping_getdriverbusinfo },
397 { "businfo", &mapping_addbusinfo, &mapping_cmpbusinfo,
398 &mapping_getdriverbusinfo },
399 { "firmware", &mapping_addfirmware, &mapping_cmpfirmware,
400 &mapping_getdriverbusinfo },
401 /* Base Address and IRQ from ifconfig */
402 { "baseaddress", &mapping_addbaseaddr, &mapping_cmpbaseaddr,
403 &mapping_getbaseaddrirq },
404 { "irq", &mapping_addirq, &mapping_cmpirq, &mapping_getbaseaddrirq },
405 { "interrupt", &mapping_addirq, &mapping_cmpirq, &mapping_getbaseaddrirq },
406 /* Wireless Protocol from iwconfig */
407 { "iwproto", &mapping_addiwproto, &mapping_cmpiwproto, &mapping_getiwproto },
408 /* Pcmcia slot from cardmgr */
409 { "pcmciaslot", &mapping_addpcmciaslot, &mapping_cmppcmciaslot, &mapping_getpcmciaslot },
410 /* sysfs file (udev emulation) */
411 { "sysfs", &mapping_addsysfs, &mapping_cmpsysfs, &mapping_getsysfs },
412 /* previous interface name */
413 { "prevname", &mapping_addprevname, &mapping_cmpprevname, &mapping_getprevname },
414 /* The Terminator */
415 { NULL, NULL, NULL, NULL },
416 };
417 const int selector_num = sizeof(selector_list)/sizeof(selector_list[0]);
418
419 /* List of active selectors */
420 int selector_active[SELECT_NUM]; /* Selectors active */
421
422 /*
423 * All the following flags are controlled by the command line switches...
424 * It's a bit hackish to have them all as global, so maybe we should pass
425 * them in a big struct as function arguments... More complex and
426 * probably not worth it ?
427 */
428
429 /* Invocation type */
430 int print_newname = 0;
431 char * new_name = NULL;
432
433 /* Takeover support */
434 int force_takeover = 0; /* Takeover name from other interface */
435 int num_takeover = 0; /* Number of takeover done */
436
437 /* Dry-run support */
438 int dry_run = 0; /* Just print new name, don't rename */
439
440 /* Verbose support (i.e. debugging) */
441 int verbose = 0;
442
443 /* udev output support (print new DEVPATH) */
444 int udev_output = 0;
445
446 /* sysfs global data */
447 struct sysfs_metadata sysfs_global =
448 {
449 NULL, 0,
450 0, { NULL, NULL, NULL, NULL, NULL },
451 };
452
453 /******************** INTERFACE NAME MANAGEMENT ********************/
454 /*
455 * Bunch of low level function for managing interface names.
456 */
457
458 /*------------------------------------------------------------------*/
459 /*
460 * Compare two interface names, with wildcards.
461 * We can't use fnmatch() because we don't want expansion of '[...]'
462 * expressions, '\' sequences and matching of '.'.
463 * We only want to match a single '*' (converted to a %d at that point)
464 * to a numerical value (no ascii).
465 * Return 0 is matches.
466 */
467 static int
468 if_match_ifname(const char * pattern,
469 const char * value)
470 {
471 const char * p;
472 const char * v;
473 int n;
474 int ret;
475
476 /* Check for a wildcard */
477 p = strchr(pattern, '*');
478
479 /* No wildcard, simple comparison */
480 if(p == NULL)
481 return(strcmp(pattern, value));
482
483 /* Check is prefixes match */
484 n = (p - pattern);
485 ret = strncmp(pattern, value, n);
486 if(ret)
487 return(ret);
488
489 /* Check that value has some digits at this point */
490 v = value + n;
491 if(!isdigit(*v))
492 return(-1);
493
494 /* Skip digits to go to value suffix */
495 do
496 v++;
497 while(isdigit(*v));
498
499 /* Pattern suffix */
500 p += 1;
501
502 /* Compare suffixes */
503 return(strcmp(p, v));
504 }
505
506 /*------------------------------------------------------------------*/
507 /*
508 * Steal interface name from another interface. This enable interface
509 * name swapping.
510 * This will work :
511 * 1) with kernel 2.6.X
512 * 2) if other interface is down
513 * Because of (2), it won't work with hotplug, but we don't need it
514 * with hotplug, only with static ifaces...
515 */
516 static int
517 if_takeover_name(int skfd,
518 const char * victimname)
519 {
520 char autoname[IFNAMSIZ+1];
521 int len;
522 struct ifreq ifr;
523 int ret;
524
525 /* Compute name for victim interface */
526 len = strlen(victimname);
527 memcpy(autoname, victimname, len + 1);
528 if(len > (IFNAMSIZ - 2))
529 len = IFNAMSIZ - 2; /* Make sure we have at least two char */
530 len--; /* Convert to index */
531 while(isdigit(autoname[len]))
532 len--; /* Scrap all trailing digits */
533 strcpy(autoname + len + 1, "%d");
534
535 if(verbose)
536 fprintf(stderr, "Takeover : moving interface `%s' to `%s'.\n",
537 victimname, autoname);
538
539 /* Prepare request */
540 bzero(&ifr, sizeof(struct ifreq));
541 strncpy(ifr.ifr_name, victimname, IFNAMSIZ);
542 strncpy(ifr.ifr_newname, autoname, IFNAMSIZ);
543
544 /* Rename victim interface */
545 ret = ioctl(skfd, SIOCSIFNAME, &ifr);
546
547 if(!ret)
548 num_takeover++;
549
550 return(ret);
551 }
552
553 /*------------------------------------------------------------------*/
554 /*
555 * Ask the kernel to change the name of an interface.
556 * That's what we want to do. All the rest is to make sure we call this
557 * appropriately.
558 */
559 static int
560 if_set_name(int skfd,
561 const char * oldname,
562 const char * newname,
563 char * retname)
564 {
565 struct ifreq ifr;
566 char * star;
567 int ret;
568
569 /* The kernel doesn't check is the interface already has the correct
570 * name and may return an error, so check ourselves.
571 * In the case of wildcard, the result can be weird : if oldname='eth0'
572 * and newname='eth*', retname would be 'eth1'.
573 * So, if the oldname value matches the newname pattern, just return
574 * success. */
575 if(!if_match_ifname(newname, oldname))
576 {
577 if(verbose)
578 fprintf(stderr, "Setting : Interface `%s' already matches `%s'.\n",
579 oldname, newname);
580
581 strcpy(retname, oldname);
582 return(0);
583 }
584
585 /* Prepare request */
586 bzero(&ifr, sizeof(struct ifreq));
587 strncpy(ifr.ifr_name, oldname, IFNAMSIZ);
588 strncpy(ifr.ifr_newname, newname, IFNAMSIZ);
589
590 /* Check for wildcard interface name, such as 'eth*' or 'wlan*'...
591 * This require specific kernel support (2.6.2-rc1 and later).
592 * We externally use '*', but the kernel doesn't know about that,
593 * so convert it to something it knows about... */
594 star = strchr(newname, '*');
595 if(star != NULL)
596 {
597 int slen = star - newname;
598 /* Replace '*' with '%d' in the new buffer */
599 star = ifr.ifr_newname + slen;
600 /* Size was checked in process_rename() and mapping_create() */
601 memmove(star + 2, star + 1, IFNAMSIZ - slen - 2);
602 star[0] = '%';
603 star[1] = 'd';
604 }
605
606 /* Do it */
607 ret = ioctl(skfd, SIOCSIFNAME, &ifr);
608
609 /* Takeover support : grab interface name from another interface */
610 if(ret && (errno == EEXIST) && force_takeover)
611 {
612 /* Push things around */
613 ret = if_takeover_name(skfd, newname);
614 if(!ret)
615 /* Second try */
616 ret = ioctl(skfd, SIOCSIFNAME, &ifr);
617 }
618
619 if(!ret)
620 {
621 /* Get the real new name (in case newname is a wildcard) */
622 strcpy(retname, ifr.ifr_newname);
623
624 if(verbose)
625 fprintf(stderr, "Setting : Interface `%s' renamed to `%s'.\n",
626 oldname, retname);
627 }
628
629 return(ret);
630 }
631
632 /************************ SELECTOR HANDLING ************************/
633 /*
634 * Handle the various selector we support
635 */
636
637 /*------------------------------------------------------------------*/
638 /*
639 * Add a MAC address selector to a mapping
640 */
641 static int
642 mapping_addmac(struct if_mapping * ifnode,
643 int * active,
644 char * string,
645 size_t len,
646 struct add_extra * extra,
647 int linenum)
648 {
649 size_t n;
650
651 /* Avoid "Unused parameter" warning */
652 extra = extra;
653
654 /* Verify validity of string */
655 if(len >= sizeof(ifnode->mac_filter))
656 {
657 fprintf(stderr, "Error : MAC address too long at line %d\n", linenum);
658 return(-1);
659 }
660 n = strspn(string, "0123456789ABCDEFabcdef:*");
661 if(n < len)
662 {
663 fprintf(stderr, "Error: Invalid MAC address `%s' at line %d\n",
664 string, linenum);
665 return(-1);
666 }
667
668 /* Copy as filter in all cases */
669 memcpy(ifnode->mac_filter, string, len + 1);
670
671 /* Check the type of MAC address */
672 if (strchr(ifnode->mac_filter, '*') != NULL)
673 {
674 /* This is a wilcard. Usual format : "01:23:45:*"
675 * Unfortunately, we can't do proper parsing. */
676 ifnode->active[SELECT_MAC] = HAS_MAC_FILTER;
677 active[SELECT_MAC] = HAS_MAC_FILTER;
678 }
679 else
680 {
681 /* Not a wildcard : "01:23:45:67:89:AB" */
682 ifnode->mac_len = iw_mac_aton(ifnode->mac_filter,
683 ifnode->mac, MAX_MAC_LEN);
684 if(ifnode->mac_len == 0)
685 {
686 fprintf(stderr, "Error: Invalid MAC address `%s' at line %d\n",
687 ifnode->mac_filter, linenum);
688 return(-1);
689 }
690
691 /* Check that it's not NULL */
692 if((ifnode->mac_len == 6) && (!memcmp(&ifnode->mac, &zero_mac, 6)))
693 {
694 fprintf(stderr,
695 "Warning: MAC address is null at line %d, this is dangerous...\n",
696 linenum);
697 }
698
699 ifnode->active[SELECT_MAC] = HAS_MAC_EXACT;
700 if(active[SELECT_MAC] == 0)
701 active[SELECT_MAC] = HAS_MAC_EXACT;
702 }
703
704 if(verbose)
705 fprintf(stderr,
706 "Parsing : Added %s MAC address `%s' from line %d.\n",
707 ifnode->active[SELECT_MAC] == HAS_MAC_FILTER ? "filter" : "exact",
708 ifnode->mac_filter, linenum);
709
710 return(0);
711 }
712
713 /*------------------------------------------------------------------*/
714 /*
715 * Compare the mac address of two mappings
716 */
717 static int
718 mapping_cmpmac(struct if_mapping * ifnode,
719 struct if_mapping * target)
720 {
721 /* Check for wildcard matching */
722 if(ifnode->active[SELECT_MAC] == HAS_MAC_FILTER)
723 /* Do wildcard matching, case insensitive */
724 return(fnmatch(ifnode->mac_filter, target->mac_filter, FNM_CASEFOLD));
725 else
726 /* Exact matching, in hex */
727 return((ifnode->mac_len != target->mac_len) ||
728 memcmp(ifnode->mac, target->mac, ifnode->mac_len));
729 }
730
731 /*------------------------------------------------------------------*/
732 /*
733 * Extract the MAC address and Link Type of an interface
734 */
735 static int
736 mapping_getmac(int skfd,
737 const char * ifname,
738 struct if_mapping * target,
739 int flag)
740 {
741 struct ifreq ifr;
742 int ret;
743 int i;
744
745 /* Get MAC address */
746 bzero(&ifr, sizeof(struct ifreq));
747 strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
748 ret = ioctl(skfd, SIOCGIFHWADDR, &ifr);
749 if(ret < 0)
750 {
751 fprintf(stderr, "Error: Can't read MAC address on interface `%s' : %s\n",
752 ifname, strerror(errno));
753 return(-1);
754 }
755
756 /* Extract ARP type */
757 target->hw_type = ifr.ifr_hwaddr.sa_family;
758 /* Calculate address length */
759 target->mac_len = 6;
760 for(i = 0; i < weird_mac_len_num; i++)
761 if(weird_mac_len[i][0] == ifr.ifr_hwaddr.sa_family)
762 {
763 target->mac_len = weird_mac_len[i][1];
764 break;
765 }
766 /* Extract MAC address bytes */
767 memcpy(target->mac, ifr.ifr_hwaddr.sa_data, target->mac_len);
768
769 /* Check the type of comparison */
770 if((flag == HAS_MAC_FILTER) || verbose)
771 {
772 /* Convert to ASCII */
773 iw_mac_ntop(target->mac, target->mac_len,
774 target->mac_filter, sizeof(target->mac_filter));
775 }
776
777 target->active[SELECT_MAC] = flag;
778 target->active[SELECT_ARP] = 1;
779
780 if(verbose)
781 fprintf(stderr,
782 "Querying %s : Got MAC address `%s' and ARP/Link Type `%d'.\n",
783 ifname, target->mac_filter, target->hw_type);
784
785 return(0);
786 }
787
788 /*------------------------------------------------------------------*/
789 /*
790 * Add a ARP/Link type selector to a mapping
791 */
792 static int
793 mapping_addarp(struct if_mapping * ifnode,
794 int * active,
795 char * string,
796 size_t len,
797 struct add_extra * extra,
798 int linenum)
799 {
800 size_t n;
801 unsigned int type;
802
803 /* Avoid "Unused parameter" warning */
804 extra = extra;
805
806 /* Verify validity of string, convert to int */
807 n = strspn(string, "0123456789");
808 if((n < len) || (sscanf(string, "%d", &type) != 1))
809 {
810 fprintf(stderr, "Error: Invalid ARP/Link Type `%s' at line %d\n",
811 string, linenum);
812 return(-1);
813 }
814
815 ifnode->hw_type = (unsigned short) type;
816 ifnode->active[SELECT_ARP] = 1;
817 active[SELECT_ARP] = 1;
818
819 if(verbose)
820 fprintf(stderr, "Parsing : Added ARP/Link Type `%d' from line %d.\n",
821 ifnode->hw_type, linenum);
822
823 return(0);
824 }
825
826 /*------------------------------------------------------------------*/
827 /*
828 * Compare the ARP/Link type of two mappings
829 */
830 static int
831 mapping_cmparp(struct if_mapping * ifnode,
832 struct if_mapping * target)
833 {
834 return(!(ifnode->hw_type == target->hw_type));
835 }
836
837 /*------------------------------------------------------------------*/
838 /*
839 * Extract the ARP/Link type of an interface
840 */
841 static int
842 mapping_getarp(int skfd,
843 const char * ifname,
844 struct if_mapping * target,
845 int flag)
846 {
847 /* We may have already extracted the MAC address */
848 if(target->active[SELECT_MAC])
849 return(0);
850
851 /* Otherwise just do it */
852 return(mapping_getmac(skfd, ifname, target, flag));
853 }
854
855 /*------------------------------------------------------------------*/
856 /*
857 * Add a Driver name selector to a mapping
858 */
859 static int
860 mapping_adddriver(struct if_mapping * ifnode,
861 int * active,
862 char * string,
863 size_t len,
864 struct add_extra * extra,
865 int linenum)
866 {
867 /* Avoid "Unused parameter" warning */
868 extra = extra;
869
870 /* Plain string, minimal verification */
871 if(len >= sizeof(ifnode->driver))
872 {
873 fprintf(stderr, "Error: Driver name too long at line %d\n", linenum);
874 return(-1);
875 }
876
877 /* Copy */
878 memcpy(ifnode->driver, string, len + 1);
879
880 /* Activate */
881 ifnode->active[SELECT_DRIVER] = 1;
882 active[SELECT_DRIVER] = 1;
883
884 if(verbose)
885 fprintf(stderr,
886 "Parsing : Added Driver name `%s' from line %d.\n",
887 ifnode->driver, linenum);
888
889 return(0);
890 }
891
892 /*------------------------------------------------------------------*/
893 /*
894 * Compare the Driver name of two mappings
895 */
896 static int
897 mapping_cmpdriver(struct if_mapping * ifnode,
898 struct if_mapping * target)
899 {
900 /* Do wildcard matching, case insensitive */
901 return(fnmatch(ifnode->driver, target->driver, FNM_CASEFOLD));
902 }
903
904 /*------------------------------------------------------------------*/
905 /*
906 * Add a Bus-Info selector to a mapping
907 */
908 static int
909 mapping_addbusinfo(struct if_mapping * ifnode,
910 int * active,
911 char * string,
912 size_t len,
913 struct add_extra * extra,
914 int linenum)
915 {
916 #if 0
917 size_t n;
918 #endif
919
920 /* Avoid "Unused parameter" warning */
921 extra = extra;
922
923 /* Verify validity of string */
924 if(len >= sizeof(ifnode->bus_info))
925 {
926 fprintf(stderr, "Bus Info too long at line %d\n", linenum);
927 return(-1);
928 }
929 #if 0
930 /* Hum... This doesn's seem true for non-PCI bus-info */
931 n = strspn(string, "0123456789ABCDEFabcdef:.*");
932 if(n < len)
933 {
934 fprintf(stderr, "Error: Invalid Bus Info `%s' at line %d\n",
935 string, linenum);
936 return(-1);
937 }
938 #endif
939
940 /* Copy */
941 memcpy(ifnode->bus_info, string, len + 1);
942
943 /* Activate */
944 ifnode->active[SELECT_BUSINFO] = 1;
945 active[SELECT_BUSINFO] = 1;
946
947 if(verbose)
948 fprintf(stderr,
949 "Parsing : Added Bus Info `%s' from line %d.\n",
950 ifnode->bus_info, linenum);
951
952 return(0);
953 }
954
955 /*------------------------------------------------------------------*/
956 /*
957 * Compare the Bus-Info of two mappings
958 */
959 static int
960 mapping_cmpbusinfo(struct if_mapping * ifnode,
961 struct if_mapping * target)
962 {
963 /* Do wildcard matching, case insensitive */
964 return(fnmatch(ifnode->bus_info, target->bus_info, FNM_CASEFOLD));
965 }
966
967 /*------------------------------------------------------------------*/
968 /*
969 * Add a Firmare revision selector to a mapping
970 */
971 static int
972 mapping_addfirmware(struct if_mapping * ifnode,
973 int * active,
974 char * string,
975 size_t len,
976 struct add_extra * extra,
977 int linenum)
978 {
979 /* Avoid "Unused parameter" warning */
980 extra = extra;
981
982 /* Verify validity of string */
983 if(len >= sizeof(ifnode->fw_version))
984 {
985 fprintf(stderr, "Firmware revision too long at line %d\n", linenum);
986 return(-1);
987 }
988
989 /* Copy */
990 memcpy(ifnode->fw_version, string, len + 1);
991
992 /* Activate */
993 ifnode->active[SELECT_FIRMWARE] = 1;
994 active[SELECT_FIRMWARE] = 1;
995
996 if(verbose)
997 fprintf(stderr,
998 "Parsing : Added Firmware Revision `%s' from line %d.\n",
999 ifnode->fw_version, linenum);
1000
1001 return(0);
1002 }
1003
1004 /*------------------------------------------------------------------*/
1005 /*
1006 * Compare the Bus-Info of two mappings
1007 */
1008 static int
1009 mapping_cmpfirmware(struct if_mapping * ifnode,
1010 struct if_mapping * target)
1011 {
1012 /* Do wildcard matching, case insensitive */
1013 return(fnmatch(ifnode->fw_version, target->fw_version, FNM_CASEFOLD));
1014 }
1015
1016 /*------------------------------------------------------------------*/
1017 /*
1018 * Extract the Driver name and Bus-Info from a live interface
1019 */
1020 static int
1021 mapping_getdriverbusinfo(int skfd,
1022 const char * ifname,
1023 struct if_mapping * target,
1024 int flag)
1025 {
1026 struct ifreq ifr;
1027 struct ethtool_drvinfo drvinfo;
1028 int ret;
1029
1030 /* Avoid "Unused parameter" warning */
1031 flag = flag;
1032
1033 /* We may come here twice or more, so do the job only once */
1034 if(target->active[SELECT_DRIVER] || target->active[SELECT_BUSINFO]
1035 || target->active[SELECT_FIRMWARE])
1036 return(0);
1037
1038 /* Prepare request */
1039 bzero(&ifr, sizeof(struct ifreq));
1040 bzero(&drvinfo, sizeof(struct ethtool_drvinfo));
1041 strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
1042 drvinfo.cmd = ETHTOOL_GDRVINFO;
1043 ifr.ifr_data = (caddr_t) &drvinfo;
1044
1045 /* Do it */
1046 ret = ioctl(skfd, SIOCETHTOOL, &ifr);
1047 if(ret < 0)
1048 {
1049 /* Most drivers don't support that, keep quiet for now */
1050 if(verbose)
1051 fprintf(stderr,
1052 "Error: Can't read driver/bus-info on interface `%s' : %s\n",
1053 ifname, strerror(errno));
1054 return(-1);
1055 }
1056
1057 /* Copy over */
1058 strcpy(target->driver, drvinfo.driver);
1059 strcpy(target->bus_info, drvinfo.bus_info);
1060 strcpy(target->fw_version, drvinfo.fw_version);
1061
1062 /* Activate */
1063 target->active[SELECT_DRIVER] = 1;
1064 target->active[SELECT_BUSINFO] = 1;
1065 target->active[SELECT_FIRMWARE] = 1;
1066
1067 if(verbose)
1068 fprintf(stderr,
1069 "Querying %s : Got Driver name `%s', Bus Info `%s' and Firmware `%s'.\n",
1070 ifname, target->driver, target->bus_info, target->fw_version);
1071
1072 return(0);
1073 }
1074
1075 /*------------------------------------------------------------------*/
1076 /*
1077 * Add a Base Address selector to a mapping
1078 */
1079 static int
1080 mapping_addbaseaddr(struct if_mapping * ifnode,
1081 int * active,
1082 char * string,
1083 size_t len,
1084 struct add_extra * extra,
1085 int linenum)
1086 {
1087 size_t n;
1088 unsigned int address;
1089
1090 /* Avoid "Unused parameter" warning */
1091 extra = extra;
1092
1093 /* Verify validity of string */
1094 n = strspn(string, "0123456789ABCDEFabcdefx");
1095 if((n < len) || (sscanf(string, "0x%X", &address) != 1))
1096 {
1097 fprintf(stderr, "Error: Invalid Base Address `%s' at line %d\n",
1098 string, linenum);
1099 return(-1);
1100 }
1101
1102 /* Copy */
1103 ifnode->base_addr = (unsigned short) address;
1104
1105 /* Activate */
1106 ifnode->active[SELECT_BASEADDR] = 1;
1107 active[SELECT_BASEADDR] = 1;
1108
1109 if(verbose)
1110 fprintf(stderr,
1111 "Parsing : Added Base Address `0x%X' from line %d.\n",
1112 ifnode->base_addr, linenum);
1113
1114 return(0);
1115 }
1116
1117 /*------------------------------------------------------------------*/
1118 /*
1119 * Compare the Base Address of two mappings
1120 */
1121 static int
1122 mapping_cmpbaseaddr(struct if_mapping * ifnode,
1123 struct if_mapping * target)
1124 {
1125 /* Do wildcard matching, case insensitive */
1126 return(!(ifnode->base_addr == target->base_addr));
1127 }
1128
1129 /*------------------------------------------------------------------*/
1130 /*
1131 * Add a IRQ selector to a mapping
1132 */
1133 static int
1134 mapping_addirq(struct if_mapping * ifnode,
1135 int * active,
1136 char * string,
1137 size_t len,
1138 struct add_extra * extra,
1139 int linenum)
1140 {
1141 size_t n;
1142 unsigned int irq;
1143
1144 /* Avoid "Unused parameter" warning */
1145 extra = extra;
1146
1147 /* Verify validity of string */
1148 n = strspn(string, "0123456789");
1149 if((n < len) || (sscanf(string, "%d", &irq) != 1))
1150 {
1151 fprintf(stderr, "Error: Invalid Base Address `%s' at line %d\n",
1152 string, linenum);
1153 return(-1);
1154 }
1155
1156 /* Copy */
1157 ifnode->irq = (unsigned char) irq;
1158
1159 /* Activate */
1160 ifnode->active[SELECT_IRQ] = 1;
1161 active[SELECT_IRQ] = 1;
1162
1163 if(verbose)
1164 fprintf(stderr,
1165 "Parsing : Added IRQ `%d' from line %d.\n",
1166 ifnode->irq, linenum);
1167
1168 return(0);
1169 }
1170
1171 /*------------------------------------------------------------------*/
1172 /*
1173 * Compare the IRQ of two mappings
1174 */
1175 static int
1176 mapping_cmpirq(struct if_mapping * ifnode,
1177 struct if_mapping * target)
1178 {
1179 /* Do wildcard matching, case insensitive */
1180 return(!(ifnode->irq == target->irq));
1181 }
1182
1183 /*------------------------------------------------------------------*/
1184 /*
1185 * Extract the Driver name and Bus-Info from a live interface
1186 */
1187 static int
1188 mapping_getbaseaddrirq(int skfd,
1189 const char * ifname,
1190 struct if_mapping * target,
1191 int flag)
1192 {
1193 struct ifreq ifr;
1194 struct ifmap map; /* hardware setup */
1195 int ret;
1196
1197 /* Avoid "Unused parameter" warning */
1198 flag = flag;
1199
1200 /* We may come here twice, so do the job only once */
1201 if(target->active[SELECT_BASEADDR] || target->active[SELECT_IRQ])
1202 return(0);
1203
1204 /* Prepare request */
1205 bzero(&ifr, sizeof(struct ifreq));
1206 bzero(&map, sizeof(struct ifmap));
1207 strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
1208
1209 /* Do it */
1210 ret = ioctl(skfd, SIOCGIFMAP, &ifr);
1211 if(ret < 0)
1212 {
1213 /* Don't know if every interface has that, so keep quiet... */
1214 if(verbose)
1215 fprintf(stderr,
1216 "Error: Can't read base address/irq on interface `%s' : %s\n",
1217 ifname, strerror(errno));
1218 return(-1);
1219 }
1220
1221 /* Copy over, activate */
1222 if(ifr.ifr_map.base_addr >= 0x100)
1223 {
1224 target->base_addr = ifr.ifr_map.base_addr;
1225 target->active[SELECT_BASEADDR] = 1;
1226 }
1227 target->irq = ifr.ifr_map.irq;
1228 target->active[SELECT_IRQ] = 1;
1229
1230 if(verbose)
1231 fprintf(stderr,
1232 "Querying %s : Got Base Address `0x%X' and IRQ `%d'.\n",
1233 ifname, target->base_addr, target->irq);
1234
1235 return(0);
1236 }
1237
1238 /*------------------------------------------------------------------*/
1239 /*
1240 * Add a Wireless Protocol selector to a mapping
1241 */
1242 static int
1243 mapping_addiwproto(struct if_mapping * ifnode,
1244 int * active,
1245 char * string,
1246 size_t len,
1247 struct add_extra * extra,
1248 int linenum)
1249 {
1250 /* Avoid "Unused parameter" warning */
1251 extra = extra;
1252
1253 /* Verify validity of string */
1254 if(len >= sizeof(ifnode->iwproto))
1255 {
1256 fprintf(stderr, "Wireless Protocol too long at line %d\n", linenum);
1257 return(-1);
1258 }
1259
1260 /* Copy */
1261 memcpy(ifnode->iwproto, string, len + 1);
1262
1263 /* Activate */
1264 ifnode->active[SELECT_IWPROTO] = 1;
1265 active[SELECT_IWPROTO] = 1;
1266
1267 if(verbose)
1268 fprintf(stderr,
1269 "Parsing : Added Wireless Protocol `%s' from line %d.\n",
1270 ifnode->iwproto, linenum);
1271
1272 return(0);
1273 }
1274
1275 /*------------------------------------------------------------------*/
1276 /*
1277 * Compare the Wireless Protocol of two mappings
1278 */
1279 static int
1280 mapping_cmpiwproto(struct if_mapping * ifnode,
1281 struct if_mapping * target)
1282 {
1283 /* Do wildcard matching, case insensitive */
1284 return(fnmatch(ifnode->iwproto, target->iwproto, FNM_CASEFOLD));
1285 }
1286
1287 /*------------------------------------------------------------------*/
1288 /*
1289 * Extract the Wireless Protocol from a live interface
1290 */
1291 static int
1292 mapping_getiwproto(int skfd,
1293 const char * ifname,
1294 struct if_mapping * target,
1295 int flag)
1296 {
1297 struct iwreq wrq;
1298
1299 /* Avoid "Unused parameter" warning */
1300 flag = flag;
1301
1302 /* Get wireless name */
1303 if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
1304 /* Don't complain about it, Ethernet cards will never support this */
1305 return(-1);
1306
1307 strncpy(target->iwproto, wrq.u.name, IFNAMSIZ);
1308 target->iwproto[IFNAMSIZ] = '\0';
1309
1310 /* Activate */
1311 target->active[SELECT_IWPROTO] = 1;
1312
1313 if(verbose)
1314 fprintf(stderr,
1315 "Querying %s : Got Wireless Protocol `%s'.\n",
1316 ifname, target->iwproto);
1317
1318 return(0);
1319 }
1320
1321 /*------------------------------------------------------------------*/
1322 /*
1323 * Add a Pcmcia Slot selector to a mapping
1324 */
1325 static int
1326 mapping_addpcmciaslot(struct if_mapping * ifnode,
1327 int * active,
1328 char * string,
1329 size_t len,
1330 struct add_extra * extra,
1331 int linenum)
1332 {
1333 size_t n;
1334
1335 /* Avoid "Unused parameter" warning */
1336 extra = extra;
1337
1338 /* Verify validity of string, convert to int */
1339 n = strspn(string, "0123456789");
1340 if((n < len) || (sscanf(string, "%d", &ifnode->pcmcia_slot) != 1))
1341 {
1342 fprintf(stderr, "Error: Invalid Pcmcia Slot `%s' at line %d\n",
1343 string, linenum);
1344 return(-1);
1345 }
1346
1347 ifnode->active[SELECT_PCMCIASLOT] = 1;
1348 active[SELECT_PCMCIASLOT] = 1;
1349
1350 if(verbose)
1351 fprintf(stderr, "Parsing : Added Pcmcia Slot `%d' from line %d.\n",
1352 ifnode->pcmcia_slot, linenum);
1353
1354 return(0);
1355 }
1356
1357 /*------------------------------------------------------------------*/
1358 /*
1359 * Compare the Pcmcia Slot of two mappings
1360 */
1361 static int
1362 mapping_cmppcmciaslot(struct if_mapping * ifnode,
1363 struct if_mapping * target)
1364 {
1365 return(!(ifnode->pcmcia_slot == target->pcmcia_slot));
1366 }
1367
1368 /*------------------------------------------------------------------*/
1369 /*
1370 * Extract the Pcmcia Slot of an interface
1371 * Note that this works only for cards fully managed by cardmgr.
1372 * With the kernel pcmcia modules, 32 bits cards (CardBus) are not managed
1373 * by cardmgr, and therefore won't have a valid slot number. For those
1374 * cards, you should use Bus Info (when the driver exports it).
1375 * In the long term, 16 bits card as well will no longer be managed by
1376 * cardmgr. Currently, Bus Info for 16 bit cards don't have any information
1377 * enabling to locate their physical location on the system, but I hope that
1378 * this will change.
1379 * When that happen, we can drop this code...
1380 */
1381 static int
1382 mapping_getpcmciaslot(int skfd,
1383 const char * ifname,
1384 struct if_mapping * target,
1385 int flag)
1386 {
1387 FILE * stream;
1388 char * linebuf = NULL;
1389 size_t linelen = 0;
1390 int linenum = 0;
1391
1392 /* Avoid "Unused parameter" warning */
1393 skfd = skfd;
1394 flag = flag;
1395
1396 /* Open the stab file for reading */
1397 stream = fopen(PCMCIA_STAB1, "r");
1398 if(!stream)
1399 {
1400 /* Try again, alternate location */
1401 stream = fopen(PCMCIA_STAB2, "r");
1402 if(!stream)
1403 {
1404 fprintf(stderr, "Error: Can't open PCMCIA Stab file `%s' or `%s': %s\n",
1405 PCMCIA_STAB1, PCMCIA_STAB2, strerror(errno));
1406 return(-1);
1407 }
1408 }
1409
1410 /* Read each line of file
1411 * getline is a GNU extension :-( The buffer is recycled and increased
1412 * as needed by getline. */
1413 while(getline(&linebuf, &linelen, stream) > 0)
1414 {
1415 char * p;
1416 size_t n;
1417 size_t k;
1418 int pcmcia_slot;
1419 int i;
1420
1421 /* Keep track of line number */
1422 linenum++;
1423
1424 /* Get Pcmcia socket number */
1425 p = linebuf;
1426 while(isspace(*p))
1427 ++p;
1428 if(*p == '\0')
1429 continue; /* Line ended */
1430 n = strcspn(p, " \t\n");
1431 k = strspn(p, "0123456789");
1432 if((k < n) || (sscanf(p, "%d", &pcmcia_slot) != 1))
1433 /* Next line */
1434 continue;
1435
1436 /* Skip socket number */
1437 /* Skip socket number ; device class ; driver name ; instance */
1438 for(i = 0; i < 4; i++)
1439 {
1440 /* Skip item */
1441 p += n;
1442 /* Skip space */
1443 p += strspn(p, " \t\n");
1444 if(*p == '\0')
1445 break; /* Line ended */
1446 /* Next item size */
1447 n = strcspn(p, " \t\n");
1448 }
1449 if(*p == '\0')
1450 continue; /* Line ended */
1451
1452 /* Terminate dev name */
1453 p[n] = '\0';
1454
1455 /* Compare to interface name */
1456 if(!strcmp(p, ifname))
1457 {
1458 /* Save */
1459 target->pcmcia_slot = pcmcia_slot;
1460
1461 /* Activate */
1462 target->active[SELECT_PCMCIASLOT] = 1;
1463
1464 if(verbose)
1465 fprintf(stderr,
1466 "Querying %s : Got Pcmcia Slot `%d'.\n",
1467 ifname, target->pcmcia_slot);
1468 /* Exit loop, found it */
1469 break;
1470 }
1471
1472 /* Finished -> next line */
1473 }
1474
1475 /* Cleanup */
1476 free(linebuf);
1477 fclose(stream);
1478
1479 return(target->active[SELECT_PCMCIASLOT] ? 0 : -1);
1480 }
1481
1482 /*------------------------------------------------------------------*/
1483 /*
1484 * Add a sysfs selector to a mapping
1485 */
1486 static int
1487 mapping_addsysfs(struct if_mapping * ifnode,
1488 int * active,
1489 char * string,
1490 size_t len,
1491 struct add_extra * extra,
1492 int linenum)
1493 {
1494 int findex; /* filename index */
1495 char * sdup;
1496
1497 /* Check if we have a modifier */
1498 if((extra == NULL) || (extra->modif_pos == NULL))
1499 {
1500 fprintf(stderr, "Error: No SYSFS filename at line %d\n", linenum);
1501 return(-1);
1502 }
1503
1504 /* Search if the filename already exist */
1505 for(findex = 0; findex < sysfs_global.filenum; findex++)
1506 {
1507 if(!strcmp(extra->modif_pos, sysfs_global.filename[findex]))
1508 break;
1509 }
1510
1511 /* If filename does not exist, creates it */
1512 if(findex == sysfs_global.filenum)
1513 {
1514 if(findex == SYSFS_MAX_FILE)
1515 {
1516 fprintf(stderr, "Error: Too many SYSFS filenames at line %d\n", linenum);
1517 return(-1);
1518 }
1519 sdup = strndup(extra->modif_pos, extra->modif_len);
1520 if(sdup == NULL)
1521 {
1522 fprintf(stderr, "Error: Can't allocate SYSFS file\n");
1523 return(-1);
1524 }
1525 sysfs_global.filename[findex] = sdup;
1526 sysfs_global.filenum++;
1527 }
1528
1529 /* Store value */
1530 sdup = strndup(string, len);
1531 if(sdup == NULL)
1532 {
1533 fprintf(stderr, "Error: Can't allocate SYSFS value\n");
1534 return(-1);
1535 }
1536 ifnode->sysfs[findex] = sdup;
1537
1538 /* Activate */
1539 ifnode->active[SELECT_SYSFS] = 1;
1540 active[SELECT_SYSFS] = 1;
1541
1542 if(verbose)
1543 fprintf(stderr,
1544 "Parsing : Added SYSFS filename `%s' value `%s' from line %d.\n",
1545 sysfs_global.filename[findex], ifnode->sysfs[findex], linenum);
1546
1547 return(0);
1548 }
1549
1550 /*------------------------------------------------------------------*/
1551 /*
1552 * Compare all the sysfs values of two mappings
1553 */
1554 static int
1555 mapping_cmpsysfs(struct if_mapping * ifnode,
1556 struct if_mapping * target)
1557 {
1558 int findex; /* filename index */
1559 int match = 1;
1560
1561 /* Loop on all sysfs selector */
1562 for(findex = 0; findex < sysfs_global.filenum; findex++)
1563 {
1564 /* If the mapping defines this sysfs selector.. */
1565 if(ifnode->sysfs[findex] != NULL)
1566 /* And if the sysfs values don't match */
1567 if((target->sysfs[findex] == NULL) ||
1568 (fnmatch(ifnode->sysfs[findex], target->sysfs[findex],
1569 FNM_CASEFOLD)))
1570 /* Then the sysfs selector doesn't match */
1571 match = 0;
1572 }
1573
1574 return(!match);
1575 }
1576
1577 /*------------------------------------------------------------------*/
1578 /*
1579 * Extract all the sysfs values of an interface
1580 */
1581 static int
1582 mapping_getsysfs(int skfd,
1583 const char * ifname,
1584 struct if_mapping * target,
1585 int flag)
1586 {
1587 FILE * stream;
1588 char * fname;
1589 int fnsize;
1590 char * linebuf = NULL;
1591 size_t linelen = 0;
1592 char * sdup;
1593 int findex; /* filename index */
1594
1595 /* Avoid "Unused parameter" warning */
1596 skfd = skfd;
1597 flag = flag;
1598
1599 /* Check if we know the devpath of this device */
1600 if(target->sysfs_devpath == NULL)
1601 {
1602 /* Check if we know the root of the sysfs filesystem */
1603 if(sysfs_global.root == NULL)
1604 {
1605 /* Open the mount file for reading */
1606 stream = fopen("/proc/mounts", "r");
1607 if(!stream)
1608 {
1609 fprintf(stderr, "Error: Can't open /proc/mounts file: %s\n",
1610 strerror(errno));
1611 return(-1);
1612 }
1613
1614 /* Read each line of file
1615 * getline is a GNU extension :-( The buffer is recycled and
1616 * increased as needed by getline. */
1617 while(getline(&linebuf, &linelen, stream) > 0)
1618 {
1619 int i;
1620 char * p;
1621 size_t n;
1622 char * token[3];
1623 size_t toklen[3];
1624
1625 /* The format of /proc/mounts is similar to /etc/fstab (5).
1626 * The first argument is the device. For sysfs, there is no
1627 * associated device, so this argument is ignored.
1628 * The second argument is the mount point.
1629 * The third argument is the filesystem type.
1630 */
1631
1632 /* Extract the first 3 tokens */
1633 p = linebuf;
1634 for(i = 0; i < 3; i++)
1635 {
1636 while(isspace(*p))
1637 ++p;
1638 token[i] = p;
1639 n = strcspn(p, " \t\n");
1640 toklen[i] = n;
1641 p += n;
1642 }
1643 /* Get the filesystem which type is "sysfs" */
1644 if((n == 5) && (!strncasecmp(token[2], "sysfs", 5)))
1645 {
1646 /* Get its mount point */
1647 n = toklen[1];
1648 sdup = strndup(token[1], n);
1649 if((n == 0) || (sdup == NULL))
1650 {
1651 fprintf(stderr,
1652 "Error: Can't parse /proc/mounts file: %s\n",
1653 strerror(errno));
1654 return(-1);
1655 }
1656 /* Store it */
1657 sysfs_global.root = sdup;
1658 sysfs_global.rlen = n;
1659 break;
1660 }
1661 /* Finished -> next line */
1662 }
1663
1664 /* Cleanup */
1665 fclose(stream);
1666
1667 /* Check if we found it */
1668 if(sysfs_global.root == NULL)
1669 {
1670 fprintf(stderr,
1671 "Error: Can't find sysfs in /proc/mounts file\n");
1672 free(linebuf);
1673 return(-1);
1674 }
1675 }
1676
1677 /* Construct devpath for this interface.
1678 * Reserve enough space to replace name without realloc. */
1679 fnsize = (sysfs_global.rlen + 11 + IFNAMSIZ + 1);
1680 fname = malloc(fnsize);
1681 if(fname == NULL)
1682 {
1683 fprintf(stderr, "Error: Can't allocate SYSFS devpath\n");
1684 return(-1);
1685 }
1686 /* Not true devpath for 2.6.20+, but this syslink should work */
1687 target->sysfs_devplen = sprintf(fname, "%s/class/net/%s",
1688 sysfs_global.root, ifname);
1689 target->sysfs_devpath = fname;
1690 }
1691
1692 /* Loop on all sysfs selector */
1693 for(findex = 0; findex < sysfs_global.filenum; findex++)
1694 {
1695 char * p;
1696 ssize_t n;
1697
1698 /* Construct complete filename for the sysfs selector */
1699 fnsize = (target->sysfs_devplen + 1 +
1700 strlen(sysfs_global.filename[findex]) + 1);
1701 fname = malloc(fnsize);
1702 if(fname == NULL)
1703 {
1704 fprintf(stderr, "Error: Can't allocate SYSFS filename\n");
1705 free(linebuf);
1706 return(-1);
1707 }
1708 sprintf(fname, "%s/%s", target->sysfs_devpath,
1709 sysfs_global.filename[findex]);
1710
1711 /* Open the sysfs file for reading */
1712 stream = fopen(fname, "r");
1713 if(!stream)
1714 {
1715 /* Some sysfs attribute may no exist for some interface */
1716 if(verbose)
1717 fprintf(stderr, "Error: Can't open file `%s': %s\n", fname,
1718 strerror(errno));
1719 /* Next sysfs selector */
1720 continue;
1721 }
1722
1723 /* Read file. Only one line in file. */
1724 n = getline(&linebuf, &linelen, stream);
1725 fclose(stream);
1726 if(n <= 0)
1727 {
1728 /* Some attributes are just symlinks to another directory.
1729 * We can read the attributes in that other directory
1730 * just fine, but sometimes the symlink itself gives a lot
1731 * of information.
1732 * Examples : SYSFS{device} and SYSFS{device/driver}
1733 * In such cases, get the name of the directory pointed to...
1734 */
1735 /*
1736 * I must note that the API for readlink() is very bad,
1737 * which force us to have this ugly code. Yuck !
1738 */
1739 int allocsize = 128; /* 256 = Good start */
1740 int retry = 16;
1741 char * linkpath = NULL;
1742 int pathlen;
1743
1744 /* Try reading the link with increased buffer size */
1745 do
1746 {
1747 allocsize *= 2;
1748 linkpath = realloc(linkpath, allocsize);
1749 pathlen = readlink(fname, linkpath, allocsize);
1750 /* If we did not hit the buffer limit, success */
1751 if(pathlen < allocsize)
1752 break;
1753 }
1754 while(retry-- > 0);
1755
1756 /* Check for error, most likely ENOENT */
1757 if(pathlen > 0)
1758 /* We have a symlink ;-) Terminate the string. */
1759 linkpath[pathlen] = '\0';
1760 else
1761 {
1762 /* Error ! */
1763 free(linkpath);
1764
1765 /* A lot of information in the sysfs is implicit, given
1766 * by the position of a file in the tree. It is therefore
1767 * important to be able to read the various components
1768 * of a path. For this reason, we resolve '..' to the
1769 * real name of the parent directory... */
1770 /* We have at least 11 char, see above */
1771 if(!strcmp(fname + fnsize - 4, "/.."))
1772 //if(!strcmp(fname + strlen(fname) - 3, "/.."))
1773 {
1774 /* This procedure to get the realpath is not very
1775 * nice, but it's the "best practice". Hmm... */
1776 int cwd_fd = open(".", O_RDONLY);
1777 linkpath = NULL;
1778 if(cwd_fd > 0)
1779 {
1780 int ret = chdir(fname);
1781 if(ret == 0)
1782 /* Using getcwd with NULL is a GNU extension. Nice. */
1783 linkpath = getcwd(NULL, 0);
1784 /* This may fail, but it's not fatal */
1785 fchdir(cwd_fd);
1786 }
1787 /* Check if we suceeded */
1788 if(!linkpath)
1789 {
1790 free(linkpath);
1791 if(verbose)
1792 fprintf(stderr, "Error: Can't read parent directory `%s'\n", fname);
1793 /* Next sysfs selector */
1794 continue;
1795 }
1796 }
1797 else
1798 {
1799 /* Some sysfs attribute are void for some interface,
1800 * we may have a real directory, or we may have permission
1801 * issues... */
1802 if(verbose)
1803 fprintf(stderr, "Error: Can't read file `%s'\n", fname);
1804 /* Next sysfs selector */
1805 continue;
1806 }
1807 }
1808
1809 /* Here, we have a link name or a parent directory name */
1810
1811 /* Keep only the last component of path name, save it */
1812 p = basename(linkpath);
1813 sdup = strdup(p);
1814 free(linkpath);
1815 }
1816 else
1817 {
1818 /* This is a regular file (well, pseudo file) */
1819 /* Get content, remove trailing '/n', save it */
1820 p = linebuf;
1821 if(p[n - 1] == '\n')
1822 n--;
1823 sdup = strndup(p, n);
1824 }
1825 if(sdup == NULL)
1826 {
1827 fprintf(stderr, "Error: Can't allocate SYSFS value\n");
1828 free(linebuf);
1829 return(-1);
1830 }
1831 target->sysfs[findex] = sdup;
1832
1833 /* Activate */
1834 target->active[SELECT_SYSFS] = 1;
1835
1836 if(verbose)
1837 fprintf(stderr,
1838 "Querying %s : Got SYSFS filename `%s' value `%s'.\n",
1839 ifname, sysfs_global.filename[findex], target->sysfs[findex]);
1840
1841 /* Finished : Next sysfs selector */
1842 }
1843
1844 /* Cleanup */
1845 free(linebuf);
1846
1847 return(target->active[SELECT_SYSFS] ? 0 : -1);
1848 }
1849
1850 /*------------------------------------------------------------------*/
1851 /*
1852 * Add a Previous Interface Name selector to a mapping
1853 */
1854 static int
1855 mapping_addprevname(struct if_mapping * ifnode,
1856 int * active,
1857 char * string,
1858 size_t len,
1859 struct add_extra * extra,
1860 int linenum)
1861 {
1862 /* Avoid "Unused parameter" warning */
1863 extra = extra;
1864
1865 /* Verify validity of string */
1866 if(len >= sizeof(ifnode->prevname))
1867 {
1868 fprintf(stderr, "Old Interface Name too long at line %d\n", linenum);
1869 return(-1);
1870 }
1871
1872 /* Copy */
1873 memcpy(ifnode->prevname, string, len + 1);
1874
1875 /* Activate */
1876 ifnode->active[SELECT_PREVNAME] = 1;
1877 active[SELECT_PREVNAME] = 1;
1878
1879 if(verbose)
1880 fprintf(stderr,
1881 "Parsing : Added Old Interface Name `%s' from line %d.\n",
1882 ifnode->prevname, linenum);
1883
1884 return(0);
1885 }
1886
1887 /*------------------------------------------------------------------*/
1888 /*
1889 * Compare the Previous Interface Name of two mappings
1890 * Note : this one is special.
1891 */
1892 static int
1893 mapping_cmpprevname(struct if_mapping * ifnode,
1894 struct if_mapping * target)
1895 {
1896 /* Do wildcard matching, case insensitive */
1897 return(fnmatch(ifnode->prevname, target->ifname, FNM_CASEFOLD));
1898 }
1899
1900 /*------------------------------------------------------------------*/
1901 /*
1902 * Extract the Previous Interface Name from a live interface
1903 */
1904 static int
1905 mapping_getprevname(int skfd,
1906 const char * ifname,
1907 struct if_mapping * target,
1908 int flag)
1909 {
1910 /* Avoid "Unused parameter" warning */
1911 skfd = skfd; ifname = ifname; flag = flag;
1912
1913 /* Don't do anything, it's already in target->ifname ;-) */
1914
1915 /* Activate */
1916 target->active[SELECT_PREVNAME] = 1;
1917
1918 return(0);
1919 }
1920
1921
1922 /*********************** MAPPING MANAGEMENTS ***********************/
1923 /*
1924 * Manage interface mappings.
1925 * Each mapping tell us how to identify a specific interface name.
1926 * It is composed of a bunch of selector values.
1927 */
1928
1929 /*------------------------------------------------------------------*/
1930 /*
1931 * Create a new interface mapping and verify its name
1932 */
1933 static struct if_mapping *
1934 mapping_create(char * pos,
1935 int len,
1936 int linenum)
1937 {
1938 struct if_mapping * ifnode;
1939 char * star;
1940
1941 star = memchr(pos, '*', len);
1942
1943 /* Check overflow, need one extra char for wildcard */
1944 if((len + (star != NULL)) > IFNAMSIZ)
1945 {
1946 fprintf(stderr, "Error: Interface name `%.*s' too long at line %d\n",
1947 (int) len, pos, linenum);
1948 return(NULL);
1949 }
1950
1951 /* Create mapping, zero it */
1952 ifnode = calloc(1, sizeof(if_mapping));
1953 if(!ifnode)
1954 {
1955 fprintf(stderr, "Error: Can't allocate interface mapping.\n");
1956 return(NULL);
1957 }
1958
1959 /* Set the name, terminates it */
1960 memcpy(ifnode->ifname, pos, len);
1961 ifnode->ifname[len] = '\0';
1962
1963 /* Check the interface name and issue various pedantic warnings.
1964 * We assume people using takeover want to force interfaces to those
1965 * names and know what they are doing, so don't bother them... */
1966 if((!force_takeover) &&
1967 ((!strcmp(ifnode->ifname, "eth0")) || (!strcmp(ifnode->ifname, "wlan0"))))
1968 fprintf(stderr,
1969 "Warning: Interface name is `%s' at line %d, can't be mapped reliably.\n",
1970 ifnode->ifname, linenum);
1971 if(strchr(ifnode->ifname, ':'))
1972 fprintf(stderr, "Warning: Alias device `%s' at line %d probably can't be mapped.\n",
1973 ifnode->ifname, linenum);
1974
1975 if(verbose)
1976 fprintf(stderr, "Parsing : Added Mapping `%s' from line %d.\n",
1977 ifnode->ifname, linenum);
1978
1979 /* Done */
1980 return(ifnode);
1981 }
1982
1983 /*------------------------------------------------------------------*/
1984 /*
1985 * Find the most appropriate selector matching a given selector name
1986 */
1987 static inline const struct mapping_selector *
1988 selector_find(const char * string,
1989 size_t slen,
1990 int linenum)
1991 {
1992 const struct mapping_selector * found = NULL;
1993 int ambig = 0;
1994 int i;
1995
1996 /* Go through all selectors */
1997 for(i = 0; selector_list[i].name != NULL; ++i)
1998 {
1999 /* No match -> next one */
2000 if(strncasecmp(selector_list[i].name, string, slen) != 0)
2001 continue;
2002
2003 /* Exact match -> perfect */
2004 if(slen == strlen(selector_list[i].name))
2005 return &selector_list[i];
2006
2007 /* Partial match */
2008 if(found == NULL)
2009 /* First time */
2010 found = &selector_list[i];
2011 else
2012 /* Another time */
2013 if (selector_list[i].add_fn != found->add_fn)
2014 ambig = 1;
2015 }
2016
2017 if(found == NULL)
2018 {
2019 fprintf(stderr, "Error: Unknown selector `%.*s' at line %d.\n",
2020 (int) slen, string, linenum);
2021 return NULL;
2022 }
2023
2024 if(ambig)
2025 {
2026 fprintf(stderr, "Selector `%.*s'at line %d is ambiguous.\n",
2027 (int) slen, string, linenum);
2028 return NULL;
2029 }
2030
2031 return found;
2032 }
2033
2034 /*------------------------------------------------------------------*/
2035 /*
2036 * Read the configuration file and extract all valid mappings and their
2037 * selectors.
2038 */
2039 static int
2040 mapping_readfile(const char * filename)
2041 {
2042 FILE * stream;
2043 char * linebuf = NULL;
2044 size_t linelen = 0;
2045 int linenum = 0;
2046 struct add_extra extrainfo;
2047
2048 /* Reset the list of filters */
2049 bzero(selector_active, sizeof(selector_active));
2050
2051 /* Check filename */
2052 if(!strcmp(filename, "-"))
2053 {
2054 /* Read from stdin */
2055 stream = stdin;
2056
2057 }
2058 else
2059 {
2060 /* Open the file for reading */
2061 stream = fopen(filename, "r");
2062 if(!stream)
2063 {
2064 fprintf(stderr, "Error: Can't open configuration file `%s': %s\n",
2065 filename, strerror(errno));
2066 return(-1);
2067 }
2068 }
2069
2070 /* Read each line of file
2071 * getline is a GNU extension :-( The buffer is recycled and increased
2072 * as needed by getline. */
2073 while(getline(&linebuf, &linelen, stream) > 0)
2074 {
2075 struct if_mapping * ifnode;
2076 char * p;
2077 char * e;
2078 size_t n;
2079 int ret = -13; /* Complain if no selectors */
2080
2081 /* Keep track of line number */
2082 linenum++;
2083
2084 /* Every comments terminates parsing */
2085 if((p = strchr(linebuf,'#')) != NULL)
2086 *p = '\0';
2087
2088 /* Get interface name */
2089 p = linebuf;
2090 while(isspace(*p))
2091 ++p;
2092 if(*p == '\0')
2093 continue; /* Line ended */
2094 n = strcspn(p, " \t\n");
2095
2096 /* Create mapping */
2097 ifnode = mapping_create(p, n, linenum);
2098 if(!ifnode)
2099 continue; /* Ignore this line */
2100 p += n;
2101 p += strspn(p, " \t\n");
2102
2103 /* Loop on all selectors */
2104 while(*p != '\0')
2105 {
2106 const struct mapping_selector * selector = NULL;
2107 struct add_extra * extra = NULL;
2108
2109 /* Selector name length - stop at modifier start */
2110 n = strcspn(p, " \t\n{");
2111
2112 /* Find it */
2113 selector = selector_find(p, n, linenum);
2114 if(!selector)
2115 {
2116 ret = -1;
2117 break;
2118 }
2119 p += n;
2120
2121 /* Check for modifier */
2122 if(*p == '{')
2123 {
2124 p++;
2125 /* Find end of modifier */
2126 e = strchr(p, '}');
2127 if(e == NULL)
2128 {
2129 fprintf(stderr,
2130 "Error: unterminated selector modifier value on line %d\n",
2131 linenum);
2132 ret = -1;
2133 break; /* Line ended */
2134 }
2135 /* Fill in struct and hook it */
2136 extrainfo.modif_pos = p;
2137 extrainfo.modif_len = e - p;
2138 extra = &extrainfo;
2139 /* Terminate modifier value */
2140 e[0] = '\0';
2141 /* Skip it */
2142 p = e + 1;
2143 }
2144
2145 /* Get to selector value */
2146 p += strspn(p, " \t\n");
2147 if(*p == '\0')
2148 {
2149 fprintf(stderr, "Error: no value for selector `%s' on line %d\n",
2150 selector->name, linenum);
2151 ret = -1;
2152 break; /* Line ended */
2153 }
2154 /* Check for quoted arguments */
2155 if(*p == '"')
2156 {
2157 p++;
2158 e = strchr(p, '"');
2159 if(e == NULL)
2160 {
2161 fprintf(stderr,
2162 "Error: unterminated quoted value on line %d\n",
2163 linenum);
2164 ret = -1;
2165 break; /* Line ended */
2166 }
2167 n = e - p;
2168 e++;
2169 }
2170 else
2171 {
2172 /* Just end at next blank */
2173 n = strcspn(p, " \t\n");
2174 e = p + n;
2175 }
2176 /* Make 'e' point past the '\0' we are going to add */
2177 if(*e != '\0')
2178 e++;
2179 /* Terminate selector value */
2180 p[n] = '\0';
2181
2182 /* Add it to the mapping */
2183 ret = selector->add_fn(ifnode, selector_active, p, n,
2184 extra, linenum);
2185 if(ret < 0)
2186 break;
2187
2188 /* Go to next selector */
2189 p = e;
2190 p += strspn(p, " \t\n");
2191 }
2192
2193 /* We add a mapping only if it has at least one selector and if all
2194 * selectors were parsed properly. */
2195 if(ret < 0)
2196 {
2197 /* If we have not yet printed an error, now is a good time ;-) */
2198 if(ret == -13)
2199 fprintf(stderr, "Error: Line %d ignored, no valid selectors\n",
2200 linenum);
2201 else
2202 fprintf(stderr, "Error: Line %d ignored due to prior errors\n",
2203 linenum);
2204
2205 free(ifnode);
2206 }
2207 else
2208 {
2209 /* Link it in the list */
2210 ifnode->next = mapping_list;
2211 mapping_list = ifnode;
2212 }
2213 }
2214
2215 /* Cleanup */
2216 free(linebuf);
2217
2218 /* Finished reading, close the file */
2219 if(stream != stdin)
2220 fclose(stream);
2221 return(0);
2222 }
2223
2224 /*------------------------------------------------------------------*/
2225 /*
2226 * Extract all the interesting selectors for the interface in consideration
2227 */
2228 static struct if_mapping *
2229 mapping_extract(int skfd,
2230 const char * ifname)
2231 {
2232 struct if_mapping * target;
2233 int i;
2234
2235 /* Create mapping, zero it */
2236 target = calloc(1, sizeof(if_mapping));
2237 if(!target)
2238 {
2239 fprintf(stderr, "Error: Can't allocate interface mapping.\n");
2240 return(NULL);
2241 }
2242
2243 /* Set the interface name */
2244 strcpy(target->ifname, ifname);
2245
2246 /* Loop on all active selectors */
2247 for(i = 0; i < SELECT_NUM; i++)
2248 {
2249 /* Check if this selector is active */
2250 if(selector_active[i] != 0)
2251 {
2252 /* Extract selector */
2253 selector_list[i].get_fn(skfd, ifname, target, selector_active[i]);
2254
2255 /* Ignore errors. Some mapping may not need all selectors */
2256 }
2257 }
2258
2259 return(target);
2260 }
2261
2262 /*------------------------------------------------------------------*/
2263 /*
2264 * Find the first mapping in the list matching the one we want.
2265 */
2266 static struct if_mapping *
2267 mapping_find(struct if_mapping * target)
2268 {
2269 struct if_mapping * ifnode;
2270 int i;
2271
2272 /* Look over all our mappings */
2273 for(ifnode = mapping_list; ifnode != NULL; ifnode = ifnode->next)
2274 {
2275 int matches = 1;
2276
2277 /* Look over all our selectors, all must match */
2278 for(i = 0; i < SELECT_NUM; i++)
2279 {
2280 /* Check if this selector is active */
2281 if(ifnode->active[i] != 0)
2282 {
2283 /* If this selector doesn't match, game over for this mapping */
2284 if((target->active[i] == 0) ||
2285 (selector_list[i].cmp_fn(ifnode, target) != 0))
2286 {
2287 matches = 0;
2288 break;
2289 }
2290 }
2291 }
2292
2293 /* Check is this mapping was "the one" */
2294 if(matches)
2295 return(ifnode);
2296 }
2297
2298 /* Not found */
2299 return(NULL);
2300 }
2301
2302 /************************** MODULE SUPPORT **************************/
2303 /*
2304 * Load all necessary module so that interfaces do exist.
2305 * This is necessary for system that are fully modular when
2306 * doing the boot time processing, because we need to run before
2307 * 'ifup -a'.
2308 */
2309
2310 /*------------------------------------------------------------------*/
2311 /*
2312 * Probe interfaces based on our list of mappings.
2313 * This is the default, but usually not the best way to do it.
2314 */
2315 static void
2316 probe_mappings(int skfd)
2317 {
2318 struct if_mapping * ifnode;
2319 struct ifreq ifr;
2320
2321 /* Look over all our mappings */
2322 for(ifnode = mapping_list; ifnode != NULL; ifnode = ifnode->next)
2323 {
2324 /* Can't load wildcards interface name :-( */
2325 if(strchr(ifnode->ifname, '%') != NULL)
2326 continue;
2327
2328 if(verbose)
2329 fprintf(stderr, "Probing : Trying to load interface [%s]\n",
2330 ifnode->ifname);
2331
2332 /* Trick the kernel into loading the interface.
2333 * This allow us to not depend on the exact path and
2334 * name of the '/sbin/modprobe' command.
2335 * Obviously, we expect this command to 'fail', as
2336 * the interface will load with the old/wrong name.
2337 */
2338 strncpy(ifr.ifr_name, ifnode->ifname, IFNAMSIZ);
2339 ioctl(skfd, SIOCGIFHWADDR, &ifr);
2340 }
2341 }
2342
2343 /*------------------------------------------------------------------*/
2344 /*
2345 * Probe interfaces based on Debian's config files.
2346 * This allow to enly load modules for interfaces the user want active,
2347 * all built-in interfaces that should remain unconfigured won't
2348 * be probed (and can have mappings).
2349 */
2350 static void
2351 probe_debian(int skfd)
2352 {
2353 FILE * stream;
2354 char * linebuf = NULL;
2355 size_t linelen = 0;
2356 struct ifreq ifr;
2357
2358 /* Open Debian config file */
2359 stream = fopen(DEBIAN_CONFIG_FILE, "r");
2360 if(stream == NULL)
2361 {
2362 fprintf(stderr, "Error: can't open file [%s]\n", DEBIAN_CONFIG_FILE);
2363 return;
2364 }
2365
2366 /* Read each line of file
2367 * getline is a GNU extension :-( The buffer is recycled and increased
2368 * as needed by getline. */
2369 while(getline(&linebuf, &linelen, stream) > 0)
2370 {
2371 char * p;
2372 char * e;
2373 size_t n;
2374
2375 /* Check for auto keyword, ignore when commented out */
2376 if(!strncasecmp(linebuf, "auto ", 5))
2377 {
2378 /* Skip "auto" keyword */
2379 p = linebuf + 5;
2380
2381 /* Terminate at first comment */
2382 e = strchr(p, '#');
2383 if(e != NULL)
2384 *e = '\0';
2385
2386 /* Loop on all interfaces given */
2387 while(*p != '\0')
2388 {
2389 /* Interface name length */
2390 n = strcspn(p, " \t\n");
2391
2392 /* Look for end of interface name */
2393 e = p + n;
2394 /* Make 'e' point past the '\0' we are going to add */
2395 if(*e != '\0')
2396 e++;
2397 /* Terminate interface name */
2398 p[n] = '\0';
2399
2400 if(verbose)
2401 fprintf(stderr, "Probing : Trying to load interface [%s]\n",
2402 p);
2403
2404 /* Load interface */
2405 strncpy(ifr.ifr_name, p, IFNAMSIZ);
2406 ioctl(skfd, SIOCGIFHWADDR, &ifr);
2407
2408 /* Go to next interface name */
2409 p = e;
2410 p += strspn(p, " \t\n");
2411 }
2412 }
2413 }
2414
2415 /* Done */
2416 fclose(stream);
2417 return;
2418 }
2419
2420 /**************************** MAIN LOGIC ****************************/
2421
2422 /*------------------------------------------------------------------*/
2423 /*
2424 * Rename an interface to a specified new name.
2425 */
2426 static int
2427 process_rename(int skfd,
2428 char * ifname,
2429 char * newname)
2430 {
2431 char retname[IFNAMSIZ+1];
2432 int len;
2433 char * star;
2434
2435 len = strlen(newname);
2436 star = strchr(newname, '*');
2437
2438 /* Check newname length, need one extra char for wildcard */
2439 if((len + (star != NULL)) > IFNAMSIZ)
2440 {
2441 fprintf(stderr, "Error: Interface name `%s' too long.\n",
2442 newname);
2443 return(-1);
2444 }
2445
2446 /* Change the name of the interface */
2447 if(if_set_name(skfd, ifname, newname, retname) < 0)
2448 {
2449 fprintf(stderr, "Error: cannot change name of %s to %s: %s\n",
2450 ifname, newname, strerror(errno));
2451 return(-1);
2452 }
2453
2454 /* Always print out the *new* interface name so that
2455 * the calling script can pick it up and know where its interface
2456 * has gone. */
2457 printf("%s\n", retname);
2458
2459 /* Done */
2460 return(0);
2461 }
2462
2463 /*------------------------------------------------------------------*/
2464 /*
2465 * Process a specified interface.
2466 */
2467 static int
2468 process_ifname(int skfd,
2469 char * ifname,
2470 char * args[],
2471 int count)
2472 {
2473 struct if_mapping * target;
2474 const struct if_mapping * mapping;
2475 char retname[IFNAMSIZ+1];
2476
2477 /* Avoid "Unused parameter" warning */
2478 args = args; count = count;
2479
2480 /* Get description of this interface */
2481 target = mapping_extract(skfd, ifname);
2482 if(target == NULL)
2483 return(-1);
2484
2485 /* If udev is calling us, get the real devpath. */
2486 if(udev_output)
2487 {
2488 const char *env;
2489 /* It's passed to us as an environment variable */
2490 env = getenv("DEVPATH");
2491 if(env)
2492 {
2493 int env_len = strlen(env);
2494 target->sysfs_devplen = env_len;
2495 /* Make enough space for new interface name */
2496 target->sysfs_devpath = malloc(env_len + IFNAMSIZ + 1);
2497 if(target->sysfs_devpath != NULL)
2498 memcpy(target->sysfs_devpath, env, env_len + 1);
2499 }
2500 /* We will get a second chance is the user has some sysfs selectors */
2501 }
2502
2503 /* Find matching mapping */
2504 mapping = mapping_find(target);
2505 if(mapping == NULL)
2506 return(-1);
2507
2508 /* If user specified a new name, keep only interfaces that would
2509 * match the new name... */
2510 if((new_name != NULL) && (if_match_ifname(mapping->ifname, new_name) != 0))
2511 return(-1);
2512
2513 /* Check if user want only dry-run.
2514 * Note that, in the case of wildcard, we don't resolve the wildcard.
2515 * That would be tricky to do... */
2516 if(dry_run)
2517 {
2518 strcpy(retname, mapping->ifname);
2519 fprintf(stderr, "Dry-run : Would rename %s to %s.\n",
2520 target->ifname, mapping->ifname);
2521 }
2522 else
2523 {
2524 /* Change the name of the interface */
2525 if(if_set_name(skfd, target->ifname, mapping->ifname, retname) < 0)
2526 {
2527 fprintf(stderr, "Error: cannot change name of %s to %s: %s\n",
2528 target->ifname, mapping->ifname, strerror(errno));
2529 return(-1);
2530 }
2531 }
2532
2533 /* Check if called with an explicit interface name */
2534 if(print_newname)
2535 {
2536 if(!udev_output)
2537 /* Always print out the *new* interface name so that
2538 * the calling script can pick it up and know where its interface
2539 * has gone. */
2540 printf("%s\n", retname);
2541 else
2542 /* udev likes to call us as an IMPORT action. This means that
2543 * we need to return udev the environment variables changed.
2544 * Obviously, we don't want to return anything is nothing changed. */
2545 if(strcmp(target->ifname, retname))
2546 {
2547 char * pos;
2548 /* Hack */
2549 if(!target->sysfs_devpath)
2550 mapping_getsysfs(skfd, ifname, target, 0);
2551 /* Update devpath. Size is large enough. */
2552 pos = strrchr(target->sysfs_devpath, '/');
2553 if((pos != NULL) && (!strcmp(target->ifname, pos + 1)))
2554 strcpy(pos + 1, retname);
2555 /* Return new environment variables */
2556 printf("DEVPATH=%s\nINTERFACE=%s\nINTERFACE_OLD=%s\n",
2557 target->sysfs_devpath, retname, target->ifname);
2558 }
2559 }
2560
2561 /* Done */
2562 return(0);
2563 }
2564
2565 /*------------------------------------------------------------------*/
2566 /*
2567 * Process all network interface present on the system.
2568 */
2569 static inline int
2570 process_iflist(int skfd,
2571 char * args[],
2572 int count)
2573 {
2574 num_takeover = 0;
2575
2576 /* Just do it */
2577 iw_enum_devices(skfd, &process_ifname, args, count);
2578
2579 /* If we do any takeover, the interface list grabbed with
2580 * iw_enum_devices() may get out of sync with the real interfaces,
2581 * and we may miss the victim interface. So, let's go through the
2582 * list again.
2583 * On the other hand, we may have ping pong between two interfaces,
2584 * each claiming the same name, so let's not do it forever...
2585 * Two time should be enough for most configs...
2586 * Jean II */
2587 if(force_takeover && num_takeover)
2588 /* Play it again, Sam... */
2589 iw_enum_devices(skfd, &process_ifname, args, count);
2590
2591 /* Done */
2592 return(0);
2593 }
2594
2595 /******************************* MAIN *******************************/
2596
2597
2598 /*------------------------------------------------------------------*/
2599 /*
2600 */
2601 static void
2602 usage(void)
2603 {
2604 fprintf(stderr, "usage: ifrename [-c configurationfile] [-i ifname] [-p] [-t] [-d] [-D]\n");
2605 exit(1);
2606 }
2607
2608 /*------------------------------------------------------------------*/
2609 /*
2610 * The main !
2611 */
2612 int
2613 main(int argc,
2614 char * argv[])
2615 {
2616 const char * conf_file = DEFAULT_CONF;
2617 char * ifname = NULL;
2618 int use_probe = 0;
2619 int is_debian = 0;
2620 int skfd;
2621 int ret;
2622
2623 /* Loop over all command line options */
2624 while(1)
2625 {
2626 int c = getopt_long(argc, argv, "c:dDi:n:ptuvV", long_opt, NULL);
2627 if(c == -1)
2628 break;
2629
2630 switch(c)
2631 {
2632 default:
2633 case '?':
2634 usage();
2635 case 'c':
2636 conf_file = optarg;
2637 break;
2638 case 'd':
2639 is_debian = 1;
2640 break;
2641 case 'D':
2642 dry_run = 1;
2643 break;
2644 case 'i':
2645 ifname = optarg;
2646 break;
2647 case 'n':
2648 new_name = optarg;
2649 break;
2650 case 'p':
2651 use_probe = 1;
2652 break;
2653 case 't':
2654 force_takeover = 1;
2655 break;
2656 case 'u':
2657 udev_output = 1;
2658 break;
2659 case 'v':
2660 printf("%-8.16s Wireless-Tools version %d\n", "ifrename", WT_VERSION);
2661 return(0);
2662 case 'V':
2663 verbose = 1;
2664 break;
2665 }
2666 }
2667
2668 /* Read the specified/default config file, or stdin. */
2669 if(mapping_readfile(conf_file) < 0)
2670 return(-1);
2671
2672 /* Create a channel to the NET kernel. */
2673 if((skfd = iw_sockets_open()) < 0)
2674 {
2675 perror("socket");
2676 return(-1);
2677 }
2678
2679 /* Check if interface name was specified with -i. */
2680 if(ifname != NULL)
2681 {
2682 /* Check is target name specified */
2683 if(new_name != NULL)
2684 {
2685 /* User want to simply rename an interface to a specified name */
2686 ret = process_rename(skfd, ifname, new_name);
2687 }
2688 else
2689 {
2690 /* Rename only this interface based on mappings
2691 * Mostly used for HotPlug processing (from /etc/hotplug/net.agent)
2692 * or udev processing (from a udev IMPORT rule).
2693 * Process the network interface specified on the command line,
2694 * and return the new name on stdout.
2695 */
2696 print_newname = 1;
2697 ret = process_ifname(skfd, ifname, NULL, 0);
2698 }
2699 }
2700 else
2701 {
2702 /* Load all the necesary modules */
2703 if(use_probe)
2704 {
2705 if(is_debian)
2706 probe_debian(skfd);
2707 else
2708 probe_mappings(skfd);
2709 }
2710
2711 /* Rename all system interfaces
2712 * Mostly used for boot time processing (from init scripts).
2713 */
2714 ret = process_iflist(skfd, NULL, 0);
2715 }
2716
2717 /* Cleanup */
2718 iw_sockets_close(skfd);
2719 return(ret);
2720 }
+0
-313
src/lwe/iftab.5 less more
0 .\" Jean II - HPL - 2004-2007
1 .\" iftab.5
2 .\"
3 .TH IFTAB 5 "26 February 2007" "wireless-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iftab \- static information about the network interfaces
9 .\"
10 .\" DESCRIPTION part
11 .\"
12 .SH DESCRIPTION
13 The file
14 .B /etc/iftab
15 contains descriptive information about the various network interfaces.
16 .B iftab
17 is only used by the program
18 .IR ifrename (8)
19 to assign a consistent network interface name to each network interface.
20 .PP
21 .B /etc/iftab
22 defines a set of
23 .IR mappings .
24 Each mapping contains an interface name and a set of selectors. The
25 selectors allow
26 .B ifrename
27 to identify each network interface on the system. If a network
28 interface matches all descriptors of a mapping,
29 .B ifrename
30 attempt to change the name of the interface to the interface name
31 given by the mapping.
32 .\"
33 .\" MAPPINGS part
34 .\"
35 .SH MAPPINGS
36 Each mapping is described on a separate line, it starts with an
37 .IR "interface name" ,
38 and contains a set of
39 .IR descriptors ,
40 separated by space or tabs.
41 .PP
42 The relationship between descriptors of a mapping is a
43 .IR "logical and" .
44 A mapping matches a network interface only is all the descriptors
45 match. If a network interface doesn't support a specific descriptor,
46 it won't match any mappings using this descriptor.
47 .PP
48 If you want to use alternate descriptors for an interface name
49 (logical or), specify two different mappings with the same interface
50 name (one on each line).
51 .B Ifrename
52 always use the first matching mapping starting from the
53 .I end
54 of
55 .BR iftab ,
56 therefore more restrictive mapping should be specified last.
57 .\"
58 .\" INTERFACE NAME part
59 .\"
60 .SH INTERFACE NAME
61 The first part of each mapping is an interface name. If a network
62 interface matches all descriptors of a mapping,
63 .B ifrename
64 attempt to change the name of the interface to the interface name
65 given by the mapping.
66 .PP
67 The interface name of a mapping is either a plain interface name (such as
68 .IR eth2 " or " wlan1 )
69 or a interface name pattern containing a single wildcard (such as
70 .IR eth* " or " wlan* ).
71 In case of wildcard, the kernel replace the '*' with the lowest
72 available integer making this interface name unique. Note that
73 wildcard is only supported for kernel 2.6.1 and 2.4.30 and later.
74 .PP
75 It is discouraged to try to map interfaces to default interfaces names
76 such as
77 .IR eth0 ", " wlan0 " or " ppp0 .
78 The kernel use those as the default name for any new interface,
79 therefore most likely an interface will already use this name and
80 prevent ifrename to use it. Even if you use takeover, the interface
81 may already be up in some cases. Not using those name will allow you
82 to immediately spot unconfigured or new interfaces.
83 .br
84 Good names are either totally unique and meaningfull,
85 such as
86 .IR mydsl " or " privatehub ,
87 or use larger integer, such as
88 .IR eth5 " or " wlan5 .
89 The second type is usually easier to integrate in various network utilities.
90 .\"
91 .\" DESCRIPTORS part
92 .\"
93 .SH DESCRIPTORS
94 Each descriptor is composed of a descriptor name and descriptor
95 value. Descriptors specify a static attribute of a network interface,
96 the goal is to uniquely identify each piece of hardware.
97 .PP
98 Most users will only use the
99 .B mac
100 selector despite its potential problems, other selectors are for more
101 specialised setup. Most selectors accept a '*' in the selector value
102 for wilcard matching, and most selectors are case insensitive.
103 .TP
104 .BI mac " mac address"
105 Matches the MAC Address of the interface with the specified MAC
106 address. The MAC address of the interface can be shown using
107 .IR ifconfig (8)
108 or
109 .IR ip (8).
110 .br
111 This is the most common selector, as most interfaces have a unique MAC
112 address allowing to identify network interfaces without ambiguity.
113 However, some interfaces don't have a valid MAC address until they are
114 brought up, in such case using this selector is tricky or impossible.
115 .TP
116 .BI arp " arp type"
117 Matches the ARP Type (also called Link Type) of the interface with the
118 specified ARP type as a number. The ARP Type of the interface can be
119 shown using
120 .IR ifconfig (8)
121 or
122 .IR ip (8),
123 the
124 .B link/ether
125 type correspond to
126 .B 1
127 and the
128 .B link/ieee802.11
129 type correspond to
130 .BR 801 .
131 .br
132 This selector is useful when a driver create multiple network
133 interfaces for a single network card.
134 .TP
135 .BI driver " driver name"
136 Matches the Driver Name of the interface with the specified driver
137 name. The Driver Name of the interface can be shown using
138 .IR "ethtool -i" (8).
139 .TP
140 .BI businfo " bus information"
141 Matches the Bus Information of the interface with the specified bus
142 information. The Bus Information of the interface can be shown using
143 .IR "ethtool -i" (8).
144 .TP
145 .BI firmware " firmware revision"
146 Matches the Firmware Revision of the interface with the firmware
147 revision information. The Firmware Revision of the interface can be
148 shown using
149 .IR "ethtool -i" (8).
150 .TP
151 .BI baseaddress " base address"
152 Matches the Base Address of the interface with the specified base
153 address. The Base Address of the interface can be shown using
154 .IR ifconfig (8).
155 .br
156 Because most cards use dynamic allocation of the Base Address, this
157 selector is only useful for ISA and EISA cards.
158 .TP
159 .BI irq " irq line"
160 Matches the IRQ Line (interrupt) of the interface with the specified
161 IRQ line. The IRQ Line of the interface can be shown using
162 .IR ifconfig (8).
163 .br
164 Because there are IRQ Lines may be shared, this selector is usually
165 not sufficient to uniquely identify an interface.
166 .TP
167 .BI iwproto " wireless protocol"
168 Matches the Wireless Protocol of the interface with the specified
169 wireless protocol. The Wireless Protocol of the interface can be shown
170 using
171 .IR iwconfig (8)
172 or
173 .IR iwgetid (8).
174 .br
175 This selector is only supported on wireless interfaces and is not
176 sufficient to uniquely identify an interface.
177 .TP
178 .BI pcmciaslot " pcmcia slot"
179 Matches the Pcmcia Socket number of the interface with the specified
180 slot number. Pcmcia Socket number of the interface can be shown
181 using
182 .IR "cardctl ident" (8).
183 .br
184 This selector is usually only supported on 16 bits cards, for 32 bits
185 cards it is advised to use the selector
186 .BR businfo .
187 .TP
188 .BI prevname " previous interface name"
189 Matches the name of the interface prior to renaming with the specified
190 oldname.
191 .br
192 This selector should be avoided as the previous interface name may
193 vary depending on various condition. A system/kernel/driver update may
194 change the original name. Then, ifrename or another tool may rename it
195 prior to the execution of this selector.
196 .TP
197 .BI SYSFS{ filename } " value"
198 Matches the content the sysfs attribute given by filename to the
199 specified value. For symlinks and parents directories, match the
200 actual directory name of the sysfs attribute given by filename to the
201 specified value.
202 .br
203 A list of the most useful sysfs attributes is given in the next
204 section.
205 .\"
206 .\" SYSFS DESCRIPTORS part
207 .\"
208 .SH SYSFS DESCRIPTORS
209 Sysfs attributes for a specific interface are located on most systems
210 in the directory named after that interface at
211 .IR /sys/class/net/ .
212 Most sysfs attribute are files, and their values can be read using
213 .IR cat "(1) or " more (1).
214 It is also possible to match attributes in subdirectories.
215 .PP
216 Some sysfs attributes are symlinks, pointing to another directory in
217 sysfs. If the attribute filename is a symlink the sysfs attribute
218 resolves to the name of the directory pointed by the symlink using
219 .IR readlink (1).
220 The location is a directory in the sysfs tree is also important. If
221 the attribute filename ends with
222 .IR /.. ,
223 the sysfs attribute resolves to the real name of the parent directory
224 using
225 .IR pwd (1).
226 .PP
227 The sysfs filesystem is only supported with 2.6.X kernel and need to
228 be mounted (usually in
229 .IR /sys ).
230 sysfs selectors are not as efficient as other selectors, therefore
231 they should be avoided for maximum performance.
232 .PP
233 These are common sysfs attributes and their corresponding ifrename
234 descriptors.
235 .TP
236 .BI SYSFS{address} " value"
237 Same as the
238 .B mac
239 descriptor.
240 .TP
241 .BI SYSFS{type} " value"
242 Same as the
243 .B arp
244 descriptor.
245 .TP
246 .BI SYSFS{device} " value"
247 Valid only up to kernel 2.6.20. Same as the
248 .B businfo
249 descriptor.
250 .TP
251 .BI SYSFS{..} " value"
252 Valid only from kernel 2.6.21. Same as the
253 .B businfo
254 descriptor.
255 .TP
256 .BI SYSFS{device/driver} " value"
257 Valid only up to kernel 2.6.20. Same as the
258 .B driver
259 descriptor.
260 .TP
261 .BI SYSFS{../driver} " value"
262 Valid only from kernel 2.6.21. Same as the
263 .B driver
264 descriptor.
265 .TP
266 .BI SYSFS{device/irq} " value"
267 Valid only up to kernel 2.6.20. Same as the
268 .B irq
269 descriptor.
270 .TP
271 .BI SYSFS{../irq} " value"
272 Valid only from kernel 2.6.21. Same as the
273 .B irq
274 descriptor.
275 .\"
276 .\" EXAMPLES part
277 .\"
278 .SH EXAMPLES
279 # This is a comment
280 .br
281 eth2 mac 08:00:09:DE:82:0E
282 .br
283 eth3 driver wavelan interrupt 15 baseaddress 0x390
284 .br
285 eth4 driver pcnet32 businfo 0000:02:05.0
286 .br
287 air* mac 00:07:0E:* arp 1
288 .br
289 myvpn SYSFS{address} 00:10:83:* SYSFS{type} 1
290 .br
291 bcm* SYSFS{device} 0000:03:00.0 SYSFS{device/driver} bcm43xx
292 .br
293 bcm* SYSFS{..} 0000:03:00.0 SYSFS{../driver} bcm43xx
294 .\"
295 .\" AUTHOR part
296 .\"
297 .SH AUTHOR
298 Jean Tourrilhes \- [email protected]
299 .\"
300 .\" FILES part
301 .\"
302 .SH FILES
303 .I /etc/iftab
304 .\"
305 .\" SEE ALSO part
306 .\"
307 .SH SEE ALSO
308 .BR ifrename (8),
309 .BR ifconfig (8),
310 .BR ip (8),
311 .BR ethtool (8),
312 .BR iwconfig (8).
+0
-609
src/lwe/iwconfig.8 less more
0 .\" Jean II - HPLB - 1996 => HPL - 2004
1 .\" iwconfig.8
2 .\"
3 .TH IWCONFIG 8 "30 March 2006" "wireless-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iwconfig \- configure a wireless network interface
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .BI "iwconfig [" interface ]
14 .br
15 .BI "iwconfig " interface " [essid " X "] [nwid " N "] [mode " M "] [freq " F "]
16 .br
17 .BI " [channel " C ] [sens " S "] [ap " A "] [nick " NN ]
18 .br
19 .BI " [rate " R "] [rts " RT "] [frag " FT "] [txpower " T ]
20 .br
21 .BI " [enc " E "] [key " K "] [power " P "] [retry " R ]
22 .br
23 .BI " [modu " M "] [commit]
24 .br
25 .BI "iwconfig --help"
26 .br
27 .BI "iwconfig --version"
28 .\"
29 .\" DESCRIPTION part
30 .\"
31 .SH DESCRIPTION
32 .B Iwconfig
33 is similar to
34 .IR ifconfig (8),
35 but is dedicated to the wireless interfaces. It is used to set the
36 parameters of the network interface which are specific to the wireless
37 operation (for example : the frequency).
38 .B Iwconfig
39 may also be used to display those parameters, and the wireless
40 statistics (extracted from
41 .IR /proc/net/wireless ).
42 .PP
43 All these parameters and statistics are device dependent. Each driver
44 will provide only some of them depending on hardware support, and the
45 range of values may change. Please refer to the man page of each
46 device for details.
47 .\"
48 .\" PARAMETER part
49 .\"
50 .SH PARAMETERS
51 .TP
52 .B essid
53 Set the ESSID (or Network Name - in some products it may also be
54 called Domain ID). The ESSID is used to identify cells which are part
55 of the same virtual network.
56 .br
57 As opposed to the AP Address or NWID which define a single cell, the
58 ESSID defines a group of cells connected via repeaters or
59 infrastructure, where the user may roam transparently.
60 .br
61 With some cards, you may disable the ESSID checking (ESSID
62 promiscuous) with
63 .IR off " or " any " (and " on
64 to reenable it).
65 .br
66 If the ESSID of your network is one of the special keywords
67 .RI ( off ", " on " or " any ),
68 you should use
69 .I --
70 to escape it.
71 .br
72 .B Examples :
73 .br
74 .I " iwconfig eth0 essid any"
75 .br
76 .I " iwconfig eth0 essid ""My Network""
77 .br
78 .I " iwconfig eth0 essid -- ""ANY""
79 .TP
80 .BR nwid
81 Set the Network ID. As all adjacent wireless networks share the same
82 medium, this parameter is used to differentiate them (create logical
83 colocated networks) and identify nodes belonging to the same cell.
84 .br
85 This parameter is only used for pre-802.11 hardware, the 802.11
86 protocol uses the ESSID and AP Address for this function.
87 .br
88 With some cards, you may disable the Network ID checking (NWID
89 promiscuous) with
90 .IR off " (and " on
91 to reenable it).
92 .br
93 .B Examples :
94 .br
95 .I " iwconfig eth0 nwid AB34
96 .br
97 .I " iwconfig eth0 nwid off"
98 .TP
99 .BR nick [name]
100 Set the nickname, or the station name. Some 802.11 products do define
101 it, but this is not used as far as the protocols (MAC, IP, TCP) are
102 concerned and completely useless as far as configuration goes. Only
103 some wireless diagnostic tools may use it.
104 .br
105 .B Example :
106 .br
107 .I " iwconfig eth0 nickname ""My Linux Node""
108 .TP
109 .B mode
110 Set the operating mode of the device, which depends on the network
111 topology. The mode can be
112 .I Ad-Hoc
113 (network composed of only one cell and without Access Point),
114 .I Managed
115 (node connects to a network composed of many Access Points, with roaming),
116 .I Master
117 (the node is the synchronisation master or acts as an Access Point),
118 .I Repeater
119 (the node forwards packets between other wireless nodes),
120 .I Secondary
121 (the node acts as a backup master/repeater),
122 .I Monitor
123 (the node is not associated with any cell and passively monitor all
124 packets on the frequency) or
125 .IR Auto .
126 .br
127 .B Example :
128 .br
129 .I " iwconfig eth0 mode Managed"
130 .br
131 .I " iwconfig eth0 mode Ad-Hoc"
132 .TP
133 .BR freq / channel
134 Set the operating frequency or channel in the device. A value below
135 1000 indicates a channel number, a value greater than 1000 is a
136 frequency in Hz. You may append the suffix k, M or G to the value (for
137 example, "2.46G" for 2.46 GHz frequency), or add enough '0'.
138 .br
139 Channels are usually numbered starting at 1, and you may use
140 .IR iwlist (8)
141 to get the total number of channels, list the available frequencies,
142 and display the current frequency as a channel. Depending on
143 regulations, some frequencies/channels may not be available.
144 .br
145 When using Managed mode, most often the Access Point dictates the
146 channel and the driver may refuse the setting of the frequency. In
147 Ad-Hoc mode, the frequency setting may only be used at initial cell
148 creation, and may be ignored when joining an existing cell.
149 .br
150 You may also use
151 .I off
152 or
153 .I auto
154 to let the card pick up the best channel (when supported).
155 .br
156 .B Examples :
157 .br
158 .I " iwconfig eth0 freq 2422000000"
159 .br
160 .I " iwconfig eth0 freq 2.422G"
161 .br
162 .I " iwconfig eth0 channel 3"
163 .br
164 .I " iwconfig eth0 channel auto"
165 .TP
166 .B ap
167 Force the card to register to the Access Point given by the address,
168 if it is possible. This address is the cell identity of the Access
169 Point, as reported by wireless scanning, which may be different from
170 its network MAC address. If the wireless link is point to point, set
171 the address of the other end of the link. If the link is ad-hoc, set
172 the cell identity of the ad-hoc network.
173 .br
174 When the quality of the connection goes too low, the driver may revert
175 back to automatic mode (the card selects the best Access Point in
176 range).
177 .br
178 You may also use
179 .I off
180 to re-enable automatic mode without changing the current Access Point,
181 or you may use
182 .I any
183 or
184 .I auto
185 to force the card to reassociate with the currently best Access Point.
186 .br
187 .B Example :
188 .br
189 .I " iwconfig eth0 ap 00:60:1D:01:23:45"
190 .br
191 .I " iwconfig eth0 ap any"
192 .br
193 .I " iwconfig eth0 ap off"
194 .TP
195 .BR rate / bit [rate]
196 For cards supporting multiple bit rates, set the bit-rate in b/s. The
197 bit-rate is the speed at which bits are transmitted over the medium,
198 the user speed of the link is lower due to medium sharing and
199 various overhead.
200 .br
201 You may append the suffix k, M or G to the value (decimal multiplier :
202 10^3, 10^6 and 10^9 b/s), or add enough '0'. Values below 1000 are
203 card specific, usually an index in the bit-rate list. Use
204 .I auto
205 to select automatic bit-rate mode (fallback to lower rate on noisy
206 channels), which is the default for most cards, and
207 .I fixed
208 to revert back to fixed setting. If you specify a bit-rate value and append
209 .IR auto ,
210 the driver will use all bit-rates lower and equal than this value.
211 .br
212 .B Examples :
213 .br
214 .I " iwconfig eth0 rate 11M"
215 .br
216 .I " iwconfig eth0 rate auto"
217 .br
218 .I " iwconfig eth0 rate 5.5M auto"
219 .TP
220 .BR txpower
221 For cards supporting multiple transmit powers, sets the transmit power
222 in dBm. If
223 .I W
224 is the power in Watt, the power in dBm is
225 .IR "P = 30 + 10.log(W)" .
226 If the value is postfixed by
227 .IR mW ,
228 it will be automatically converted to dBm.
229 .br
230 In addition,
231 .IR on " and " off
232 enable and disable the radio, and
233 .IR auto " and " fixed
234 enable and disable power control (if those features are available).
235 .br
236 .B Examples :
237 .br
238 .I " iwconfig eth0 txpower 15"
239 .br
240 .I " iwconfig eth0 txpower 30mW"
241 .br
242 .I " iwconfig eth0 txpower auto"
243 .br
244 .I " iwconfig eth0 txpower off"
245 .TP
246 .B sens
247 Set the sensitivity threshold. This define how sensitive is the card
248 to poor operating conditions (low signal, interference). Positive
249 values are assumed to be the raw value used by the hardware or a
250 percentage, negative values are assumed to be dBm. Depending on the
251 hardware implementation, this parameter may control various functions.
252 .br
253 On modern cards, this parameter usually control handover/roaming
254 threshold, the lowest signal level for which the hardware remains
255 associated with the current Access Point. When the signal level goes
256 below this threshold the card starts looking for a new/better Access
257 Point. Some cards may use the number of missed beacons to trigger
258 this. For high density of Access Points, a higher threshold make sure
259 the card is always associated with the best AP, for low density of
260 APs, a lower threshold minimise the number of failed handoffs.
261 .br
262 On more ancient card this parameter usually controls the defer
263 threshold, the lowest signal level for which the hardware considers
264 the channel busy. Signal levels above this threshold make the hardware
265 inhibits its own transmission whereas signals weaker than this are
266 ignored and the hardware is free to transmit. This is usually strongly
267 linked to the receive threshold, the lowest signal level for which the
268 hardware attempts packet reception. Proper setting of these thresholds
269 prevent the card to waste time on background noise while still
270 receiving weak transmissions. Modern designs seems to control those
271 thresholds automatically.
272 .br
273 .br
274 .B Example :
275 .br
276 .I " iwconfig eth0 sens -80"
277 .br
278 .I " iwconfig eth0 sens 2"
279 .TP
280 .BR retry
281 Most cards have MAC retransmissions, and some allow to set the
282 behaviour of the retry mechanism.
283 .br
284 To set the maximum number of retries, enter
285 .IR "limit `value'" .
286 This is an absolute value (without unit), and the default (when
287 nothing is specified).
288 To set the maximum length of time the MAC should retry, enter
289 .IR "lifetime `value'" .
290 By defaults, this value in in seconds, append the suffix m or u to
291 specify values in milliseconds or microseconds.
292 .br
293 You can also add the
294 .IR short ", " long ", " min " and " max
295 modifiers. If the card supports automatic mode, they define the bounds
296 of the limit or lifetime. Some other cards define different values
297 depending on packet size, for example in 802.11
298 .I min limit
299 is the short retry limit (non RTS/CTS packets).
300 .br
301 .B Examples :
302 .br
303 .I " iwconfig eth0 retry 16"
304 .br
305 .I " iwconfig eth0 retry lifetime 300m"
306 .br
307 .I " iwconfig eth0 retry short 12"
308 .br
309 .I " iwconfig eth0 retry min limit 8"
310 .TP
311 .BR rts [_threshold]
312 RTS/CTS adds a handshake before each packet transmission to make sure
313 that the channel is clear. This adds overhead, but increases
314 performance in case of hidden nodes or a large number of active
315 nodes. This parameter sets the size of the smallest packet for which
316 the node sends RTS ; a value equal to the maximum packet size disables
317 the mechanism. You may also set this parameter to
318 .IR auto ", " fixed " or " off .
319 .br
320 .B Examples :
321 .br
322 .I " iwconfig eth0 rts 250"
323 .br
324 .I " iwconfig eth0 rts off"
325 .TP
326 .BR frag [mentation_threshold]
327 Fragmentation allows to split an IP packet in a burst of smaller
328 fragments transmitted on the medium. In most cases this adds overhead,
329 but in a very noisy environment this reduces the error penalty and
330 allow packets to get through interference bursts. This parameter sets
331 the maximum fragment size which is always lower than the maximum
332 packet size.
333 .br
334 This parameter may also control Frame Bursting available on some
335 cards, the ability to send multiple IP packets together. This
336 mechanism would be enabled if the fragment size is larger than the
337 maximum packet size.
338 .br
339 You may also set this parameter to
340 .IR auto ", " fixed " or " off .
341 .br
342 .B Examples :
343 .br
344 .I " iwconfig eth0 frag 512"
345 .br
346 .I " iwconfig eth0 frag off"
347 .TP
348 .BR key / enc [ryption]
349 Used to manipulate encryption or scrambling keys and security mode.
350 .br
351 To set the current encryption key, just enter the key in hex digits as
352 .IR XXXX-XXXX-XXXX-XXXX " or " XXXXXXXX .
353 To set a key other than the current key, prepend or append
354 .I [index]
355 to the key itself (this won't change which is the active key). You can
356 also enter the key as an ASCII string by using the
357 .I s:
358 prefix. Passphrase is currently not supported.
359 .br
360 To change which key is the currently active key, just enter
361 .I [index]
362 (without entering any key value).
363 .br
364 .IR off " and " on
365 disable and reenable encryption.
366 .br
367 The security mode may be
368 .I open
369 or
370 .IR restricted ,
371 and its meaning depends on the card used. With most cards, in
372 .I open
373 mode no authentication is used and the card may also accept
374 non-encrypted sessions, whereas in
375 .I restricted
376 mode only encrypted sessions are accepted and the card will use
377 authentication if available.
378 .br
379 If you need to set multiple keys, or set a key and change the active
380 key, you need to use multiple
381 .B key
382 directives. Arguments can be put in any order, the last one will take
383 precedence.
384 .br
385 .B Examples :
386 .br
387 .I " iwconfig eth0 key 0123-4567-89"
388 .br
389 .I " iwconfig eth0 key [3] 0123-4567-89"
390 .br
391 .I " iwconfig eth0 key s:password [2]"
392 .br
393 .I " iwconfig eth0 key [2]"
394 .br
395 .I " iwconfig eth0 key open"
396 .br
397 .I " iwconfig eth0 key off"
398 .br
399 .I " iwconfig eth0 key restricted [3] 0123456789"
400 .br
401 .I " iwconfig eth0 key 01-23 key 45-67 [4] key [4]"
402 .TP
403 .BR power
404 Used to manipulate power management scheme parameters and mode.
405 .br
406 To set the period between wake ups, enter
407 .IR "period `value'" .
408 To set the timeout before going back to sleep, enter
409 .IR "timeout `value'" .
410 To set the generic level of power saving, enter
411 .IR "saving `value'" .
412 You can also add the
413 .IR min " and " max
414 modifiers. By default, those values are in seconds, append the suffix
415 m or u to specify values in milliseconds or microseconds. Sometimes,
416 those values are without units (number of beacon periods, dwell,
417 percentage or similar).
418 .br
419 .IR off " and " on
420 disable and reenable power management. Finally, you may set the power
421 management mode to
422 .I all
423 (receive all packets),
424 .I unicast
425 (receive unicast packets only, discard multicast and broadcast) and
426 .I multicast
427 (receive multicast and broadcast only, discard unicast packets).
428 .br
429 .B Examples :
430 .br
431 .I " iwconfig eth0 power period 2"
432 .br
433 .I " iwconfig eth0 power 500m unicast"
434 .br
435 .I " iwconfig eth0 power timeout 300u all"
436 .br
437 .I " iwconfig eth0 power saving 3"
438 .br
439 .I " iwconfig eth0 power off"
440 .br
441 .I " iwconfig eth0 power min period 2 power max period 4"
442 .TP
443 .BR modu [lation]
444 Force the card to use a specific set of modulations. Modern cards
445 support various modulations, some which are standard, such as 802.11b
446 or 802.11g, and some proprietary. This command force the card to only
447 use the specific set of modulations listed on the command line. This
448 can be used to fix interoperability issues.
449 .br
450 The list of available modulations depend on the card/driver and can be
451 displayed using
452 .IR "iwlist modulation" .
453 Note that some card/driver may not be able to select each modulation
454 listed independantly, some may come as a group. You may also set this
455 parameter to
456 .IR auto
457 let the card/driver do its best.
458 .br
459 .B Examples :
460 .br
461 .I " iwconfig eth0 modu 11g"
462 .br
463 .I " iwconfig eth0 modu CCK OFDMa"
464 .br
465 .I " iwconfig eth0 modu auto"
466 .TP
467 .BR commit
468 Some cards may not apply changes done through Wireless Extensions
469 immediately (they may wait to aggregate the changes or apply it only
470 when the card is brought up via
471 .IR ifconfig ).
472 This command (when available) forces the card to apply all pending
473 changes.
474 .br
475 This is normally not needed, because the card will eventually apply
476 the changes, but can be useful for debugging.
477 .\"
478 .\" DISPLAY part
479 .\"
480 .SH DISPLAY
481 For each device which supports wireless extensions,
482 .I iwconfig
483 will display the name of the
484 .B MAC protocol
485 used (name of device for proprietary protocols), the
486 .B ESSID
487 (Network Name), the
488 .BR NWID ,
489 the
490 .B frequency
491 (or channel), the
492 .BR sensitivity ,
493 the
494 .B mode
495 of operation, the
496 .B Access Point
497 address, the
498 .BR bit-rate ,
499 the
500 .BR "RTS threshold" ", the " "fragmentation threshold" ,
501 the
502 .B encryption key
503 and the
504 .B power management
505 settings (depending on availability).
506 .PP
507 The parameters displayed have the same meaning and values as the
508 parameters you can set, please refer to the previous part for a
509 detailed explanation of them.
510 .br
511 Some parameters are only displayed in short/abbreviated form (such as
512 encryption). You may use
513 .IR iwlist (8)
514 to get all the details.
515 .br
516 Some parameters have two modes (such as bitrate). If the value is
517 prefixed by
518 .RB ` = ',
519 it means that the parameter is fixed and forced to that value, if it
520 is prefixed by
521 .RB ` : ',
522 the parameter is in automatic mode and the current value is shown (and
523 may change).
524 .TP
525 .BR "Access Point" / Cell
526 An address equal to 00:00:00:00:00:00 means that the card failed to
527 associate with an Access Point (most likely a configuration
528 issue). The
529 .B Access Point
530 parameter will be shown as
531 .B Cell
532 in ad-hoc mode (for obvious reasons), but otherwise works the same.
533 .PP
534 If
535 .I /proc/net/wireless
536 exists,
537 .I iwconfig
538 will also display its content. Note that those values will depend on
539 the driver and the hardware specifics, so you need to refer to your
540 driver documentation for proper interpretation of those values.
541 .TP
542 .B Link quality
543 Overall quality of the link. May be based on the level of contention
544 or interference, the bit or frame error rate, how good the received
545 signal is, some timing synchronisation, or other hardware metric. This
546 is an aggregate value, and depends totally on the driver and hardware.
547 .TP
548 .B Signal level
549 Received signal strength (RSSI - how strong the received signal
550 is). May be arbitrary units or dBm,
551 .I iwconfig
552 uses driver meta information to interpret the raw value given by
553 .I /proc/net/wireless
554 and display the proper unit or maximum value (using 8 bit arithmetic). In
555 .I Ad-Hoc
556 mode, this may be undefined and you should use
557 .IR iwspy .
558 .TP
559 .B Noise level
560 Background noise level (when no packet is transmitted). Similar
561 comments as for
562 .BR "Signal level" .
563 .TP
564 .B Rx invalid nwid
565 Number of packets received with a different NWID or ESSID. Used to
566 detect configuration problems or adjacent network existence (on the
567 same frequency).
568 .TP
569 .B Rx invalid crypt
570 Number of packets that the hardware was unable to decrypt. This can be
571 used to detect invalid encryption settings.
572 .TP
573 .B Rx invalid frag
574 Number of packets for which the hardware was not able to properly
575 re-assemble the link layer fragments (most likely one was missing).
576 .TP
577 .B Tx excessive retries
578 Number of packets that the hardware failed to deliver. Most MAC
579 protocols will retry the packet a number of times before giving up.
580 .TP
581 .B Invalid misc
582 Other packets lost in relation with specific wireless operations.
583 .TP
584 .B Missed beacon
585 Number of periodic beacons from the Cell or the Access Point we have
586 missed. Beacons are sent at regular intervals to maintain the cell
587 coordination, failure to receive them usually indicates that the card
588 is out of range.
589 .\"
590 .\" AUTHOR part
591 .\"
592 .SH AUTHOR
593 Jean Tourrilhes \- [email protected]
594 .\"
595 .\" FILES part
596 .\"
597 .SH FILES
598 .I /proc/net/wireless
599 .\"
600 .\" SEE ALSO part
601 .\"
602 .SH SEE ALSO
603 .BR ifconfig (8),
604 .BR iwspy (8),
605 .BR iwlist (8),
606 .BR iwevent (8),
607 .BR iwpriv (8),
608 .BR wireless (7).
+0
-1954
src/lwe/iwconfig.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPLB 97->99 - HPL 99->07
4 *
5 * Main code for "iwconfig". This is the generic tool for most
6 * manipulations...
7 * You need to link this code against "iwlib.c" and "-lm".
8 *
9 * This file is released under the GPL license.
10 * Copyright (c) 1997-2007 Jean Tourrilhes <[email protected]>
11 */
12
13 #include "iwlib.h" /* Header */
14
15 /**************************** CONSTANTS ****************************/
16
17 /*
18 * Error codes defined for setting args
19 */
20 #define IWERR_ARG_NUM -2
21 #define IWERR_ARG_TYPE -3
22 #define IWERR_ARG_SIZE -4
23 #define IWERR_ARG_CONFLICT -5
24 #define IWERR_SET_EXT -6
25 #define IWERR_GET_EXT -7
26
27 /**************************** VARIABLES ****************************/
28
29 /*
30 * Ugly, but deal with errors in set_info() efficiently...
31 */
32 static int errarg;
33 static int errmax;
34
35 /************************* DISPLAY ROUTINES **************************/
36
37 /*------------------------------------------------------------------*/
38 /*
39 * Get wireless informations & config from the device driver
40 * We will call all the classical wireless ioctl on the driver through
41 * the socket to know what is supported and to get the settings...
42 */
43 static int
44 get_info(int skfd,
45 char * ifname,
46 struct wireless_info * info)
47 {
48 struct iwreq wrq;
49
50 memset((char *) info, 0, sizeof(struct wireless_info));
51
52 /* Get basic information */
53 if(iw_get_basic_config(skfd, ifname, &(info->b)) < 0)
54 {
55 /* If no wireless name : no wireless extensions */
56 /* But let's check if the interface exists at all */
57 struct ifreq ifr;
58
59 strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
60 if(ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
61 return(-ENODEV);
62 else
63 return(-ENOTSUP);
64 }
65
66 /* Get ranges */
67 if(iw_get_range_info(skfd, ifname, &(info->range)) >= 0)
68 info->has_range = 1;
69
70 /* Get AP address */
71 if(iw_get_ext(skfd, ifname, SIOCGIWAP, &wrq) >= 0)
72 {
73 info->has_ap_addr = 1;
74 memcpy(&(info->ap_addr), &(wrq.u.ap_addr), sizeof (sockaddr));
75 }
76
77 /* Get bit rate */
78 if(iw_get_ext(skfd, ifname, SIOCGIWRATE, &wrq) >= 0)
79 {
80 info->has_bitrate = 1;
81 memcpy(&(info->bitrate), &(wrq.u.bitrate), sizeof(iwparam));
82 }
83
84 /* Get Power Management settings */
85 wrq.u.power.flags = 0;
86 if(iw_get_ext(skfd, ifname, SIOCGIWPOWER, &wrq) >= 0)
87 {
88 info->has_power = 1;
89 memcpy(&(info->power), &(wrq.u.power), sizeof(iwparam));
90 }
91
92 /* Get stats */
93 if(iw_get_stats(skfd, ifname, &(info->stats),
94 &info->range, info->has_range) >= 0)
95 {
96 info->has_stats = 1;
97 }
98
99 #ifndef WE_ESSENTIAL
100 /* Get NickName */
101 wrq.u.essid.pointer = (caddr_t) info->nickname;
102 wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
103 wrq.u.essid.flags = 0;
104 if(iw_get_ext(skfd, ifname, SIOCGIWNICKN, &wrq) >= 0)
105 if(wrq.u.data.length > 1)
106 info->has_nickname = 1;
107
108 if((info->has_range) && (info->range.we_version_compiled > 9))
109 {
110 /* Get Transmit Power */
111 if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
112 {
113 info->has_txpower = 1;
114 memcpy(&(info->txpower), &(wrq.u.txpower), sizeof(iwparam));
115 }
116 }
117
118 /* Get sensitivity */
119 if(iw_get_ext(skfd, ifname, SIOCGIWSENS, &wrq) >= 0)
120 {
121 info->has_sens = 1;
122 memcpy(&(info->sens), &(wrq.u.sens), sizeof(iwparam));
123 }
124
125 if((info->has_range) && (info->range.we_version_compiled > 10))
126 {
127 /* Get retry limit/lifetime */
128 if(iw_get_ext(skfd, ifname, SIOCGIWRETRY, &wrq) >= 0)
129 {
130 info->has_retry = 1;
131 memcpy(&(info->retry), &(wrq.u.retry), sizeof(iwparam));
132 }
133 }
134
135 /* Get RTS threshold */
136 if(iw_get_ext(skfd, ifname, SIOCGIWRTS, &wrq) >= 0)
137 {
138 info->has_rts = 1;
139 memcpy(&(info->rts), &(wrq.u.rts), sizeof(iwparam));
140 }
141
142 /* Get fragmentation threshold */
143 if(iw_get_ext(skfd, ifname, SIOCGIWFRAG, &wrq) >= 0)
144 {
145 info->has_frag = 1;
146 memcpy(&(info->frag), &(wrq.u.frag), sizeof(iwparam));
147 }
148 #endif /* WE_ESSENTIAL */
149
150 return(0);
151 }
152
153 /*------------------------------------------------------------------*/
154 /*
155 * Print on the screen in a neat fashion all the info we have collected
156 * on a device.
157 */
158 static void
159 display_info(struct wireless_info * info,
160 char * ifname)
161 {
162 char buffer[128]; /* Temporary buffer */
163
164 /* One token is more of less 5 characters, 14 tokens per line */
165 int tokens = 3; /* For name */
166
167 /* Display device name and wireless name (name of the protocol used) */
168 printf("%-8.16s %s ", ifname, info->b.name);
169
170 /* Display ESSID (extended network), if any */
171 if(info->b.has_essid)
172 {
173 if(info->b.essid_on)
174 {
175 /* Does it have an ESSID index ? */
176 if((info->b.essid_on & IW_ENCODE_INDEX) > 1)
177 printf("ESSID:\"%s\" [%d] ", info->b.essid,
178 (info->b.essid_on & IW_ENCODE_INDEX));
179 else
180 printf("ESSID:\"%s\" ", info->b.essid);
181 }
182 else
183 printf("ESSID:off/any ");
184 }
185
186 #ifndef WE_ESSENTIAL
187 /* Display NickName (station name), if any */
188 if(info->has_nickname)
189 printf("Nickname:\"%s\"", info->nickname);
190 #endif /* WE_ESSENTIAL */
191
192 /* Formatting */
193 if(info->b.has_essid || info->has_nickname)
194 {
195 printf("\n ");
196 tokens = 0;
197 }
198
199 #ifndef WE_ESSENTIAL
200 /* Display Network ID */
201 if(info->b.has_nwid)
202 {
203 /* Note : should display proper number of digits according to info
204 * in range structure */
205 if(info->b.nwid.disabled)
206 printf("NWID:off/any ");
207 else
208 printf("NWID:%X ", info->b.nwid.value);
209 tokens +=2;
210 }
211 #endif /* WE_ESSENTIAL */
212
213 /* Display the current mode of operation */
214 if(info->b.has_mode)
215 {
216 printf("Mode:%s ", iw_operation_mode[info->b.mode]);
217 tokens +=3;
218 }
219
220 /* Display frequency / channel */
221 if(info->b.has_freq)
222 {
223 double freq = info->b.freq; /* Frequency/channel */
224 int channel = -1; /* Converted to channel */
225 /* Some drivers insist of returning channel instead of frequency.
226 * This fixes them up. Note that, driver should still return
227 * frequency, because other tools depend on it. */
228 if(info->has_range && (freq < KILO))
229 channel = iw_channel_to_freq((int) freq, &freq, &info->range);
230 /* Display */
231 iw_print_freq(buffer, sizeof(buffer), freq, -1, info->b.freq_flags);
232 printf("%s ", buffer);
233 tokens +=4;
234 }
235
236 /* Display the address of the current Access Point */
237 if(info->has_ap_addr)
238 {
239 /* A bit of clever formatting */
240 if(tokens > 8)
241 {
242 printf("\n ");
243 tokens = 0;
244 }
245 tokens +=6;
246
247 /* Oups ! No Access Point in Ad-Hoc mode */
248 if((info->b.has_mode) && (info->b.mode == IW_MODE_ADHOC))
249 printf("Cell:");
250 else
251 printf("Access Point:");
252 printf(" %s ", iw_sawap_ntop(&info->ap_addr, buffer));
253 }
254
255 /* Display the currently used/set bit-rate */
256 if(info->has_bitrate)
257 {
258 /* A bit of clever formatting */
259 if(tokens > 11)
260 {
261 printf("\n ");
262 tokens = 0;
263 }
264 tokens +=3;
265
266 /* Display it */
267 iw_print_bitrate(buffer, sizeof(buffer), info->bitrate.value);
268 printf("Bit Rate%c%s ", (info->bitrate.fixed ? '=' : ':'), buffer);
269 }
270
271 #ifndef WE_ESSENTIAL
272 /* Display the Transmit Power */
273 if(info->has_txpower)
274 {
275 /* A bit of clever formatting */
276 if(tokens > 11)
277 {
278 printf("\n ");
279 tokens = 0;
280 }
281 tokens +=3;
282
283 /* Display it */
284 iw_print_txpower(buffer, sizeof(buffer), &info->txpower);
285 printf("Tx-Power%c%s ", (info->txpower.fixed ? '=' : ':'), buffer);
286 }
287
288 /* Display sensitivity */
289 if(info->has_sens)
290 {
291 /* A bit of clever formatting */
292 if(tokens > 10)
293 {
294 printf("\n ");
295 tokens = 0;
296 }
297 tokens +=4;
298
299 /* Fixed ? */
300 printf("Sensitivity%c", info->sens.fixed ? '=' : ':');
301
302 if(info->has_range)
303 /* Display in dBm ? */
304 if(info->sens.value < 0)
305 printf("%d dBm ", info->sens.value);
306 else
307 printf("%d/%d ", info->sens.value, info->range.sensitivity);
308 else
309 printf("%d ", info->sens.value);
310 }
311 #endif /* WE_ESSENTIAL */
312
313 printf("\n ");
314 tokens = 0;
315
316 #ifndef WE_ESSENTIAL
317 /* Display retry limit/lifetime information */
318 if(info->has_retry)
319 {
320 printf("Retry");
321 /* Disabled ? */
322 if(info->retry.disabled)
323 printf(":off");
324 else
325 {
326 /* Let's check the value and its type */
327 if(info->retry.flags & IW_RETRY_TYPE)
328 {
329 iw_print_retry_value(buffer, sizeof(buffer),
330 info->retry.value, info->retry.flags,
331 info->range.we_version_compiled);
332 printf("%s", buffer);
333 }
334
335 /* Let's check if nothing (simply on) */
336 if(info->retry.flags == IW_RETRY_ON)
337 printf(":on");
338 }
339 printf(" ");
340 tokens += 5; /* Between 3 and 5, depend on flags */
341 }
342
343 /* Display the RTS threshold */
344 if(info->has_rts)
345 {
346 /* Disabled ? */
347 if(info->rts.disabled)
348 printf("RTS thr:off ");
349 else
350 {
351 /* Fixed ? */
352 printf("RTS thr%c%d B ",
353 info->rts.fixed ? '=' : ':',
354 info->rts.value);
355 }
356 tokens += 3;
357 }
358
359 /* Display the fragmentation threshold */
360 if(info->has_frag)
361 {
362 /* A bit of clever formatting */
363 if(tokens > 10)
364 {
365 printf("\n ");
366 tokens = 0;
367 }
368 tokens +=4;
369
370 /* Disabled ? */
371 if(info->frag.disabled)
372 printf("Fragment thr:off");
373 else
374 {
375 /* Fixed ? */
376 printf("Fragment thr%c%d B ",
377 info->frag.fixed ? '=' : ':',
378 info->frag.value);
379 }
380 }
381
382 /* Formating */
383 if(tokens > 0)
384 printf("\n ");
385 #endif /* WE_ESSENTIAL */
386
387 /* Display encryption information */
388 /* Note : we display only the "current" key, use iwlist to list all keys */
389 if(info->b.has_key)
390 {
391 printf("Encryption key:");
392 if((info->b.key_flags & IW_ENCODE_DISABLED) || (info->b.key_size == 0))
393 printf("off");
394 else
395 {
396 /* Display the key */
397 iw_print_key(buffer, sizeof(buffer),
398 info->b.key, info->b.key_size, info->b.key_flags);
399 printf("%s", buffer);
400
401 /* Other info... */
402 if((info->b.key_flags & IW_ENCODE_INDEX) > 1)
403 printf(" [%d]", info->b.key_flags & IW_ENCODE_INDEX);
404 if(info->b.key_flags & IW_ENCODE_RESTRICTED)
405 printf(" Security mode:restricted");
406 if(info->b.key_flags & IW_ENCODE_OPEN)
407 printf(" Security mode:open");
408 }
409 printf("\n ");
410 }
411
412 /* Display Power Management information */
413 /* Note : we display only one parameter, period or timeout. If a device
414 * (such as HiperLan) has both, the user need to use iwlist... */
415 if(info->has_power) /* I hope the device has power ;-) */
416 {
417 printf("Power Management");
418 /* Disabled ? */
419 if(info->power.disabled)
420 printf(":off");
421 else
422 {
423 /* Let's check the value and its type */
424 if(info->power.flags & IW_POWER_TYPE)
425 {
426 iw_print_pm_value(buffer, sizeof(buffer),
427 info->power.value, info->power.flags,
428 info->range.we_version_compiled);
429 printf("%s ", buffer);
430 }
431
432 /* Let's check the mode */
433 iw_print_pm_mode(buffer, sizeof(buffer), info->power.flags);
434 printf("%s", buffer);
435
436 /* Let's check if nothing (simply on) */
437 if(info->power.flags == IW_POWER_ON)
438 printf(":on");
439 }
440 printf("\n ");
441 }
442
443 /* Display statistics */
444 if(info->has_stats)
445 {
446 iw_print_stats(buffer, sizeof(buffer),
447 &info->stats.qual, &info->range, info->has_range);
448 printf("Link %s\n", buffer);
449
450 if(info->range.we_version_compiled > 11)
451 printf(" Rx invalid nwid:%d Rx invalid crypt:%d Rx invalid frag:%d\n Tx excessive retries:%d Invalid misc:%d Missed beacon:%d\n",
452 info->stats.discard.nwid,
453 info->stats.discard.code,
454 info->stats.discard.fragment,
455 info->stats.discard.retries,
456 info->stats.discard.misc,
457 info->stats.miss.beacon);
458 else
459 printf(" Rx invalid nwid:%d invalid crypt:%d invalid misc:%d\n",
460 info->stats.discard.nwid,
461 info->stats.discard.code,
462 info->stats.discard.misc);
463 }
464
465 printf("\n");
466 }
467
468 /*------------------------------------------------------------------*/
469 /*
470 * Print on the screen in a neat fashion all the info we have collected
471 * on a device.
472 */
473 static int
474 print_info(int skfd,
475 char * ifname,
476 char * args[],
477 int count)
478 {
479 struct wireless_info info;
480 int rc;
481
482 /* Avoid "Unused parameter" warning */
483 args = args; count = count;
484
485 rc = get_info(skfd, ifname, &info);
486 switch(rc)
487 {
488 case 0: /* Success */
489 /* Display it ! */
490 display_info(&info, ifname);
491 break;
492
493 case -ENOTSUP:
494 fprintf(stderr, "%-8.16s no wireless extensions.\n\n",
495 ifname);
496 break;
497
498 default:
499 fprintf(stderr, "%-8.16s %s\n\n", ifname, strerror(-rc));
500 }
501 return(rc);
502 }
503
504 /****************** COMMAND LINE MODIFIERS PARSING ******************/
505 /*
506 * Factor out the parsing of command line modifiers.
507 */
508
509 /*------------------------------------------------------------------*/
510 /*
511 * Map command line modifiers to the proper flags...
512 */
513 typedef struct iwconfig_modifier {
514 const char * cmd; /* Command line shorthand */
515 __u16 flag; /* Flags to add */
516 __u16 exclude; /* Modifiers to exclude */
517 } iwconfig_modifier;
518
519 /*------------------------------------------------------------------*/
520 /*
521 * Modifiers for Power
522 */
523 static const struct iwconfig_modifier iwmod_power[] = {
524 { "min", IW_POWER_MIN, IW_POWER_MAX },
525 { "max", IW_POWER_MAX, IW_POWER_MIN },
526 { "period", IW_POWER_PERIOD, IW_POWER_TIMEOUT | IW_POWER_SAVING },
527 { "timeout", IW_POWER_TIMEOUT, IW_POWER_PERIOD | IW_POWER_SAVING },
528 { "saving", IW_POWER_SAVING, IW_POWER_TIMEOUT | IW_POWER_PERIOD },
529 };
530 #define IWMOD_POWER_NUM (sizeof(iwmod_power)/sizeof(iwmod_power[0]))
531
532 /*------------------------------------------------------------------*/
533 /*
534 * Modifiers for Retry
535 */
536 #ifndef WE_ESSENTIAL
537 static const struct iwconfig_modifier iwmod_retry[] = {
538 { "min", IW_RETRY_MIN, IW_RETRY_MAX },
539 { "max", IW_RETRY_MAX, IW_RETRY_MIN },
540 { "short", IW_RETRY_SHORT, IW_RETRY_LONG },
541 { "long", IW_RETRY_LONG, IW_RETRY_SHORT },
542 { "limit", IW_RETRY_LIMIT, IW_RETRY_LIFETIME },
543 { "lifetime", IW_RETRY_LIFETIME, IW_RETRY_LIMIT },
544 };
545 #define IWMOD_RETRY_NUM (sizeof(iwmod_retry)/sizeof(iwmod_retry[0]))
546 #endif /* WE_ESSENTIAL */
547
548 /*------------------------------------------------------------------*/
549 /*
550 * Parse command line modifiers.
551 * Return error or number arg parsed.
552 * Modifiers must be at the beggining of command line.
553 */
554 static int
555 parse_modifiers(char * args[], /* Command line args */
556 int count, /* Args count */
557 __u16 * pout, /* Flags to write */
558 const struct iwconfig_modifier modifier[],
559 int modnum)
560 {
561 int i = 0;
562 int k = 0;
563 __u16 result = 0; /* Default : no flag set */
564
565 /* Get all modifiers and value types on the command line */
566 do
567 {
568 for(k = 0; k < modnum; k++)
569 {
570 /* Check if matches */
571 if(!strcasecmp(args[i], modifier[k].cmd))
572 {
573 /* Check for conflicting flags */
574 if(result & modifier[k].exclude)
575 {
576 errarg = i;
577 return(IWERR_ARG_CONFLICT);
578 }
579 /* Just add it */
580 result |= modifier[k].flag;
581 ++i;
582 break;
583 }
584 }
585 }
586 /* For as long as current arg matched and not out of args */
587 while((i < count) && (k < modnum));
588
589 /* Check there remains one arg for value */
590 if(i >= count)
591 return(IWERR_ARG_NUM);
592
593 /* Return result */
594 *pout = result;
595 return(i);
596 }
597
598
599 /*********************** SETTING SUB-ROUTINES ***********************/
600 /*
601 * The following functions are use to set some wireless parameters and
602 * are called by the set dispatcher set_info().
603 * They take as arguments the remaining of the command line, with
604 * arguments processed already removed.
605 * An error is indicated by a negative return value.
606 * 0 and positive return values indicate the number of args consumed.
607 */
608
609 /*------------------------------------------------------------------*/
610 /*
611 * Set ESSID
612 */
613 static int
614 set_essid_info(int skfd,
615 char * ifname,
616 char * args[], /* Command line args */
617 int count) /* Args count */
618 {
619 struct iwreq wrq;
620 int i = 1;
621 char essid[IW_ESSID_MAX_SIZE + 1];
622 int we_kernel_version;
623
624 if((!strcasecmp(args[0], "off")) ||
625 (!strcasecmp(args[0], "any")))
626 {
627 wrq.u.essid.flags = 0;
628 essid[0] = '\0';
629 }
630 else
631 if(!strcasecmp(args[0], "on"))
632 {
633 /* Get old essid */
634 memset(essid, '\0', sizeof(essid));
635 wrq.u.essid.pointer = (caddr_t) essid;
636 wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
637 wrq.u.essid.flags = 0;
638 if(iw_get_ext(skfd, ifname, SIOCGIWESSID, &wrq) < 0)
639 return(IWERR_GET_EXT);
640 wrq.u.essid.flags = 1;
641 }
642 else
643 {
644 i = 0;
645
646 /* '-' or '--' allow to escape the ESSID string, allowing
647 * to set it to the string "any" or "off".
648 * This is a big ugly, but it will do for now */
649 if((!strcmp(args[0], "-")) || (!strcmp(args[0], "--")))
650 {
651 if(++i >= count)
652 return(IWERR_ARG_NUM);
653 }
654
655 /* Check the size of what the user passed us to avoid
656 * buffer overflows */
657 if(strlen(args[i]) > IW_ESSID_MAX_SIZE)
658 {
659 errmax = IW_ESSID_MAX_SIZE;
660 return(IWERR_ARG_SIZE);
661 }
662 else
663 {
664 int temp;
665
666 wrq.u.essid.flags = 1;
667 strcpy(essid, args[i]); /* Size checked, all clear */
668 i++;
669
670 /* Check for ESSID index */
671 if((i < count) &&
672 (sscanf(args[i], "[%i]", &temp) == 1) &&
673 (temp > 0) && (temp < IW_ENCODE_INDEX))
674 {
675 wrq.u.essid.flags = temp;
676 ++i;
677 }
678 }
679 }
680
681 /* Get version from kernel, device may not have range... */
682 we_kernel_version = iw_get_kernel_we_version();
683
684 /* Finally set the ESSID value */
685 wrq.u.essid.pointer = (caddr_t) essid;
686 wrq.u.essid.length = strlen(essid);
687 if(we_kernel_version < 21)
688 wrq.u.essid.length++;
689
690 if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0)
691 return(IWERR_SET_EXT);
692
693 /* Var args */
694 return(i);
695 }
696
697 /*------------------------------------------------------------------*/
698 /*
699 * Set Mode
700 */
701 static int
702 set_mode_info(int skfd,
703 char * ifname,
704 char * args[], /* Command line args */
705 int count) /* Args count */
706 {
707 struct iwreq wrq;
708 unsigned int k; /* Must be unsigned */
709
710 /* Avoid "Unused parameter" warning */
711 count = count;
712
713 /* Check if it is a uint, otherwise get is as a string */
714 if(sscanf(args[0], "%i", &k) != 1)
715 {
716 k = 0;
717 while((k < IW_NUM_OPER_MODE) &&
718 strncasecmp(args[0], iw_operation_mode[k], 3))
719 k++;
720 }
721 if(k >= IW_NUM_OPER_MODE)
722 {
723 errarg = 0;
724 return(IWERR_ARG_TYPE);
725 }
726
727 wrq.u.mode = k;
728 if(iw_set_ext(skfd, ifname, SIOCSIWMODE, &wrq) < 0)
729 return(IWERR_SET_EXT);
730
731 /* 1 arg */
732 return(1);
733 }
734
735 /*------------------------------------------------------------------*/
736 /*
737 * Set frequency/channel
738 */
739 static int
740 set_freq_info(int skfd,
741 char * ifname,
742 char * args[], /* Command line args */
743 int count) /* Args count */
744 {
745 struct iwreq wrq;
746 int i = 1;
747
748 if(!strcasecmp(args[0], "auto"))
749 {
750 wrq.u.freq.m = -1;
751 wrq.u.freq.e = 0;
752 wrq.u.freq.flags = 0;
753 }
754 else
755 {
756 if(!strcasecmp(args[0], "fixed"))
757 {
758 /* Get old frequency */
759 if(iw_get_ext(skfd, ifname, SIOCGIWFREQ, &wrq) < 0)
760 return(IWERR_GET_EXT);
761 wrq.u.freq.flags = IW_FREQ_FIXED;
762 }
763 else /* Should be a numeric value */
764 {
765 double freq;
766 char * unit;
767
768 freq = strtod(args[0], &unit);
769 if(unit == args[0])
770 {
771 errarg = 0;
772 return(IWERR_ARG_TYPE);
773 }
774 if(unit != NULL)
775 {
776 if(unit[0] == 'G') freq *= GIGA;
777 if(unit[0] == 'M') freq *= MEGA;
778 if(unit[0] == 'k') freq *= KILO;
779 }
780
781 iw_float2freq(freq, &(wrq.u.freq));
782
783 wrq.u.freq.flags = IW_FREQ_FIXED;
784
785 /* Check for an additional argument */
786 if((i < count) && (!strcasecmp(args[i], "auto")))
787 {
788 wrq.u.freq.flags = 0;
789 ++i;
790 }
791 if((i < count) && (!strcasecmp(args[i], "fixed")))
792 {
793 wrq.u.freq.flags = IW_FREQ_FIXED;
794 ++i;
795 }
796 }
797 }
798
799 if(iw_set_ext(skfd, ifname, SIOCSIWFREQ, &wrq) < 0)
800 return(IWERR_SET_EXT);
801
802 /* Var args */
803 return(i);
804 }
805
806 /*------------------------------------------------------------------*/
807 /*
808 * Set Bit Rate
809 */
810 static int
811 set_bitrate_info(int skfd,
812 char * ifname,
813 char * args[], /* Command line args */
814 int count) /* Args count */
815 {
816 struct iwreq wrq;
817 int i = 1;
818
819 wrq.u.bitrate.flags = 0;
820 if(!strcasecmp(args[0], "auto"))
821 {
822 wrq.u.bitrate.value = -1;
823 wrq.u.bitrate.fixed = 0;
824 }
825 else
826 {
827 if(!strcasecmp(args[0], "fixed"))
828 {
829 /* Get old bitrate */
830 if(iw_get_ext(skfd, ifname, SIOCGIWRATE, &wrq) < 0)
831 return(IWERR_GET_EXT);
832 wrq.u.bitrate.fixed = 1;
833 }
834 else /* Should be a numeric value */
835 {
836 double brate;
837 char * unit;
838
839 brate = strtod(args[0], &unit);
840 if(unit == args[0])
841 {
842 errarg = 0;
843 return(IWERR_ARG_TYPE);
844 }
845 if(unit != NULL)
846 {
847 if(unit[0] == 'G') brate *= GIGA;
848 if(unit[0] == 'M') brate *= MEGA;
849 if(unit[0] == 'k') brate *= KILO;
850 }
851 wrq.u.bitrate.value = (long) brate;
852 wrq.u.bitrate.fixed = 1;
853
854 /* Check for an additional argument */
855 if((i < count) && (!strcasecmp(args[i], "auto")))
856 {
857 wrq.u.bitrate.fixed = 0;
858 ++i;
859 }
860 if((i < count) && (!strcasecmp(args[i], "fixed")))
861 {
862 wrq.u.bitrate.fixed = 1;
863 ++i;
864 }
865 if((i < count) && (!strcasecmp(args[i], "unicast")))
866 {
867 wrq.u.bitrate.flags |= IW_BITRATE_UNICAST;
868 ++i;
869 }
870 if((i < count) && (!strcasecmp(args[i], "broadcast")))
871 {
872 wrq.u.bitrate.flags |= IW_BITRATE_BROADCAST;
873 ++i;
874 }
875 }
876 }
877
878 if(iw_set_ext(skfd, ifname, SIOCSIWRATE, &wrq) < 0)
879 return(IWERR_SET_EXT);
880
881 /* Var args */
882 return(i);
883 }
884
885 /*------------------------------------------------------------------*/
886 /*
887 * Set encryption
888 */
889 static int
890 set_enc_info(int skfd,
891 char * ifname,
892 char * args[], /* Command line args */
893 int count) /* Args count */
894 {
895 struct iwreq wrq;
896 int i = 1;
897 unsigned char key[IW_ENCODING_TOKEN_MAX];
898
899 if(!strcasecmp(args[0], "on"))
900 {
901 /* Get old encryption information */
902 wrq.u.data.pointer = (caddr_t) key;
903 wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
904 wrq.u.data.flags = 0;
905 if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0)
906 return(IWERR_GET_EXT);
907 wrq.u.data.flags &= ~IW_ENCODE_DISABLED; /* Enable */
908 }
909 else
910 {
911 int gotone = 0;
912 int oldone;
913 int keylen;
914 int temp;
915
916 wrq.u.data.pointer = (caddr_t) NULL;
917 wrq.u.data.flags = 0;
918 wrq.u.data.length = 0;
919 i = 0;
920
921 /* Allow arguments in any order (it's safe) */
922 do
923 {
924 oldone = gotone;
925
926 /* -- Check for the key -- */
927 if(i < count)
928 {
929 keylen = iw_in_key_full(skfd, ifname,
930 args[i], key, &wrq.u.data.flags);
931 if(keylen > 0)
932 {
933 wrq.u.data.length = keylen;
934 wrq.u.data.pointer = (caddr_t) key;
935 ++i;
936 gotone++;
937 }
938 }
939
940 /* -- Check for token index -- */
941 if((i < count) &&
942 (sscanf(args[i], "[%i]", &temp) == 1) &&
943 (temp > 0) && (temp < IW_ENCODE_INDEX))
944 {
945 wrq.u.encoding.flags |= temp;
946 ++i;
947 gotone++;
948 }
949
950 /* -- Check the various flags -- */
951 if((i < count) && (!strcasecmp(args[i], "off")))
952 {
953 wrq.u.data.flags |= IW_ENCODE_DISABLED;
954 ++i;
955 gotone++;
956 }
957 if((i < count) && (!strcasecmp(args[i], "open")))
958 {
959 wrq.u.data.flags |= IW_ENCODE_OPEN;
960 ++i;
961 gotone++;
962 }
963 if((i < count) && (!strncasecmp(args[i], "restricted", 5)))
964 {
965 wrq.u.data.flags |= IW_ENCODE_RESTRICTED;
966 ++i;
967 gotone++;
968 }
969 if((i < count) && (!strncasecmp(args[i], "temporary", 4)))
970 {
971 wrq.u.data.flags |= IW_ENCODE_TEMP;
972 ++i;
973 gotone++;
974 }
975 }
976 while(gotone != oldone);
977
978 /* Pointer is absent in new API */
979 if(wrq.u.data.pointer == NULL)
980 wrq.u.data.flags |= IW_ENCODE_NOKEY;
981
982 /* Check if we have any invalid argument */
983 if(!gotone)
984 {
985 errarg = 0;
986 return(IWERR_ARG_TYPE);
987 }
988 }
989
990 if(iw_set_ext(skfd, ifname, SIOCSIWENCODE, &wrq) < 0)
991 return(IWERR_SET_EXT);
992
993 /* Var arg */
994 return(i);
995 }
996
997 /*------------------------------------------------------------------*/
998 /*
999 * Set Power Management
1000 */
1001 static int
1002 set_power_info(int skfd,
1003 char * ifname,
1004 char * args[], /* Command line args */
1005 int count) /* Args count */
1006 {
1007 struct iwreq wrq;
1008 int i = 1;
1009
1010 if(!strcasecmp(args[0], "off"))
1011 wrq.u.power.disabled = 1; /* i.e. max size */
1012 else
1013 if(!strcasecmp(args[0], "on"))
1014 {
1015 /* Get old Power info */
1016 wrq.u.power.flags = 0;
1017 if(iw_get_ext(skfd, ifname, SIOCGIWPOWER, &wrq) < 0)
1018 return(IWERR_GET_EXT);
1019 wrq.u.power.disabled = 0;
1020 }
1021 else
1022 {
1023 double value;
1024 char * unit;
1025 int gotone = 0;
1026
1027 /* Parse modifiers */
1028 i = parse_modifiers(args, count, &wrq.u.power.flags,
1029 iwmod_power, IWMOD_POWER_NUM);
1030 if(i < 0)
1031 return(i);
1032
1033 wrq.u.power.disabled = 0;
1034
1035 /* Is there any value to grab ? */
1036 value = strtod(args[0], &unit);
1037 if(unit != args[0])
1038 {
1039 struct iw_range range;
1040 int flags;
1041 /* Extract range info to handle properly 'relative' */
1042 if(iw_get_range_info(skfd, ifname, &range) < 0)
1043 memset(&range, 0, sizeof(range));
1044
1045 /* Get the flags to be able to do the proper conversion */
1046 switch(wrq.u.power.flags & IW_POWER_TYPE)
1047 {
1048 case IW_POWER_SAVING:
1049 flags = range.pms_flags;
1050 break;
1051 case IW_POWER_TIMEOUT:
1052 flags = range.pmt_flags;
1053 break;
1054 default:
1055 flags = range.pmp_flags;
1056 break;
1057 }
1058 /* Check if time or relative */
1059 if(flags & IW_POWER_RELATIVE)
1060 {
1061 if(range.we_version_compiled < 21)
1062 value *= MEGA;
1063 else
1064 wrq.u.power.flags |= IW_POWER_RELATIVE;
1065 }
1066 else
1067 {
1068 value *= MEGA; /* default = s */
1069 if(unit[0] == 'u') value /= MEGA;
1070 if(unit[0] == 'm') value /= KILO;
1071 }
1072 wrq.u.power.value = (long) value;
1073 /* Set some default type if none */
1074 if((wrq.u.power.flags & IW_POWER_TYPE) == 0)
1075 wrq.u.power.flags |= IW_POWER_PERIOD;
1076 ++i;
1077 gotone = 1;
1078 }
1079
1080 /* Now, check the mode */
1081 if(i < count)
1082 {
1083 if(!strcasecmp(args[i], "all"))
1084 wrq.u.power.flags |= IW_POWER_ALL_R;
1085 if(!strncasecmp(args[i], "unicast", 4))
1086 wrq.u.power.flags |= IW_POWER_UNICAST_R;
1087 if(!strncasecmp(args[i], "multicast", 5))
1088 wrq.u.power.flags |= IW_POWER_MULTICAST_R;
1089 if(!strncasecmp(args[i], "force", 5))
1090 wrq.u.power.flags |= IW_POWER_FORCE_S;
1091 if(!strcasecmp(args[i], "repeat"))
1092 wrq.u.power.flags |= IW_POWER_REPEATER;
1093 if(wrq.u.power.flags & IW_POWER_MODE)
1094 {
1095 ++i;
1096 gotone = 1;
1097 }
1098 }
1099 if(!gotone)
1100 {
1101 errarg = i;
1102 return(IWERR_ARG_TYPE);
1103 }
1104 }
1105
1106 if(iw_set_ext(skfd, ifname, SIOCSIWPOWER, &wrq) < 0)
1107 return(IWERR_SET_EXT);
1108
1109 /* Var args */
1110 return(i);
1111 }
1112
1113 #ifndef WE_ESSENTIAL
1114 /*------------------------------------------------------------------*/
1115 /*
1116 * Set Nickname
1117 */
1118 static int
1119 set_nick_info(int skfd,
1120 char * ifname,
1121 char * args[], /* Command line args */
1122 int count) /* Args count */
1123 {
1124 struct iwreq wrq;
1125 int we_kernel_version;
1126
1127 /* Avoid "Unused parameter" warning */
1128 count = count;
1129
1130 if(strlen(args[0]) > IW_ESSID_MAX_SIZE)
1131 {
1132 errmax = IW_ESSID_MAX_SIZE;
1133 return(IWERR_ARG_SIZE);
1134 }
1135
1136 we_kernel_version = iw_get_kernel_we_version();
1137
1138 wrq.u.essid.pointer = (caddr_t) args[0];
1139 wrq.u.essid.length = strlen(args[0]);
1140 if(we_kernel_version < 21)
1141 wrq.u.essid.length++;
1142
1143 if(iw_set_ext(skfd, ifname, SIOCSIWNICKN, &wrq) < 0)
1144 return(IWERR_SET_EXT);
1145
1146 /* 1 args */
1147 return(1);
1148 }
1149
1150 /*------------------------------------------------------------------*/
1151 /*
1152 * Set commit
1153 */
1154 static int
1155 set_nwid_info(int skfd,
1156 char * ifname,
1157 char * args[], /* Command line args */
1158 int count) /* Args count */
1159 {
1160 struct iwreq wrq;
1161 unsigned long temp;
1162
1163 /* Avoid "Unused parameter" warning */
1164 count = count;
1165
1166 if((!strcasecmp(args[0], "off")) ||
1167 (!strcasecmp(args[0], "any")))
1168 wrq.u.nwid.disabled = 1;
1169 else
1170 if(!strcasecmp(args[0], "on"))
1171 {
1172 /* Get old nwid */
1173 if(iw_get_ext(skfd, ifname, SIOCGIWNWID, &wrq) < 0)
1174 return(IWERR_GET_EXT);
1175 wrq.u.nwid.disabled = 0;
1176 }
1177 else
1178 if(sscanf(args[0], "%lX", &(temp)) != 1)
1179 {
1180 errarg = 0;
1181 return(IWERR_ARG_TYPE);
1182 }
1183 else
1184 {
1185 wrq.u.nwid.value = temp;
1186 wrq.u.nwid.disabled = 0;
1187 }
1188
1189 wrq.u.nwid.fixed = 1;
1190
1191 /* Set new nwid */
1192 if(iw_set_ext(skfd, ifname, SIOCSIWNWID, &wrq) < 0)
1193 return(IWERR_SET_EXT);
1194
1195 /* 1 arg */
1196 return(1);
1197 }
1198
1199 /*------------------------------------------------------------------*/
1200 /*
1201 * Set AP Address
1202 */
1203 static int
1204 set_apaddr_info(int skfd,
1205 char * ifname,
1206 char * args[], /* Command line args */
1207 int count) /* Args count */
1208 {
1209 struct iwreq wrq;
1210
1211 /* Avoid "Unused parameter" warning */
1212 count = count;
1213
1214 if((!strcasecmp(args[0], "auto")) ||
1215 (!strcasecmp(args[0], "any")))
1216 {
1217 /* Send a broadcast address */
1218 iw_broad_ether(&(wrq.u.ap_addr));
1219 }
1220 else
1221 {
1222 if(!strcasecmp(args[0], "off"))
1223 {
1224 /* Send a NULL address */
1225 iw_null_ether(&(wrq.u.ap_addr));
1226 }
1227 else
1228 {
1229 /* Get the address and check if the interface supports it */
1230 if(iw_in_addr(skfd, ifname, args[0], &(wrq.u.ap_addr)) < 0)
1231 {
1232 errarg = 0;
1233 return(IWERR_ARG_TYPE);
1234 }
1235 }
1236 }
1237
1238 if(iw_set_ext(skfd, ifname, SIOCSIWAP, &wrq) < 0)
1239 return(IWERR_SET_EXT);
1240
1241 /* 1 args */
1242 return(1);
1243 }
1244
1245 /*------------------------------------------------------------------*/
1246 /*
1247 * Set Tx Power
1248 */
1249 static int
1250 set_txpower_info(int skfd,
1251 char * ifname,
1252 char * args[], /* Command line args */
1253 int count) /* Args count */
1254 {
1255 struct iwreq wrq;
1256 int i = 1;
1257
1258 /* Avoid "Unused parameter" warning */
1259 args = args; count = count;
1260
1261 /* Prepare the request */
1262 wrq.u.txpower.value = -1;
1263 wrq.u.txpower.fixed = 1;
1264 wrq.u.txpower.disabled = 0;
1265 wrq.u.txpower.flags = IW_TXPOW_DBM;
1266
1267 if(!strcasecmp(args[0], "off"))
1268 wrq.u.txpower.disabled = 1; /* i.e. turn radio off */
1269 else
1270 if(!strcasecmp(args[0], "auto"))
1271 wrq.u.txpower.fixed = 0; /* i.e. use power control */
1272 else
1273 {
1274 if(!strcasecmp(args[0], "on"))
1275 {
1276 /* Get old tx-power */
1277 if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) < 0)
1278 return(IWERR_GET_EXT);
1279 wrq.u.txpower.disabled = 0;
1280 }
1281 else
1282 {
1283 if(!strcasecmp(args[0], "fixed"))
1284 {
1285 /* Get old tx-power */
1286 if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) < 0)
1287 return(IWERR_GET_EXT);
1288 wrq.u.txpower.fixed = 1;
1289 wrq.u.txpower.disabled = 0;
1290 }
1291 else /* Should be a numeric value */
1292 {
1293 int power;
1294 int ismwatt = 0;
1295 struct iw_range range;
1296
1297 /* Extract range info to do proper conversion */
1298 if(iw_get_range_info(skfd, ifname, &range) < 0)
1299 memset(&range, 0, sizeof(range));
1300
1301 /* Get the value */
1302 if(sscanf(args[0], "%i", &(power)) != 1)
1303 {
1304 errarg = 0;
1305 return(IWERR_ARG_TYPE);
1306 }
1307
1308 /* Check if milliWatt
1309 * We authorise a single 'm' as a shorthand for 'mW',
1310 * on the other hand a 'd' probably means 'dBm'... */
1311 ismwatt = ((strchr(args[0], 'm') != NULL)
1312 && (strchr(args[0], 'd') == NULL));
1313
1314 /* We could check 'W' alone... Another time... */
1315
1316 /* Convert */
1317 if(range.txpower_capa & IW_TXPOW_RELATIVE)
1318 {
1319 /* Can't convert */
1320 if(ismwatt)
1321 {
1322 errarg = 0;
1323 return(IWERR_ARG_TYPE);
1324 }
1325 wrq.u.txpower.flags = IW_TXPOW_RELATIVE;
1326 }
1327 else
1328 if(range.txpower_capa & IW_TXPOW_MWATT)
1329 {
1330 if(!ismwatt)
1331 power = iw_dbm2mwatt(power);
1332 wrq.u.txpower.flags = IW_TXPOW_MWATT;
1333 }
1334 else
1335 {
1336 if(ismwatt)
1337 power = iw_mwatt2dbm(power);
1338 wrq.u.txpower.flags = IW_TXPOW_DBM;
1339 }
1340 wrq.u.txpower.value = power;
1341
1342 /* Check for an additional argument */
1343 if((i < count) && (!strcasecmp(args[i], "auto")))
1344 {
1345 wrq.u.txpower.fixed = 0;
1346 ++i;
1347 }
1348 if((i < count) && (!strcasecmp(args[i], "fixed")))
1349 {
1350 wrq.u.txpower.fixed = 1;
1351 ++i;
1352 }
1353 }
1354 }
1355 }
1356
1357 if(iw_set_ext(skfd, ifname, SIOCSIWTXPOW, &wrq) < 0)
1358 return(IWERR_SET_EXT);
1359
1360 /* Var args */
1361 return(i);
1362 }
1363
1364 /*------------------------------------------------------------------*/
1365 /*
1366 * Set Sensitivity
1367 */
1368 static int
1369 set_sens_info(int skfd,
1370 char * ifname,
1371 char * args[], /* Command line args */
1372 int count) /* Args count */
1373 {
1374 struct iwreq wrq;
1375 int temp;
1376
1377 /* Avoid "Unused parameter" warning */
1378 count = count;
1379
1380 if(sscanf(args[0], "%i", &(temp)) != 1)
1381 {
1382 errarg = 0;
1383 return(IWERR_ARG_TYPE);
1384 }
1385 wrq.u.sens.value = temp;
1386
1387 if(iw_set_ext(skfd, ifname, SIOCSIWSENS, &wrq) < 0)
1388 return(IWERR_SET_EXT);
1389
1390 /* 1 arg */
1391 return(1);
1392 }
1393
1394 /*------------------------------------------------------------------*/
1395 /*
1396 * Set Retry Limit
1397 */
1398 static int
1399 set_retry_info(int skfd,
1400 char * ifname,
1401 char * args[], /* Command line args */
1402 int count) /* Args count */
1403 {
1404 struct iwreq wrq;
1405 int i = 0;
1406 double value;
1407 char * unit;
1408
1409 /* Parse modifiers */
1410 i = parse_modifiers(args, count, &wrq.u.retry.flags,
1411 iwmod_retry, IWMOD_RETRY_NUM);
1412 if(i < 0)
1413 return(i);
1414
1415 /* Add default type if none */
1416 if((wrq.u.retry.flags & IW_RETRY_TYPE) == 0)
1417 wrq.u.retry.flags |= IW_RETRY_LIMIT;
1418
1419 wrq.u.retry.disabled = 0;
1420
1421 /* Is there any value to grab ? */
1422 value = strtod(args[0], &unit);
1423 if(unit == args[0])
1424 {
1425 errarg = i;
1426 return(IWERR_ARG_TYPE);
1427 }
1428
1429 /* Limit is absolute, on the other hand lifetime is seconds */
1430 if(wrq.u.retry.flags & IW_RETRY_LIFETIME)
1431 {
1432 struct iw_range range;
1433 /* Extract range info to handle properly 'relative' */
1434 if(iw_get_range_info(skfd, ifname, &range) < 0)
1435 memset(&range, 0, sizeof(range));
1436
1437 if(range.r_time_flags & IW_RETRY_RELATIVE)
1438 {
1439 if(range.we_version_compiled < 21)
1440 value *= MEGA;
1441 else
1442 wrq.u.retry.flags |= IW_RETRY_RELATIVE;
1443 }
1444 else
1445 {
1446 /* Normalise lifetime */
1447 value *= MEGA; /* default = s */
1448 if(unit[0] == 'u') value /= MEGA;
1449 if(unit[0] == 'm') value /= KILO;
1450 }
1451 }
1452 wrq.u.retry.value = (long) value;
1453 ++i;
1454
1455 if(iw_set_ext(skfd, ifname, SIOCSIWRETRY, &wrq) < 0)
1456 return(IWERR_SET_EXT);
1457
1458 /* Var args */
1459 return(i);
1460 }
1461
1462 /*------------------------------------------------------------------*/
1463 /*
1464 * Set RTS Threshold
1465 */
1466 static int
1467 set_rts_info(int skfd,
1468 char * ifname,
1469 char * args[], /* Command line args */
1470 int count) /* Args count */
1471 {
1472 struct iwreq wrq;
1473
1474 /* Avoid "Unused parameter" warning */
1475 count = count;
1476
1477 wrq.u.rts.value = -1;
1478 wrq.u.rts.fixed = 1;
1479 wrq.u.rts.disabled = 0;
1480
1481 if(!strcasecmp(args[0], "off"))
1482 wrq.u.rts.disabled = 1; /* i.e. max size */
1483 else
1484 if(!strcasecmp(args[0], "auto"))
1485 wrq.u.rts.fixed = 0;
1486 else
1487 {
1488 if(!strcasecmp(args[0], "fixed"))
1489 {
1490 /* Get old RTS threshold */
1491 if(iw_get_ext(skfd, ifname, SIOCGIWRTS, &wrq) < 0)
1492 return(IWERR_GET_EXT);
1493 wrq.u.rts.fixed = 1;
1494 }
1495 else
1496 { /* Should be a numeric value */
1497 long temp;
1498 if(sscanf(args[0], "%li", (unsigned long *) &(temp)) != 1)
1499 {
1500 errarg = 0;
1501 return(IWERR_ARG_TYPE);
1502 }
1503 wrq.u.rts.value = temp;
1504 }
1505 }
1506
1507 if(iw_set_ext(skfd, ifname, SIOCSIWRTS, &wrq) < 0)
1508 return(IWERR_SET_EXT);
1509
1510 /* 1 arg */
1511 return(1);
1512 }
1513
1514 /*------------------------------------------------------------------*/
1515 /*
1516 * Set Fragmentation Threshold
1517 */
1518 static int
1519 set_frag_info(int skfd,
1520 char * ifname,
1521 char * args[], /* Command line args */
1522 int count) /* Args count */
1523 {
1524 struct iwreq wrq;
1525
1526 /* Avoid "Unused parameter" warning */
1527 count = count;
1528
1529 wrq.u.frag.value = -1;
1530 wrq.u.frag.fixed = 1;
1531 wrq.u.frag.disabled = 0;
1532
1533 if(!strcasecmp(args[0], "off"))
1534 wrq.u.frag.disabled = 1; /* i.e. max size */
1535 else
1536 if(!strcasecmp(args[0], "auto"))
1537 wrq.u.frag.fixed = 0;
1538 else
1539 {
1540 if(!strcasecmp(args[0], "fixed"))
1541 {
1542 /* Get old fragmentation threshold */
1543 if(iw_get_ext(skfd, ifname, SIOCGIWFRAG, &wrq) < 0)
1544 return(IWERR_GET_EXT);
1545 wrq.u.frag.fixed = 1;
1546 }
1547 else
1548 { /* Should be a numeric value */
1549 long temp;
1550 if(sscanf(args[0], "%li", &(temp))
1551 != 1)
1552 {
1553 errarg = 0;
1554 return(IWERR_ARG_TYPE);
1555 }
1556 wrq.u.frag.value = temp;
1557 }
1558 }
1559
1560 if(iw_set_ext(skfd, ifname, SIOCSIWFRAG, &wrq) < 0)
1561 return(IWERR_SET_EXT);
1562
1563 /* 1 arg */
1564 return(1);
1565 }
1566
1567 /*------------------------------------------------------------------*/
1568 /*
1569 * Set Modulation
1570 */
1571 static int
1572 set_modulation_info(int skfd,
1573 char * ifname,
1574 char * args[], /* Command line args */
1575 int count) /* Args count */
1576 {
1577 struct iwreq wrq;
1578 int i = 1;
1579
1580 /* Avoid "Unused parameter" warning */
1581 args = args; count = count;
1582
1583 if(!strcasecmp(args[0], "auto"))
1584 wrq.u.param.fixed = 0; /* i.e. use any modulation */
1585 else
1586 {
1587 if(!strcasecmp(args[0], "fixed"))
1588 {
1589 /* Get old modulation */
1590 if(iw_get_ext(skfd, ifname, SIOCGIWMODUL, &wrq) < 0)
1591 return(IWERR_GET_EXT);
1592 wrq.u.param.fixed = 1;
1593 }
1594 else
1595 {
1596 int k;
1597
1598 /* Allow multiple modulations, combine them together */
1599 wrq.u.param.value = 0x0;
1600 i = 0;
1601 do
1602 {
1603 for(k = 0; k < IW_SIZE_MODUL_LIST; k++)
1604 {
1605 if(!strcasecmp(args[i], iw_modul_list[k].cmd))
1606 {
1607 wrq.u.param.value |= iw_modul_list[k].mask;
1608 ++i;
1609 break;
1610 }
1611 }
1612 }
1613 /* For as long as current arg matched and not out of args */
1614 while((i < count) && (k < IW_SIZE_MODUL_LIST));
1615
1616 /* Check we got something */
1617 if(i == 0)
1618 {
1619 errarg = 0;
1620 return(IWERR_ARG_TYPE);
1621 }
1622
1623 /* Check for an additional argument */
1624 if((i < count) && (!strcasecmp(args[i], "auto")))
1625 {
1626 wrq.u.param.fixed = 0;
1627 ++i;
1628 }
1629 if((i < count) && (!strcasecmp(args[i], "fixed")))
1630 {
1631 wrq.u.param.fixed = 1;
1632 ++i;
1633 }
1634 }
1635 }
1636
1637 if(iw_set_ext(skfd, ifname, SIOCSIWMODUL, &wrq) < 0)
1638 return(IWERR_SET_EXT);
1639
1640 /* Var args */
1641 return(i);
1642 }
1643 #endif /* WE_ESSENTIAL */
1644
1645 /*------------------------------------------------------------------*/
1646 /*
1647 * Set commit
1648 */
1649 static int
1650 set_commit_info(int skfd,
1651 char * ifname,
1652 char * args[], /* Command line args */
1653 int count) /* Args count */
1654 {
1655 struct iwreq wrq;
1656
1657 /* Avoid "Unused parameter" warning */
1658 args = args; count = count;
1659
1660 if(iw_set_ext(skfd, ifname, SIOCSIWCOMMIT, &wrq) < 0)
1661 return(IWERR_SET_EXT);
1662
1663 /* No args */
1664 return(0);
1665 }
1666
1667 /************************** SET DISPATCHER **************************/
1668 /*
1669 * This is a modified version of the dispatcher in iwlist.
1670 * The main difference is that here we may have multiple commands per
1671 * line. Also, most commands here do take arguments, and most often
1672 * a variable number of them.
1673 * Therefore, the handler *must* return how many args were consumed...
1674 *
1675 * Note that the use of multiple commands per line is not advised
1676 * in scripts, as it makes error management hard. All commands before
1677 * the error are executed, but commands after the error are not
1678 * processed.
1679 * We also try to give as much clue as possible via stderr to the caller
1680 * on which command did fail, but if there are two time the same command,
1681 * you don't know which one failed...
1682 */
1683
1684 /*------------------------------------------------------------------*/
1685 /*
1686 * Map command line arguments to the proper procedure...
1687 */
1688 typedef struct iwconfig_entry {
1689 const char * cmd; /* Command line shorthand */
1690 iw_enum_handler fn; /* Subroutine */
1691 int min_count;
1692 int request; /* WE numerical ID */
1693 const char * name; /* Human readable string */
1694 const char * argsname; /* Args as human readable string */
1695 } iwconfig_cmd;
1696
1697 static const struct iwconfig_entry iwconfig_cmds[] = {
1698 { "essid", set_essid_info, 1, SIOCSIWESSID,
1699 "Set ESSID", "{NNN|any|on|off}" },
1700 { "mode", set_mode_info, 1, SIOCSIWMODE,
1701 "Set Mode", "{managed|ad-hoc|master|...}" },
1702 { "freq", set_freq_info, 1, SIOCSIWFREQ,
1703 "Set Frequency", "N.NNN[k|M|G]" },
1704 { "channel", set_freq_info, 1, SIOCSIWFREQ,
1705 "Set Frequency", "N" },
1706 { "bit", set_bitrate_info, 1, SIOCSIWRATE,
1707 "Set Bit Rate", "{N[k|M|G]|auto|fixed}" },
1708 { "rate", set_bitrate_info, 1, SIOCSIWRATE,
1709 "Set Bit Rate", "{N[k|M|G]|auto|fixed}" },
1710 { "enc", set_enc_info, 1, SIOCSIWENCODE,
1711 "Set Encode", "{NNNN-NNNN|off}" },
1712 { "key", set_enc_info, 1, SIOCSIWENCODE,
1713 "Set Encode", "{NNNN-NNNN|off}" },
1714 { "power", set_power_info, 1, SIOCSIWPOWER,
1715 "Set Power Management", "{period N|timeout N|saving N|off}" },
1716 #ifndef WE_ESSENTIAL
1717 { "nickname", set_nick_info, 1, SIOCSIWNICKN,
1718 "Set Nickname", "NNN" },
1719 { "nwid", set_nwid_info, 1, SIOCSIWNWID,
1720 "Set NWID", "{NN|on|off}" },
1721 { "ap", set_apaddr_info, 1, SIOCSIWAP,
1722 "Set AP Address", "{N|off|auto}" },
1723 { "txpower", set_txpower_info, 1, SIOCSIWTXPOW,
1724 "Set Tx Power", "{NmW|NdBm|off|auto}" },
1725 { "sens", set_sens_info, 1, SIOCSIWSENS,
1726 "Set Sensitivity", "N" },
1727 { "retry", set_retry_info, 1, SIOCSIWRETRY,
1728 "Set Retry Limit", "{limit N|lifetime N}" },
1729 { "rts", set_rts_info, 1, SIOCSIWRTS,
1730 "Set RTS Threshold", "{N|auto|fixed|off}" },
1731 { "frag", set_frag_info, 1, SIOCSIWFRAG,
1732 "Set Fragmentation Threshold", "{N|auto|fixed|off}" },
1733 { "modulation", set_modulation_info, 1, SIOCGIWMODUL,
1734 "Set Modulation", "{11g|11a|CCK|OFDMg|...}" },
1735 #endif /* WE_ESSENTIAL */
1736 { "commit", set_commit_info, 0, SIOCSIWCOMMIT,
1737 "Commit changes", "" },
1738 { NULL, NULL, 0, 0, NULL, NULL },
1739 };
1740
1741 /*------------------------------------------------------------------*/
1742 /*
1743 * Find the most appropriate command matching the command line
1744 */
1745 static inline const iwconfig_cmd *
1746 find_command(const char * cmd)
1747 {
1748 const iwconfig_cmd * found = NULL;
1749 int ambig = 0;
1750 unsigned int len = strlen(cmd);
1751 int i;
1752
1753 /* Go through all commands */
1754 for(i = 0; iwconfig_cmds[i].cmd != NULL; ++i)
1755 {
1756 /* No match -> next one */
1757 if(strncasecmp(iwconfig_cmds[i].cmd, cmd, len) != 0)
1758 continue;
1759
1760 /* Exact match -> perfect */
1761 if(len == strlen(iwconfig_cmds[i].cmd))
1762 return &iwconfig_cmds[i];
1763
1764 /* Partial match */
1765 if(found == NULL)
1766 /* First time */
1767 found = &iwconfig_cmds[i];
1768 else
1769 /* Another time */
1770 if (iwconfig_cmds[i].fn != found->fn)
1771 ambig = 1;
1772 }
1773
1774 if(found == NULL)
1775 {
1776 fprintf(stderr, "iwconfig: unknown command \"%s\"\n", cmd);
1777 return NULL;
1778 }
1779
1780 if(ambig)
1781 {
1782 fprintf(stderr, "iwconfig: command \"%s\" is ambiguous\n", cmd);
1783 return NULL;
1784 }
1785
1786 return found;
1787 }
1788
1789 /*------------------------------------------------------------------*/
1790 /*
1791 * Set the wireless options requested on command line
1792 * Find the individual commands and call the appropriate subroutine
1793 */
1794 static int
1795 set_info(int skfd, /* The socket */
1796 char * args[], /* Command line args */
1797 int count, /* Args count */
1798 char * ifname) /* Dev name */
1799 {
1800 const iwconfig_cmd * iwcmd;
1801 int ret;
1802
1803 /* Loop until we run out of args... */
1804 while(count > 0)
1805 {
1806 /* find the command matching the keyword */
1807 iwcmd = find_command(args[0]);
1808 if(iwcmd == NULL)
1809 {
1810 /* Here we have an unrecognised arg... Error already printed out. */
1811 return(-1);
1812 }
1813
1814 /* One arg is consumed (the command name) */
1815 args++;
1816 count--;
1817
1818 /* Check arg numbers */
1819 if(count < iwcmd->min_count)
1820 ret = IWERR_ARG_NUM;
1821 else
1822 ret = 0;
1823
1824 /* Call the command */
1825 if(!ret)
1826 ret = (*iwcmd->fn)(skfd, ifname, args, count);
1827
1828 /* Deal with various errors */
1829 if(ret < 0)
1830 {
1831 int request = iwcmd->request;
1832 if(ret == IWERR_GET_EXT)
1833 request++; /* Transform the SET into GET */
1834
1835 fprintf(stderr, "Error for wireless request \"%s\" (%X) :\n",
1836 iwcmd->name, request);
1837 switch(ret)
1838 {
1839 case IWERR_ARG_NUM:
1840 fprintf(stderr, " too few arguments.\n");
1841 break;
1842 case IWERR_ARG_TYPE:
1843 if(errarg < 0)
1844 errarg = 0;
1845 if(errarg >= count)
1846 errarg = count - 1;
1847 fprintf(stderr, " invalid argument \"%s\".\n", args[errarg]);
1848 break;
1849 case IWERR_ARG_SIZE:
1850 fprintf(stderr, " argument too big (max %d)\n", errmax);
1851 break;
1852 case IWERR_ARG_CONFLICT:
1853 if(errarg < 0)
1854 errarg = 0;
1855 if(errarg >= count)
1856 errarg = count - 1;
1857 fprintf(stderr, " conflicting argument \"%s\".\n", args[errarg]);
1858 break;
1859 case IWERR_SET_EXT:
1860 fprintf(stderr, " SET failed on device %-1.16s ; %s.\n",
1861 ifname, strerror(errno));
1862 break;
1863 case IWERR_GET_EXT:
1864 fprintf(stderr, " GET failed on device %-1.16s ; %s.\n",
1865 ifname, strerror(errno));
1866 break;
1867 }
1868 /* Stop processing, we don't know if we are in a consistent state
1869 * in reading the command line */
1870 return(ret);
1871 }
1872
1873 /* Substract consumed args from command line */
1874 args += ret;
1875 count -= ret;
1876
1877 /* Loop back */
1878 }
1879
1880 /* Done, all done */
1881 return(0);
1882 }
1883
1884 /*------------------------------------------------------------------*/
1885 /*
1886 * Display help
1887 */
1888 static inline void
1889 iw_usage(void)
1890 {
1891 int i;
1892
1893 fprintf(stderr, "Usage: iwconfig [interface]\n");
1894 for(i = 0; iwconfig_cmds[i].cmd != NULL; ++i)
1895 fprintf(stderr, " interface %s %s\n",
1896 iwconfig_cmds[i].cmd, iwconfig_cmds[i].argsname);
1897 fprintf(stderr, " Check man pages for more details.\n");
1898 }
1899
1900
1901 /******************************* MAIN ********************************/
1902
1903 /*------------------------------------------------------------------*/
1904 /*
1905 * The main !
1906 */
1907 int
1908 main(int argc,
1909 char ** argv)
1910 {
1911 int skfd; /* generic raw socket desc. */
1912 int goterr = 0;
1913
1914 /* Create a channel to the NET kernel. */
1915 if((skfd = iw_sockets_open()) < 0)
1916 {
1917 perror("socket");
1918 exit(-1);
1919 }
1920
1921 /* No argument : show the list of all device + info */
1922 if(argc == 1)
1923 iw_enum_devices(skfd, &print_info, NULL, 0);
1924 else
1925 /* Special case for help... */
1926 if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help")))
1927 iw_usage();
1928 else
1929 /* Special case for version... */
1930 if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
1931 goterr = iw_print_version_info("iwconfig");
1932 else
1933 {
1934 /* '--' escape device name */
1935 if((argc > 2) && !strcmp(argv[1], "--"))
1936 {
1937 argv++;
1938 argc--;
1939 }
1940
1941 /* The device name must be the first argument */
1942 if(argc == 2)
1943 print_info(skfd, argv[1], NULL, 0);
1944 else
1945 /* The other args on the line specify options to be set... */
1946 goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);
1947 }
1948
1949 /* Close the socket. */
1950 iw_sockets_close(skfd);
1951
1952 return(goterr);
1953 }
+0
-112
src/lwe/iwevent.8 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" iwevent.8
2 .\"
3 .TH IWEVENT 8 "23 June 2004" "net-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iwevent \- Display Wireless Events generated by drivers and setting changes
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .BI "iwevent "
14 .br
15 .\"
16 .\" DESCRIPTION part
17 .\"
18 .SH DESCRIPTION
19 .B iwevent
20 displays Wireless Events received through the RTNetlink socket. Each
21 line displays the specific Wireless Event which describes what has
22 happened on the specified wireless interface.
23 .br
24 This command doesn't take any arguments.
25 .\"
26 .\" DISPLAY part
27 .\"
28 .SH DISPLAY
29 There are two classes of Wireless Events.
30 .PP
31 The first class is events related to a change of wireless settings on
32 the interface (typically done through
33 .B iwconfig
34 or a script calling
35 .BR iwconfig ).
36 Only settings that could result in a disruption of connectivity are
37 reported. The events currently reported are changing one of the
38 following setting :
39 .br
40 .I " Network ID"
41 .br
42 .I " ESSID"
43 .br
44 .I " Frequency"
45 .br
46 .I " Mode"
47 .br
48 .I " Encryption"
49 .br
50 All those events will be generated on all wireless interfaces by the
51 kernel wireless subsystem (but only if the driver has been converted
52 to the new driver API).
53 .PP
54 The second class of events are events generated by the hardware, when
55 something happens or a task has been finished. Those events include :
56 .TP
57 .B New Access Point/Cell address
58 The interface has joined a new Access Point or Ad-Hoc Cell, or lost
59 its association with it. This is the same address that is reported
60 by
61 .BR iwconfig .
62 .TP
63 .B Scan request completed
64 A scanning request has been completed, results of the scan are
65 available (see
66 .BR iwlist ).
67 .TP
68 .B Tx packet dropped
69 A packet directed at this address has been dropped because the
70 interface believes this node doesn't answer anymore (usually maximum
71 of MAC level retry exceeded). This is usually an early indication that
72 the node may have left the cell or gone out of range, but it may be
73 due to fading or excessive contention.
74 .TP
75 .B Custom driver event
76 Event specific to the driver. Please check the driver documentation.
77 .TP
78 .B Registered node
79 The interface has successfully registered a new wireless
80 client/peer. Will be generated mostly when the interface acts as an
81 Access Point (mode Master).
82 .TP
83 .B Expired node
84 The registration of the client/peer on this interface has
85 expired. Will be generated mostly when the interface acts as an Access
86 Point (mode Master).
87 .TP
88 .B Spy threshold crossed
89 The signal strength for one of the addresses in the spy list went
90 under the low threshold or went above the high threshold.
91 .PP
92 Most wireless drivers generate only a subset of those events, not all
93 of them, the exact list depends on the specific hardware/driver
94 combination. Please refer to driver documentation for details on when
95 they are generated, and use
96 .IR iwlist (8)
97 to check what the driver supports.
98 .\"
99 .\" AUTHOR part
100 .\"
101 .SH AUTHOR
102 Jean Tourrilhes \- [email protected]
103 .\"
104 .\" SEE ALSO part
105 .\"
106 .SH SEE ALSO
107 .BR iwconfig (8),
108 .BR iwlist (8),
109 .BR iwspy (8),
110 .BR iwpriv (8),
111 .BR wireless (7).
+0
-804
src/lwe/iwevent.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPL 99->04
4 *
5 * Main code for "iwevent". This listent for wireless events on rtnetlink.
6 * You need to link this code against "iwcommon.c" and "-lm".
7 *
8 * Part of this code is from Alexey Kuznetsov, part is from Casey Carter,
9 * I've just put the pieces together...
10 * By the way, if you know a way to remove the root restrictions, tell me
11 * about it...
12 *
13 * This file is released under the GPL license.
14 * Copyright (c) 1997-2004 Jean Tourrilhes <[email protected]>
15 */
16
17 /***************************** INCLUDES *****************************/
18
19 #include "iwlib.h" /* Header */
20
21 #include <linux/netlink.h>
22 #include <linux/rtnetlink.h>
23
24 #include <getopt.h>
25 #include <time.h>
26 #include <sys/time.h>
27
28 /* Ugly backward compatibility :-( */
29 #ifndef IFLA_WIRELESS
30 #define IFLA_WIRELESS (IFLA_MASTER + 1)
31 #endif /* IFLA_WIRELESS */
32
33 /****************************** TYPES ******************************/
34
35 /*
36 * Static information about wireless interface.
37 * We cache this info for performance reason.
38 */
39 typedef struct wireless_iface
40 {
41 /* Linked list */
42 struct wireless_iface * next;
43
44 /* Interface identification */
45 int ifindex; /* Interface index == black magic */
46
47 /* Interface data */
48 char ifname[IFNAMSIZ + 1]; /* Interface name */
49 struct iw_range range; /* Wireless static data */
50 int has_range;
51 } wireless_iface;
52
53 /**************************** VARIABLES ****************************/
54
55 /* Cache of wireless interfaces */
56 struct wireless_iface * interface_cache = NULL;
57
58 /************************ RTNETLINK HELPERS ************************/
59 /*
60 * The following code is extracted from :
61 * ----------------------------------------------
62 * libnetlink.c RTnetlink service routines.
63 *
64 * This program is free software; you can redistribute it and/or
65 * modify it under the terms of the GNU General Public License
66 * as published by the Free Software Foundation; either version
67 * 2 of the License, or (at your option) any later version.
68 *
69 * Authors: Alexey Kuznetsov, <[email protected]>
70 * -----------------------------------------------
71 */
72
73 struct rtnl_handle
74 {
75 int fd;
76 struct sockaddr_nl local;
77 struct sockaddr_nl peer;
78 __u32 seq;
79 __u32 dump;
80 };
81
82 static inline void rtnl_close(struct rtnl_handle *rth)
83 {
84 close(rth->fd);
85 }
86
87 static inline int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
88 {
89 int addr_len;
90
91 memset(rth, 0, sizeof(rth));
92
93 rth->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
94 if (rth->fd < 0) {
95 perror("Cannot open netlink socket");
96 return -1;
97 }
98
99 memset(&rth->local, 0, sizeof(rth->local));
100 rth->local.nl_family = AF_NETLINK;
101 rth->local.nl_groups = subscriptions;
102
103 if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) {
104 perror("Cannot bind netlink socket");
105 return -1;
106 }
107 addr_len = sizeof(rth->local);
108 if (getsockname(rth->fd, (struct sockaddr*)&rth->local,
109 (socklen_t *) &addr_len) < 0) {
110 perror("Cannot getsockname");
111 return -1;
112 }
113 if (addr_len != sizeof(rth->local)) {
114 fprintf(stderr, "Wrong address length %d\n", addr_len);
115 return -1;
116 }
117 if (rth->local.nl_family != AF_NETLINK) {
118 fprintf(stderr, "Wrong address family %d\n", rth->local.nl_family);
119 return -1;
120 }
121 rth->seq = time(NULL);
122 return 0;
123 }
124
125 /******************* WIRELESS INTERFACE DATABASE *******************/
126 /*
127 * We keep a few information about each wireless interface on the
128 * system. This avoid to query this info at each event, therefore
129 * reducing overhead.
130 *
131 * Each interface is indexed by the 'ifindex'. As opposed to interface
132 * names, 'ifindex' are never reused (even if you reactivate the same
133 * hardware), so the data we cache will never apply to the wrong
134 * interface.
135 * Because of that, we are pretty lazy when it come to purging the
136 * cache...
137 */
138
139 /*------------------------------------------------------------------*/
140 /*
141 * Get name of interface based on interface index...
142 */
143 static inline int
144 index2name(int skfd,
145 int ifindex,
146 char * name)
147 {
148 struct ifreq irq;
149 int ret = 0;
150
151 memset(name, 0, IFNAMSIZ + 1);
152
153 /* Get interface name */
154 irq.ifr_ifindex = ifindex;
155 if(ioctl(skfd, SIOCGIFNAME, &irq) < 0)
156 ret = -1;
157 else
158 strncpy(name, irq.ifr_name, IFNAMSIZ);
159
160 return(ret);
161 }
162
163 /*------------------------------------------------------------------*/
164 /*
165 * Get interface data from cache or live interface
166 */
167 static struct wireless_iface *
168 iw_get_interface_data(int ifindex)
169 {
170 struct wireless_iface * curr;
171 int skfd = -1; /* ioctl socket */
172
173 /* Search for it in the database */
174 curr = interface_cache;
175 while(curr != NULL)
176 {
177 /* Match ? */
178 if(curr->ifindex == ifindex)
179 {
180 //printf("Cache : found %d-%s\n", curr->ifindex, curr->ifname);
181
182 /* Return */
183 return(curr);
184 }
185 /* Next entry */
186 curr = curr->next;
187 }
188
189 /* Create a channel to the NET kernel. Doesn't happen too often, so
190 * socket creation overhead is minimal... */
191 if((skfd = iw_sockets_open()) < 0)
192 {
193 perror("iw_sockets_open");
194 return(NULL);
195 }
196
197 /* Create new entry, zero, init */
198 curr = calloc(1, sizeof(struct wireless_iface));
199 if(!curr)
200 {
201 fprintf(stderr, "Malloc failed\n");
202 return(NULL);
203 }
204 curr->ifindex = ifindex;
205
206 /* Extract static data */
207 if(index2name(skfd, ifindex, curr->ifname) < 0)
208 {
209 perror("index2name");
210 free(curr);
211 return(NULL);
212 }
213 curr->has_range = (iw_get_range_info(skfd, curr->ifname, &curr->range) >= 0);
214 //printf("Cache : create %d-%s\n", curr->ifindex, curr->ifname);
215
216 /* Done */
217 iw_sockets_close(skfd);
218
219 /* Link it */
220 curr->next = interface_cache;
221 interface_cache = curr;
222
223 return(curr);
224 }
225
226 /*------------------------------------------------------------------*/
227 /*
228 * Remove interface data from cache (if it exist)
229 */
230 static void
231 iw_del_interface_data(int ifindex)
232 {
233 struct wireless_iface * curr;
234 struct wireless_iface * prev = NULL;
235 struct wireless_iface * next;
236
237 /* Go through the list, find the interface, kills it */
238 curr = interface_cache;
239 while(curr)
240 {
241 next = curr->next;
242
243 /* Got a match ? */
244 if(curr->ifindex == ifindex)
245 {
246 /* Unlink. Root ? */
247 if(!prev)
248 interface_cache = next;
249 else
250 prev->next = next;
251 //printf("Cache : purge %d-%s\n", curr->ifindex, curr->ifname);
252
253 /* Destroy */
254 free(curr);
255 }
256 else
257 {
258 /* Keep as previous */
259 prev = curr;
260 }
261
262 /* Next entry */
263 curr = next;
264 }
265 }
266
267 /********************* WIRELESS EVENT DECODING *********************/
268 /*
269 * Parse the Wireless Event and print it out
270 */
271
272 /*------------------------------------------------------------------*/
273 /*
274 * Dump a buffer as a serie of hex
275 * Maybe should go in iwlib...
276 * Maybe we should have better formatting like iw_print_key...
277 */
278 static char *
279 iw_hexdump(char * buf,
280 size_t buflen,
281 const unsigned char *data,
282 size_t datalen)
283 {
284 size_t i;
285 char * pos = buf;
286
287 for(i = 0; i < datalen; i++)
288 pos += snprintf(pos, buf + buflen - pos, "%02X", data[i]);
289 return buf;
290 }
291
292 /*------------------------------------------------------------------*/
293 /*
294 * Print one element from the scanning results
295 */
296 static inline int
297 print_event_token(struct iw_event * event, /* Extracted token */
298 struct iw_range * iw_range, /* Range info */
299 int has_range)
300 {
301 char buffer[128]; /* Temporary buffer */
302 char buffer2[30]; /* Temporary buffer */
303 char * prefix = (IW_IS_GET(event->cmd) ? "New" : "Set");
304
305 /* Now, let's decode the event */
306 switch(event->cmd)
307 {
308 /* ----- set events ----- */
309 /* Events that result from a "SET XXX" operation by the user */
310 case SIOCSIWNWID:
311 if(event->u.nwid.disabled)
312 printf("Set NWID:off/any\n");
313 else
314 printf("Set NWID:%X\n", event->u.nwid.value);
315 break;
316 case SIOCSIWFREQ:
317 case SIOCGIWFREQ:
318 {
319 double freq; /* Frequency/channel */
320 int channel = -1; /* Converted to channel */
321 freq = iw_freq2float(&(event->u.freq));
322 if(has_range)
323 {
324 if(freq < KILO)
325 /* Convert channel to frequency if possible */
326 channel = iw_channel_to_freq((int) freq, &freq, iw_range);
327 else
328 /* Convert frequency to channel if possible */
329 channel = iw_freq_to_channel(freq, iw_range);
330 }
331 iw_print_freq(buffer, sizeof(buffer),
332 freq, channel, event->u.freq.flags);
333 printf("%s %s\n", prefix, buffer);
334 }
335 break;
336 case SIOCSIWMODE:
337 printf("Set Mode:%s\n",
338 iw_operation_mode[event->u.mode]);
339 break;
340 case SIOCSIWESSID:
341 case SIOCGIWESSID:
342 {
343 char essid[IW_ESSID_MAX_SIZE+1];
344 memset(essid, '\0', sizeof(essid));
345 if((event->u.essid.pointer) && (event->u.essid.length))
346 memcpy(essid, event->u.essid.pointer, event->u.essid.length);
347 if(event->u.essid.flags)
348 {
349 /* Does it have an ESSID index ? */
350 if((event->u.essid.flags & IW_ENCODE_INDEX) > 1)
351 printf("%s ESSID:\"%s\" [%d]\n", prefix, essid,
352 (event->u.essid.flags & IW_ENCODE_INDEX));
353 else
354 printf("%s ESSID:\"%s\"\n", prefix, essid);
355 }
356 else
357 printf("%s ESSID:off/any\n", prefix);
358 }
359 break;
360 case SIOCSIWENCODE:
361 {
362 unsigned char key[IW_ENCODING_TOKEN_MAX];
363 if(event->u.data.pointer)
364 memcpy(key, event->u.data.pointer, event->u.data.length);
365 else
366 event->u.data.flags |= IW_ENCODE_NOKEY;
367 printf("Set Encryption key:");
368 if(event->u.data.flags & IW_ENCODE_DISABLED)
369 printf("off\n");
370 else
371 {
372 /* Display the key */
373 iw_print_key(buffer, sizeof(buffer), key, event->u.data.length,
374 event->u.data.flags);
375 printf("%s", buffer);
376
377 /* Other info... */
378 if((event->u.data.flags & IW_ENCODE_INDEX) > 1)
379 printf(" [%d]", event->u.data.flags & IW_ENCODE_INDEX);
380 if(event->u.data.flags & IW_ENCODE_RESTRICTED)
381 printf(" Security mode:restricted");
382 if(event->u.data.flags & IW_ENCODE_OPEN)
383 printf(" Security mode:open");
384 printf("\n");
385 }
386 }
387 break;
388 /* ----- driver events ----- */
389 /* Events generated by the driver when something important happens */
390 case SIOCGIWAP:
391 printf("New Access Point/Cell address:%s\n",
392 iw_sawap_ntop(&event->u.ap_addr, buffer));
393 break;
394 case SIOCGIWSCAN:
395 printf("Scan request completed\n");
396 break;
397 case IWEVTXDROP:
398 printf("Tx packet dropped:%s\n",
399 iw_saether_ntop(&event->u.addr, buffer));
400 break;
401 case IWEVCUSTOM:
402 {
403 char custom[IW_CUSTOM_MAX+1];
404 memset(custom, '\0', sizeof(custom));
405 if((event->u.data.pointer) && (event->u.data.length))
406 memcpy(custom, event->u.data.pointer, event->u.data.length);
407 printf("Custom driver event:%s\n", custom);
408 }
409 break;
410 case IWEVREGISTERED:
411 printf("Registered node:%s\n",
412 iw_saether_ntop(&event->u.addr, buffer));
413 break;
414 case IWEVEXPIRED:
415 printf("Expired node:%s\n",
416 iw_saether_ntop(&event->u.addr, buffer));
417 break;
418 case SIOCGIWTHRSPY:
419 {
420 struct iw_thrspy threshold;
421 if((event->u.data.pointer) && (event->u.data.length))
422 {
423 memcpy(&threshold, event->u.data.pointer,
424 sizeof(struct iw_thrspy));
425 printf("Spy threshold crossed on address:%s\n",
426 iw_saether_ntop(&threshold.addr, buffer));
427 iw_print_stats(buffer, sizeof(buffer),
428 &threshold.qual, iw_range, has_range);
429 printf(" Link %s\n", buffer);
430 }
431 else
432 printf("Invalid Spy Threshold event\n");
433 }
434 break;
435 /* ----- driver WPA events ----- */
436 /* Events generated by the driver, used for WPA operation */
437 case IWEVMICHAELMICFAILURE:
438 if(event->u.data.length >= sizeof(struct iw_michaelmicfailure))
439 {
440 struct iw_michaelmicfailure mf;
441 memcpy(&mf, event->u.data.pointer, sizeof(mf));
442 printf("Michael MIC failure flags:0x%X src_addr:%s tsc:%s\n",
443 mf.flags,
444 iw_saether_ntop(&mf.src_addr, buffer2),
445 iw_hexdump(buffer, sizeof(buffer),
446 mf.tsc, IW_ENCODE_SEQ_MAX_SIZE));
447 }
448 break;
449 case IWEVASSOCREQIE:
450 printf("Association Request IEs:%s\n",
451 iw_hexdump(buffer, sizeof(buffer),
452 event->u.data.pointer, event->u.data.length));
453 break;
454 case IWEVASSOCRESPIE:
455 printf("Association Response IEs:%s\n",
456 iw_hexdump(buffer, sizeof(buffer),
457 event->u.data.pointer, event->u.data.length));
458 break;
459 case IWEVPMKIDCAND:
460 if(event->u.data.length >= sizeof(struct iw_pmkid_cand))
461 {
462 struct iw_pmkid_cand cand;
463 memcpy(&cand, event->u.data.pointer, sizeof(cand));
464 printf("PMKID candidate flags:0x%X index:%d bssid:%s\n",
465 cand.flags, cand.index,
466 iw_saether_ntop(&cand.bssid, buffer));
467 }
468 break;
469 /* ----- junk ----- */
470 /* other junk not currently in use */
471 case SIOCGIWRATE:
472 iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value);
473 printf("New Bit Rate:%s\n", buffer);
474 break;
475 case SIOCGIWNAME:
476 printf("Protocol:%-1.16s\n", event->u.name);
477 break;
478 case IWEVQUAL:
479 {
480 event->u.qual.updated = 0x0; /* Not that reliable, disable */
481 iw_print_stats(buffer, sizeof(buffer),
482 &event->u.qual, iw_range, has_range);
483 printf("Link %s\n", buffer);
484 break;
485 }
486 default:
487 printf("(Unknown Wireless event 0x%04X)\n", event->cmd);
488 } /* switch(event->cmd) */
489
490 return(0);
491 }
492
493 /*------------------------------------------------------------------*/
494 /*
495 * Print out all Wireless Events part of the RTNetlink message
496 * Most often, there will be only one event per message, but
497 * just make sure we read everything...
498 */
499 static inline int
500 print_event_stream(int ifindex,
501 char * data,
502 int len)
503 {
504 struct iw_event iwe;
505 struct stream_descr stream;
506 int i = 0;
507 int ret;
508 char buffer[64];
509 struct timeval recv_time;
510 struct timezone tz;
511 struct wireless_iface * wireless_data;
512
513 /* Get data from cache */
514 wireless_data = iw_get_interface_data(ifindex);
515 if(wireless_data == NULL)
516 return(-1);
517
518 /* Print received time in readable form */
519 gettimeofday(&recv_time, &tz);
520 iw_print_timeval(buffer, sizeof(buffer), &recv_time, &tz);
521
522 iw_init_event_stream(&stream, data, len);
523 do
524 {
525 /* Extract an event and print it */
526 ret = iw_extract_event_stream(&stream, &iwe,
527 wireless_data->range.we_version_compiled);
528 if(ret != 0)
529 {
530 if(i++ == 0)
531 printf("%s %-8.16s ", buffer, wireless_data->ifname);
532 else
533 printf(" ");
534 if(ret > 0)
535 print_event_token(&iwe,
536 &wireless_data->range, wireless_data->has_range);
537 else
538 printf("(Invalid event)\n");
539 /* Push data out *now*, in case we are redirected to a pipe */
540 fflush(stdout);
541 }
542 }
543 while(ret > 0);
544
545 return(0);
546 }
547
548 /*********************** RTNETLINK EVENT DUMP***********************/
549 /*
550 * Dump the events we receive from rtnetlink
551 * This code is mostly from Casey
552 */
553
554 /*------------------------------------------------------------------*/
555 /*
556 * Respond to a single RTM_NEWLINK event from the rtnetlink socket.
557 */
558 static int
559 LinkCatcher(struct nlmsghdr *nlh)
560 {
561 struct ifinfomsg* ifi;
562
563 #if 0
564 fprintf(stderr, "nlmsg_type = %d.\n", nlh->nlmsg_type);
565 #endif
566
567 ifi = NLMSG_DATA(nlh);
568
569 /* Code is ugly, but sort of works - Jean II */
570
571 /* If interface is getting destoyed */
572 if(nlh->nlmsg_type == RTM_DELLINK)
573 {
574 /* Remove from cache (if in cache) */
575 iw_del_interface_data(ifi->ifi_index);
576 return 0;
577 }
578
579 /* Only keep add/change events */
580 if(nlh->nlmsg_type != RTM_NEWLINK)
581 return 0;
582
583 /* Check for attributes */
584 if (nlh->nlmsg_len > NLMSG_ALIGN(sizeof(struct ifinfomsg)))
585 {
586 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(sizeof(struct ifinfomsg));
587 struct rtattr *attr = (void *) ((char *) ifi +
588 NLMSG_ALIGN(sizeof(struct ifinfomsg)));
589
590 while (RTA_OK(attr, attrlen))
591 {
592 /* Check if the Wireless kind */
593 if(attr->rta_type == IFLA_WIRELESS)
594 {
595 /* Go to display it */
596 print_event_stream(ifi->ifi_index,
597 (char *) attr + RTA_ALIGN(sizeof(struct rtattr)),
598 attr->rta_len - RTA_ALIGN(sizeof(struct rtattr)));
599 }
600 attr = RTA_NEXT(attr, attrlen);
601 }
602 }
603
604 return 0;
605 }
606
607 /* ---------------------------------------------------------------- */
608 /*
609 * We must watch the rtnelink socket for events.
610 * This routine handles those events (i.e., call this when rth.fd
611 * is ready to read).
612 */
613 static inline void
614 handle_netlink_events(struct rtnl_handle * rth)
615 {
616 while(1)
617 {
618 struct sockaddr_nl sanl;
619 socklen_t sanllen = sizeof(struct sockaddr_nl);
620
621 struct nlmsghdr *h;
622 int amt;
623 char buf[8192];
624
625 amt = recvfrom(rth->fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sanl, &sanllen);
626 if(amt < 0)
627 {
628 if(errno != EINTR && errno != EAGAIN)
629 {
630 fprintf(stderr, "%s: error reading netlink: %s.\n",
631 __PRETTY_FUNCTION__, strerror(errno));
632 }
633 return;
634 }
635
636 if(amt == 0)
637 {
638 fprintf(stderr, "%s: EOF on netlink??\n", __PRETTY_FUNCTION__);
639 return;
640 }
641
642 h = (struct nlmsghdr*)buf;
643 while(amt >= (int)sizeof(*h))
644 {
645 int len = h->nlmsg_len;
646 int l = len - sizeof(*h);
647
648 if(l < 0 || len > amt)
649 {
650 fprintf(stderr, "%s: malformed netlink message: len=%d\n", __PRETTY_FUNCTION__, len);
651 break;
652 }
653
654 switch(h->nlmsg_type)
655 {
656 case RTM_NEWLINK:
657 case RTM_DELLINK:
658 LinkCatcher(h);
659 break;
660 default:
661 #if 0
662 fprintf(stderr, "%s: got nlmsg of type %#x.\n", __PRETTY_FUNCTION__, h->nlmsg_type);
663 #endif
664 break;
665 }
666
667 len = NLMSG_ALIGN(len);
668 amt -= len;
669 h = (struct nlmsghdr*)((char*)h + len);
670 }
671
672 if(amt > 0)
673 fprintf(stderr, "%s: remnant of size %d on netlink\n", __PRETTY_FUNCTION__, amt);
674 }
675 }
676
677 /**************************** MAIN LOOP ****************************/
678
679 /* ---------------------------------------------------------------- */
680 /*
681 * Wait until we get an event
682 */
683 static inline int
684 wait_for_event(struct rtnl_handle * rth)
685 {
686 #if 0
687 struct timeval tv; /* Select timeout */
688 #endif
689
690 /* Forever */
691 while(1)
692 {
693 fd_set rfds; /* File descriptors for select */
694 int last_fd; /* Last fd */
695 int ret;
696
697 /* Guess what ? We must re-generate rfds each time */
698 FD_ZERO(&rfds);
699 FD_SET(rth->fd, &rfds);
700 last_fd = rth->fd;
701
702 /* Wait until something happens */
703 ret = select(last_fd + 1, &rfds, NULL, NULL, NULL);
704
705 /* Check if there was an error */
706 if(ret < 0)
707 {
708 if(errno == EAGAIN || errno == EINTR)
709 continue;
710 fprintf(stderr, "Unhandled signal - exiting...\n");
711 break;
712 }
713
714 /* Check if there was a timeout */
715 if(ret == 0)
716 {
717 continue;
718 }
719
720 /* Check for interface discovery events. */
721 if(FD_ISSET(rth->fd, &rfds))
722 handle_netlink_events(rth);
723 }
724
725 return(0);
726 }
727
728 /******************************* MAIN *******************************/
729
730 /* ---------------------------------------------------------------- */
731 /*
732 * helper ;-)
733 */
734 static void
735 iw_usage(int status)
736 {
737 fputs("Usage: iwevent [OPTIONS]\n"
738 " Monitors and displays Wireless Events.\n"
739 " Options are:\n"
740 " -h,--help Print this message.\n"
741 " -v,--version Show version of this program.\n",
742 status ? stderr : stdout);
743 exit(status);
744 }
745 /* Command line options */
746 static const struct option long_opts[] = {
747 { "help", no_argument, NULL, 'h' },
748 { "version", no_argument, NULL, 'v' },
749 { NULL, 0, NULL, 0 }
750 };
751
752 /* ---------------------------------------------------------------- */
753 /*
754 * main body of the program
755 */
756 int
757 main(int argc,
758 char * argv[])
759 {
760 struct rtnl_handle rth;
761 int opt;
762
763 /* Check command line options */
764 while((opt = getopt_long(argc, argv, "hv", long_opts, NULL)) > 0)
765 {
766 switch(opt)
767 {
768 case 'h':
769 iw_usage(0);
770 break;
771
772 case 'v':
773 return(iw_print_version_info("iwevent"));
774 break;
775
776 default:
777 iw_usage(1);
778 break;
779 }
780 }
781 if(optind < argc)
782 {
783 fputs("Too many arguments.\n", stderr);
784 iw_usage(1);
785 }
786
787 /* Open netlink channel */
788 if(rtnl_open(&rth, RTMGRP_LINK) < 0)
789 {
790 perror("Can't initialize rtnetlink socket");
791 return(1);
792 }
793
794 fprintf(stderr, "Waiting for Wireless Events from interfaces...\n");
795
796 /* Do what we have to do */
797 wait_for_event(&rth);
798
799 /* Cleanup - only if you are pedantic */
800 rtnl_close(&rth);
801
802 return(0);
803 }
+0
-115
src/lwe/iwgetid.8 less more
0 .\" Guus Sliepen - 2001
1 .\" Completed and fixed up by Jean Tourrilhes - 2002-2003
2 .\" iwgetid.8
3 .\"
4 .TH IWGETID 8 "02 December 2003" "wireless-tools" "Linux Programmer's Manual"
5 .\"
6 .\" NAME part
7 .\"
8 .SH NAME
9 iwgetid \- Report ESSID, NWID or AP/Cell Address of wireless network
10 .\"
11 .\" SYNOPSIS part
12 .\"
13 .SH SYNOPSIS
14 .BI "iwgetid " [interface] " [--raw] [--scheme] [--ap] [--freq]"
15 .br
16 .BI " [--mode] [--protocol] [--channel]
17 .br
18 .\"
19 .\" DESCRIPTION part
20 .\"
21 .SH DESCRIPTION
22 .B iwgetid
23 is used to find out the NWID, ESSID or AP/Cell Address of the wireless
24 network that is currently used. The information reported is the same
25 as the one shown by
26 .BR iwconfig ", but " iwgetid
27 is easier to integrate in various scripts.
28 .br
29 By default,
30 .B iwgetid
31 will print the
32 .I ESSID
33 of the device, and if the device doesn't have any ESSID it will print
34 its
35 .IR NWID .
36 .br
37 The default formatting output is pretty-print.
38 .\"
39 .\" OPTIONS part
40 .\"
41 .SH OPTIONS
42 .TP
43 .B --raw
44 This option disables pretty-printing of the information. This option
45 is orthogonal to the other options (except
46 .BR --scheme ),
47 so with the appropriate combination of options you can print the raw
48 ESSID, AP Address or Mode.
49 .br
50 This format is ideal when storing the result of iwgetid as a
51 variable in
52 .I Shell
53 or
54 .I Perl
55 scripts or to pass the result as an argument on the command line of
56 .BR iwconfig .
57 .TP
58 .B --scheme
59 This option is similar to the previous one, it disables
60 pretty-printing of the information and removes all characters that are
61 not alphanumerics (like space, punctuation and control characters).
62 .br
63 The resulting output is a valid Pcmcia scheme identifier (that may be
64 used as an argument of the command
65 .BR "cardctl scheme" ).
66 This format is also ideal when using the result of iwgetid as a
67 selector in
68 .I Shell
69 or
70 .I Perl
71 scripts, or as a file name.
72 .TP
73 .B --ap
74 Display the MAC address of the Wireless
75 .I Access Point
76 or the
77 .IR Cell .
78 .TP
79 .B --freq
80 Display the current
81 .I frequency
82 or
83 .I channel
84 used by the interface.
85 .TP
86 .B --channel
87 Display the current
88 .I channel
89 used by the interface. The channel is determined using the current
90 frequency and the frequency list provided by the interface.
91 .TP
92 .B --mode
93 Display the current
94 .I mode
95 of the interface.
96 .TP
97 .B --protocol
98 Display the
99 .I protocol name
100 of the interface. This allows to identify all the cards that are
101 compatible with each other and accept the same type of configuration.
102 .br
103 This can also be used to
104 .I check Wireless Extension support
105 on the interface, as this is the only attribute that all drivers
106 supporting Wireless Extension are mandated to support.
107 .\"
108 .\" SEE ALSO part
109 .\"
110 .SH SEE ALSO
111 .BR iwconfig (8),
112 .BR ifconfig (8),
113 .BR iwspy (8),
114 .BR iwpriv (8).
+0
-581
src/lwe/iwgetid.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPL '01
4 *
5 * Just print the ESSID or NWID...
6 *
7 * This file is released under the GPL license.
8 * Copyright (c) 1997-2004 Jean Tourrilhes <[email protected]>
9 */
10
11 #include "iwlib.h" /* Header */
12
13 #include <getopt.h>
14
15 /*
16 * Note on Pcmcia Schemes :
17 * ----------------------
18 * The purpose of this tool is to use the ESSID discovery mechanism
19 * to select the appropriate Pcmcia Scheme. The card tell us which
20 * ESSID it has found, and we can then select the appropriate Pcmcia
21 * Scheme for this ESSID (Wireless config (encrypt keys) and IP config).
22 * The way to do it is as follows :
23 * cardctl scheme "essidany"
24 * delay 100
25 * $scheme = iwgetid --scheme
26 * cardctl scheme $scheme
27 * Of course, you need to add a scheme called "essidany" with the
28 * following setting :
29 * essidany,*,*,*)
30 * ESSID="any"
31 * IPADDR="10.0.0.1"
32 *
33 * This can also be integrated int he Pcmcia scripts.
34 * Some drivers don't activate the card up to "ifconfig up".
35 * Therefore, they wont scan ESSID up to this point, so we can't
36 * read it reliably in Pcmcia scripts.
37 * I guess the proper way to write the network script is as follows :
38 * if($scheme == "iwgetid") {
39 * iwconfig $name essid any
40 * iwconfig $name nwid any
41 * ifconfig $name up
42 * delay 100
43 * $scheme = iwgetid $name --scheme
44 * ifconfig $name down
45 * }
46 *
47 * This is pseudo code, but you get an idea...
48 * The "ifconfig up" activate the card.
49 * The "delay" is necessary to let time for the card scan the
50 * frequencies and associate with the AP.
51 * The "ifconfig down" is necessary to allow the driver to optimise
52 * the wireless parameters setting (minimise number of card resets).
53 *
54 * Another cute idea is to have a list of Pcmcia Schemes to try
55 * and to keep the first one that associate (AP address != 0). This
56 * would be necessary for closed networks and cards that can't
57 * discover essid...
58 *
59 * Jean II - 29/3/01
60 */
61
62 /**************************** CONSTANTS ****************************/
63
64 #define FORMAT_DEFAULT 0 /* Nice looking display for the user */
65 #define FORMAT_SCHEME 1 /* To be used as a Pcmcia Scheme */
66 #define FORMAT_RAW 2 /* Raw value, for shell scripts */
67 #define WTYPE_ESSID 0 /* Display ESSID or NWID */
68 #define WTYPE_AP 1 /* Display AP/Cell Address */
69 #define WTYPE_FREQ 2 /* Display frequency/channel */
70 #define WTYPE_CHANNEL 3 /* Display channel (converted from freq) */
71 #define WTYPE_MODE 4 /* Display mode */
72 #define WTYPE_PROTO 5 /* Display protocol name */
73
74 /************************ DISPLAY ESSID/NWID ************************/
75
76 /*------------------------------------------------------------------*/
77 /*
78 * Display the ESSID if possible
79 */
80 static int
81 print_essid(int skfd,
82 const char * ifname,
83 int format)
84 {
85 struct iwreq wrq;
86 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID */
87 char pessid[IW_ESSID_MAX_SIZE + 1]; /* Pcmcia format */
88 unsigned int i;
89 unsigned int j;
90
91 /* Make sure ESSID is always NULL terminated */
92 memset(essid, 0, sizeof(essid));
93
94 /* Get ESSID */
95 wrq.u.essid.pointer = (caddr_t) essid;
96 wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
97 wrq.u.essid.flags = 0;
98 if(iw_get_ext(skfd, ifname, SIOCGIWESSID, &wrq) < 0)
99 return(-1);
100
101 switch(format)
102 {
103 case FORMAT_SCHEME:
104 /* Strip all white space and stuff */
105 j = 0;
106 for(i = 0; i < strlen(essid); i++)
107 if(isalnum(essid[i]))
108 pessid[j++] = essid[i];
109 pessid[j] = '\0';
110 if((j == 0) || (j > 32))
111 return(-2);
112 printf("%s\n", pessid);
113 break;
114 case FORMAT_RAW:
115 printf("%s\n", essid);
116 break;
117 default:
118 printf("%-8.16s ESSID:\"%s\"\n", ifname, essid);
119 break;
120 }
121
122 return(0);
123 }
124
125 /*------------------------------------------------------------------*/
126 /*
127 * Display the NWID if possible
128 */
129 static int
130 print_nwid(int skfd,
131 const char * ifname,
132 int format)
133 {
134 struct iwreq wrq;
135
136 /* Get network ID */
137 if(iw_get_ext(skfd, ifname, SIOCGIWNWID, &wrq) < 0)
138 return(-1);
139
140 switch(format)
141 {
142 case FORMAT_SCHEME:
143 /* Prefix with nwid to avoid name space collisions */
144 printf("nwid%X\n", wrq.u.nwid.value);
145 break;
146 case FORMAT_RAW:
147 printf("%X\n", wrq.u.nwid.value);
148 break;
149 default:
150 printf("%-8.16s NWID:%X\n", ifname, wrq.u.nwid.value);
151 break;
152 }
153
154 return(0);
155 }
156
157 /**************************** AP ADDRESS ****************************/
158
159 /*------------------------------------------------------------------*/
160 /*
161 * Display the AP Address if possible
162 */
163 static int
164 print_ap(int skfd,
165 const char * ifname,
166 int format)
167 {
168 struct iwreq wrq;
169 char buffer[64];
170
171 /* Get AP Address */
172 if(iw_get_ext(skfd, ifname, SIOCGIWAP, &wrq) < 0)
173 return(-1);
174
175 /* Print */
176 iw_ether_ntop((const struct ether_addr *) wrq.u.ap_addr.sa_data, buffer);
177 switch(format)
178 {
179 case FORMAT_SCHEME:
180 /* I think ':' are not problematic, because Pcmcia scripts
181 * seem to handle them properly... */
182 case FORMAT_RAW:
183 printf("%s\n", buffer);
184 break;
185 default:
186 printf("%-8.16s Access Point/Cell: %s\n", ifname, buffer);
187 break;
188 }
189
190 return(0);
191 }
192
193 /****************************** OTHER ******************************/
194
195 /*------------------------------------------------------------------*/
196 /*
197 * Display the frequency (or channel) if possible
198 */
199 static int
200 print_freq(int skfd,
201 const char * ifname,
202 int format)
203 {
204 struct iwreq wrq;
205 double freq;
206 char buffer[64];
207
208 /* Get frequency / channel */
209 if(iw_get_ext(skfd, ifname, SIOCGIWFREQ, &wrq) < 0)
210 return(-1);
211
212 /* Print */
213 freq = iw_freq2float(&(wrq.u.freq));
214 switch(format)
215 {
216 case FORMAT_SCHEME:
217 /* Prefix with freq to avoid name space collisions */
218 printf("freq%g\n", freq);
219 break;
220 case FORMAT_RAW:
221 printf("%g\n", freq);
222 break;
223 default:
224 iw_print_freq(buffer, sizeof(buffer), freq, -1, wrq.u.freq.flags);
225 printf("%-8.16s %s\n", ifname, buffer);
226 break;
227 }
228
229 return(0);
230 }
231
232 /*------------------------------------------------------------------*/
233 /*
234 * Display the channel (converted from frequency) if possible
235 */
236 static int
237 print_channel(int skfd,
238 const char * ifname,
239 int format)
240 {
241 struct iwreq wrq;
242 struct iw_range range;
243 double freq;
244 int channel;
245
246 /* Get frequency / channel */
247 if(iw_get_ext(skfd, ifname, SIOCGIWFREQ, &wrq) < 0)
248 return(-1);
249
250 /* Convert to channel */
251 if(iw_get_range_info(skfd, ifname, &range) < 0)
252 return(-2);
253 freq = iw_freq2float(&(wrq.u.freq));
254 if(freq < KILO)
255 channel = (int) freq;
256 else
257 {
258 channel = iw_freq_to_channel(freq, &range);
259 if(channel < 0)
260 return(-3);
261 }
262
263 /* Print */
264 switch(format)
265 {
266 case FORMAT_SCHEME:
267 /* Prefix with freq to avoid name space collisions */
268 printf("channel%d\n", channel);
269 break;
270 case FORMAT_RAW:
271 printf("%d\n", channel);
272 break;
273 default:
274 printf("%-8.16s Channel:%d\n", ifname, channel);
275 break;
276 }
277
278 return(0);
279 }
280
281 /*------------------------------------------------------------------*/
282 /*
283 * Display the mode if possible
284 */
285 static int
286 print_mode(int skfd,
287 const char * ifname,
288 int format)
289 {
290 struct iwreq wrq;
291
292 /* Get frequency / channel */
293 if(iw_get_ext(skfd, ifname, SIOCGIWMODE, &wrq) < 0)
294 return(-1);
295 if(wrq.u.mode >= IW_NUM_OPER_MODE)
296 return(-2);
297
298 /* Print */
299 switch(format)
300 {
301 case FORMAT_SCHEME:
302 /* Strip all white space and stuff */
303 if(wrq.u.mode == IW_MODE_ADHOC)
304 printf("AdHoc\n");
305 else
306 printf("%s\n", iw_operation_mode[wrq.u.mode]);
307 break;
308 case FORMAT_RAW:
309 printf("%d\n", wrq.u.mode);
310 break;
311 default:
312 printf("%-8.16s Mode:%s\n", ifname, iw_operation_mode[wrq.u.mode]);
313 break;
314 }
315
316 return(0);
317 }
318
319 /*------------------------------------------------------------------*/
320 /*
321 * Display the ESSID if possible
322 */
323 static int
324 print_protocol(int skfd,
325 const char * ifname,
326 int format)
327 {
328 struct iwreq wrq;
329 char proto[IFNAMSIZ + 1]; /* Protocol */
330 char pproto[IFNAMSIZ + 1]; /* Pcmcia format */
331 unsigned int i;
332 unsigned int j;
333
334 /* Get Protocol name */
335 if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
336 return(-1);
337 strncpy(proto, wrq.u.name, IFNAMSIZ);
338 proto[IFNAMSIZ] = '\0';
339
340 switch(format)
341 {
342 case FORMAT_SCHEME:
343 /* Strip all white space and stuff */
344 j = 0;
345 for(i = 0; i < strlen(proto); i++)
346 if(isalnum(proto[i]))
347 pproto[j++] = proto[i];
348 pproto[j] = '\0';
349 if((j == 0) || (j > 32))
350 return(-2);
351 printf("%s\n", pproto);
352 break;
353 case FORMAT_RAW:
354 printf("%s\n", proto);
355 break;
356 default:
357 printf("%-8.16s Protocol Name:\"%s\"\n", ifname, proto);
358 break;
359 }
360
361 return(0);
362 }
363
364 /******************************* MAIN ********************************/
365
366 /*------------------------------------------------------------------*/
367 /*
368 * Check options and call the proper handler
369 */
370 static int
371 print_one_device(int skfd,
372 int format,
373 int wtype,
374 const char* ifname)
375 {
376 int ret;
377
378 /* Check wtype */
379 switch(wtype)
380 {
381 case WTYPE_AP:
382 /* Try to print an AP */
383 ret = print_ap(skfd, ifname, format);
384 break;
385
386 case WTYPE_CHANNEL:
387 /* Try to print channel */
388 ret = print_channel(skfd, ifname, format);
389 break;
390
391 case WTYPE_FREQ:
392 /* Try to print frequency */
393 ret = print_freq(skfd, ifname, format);
394 break;
395
396 case WTYPE_MODE:
397 /* Try to print the mode */
398 ret = print_mode(skfd, ifname, format);
399 break;
400
401 case WTYPE_PROTO:
402 /* Try to print the protocol */
403 ret = print_protocol(skfd, ifname, format);
404 break;
405
406 default:
407 /* Try to print an ESSID */
408 ret = print_essid(skfd, ifname, format);
409 if(ret < 0)
410 {
411 /* Try to print a nwid */
412 ret = print_nwid(skfd, ifname, format);
413 }
414 }
415
416 return(ret);
417 }
418
419 /*------------------------------------------------------------------*/
420 /*
421 * Try the various devices until one return something we can use
422 *
423 * Note : we can't use iw_enum_devices() because we want a different
424 * behaviour :
425 * 1) Stop at the first valid wireless device
426 * 2) Only go through active devices
427 */
428 static int
429 scan_devices(int skfd,
430 int format,
431 int wtype)
432 {
433 char buff[1024];
434 struct ifconf ifc;
435 struct ifreq *ifr;
436 int i;
437
438 /* Get list of active devices */
439 ifc.ifc_len = sizeof(buff);
440 ifc.ifc_buf = buff;
441 if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
442 {
443 perror("SIOCGIFCONF");
444 return(-1);
445 }
446 ifr = ifc.ifc_req;
447
448 /* Print the first match */
449 for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
450 {
451 if(print_one_device(skfd, format, wtype, ifr->ifr_name) >= 0)
452 return 0;
453 }
454 return(-1);
455 }
456
457 /*------------------------------------------------------------------*/
458 /*
459 * helper
460 */
461 static void
462 iw_usage(int status)
463 {
464 fputs("Usage iwgetid [OPTIONS] [ifname]\n"
465 " Options are:\n"
466 " -a,--ap Print the access point address\n"
467 " -c,--channel Print the current channel\n"
468 " -f,--freq Print the current frequency\n"
469 " -m,--mode Print the current mode\n"
470 " -p,--protocol Print the protocol name\n"
471 " -r,--raw Format the output as raw value for shell scripts\n"
472 " -s,--scheme Format the output as a PCMCIA scheme identifier\n"
473 " -h,--help Print this message\n",
474 status ? stderr : stdout);
475 exit(status);
476 }
477
478 static const struct option long_opts[] = {
479 { "ap", no_argument, NULL, 'a' },
480 { "channel", no_argument, NULL, 'c' },
481 { "freq", no_argument, NULL, 'f' },
482 { "mode", no_argument, NULL, 'm' },
483 { "protocol", no_argument, NULL, 'p' },
484 { "help", no_argument, NULL, 'h' },
485 { "raw", no_argument, NULL, 'r' },
486 { "scheme", no_argument, NULL, 's' },
487 { NULL, 0, NULL, 0 }
488 };
489
490 /*------------------------------------------------------------------*/
491 /*
492 * The main !
493 */
494 int
495 main(int argc,
496 char ** argv)
497 {
498 int skfd; /* generic raw socket desc. */
499 int format = FORMAT_DEFAULT;
500 int wtype = WTYPE_ESSID;
501 int opt;
502 int ret = -1;
503
504 /* Check command line arguments */
505 while((opt = getopt_long(argc, argv, "acfhmprs", long_opts, NULL)) > 0)
506 {
507 switch(opt)
508 {
509 case 'a':
510 /* User wants AP/Cell Address */
511 wtype = WTYPE_AP;
512 break;
513
514 case 'c':
515 /* User wants channel only */
516 wtype = WTYPE_CHANNEL;
517 break;
518
519 case 'f':
520 /* User wants frequency/channel */
521 wtype = WTYPE_FREQ;
522 break;
523
524 case 'm':
525 /* User wants the mode */
526 wtype = WTYPE_MODE;
527 break;
528
529 case 'p':
530 /* User wants the protocol */
531 wtype = WTYPE_PROTO;
532 break;
533
534 case 'h':
535 iw_usage(0);
536 break;
537
538 case 'r':
539 /* User wants a Raw format */
540 format = FORMAT_RAW;
541 break;
542
543 case 's':
544 /* User wants a Scheme format */
545 format = FORMAT_SCHEME;
546 break;
547
548 default:
549 iw_usage(1);
550 break;
551 }
552 }
553 if(optind + 1 < argc) {
554 fputs("Too many arguments.\n", stderr);
555 iw_usage(1);
556 }
557
558 /* Create a channel to the NET kernel. */
559 if((skfd = iw_sockets_open()) < 0)
560 {
561 perror("socket");
562 return(-1);
563 }
564
565 /* Check if first argument is a device name */
566 if(optind < argc)
567 {
568 /* Yes : query only this device */
569 ret = print_one_device(skfd, format, wtype, argv[optind]);
570 }
571 else
572 {
573 /* No : query all devices and print first found */
574 ret = scan_devices(skfd, format, wtype);
575 }
576
577 fflush(stdout);
578 iw_sockets_close(skfd);
579 return(ret);
580 }
+0
-151
src/lwe/iwlist.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwlist.8
2 .\"
3 .TH IWLIST 8 "13 April 2006" "wireless-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iwlist \- Get more detailed wireless information from a wireless interface
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .BI "iwlist [" interface "] scanning"
14 .br
15 .BI "iwlist [" interface "] frequency"
16 .br
17 .BI "iwlist [" interface "] rate"
18 .br
19 .BI "iwlist [" interface "] keys"
20 .br
21 .BI "iwlist [" interface "] power"
22 .br
23 .BI "iwlist [" interface "] txpower"
24 .br
25 .BI "iwlist [" interface "] retry"
26 .br
27 .BI "iwlist [" interface "] event"
28 .br
29 .BI "iwlist [" interface "] auth"
30 .br
31 .BI "iwlist [" interface "] wpakeys"
32 .br
33 .BI "iwlist [" interface "] genie"
34 .br
35 .BI "iwlist [" interface "] modulation"
36 .br
37 .BI "iwlist --help"
38 .br
39 .BI "iwlist --version"
40 .\"
41 .\" DESCRIPTION part
42 .\"
43 .SH DESCRIPTION
44 .B Iwlist
45 is used to display some additional information from a wireless network
46 interface that is not displayed by
47 .IR iwconfig (8).
48 The main argument is used
49 to select a category of information,
50 .B iwlist
51 displays in detailed form all information related to this category,
52 including information already shown by
53 .IR iwconfig (8).
54 .\"
55 .\" PARAMETER part
56 .\"
57 .SH PARAMETERS
58 .TP
59 .BR scan [ning]
60 Give the list of Access Points and Ad-Hoc cells in range, and
61 optionally a whole bunch of information about them (ESSID, Quality,
62 Frequency, Mode...). The type of information returned depends on what
63 the card supports.
64 .br
65 Triggering scanning is a privileged operation
66 .RI ( root
67 only) and normal users can only read left-over scan results. By
68 default, the way scanning is done (the scope of the scan) is dependant
69 on the card and card settings.
70 .br
71 This command take optional arguments, however most drivers will ignore
72 those. The option
73 .B essid
74 is used to specify a scan on a specific ESSID. The option
75 .B last
76 do not trigger a scan and read left-over scan results.
77 .TP
78 .BR freq [uency]/ channel
79 Give the list of available frequencies in the device and the number of
80 defined channels. Please note that usually the driver returns the
81 total number of channels and only the frequencies available in the
82 present locale, so there is no one-to-one mapping between frequencies
83 displayed and channel numbers.
84 .TP
85 .BR rate / bit [rate]
86 List the bit-rates supported by the device.
87 .TP
88 .BR keys / enc [ryption]
89 List the encryption key sizes supported and list all the encryption
90 keys set in the device.
91 .TP
92 .B power
93 List the various Power Management attributes and modes of the device.
94 .TP
95 .B txpower
96 List the various Transmit Powers available on the device.
97 .TP
98 .B retry
99 List the transmit retry limits and retry lifetime on the device.
100 .TP
101 .BR ap / accesspoint / peers
102 Give the list of Access Points in range, and optionally the quality of
103 link to them. This feature is
104 .B obsolete
105 and now deprecated in favor of scanning support (above), and most
106 drivers don't support it.
107 .br
108 Some drivers may use this command to return a specific list of Peers
109 or Access Points, such as the list of Peers associated/registered with
110 the card. See your driver documentation for details.
111 .TP
112 .B event
113 List the wireless events supported by the device.
114 .TP
115 .B auth
116 List the WPA authentication parametes curently set.
117 .TP
118 .BR wpa [keys]
119 List all the WPA encryption keys set in the device.
120 .TP
121 .B genie
122 List the Generic Information Elements set in the device (used for WPA
123 support).
124 .TP
125 .BR modu [lation]
126 List the modulations supported by the device and the modulations
127 currently enabled.
128 .TP
129 .B --version
130 Display the version of the tools, as well as the recommended and
131 current Wireless Extensions version for the tool and the various
132 wireless interfaces.
133 .TP
134 .B --help
135 Display short help message.
136 .\"
137 .\" FILES part
138 .\"
139 .SH FILES
140 .I /proc/net/wireless
141 .\"
142 .\" SEE ALSO part
143 .\"
144 .SH SEE ALSO
145 .BR iwconfig (8),
146 .BR iwspy (8).
147 .BR iwevent (8),
148 .BR iwpriv (8),
149 .BR wireless (7).
150
+0
-2217
src/lwe/iwlist.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPLB '99 - HPL 99->07
4 *
5 * This tool can access various piece of information on the card
6 * not part of iwconfig...
7 * You need to link this code against "iwlist.c" and "-lm".
8 *
9 * This file is released under the GPL license.
10 * Copyright (c) 1997-2007 Jean Tourrilhes <[email protected]>
11 */
12
13 #include "iwlib.h" /* Header */
14 #include <sys/time.h>
15
16 /****************************** TYPES ******************************/
17
18 /*
19 * Scan state and meta-information, used to decode events...
20 */
21 typedef struct iwscan_state
22 {
23 /* State */
24 int ap_num; /* Access Point number 1->N */
25 int val_index; /* Value in table 0->(N-1) */
26 } iwscan_state;
27
28 /*
29 * Bit to name mapping
30 */
31 typedef struct iwmask_name
32 {
33 unsigned int mask; /* bit mask for the value */
34 const char * name; /* human readable name for the value */
35 } iwmask_name;
36
37 /*
38 * Types of authentication parameters
39 */
40 typedef struct iw_auth_descr
41 {
42 int value; /* Type of auth value */
43 const char * label; /* User readable version */
44 const struct iwmask_name * names; /* Names for this value */
45 const int num_names; /* Number of names */
46 } iw_auth_descr;
47
48 /**************************** CONSTANTS ****************************/
49
50 #define IW_SCAN_HACK 0x8000
51
52 #define IW_EXTKEY_SIZE (sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX)
53
54 /* ------------------------ WPA CAPA NAMES ------------------------ */
55 /*
56 * This is the user readable name of a bunch of WPA constants in wireless.h
57 * Maybe this should go in iwlib.c ?
58 */
59
60 #ifndef WE_ESSENTIAL
61 #define IW_ARRAY_LEN(x) (sizeof(x)/sizeof((x)[0]))
62
63 //static const struct iwmask_name iw_enc_mode_name[] = {
64 // { IW_ENCODE_RESTRICTED, "restricted" },
65 // { IW_ENCODE_OPEN, "open" },
66 //};
67 //#define IW_ENC_MODE_NUM IW_ARRAY_LEN(iw_enc_mode_name)
68
69 static const struct iwmask_name iw_auth_capa_name[] = {
70 { IW_ENC_CAPA_WPA, "WPA" },
71 { IW_ENC_CAPA_WPA2, "WPA2" },
72 { IW_ENC_CAPA_CIPHER_TKIP, "CIPHER-TKIP" },
73 { IW_ENC_CAPA_CIPHER_CCMP, "CIPHER-CCMP" },
74 };
75 #define IW_AUTH_CAPA_NUM IW_ARRAY_LEN(iw_auth_capa_name)
76
77 static const struct iwmask_name iw_auth_cypher_name[] = {
78 { IW_AUTH_CIPHER_NONE, "none" },
79 { IW_AUTH_CIPHER_WEP40, "WEP-40" },
80 { IW_AUTH_CIPHER_TKIP, "TKIP" },
81 { IW_AUTH_CIPHER_CCMP, "CCMP" },
82 { IW_AUTH_CIPHER_WEP104, "WEP-104" },
83 };
84 #define IW_AUTH_CYPHER_NUM IW_ARRAY_LEN(iw_auth_cypher_name)
85
86 static const struct iwmask_name iw_wpa_ver_name[] = {
87 { IW_AUTH_WPA_VERSION_DISABLED, "disabled" },
88 { IW_AUTH_WPA_VERSION_WPA, "WPA" },
89 { IW_AUTH_WPA_VERSION_WPA2, "WPA2" },
90 };
91 #define IW_WPA_VER_NUM IW_ARRAY_LEN(iw_wpa_ver_name)
92
93 static const struct iwmask_name iw_auth_key_mgmt_name[] = {
94 { IW_AUTH_KEY_MGMT_802_1X, "802.1x" },
95 { IW_AUTH_KEY_MGMT_PSK, "PSK" },
96 };
97 #define IW_AUTH_KEY_MGMT_NUM IW_ARRAY_LEN(iw_auth_key_mgmt_name)
98
99 static const struct iwmask_name iw_auth_alg_name[] = {
100 { IW_AUTH_ALG_OPEN_SYSTEM, "open" },
101 { IW_AUTH_ALG_SHARED_KEY, "shared-key" },
102 { IW_AUTH_ALG_LEAP, "LEAP" },
103 };
104 #define IW_AUTH_ALG_NUM IW_ARRAY_LEN(iw_auth_alg_name)
105
106 static const struct iw_auth_descr iw_auth_settings[] = {
107 { IW_AUTH_WPA_VERSION, "WPA version", iw_wpa_ver_name, IW_WPA_VER_NUM },
108 { IW_AUTH_KEY_MGMT, "Key management", iw_auth_key_mgmt_name, IW_AUTH_KEY_MGMT_NUM },
109 { IW_AUTH_CIPHER_PAIRWISE, "Pairwise cipher", iw_auth_cypher_name, IW_AUTH_CYPHER_NUM },
110 { IW_AUTH_CIPHER_GROUP, "Pairwise cipher", iw_auth_cypher_name, IW_AUTH_CYPHER_NUM },
111 { IW_AUTH_TKIP_COUNTERMEASURES, "TKIP countermeasures", NULL, 0 },
112 { IW_AUTH_DROP_UNENCRYPTED, "Drop unencrypted", NULL, 0 },
113 { IW_AUTH_80211_AUTH_ALG, "Authentication algorithm", iw_auth_alg_name, IW_AUTH_ALG_NUM },
114 { IW_AUTH_RX_UNENCRYPTED_EAPOL, "Receive unencrypted EAPOL", NULL, 0 },
115 { IW_AUTH_ROAMING_CONTROL, "Roaming control", NULL, 0 },
116 { IW_AUTH_PRIVACY_INVOKED, "Privacy invoked", NULL, 0 },
117 };
118 #define IW_AUTH_SETTINGS_NUM IW_ARRAY_LEN(iw_auth_settings)
119
120 /* Values for the IW_ENCODE_ALG_* returned by SIOCSIWENCODEEXT */
121 static const char * iw_encode_alg_name[] = {
122 "none",
123 "WEP",
124 "TKIP",
125 "CCMP",
126 "unknown"
127 };
128 #define IW_ENCODE_ALG_NUM IW_ARRAY_LEN(iw_encode_alg_name)
129
130 #ifndef IW_IE_CIPHER_NONE
131 /* Cypher values in GENIE (pairwise and group) */
132 #define IW_IE_CIPHER_NONE 0
133 #define IW_IE_CIPHER_WEP40 1
134 #define IW_IE_CIPHER_TKIP 2
135 #define IW_IE_CIPHER_WRAP 3
136 #define IW_IE_CIPHER_CCMP 4
137 #define IW_IE_CIPHER_WEP104 5
138 /* Key management in GENIE */
139 #define IW_IE_KEY_MGMT_NONE 0
140 #define IW_IE_KEY_MGMT_802_1X 1
141 #define IW_IE_KEY_MGMT_PSK 2
142 #endif /* IW_IE_CIPHER_NONE */
143
144 /* Values for the IW_IE_CIPHER_* in GENIE */
145 static const char * iw_ie_cypher_name[] = {
146 "none",
147 "WEP-40",
148 "TKIP",
149 "WRAP",
150 "CCMP",
151 "WEP-104",
152 };
153 #define IW_IE_CYPHER_NUM IW_ARRAY_LEN(iw_ie_cypher_name)
154
155 /* Values for the IW_IE_KEY_MGMT_* in GENIE */
156 static const char * iw_ie_key_mgmt_name[] = {
157 "none",
158 "802.1x",
159 "PSK",
160 };
161 #define IW_IE_KEY_MGMT_NUM IW_ARRAY_LEN(iw_ie_key_mgmt_name)
162
163 #endif /* WE_ESSENTIAL */
164
165 /************************* WPA SUBROUTINES *************************/
166
167 #ifndef WE_ESSENTIAL
168 /*------------------------------------------------------------------*/
169 /*
170 * Print all names corresponding to a mask.
171 * This may want to be used in iw_print_retry_value() ?
172 */
173 static void
174 iw_print_mask_name(unsigned int mask,
175 const struct iwmask_name names[],
176 const unsigned int num_names,
177 const char * sep)
178 {
179 unsigned int i;
180
181 /* Print out all names for the bitmask */
182 for(i = 0; i < num_names; i++)
183 {
184 if(mask & names[i].mask)
185 {
186 /* Print out */
187 printf("%s%s", sep, names[i].name);
188 /* Remove the bit from the mask */
189 mask &= ~names[i].mask;
190 }
191 }
192 /* If there is unconsumed bits... */
193 if(mask != 0)
194 printf("%sUnknown", sep);
195 }
196
197 /*------------------------------------------------------------------*/
198 /*
199 * Print the name corresponding to a value, with overflow check.
200 */
201 static void
202 iw_print_value_name(unsigned int value,
203 const char * names[],
204 const unsigned int num_names)
205 {
206 if(value >= num_names)
207 printf(" unknown (%d)", value);
208 else
209 printf(" %s", names[value]);
210 }
211
212 /*------------------------------------------------------------------*/
213 /*
214 * Parse, and display the results of an unknown IE.
215 *
216 */
217 static void
218 iw_print_ie_unknown(unsigned char * iebuf,
219 int buflen)
220 {
221 int ielen = iebuf[1] + 2;
222 int i;
223
224 if(ielen > buflen)
225 ielen = buflen;
226
227 printf("Unknown: ");
228 for(i = 0; i < ielen; i++)
229 printf("%02X", iebuf[i]);
230 printf("\n");
231 }
232
233 /*------------------------------------------------------------------*/
234 /*
235 * Parse, and display the results of a WPA or WPA2 IE.
236 *
237 */
238 static inline void
239 iw_print_ie_wpa(unsigned char * iebuf,
240 int buflen)
241 {
242 int ielen = iebuf[1] + 2;
243 int offset = 2; /* Skip the IE id, and the length. */
244 unsigned char wpa1_oui[3] = {0x00, 0x50, 0xf2};
245 unsigned char wpa2_oui[3] = {0x00, 0x0f, 0xac};
246 unsigned char * wpa_oui;
247 int i;
248 uint16_t ver = 0;
249 uint16_t cnt = 0;
250
251 if(ielen > buflen)
252 ielen = buflen;
253
254 #ifdef DEBUG
255 /* Debugging code. In theory useless, because it's debugged ;-) */
256 printf("IE raw value %d [%02X", buflen, iebuf[0]);
257 for(i = 1; i < buflen; i++)
258 printf(":%02X", iebuf[i]);
259 printf("]\n");
260 #endif
261
262 switch(iebuf[0])
263 {
264 case 0x30: /* WPA2 */
265 /* Check if we have enough data */
266 if(ielen < 4)
267 {
268 iw_print_ie_unknown(iebuf, buflen);
269 return;
270 }
271
272 wpa_oui = wpa2_oui;
273 break;
274
275 case 0xdd: /* WPA or else */
276 wpa_oui = wpa1_oui;
277
278 /* Not all IEs that start with 0xdd are WPA.
279 * So check that the OUI is valid. Note : offset==2 */
280 if((ielen < 8)
281 || (memcmp(&iebuf[offset], wpa_oui, 3) != 0)
282 || (iebuf[offset + 3] != 0x01))
283 {
284 iw_print_ie_unknown(iebuf, buflen);
285 return;
286 }
287
288 /* Skip the OUI type */
289 offset += 4;
290 break;
291
292 default:
293 return;
294 }
295
296 /* Pick version number (little endian) */
297 ver = iebuf[offset] | (iebuf[offset + 1] << 8);
298 offset += 2;
299
300 if(iebuf[0] == 0xdd)
301 printf("WPA Version %d\n", ver);
302 if(iebuf[0] == 0x30)
303 printf("IEEE 802.11i/WPA2 Version %d\n", ver);
304
305 /* From here, everything is technically optional. */
306
307 /* Check if we are done */
308 if(ielen < (offset + 4))
309 {
310 /* We have a short IE. So we should assume TKIP/TKIP. */
311 printf(" Group Cipher : TKIP\n");
312 printf(" Pairwise Cipher : TKIP\n");
313 return;
314 }
315
316 /* Next we have our group cipher. */
317 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
318 {
319 printf(" Group Cipher : Proprietary\n");
320 }
321 else
322 {
323 printf(" Group Cipher :");
324 iw_print_value_name(iebuf[offset+3],
325 iw_ie_cypher_name, IW_IE_CYPHER_NUM);
326 printf("\n");
327 }
328 offset += 4;
329
330 /* Check if we are done */
331 if(ielen < (offset + 2))
332 {
333 /* We don't have a pairwise cipher, or auth method. Assume TKIP. */
334 printf(" Pairwise Ciphers : TKIP\n");
335 return;
336 }
337
338 /* Otherwise, we have some number of pairwise ciphers. */
339 cnt = iebuf[offset] | (iebuf[offset + 1] << 8);
340 offset += 2;
341 printf(" Pairwise Ciphers (%d) :", cnt);
342
343 if(ielen < (offset + 4*cnt))
344 return;
345
346 for(i = 0; i < cnt; i++)
347 {
348 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
349 {
350 printf(" Proprietary");
351 }
352 else
353 {
354 iw_print_value_name(iebuf[offset+3],
355 iw_ie_cypher_name, IW_IE_CYPHER_NUM);
356 }
357 offset+=4;
358 }
359 printf("\n");
360
361 /* Check if we are done */
362 if(ielen < (offset + 2))
363 return;
364
365 /* Now, we have authentication suites. */
366 cnt = iebuf[offset] | (iebuf[offset + 1] << 8);
367 offset += 2;
368 printf(" Authentication Suites (%d) :", cnt);
369
370 if(ielen < (offset + 4*cnt))
371 return;
372
373 for(i = 0; i < cnt; i++)
374 {
375 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0)
376 {
377 printf(" Proprietary");
378 }
379 else
380 {
381 iw_print_value_name(iebuf[offset+3],
382 iw_ie_key_mgmt_name, IW_IE_KEY_MGMT_NUM);
383 }
384 offset+=4;
385 }
386 printf("\n");
387
388 /* Check if we are done */
389 if(ielen < (offset + 1))
390 return;
391
392 /* Otherwise, we have capabilities bytes.
393 * For now, we only care about preauth which is in bit position 1 of the
394 * first byte. (But, preauth with WPA version 1 isn't supposed to be
395 * allowed.) 8-) */
396 if(iebuf[offset] & 0x01)
397 {
398 printf(" Preauthentication Supported\n");
399 }
400 }
401
402 /*------------------------------------------------------------------*/
403 /*
404 * Process a generic IE and display the info in human readable form
405 * for some of the most interesting ones.
406 * For now, we only decode the WPA IEs.
407 */
408 static inline void
409 iw_print_gen_ie(unsigned char * buffer,
410 int buflen)
411 {
412 int offset = 0;
413
414 /* Loop on each IE, each IE is minimum 2 bytes */
415 while(offset <= (buflen - 2))
416 {
417 printf(" IE: ");
418
419 /* Check IE type */
420 switch(buffer[offset])
421 {
422 case 0xdd: /* WPA1 (and other) */
423 case 0x30: /* WPA2 */
424 iw_print_ie_wpa(buffer + offset, buflen);
425 break;
426 default:
427 iw_print_ie_unknown(buffer + offset, buflen);
428 }
429 /* Skip over this IE to the next one in the list. */
430 offset += buffer[offset+1] + 2;
431 }
432 }
433 #endif /* WE_ESSENTIAL */
434
435 /***************************** SCANNING *****************************/
436 /*
437 * This one behave quite differently from the others
438 *
439 * Note that we don't use the scanning capability of iwlib (functions
440 * iw_process_scan() and iw_scan()). The main reason is that
441 * iw_process_scan() return only a subset of the scan data to the caller,
442 * for example custom elements and bitrates are ommited. Here, we
443 * do the complete job...
444 */
445
446 /*------------------------------------------------------------------*/
447 /*
448 * Print one element from the scanning results
449 */
450 static inline void
451 print_scanning_token(struct stream_descr * stream, /* Stream of events */
452 struct iw_event * event, /* Extracted token */
453 struct iwscan_state * state,
454 struct iw_range * iw_range, /* Range info */
455 int has_range)
456 {
457 char buffer[128]; /* Temporary buffer */
458
459 /* Now, let's decode the event */
460 switch(event->cmd)
461 {
462 case SIOCGIWAP:
463 printf(" Cell %02d - Address: %s\n", state->ap_num,
464 iw_saether_ntop(&event->u.ap_addr, buffer));
465 state->ap_num++;
466 break;
467 case SIOCGIWNWID:
468 if(event->u.nwid.disabled)
469 printf(" NWID:off/any\n");
470 else
471 printf(" NWID:%X\n", event->u.nwid.value);
472 break;
473 case SIOCGIWFREQ:
474 {
475 double freq; /* Frequency/channel */
476 int channel = -1; /* Converted to channel */
477 freq = iw_freq2float(&(event->u.freq));
478 /* Convert to channel if possible */
479 if(has_range)
480 channel = iw_freq_to_channel(freq, iw_range);
481 iw_print_freq(buffer, sizeof(buffer),
482 freq, channel, event->u.freq.flags);
483 printf(" %s\n", buffer);
484 }
485 break;
486 case SIOCGIWMODE:
487 /* Note : event->u.mode is unsigned, no need to check <= 0 */
488 if(event->u.mode >= IW_NUM_OPER_MODE)
489 event->u.mode = IW_NUM_OPER_MODE;
490 printf(" Mode:%s\n",
491 iw_operation_mode[event->u.mode]);
492 break;
493 case SIOCGIWNAME:
494 printf(" Protocol:%-1.16s\n", event->u.name);
495 break;
496 case SIOCGIWESSID:
497 {
498 char essid[IW_ESSID_MAX_SIZE+1];
499 memset(essid, '\0', sizeof(essid));
500 if((event->u.essid.pointer) && (event->u.essid.length))
501 memcpy(essid, event->u.essid.pointer, event->u.essid.length);
502 if(event->u.essid.flags)
503 {
504 /* Does it have an ESSID index ? */
505 if((event->u.essid.flags & IW_ENCODE_INDEX) > 1)
506 printf(" ESSID:\"%s\" [%d]\n", essid,
507 (event->u.essid.flags & IW_ENCODE_INDEX));
508 else
509 printf(" ESSID:\"%s\"\n", essid);
510 }
511 else
512 printf(" ESSID:off/any/hidden\n");
513 }
514 break;
515 case SIOCGIWENCODE:
516 {
517 unsigned char key[IW_ENCODING_TOKEN_MAX];
518 if(event->u.data.pointer)
519 memcpy(key, event->u.data.pointer, event->u.data.length);
520 else
521 event->u.data.flags |= IW_ENCODE_NOKEY;
522 printf(" Encryption key:");
523 if(event->u.data.flags & IW_ENCODE_DISABLED)
524 printf("off\n");
525 else
526 {
527 /* Display the key */
528 iw_print_key(buffer, sizeof(buffer), key, event->u.data.length,
529 event->u.data.flags);
530 printf("%s", buffer);
531
532 /* Other info... */
533 if((event->u.data.flags & IW_ENCODE_INDEX) > 1)
534 printf(" [%d]", event->u.data.flags & IW_ENCODE_INDEX);
535 if(event->u.data.flags & IW_ENCODE_RESTRICTED)
536 printf(" Security mode:restricted");
537 if(event->u.data.flags & IW_ENCODE_OPEN)
538 printf(" Security mode:open");
539 printf("\n");
540 }
541 }
542 break;
543 case SIOCGIWRATE:
544 if(state->val_index == 0)
545 printf(" Bit Rates:");
546 else
547 if((state->val_index % 5) == 0)
548 printf("\n ");
549 else
550 printf("; ");
551 iw_print_bitrate(buffer, sizeof(buffer), event->u.bitrate.value);
552 printf("%s", buffer);
553 /* Check for termination */
554 if(stream->value == NULL)
555 {
556 printf("\n");
557 state->val_index = 0;
558 }
559 else
560 state->val_index++;
561 break;
562 case SIOCGIWMODUL:
563 {
564 unsigned int modul = event->u.param.value;
565 int i;
566 int n = 0;
567 printf(" Modulations :");
568 for(i = 0; i < IW_SIZE_MODUL_LIST; i++)
569 {
570 if((modul & iw_modul_list[i].mask) == iw_modul_list[i].mask)
571 {
572 if((n++ % 8) == 7)
573 printf("\n ");
574 else
575 printf(" ; ");
576 printf("%s", iw_modul_list[i].cmd);
577 }
578 }
579 printf("\n");
580 }
581 break;
582 case IWEVQUAL:
583 iw_print_stats(buffer, sizeof(buffer),
584 &event->u.qual, iw_range, has_range);
585 printf(" %s\n", buffer);
586 break;
587 #ifndef WE_ESSENTIAL
588 case IWEVGENIE:
589 /* Informations Elements are complex, let's do only some of them */
590 iw_print_gen_ie(event->u.data.pointer, event->u.data.length);
591 break;
592 #endif /* WE_ESSENTIAL */
593 case IWEVCUSTOM:
594 {
595 char custom[IW_CUSTOM_MAX+1];
596 if((event->u.data.pointer) && (event->u.data.length))
597 memcpy(custom, event->u.data.pointer, event->u.data.length);
598 custom[event->u.data.length] = '\0';
599 printf(" Extra:%s\n", custom);
600 }
601 break;
602 default:
603 printf(" (Unknown Wireless Token 0x%04X)\n",
604 event->cmd);
605 } /* switch(event->cmd) */
606 }
607
608 /*------------------------------------------------------------------*/
609 /*
610 * Perform a scanning on one device
611 */
612 static int
613 print_scanning_info(int skfd,
614 char * ifname,
615 char * args[], /* Command line args */
616 int count) /* Args count */
617 {
618 struct iwreq wrq;
619 struct iw_scan_req scanopt; /* Options for 'set' */
620 int scanflags = 0; /* Flags for scan */
621 unsigned char * buffer = NULL; /* Results */
622 int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
623 struct iw_range range;
624 int has_range;
625 struct timeval tv; /* Select timeout */
626 int timeout = 15000000; /* 15s */
627
628 /* Avoid "Unused parameter" warning */
629 args = args; count = count;
630
631 /* Debugging stuff */
632 if((IW_EV_LCP_PK2_LEN != IW_EV_LCP_PK_LEN) || (IW_EV_POINT_PK2_LEN != IW_EV_POINT_PK_LEN))
633 {
634 fprintf(stderr, "*** Please report to [email protected] your platform details\n");
635 fprintf(stderr, "*** and the following line :\n");
636 fprintf(stderr, "*** IW_EV_LCP_PK2_LEN = %zu ; IW_EV_POINT_PK2_LEN = %zu\n\n",
637 IW_EV_LCP_PK2_LEN, IW_EV_POINT_PK2_LEN);
638 }
639
640 /* Get range stuff */
641 has_range = (iw_get_range_info(skfd, ifname, &range) >= 0);
642
643 /* Check if the interface could support scanning. */
644 if((!has_range) || (range.we_version_compiled < 14))
645 {
646 fprintf(stderr, "%-8.16s Interface doesn't support scanning.\n\n",
647 ifname);
648 return(-1);
649 }
650
651 /* Init timeout value -> 250ms between set and first get */
652 tv.tv_sec = 0;
653 tv.tv_usec = 250000;
654
655 /* Clean up set args */
656 memset(&scanopt, 0, sizeof(scanopt));
657
658 /* Parse command line arguments and extract options.
659 * Note : when we have enough options, we should use the parser
660 * from iwconfig... */
661 while(count > 0)
662 {
663 /* One arg is consumed (the option name) */
664 count--;
665
666 /*
667 * Check for Active Scan (scan with specific essid)
668 */
669 if(!strncmp(args[0], "essid", 5))
670 {
671 if(count < 1)
672 {
673 fprintf(stderr, "Too few arguments for scanning option [%s]\n",
674 args[0]);
675 return(-1);
676 }
677 args++;
678 count--;
679
680 /* Store the ESSID in the scan options */
681 scanopt.essid_len = strlen(args[0]);
682 memcpy(scanopt.essid, args[0], scanopt.essid_len);
683 /* Initialise BSSID as needed */
684 if(scanopt.bssid.sa_family == 0)
685 {
686 scanopt.bssid.sa_family = ARPHRD_ETHER;
687 memset(scanopt.bssid.sa_data, 0xff, ETH_ALEN);
688 }
689 /* Scan only this ESSID */
690 scanflags |= IW_SCAN_THIS_ESSID;
691 }
692 else
693 /* Check for last scan result (do not trigger scan) */
694 if(!strncmp(args[0], "last", 4))
695 {
696 /* Hack */
697 scanflags |= IW_SCAN_HACK;
698 }
699 else
700 {
701 fprintf(stderr, "Invalid scanning option [%s]\n", args[0]);
702 return(-1);
703 }
704
705 /* Next arg */
706 args++;
707 }
708
709 /* Check if we have scan options */
710 if(scanflags)
711 {
712 wrq.u.data.pointer = (caddr_t) &scanopt;
713 wrq.u.data.length = sizeof(scanopt);
714 wrq.u.data.flags = scanflags;
715 }
716 else
717 {
718 wrq.u.data.pointer = NULL;
719 wrq.u.data.flags = 0;
720 wrq.u.data.length = 0;
721 }
722
723 /* If only 'last' was specified on command line, don't trigger a scan */
724 if(scanflags == IW_SCAN_HACK)
725 {
726 /* Skip waiting */
727 tv.tv_usec = 0;
728 }
729 else
730 {
731 /* Initiate Scanning */
732 if(iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0)
733 {
734 if((errno != EPERM) || (scanflags != 0))
735 {
736 fprintf(stderr, "%-8.16s Interface doesn't support scanning : %s\n\n",
737 ifname, strerror(errno));
738 return(-1);
739 }
740 /* If we don't have the permission to initiate the scan, we may
741 * still have permission to read left-over results.
742 * But, don't wait !!! */
743 #if 0
744 /* Not cool, it display for non wireless interfaces... */
745 fprintf(stderr, "%-8.16s (Could not trigger scanning, just reading left-over results)\n", ifname);
746 #endif
747 tv.tv_usec = 0;
748 }
749 }
750 timeout -= tv.tv_usec;
751
752 /* Forever */
753 while(1)
754 {
755 fd_set rfds; /* File descriptors for select */
756 int last_fd; /* Last fd */
757 int ret;
758
759 /* Guess what ? We must re-generate rfds each time */
760 FD_ZERO(&rfds);
761 last_fd = -1;
762
763 /* In here, add the rtnetlink fd in the list */
764
765 /* Wait until something happens */
766 ret = select(last_fd + 1, &rfds, NULL, NULL, &tv);
767
768 /* Check if there was an error */
769 if(ret < 0)
770 {
771 if(errno == EAGAIN || errno == EINTR)
772 continue;
773 fprintf(stderr, "Unhandled signal - exiting...\n");
774 return(-1);
775 }
776
777 /* Check if there was a timeout */
778 if(ret == 0)
779 {
780 unsigned char * newbuf;
781
782 realloc:
783 /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */
784 newbuf = realloc(buffer, buflen);
785 if(newbuf == NULL)
786 {
787 if(buffer)
788 free(buffer);
789 fprintf(stderr, "%s: Allocation failed\n", __FUNCTION__);
790 return(-1);
791 }
792 buffer = newbuf;
793
794 /* Try to read the results */
795 wrq.u.data.pointer = buffer;
796 wrq.u.data.flags = 0;
797 wrq.u.data.length = buflen;
798 if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
799 {
800 /* Check if buffer was too small (WE-17 only) */
801 if((errno == E2BIG) && (range.we_version_compiled > 16))
802 {
803 /* Some driver may return very large scan results, either
804 * because there are many cells, or because they have many
805 * large elements in cells (like IWEVCUSTOM). Most will
806 * only need the regular sized buffer. We now use a dynamic
807 * allocation of the buffer to satisfy everybody. Of course,
808 * as we don't know in advance the size of the array, we try
809 * various increasing sizes. Jean II */
810
811 /* Check if the driver gave us any hints. */
812 if(wrq.u.data.length > buflen)
813 buflen = wrq.u.data.length;
814 else
815 buflen *= 2;
816
817 /* Try again */
818 goto realloc;
819 }
820
821 /* Check if results not available yet */
822 if(errno == EAGAIN)
823 {
824 /* Restart timer for only 100ms*/
825 tv.tv_sec = 0;
826 tv.tv_usec = 100000;
827 timeout -= tv.tv_usec;
828 if(timeout > 0)
829 continue; /* Try again later */
830 }
831
832 /* Bad error */
833 free(buffer);
834 fprintf(stderr, "%-8.16s Failed to read scan data : %s\n\n",
835 ifname, strerror(errno));
836 return(-2);
837 }
838 else
839 /* We have the results, go to process them */
840 break;
841 }
842
843 /* In here, check if event and event type
844 * if scan event, read results. All errors bad & no reset timeout */
845 }
846
847 if(wrq.u.data.length)
848 {
849 struct iw_event iwe;
850 struct stream_descr stream;
851 struct iwscan_state state = { .ap_num = 1, .val_index = 0 };
852 int ret;
853
854 #ifdef DEBUG
855 /* Debugging code. In theory useless, because it's debugged ;-) */
856 int i;
857 printf("Scan result %d [%02X", wrq.u.data.length, buffer[0]);
858 for(i = 1; i < wrq.u.data.length; i++)
859 printf(":%02X", buffer[i]);
860 printf("]\n");
861 #endif
862 printf("%-8.16s Scan completed :\n", ifname);
863 iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length);
864 do
865 {
866 /* Extract an event and print it */
867 ret = iw_extract_event_stream(&stream, &iwe,
868 range.we_version_compiled);
869 if(ret > 0)
870 print_scanning_token(&stream, &iwe, &state,
871 &range, has_range);
872 }
873 while(ret > 0);
874 printf("\n");
875 }
876 else
877 printf("%-8.16s No scan results\n\n", ifname);
878
879 free(buffer);
880 return(0);
881 }
882
883 /*********************** FREQUENCIES/CHANNELS ***********************/
884
885 /*------------------------------------------------------------------*/
886 /*
887 * Print the number of channels and available frequency for the device
888 */
889 static int
890 print_freq_info(int skfd,
891 char * ifname,
892 char * args[], /* Command line args */
893 int count) /* Args count */
894 {
895 struct iwreq wrq;
896 struct iw_range range;
897 double freq;
898 int k;
899 int channel;
900 char buffer[128]; /* Temporary buffer */
901
902 /* Avoid "Unused parameter" warning */
903 args = args; count = count;
904
905 /* Get list of frequencies / channels */
906 if(iw_get_range_info(skfd, ifname, &range) < 0)
907 fprintf(stderr, "%-8.16s no frequency information.\n\n",
908 ifname);
909 else
910 {
911 if(range.num_frequency > 0)
912 {
913 printf("%-8.16s %d channels in total; available frequencies :\n",
914 ifname, range.num_channels);
915 /* Print them all */
916 for(k = 0; k < range.num_frequency; k++)
917 {
918 freq = iw_freq2float(&(range.freq[k]));
919 iw_print_freq_value(buffer, sizeof(buffer), freq);
920 printf(" Channel %.2d : %s\n",
921 range.freq[k].i, buffer);
922 }
923 }
924 else
925 printf("%-8.16s %d channels\n",
926 ifname, range.num_channels);
927
928 /* Get current frequency / channel and display it */
929 if(iw_get_ext(skfd, ifname, SIOCGIWFREQ, &wrq) >= 0)
930 {
931 freq = iw_freq2float(&(wrq.u.freq));
932 channel = iw_freq_to_channel(freq, &range);
933 iw_print_freq(buffer, sizeof(buffer),
934 freq, channel, wrq.u.freq.flags);
935 printf(" Current %s\n\n", buffer);
936 }
937 }
938 return(0);
939 }
940
941 /***************************** BITRATES *****************************/
942
943 /*------------------------------------------------------------------*/
944 /*
945 * Print the number of available bitrates for the device
946 */
947 static int
948 print_bitrate_info(int skfd,
949 char * ifname,
950 char * args[], /* Command line args */
951 int count) /* Args count */
952 {
953 struct iwreq wrq;
954 struct iw_range range;
955 int k;
956 char buffer[128];
957
958 /* Avoid "Unused parameter" warning */
959 args = args; count = count;
960
961 /* Extract range info */
962 if(iw_get_range_info(skfd, ifname, &range) < 0)
963 fprintf(stderr, "%-8.16s no bit-rate information.\n\n",
964 ifname);
965 else
966 {
967 if((range.num_bitrates > 0) && (range.num_bitrates <= IW_MAX_BITRATES))
968 {
969 printf("%-8.16s %d available bit-rates :\n",
970 ifname, range.num_bitrates);
971 /* Print them all */
972 for(k = 0; k < range.num_bitrates; k++)
973 {
974 iw_print_bitrate(buffer, sizeof(buffer), range.bitrate[k]);
975 /* Maybe this should be %10s */
976 printf("\t %s\n", buffer);
977 }
978 }
979 else
980 printf("%-8.16s unknown bit-rate information.\n", ifname);
981
982 /* Get current bit rate */
983 if(iw_get_ext(skfd, ifname, SIOCGIWRATE, &wrq) >= 0)
984 {
985 iw_print_bitrate(buffer, sizeof(buffer), wrq.u.bitrate.value);
986 printf(" Current Bit Rate%c%s\n",
987 (wrq.u.bitrate.fixed ? '=' : ':'), buffer);
988 }
989
990 /* Try to get the broadcast bitrate if it exist... */
991 if(range.bitrate_capa & IW_BITRATE_BROADCAST)
992 {
993 wrq.u.bitrate.flags = IW_BITRATE_BROADCAST;
994 if(iw_get_ext(skfd, ifname, SIOCGIWRATE, &wrq) >= 0)
995 {
996 iw_print_bitrate(buffer, sizeof(buffer), wrq.u.bitrate.value);
997 printf(" Broadcast Bit Rate%c%s\n",
998 (wrq.u.bitrate.fixed ? '=' : ':'), buffer);
999 }
1000 }
1001
1002 printf("\n");
1003 }
1004 return(0);
1005 }
1006
1007 /************************* ENCRYPTION KEYS *************************/
1008
1009 /*------------------------------------------------------------------*/
1010 /*
1011 * Print all the available encryption keys for the device
1012 */
1013 static int
1014 print_keys_info(int skfd,
1015 char * ifname,
1016 char * args[], /* Command line args */
1017 int count) /* Args count */
1018 {
1019 struct iwreq wrq;
1020 struct iw_range range;
1021 unsigned char key[IW_ENCODING_TOKEN_MAX];
1022 unsigned int k;
1023 char buffer[128];
1024
1025 /* Avoid "Unused parameter" warning */
1026 args = args; count = count;
1027
1028 /* Extract range info */
1029 if(iw_get_range_info(skfd, ifname, &range) < 0)
1030 fprintf(stderr, "%-8.16s no encryption keys information.\n\n",
1031 ifname);
1032 else
1033 {
1034 printf("%-8.16s ", ifname);
1035 /* Print key sizes */
1036 if((range.num_encoding_sizes > 0) &&
1037 (range.num_encoding_sizes < IW_MAX_ENCODING_SIZES))
1038 {
1039 printf("%d key sizes : %d", range.num_encoding_sizes,
1040 range.encoding_size[0] * 8);
1041 /* Print them all */
1042 for(k = 1; k < range.num_encoding_sizes; k++)
1043 printf(", %d", range.encoding_size[k] * 8);
1044 printf("bits\n ");
1045 }
1046 /* Print the keys and associate mode */
1047 printf("%d keys available :\n", range.max_encoding_tokens);
1048 for(k = 1; k <= range.max_encoding_tokens; k++)
1049 {
1050 wrq.u.data.pointer = (caddr_t) key;
1051 wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
1052 wrq.u.data.flags = k;
1053 if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) < 0)
1054 {
1055 fprintf(stderr, "Error reading wireless keys (SIOCGIWENCODE): %s\n", strerror(errno));
1056 break;
1057 }
1058 if((wrq.u.data.flags & IW_ENCODE_DISABLED) ||
1059 (wrq.u.data.length == 0))
1060 printf("\t\t[%d]: off\n", k);
1061 else
1062 {
1063 /* Display the key */
1064 iw_print_key(buffer, sizeof(buffer),
1065 key, wrq.u.data.length, wrq.u.data.flags);
1066 printf("\t\t[%d]: %s", k, buffer);
1067
1068 /* Other info... */
1069 printf(" (%d bits)", wrq.u.data.length * 8);
1070 printf("\n");
1071 }
1072 }
1073 /* Print current key index and mode */
1074 wrq.u.data.pointer = (caddr_t) key;
1075 wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
1076 wrq.u.data.flags = 0; /* Set index to zero to get current */
1077 if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) >= 0)
1078 {
1079 /* Note : if above fails, we have already printed an error
1080 * message int the loop above */
1081 printf(" Current Transmit Key: [%d]\n",
1082 wrq.u.data.flags & IW_ENCODE_INDEX);
1083 if(wrq.u.data.flags & IW_ENCODE_RESTRICTED)
1084 printf(" Security mode:restricted\n");
1085 if(wrq.u.data.flags & IW_ENCODE_OPEN)
1086 printf(" Security mode:open\n");
1087 }
1088
1089 printf("\n\n");
1090 }
1091 return(0);
1092 }
1093
1094 /************************* POWER MANAGEMENT *************************/
1095
1096 /*------------------------------------------------------------------*/
1097 /*
1098 * Print Power Management info for each device
1099 */
1100 static int
1101 get_pm_value(int skfd,
1102 char * ifname,
1103 struct iwreq * pwrq,
1104 int flags,
1105 char * buffer,
1106 int buflen,
1107 int we_version_compiled)
1108 {
1109 /* Get Another Power Management value */
1110 pwrq->u.power.flags = flags;
1111 if(iw_get_ext(skfd, ifname, SIOCGIWPOWER, pwrq) >= 0)
1112 {
1113 /* Let's check the value and its type */
1114 if(pwrq->u.power.flags & IW_POWER_TYPE)
1115 {
1116 iw_print_pm_value(buffer, buflen,
1117 pwrq->u.power.value, pwrq->u.power.flags,
1118 we_version_compiled);
1119 printf("\n %s", buffer);
1120 }
1121 }
1122 return(pwrq->u.power.flags);
1123 }
1124
1125 /*------------------------------------------------------------------*/
1126 /*
1127 * Print Power Management range for each type
1128 */
1129 static void
1130 print_pm_value_range(char * name,
1131 int mask,
1132 int iwr_flags,
1133 int iwr_min,
1134 int iwr_max,
1135 char * buffer,
1136 int buflen,
1137 int we_version_compiled)
1138 {
1139 if(iwr_flags & mask)
1140 {
1141 int flags = (iwr_flags & ~(IW_POWER_MIN | IW_POWER_MAX));
1142 /* Display if auto or fixed */
1143 printf("%s %s ; ",
1144 (iwr_flags & IW_POWER_MIN) ? "Auto " : "Fixed",
1145 name);
1146 /* Print the range */
1147 iw_print_pm_value(buffer, buflen,
1148 iwr_min, flags | IW_POWER_MIN,
1149 we_version_compiled);
1150 printf("%s\n ", buffer);
1151 iw_print_pm_value(buffer, buflen,
1152 iwr_max, flags | IW_POWER_MAX,
1153 we_version_compiled);
1154 printf("%s\n ", buffer);
1155 }
1156 }
1157
1158 /*------------------------------------------------------------------*/
1159 /*
1160 * Power Management types of values
1161 */
1162 static const unsigned int pm_type_flags[] = {
1163 IW_POWER_PERIOD,
1164 IW_POWER_TIMEOUT,
1165 IW_POWER_SAVING,
1166 };
1167 static const int pm_type_flags_size = (sizeof(pm_type_flags)/sizeof(pm_type_flags[0]));
1168
1169 /*------------------------------------------------------------------*/
1170 /*
1171 * Print Power Management info for each device
1172 */
1173 static int
1174 print_pm_info(int skfd,
1175 char * ifname,
1176 char * args[], /* Command line args */
1177 int count) /* Args count */
1178 {
1179 struct iwreq wrq;
1180 struct iw_range range;
1181 char buffer[128];
1182
1183 /* Avoid "Unused parameter" warning */
1184 args = args; count = count;
1185
1186 /* Extract range info */
1187 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1188 (range.we_version_compiled < 10))
1189 fprintf(stderr, "%-8.16s no power management information.\n\n",
1190 ifname);
1191 else
1192 {
1193 printf("%-8.16s ", ifname);
1194
1195 /* Display modes availables */
1196 if(range.pm_capa & IW_POWER_MODE)
1197 {
1198 printf("Supported modes :\n ");
1199 if(range.pm_capa & (IW_POWER_UNICAST_R | IW_POWER_MULTICAST_R))
1200 printf("\t\to Receive all packets (unicast & multicast)\n ");
1201 if(range.pm_capa & IW_POWER_UNICAST_R)
1202 printf("\t\to Receive Unicast only (discard multicast)\n ");
1203 if(range.pm_capa & IW_POWER_MULTICAST_R)
1204 printf("\t\to Receive Multicast only (discard unicast)\n ");
1205 if(range.pm_capa & IW_POWER_FORCE_S)
1206 printf("\t\to Force sending using Power Management\n ");
1207 if(range.pm_capa & IW_POWER_REPEATER)
1208 printf("\t\to Repeat multicast\n ");
1209 }
1210 /* Display min/max period availables */
1211 print_pm_value_range("period ", IW_POWER_PERIOD,
1212 range.pmp_flags, range.min_pmp, range.max_pmp,
1213 buffer, sizeof(buffer), range.we_version_compiled);
1214 /* Display min/max timeout availables */
1215 print_pm_value_range("timeout", IW_POWER_TIMEOUT,
1216 range.pmt_flags, range.min_pmt, range.max_pmt,
1217 buffer, sizeof(buffer), range.we_version_compiled);
1218 /* Display min/max saving availables */
1219 print_pm_value_range("saving ", IW_POWER_SAVING,
1220 range.pms_flags, range.min_pms, range.max_pms,
1221 buffer, sizeof(buffer), range.we_version_compiled);
1222
1223 /* Get current Power Management settings */
1224 wrq.u.power.flags = 0;
1225 if(iw_get_ext(skfd, ifname, SIOCGIWPOWER, &wrq) >= 0)
1226 {
1227 int flags = wrq.u.power.flags;
1228
1229 /* Is it disabled ? */
1230 if(wrq.u.power.disabled)
1231 printf("Current mode:off\n");
1232 else
1233 {
1234 unsigned int pm_type = 0;
1235 unsigned int pm_mask = 0;
1236 unsigned int remain_mask = range.pm_capa & IW_POWER_TYPE;
1237 int i = 0;
1238
1239 /* Let's check the mode */
1240 iw_print_pm_mode(buffer, sizeof(buffer), flags);
1241 printf("Current %s", buffer);
1242
1243 /* Let's check if nothing (simply on) */
1244 if((flags & IW_POWER_MODE) == IW_POWER_ON)
1245 printf("mode:on");
1246
1247 /* Let's check the value and its type */
1248 if(wrq.u.power.flags & IW_POWER_TYPE)
1249 {
1250 iw_print_pm_value(buffer, sizeof(buffer),
1251 wrq.u.power.value, wrq.u.power.flags,
1252 range.we_version_compiled);
1253 printf("\n %s", buffer);
1254 }
1255
1256 while(1)
1257 {
1258 /* Deal with min/max for the current value */
1259 pm_mask = 0;
1260 /* If we have been returned a MIN value, ask for the MAX */
1261 if(flags & IW_POWER_MIN)
1262 pm_mask = IW_POWER_MAX;
1263 /* If we have been returned a MAX value, ask for the MIN */
1264 if(flags & IW_POWER_MAX)
1265 pm_mask = IW_POWER_MIN;
1266 /* If we have something to ask for... */
1267 if(pm_mask)
1268 {
1269 pm_mask |= pm_type;
1270 get_pm_value(skfd, ifname, &wrq, pm_mask,
1271 buffer, sizeof(buffer),
1272 range.we_version_compiled);
1273 }
1274
1275 /* Remove current type from mask */
1276 remain_mask &= ~(wrq.u.power.flags);
1277
1278 /* Check what other types we still have to read */
1279 while(i < pm_type_flags_size)
1280 {
1281 pm_type = remain_mask & pm_type_flags[i];
1282 if(pm_type)
1283 break;
1284 i++;
1285 }
1286 /* Nothing anymore : exit the loop */
1287 if(!pm_type)
1288 break;
1289
1290 /* Ask for this other type of value */
1291 flags = get_pm_value(skfd, ifname, &wrq, pm_type,
1292 buffer, sizeof(buffer),
1293 range.we_version_compiled);
1294 /* Loop back for min/max */
1295 }
1296 printf("\n");
1297 }
1298 }
1299 printf("\n");
1300 }
1301 return(0);
1302 }
1303
1304 #ifndef WE_ESSENTIAL
1305 /************************** TRANSMIT POWER **************************/
1306
1307 /*------------------------------------------------------------------*/
1308 /*
1309 * Print the number of available transmit powers for the device
1310 */
1311 static int
1312 print_txpower_info(int skfd,
1313 char * ifname,
1314 char * args[], /* Command line args */
1315 int count) /* Args count */
1316 {
1317 struct iwreq wrq;
1318 struct iw_range range;
1319 int dbm;
1320 int mwatt;
1321 int k;
1322
1323 /* Avoid "Unused parameter" warning */
1324 args = args; count = count;
1325
1326 /* Extract range info */
1327 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1328 (range.we_version_compiled < 10))
1329 fprintf(stderr, "%-8.16s no transmit-power information.\n\n",
1330 ifname);
1331 else
1332 {
1333 if((range.num_txpower <= 0) || (range.num_txpower > IW_MAX_TXPOWER))
1334 printf("%-8.16s unknown transmit-power information.\n\n", ifname);
1335 else
1336 {
1337 printf("%-8.16s %d available transmit-powers :\n",
1338 ifname, range.num_txpower);
1339 /* Print them all */
1340 for(k = 0; k < range.num_txpower; k++)
1341 {
1342 /* Check for relative values */
1343 if(range.txpower_capa & IW_TXPOW_RELATIVE)
1344 {
1345 printf("\t %d (no units)\n", range.txpower[k]);
1346 }
1347 else
1348 {
1349 if(range.txpower_capa & IW_TXPOW_MWATT)
1350 {
1351 dbm = iw_mwatt2dbm(range.txpower[k]);
1352 mwatt = range.txpower[k];
1353 }
1354 else
1355 {
1356 dbm = range.txpower[k];
1357 mwatt = iw_dbm2mwatt(range.txpower[k]);
1358 }
1359 printf("\t %d dBm \t(%d mW)\n", dbm, mwatt);
1360 }
1361 }
1362 }
1363
1364 /* Get current Transmit Power */
1365 if(iw_get_ext(skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
1366 {
1367 printf(" Current Tx-Power");
1368 /* Disabled ? */
1369 if(wrq.u.txpower.disabled)
1370 printf(":off\n\n");
1371 else
1372 {
1373 /* Fixed ? */
1374 if(wrq.u.txpower.fixed)
1375 printf("=");
1376 else
1377 printf(":");
1378 /* Check for relative values */
1379 if(wrq.u.txpower.flags & IW_TXPOW_RELATIVE)
1380 {
1381 /* I just hate relative value, because they are
1382 * driver specific, so not very meaningfull to apps.
1383 * But, we have to support that, because
1384 * this is the way hardware is... */
1385 printf("\t %d (no units)\n", wrq.u.txpower.value);
1386 }
1387 else
1388 {
1389 if(wrq.u.txpower.flags & IW_TXPOW_MWATT)
1390 {
1391 dbm = iw_mwatt2dbm(wrq.u.txpower.value);
1392 mwatt = wrq.u.txpower.value;
1393 }
1394 else
1395 {
1396 dbm = wrq.u.txpower.value;
1397 mwatt = iw_dbm2mwatt(wrq.u.txpower.value);
1398 }
1399 printf("%d dBm \t(%d mW)\n\n", dbm, mwatt);
1400 }
1401 }
1402 }
1403 }
1404 return(0);
1405 }
1406
1407 /*********************** RETRY LIMIT/LIFETIME ***********************/
1408
1409 /*------------------------------------------------------------------*/
1410 /*
1411 * Print one retry value
1412 */
1413 static int
1414 get_retry_value(int skfd,
1415 char * ifname,
1416 struct iwreq * pwrq,
1417 int flags,
1418 char * buffer,
1419 int buflen,
1420 int we_version_compiled)
1421 {
1422 /* Get Another retry value */
1423 pwrq->u.retry.flags = flags;
1424 if(iw_get_ext(skfd, ifname, SIOCGIWRETRY, pwrq) >= 0)
1425 {
1426 /* Let's check the value and its type */
1427 if(pwrq->u.retry.flags & IW_RETRY_TYPE)
1428 {
1429 iw_print_retry_value(buffer, buflen,
1430 pwrq->u.retry.value, pwrq->u.retry.flags,
1431 we_version_compiled);
1432 printf("%s\n ", buffer);
1433 }
1434 }
1435 return(pwrq->u.retry.flags);
1436 }
1437
1438 /*------------------------------------------------------------------*/
1439 /*
1440 * Print Power Management range for each type
1441 */
1442 static void
1443 print_retry_value_range(char * name,
1444 int mask,
1445 int iwr_flags,
1446 int iwr_min,
1447 int iwr_max,
1448 char * buffer,
1449 int buflen,
1450 int we_version_compiled)
1451 {
1452 if(iwr_flags & mask)
1453 {
1454 int flags = (iwr_flags & ~(IW_RETRY_MIN | IW_RETRY_MAX));
1455 /* Display if auto or fixed */
1456 printf("%s %s ; ",
1457 (iwr_flags & IW_POWER_MIN) ? "Auto " : "Fixed",
1458 name);
1459 /* Print the range */
1460 iw_print_retry_value(buffer, buflen,
1461 iwr_min, flags | IW_POWER_MIN,
1462 we_version_compiled);
1463 printf("%s\n ", buffer);
1464 iw_print_retry_value(buffer, buflen,
1465 iwr_max, flags | IW_POWER_MAX,
1466 we_version_compiled);
1467 printf("%s\n ", buffer);
1468 }
1469 }
1470
1471 /*------------------------------------------------------------------*/
1472 /*
1473 * Print Retry info for each device
1474 */
1475 static int
1476 print_retry_info(int skfd,
1477 char * ifname,
1478 char * args[], /* Command line args */
1479 int count) /* Args count */
1480 {
1481 struct iwreq wrq;
1482 struct iw_range range;
1483 char buffer[128];
1484
1485 /* Avoid "Unused parameter" warning */
1486 args = args; count = count;
1487
1488 /* Extract range info */
1489 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1490 (range.we_version_compiled < 11))
1491 fprintf(stderr, "%-8.16s no retry limit/lifetime information.\n\n",
1492 ifname);
1493 else
1494 {
1495 printf("%-8.16s ", ifname);
1496
1497 /* Display min/max limit availables */
1498 print_retry_value_range("limit ", IW_RETRY_LIMIT, range.retry_flags,
1499 range.min_retry, range.max_retry,
1500 buffer, sizeof(buffer),
1501 range.we_version_compiled);
1502 /* Display min/max lifetime availables */
1503 print_retry_value_range("lifetime", IW_RETRY_LIFETIME,
1504 range.r_time_flags,
1505 range.min_r_time, range.max_r_time,
1506 buffer, sizeof(buffer),
1507 range.we_version_compiled);
1508
1509 /* Get current retry settings */
1510 wrq.u.retry.flags = 0;
1511 if(iw_get_ext(skfd, ifname, SIOCGIWRETRY, &wrq) >= 0)
1512 {
1513 int flags = wrq.u.retry.flags;
1514
1515 /* Is it disabled ? */
1516 if(wrq.u.retry.disabled)
1517 printf("Current mode:off\n ");
1518 else
1519 {
1520 unsigned int retry_type = 0;
1521 unsigned int retry_mask = 0;
1522 unsigned int remain_mask = range.retry_capa & IW_RETRY_TYPE;
1523
1524 /* Let's check the mode */
1525 printf("Current mode:on\n ");
1526
1527 /* Let's check the value and its type */
1528 if(wrq.u.retry.flags & IW_RETRY_TYPE)
1529 {
1530 iw_print_retry_value(buffer, sizeof(buffer),
1531 wrq.u.retry.value, wrq.u.retry.flags,
1532 range.we_version_compiled);
1533 printf("%s\n ", buffer);
1534 }
1535
1536 while(1)
1537 {
1538 /* Deal with min/max/short/long for the current value */
1539 retry_mask = 0;
1540 /* If we have been returned a MIN value, ask for the MAX */
1541 if(flags & IW_RETRY_MIN)
1542 retry_mask = IW_RETRY_MAX;
1543 /* If we have been returned a MAX value, ask for the MIN */
1544 if(flags & IW_RETRY_MAX)
1545 retry_mask = IW_RETRY_MIN;
1546 /* Same for SHORT and LONG */
1547 if(flags & IW_RETRY_SHORT)
1548 retry_mask = IW_RETRY_LONG;
1549 if(flags & IW_RETRY_LONG)
1550 retry_mask = IW_RETRY_SHORT;
1551 /* If we have something to ask for... */
1552 if(retry_mask)
1553 {
1554 retry_mask |= retry_type;
1555 get_retry_value(skfd, ifname, &wrq, retry_mask,
1556 buffer, sizeof(buffer),
1557 range.we_version_compiled);
1558 }
1559
1560 /* And if we have both a limit and a lifetime,
1561 * ask the other one */
1562 remain_mask &= ~(wrq.u.retry.flags);
1563 retry_type = remain_mask;
1564 /* Nothing anymore : exit the loop */
1565 if(!retry_type)
1566 break;
1567
1568 /* Ask for this other type of value */
1569 flags = get_retry_value(skfd, ifname, &wrq, retry_type,
1570 buffer, sizeof(buffer),
1571 range.we_version_compiled);
1572 /* Loop back for min/max/short/long */
1573 }
1574 }
1575 }
1576 printf("\n");
1577 }
1578 return(0);
1579 }
1580
1581 /************************ ACCESS POINT LIST ************************/
1582 /*
1583 * Note : now that we have scanning support, this is depracted and
1584 * won't survive long. Actually, next version it's out !
1585 */
1586
1587 /*------------------------------------------------------------------*/
1588 /*
1589 * Display the list of ap addresses and the associated stats
1590 * Exacly the same as the spy list, only with different IOCTL and messages
1591 */
1592 static int
1593 print_ap_info(int skfd,
1594 char * ifname,
1595 char * args[], /* Command line args */
1596 int count) /* Args count */
1597 {
1598 struct iwreq wrq;
1599 char buffer[(sizeof(struct iw_quality) +
1600 sizeof(struct sockaddr)) * IW_MAX_AP];
1601 char temp[128];
1602 struct sockaddr * hwa;
1603 struct iw_quality * qual;
1604 iwrange range;
1605 int has_range = 0;
1606 int has_qual = 0;
1607 int n;
1608 int i;
1609
1610 /* Avoid "Unused parameter" warning */
1611 args = args; count = count;
1612
1613 /* Collect stats */
1614 wrq.u.data.pointer = (caddr_t) buffer;
1615 wrq.u.data.length = IW_MAX_AP;
1616 wrq.u.data.flags = 0;
1617 if(iw_get_ext(skfd, ifname, SIOCGIWAPLIST, &wrq) < 0)
1618 {
1619 fprintf(stderr, "%-8.16s Interface doesn't have a list of Peers/Access-Points\n\n", ifname);
1620 return(-1);
1621 }
1622
1623 /* Number of addresses */
1624 n = wrq.u.data.length;
1625 has_qual = wrq.u.data.flags;
1626
1627 /* The two lists */
1628 hwa = (struct sockaddr *) buffer;
1629 qual = (struct iw_quality *) (buffer + (sizeof(struct sockaddr) * n));
1630
1631 /* Check if we have valid mac address type */
1632 if(iw_check_mac_addr_type(skfd, ifname) < 0)
1633 {
1634 fprintf(stderr, "%-8.16s Interface doesn't support MAC addresses\n\n", ifname);
1635 return(-2);
1636 }
1637
1638 /* Get range info if we can */
1639 if(iw_get_range_info(skfd, ifname, &(range)) >= 0)
1640 has_range = 1;
1641
1642 /* Display it */
1643 if(n == 0)
1644 printf("%-8.16s No Peers/Access-Point in range\n", ifname);
1645 else
1646 printf("%-8.16s Peers/Access-Points in range:\n", ifname);
1647 for(i = 0; i < n; i++)
1648 {
1649 if(has_qual)
1650 {
1651 /* Print stats for this address */
1652 printf(" %s : ", iw_saether_ntop(&hwa[i], temp));
1653 iw_print_stats(temp, sizeof(buffer), &qual[i], &range, has_range);
1654 printf("%s\n", temp);
1655 }
1656 else
1657 /* Only print the address */
1658 printf(" %s\n", iw_saether_ntop(&hwa[i], temp));
1659 }
1660 printf("\n");
1661 return(0);
1662 }
1663
1664 /******************** WIRELESS EVENT CAPABILITY ********************/
1665
1666 static const char * event_capa_req[] =
1667 {
1668 [SIOCSIWNWID - SIOCIWFIRST] = "Set NWID (kernel generated)",
1669 [SIOCSIWFREQ - SIOCIWFIRST] = "Set Frequency/Channel (kernel generated)",
1670 [SIOCGIWFREQ - SIOCIWFIRST] = "New Frequency/Channel",
1671 [SIOCSIWMODE - SIOCIWFIRST] = "Set Mode (kernel generated)",
1672 [SIOCGIWTHRSPY - SIOCIWFIRST] = "Spy threshold crossed",
1673 [SIOCGIWAP - SIOCIWFIRST] = "New Access Point/Cell address - roaming",
1674 [SIOCGIWSCAN - SIOCIWFIRST] = "Scan request completed",
1675 [SIOCSIWESSID - SIOCIWFIRST] = "Set ESSID (kernel generated)",
1676 [SIOCGIWESSID - SIOCIWFIRST] = "New ESSID",
1677 [SIOCGIWRATE - SIOCIWFIRST] = "New bit-rate",
1678 [SIOCSIWENCODE - SIOCIWFIRST] = "Set Encoding (kernel generated)",
1679 [SIOCGIWPOWER - SIOCIWFIRST] = NULL,
1680 };
1681
1682 static const char * event_capa_evt[] =
1683 {
1684 [IWEVTXDROP - IWEVFIRST] = "Tx packet dropped - retry exceeded",
1685 [IWEVCUSTOM - IWEVFIRST] = "Custom driver event",
1686 [IWEVREGISTERED - IWEVFIRST] = "Registered node",
1687 [IWEVEXPIRED - IWEVFIRST] = "Expired node",
1688 };
1689
1690 /*------------------------------------------------------------------*/
1691 /*
1692 * Print the event capability for the device
1693 */
1694 static int
1695 print_event_capa_info(int skfd,
1696 char * ifname,
1697 char * args[], /* Command line args */
1698 int count) /* Args count */
1699 {
1700 struct iw_range range;
1701 int cmd;
1702
1703 /* Avoid "Unused parameter" warning */
1704 args = args; count = count;
1705
1706 /* Extract range info */
1707 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1708 (range.we_version_compiled < 10))
1709 fprintf(stderr, "%-8.16s no wireless event capability information.\n\n",
1710 ifname);
1711 else
1712 {
1713 #ifdef DEBUG
1714 /* Debugging ;-) */
1715 for(cmd = 0x8B00; cmd < 0x8C0F; cmd++)
1716 {
1717 int idx = IW_EVENT_CAPA_INDEX(cmd);
1718 int mask = IW_EVENT_CAPA_MASK(cmd);
1719 printf("0x%X - %d - %X\n", cmd, idx, mask);
1720 }
1721 #endif
1722
1723 printf("%-8.16s Wireless Events supported :\n", ifname);
1724
1725 for(cmd = SIOCIWFIRST; cmd <= SIOCGIWPOWER; cmd++)
1726 {
1727 int idx = IW_EVENT_CAPA_INDEX(cmd);
1728 int mask = IW_EVENT_CAPA_MASK(cmd);
1729 if(range.event_capa[idx] & mask)
1730 printf(" 0x%04X : %s\n",
1731 cmd, event_capa_req[cmd - SIOCIWFIRST]);
1732 }
1733 for(cmd = IWEVFIRST; cmd <= IWEVEXPIRED; cmd++)
1734 {
1735 int idx = IW_EVENT_CAPA_INDEX(cmd);
1736 int mask = IW_EVENT_CAPA_MASK(cmd);
1737 if(range.event_capa[idx] & mask)
1738 printf(" 0x%04X : %s\n",
1739 cmd, event_capa_evt[cmd - IWEVFIRST]);
1740 }
1741 printf("\n");
1742 }
1743 return(0);
1744 }
1745
1746 /*************************** WPA SUPPORT ***************************/
1747
1748 /*------------------------------------------------------------------*/
1749 /*
1750 * Print the authentication parameters for the device
1751 */
1752 static int
1753 print_auth_info(int skfd,
1754 char * ifname,
1755 char * args[], /* Command line args */
1756 int count) /* Args count */
1757 {
1758 struct iwreq wrq;
1759 struct iw_range range;
1760 unsigned int k;
1761
1762 /* Avoid "Unused parameter" warning */
1763 args = args; count = count;
1764
1765 /* Extract range info */
1766 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1767 (range.we_version_compiled < 18))
1768 fprintf(stderr, "%-8.16s no authentication information.\n\n",
1769 ifname);
1770 else
1771 {
1772 /* Print WPA/802.1x/802.11i security parameters */
1773 if(!range.enc_capa)
1774 {
1775 printf("%-8.16s unknown authentication information.\n\n", ifname);
1776 }
1777 else
1778 {
1779 /* Display advanced encryption capabilities */
1780 printf("%-8.16s Authentication capabilities :", ifname);
1781 iw_print_mask_name(range.enc_capa,
1782 iw_auth_capa_name, IW_AUTH_CAPA_NUM,
1783 "\n\t\t");
1784 printf("\n");
1785
1786 /* Extract all auth settings */
1787 for(k = 0; k < IW_AUTH_SETTINGS_NUM; k++)
1788 {
1789 wrq.u.param.flags = iw_auth_settings[k].value;
1790 if(iw_get_ext(skfd, ifname, SIOCGIWAUTH, &wrq) >= 0)
1791 {
1792 printf(" Current %s :", iw_auth_settings[k].label);
1793 if(iw_auth_settings[k].names != NULL)
1794 iw_print_mask_name(wrq.u.param.value,
1795 iw_auth_settings[k].names,
1796 iw_auth_settings[k].num_names,
1797 "\n\t\t");
1798 else
1799 printf((wrq.u.param.value) ? " yes" : " no");
1800 printf("\n");
1801 }
1802 }
1803 }
1804
1805 printf("\n\n");
1806 }
1807 return(0);
1808 }
1809
1810 /*------------------------------------------------------------------*/
1811 /*
1812 * Print all the available wpa keys for the device
1813 */
1814 static int
1815 print_wpakeys_info(int skfd,
1816 char * ifname,
1817 char * args[], /* Command line args */
1818 int count) /* Args count */
1819 {
1820 struct iwreq wrq;
1821 struct iw_range range;
1822 unsigned char extbuf[IW_EXTKEY_SIZE];
1823 struct iw_encode_ext *extinfo;
1824 unsigned int k;
1825 char buffer[128];
1826
1827 /* Avoid "Unused parameter" warning */
1828 args = args; count = count;
1829
1830 /* This always point to the same place */
1831 extinfo = (struct iw_encode_ext *) extbuf;
1832
1833 /* Extract range info */
1834 if(iw_get_range_info(skfd, ifname, &range) < 0)
1835 fprintf(stderr, "%-8.16s no wpa key information.\n\n",
1836 ifname);
1837 else
1838 {
1839 printf("%-8.16s ", ifname);
1840 /* Print key sizes */
1841 if((range.num_encoding_sizes > 0) &&
1842 (range.num_encoding_sizes < IW_MAX_ENCODING_SIZES))
1843 {
1844 printf("%d key sizes : %d", range.num_encoding_sizes,
1845 range.encoding_size[0] * 8);
1846 /* Print them all */
1847 for(k = 1; k < range.num_encoding_sizes; k++)
1848 printf(", %d", range.encoding_size[k] * 8);
1849 printf("bits\n ");
1850 }
1851
1852 /* Print the keys */
1853 printf("%d keys available :\n", range.max_encoding_tokens);
1854 for(k = 1; k <= range.max_encoding_tokens; k++)
1855 {
1856 /* Cleanup. Driver may not fill everything */
1857 memset(extbuf, '\0', IW_EXTKEY_SIZE);
1858
1859 /* Get whole struct containing one WPA key */
1860 wrq.u.data.pointer = (caddr_t) extbuf;
1861 wrq.u.data.length = IW_EXTKEY_SIZE;
1862 wrq.u.data.flags = k;
1863 if(iw_get_ext(skfd, ifname, SIOCGIWENCODEEXT, &wrq) < 0)
1864 {
1865 fprintf(stderr, "Error reading wpa keys (SIOCGIWENCODEEXT): %s\n", strerror(errno));
1866 break;
1867 }
1868
1869 /* Sanity check */
1870 if(wrq.u.data.length <
1871 (sizeof(struct iw_encode_ext) + extinfo->key_len))
1872 break;
1873
1874 /* Check if key is disabled */
1875 if((wrq.u.data.flags & IW_ENCODE_DISABLED) ||
1876 (extinfo->key_len == 0))
1877 printf("\t\t[%d]: off\n", k);
1878 else
1879 {
1880 /* Display the key */
1881 iw_print_key(buffer, sizeof(buffer),
1882 extinfo->key, extinfo->key_len, wrq.u.data.flags);
1883 printf("\t\t[%d]: %s", k, buffer);
1884
1885 /* Key size */
1886 printf(" (%d bits)", extinfo->key_len * 8);
1887 printf("\n");
1888
1889 /* Other info... */
1890 printf("\t\t Address: %s\n",
1891 iw_saether_ntop(&extinfo->addr, buffer));
1892
1893 printf("\t\t Algorithm:");
1894 iw_print_value_name(extinfo->alg,
1895 iw_encode_alg_name, IW_ENCODE_ALG_NUM);
1896
1897 printf("\n\t\t Flags: 0x%08x\n", extinfo->ext_flags);
1898 if (extinfo->ext_flags & IW_ENCODE_EXT_TX_SEQ_VALID)
1899 printf("\t\t tx-seq-valid\n");
1900 if (extinfo->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
1901 printf("\t\t rx-seq-valid\n");
1902 if (extinfo->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
1903 printf("\t\t group-key\n");
1904 }
1905 }
1906 /* Print current key index and mode */
1907 wrq.u.data.pointer = (caddr_t) extbuf;
1908 wrq.u.data.length = IW_EXTKEY_SIZE;
1909 wrq.u.data.flags = 0; /* Set index to zero to get current */
1910 if(iw_get_ext(skfd, ifname, SIOCGIWENCODEEXT, &wrq) >= 0)
1911 {
1912 /* Note : if above fails, we have already printed an error
1913 * message int the loop above */
1914 printf(" Current Transmit Key: [%d]\n",
1915 wrq.u.data.flags & IW_ENCODE_INDEX);
1916 if(wrq.u.data.flags & IW_ENCODE_RESTRICTED)
1917 printf(" Security mode:restricted\n");
1918 if(wrq.u.data.flags & IW_ENCODE_OPEN)
1919 printf(" Security mode:open\n");
1920 }
1921
1922 printf("\n\n");
1923 }
1924 return(0);
1925 }
1926
1927 /*------------------------------------------------------------------*/
1928 /*
1929 * Print the Generic IE for the device
1930 * Note : indentation is broken. We need to fix that.
1931 */
1932 static int
1933 print_gen_ie_info(int skfd,
1934 char * ifname,
1935 char * args[], /* Command line args */
1936 int count) /* Args count */
1937 {
1938 struct iwreq wrq;
1939 unsigned char buf[IW_GENERIC_IE_MAX];
1940
1941 /* Avoid "Unused parameter" warning */
1942 args = args; count = count;
1943
1944 wrq.u.data.pointer = (caddr_t)buf;
1945 wrq.u.data.length = IW_GENERIC_IE_MAX;
1946 wrq.u.data.flags = 0;
1947
1948 if(iw_get_ext(skfd, ifname, SIOCGIWGENIE, &wrq) < 0)
1949 fprintf(stderr, "%-8.16s no generic IE (%s).\n\n",
1950 ifname, strerror(errno));
1951 else
1952 {
1953 fprintf(stderr, "%-8.16s\n", ifname);
1954 if(wrq.u.data.length == 0)
1955 printf(" empty generic IE\n");
1956 else
1957 iw_print_gen_ie(buf, wrq.u.data.length);
1958 printf("\n");
1959 }
1960 return(0);
1961 }
1962
1963 /**************************** MODULATION ****************************/
1964
1965 /*------------------------------------------------------------------*/
1966 /*
1967 * Print Modulation info for each device
1968 */
1969 static int
1970 print_modul_info(int skfd,
1971 char * ifname,
1972 char * args[], /* Command line args */
1973 int count) /* Args count */
1974 {
1975 struct iwreq wrq;
1976 struct iw_range range;
1977
1978 /* Avoid "Unused parameter" warning */
1979 args = args; count = count;
1980
1981 /* Extract range info */
1982 if((iw_get_range_info(skfd, ifname, &range) < 0) ||
1983 (range.we_version_compiled < 11))
1984 fprintf(stderr, "%-8.16s no modulation information.\n\n",
1985 ifname);
1986 else
1987 {
1988 if(range.modul_capa == 0x0)
1989 printf("%-8.16s unknown modulation information.\n\n", ifname);
1990 else
1991 {
1992 int i;
1993 printf("%-8.16s Modulations available :\n", ifname);
1994
1995 /* Display each modulation available */
1996 for(i = 0; i < IW_SIZE_MODUL_LIST; i++)
1997 {
1998 if((range.modul_capa & iw_modul_list[i].mask)
1999 == iw_modul_list[i].mask)
2000 printf(" %-8s: %s\n",
2001 iw_modul_list[i].cmd, iw_modul_list[i].verbose);
2002 }
2003
2004 /* Get current modulations settings */
2005 wrq.u.param.flags = 0;
2006 if(iw_get_ext(skfd, ifname, SIOCGIWMODUL, &wrq) >= 0)
2007 {
2008 unsigned int modul = wrq.u.param.value;
2009 int n = 0;
2010
2011 printf(" Current modulations %c",
2012 wrq.u.param.fixed ? '=' : ':');
2013
2014 /* Display each modulation enabled */
2015 for(i = 0; i < IW_SIZE_MODUL_LIST; i++)
2016 {
2017 if((modul & iw_modul_list[i].mask) == iw_modul_list[i].mask)
2018 {
2019 if((n++ % 8) == 0)
2020 printf("\n ");
2021 else
2022 printf(" ; ");
2023 printf("%s", iw_modul_list[i].cmd);
2024 }
2025 }
2026
2027 printf("\n");
2028 }
2029 printf("\n");
2030 }
2031 }
2032 return(0);
2033 }
2034 #endif /* WE_ESSENTIAL */
2035
2036 /************************* COMMON UTILITIES *************************/
2037 /*
2038 * This section was initially written by Michael Tokarev <[email protected]>
2039 * but heavily modified by me ;-)
2040 */
2041
2042 /*------------------------------------------------------------------*/
2043 /*
2044 * Map command line arguments to the proper procedure...
2045 */
2046 typedef struct iwlist_entry {
2047 const char * cmd; /* Command line shorthand */
2048 iw_enum_handler fn; /* Subroutine */
2049 int max_count;
2050 const char * argsname; /* Args as human readable string */
2051 } iwlist_cmd;
2052
2053 static const struct iwlist_entry iwlist_cmds[] = {
2054 { "scanning", print_scanning_info, -1, "[essid NNN] [last]" },
2055 { "frequency", print_freq_info, 0, NULL },
2056 { "channel", print_freq_info, 0, NULL },
2057 { "bitrate", print_bitrate_info, 0, NULL },
2058 { "rate", print_bitrate_info, 0, NULL },
2059 { "encryption", print_keys_info, 0, NULL },
2060 { "keys", print_keys_info, 0, NULL },
2061 { "power", print_pm_info, 0, NULL },
2062 #ifndef WE_ESSENTIAL
2063 { "txpower", print_txpower_info, 0, NULL },
2064 { "retry", print_retry_info, 0, NULL },
2065 { "ap", print_ap_info, 0, NULL },
2066 { "accesspoints", print_ap_info, 0, NULL },
2067 { "peers", print_ap_info, 0, NULL },
2068 { "event", print_event_capa_info, 0, NULL },
2069 { "auth", print_auth_info, 0, NULL },
2070 { "wpakeys", print_wpakeys_info, 0, NULL },
2071 { "genie", print_gen_ie_info, 0, NULL },
2072 { "modulation", print_modul_info, 0, NULL },
2073 #endif /* WE_ESSENTIAL */
2074 { NULL, NULL, 0, 0 },
2075 };
2076
2077 /*------------------------------------------------------------------*/
2078 /*
2079 * Find the most appropriate command matching the command line
2080 */
2081 static inline const iwlist_cmd *
2082 find_command(const char * cmd)
2083 {
2084 const iwlist_cmd * found = NULL;
2085 int ambig = 0;
2086 unsigned int len = strlen(cmd);
2087 int i;
2088
2089 /* Go through all commands */
2090 for(i = 0; iwlist_cmds[i].cmd != NULL; ++i)
2091 {
2092 /* No match -> next one */
2093 if(strncasecmp(iwlist_cmds[i].cmd, cmd, len) != 0)
2094 continue;
2095
2096 /* Exact match -> perfect */
2097 if(len == strlen(iwlist_cmds[i].cmd))
2098 return &iwlist_cmds[i];
2099
2100 /* Partial match */
2101 if(found == NULL)
2102 /* First time */
2103 found = &iwlist_cmds[i];
2104 else
2105 /* Another time */
2106 if (iwlist_cmds[i].fn != found->fn)
2107 ambig = 1;
2108 }
2109
2110 if(found == NULL)
2111 {
2112 fprintf(stderr, "iwlist: unknown command `%s' (check 'iwlist --help').\n", cmd);
2113 return NULL;
2114 }
2115
2116 if(ambig)
2117 {
2118 fprintf(stderr, "iwlist: command `%s' is ambiguous (check 'iwlist --help').\n", cmd);
2119 return NULL;
2120 }
2121
2122 return found;
2123 }
2124
2125 /*------------------------------------------------------------------*/
2126 /*
2127 * Display help
2128 */
2129 static void iw_usage(int status)
2130 {
2131 FILE * f = status ? stderr : stdout;
2132 int i;
2133
2134 for(i = 0; iwlist_cmds[i].cmd != NULL; ++i)
2135 {
2136 fprintf(f, "%s [interface] %s %s\n",
2137 (i ? " " : "Usage: iwlist"),
2138 iwlist_cmds[i].cmd,
2139 iwlist_cmds[i].argsname ? iwlist_cmds[i].argsname : "");
2140 }
2141
2142 exit(status);
2143 }
2144
2145 /******************************* MAIN ********************************/
2146
2147 /*------------------------------------------------------------------*/
2148 /*
2149 * The main !
2150 */
2151 int
2152 main(int argc,
2153 char ** argv)
2154 {
2155 int skfd; /* generic raw socket desc. */
2156 char *dev; /* device name */
2157 char *cmd; /* command */
2158 char **args; /* Command arguments */
2159 int count; /* Number of arguments */
2160 const iwlist_cmd *iwcmd;
2161
2162 if(argc < 2)
2163 iw_usage(1);
2164
2165 /* Those don't apply to all interfaces */
2166 if((argc == 2) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
2167 iw_usage(0);
2168 if((argc == 2) && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")))
2169 return(iw_print_version_info("iwlist"));
2170
2171 if(argc == 2)
2172 {
2173 cmd = argv[1];
2174 dev = NULL;
2175 args = NULL;
2176 count = 0;
2177 }
2178 else
2179 {
2180 cmd = argv[2];
2181 dev = argv[1];
2182 args = argv + 3;
2183 count = argc - 3;
2184 }
2185
2186 /* find a command */
2187 iwcmd = find_command(cmd);
2188 if(iwcmd == NULL)
2189 return 1;
2190
2191 /* Check arg numbers */
2192 if((iwcmd->max_count >= 0) && (count > iwcmd->max_count))
2193 {
2194 fprintf(stderr, "iwlist: command `%s' needs fewer arguments (max %d)\n",
2195 iwcmd->cmd, iwcmd->max_count);
2196 return 1;
2197 }
2198
2199 /* Create a channel to the NET kernel. */
2200 if((skfd = iw_sockets_open()) < 0)
2201 {
2202 perror("socket");
2203 return -1;
2204 }
2205
2206 /* do the actual work */
2207 if (dev)
2208 (*iwcmd->fn)(skfd, dev, args, count);
2209 else
2210 iw_enum_devices(skfd, iwcmd->fn, args, count);
2211
2212 /* Close the socket. */
2213 iw_sockets_close(skfd);
2214
2215 return 0;
2216 }
+0
-143
src/lwe/iwmulticall.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPL 04
4 *
5 * Main code for "iwmulticall". This is a wrapper for the multicall version
6 * of the wireless tools.
7 * You need to link this code against "-lm".
8 * Thanks to Ned Ludd <[email protected]> for the inspiration...
9 *
10 * This file is released under the GPL license.
11 * Copyright (c) 1997-2004 Jean Tourrilhes <[email protected]>
12 */
13
14 /***************************** INCLUDES *****************************/
15
16 #include <libgen.h> /* Basename */
17
18 /**************************** PROTOTYPES ****************************/
19
20 /* Prototypes of the main of each tool */
21 extern int
22 main_iwconfig(int argc,
23 char ** argv);
24 extern int
25 main_iwlist(int argc,
26 char ** argv);
27 extern int
28 main_iwspy(int argc,
29 char ** argv);
30 extern int
31 main_iwpriv(int argc,
32 char ** argv);
33 extern int
34 main_iwgetid(int argc,
35 char ** argv);
36
37 /************************** MULTICALL HACK **************************/
38 /*
39 * The idea for multicall is to put all the tools and the library in
40 * the same binary. This way, you can save the overhead of the library,
41 * of each tool, can better optimise the code and throw away the stuff
42 * you don't need from the library.
43 * This almost divide the size of the tools by two (without stripping).
44 * On the down side, you no longer have the libiw for other tools to
45 * use, but for the target systems (embedded), this doesn't matter
46 * much, as they just need to configure the card...
47 * Note that splitting the lib and the multicall tools would not
48 * make sense, as most gains are found in the inclusion of the lib...
49 *
50 * Our strategy is to include directly the *.c, rather than compile
51 * them separatly. This allow to simplify compilation and hide the
52 * multicall tweaks from the other tools.
53 * Yeah, this leads to a bit a preprocessor abuse...
54 * Jean II
55 */
56
57 /* We need the library */
58 #include "iwlib.c"
59
60 /* Get iwconfig in there. Mandatory. */
61 #define main(args...) main_iwconfig(args)
62 #define iw_usage(args...) iwconfig_usage(args)
63 #define find_command(args...) iwconfig_find_command(args)
64 #include "iwconfig.c"
65 #undef find_command
66 #undef iw_usage
67 #undef main
68
69 /* Get iwlist in there. Scanning support is pretty sweet. */
70 #define main(args...) main_iwlist(args)
71 #define iw_usage(args...) iwlist_usage(args)
72 #define find_command(args...) iwlist_find_command(args)
73 #include "iwlist.c"
74 #undef find_command
75 #undef iw_usage
76 #undef main
77
78 #ifndef WE_ESSENTIAL
79 /* Get iwspy in there, it's not that big. */
80 #define main(args...) main_iwspy(args)
81 #include "iwspy.c"
82 #undef main
83 #endif /* WE_ESSENTIAL */
84
85 /* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
86 #define main(args...) main_iwpriv(args)
87 #define iw_usage(args...) iwpriv_usage(args)
88 #include "iwpriv.c"
89 #undef iw_usage
90 #undef main
91
92 /* Do we really need iwgetid ? Well, it's not like it's a big one */
93 #define main(args...) main_iwgetid(args)
94 #define iw_usage(args...) iwgetid_usage(args)
95 #include "iwgetid.c"
96 #undef iw_usage
97 #undef main
98
99 /* iwevent is useless for most people, don't grab it ? */
100
101 /* ifrename is big and useless for those systems */
102
103
104 /******************************* MAIN ********************************/
105
106 /*------------------------------------------------------------------*/
107 /*
108 * The main !
109 */
110 int
111 main(int argc,
112 char ** argv)
113 {
114 char * call_name = basename(argv[0]); /* Strip path */
115
116 /* This is a testing hack */
117 if(!strcmp(call_name, "iwmulticall") && (argc > 0))
118 {
119 argv++;
120 argc--;
121 call_name = basename(argv[0]);
122 }
123
124 /* Just check the name under which we were called... */
125
126 if(!strcmp(call_name, "iwconfig"))
127 return(main_iwconfig(argc, argv));
128 if(!strcmp(call_name, "iwlist"))
129 return(main_iwlist(argc, argv));
130 #ifndef WE_ESSENTIAL
131 if(!strcmp(call_name, "iwspy"))
132 return(main_iwspy(argc, argv));
133 #endif /* WE_ESSENTIAL */
134 if(!strcmp(call_name, "iwpriv"))
135 return(main_iwpriv(argc, argv));
136 if(!strcmp(call_name, "iwgetid"))
137 return(main_iwgetid(argc, argv));
138
139 /* Uh oh... Not supposed to come here. */
140 printf("iwmulticall : you are not supposed to call me this way...\n");
141 return(0);
142 }
+0
-118
src/lwe/iwpriv.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwpriv.8
2 .\"
3 .TH IWPRIV 8 "31 October 1996" "net-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iwpriv \- configure optionals (private) parameters of a wireless
9 network interface
10 .\"
11 .\" SYNOPSIS part
12 .\"
13 .SH SYNOPSIS
14 .BI "iwpriv [" interface ]
15 .br
16 .BI "iwpriv " "interface private-command " "[" private-parameters ]
17 .br
18 .BI "iwpriv " "interface private-command " [ I "] [" private-parameters ]
19 .br
20 .BI "iwpriv " interface " --all"
21 .\"
22 .\" DESCRIPTION part
23 .\"
24 .SH DESCRIPTION
25 .B Iwpriv
26 is the companion tool to
27 .IR iwconfig (8).
28 .B Iwpriv
29 deals with parameters and setting specific to each driver (as opposed to
30 .I iwconfig
31 which deals with generic ones).
32 .PP
33 Without any argument,
34 .B iwpriv
35 list the available private commands available on each interface, and
36 the parameters that they require. Using this information, the user may
37 apply those interface specific commands on the specified interface.
38 .PP
39 In theory, the documentation of each device driver should indicate how
40 to use those interface specific commands and their effect.
41 .\"
42 .\" PARAMETER part
43 .\"
44 .SH PARAMETERS
45 .TP
46 .IR private-command " [" private-parameters ]
47 Execute the specified
48 .I private-command
49 on the interface.
50 .br
51 The command may optionally take or require arguments, and may display
52 information. Therefore, the command line parameters may or may not be
53 needed and should match the command expectations. The list of commands
54 that
55 .B iwpriv
56 displays (when called without argument) should give you some hints
57 about those parameters.
58 .br
59 However you should refer to the device driver documentation for
60 information on how to properly use the command and the effect.
61 .TP
62 .IR "private-command " [ I "] [" private-parameters ]
63 Idem, except that
64 .I I
65 (an integer) is passed to the command as a
66 .IR "Token Index" .
67 Only some command will use the Token Index (most will ignore it), and
68 the driver documentation should tell you when it's needed.
69 .TP
70 .BR -a / --all
71 Execute and display all the private commands that don't take any
72 arguments (i.e. read only).
73 .\"
74 .\" DISPLAY part
75 .\"
76 .SH DISPLAY
77 For each device which support private commands,
78 .I iwpriv
79 will display the list of private commands available.
80 .PP
81 This include the name of the private command, the number or arguments
82 that may be set and their type, and the number or arguments that may
83 be display and their type.
84 .PP
85 For example, you may have the following display :
86 .br
87 .B "eth0 Available private ioctl :"
88 .br
89 .B " setqualthr (89F0) : set 1 byte & get 0"
90 .br
91 .B " gethisto (89F7) : set 0 & get 16 int"
92 .PP
93 This indicate that you may set the quality threshold and display an
94 histogram of up to 16 values with the following commands :
95 .br
96 .I " iwpriv eth0 setqualthr 20"
97 .br
98 .I " iwpriv eth0 gethisto"
99 .\"
100 .\" AUTHOR part
101 .\"
102 .SH AUTHOR
103 Jean Tourrilhes \- [email protected]
104 .\"
105 .\" FILES part
106 .\"
107 .SH FILES
108 .I /proc/net/wireless
109 .\"
110 .\" SEE ALSO part
111 .\"
112 .SH SEE ALSO
113 .BR iwconfig (8),
114 .BR iwlist (8),
115 .BR iwevent (8),
116 .BR iwspy (8),
117 .BR wireless (7).
+0
-977
src/lwe/iwpriv.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPLB 97->99 - HPL 99->07
4 *
5 * Main code for "iwconfig". This is the generic tool for most
6 * manipulations...
7 * You need to link this code against "iwlib.c" and "-lm".
8 *
9 * This file is released under the GPL license.
10 * Copyright (c) 1997-2007 Jean Tourrilhes <[email protected]>
11 */
12
13 #include "iwlib.h" /* Header */
14
15 /************************** DOCUMENTATION **************************/
16
17 /*
18 * BASIC PRINCIPLE
19 * ---------------
20 * Wireless Extension recognise that each wireless device has some
21 * specific features not covered by the standard wireless extensions.
22 * Private wireless ioctls/requests allow a device to export the control
23 * of those device specific features, and allow users to directly interact
24 * with your driver.
25 * There are many other ways you can implement such functionality :
26 * o module parameters
27 * o netlink socket
28 * o file system (/proc/ or /sysfs/)
29 * o extra character device (/dev/)
30 * Private wireless ioctls is one of the simplest implementation,
31 * however it is limited, so you may want to check the alternatives.
32 *
33 * Like for standard Wireless Extensions, each private wireless
34 * request is identified by an IOCTL NUMBER and carry a certain number
35 * of arguments (SET or GET).
36 * The driver exports a description of those requests (ioctl number,
37 * request name, set and get arguments). Then, iwpriv uses those request
38 * descriptions to call the appropriate request and handle the
39 * arguments.
40 *
41 * IOCTL RANGES :
42 * ------------
43 * The initial implementation of iwpriv was using the SIOCDEVPRIVATE
44 * ioctl range (up to 16 ioctls - driver specific). However, this was
45 * causing some compatibility problems with other usages of those
46 * ioctls, and those ioctls are supposed to be removed.
47 * Therefore, I created a new ioctl range, at SIOCIWFIRSTPRIV. Those
48 * ioctls are specific to Wireless Extensions, so you don't have to
49 * worry about collisions with other usages. On the other hand, in the
50 * new range, the SET convention is enforced (see below).
51 * The differences are : SIOCDEVPRIVATE SIOCIWFIRSTPRIV
52 * o availability <= 2.5.X WE > 11 (>= 2.4.13)
53 * o collisions yes no
54 * o SET convention optional enforced
55 * o number 16 32
56 *
57 * NEW DRIVER API :
58 * --------------
59 * Wireless Extension 13 introduces a new driver API. Wireless
60 * Extensions requests can be handled via a iw_handler table instead
61 * of through the regular ioctl handler.
62 * The new driver API can be handled only with the new ioctl range
63 * and enforces the GET convention (see below).
64 * The differences are : old API new API
65 * o handler do_ioctl() struct iw_handler_def
66 * o SIOCIWFIRSTPRIV WE > 11 yes
67 * o SIOCDEVPRIVATE yes no
68 * o GET convention optional enforced
69 * Note that the new API before Wireless Extension 15 contains bugs
70 * when handling sub-ioctls and addr/float data types.
71 *
72 * INLINING vs. POINTER :
73 * --------------------
74 * One of the tricky aspect of the old driver API is how the data
75 * is handled, which is how the driver is supposed to extract the data
76 * passed to it by iwpriv.
77 * 1) If the data has a fixed size (private ioctl definition
78 * has the flag IW_PRIV_SIZE_FIXED) and the byte size of the data is
79 * lower than 16 bytes, the data will be inlined. The driver can extract
80 * data in the field 'u.name' of the struct iwreq.
81 * 2) If the if the data doesn't have a fixed size or is larger than
82 * 16 bytes, the data is passed by pointer. struct iwreq contains a
83 * struct iwpoint with a user space pointer to the data. Appropriate
84 * copy_from/to_user() function should be used.
85 *
86 * With the new API, this is handled transparently, the data is
87 * always available as the fourth argument of the request handler
88 * (usually called 'extra').
89 *
90 * SET/GET CONVENTION :
91 * ------------------
92 * Simplistic summary :
93 * o even numbered ioctls are SET, restricted to root, and should not
94 * return arguments (get_args = 0).
95 * o odd numbered ioctls are GET, authorised to anybody, and should
96 * not expect any arguments (set_args = 0).
97 *
98 * The regular Wireless Extensions use the SET/GET convention, where
99 * the low order bit identify a SET (0) or a GET (1) request. The private
100 * Wireless Extension is not as restrictive, but still has some
101 * limitations.
102 * The new ioctl range enforces the SET convention : SET request will
103 * be available to root only and can't return any arguments. If you don't
104 * like that, just use every other two ioctl.
105 * The new driver API enforce the GET convention : GET request won't
106 * be able to accept any arguments (except if its fits within (union
107 * iwreq_data)). If you don't like that, you can either use the Token Index
108 * support or the old API (aka the ioctl handler).
109 * In any case, it's a good idea to not have ioctl with both SET
110 * and GET arguments. If the GET arguments doesn't fit within
111 * (union iwreq_data) and SET do, or vice versa, the current code in iwpriv
112 * won't work. One exception is if both SET and GET arguments fit within
113 * (union iwreq_data), this case should be handled safely in a GET
114 * request.
115 * If you don't fully understand those limitations, just follow the
116 * rules of the simplistic summary ;-)
117 *
118 * SUB-IOCTLS :
119 * ----------
120 * Wireless Extension 15 introduces sub-ioctls. For some applications,
121 * 32 ioctls is not enough, and this simple mechanism allows to increase
122 * the number of ioctls by adding a sub-ioctl index to some of the ioctls
123 * (so basically it's a two level addressing).
124 * One might argue that at the point, some other mechanisms might be
125 * better, like using a real filesystem abstraction (/proc, driverfs, ...),
126 * but sub-ioctls are simple enough and don't have much drawbacks (which
127 * means that it's a quick and dirty hack ;-).
128 *
129 * There are two slightly different variations of the sub-ioctl scheme :
130 * 1) If the payload fits within (union iwreq_data), the first int
131 * (4 bytes) is reserved as the sub-ioctl number and the regular payload
132 * shifted by 4 bytes. The handler must extract the sub-ioctl number,
133 * increment the data pointer and then use it in the usual way.
134 * 2) If the ioctl uses (struct iw_point), the sub-ioctl number is
135 * set in the flags member of the structure. In this case, the handler
136 * should simply get the sub-ioctl number from the flags and process the
137 * data in the usual way.
138 *
139 * Sub-ioctls are declared normally in the private definition table,
140 * with cmd (first arg) being the sub-ioctl number. Then, you should
141 * declare the real ioctl, which will process the sub-ioctls, with
142 * the SAME ARGUMENTS and a EMPTY NAME.
143 * Here's an example of how it could look like :
144 * --------------------------------------------
145 // --- sub-ioctls handlers ---
146 { 0x8BE0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
147 { 0x8BE1, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
148 // --- sub-ioctls definitions ---
149 { 1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_param1" },
150 { 1, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param1" },
151 { 2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_param2" },
152 { 2, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param2" },
153 // --- Raw access to sub-ioctl handlers ---
154 { 0x8BE0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_paramN" },
155 { 0x8BE1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_paramN" },
157 * --------------------------------------------
158 * And iwpriv should do the rest for you ;-)
159 *
160 * Note that versions of iwpriv up to v24 (included) expect at most
161 * 16 ioctls definitions and will likely crash when given more.
162 * There is no fix that I can see, apart from recommending your users
163 * to upgrade their Wireless Tools. Wireless Extensions 15 will check this
164 * condition, so another workaround is restricting those extra definitions
165 * to WE-15.
166 *
167 * Another problem is that the new API before Wireless Extension 15
168 * has a bug when passing fixed arguments of 12-15 bytes. It will
169 * try to get them inline instead of by pointer. You can fool the new API
170 * to do the right thing using fake ioctl definitions (but remember that
171 * you will be more likely to hit the limit of 16 ioctl definitions).
172 * To play safe, use the old-style ioctl handler before v15.
173 *
174 * NEW DATA TYPES (ADDR/FLOAT) :
175 * ---------------------------
176 * Wireless Tools 25 introduce two new data types, addr and float,
177 * corresponding to struct sockaddr and struct iwfreq.
178 * Those types are properly handled with Wireless Extensions 15.
179 * However, the new API before v15 won't handle them properly.
180 *
181 * The first problem is that the new API won't know their size, so
182 * it won't copy them. This can be workaround with a fake ioctl definition.
183 * The second problem is that a fixed single addr won't be inlined
184 * in struct iwreq and will be passed as a pointer. This is due to an
185 * off-by-one error, where all fixed data of 16 bytes is considered too
186 * big to fit in struct iwreq.
187 *
188 * For those reasons, I would recommend to use the ioctl handler
189 * before v15 when manipulating those data.
190 *
191 * TOKEN INDEX :
192 * -----------
193 * Token index is very similar to sub-ioctl. It allows the user
194 * to specify an integer index in front of a bunch of other arguments
195 * (addresses, strings, ...). It's specified in square brackets on the
196 * iwpriv command line before other arguments.
197 * > iwpriv eth0 [index] args...
198 * Token index works only when the data is passed as pointer, and
199 * is otherwise ignored. If your data would fit within struct iwreq, you
200 * should declare the command *without* IW_PRIV_SIZE_FIXED to force
201 * this to happen (and check arg number yourself).
202 * --------------------------------------------
203 // --- Commands that would fit in struct iwreq ---
204 { 0x8BE0, IW_PRIV_TYPE_ADDR | 1, 0, "set_param_with_token" },
205 // --- No problem here (bigger than struct iwreq) ---
206 { 0x8BE1, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 2, 0, "again" },
207 * --------------------------------------------
208 * The token index feature is pretty transparent, the token index
209 * will just be in the flags member of (struct iw_point). Default value
210 * (if the user doesn't specify it) will be 0. Token index itself will
211 * work with any version of Wireless Extensions.
212 * Token index is not compatible with sub-ioctl (both use the same
213 * field of struct iw_point). However, the token index can be used to offer
214 * raw access to the sub-ioctl handlers (if it uses struct iw_point) :
215 * --------------------------------------------
216 // --- sub-ioctls handler ---
217 { 0x8BE0, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "" },
218 // --- sub-ioctls definitions ---
219 { 0, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "setaddr" },
220 { 1, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "deladdr" },
221 // --- raw access with token index (+ iwreq workaround) ---
222 { 0x8BE0, IW_PRIV_TYPE_ADDR | 1, 0, "rawaddr" },
223 * --------------------------------------------
224 *
225 * Jean II
226 */
227
228 /**************************** CONSTANTS ****************************/
229
230 static const char * argtype[] = {
231 " ", "byte ", "char ", "", "int ", "float", "addr " };
232
233 /************************* MISC SUBROUTINES **************************/
234
235 /*------------------------------------------------------------------*/
236 /*
237 * Print usage string
238 */
239 static void
240 iw_usage(void)
241 {
242 fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
243 }
244
245 /************************* SETTING ROUTINES **************************/
246
247 /*------------------------------------------------------------------*/
248 /*
249 * Execute a private command on the interface
250 */
251 static int
252 set_private_cmd(int skfd, /* Socket */
253 char * args[], /* Command line args */
254 int count, /* Args count */
255 char * ifname, /* Dev name */
256 char * cmdname, /* Command name */
257 iwprivargs * priv, /* Private ioctl description */
258 int priv_num) /* Number of descriptions */
259 {
260 struct iwreq wrq;
261 u_char buffer[4096]; /* Only that big in v25 and later */
262 int i = 0; /* Start with first command arg */
263 int k; /* Index in private description table */
264 int temp;
265 int subcmd = 0; /* sub-ioctl index */
266 int offset = 0; /* Space for sub-ioctl index */
267
268 /* Check if we have a token index.
269 * Do it now so that sub-ioctl takes precedence, and so that we
270 * don't have to bother with it later on... */
271 if((count >= 1) && (sscanf(args[0], "[%i]", &temp) == 1))
272 {
273 subcmd = temp;
274 args++;
275 count--;
276 }
277
278 /* Search the correct ioctl */
279 k = -1;
280 while((++k < priv_num) && strcmp(priv[k].name, cmdname));
281
282 /* If not found... */
283 if(k == priv_num)
284 {
285 fprintf(stderr, "Invalid command : %s\n", cmdname);
286 return(-1);
287 }
288
289 /* Watch out for sub-ioctls ! */
290 if(priv[k].cmd < SIOCDEVPRIVATE)
291 {
292 int j = -1;
293
294 /* Find the matching *real* ioctl */
295 while((++j < priv_num) && ((priv[j].name[0] != '\0') ||
296 (priv[j].set_args != priv[k].set_args) ||
297 (priv[j].get_args != priv[k].get_args)));
298
299 /* If not found... */
300 if(j == priv_num)
301 {
302 fprintf(stderr, "Invalid private ioctl definition for : %s\n",
303 cmdname);
304 return(-1);
305 }
306
307 /* Save sub-ioctl number */
308 subcmd = priv[k].cmd;
309 /* Reserve one int (simplify alignment issues) */
310 offset = sizeof(__u32);
311 /* Use real ioctl definition from now on */
312 k = j;
313
314 #if 0
315 printf("<mapping sub-ioctl %s to cmd 0x%X-%d>\n", cmdname,
316 priv[k].cmd, subcmd);
317 #endif
318 }
319
320 /* If we have to set some data */
321 if((priv[k].set_args & IW_PRIV_TYPE_MASK) &&
322 (priv[k].set_args & IW_PRIV_SIZE_MASK))
323 {
324 switch(priv[k].set_args & IW_PRIV_TYPE_MASK)
325 {
326 case IW_PRIV_TYPE_BYTE:
327 /* Number of args to fetch */
328 wrq.u.data.length = count;
329 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
330 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
331
332 /* Fetch args */
333 for(; i < wrq.u.data.length; i++) {
334 sscanf(args[i], "%i", &temp);
335 buffer[i] = (char) temp;
336 }
337 break;
338
339 case IW_PRIV_TYPE_INT:
340 /* Number of args to fetch */
341 wrq.u.data.length = count;
342 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
343 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
344
345 /* Fetch args */
346 for(; i < wrq.u.data.length; i++) {
347 sscanf(args[i], "%i", &temp);
348 ((__s32 *) buffer)[i] = (__s32) temp;
349 }
350 break;
351
352 case IW_PRIV_TYPE_CHAR:
353 if(i < count)
354 {
355 /* Size of the string to fetch */
356 wrq.u.data.length = strlen(args[i]) + 1;
357 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
358 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
359
360 /* Fetch string */
361 memcpy(buffer, args[i], wrq.u.data.length);
362 buffer[sizeof(buffer) - 1] = '\0';
363 i++;
364 }
365 else
366 {
367 wrq.u.data.length = 1;
368 buffer[0] = '\0';
369 }
370 break;
371
372 case IW_PRIV_TYPE_FLOAT:
373 /* Number of args to fetch */
374 wrq.u.data.length = count;
375 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
376 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
377
378 /* Fetch args */
379 for(; i < wrq.u.data.length; i++) {
380 double freq;
381 if(sscanf(args[i], "%lg", &(freq)) != 1)
382 {
383 printf("Invalid float [%s]...\n", args[i]);
384 return(-1);
385 }
386 if(strchr(args[i], 'G')) freq *= GIGA;
387 if(strchr(args[i], 'M')) freq *= MEGA;
388 if(strchr(args[i], 'k')) freq *= KILO;
389 sscanf(args[i], "%i", &temp);
390 iw_float2freq(freq, ((struct iw_freq *) buffer) + i);
391 }
392 break;
393
394 case IW_PRIV_TYPE_ADDR:
395 /* Number of args to fetch */
396 wrq.u.data.length = count;
397 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
398 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
399
400 /* Fetch args */
401 for(; i < wrq.u.data.length; i++) {
402 if(iw_in_addr(skfd, ifname, args[i],
403 ((struct sockaddr *) buffer) + i) < 0)
404 {
405 printf("Invalid address [%s]...\n", args[i]);
406 return(-1);
407 }
408 }
409 break;
410
411 default:
412 fprintf(stderr, "Not implemented...\n");
413 return(-1);
414 }
415
416 if((priv[k].set_args & IW_PRIV_SIZE_FIXED) &&
417 (wrq.u.data.length != (priv[k].set_args & IW_PRIV_SIZE_MASK)))
418 {
419 printf("The command %s needs exactly %d argument(s)...\n",
420 cmdname, priv[k].set_args & IW_PRIV_SIZE_MASK);
421 return(-1);
422 }
423 } /* if args to set */
424 else
425 {
426 wrq.u.data.length = 0L;
427 }
428
429 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
430
431 /* Those two tests are important. They define how the driver
432 * will have to handle the data */
433 if((priv[k].set_args & IW_PRIV_SIZE_FIXED) &&
434 ((iw_get_priv_size(priv[k].set_args) + offset) <= IFNAMSIZ))
435 {
436 /* First case : all SET args fit within wrq */
437 if(offset)
438 wrq.u.mode = subcmd;
439 memcpy(wrq.u.name + offset, buffer, IFNAMSIZ - offset);
440 }
441 else
442 {
443 if((priv[k].set_args == 0) &&
444 (priv[k].get_args & IW_PRIV_SIZE_FIXED) &&
445 (iw_get_priv_size(priv[k].get_args) <= IFNAMSIZ))
446 {
447 /* Second case : no SET args, GET args fit within wrq */
448 if(offset)
449 wrq.u.mode = subcmd;
450 }
451 else
452 {
453 /* Third case : args won't fit in wrq, or variable number of args */
454 wrq.u.data.pointer = (caddr_t) buffer;
455 wrq.u.data.flags = subcmd;
456 }
457 }
458
459 /* Perform the private ioctl */
460 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
461 {
462 fprintf(stderr, "Interface doesn't accept private ioctl...\n");
463 fprintf(stderr, "%s (%X): %s\n", cmdname, priv[k].cmd, strerror(errno));
464 return(-1);
465 }
466
467 /* If we have to get some data */
468 if((priv[k].get_args & IW_PRIV_TYPE_MASK) &&
469 (priv[k].get_args & IW_PRIV_SIZE_MASK))
470 {
471 int j;
472 int n = 0; /* number of args */
473
474 printf("%-8.16s %s:", ifname, cmdname);
475
476 /* Check where is the returned data */
477 if((priv[k].get_args & IW_PRIV_SIZE_FIXED) &&
478 (iw_get_priv_size(priv[k].get_args) <= IFNAMSIZ))
479 {
480 memcpy(buffer, wrq.u.name, IFNAMSIZ);
481 n = priv[k].get_args & IW_PRIV_SIZE_MASK;
482 }
483 else
484 n = wrq.u.data.length;
485
486 switch(priv[k].get_args & IW_PRIV_TYPE_MASK)
487 {
488 case IW_PRIV_TYPE_BYTE:
489 /* Display args */
490 for(j = 0; j < n; j++)
491 printf("%d ", buffer[j]);
492 printf("\n");
493 break;
494
495 case IW_PRIV_TYPE_INT:
496 /* Display args */
497 for(j = 0; j < n; j++)
498 printf("%d ", ((__s32 *) buffer)[j]);
499 printf("\n");
500 break;
501
502 case IW_PRIV_TYPE_CHAR:
503 /* Display args */
504 buffer[n] = '\0';
505 printf("%s\n", buffer);
506 break;
507
508 case IW_PRIV_TYPE_FLOAT:
509 {
510 double freq;
511 /* Display args */
512 for(j = 0; j < n; j++)
513 {
514 freq = iw_freq2float(((struct iw_freq *) buffer) + j);
515 if(freq >= GIGA)
516 printf("%gG ", freq / GIGA);
517 else
518 if(freq >= MEGA)
519 printf("%gM ", freq / MEGA);
520 else
521 printf("%gk ", freq / KILO);
522 }
523 printf("\n");
524 }
525 break;
526
527 case IW_PRIV_TYPE_ADDR:
528 {
529 char scratch[128];
530 struct sockaddr * hwa;
531 /* Display args */
532 for(j = 0; j < n; j++)
533 {
534 hwa = ((struct sockaddr *) buffer) + j;
535 if(j)
536 printf(" %.*s",
537 (int) strlen(cmdname), " ");
538 printf("%s\n", iw_saether_ntop(hwa, scratch));
539 }
540 }
541 break;
542
543 default:
544 fprintf(stderr, "Not yet implemented...\n");
545 return(-1);
546 }
547 } /* if args to set */
548
549 return(0);
550 }
551
552 /*------------------------------------------------------------------*/
553 /*
554 * Execute a private command on the interface
555 */
556 static inline int
557 set_private(int skfd, /* Socket */
558 char * args[], /* Command line args */
559 int count, /* Args count */
560 char * ifname) /* Dev name */
561 {
562 iwprivargs * priv;
563 int number; /* Max of private ioctl */
564 int ret;
565
566 /* Read the private ioctls */
567 number = iw_get_priv_info(skfd, ifname, &priv);
568
569 /* Is there any ? */
570 if(number <= 0)
571 {
572 /* Should I skip this message ? */
573 fprintf(stderr, "%-8.16s no private ioctls.\n\n",
574 ifname);
575 if(priv)
576 free(priv);
577 return(-1);
578 }
579
580 /* Do it */
581 ret = set_private_cmd(skfd, args + 1, count - 1, ifname, args[0],
582 priv, number);
583
584 free(priv);
585 return(ret);
586 }
587
588 /************************ CATALOG FUNCTIONS ************************/
589
590 /*------------------------------------------------------------------*/
591 /*
592 * Print on the screen in a neat fashion the list of private ioctls
593 * for the device.
594 */
595 static int
596 print_priv_info(int skfd,
597 char * ifname,
598 char * args[],
599 int count)
600 {
601 int k;
602 iwprivargs * priv;
603 int n;
604
605 /* Avoid "Unused parameter" warning */
606 args = args; count = count;
607
608 /* Read the private ioctls */
609 n = iw_get_priv_info(skfd, ifname, &priv);
610
611 /* Is there any ? */
612 if(n <= 0)
613 {
614 /* Should I skip this message ? */
615 fprintf(stderr, "%-8.16s no private ioctls.\n\n",
616 ifname);
617 }
618 else
619 {
620 printf("%-8.16s Available private ioctls :\n", ifname);
621 /* Print them all */
622 for(k = 0; k < n; k++)
623 if(priv[k].name[0] != '\0')
624 printf(" %-16.16s (%.4X) : set %3d %s & get %3d %s\n",
625 priv[k].name, priv[k].cmd,
626 priv[k].set_args & IW_PRIV_SIZE_MASK,
627 argtype[(priv[k].set_args & IW_PRIV_TYPE_MASK) >> 12],
628 priv[k].get_args & IW_PRIV_SIZE_MASK,
629 argtype[(priv[k].get_args & IW_PRIV_TYPE_MASK) >> 12]);
630 printf("\n");
631 }
632
633 /* Cleanup */
634 if(priv)
635 free(priv);
636 return(0);
637 }
638
639 /*------------------------------------------------------------------*/
640 /*
641 * Print on the screen in a neat fashion the list of private GET ioctl
642 * data for the device and data returned by those.
643 */
644 static int
645 print_priv_all(int skfd,
646 char * ifname,
647 char * args[],
648 int count)
649 {
650 int k;
651 iwprivargs * priv;
652 int n;
653
654 /* Avoid "Unused parameter" warning */
655 args = args; count = count;
656
657 /* Read the private ioctls */
658 n = iw_get_priv_info(skfd, ifname, &priv);
659
660 /* Is there any ? */
661 if(n <= 0)
662 {
663 /* Should I skip this message ? */
664 fprintf(stderr, "%-8.16s no private ioctls.\n\n",
665 ifname);
666 }
667 else
668 {
669 printf("%-8.16s Available read-only private ioctl :\n", ifname);
670 /* Print them all */
671 for(k = 0; k < n; k++)
672 /* We call all ioctls that don't have a null name, don't require
673 * args and return some (avoid triggering "reset" commands) */
674 if((priv[k].name[0] != '\0') && (priv[k].set_args == 0) &&
675 (priv[k].get_args != 0))
676 set_private_cmd(skfd, NULL, 0, ifname, priv[k].name,
677 priv, n);
678 printf("\n");
679 }
680
681 /* Cleanup */
682 if(priv)
683 free(priv);
684 return(0);
685 }
686
687 /********************** PRIVATE IOCTLS MANIPS ***********************/
688 /*
689 * Convenient access to some private ioctls of some devices
690 */
691
692 #if 0
693 /*------------------------------------------------------------------*/
694 /*
695 * Set roaming mode on and off
696 * Found in wavelan_cs driver
697 * Note : this is obsolete, most 802.11 devices should use the
698 * SIOCSIWAP request.
699 */
700 static int
701 set_roaming(int skfd, /* Socket */
702 char * args[], /* Command line args */
703 int count, /* Args count */
704 char * ifname) /* Dev name */
705 {
706 u_char buffer[1024];
707 struct iwreq wrq;
708 int i = 0; /* Start with first arg */
709 int k;
710 iwprivargs * priv;
711 int number;
712 int roamcmd;
713 char RoamState; /* buffer to hold new roam state */
714 char ChangeRoamState=0; /* whether or not we are going to
715 change roam states */
716
717 /* Read the private ioctls */
718 number = iw_get_priv_info(skfd, ifname, &priv);
719
720 /* Is there any ? */
721 if(number <= 0)
722 {
723 /* Should I skip this message ? */
724 fprintf(stderr, "%-8.16s no private ioctls.\n\n",
725 ifname);
726 if(priv)
727 free(priv);
728 return(-1);
729 }
730
731 /* Get the ioctl number */
732 k = -1;
733 while((++k < number) && strcmp(priv[k].name, "setroam"));
734 if(k == number)
735 {
736 fprintf(stderr, "This device doesn't support roaming\n");
737 free(priv);
738 return(-1);
739 }
740 roamcmd = priv[k].cmd;
741
742 /* Cleanup */
743 free(priv);
744
745 if(count != 1)
746 {
747 iw_usage();
748 return(-1);
749 }
750
751 if(!strcasecmp(args[i], "on"))
752 {
753 printf("%-8.16s enable roaming\n", ifname);
754 if(!number)
755 {
756 fprintf(stderr, "This device doesn't support roaming\n");
757 return(-1);
758 }
759 ChangeRoamState=1;
760 RoamState=1;
761 }
762 else
763 if(!strcasecmp(args[i], "off"))
764 {
765 i++;
766 printf("%-8.16s disable roaming\n", ifname);
767 if(!number)
768 {
769 fprintf(stderr, "This device doesn't support roaming\n");
770 return(-1);
771 }
772 ChangeRoamState=1;
773 RoamState=0;
774 }
775 else
776 {
777 iw_usage();
778 return(-1);
779 }
780
781 if(ChangeRoamState)
782 {
783 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
784
785 buffer[0]=RoamState;
786
787 memcpy(wrq.u.name, &buffer, IFNAMSIZ);
788
789 if(ioctl(skfd, roamcmd, &wrq) < 0)
790 {
791 fprintf(stderr, "Roaming support is broken.\n");
792 return(-1);
793 }
794 }
795
796 return(0);
797 }
798
799 /*------------------------------------------------------------------*/
800 /*
801 * Get and set the port type
802 * Found in wavelan2_cs and wvlan_cs drivers
803 * TODO : Add support for HostAP ?
804 */
805 static int
806 port_type(int skfd, /* Socket */
807 char * args[], /* Command line args */
808 int count, /* Args count */
809 char * ifname) /* Dev name */
810 {
811 struct iwreq wrq;
812 int i = 0; /* Start with first arg */
813 int k;
814 iwprivargs * priv;
815 int number;
816 char ptype = 0;
817 char * modes[] = { "invalid", "managed (BSS)", "reserved", "ad-hoc" };
818
819 /* Read the private ioctls */
820 number = iw_get_priv_info(skfd, ifname, &priv);
821
822 /* Is there any ? */
823 if(number <= 0)
824 {
825 /* Should I skip this message ? */
826 fprintf(stderr, "%-8.16s no private ioctls.\n\n", ifname);
827 if(priv)
828 free(priv);
829 return(-1);
830 }
831
832 /* Arguments ? */
833 if(count == 0)
834 {
835 /* So, we just want to see the current value... */
836 k = -1;
837 while((++k < number) && strcmp(priv[k].name, "gport_type") &&
838 strcmp(priv[k].name, "get_port"));
839 if(k == number)
840 {
841 fprintf(stderr, "This device doesn't support getting port type\n");
842 goto err;
843 }
844 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
845
846 /* Get it */
847 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
848 {
849 fprintf(stderr, "Port type support is broken.\n");
850 goto err;
851 }
852 ptype = *wrq.u.name;
853
854 /* Display it */
855 printf("%-8.16s Current port mode is %s <port type is %d>.\n\n",
856 ifname, modes[(int) ptype], ptype);
857
858 free(priv);
859 return(0);
860 }
861
862 if(count != 1)
863 {
864 iw_usage();
865 goto err;
866 }
867
868 /* Read it */
869 /* As a string... */
870 k = 0;
871 while((k < 4) && strncasecmp(args[i], modes[k], 2))
872 k++;
873 if(k < 4)
874 ptype = k;
875 else
876 /* ...or as an integer */
877 if(sscanf(args[i], "%i", (int *) &ptype) != 1)
878 {
879 iw_usage();
880 goto err;
881 }
882
883 k = -1;
884 while((++k < number) && strcmp(priv[k].name, "sport_type") &&
885 strcmp(priv[k].name, "set_port"));
886 if(k == number)
887 {
888 fprintf(stderr, "This device doesn't support setting port type\n");
889 goto err;
890 }
891 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
892
893 *(wrq.u.name) = ptype;
894
895 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
896 {
897 fprintf(stderr, "Invalid port type (or setting not allowed)\n");
898 goto err;
899 }
900
901 free(priv);
902 return(0);
903
904 err:
905 free(priv);
906 return(-1);
907 }
908 #endif
909
910 /******************************* MAIN ********************************/
911
912 /*------------------------------------------------------------------*/
913 /*
914 * The main !
915 */
916 int
917 main(int argc,
918 char ** argv)
919 {
920 int skfd; /* generic raw socket desc. */
921 int goterr = 0;
922
923 /* Create a channel to the NET kernel. */
924 if((skfd = iw_sockets_open()) < 0)
925 {
926 perror("socket");
927 return(-1);
928 }
929
930 /* No argument : show the list of all devices + ioctl list */
931 if(argc == 1)
932 iw_enum_devices(skfd, &print_priv_info, NULL, 0);
933 else
934 /* Special cases take one... */
935 /* All */
936 if((!strncmp(argv[1], "-a", 2)) || (!strcmp(argv[1], "--all")))
937 iw_enum_devices(skfd, &print_priv_all, NULL, 0);
938 else
939 /* Help */
940 if((!strncmp(argv[1], "-h", 2)) || (!strcmp(argv[1], "--help")))
941 iw_usage();
942 else
943 /* Version */
944 if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
945 goterr = iw_print_version_info("iwpriv");
946 else
947 /* The device name must be the first argument */
948 /* Name only : show for that device only */
949 if(argc == 2)
950 print_priv_info(skfd, argv[1], NULL, 0);
951 else
952 /* Special cases take two... */
953 /* All */
954 if((!strncmp(argv[2], "-a", 2)) ||
955 (!strcmp(argv[2], "--all")))
956 print_priv_all(skfd, argv[1], NULL, 0);
957 else
958 #if 0
959 /* Roaming */
960 if(!strncmp(argv[2], "roam", 4))
961 goterr = set_roaming(skfd, argv + 3, argc - 3, argv[1]);
962 else
963 /* Port type */
964 if(!strncmp(argv[2], "port", 4))
965 goterr = port_type(skfd, argv + 3, argc - 3, argv[1]);
966 else
967 #endif
968 /*-------------*/
969 /* Otherwise, it's a private ioctl */
970 goterr = set_private(skfd, argv + 2, argc - 2, argv[1]);
971
972 /* Close the socket. */
973 iw_sockets_close(skfd);
974
975 return(goterr);
976 }
+0
-111
src/lwe/iwspy.8 less more
0 .\" Jean II - HPLB - 96
1 .\" iwspy.8
2 .\"
3 .TH IWSPY 8 "31 October 1996" "net-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 iwspy \- Get wireless statistics from specific nodes
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .BI "iwspy [" interface ]
14 .br
15 .BI "iwspy " interface " [+] " DNSNAME " | " IPADDR " | " HWADDR " [...]"
16 .br
17 .BI "iwspy " interface " off"
18 .br
19 .BI "iwspy " interface " setthr " "low high"
20 .br
21 .BI "iwspy " interface " getthr"
22 .\"
23 .\" DESCRIPTION part
24 .\"
25 .SH DESCRIPTION
26 .B Iwspy
27 is used to set a list of addresses to monitor in a wireless network
28 interface and to read back quality of link information for each of
29 those. This information is the same as the one available in
30 .I /proc/net/wireless
31 : quality of the link, signal strength and noise level.
32 .PP
33 This information is updated each time a new packet is received, so
34 each address of the list adds some overhead in the driver.
35 .PP
36 Note that this functionality works only for nodes part of the current
37 wireless cell, you can not monitor Access Points you are not
38 associated with (you can use Scanning for that) and nodes in other
39 cells. In Managed mode, in most case packets are relayed by the Access
40 Point, in this case you will get the signal strength of the Access
41 Point. For those reasons this functionality is mostly useful in Ad-Hoc
42 and Master mode.
43 .\"
44 .\" PARAMETER part
45 .\"
46 .SH PARAMETERS
47 You may set any number of addresses up to 8.
48 .TP
49 .BR DNSNAME " | " IPADDR
50 Set an IP address, or in some cases a DNS name (using the name
51 resolver). As the hardware works with hardware addresses,
52 .B iwspy
53 will translate this IP address through
54 .IR ARP .
55 In some case, this address might not be in the ARP cache and
56 .B iwspy
57 will fail. In those case,
58 .IR ping (8)
59 this name/address and retry.
60 .TP
61 .B HWADDR
62 Set a hardware (MAC) address (this address is not translated & checked
63 like the IP one). The address must contain a colon
64 .RB ( : )
65 to be recognised as a hardware address.
66 .TP
67 .B +
68 Add the new set of addresses at the end of the current list instead of
69 replacing it. The address list is unique for each device, so each user
70 should use this option to avoid conflicts.
71 .TP
72 .B off
73 Remove the current list of addresses and disable the spy functionality
74 .TP
75 .B setthr
76 Set the
77 .I low
78 and
79 .I high
80 signal strength threshold for the iwspy event (for drivers that
81 support it).
82 .br
83 Every time the signal strength for any of the address monitored
84 with iwspy goes lower than the low threshold or goes higher than the
85 high threshold, a Wireless Event will be generated.
86 .br
87 This can be used to monitor link outages without having to run iwspy
88 periodically.
89 .TP
90 .B getthr
91 Retrieve the current
92 .I low
93 and
94 .I high
95 signal strength threshold for the iwspy event.
96 \"
97 .\" FILES part
98 .\"
99 .SH FILES
100 .I /proc/net/wireless
101 .\"
102 .\" SEE ALSO part
103 .\"
104 .SH SEE ALSO
105 .BR iwconfig (8),
106 .BR iwlist (8),
107 .BR iwevent (8),
108 .BR iwpriv (8),
109 .BR wireless (7).
110
+0
-376
src/lwe/iwspy.c less more
0 /*
1 * Wireless Tools
2 *
3 * Jean II - HPLB '99 - HPL 99->04
4 *
5 * This tool can manipulate the spy list : add addresses and display stat
6 * You need to link this code against "iwlib.c" and "-lm".
7 *
8 * This file is released under the GPL license.
9 * Copyright (c) 1997-2004 Jean Tourrilhes <[email protected]>
10 */
11
12 #include "iwlib.h" /* Header */
13
14 /************************* DISPLAY ROUTINES **************************/
15
16 /*------------------------------------------------------------------*/
17 /*
18 * Display the spy list of addresses and the associated stats
19 */
20 static int
21 print_spy_info(int skfd,
22 char * ifname,
23 char * args[],
24 int count)
25 {
26 struct iwreq wrq;
27 char buffer[(sizeof(struct iw_quality) +
28 sizeof(struct sockaddr)) * IW_MAX_SPY];
29 char temp[128];
30 struct sockaddr * hwa;
31 struct iw_quality * qual;
32 iwrange range;
33 int has_range = 0;
34 int n;
35 int i;
36
37 /* Avoid "Unused parameter" warning */
38 args = args; count = count;
39
40 /* Collect stats */
41 wrq.u.data.pointer = (caddr_t) buffer;
42 wrq.u.data.length = IW_MAX_SPY;
43 wrq.u.data.flags = 0;
44 if(iw_get_ext(skfd, ifname, SIOCGIWSPY, &wrq) < 0)
45 {
46 fprintf(stderr, "%-8.16s Interface doesn't support wireless statistic collection\n\n", ifname);
47 return(-1);
48 }
49
50 /* Number of addresses */
51 n = wrq.u.data.length;
52
53 /* Check if we have valid mac address type */
54 if(iw_check_mac_addr_type(skfd, ifname) < 0)
55 {
56 fprintf(stderr, "%-8.16s Interface doesn't support MAC addresses\n\n", ifname);
57 return(-2);
58 }
59
60 /* Get range info if we can */
61 if(iw_get_range_info(skfd, ifname, &(range)) >= 0)
62 has_range = 1;
63
64 /* Display it */
65 if(n == 0)
66 printf("%-8.16s No statistics to collect\n", ifname);
67 else
68 printf("%-8.16s Statistics collected:\n", ifname);
69
70 /* The two lists */
71 hwa = (struct sockaddr *) buffer;
72 qual = (struct iw_quality *) (buffer + (sizeof(struct sockaddr) * n));
73
74 for(i = 0; i < n; i++)
75 {
76 /* Print stats for each address */
77 printf(" %s : ", iw_saether_ntop(&hwa[i], temp));
78 iw_print_stats(temp, sizeof(temp), &qual[i], &range, has_range);
79 printf("%s\n", temp);
80 }
81
82 if((n > 0) && (has_range) && (range.we_version_compiled > 11))
83 {
84 iwstats stats;
85
86 /* Get /proc/net/wireless */
87 if(iw_get_stats(skfd, ifname, &stats, &range, has_range) >= 0)
88 {
89 iw_print_stats(temp, sizeof(temp), &stats.qual, &range, has_range);
90 printf(" Link/Cell/AP : %s\n", temp);
91 /* Display the static data */
92 iw_print_stats(temp, sizeof(temp),
93 &range.avg_qual, &range, has_range);
94 printf(" Typical/Reference : %s\n", temp);
95 }
96 }
97
98 printf("\n");
99 return(0);
100 }
101
102 /*------------------------------------------------------------------*/
103 /*
104 * Get spy thresholds from the driver and display
105 */
106 static int
107 get_spy_threshold(int skfd, /* The socket */
108 char * ifname, /* Dev name */
109 char * args[], /* Command line args */
110 int count) /* Args count */
111 {
112 struct iwreq wrq;
113 struct iw_thrspy threshold;
114 iwrange range;
115 int has_range = 0;
116
117 /* Avoid "Unused parameter" warning */
118 args = args; count = count;
119
120 /* Time to send thresholds to the driver */
121 wrq.u.data.pointer = (caddr_t) &threshold;
122 wrq.u.data.length = 1;
123 wrq.u.data.flags = 0;
124 if(iw_set_ext(skfd, ifname, SIOCGIWTHRSPY, &wrq) < 0)
125 {
126 fprintf(stderr, "Interface doesn't support thresholds...\n");
127 fprintf(stderr, "SIOCGIWTHRSPY: %s\n", strerror(errno));
128 return(-1);
129 }
130
131 /* Get range info if we can */
132 if(iw_get_range_info(skfd, ifname, &(range)) >= 0)
133 has_range = 1;
134
135 /* Display thresholds */
136 if((has_range) && (threshold.low.level))
137 {
138 /* If the statistics are in dBm */
139 if(threshold.low.level > range.max_qual.level)
140 {
141 /* Statistics are in dBm (absolute power measurement) */
142 printf("%-8.16s Low threshold:%d dBm High threshold:%d dBm\n\n",
143 ifname,
144 threshold.low.level - 0x100, threshold.high.level - 0x100);
145 }
146 else
147 {
148 /* Statistics are relative values (0 -> max) */
149 printf("%-8.16s Low threshold:%d/%d High threshold:%d/%d\n\n",
150 ifname,
151 threshold.low.level, range.max_qual.level,
152 threshold.high.level, range.max_qual.level);
153 }
154 }
155 else
156 {
157 /* We can't read the range, so we don't know... */
158 printf("%-8.16s Low threshold:%d High threshold:%d\n\n",
159 ifname,
160 threshold.low.level, threshold.high.level);
161 }
162
163 return(0);
164 }
165
166 /************************* SETTING ROUTINES **************************/
167
168 /*------------------------------------------------------------------*/
169 /*
170 * Set list of addresses specified on command line in the driver.
171 */
172 static int
173 set_spy_info(int skfd, /* The socket */
174 char * ifname, /* Dev name */
175 char * args[], /* Command line args */
176 int count) /* Args count */
177 {
178 struct iwreq wrq;
179 int i;
180 int nbr; /* Number of valid addresses */
181 struct sockaddr hw_address[IW_MAX_SPY];
182
183 /* Read command line */
184 i = 0; /* first arg to read */
185 nbr = 0; /* Number of args read so far */
186
187 /* "off" : disable functionality (set 0 addresses) */
188 if(!strcmp(args[0], "off"))
189 i = 1; /* skip the "off" */
190 else
191 {
192 /* "+" : add all addresses already in the driver */
193 if(!strcmp(args[0], "+"))
194 {
195 char buffer[(sizeof(struct iw_quality) +
196 sizeof(struct sockaddr)) * IW_MAX_SPY];
197
198 /* Check if we have valid mac address type */
199 if(iw_check_mac_addr_type(skfd, ifname) < 0)
200 {
201 fprintf(stderr, "%-8.16s Interface doesn't support MAC addresses\n", ifname);
202 return(-1);
203 }
204
205 wrq.u.data.pointer = (caddr_t) buffer;
206 wrq.u.data.length = IW_MAX_SPY;
207 wrq.u.data.flags = 0;
208 if(iw_get_ext(skfd, ifname, SIOCGIWSPY, &wrq) < 0)
209 {
210 fprintf(stderr, "Interface doesn't accept reading addresses...\n");
211 fprintf(stderr, "SIOCGIWSPY: %s\n", strerror(errno));
212 return(-1);
213 }
214
215 /* Copy old addresses */
216 nbr = wrq.u.data.length;
217 memcpy(hw_address, buffer, nbr * sizeof(struct sockaddr));
218
219 i = 1; /* skip the "+" */
220 }
221
222 /* Read other args on command line */
223 while((i < count) && (nbr < IW_MAX_SPY))
224 {
225 /* Get the address and check if the interface supports it */
226 if(iw_in_addr(skfd, ifname, args[i++], &(hw_address[nbr])) < 0)
227 continue;
228 nbr++;
229 }
230
231 /* Check the number of addresses */
232 if(nbr == 0)
233 {
234 fprintf(stderr, "No valid addresses found : exiting...\n");
235 return(-1);
236 }
237 }
238
239 /* Check if there is some remaining arguments */
240 if(i < count)
241 {
242 fprintf(stderr, "Got only the first %d arguments, remaining discarded\n", i);
243 }
244
245 /* Time to do send addresses to the driver */
246 wrq.u.data.pointer = (caddr_t) hw_address;
247 wrq.u.data.length = nbr;
248 wrq.u.data.flags = 0;
249 if(iw_set_ext(skfd, ifname, SIOCSIWSPY, &wrq) < 0)
250 {
251 fprintf(stderr, "Interface doesn't accept addresses...\n");
252 fprintf(stderr, "SIOCSIWSPY: %s\n", strerror(errno));
253 return(-1);
254 }
255
256 return(0);
257 }
258
259 /*------------------------------------------------------------------*/
260 /*
261 * Set spy thresholds in the driver from command line
262 */
263 static int
264 set_spy_threshold(int skfd, /* The socket */
265 char * ifname, /* Dev name */
266 char * args[], /* Command line args */
267 int count) /* Args count */
268 {
269 struct iwreq wrq;
270 struct iw_thrspy threshold;
271 int low_thr;
272 int high_thr;
273
274 /* Init */
275 memset(&threshold, '\0', sizeof(threshold));
276
277 /* "off" : disable functionality (set 0 addresses) */
278 if(!strcmp(args[0], "off"))
279 {
280 /* Just send null threshold, will disable it */
281 }
282 else
283 {
284 /* Try to get our threshold */
285 if(count < 2)
286 {
287 fprintf(stderr, "%-8.16s Need two threshold values\n", ifname);
288 return(-1);
289 }
290 if((sscanf(args[0], "%i", &low_thr) != 1) ||
291 (sscanf(args[1], "%i", &high_thr) != 1))
292 {
293 fprintf(stderr, "%-8.16s Invalid threshold values\n", ifname);
294 return(-1);
295 }
296 /* Basic sanity check */
297 if(high_thr < low_thr)
298 {
299 fprintf(stderr, "%-8.16s Inverted threshold range\n", ifname);
300 return(-1);
301 }
302 /* Copy thresholds */
303 threshold.low.level = low_thr;
304 threshold.low.updated = 0x2;
305 threshold.high.level = high_thr;
306 threshold.high.updated = 0x2;
307 }
308
309 /* Time to send thresholds to the driver */
310 wrq.u.data.pointer = (caddr_t) &threshold;
311 wrq.u.data.length = 1;
312 wrq.u.data.flags = 0;
313 if(iw_set_ext(skfd, ifname, SIOCSIWTHRSPY, &wrq) < 0)
314 {
315 fprintf(stderr, "Interface doesn't accept thresholds...\n");
316 fprintf(stderr, "SIOCSIWTHRSPY: %s\n", strerror(errno));
317 return(-1);
318 }
319
320 return(0);
321 }
322
323 /******************************* MAIN ********************************/
324
325 /*------------------------------------------------------------------*/
326 /*
327 * The main !
328 */
329 int
330 main(int argc,
331 char ** argv)
332 {
333 int skfd; /* generic raw socket desc. */
334 int goterr = 0;
335
336 /* Create a channel to the NET kernel. */
337 if((skfd = iw_sockets_open()) < 0)
338 {
339 perror("socket");
340 return(-1);
341 }
342
343 /* No argument : show the list of all device + info */
344 if(argc == 1)
345 iw_enum_devices(skfd, &print_spy_info, NULL, 0);
346 else
347 /* Special cases take one... */
348 /* Help */
349 if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help")))
350 fprintf(stderr, "Usage: iwspy interface [+] [MAC address] [IP address]\n");
351 else
352 /* Version */
353 if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
354 goterr = iw_print_version_info("iwspy");
355 else
356 /* The device name must be the first argument */
357 /* Name only : show spy list for that device only */
358 if(argc == 2)
359 print_spy_info(skfd, argv[1], NULL, 0);
360 else
361 /* Special commands */
362 if(!strcmp(argv[2], "setthr"))
363 goterr = set_spy_threshold(skfd, argv[1], argv + 3, argc - 3);
364 else
365 if(!strcmp(argv[2], "getthr"))
366 goterr = get_spy_threshold(skfd, argv[1], argv + 3, argc - 3);
367 else
368 /* Otherwise, it's a list of address to set in the spy list */
369 goterr = set_spy_info(skfd, argv[1], argv + 2, argc - 2);
370
371 /* Close the socket. */
372 iw_sockets_close(skfd);
373
374 return(goterr);
375 }
+0
-54
src/lwe/macaddr.c less more
0 /*
1 * macaddr
2 *
3 * Program to return the MAC address of an Ethernet
4 * adapter. This was written to help configure the
5 * adapter based on the MAC address rather than the
6 * name.
7 *
8 * Version 1.0 Eric Dittman 2001-10-19
9 *
10 * This is released unther the GPL license.
11 */
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <unistd.h>
17 #include <sys/ioctl.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20
21 #include "iwlib.h"
22
23 int main(int argc, char** argv)
24 {
25
26 int devsock;
27 struct ifreq ifbuffer;
28 char buf[20];
29
30 if ((argc != 2) || (argv[1][0] == '-')) {
31 printf("Usage: macaddr interface\n");
32 exit(1);
33 }
34
35 devsock = socket(AF_INET, SOCK_STREAM, 0);
36
37 if (devsock == -1) {
38 perror("Failed opening socket");
39 exit (1);
40 }
41
42 memset(&ifbuffer, 0, sizeof(ifbuffer));
43 strncpy(ifbuffer.ifr_name, argv[1], sizeof(ifbuffer.ifr_name));
44 if (ioctl(devsock, SIOCGIFHWADDR, &ifbuffer) == -1) {
45 fprintf(stderr, "There is no MACADDR for %s\n", argv[1]);
46 exit(1);
47 }
48 close(devsock);
49
50 puts(iw_saether_ntop(&ifbuffer.ifr_ifru.ifru_hwaddr, buf));
51
52 exit(0);
53 }
+0
-191
src/lwe/sample_enc.c less more
0 /* Note : this particular snipset of code is available under
1 * the LGPL, MPL or BSD license (at your choice).
2 * Jean II
3 */
4
5 /* --------------------------- INCLUDE --------------------------- */
6
7 #define MAX_KEY_SIZE 16
8 #define MAX_KEYS 8
9 int key_on = 0;
10 int key_open = 1;
11 int key_current = 0;
12 char key_table[MAX_KEYS][MAX_KEY_SIZE];
13 int key_size[MAX_KEYS];
14
15 /* --------------------------- HANDLERS --------------------------- */
16
17 static int ioctl_set_encode(struct net_device *dev,
18 struct iw_request_info *info,
19 struct iw_point *erq,
20 char *key)
21 {
22 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
23
24 if (erq->length > 0)
25 {
26 /* Check the size of the key */
27 if(erq->length > MAX_KEY_SIZE)
28 return(-EINVAL);
29
30 /* Check the index */
31 if((index < 0) || (index >= MAX_KEYS))
32 index = key_current;
33
34 /* Copy the key in the driver */
35 memcpy(key_table[index], key, erq->length);
36 key_size[index] = erq->length;
37 key_on = 1;
38 }
39 else
40 {
41 /* Do we want to just set the current key ? */
42 if((index >= 0) && (index < MAX_KEYS))
43 {
44 if(key_size[index] > 0)
45 {
46 key_current = index;
47 key_on = 1;
48 }
49 else
50 return(-EINVAL);
51 }
52 }
53
54 /* Read the flags */
55 if(erq->flags & IW_ENCODE_DISABLED)
56 key_on = 0; /* disable encryption */
57 if(erq->flags & IW_ENCODE_RESTRICTED)
58 key_open = 0; /* disable open mode */
59 if(erq->flags & IW_ENCODE_OPEN)
60 key_open = 1; /* enable open mode */
61
62 return(0);
63 }
64
65 static int ioctl_get_encode(struct net_device *dev,
66 struct iw_request_info *info,
67 struct iw_point *erq,
68 char *key)
69 {
70 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
71
72 /* Set the flags */
73 erq->flags = 0;
74 if(key_on == 0)
75 erq->flags |= IW_ENCODE_DISABLED;
76 if(key_open == 0)
77 erq->flags |= IW_ENCODE_RESTRICTED;
78 else
79 erq->flags |= IW_ENCODE_OPEN;
80
81 /* Which key do we want */
82 if((index < 0) || (index >= MAX_KEYS))
83 index = key_current;
84 erq->flags |= index + 1;
85
86 /* Copy the key to the user buffer */
87 erq->length = key_size[index];
88 memcpy(key, key_table[index], key_size[index]);
89
90 return(0);
91 }
92
93 static int ioctl_get_range(struct net_device *dev,
94 struct iw_request_info *info,
95 struct iw_point *rrq,
96 char *extra)
97 {
98 struct iw_range *range = (struct iw_range *) extra;
99
100 rrq->length = sizeof(struct iw_range);
101
102 memset(range, 0, sizeof(struct iw_range));
103
104 #if WIRELESS_EXT > 10
105 /* Version we are compiled with */
106 range->we_version_compiled = WIRELESS_EXT;
107 /* Minimum version we recommend */
108 range->we_version_source = 8;
109 #endif /* WIRELESS_EXT > 10 */
110
111 #if WIRELESS_EXT > 8
112 range->encoding_size[0] = 8; /* DES = 64 bits key */
113 range->encoding_size[1] = 16;
114 range->num_encoding_sizes = 2;
115 range->max_encoding_tokens = 8;
116 #endif /* WIRELESS_EXT > 8 */
117 return(0);
118 }
119
120 /* --------------------------- BINDING --------------------------- */
121
122 #if WIRELESS_EXT > 12
123 static const iw_handler handler_table[] =
124 {
125 ...
126 (iw_handler) ioctl_set_encode, /* SIOCSIWENCODE */
127 (iw_handler) ioctl_get_encode, /* SIOCGIWENCODE */
128 };
129 #else /* WIRELESS_EXT < 12 */
130 static int
131 do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
132 {
133 struct iwreq *wrq = (struct iwreq *) ifr;
134 int err = 0;
135
136 switch (cmd)
137 {
138 #if WIRELESS_EXT > 8
139 case SIOCSIWENCODE:
140 {
141 char keybuf[MAX_KEY_SIZE];
142 if(wrq->u.encoding.pointer)
143 {
144 /* We actually have a key to set */
145 if(wrq->u.encoding.length > MAX_KEY_SIZE)
146 {
147 err = -E2BIG;
148 break;
149 }
150 if(copy_from_user(keybuf, wrq->u.encoding.pointer,
151 wrq->u.encoding.length))
152 {
153 err = -EFAULT;
154 break;
155 }
156 }
157 else
158 if(wrq->u.encoding.length != 0)
159 {
160 err = -EINVAL;
161 break;
162 }
163 err = ioctl_set_encode(dev, NULL, &(wrq->u.encoding), keybuf);
164 }
165 break;
166
167 case SIOCGIWENCODE:
168 /* only super-user can see encryption key */
169 if(! capable(CAP_NET_ADMIN))
170 {
171 err = -EPERM;
172 break;
173 }
174 {
175 char keybuf[MAX_KEY_SIZE];
176 err = ioctl_get_encode(dev, NULL, &(wrq->u.encoding), keybuf);
177 if(wrq->u.encoding.pointer)
178 {
179 if (copy_to_user(wrq->u.encoding.pointer, keybuf,
180 wrq->u.encoding.length))
181 err= -EFAULT;
182 }
183 }
184 break;
185 #endif /* WIRELESS_EXT > 8 */
186 }
187 return(err);
188 }
189 #endif /* WIRELESS_EXT < 12 */
190
+0
-234
src/lwe/sample_pm.c less more
0 /* Note : this particular snipset of code is available under
1 * the LGPL, MPL or BSD license (at your choice).
2 * Jean II
3 */
4
5 /* --------------------------- INCLUDE --------------------------- */
6
7 /* Backward compatibility for Wireless Extension 9 */
8 #ifndef IW_POWER_MODIFIER
9 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
10 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
11 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
12 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
13 #endif IW_POWER_MODIFIER
14
15 struct net_local {
16 int pm_on; // Power Management enabled
17 int pm_multi; // Receive multicasts
18 int pm_period; // Power Management period
19 int pm_period_auto; // Power Management auto mode
20 int pm_max_period; // Power Management max period
21 int pm_min_period; // Power Management min period
22 int pm_timeout; // Power Management timeout
23 };
24
25 /* --------------------------- HANDLERS --------------------------- */
26
27 static int ioctl_set_power(struct net_device *dev,
28 struct iw_request_info *info,
29 struct iw_param *prq,
30 char *extra)
31 {
32 /* Disable it ? */
33 if(prq->disabled)
34 {
35 local->pm_on = 0;
36 }
37 else
38 {
39 /* Check mode */
40 switch(prq->flags & IW_POWER_MODE)
41 {
42 case IW_POWER_UNICAST_R:
43 local->pm_multi = 0;
44 local->need_commit = 1;
45 break;
46 case IW_POWER_ALL_R:
47 local->pm_multi = 1;
48 local->need_commit = 1;
49 break;
50 case IW_POWER_ON: /* None = ok */
51 break;
52 default: /* Invalid */
53 return(-EINVAL);
54 }
55 /* Set period */
56 if(prq->flags & IW_POWER_PERIOD)
57 {
58 int period = prq->value;
59 #if WIRELESS_EXT < 21
60 period /= 1000000;
61 #endif
62 /* Hum: check if within bounds... */
63
64 /* Activate PM */
65 local->pm_on = 1;
66 local->need_commit = 1;
67
68 /* Check min value */
69 if(prq->flags & IW_POWER_MIN)
70 {
71 local->pm_min_period = period;
72 local->pm_period_auto = 1;
73 }
74 else
75 /* Check max value */
76 if(prq->flags & IW_POWER_MAX)
77 {
78 local->pm_max_period = period;
79 local->pm_period_auto = 1;
80 }
81 else
82 {
83 /* Fixed value */
84 local->pm_period = period;
85 local->pm_period_auto = 0;
86 }
87 }
88 /* Set timeout */
89 if(prq->flags & IW_POWER_TIMEOUT)
90 {
91 /* Activate PM */
92 local->pm_on = 1;
93 local->need_commit = 1;
94 /* Fixed value in ms */
95 local->pm_timeout = prq->value/1000;
96 }
97 }
98
99 return(0);
100 }
101
102 static int ioctl_get_power(struct net_device *dev,
103 struct iw_request_info *info,
104 struct iw_param *prq,
105 char *extra)
106 {
107 prq->disabled = !local->pm_on;
108 /* By default, display the period */
109 if(!(prq->flags & IW_POWER_TIMEOUT))
110 {
111 int inc_flags = prq->flags;
112 prq->flags = IW_POWER_PERIOD | IW_POWER_RELATIVE;
113 /* Check if auto */
114 if(local->pm_period_auto)
115 {
116 /* By default, the min */
117 if(!(inc_flags & IW_POWER_MAX))
118 {
119 prq->value = local->pm_min_period;
120 #if WIRELESS_EXT < 21
121 prq->value *= 1000000;
122 #endif
123 prq->flags |= IW_POWER_MIN;
124 }
125 else
126 {
127 prq->value = local->pm_max_period;
128 #if WIRELESS_EXT < 21
129 prq->value *= 1000000;
130 #endif
131 prq->flags |= IW_POWER_MAX;
132 }
133 }
134 else
135 {
136 /* Fixed value. Check the flags */
137 if(inc_flags & (IW_POWER_MIN | IW_POWER_MAX))
138 return(-EINVAL);
139 else
140 {
141 prq->value = local->pm_period;
142 #if WIRELESS_EXT < 21
143 prq->value *= 1000000;
144 #endif
145 }
146 }
147 }
148 else
149 {
150 /* Deal with the timeout - always fixed */
151 prq->flags = IW_POWER_TIMEOUT;
152 prq->value = local->pm_timeout * 1000;
153 }
154 if(local->pm_multi)
155 prq->flags |= IW_POWER_ALL_R;
156 else
157 prq->flags |= IW_POWER_UNICAST_R;
158
159 return(0);
160 }
161
162 static int ioctl_get_range(struct net_device *dev,
163 struct iw_request_info *info,
164 struct iw_point *rrq,
165 char *extra)
166 {
167 struct iw_range *range = (struct iw_range *) extra;
168
169 rrq->length = sizeof(struct iw_range);
170
171 memset(range, 0, sizeof(struct iw_range));
172
173 #if WIRELESS_EXT > 10
174 /* Version we are compiled with */
175 range->we_version_compiled = WIRELESS_EXT;
176 /* Minimum version we recommend */
177 range->we_version_source = 8;
178 #endif /* WIRELESS_EXT > 10 */
179
180 #if WIRELESS_EXT > 9
181 #if WIRELESS_EXT < 21
182 range.min_pmp = 1000000; /* 1 units */
183 range.max_pmp = 12000000; /* 12 units */
184 #else
185 range.min_pmp = 1; /* 1 units */
186 range.max_pmp = 12; /* 12 units */
187 #endif
188 range.min_pmt = 1000; /* 1 ms */
189 range.max_pmt = 1000000; /* 1 s */
190 range.pmp_flags = IW_POWER_PERIOD | IW_POWER_RELATIVE |
191 IW_POWER_MIN | IW_POWER_MAX;
192 range.pmt_flags = IW_POWER_TIMEOUT;
193 range.pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
194 #endif /* WIRELESS_EXT > 9 */
195 return(0);
196 }
197
198 /* --------------------------- BINDING --------------------------- */
199
200 #if WIRELESS_EXT > 12
201 /* Use the new driver API, save overhead */
202 static const iw_handler handler_table[] =
203 {
204 ...
205 (iw_handler) ioctl_set_power, /* SIOCSIWPOWER */
206 (iw_handler) ioctl_get_power, /* SIOCGIWPOWER */
207 };
208 #else /* WIRELESS_EXT < 12 */
209 /* Use old API in the ioctl handler */
210 static int
211 do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
212 {
213 struct iwreq *wrq = (struct iwreq *) ifr;
214 int err = 0;
215
216 switch (cmd)
217 {
218 #if WIRELESS_EXT > 8
219 /* Set the desired Power Management mode */
220 case SIOCSIWPOWER:
221 err = ioctl_set_power(dev, NULL, &(wrq->u.power), NULL);
222 break;
223
224 /* Get the power management settings */
225 case SIOCGIWPOWER:
226 err = ioctl_get_power(dev, NULL, &(wrq->u.power), NULL);
227 break;
228 #endif /* WIRELESS_EXT > 8 */
229 }
230 return(err);
231 }
232 #endif /* WIRELESS_EXT < 12 */
233
+0
-210
src/lwe/sample_priv_addr.c less more
0 /* Note : this particular snipset of code is available under
1 * the LGPL, MPL or BSD license (at your choice).
2 * Jean II
3 */
4
5 // Require Wireless Tools 25 for sub-ioctl and addr support
6
7 /* --------------------------- INCLUDE --------------------------- */
8
9 #if WIRELESS_EXT <= 12
10 /* Wireless extensions backward compatibility */
11
12 /* We need the full definition for private ioctls */
13 struct iw_request_info
14 {
15 __u16 cmd; /* Wireless Extension command */
16 __u16 flags; /* More to come ;-) */
17 };
18 #endif /* WIRELESS_EXT <= 12 */
19
20 #ifndef IW_PRIV_TYPE_ADDR
21 #define IW_PRIV_TYPE_ADDR 0x6000
22 #endif /* IW_PRIV_TYPE_ADDR */
23
24 /* --------------------------- HANDLERS --------------------------- */
25
26 /* First method : using sub-ioctls.
27 * Note that sizeof(int + struct sockaddr) = 20 > 16, therefore the
28 * data is passed in (char *) extra, and sub-ioctl in data->flags. */
29 static int sample_ioctl_set_mac(struct net_device *dev,
30 struct iw_request_info *info,
31 struct iw_point *data,
32 struct sockaddr *mac_addr)
33 {
34 unsigned char * addr = (char *) &mac_addr->sa_data;
35
36 switch(data->flags) {
37 case 0:
38 printk(KERN_DEBUG "%s: mac_add %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
39 break;
40 case 1:
41 printk(KERN_DEBUG "%s: mac_del %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
42 break;
43 case 2:
44 printk(KERN_DEBUG "%s: mac_kick %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
45 break;
46 default:
47 printk(KERN_DEBUG "%s: mac_undefined %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
48 break;
49 }
50
51 return 0;
52 }
53
54 /* Second method : bind single handler to multiple ioctls.
55 * Note that sizeof(struct sockaddr) = 16 <= 16, therefore the
56 * data is passed in (struct iwreq) (and also mapped in extra).
57 */
58 static int sample_ioctl_set_addr(struct net_device *dev,
59 struct iw_request_info *info,
60 struct sockaddr *mac_addr, char *extra)
61 {
62 unsigned char * addr = (char *) &mac_addr->sa_data;
63
64 switch(info->cmd) {
65 case SIOCIWFIRSTPRIV + 28:
66 printk(KERN_DEBUG "%s: addr_add %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
67 break;
68 case SIOCIWFIRSTPRIV + 30:
69 printk(KERN_DEBUG "%s: addr_del %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
70 break;
71 default:
72 printk(KERN_DEBUG "%s: mac_undefined %02X:%02X:%02X:%02X:%02X:%02X\n", dev->name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
73 break;
74 }
75
76 return 0;
77 }
78
79 // Extra fun for testing
80 static int sample_ioctl_get_mac(struct net_device *dev,
81 struct iw_request_info *info,
82 struct iw_point *data,
83 struct sockaddr *mac_addr)
84 {
85 unsigned char fake_addr[6];
86 int i;
87 int j;
88
89 for(i = 0; i < 16; i++) {
90 /* Create a fake address */
91 for(j = 0; j < 6; j++)
92 fake_addr[j] = (unsigned char) ((j << 4) + i);
93 /* Put in in the table */
94 memcpy(&(mac_addr[i]).sa_data, fake_addr, ETH_ALEN);
95 mac_addr[i].sa_family = ARPHRD_ETHER;
96 }
97 data->length = 16;
98
99 return 0;
100 }
101
102 static int sample_ioctl_set_float(struct net_device *dev,
103 struct iw_request_info *info,
104 struct iw_freq *freq, char *extra)
105 {
106 printk(KERN_DEBUG "%s: set_float %d;%d\n",
107 dev->name, freq->m, freq->e);
108
109 return 0;
110 }
111
112 /* --------------------------- BINDING --------------------------- */
113
114 static const struct iw_priv_args sample_priv[] = {
115 // *** Method 1 : using sub-ioctls ***
116 /* --- sub-ioctls handler --- */
117 { SIOCIWFIRSTPRIV + 0,
118 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "" },
119 /* --- sub-ioctls definitions --- */
120 { 0,
121 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "macadd" },
122 { 1,
123 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "macdel" },
124 { 2,
125 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "mackick" },
126 // *** Method 2 : binding one handler to multiple ioctls ***
127 { SIOCIWFIRSTPRIV + 2,
128 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "addradd" },
129 { SIOCIWFIRSTPRIV + 4,
130 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "addrdel" },
131 // *** Extra fun ***
132 { SIOCIWFIRSTPRIV + 1,
133 0, IW_PRIV_TYPE_ADDR | 16, "macget" },
134 { SIOCIWFIRSTPRIV + 6,
135 IW_PRIV_TYPE_FLOAT | IW_PRIV_SIZE_FIXED | 1, 0, "setfloat" },
136 };
137
138 static const iw_handler sample_private_handler[] =
139 { /* SIOCIWFIRSTPRIV + */
140 #if WIRELESS_EXT >= 15
141 /* Various little annoying bugs in the new API before
142 * version 15 make it difficult to use the new API for those ioctls.
143 * For example, it doesn't know about the new data type.
144 * Rather than littering the code with workarounds,
145 * let's use the regular ioctl handler. - Jean II */
146 (iw_handler) sample_ioctl_set_mac, /* 0 */
147 (iw_handler) sample_ioctl_get_mac, /* 1 */
148 (iw_handler) sample_ioctl_set_addr, /* 2 */
149 (iw_handler) NULL, /* 3 */
150 (iw_handler) sample_ioctl_set_addr, /* 4 */
151 (iw_handler) NULL, /* 5 */
152 (iw_handler) sample_ioctl_set_float, /* 6 */
153 #endif /* WIRELESS_EXT >= 15 */
154 };
155
156 #if WIRELESS_EXT < 15
157 /* Various little annoying bugs in the new API before
158 * version 15 make it difficult to use those ioctls.
159 * For example, it doesn't know about the new data type.
160 * Rather than littering the code with workarounds,
161 * let's use this code that just works. - Jean II */
162 case SIOCIWFIRSTPRIV + 0:
163 if (wrq->u.data.length > 1)
164 ret = -E2BIG;
165 else if (wrq->u.data.pointer) {
166 struct sockaddr mac_addr;
167 if (copy_from_user(&mac_addr, wrq->u.data.pointer,
168 sizeof(struct sockaddr))) {
169 ret = -EFAULT;
170 break;
171 }
172 ret = sample_ioctl_set_mac(dev, NULL, &wrq->u.data,
173 &mac_addr);
174 }
175 break;
176 case SIOCIWFIRSTPRIV + 2:
177 case SIOCIWFIRSTPRIV + 4:
178 if (!capable(CAP_NET_ADMIN))
179 ret = -EPERM;
180 else {
181 struct iw_request_info info;
182 info.cmd = cmd;
183 ret = sample_ioctl_set_addr(dev, &info,
184 &wrq->u.ap_addr,
185 NULL);
186 }
187 break;
188 case SIOCIWFIRSTPRIV + 1:
189 if (wrq->u.essid.pointer) {
190 struct sockaddr mac_addr[16];
191 char nickbuf[IW_ESSID_MAX_SIZE + 1];
192 ret = sample_ioctl_get_mac(dev, NULL, &wrq->u.data,
193 mac_addr);
194 if (copy_to_user(wrq->u.data.pointer, nickbuf,
195 wrq->u.data.length *
196 sizeof(struct sockaddr)))
197 ret = -EFAULT;
198 }
199 break;
200 case SIOCIWFIRSTPRIV + 6:
201 if (!capable(CAP_NET_ADMIN))
202 ret = -EPERM;
203 else {
204 ret = sample_ioctl_set_float(dev, NULL,
205 &wrq->u.freq,
206 NULL);
207 }
208 break;
209 #endif /* WIRELESS_EXT < 15 */
+0
-39
src/lwe/udev.import_devpath.diff less more
0 diff -u -p udev-106/udev_rules.j1.c udev-106/udev_rules.c
1 --- udev-106/udev_rules.j1.c 2007-03-15 10:07:51.000000000 -0700
2 +++ udev-106/udev_rules.c 2007-03-15 10:09:50.000000000 -0700
3 @@ -186,7 +186,16 @@ static int import_keys_into_env(struct u
4 linepos = line;
5 if (get_key(&linepos, &variable, &value) == 0) {
6 dbg("import '%s=%s'", variable, value);
7 - name_list_key_add(&udev->env_list, variable, value);
8 + /* handle device, renamed by external tool,
9 + * returning new path */
10 + if (strcmp(variable, "DEVPATH") == 0) {
11 + info("updating devpath from '%s' to '%s'",
12 + udev->dev->devpath, value);
13 + sysfs_device_set_values(udev->dev, value,
14 + NULL, NULL);
15 + } else
16 + name_list_key_add(&udev->env_list,
17 + variable, value);
18 setenv(variable, value, 1);
19 }
20 }
21 diff -u -p udev-106/udevtest.j1.c udev-106/udevtest.c
22 --- udev-106/udevtest.j1.c 2007-03-15 10:39:16.000000000 -0700
23 +++ udev-106/udevtest.c 2007-03-15 10:42:09.000000000 -0700
24 @@ -59,8 +59,13 @@ int main(int argc, char *argv[], char *e
25
26 info("version %s", UDEV_VERSION);
27 udev_config_init();
28 - if (udev_log_priority < LOG_INFO)
29 + if (udev_log_priority < LOG_INFO) {
30 + char priority[32];
31 +
32 udev_log_priority = LOG_INFO;
33 + sprintf(priority, "%i", udev_log_priority);
34 + setenv("UDEV_LOG", priority, 1);
35 + }
36
37 for (i = 1 ; i < argc; i++) {
38 char *arg = argv[i];
+0
-479
src/lwe/wireless.10.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 9 16.10.99
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 */
7
8 #ifndef _LINUX_WIRELESS_H
9 #define _LINUX_WIRELESS_H
10
11 /************************** DOCUMENTATION **************************/
12 /*
13 * Basically, the wireless extensions are for now a set of standard ioctl
14 * call + /proc/net/wireless
15 *
16 * The entry /proc/net/wireless give statistics and information on the
17 * driver.
18 * This is better than having each driver having its entry because
19 * its centralised and we may remove the driver module safely.
20 *
21 * Ioctl are used to configure the driver and issue commands. This is
22 * better than command line options of insmod because we may want to
23 * change dynamically (while the driver is running) some parameters.
24 *
25 * The ioctl mechanimsm are copied from standard devices ioctl.
26 * We have the list of command plus a structure descibing the
27 * data exchanged...
28 * Note that to add these ioctl, I was obliged to modify :
29 * net/core/dev.c (two place + add include)
30 * net/ipv4/af_inet.c (one place + add include)
31 *
32 * /proc/net/wireless is a copy of /proc/net/dev.
33 * We have a structure for data passed from the driver to /proc/net/wireless
34 * Too add this, I've modified :
35 * net/core/dev.c (two other places)
36 * include/linux/netdevice.h (one place)
37 * include/linux/proc_fs.h (one place)
38 *
39 * Do not add here things that are redundant with other mechanisms
40 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
41 * wireless specific.
42 *
43 * These wireless extensions are not magic : each driver has to provide
44 * support for them...
45 *
46 * IMPORTANT NOTE : As everything in the kernel, this is very much a
47 * work in progress. Contact me if you have ideas of improvements...
48 */
49
50 /***************************** INCLUDES *****************************/
51
52 #include <linux/types.h> /* for "caddr_t" et al */
53 #include <linux/socket.h> /* for "struct sockaddr" et al */
54 #include <linux/if.h> /* for IFNAMSIZ and co... */
55
56 /**************************** CONSTANTS ****************************/
57
58 /* --------------------------- VERSION --------------------------- */
59 /*
60 * This constant is used to know the availability of the wireless
61 * extensions and to know which version of wireless extensions it is
62 * (there is some stuff that will be added in the future...)
63 * I just plan to increment with each new version.
64 */
65 #define WIRELESS_EXT 10
66
67 /*
68 * Changes :
69 *
70 * V2 to V3
71 * --------
72 * Alan Cox start some incompatibles changes. I've integrated a bit more.
73 * - Encryption renamed to Encode to avoid US regulation problems
74 * - Frequency changed from float to struct to avoid problems on old 386
75 *
76 * V3 to V4
77 * --------
78 * - Add sensitivity
79 *
80 * V4 to V5
81 * --------
82 * - Missing encoding definitions in range
83 * - Access points stuff
84 *
85 * V5 to V6
86 * --------
87 * - 802.11 support (ESSID ioctls)
88 *
89 * V6 to V7
90 * --------
91 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
92 *
93 * V7 to V8
94 * --------
95 * - Changed my e-mail address
96 * - More 802.11 support (nickname, rate, rts, frag)
97 * - List index in frequencies
98 *
99 * V8 to V9
100 * --------
101 * - Support for 'mode of operation' (ad-hoc, managed...)
102 * - Support for unicast and multicast power saving
103 * - Change encoding to support larger tokens (>64 bits)
104 * - Updated iw_params (disable, flags) and use it for NWID
105 * - Extracted iw_point from iwreq for clarity
106 *
107 * V9 to V10
108 * ---------
109 * - Add PM capability to range structure
110 * - Add PM modifier : MAX/MIN/RELATIVE
111 * - Add encoding option : IW_ENCODE_NOKEY
112 * - Add TxPower ioctls (work like TxRate)
113 */
114
115 /* -------------------------- IOCTL LIST -------------------------- */
116
117 /* Basic operations */
118 #define SIOCSIWNAME 0x8B00 /* Unused */
119 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
120 #define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
121 #define SIOCGIWNWID 0x8B03 /* get network id */
122 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
123 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
124 #define SIOCSIWMODE 0x8B06 /* set operation mode */
125 #define SIOCGIWMODE 0x8B07 /* get operation mode */
126 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
127 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
128
129 /* Informative stuff */
130 #define SIOCSIWRANGE 0x8B0A /* Unused */
131 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
132 #define SIOCSIWPRIV 0x8B0C /* Unused */
133 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
134
135 /* Mobile IP support */
136 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
137 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
138
139 /* Access Point manipulation */
140 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
141 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
142 #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
143
144 /* 802.11 specific support */
145 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
146 #define SIOCGIWESSID 0x8B1B /* get ESSID */
147 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
148 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
149 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
150 * within the 'iwreq' structure, so we need to use the 'data' member to
151 * point to a string in user space, like it is done for RANGE...
152 * The "flags" member indicate if the ESSID is active or not (promiscuous).
153 */
154
155 /* Other parameters usefull in 802.11 and some other devices */
156 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
157 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
158 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
159 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
160 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
161 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
162 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
163 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
164
165 /* Encoding stuff (scrambling, hardware security, WEP...) */
166 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
167 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
168 /* Power saving stuff (power management, unicast and multicast) */
169 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
170 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
171
172 /* ------------------------- IOCTL STUFF ------------------------- */
173
174 /* The first and the last (range) */
175 #define SIOCIWFIRST 0x8B00
176 #define SIOCIWLAST 0x8B30
177
178 /* Even : get (world access), odd : set (root access) */
179 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
180 #define IW_IS_GET(cmd) ((cmd) & 0x1)
181
182 /* ------------------------- PRIVATE INFO ------------------------- */
183 /*
184 * The following is used with SIOCGIWPRIV. It allow a driver to define
185 * the interface (name, type of data) for its private ioctl.
186 * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
187 */
188
189 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
190 #define IW_PRIV_TYPE_NONE 0x0000
191 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
192 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
193 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
194 #define IW_PRIV_TYPE_FLOAT 0x5000
195
196 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
197
198 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
199
200 /*
201 * Note : if the number of args is fixed and the size < 16 octets,
202 * instead of passing a pointer we will put args in the iwreq struct...
203 */
204
205 /* ----------------------- OTHER CONSTANTS ----------------------- */
206
207 /* Maximum frequencies in the range struct */
208 #define IW_MAX_FREQUENCIES 16
209 /* Note : if you have something like 80 frequencies,
210 * don't increase this constant and don't fill the frequency list.
211 * The user will be able to set by channel anyway... */
212
213 /* Maximum bit rates in the range struct */
214 #define IW_MAX_BITRATES 8
215
216 /* Maximum tx powers in the range struct */
217 #define IW_MAX_TXPOWER 8
218
219 /* Maximum of address that you may set with SPY */
220 #define IW_MAX_SPY 8
221
222 /* Maximum of address that you may get in the
223 list of access points in range */
224 #define IW_MAX_AP 8
225
226 /* Maximum size of the ESSID and NICKN strings */
227 #define IW_ESSID_MAX_SIZE 32
228
229 /* Modes of operation */
230 #define IW_MODE_AUTO 0 /* Let the driver decides */
231 #define IW_MODE_ADHOC 1 /* Single cell network */
232 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
233 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
234 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
235 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
236
237 /* Maximum number of size of encoding token available
238 * they are listed in the range structure */
239 #define IW_MAX_ENCODING_SIZES 8
240
241 /* Maximum size of the encoding token in bytes */
242 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
243
244 /* Flags for encoding (along with the token) */
245 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
246 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
247 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
248 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
249 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
250 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
251 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
252 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
253
254 /* Power management flags available (along with the value, if any) */
255 #define IW_POWER_ON 0x0000 /* No details... */
256 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
257 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
258 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
259 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
260 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
261 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
262 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
263 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
264 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
265 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
266 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
267 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
268 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
269
270 /* Transmit Power flags available */
271 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
272 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
273
274 /****************************** TYPES ******************************/
275
276 /* --------------------------- SUBTYPES --------------------------- */
277 /*
278 * Generic format for most parameters that fit in an int
279 */
280 struct iw_param
281 {
282 __s32 value; /* The value of the parameter itself */
283 __u8 fixed; /* Hardware should not use auto select */
284 __u8 disabled; /* Disable the feature */
285 __u16 flags; /* Various specifc flags (if any) */
286 };
287
288 /*
289 * For all data larger than 16 octets, we need to use a
290 * pointer to memory alocated in user space.
291 */
292 struct iw_point
293 {
294 caddr_t pointer; /* Pointer to the data (in user space) */
295 __u16 length; /* number of fields or size in bytes */
296 __u16 flags; /* Optional params */
297 };
298
299 /*
300 * A frequency
301 * For numbers lower than 10^9, we encode the number in 'm' and
302 * set 'e' to 0
303 * For number greater than 10^9, we divide it by the lowest power
304 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
305 * The power of 10 is in 'e', the result of the division is in 'm'.
306 */
307 struct iw_freq
308 {
309 __u32 m; /* Mantissa */
310 __u16 e; /* Exponent */
311 __u8 i; /* List index (when in range struct) */
312 };
313
314 /*
315 * Quality of the link
316 */
317 struct iw_quality
318 {
319 __u8 qual; /* link quality (%retries, SNR or better...) */
320 __u8 level; /* signal level */
321 __u8 noise; /* noise level */
322 __u8 updated; /* Flags to know if updated */
323 };
324
325 /*
326 * Packet discarded in the wireless adapter due to
327 * "wireless" specific problems...
328 */
329 struct iw_discarded
330 {
331 __u32 nwid; /* Wrong nwid */
332 __u32 code; /* Unable to code/decode */
333 __u32 misc; /* Others cases */
334 };
335
336 /* ------------------------ WIRELESS STATS ------------------------ */
337 /*
338 * Wireless statistics (used for /proc/net/wireless)
339 */
340 struct iw_statistics
341 {
342 __u16 status; /* Status
343 * - device dependent for now */
344
345 struct iw_quality qual; /* Quality of the link
346 * (instant/mean/max) */
347 struct iw_discarded discard; /* Packet discarded counts */
348 };
349
350 /* ------------------------ IOCTL REQUEST ------------------------ */
351 /*
352 * The structure to exchange data for ioctl.
353 * This structure is the same as 'struct ifreq', but (re)defined for
354 * convenience...
355 *
356 * Note that it should fit on the same memory footprint !
357 * You should check this when increasing the above structures (16 octets)
358 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
359 */
360 struct iwreq
361 {
362 union
363 {
364 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
365 } ifr_ifrn;
366
367 /* Data part */
368 union
369 {
370 /* Config - generic */
371 char name[IFNAMSIZ];
372 /* Name : used to verify the presence of wireless extensions.
373 * Name of the protocol/provider... */
374
375 struct iw_point essid; /* Extended network name */
376 struct iw_param nwid; /* network id (or domain - the cell) */
377 struct iw_freq freq; /* frequency or channel :
378 * 0-1000 = channel
379 * > 1000 = frequency in Hz */
380
381 struct iw_param sens; /* signal level threshold */
382 struct iw_param bitrate; /* default bit rate */
383 struct iw_param txpower; /* default transmit power */
384 struct iw_param rts; /* RTS threshold threshold */
385 struct iw_param frag; /* Fragmentation threshold */
386 __u32 mode; /* Operation mode */
387
388 struct iw_point encoding; /* Encoding stuff : tokens */
389 struct iw_param power; /* PM duration/timeout */
390
391 struct sockaddr ap_addr; /* Access point address */
392
393 struct iw_point data; /* Other large parameters */
394 } u;
395 };
396
397 /* -------------------------- IOCTL DATA -------------------------- */
398 /*
399 * For those ioctl which want to exchange mode data that what could
400 * fit in the above structure...
401 */
402
403 /*
404 * Range of parameters
405 */
406
407 struct iw_range
408 {
409 /* Informative stuff (to choose between different interface) */
410 __u32 throughput; /* To give an idea... */
411 /* In theory this value should be the maximum benchmarked
412 * TCP/IP throughput, because with most of these devices the
413 * bit rate is meaningless (overhead an co) to estimate how
414 * fast the connection will go and pick the fastest one.
415 * I suggest people to play with Netperf or any benchmark...
416 */
417
418 /* NWID (or domain id) */
419 __u32 min_nwid; /* Minimal NWID we are able to set */
420 __u32 max_nwid; /* Maximal NWID we are able to set */
421
422 /* Frequency */
423 __u16 num_channels; /* Number of channels [0; num - 1] */
424 __u8 num_frequency; /* Number of entry in the list */
425 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
426 /* Note : this frequency list doesn't need to fit channel numbers */
427
428 /* signal level threshold range */
429 __s32 sensitivity;
430
431 /* Quality of link & SNR stuff */
432 struct iw_quality max_qual; /* Quality of the link */
433
434 /* Rates */
435 __u8 num_bitrates; /* Number of entries in the list */
436 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
437
438 /* RTS threshold */
439 __s32 min_rts; /* Minimal RTS threshold */
440 __s32 max_rts; /* Maximal RTS threshold */
441
442 /* Frag threshold */
443 __s32 min_frag; /* Minimal frag threshold */
444 __s32 max_frag; /* Maximal frag threshold */
445
446 /* Power Management duration & timeout */
447 __s32 min_pmp; /* Minimal PM period */
448 __s32 max_pmp; /* Maximal PM period */
449 __s32 min_pmt; /* Minimal PM timeout */
450 __s32 max_pmt; /* Maximal PM timeout */
451 __u16 pmp_flags; /* How to decode max/min PM period */
452 __u16 pmt_flags; /* How to decode max/min PM timeout */
453 __u16 pm_capa; /* What PM options are supported */
454
455 /* Encoder stuff */
456 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
457 __u8 num_encoding_sizes; /* Number of entry in the list */
458 __u8 max_encoding_tokens; /* Max number of tokens */
459
460 /* Transmit power */
461 __u16 txpower_capa; /* What options are supported */
462 __u8 num_txpower; /* Number of entries in the list */
463 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
464 };
465
466 /*
467 * Private ioctl interface information
468 */
469
470 struct iw_priv_args
471 {
472 __u32 cmd; /* Number of the ioctl to issue */
473 __u16 set_args; /* Type and number of args */
474 __u16 get_args; /* Type and number of args */
475 char name[IFNAMSIZ]; /* Name of the extension */
476 };
477
478 #endif /* _LINUX_WIRELESS_H */
+0
-510
src/lwe/wireless.11.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 11 28.3.01
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 */
7
8 #ifndef _LINUX_WIRELESS_H
9 #define _LINUX_WIRELESS_H
10
11 /************************** DOCUMENTATION **************************/
12 /*
13 * Basically, the wireless extensions are for now a set of standard ioctl
14 * call + /proc/net/wireless
15 *
16 * The entry /proc/net/wireless give statistics and information on the
17 * driver.
18 * This is better than having each driver having its entry because
19 * its centralised and we may remove the driver module safely.
20 *
21 * Ioctl are used to configure the driver and issue commands. This is
22 * better than command line options of insmod because we may want to
23 * change dynamically (while the driver is running) some parameters.
24 *
25 * The ioctl mechanimsm are copied from standard devices ioctl.
26 * We have the list of command plus a structure descibing the
27 * data exchanged...
28 * Note that to add these ioctl, I was obliged to modify :
29 * net/core/dev.c (two place + add include)
30 * net/ipv4/af_inet.c (one place + add include)
31 *
32 * /proc/net/wireless is a copy of /proc/net/dev.
33 * We have a structure for data passed from the driver to /proc/net/wireless
34 * Too add this, I've modified :
35 * net/core/dev.c (two other places)
36 * include/linux/netdevice.h (one place)
37 * include/linux/proc_fs.h (one place)
38 *
39 * Do not add here things that are redundant with other mechanisms
40 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
41 * wireless specific.
42 *
43 * These wireless extensions are not magic : each driver has to provide
44 * support for them...
45 *
46 * IMPORTANT NOTE : As everything in the kernel, this is very much a
47 * work in progress. Contact me if you have ideas of improvements...
48 */
49
50 /***************************** INCLUDES *****************************/
51
52 #include <linux/types.h> /* for "caddr_t" et al */
53 #include <linux/socket.h> /* for "struct sockaddr" et al */
54 #include <linux/if.h> /* for IFNAMSIZ and co... */
55
56 /**************************** CONSTANTS ****************************/
57
58 /* --------------------------- VERSION --------------------------- */
59 /*
60 * This constant is used to know the availability of the wireless
61 * extensions and to know which version of wireless extensions it is
62 * (there is some stuff that will be added in the future...)
63 * I just plan to increment with each new version.
64 */
65 #define WIRELESS_EXT 11
66
67 /*
68 * Changes :
69 *
70 * V2 to V3
71 * --------
72 * Alan Cox start some incompatibles changes. I've integrated a bit more.
73 * - Encryption renamed to Encode to avoid US regulation problems
74 * - Frequency changed from float to struct to avoid problems on old 386
75 *
76 * V3 to V4
77 * --------
78 * - Add sensitivity
79 *
80 * V4 to V5
81 * --------
82 * - Missing encoding definitions in range
83 * - Access points stuff
84 *
85 * V5 to V6
86 * --------
87 * - 802.11 support (ESSID ioctls)
88 *
89 * V6 to V7
90 * --------
91 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
92 *
93 * V7 to V8
94 * --------
95 * - Changed my e-mail address
96 * - More 802.11 support (nickname, rate, rts, frag)
97 * - List index in frequencies
98 *
99 * V8 to V9
100 * --------
101 * - Support for 'mode of operation' (ad-hoc, managed...)
102 * - Support for unicast and multicast power saving
103 * - Change encoding to support larger tokens (>64 bits)
104 * - Updated iw_params (disable, flags) and use it for NWID
105 * - Extracted iw_point from iwreq for clarity
106 *
107 * V9 to V10
108 * ---------
109 * - Add PM capability to range structure
110 * - Add PM modifier : MAX/MIN/RELATIVE
111 * - Add encoding option : IW_ENCODE_NOKEY
112 * - Add TxPower ioctls (work like TxRate)
113 *
114 * V10 to V11
115 * ----------
116 * - Add WE version in range (help backward/forward compatibility)
117 * - Add retry ioctls (work like PM)
118 */
119
120 /* -------------------------- IOCTL LIST -------------------------- */
121
122 /* Basic operations */
123 #define SIOCSIWNAME 0x8B00 /* Unused */
124 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
125 #define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
126 #define SIOCGIWNWID 0x8B03 /* get network id */
127 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
128 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
129 #define SIOCSIWMODE 0x8B06 /* set operation mode */
130 #define SIOCGIWMODE 0x8B07 /* get operation mode */
131 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
132 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
133
134 /* Informative stuff */
135 #define SIOCSIWRANGE 0x8B0A /* Unused */
136 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
137 #define SIOCSIWPRIV 0x8B0C /* Unused */
138 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
139
140 /* Mobile IP support */
141 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
142 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
143
144 /* Access Point manipulation */
145 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
146 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
147 #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
148
149 /* 802.11 specific support */
150 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
151 #define SIOCGIWESSID 0x8B1B /* get ESSID */
152 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
153 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
154 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
155 * within the 'iwreq' structure, so we need to use the 'data' member to
156 * point to a string in user space, like it is done for RANGE...
157 * The "flags" member indicate if the ESSID is active or not (promiscuous).
158 */
159
160 /* Other parameters usefull in 802.11 and some other devices */
161 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
162 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
163 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
164 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
165 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
166 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
167 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
168 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
169 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
170 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
171
172 /* Encoding stuff (scrambling, hardware security, WEP...) */
173 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
174 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
175 /* Power saving stuff (power management, unicast and multicast) */
176 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
177 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
178
179 /* ------------------------- IOCTL STUFF ------------------------- */
180
181 /* The first and the last (range) */
182 #define SIOCIWFIRST 0x8B00
183 #define SIOCIWLAST 0x8B30
184
185 /* Even : get (world access), odd : set (root access) */
186 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
187 #define IW_IS_GET(cmd) ((cmd) & 0x1)
188
189 /* ------------------------- PRIVATE INFO ------------------------- */
190 /*
191 * The following is used with SIOCGIWPRIV. It allow a driver to define
192 * the interface (name, type of data) for its private ioctl.
193 * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF
194 */
195
196 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
197 #define IW_PRIV_TYPE_NONE 0x0000
198 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
199 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
200 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
201 #define IW_PRIV_TYPE_FLOAT 0x5000
202
203 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
204
205 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
206
207 /*
208 * Note : if the number of args is fixed and the size < 16 octets,
209 * instead of passing a pointer we will put args in the iwreq struct...
210 */
211
212 /* ----------------------- OTHER CONSTANTS ----------------------- */
213
214 /* Maximum frequencies in the range struct */
215 #define IW_MAX_FREQUENCIES 16
216 /* Note : if you have something like 80 frequencies,
217 * don't increase this constant and don't fill the frequency list.
218 * The user will be able to set by channel anyway... */
219
220 /* Maximum bit rates in the range struct */
221 #define IW_MAX_BITRATES 8
222
223 /* Maximum tx powers in the range struct */
224 #define IW_MAX_TXPOWER 8
225
226 /* Maximum of address that you may set with SPY */
227 #define IW_MAX_SPY 8
228
229 /* Maximum of address that you may get in the
230 list of access points in range */
231 #define IW_MAX_AP 8
232
233 /* Maximum size of the ESSID and NICKN strings */
234 #define IW_ESSID_MAX_SIZE 32
235
236 /* Modes of operation */
237 #define IW_MODE_AUTO 0 /* Let the driver decides */
238 #define IW_MODE_ADHOC 1 /* Single cell network */
239 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
240 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
241 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
242 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
243
244 /* Maximum number of size of encoding token available
245 * they are listed in the range structure */
246 #define IW_MAX_ENCODING_SIZES 8
247
248 /* Maximum size of the encoding token in bytes */
249 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
250
251 /* Flags for encoding (along with the token) */
252 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
253 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
254 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
255 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
256 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
257 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
258 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
259 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
260
261 /* Power management flags available (along with the value, if any) */
262 #define IW_POWER_ON 0x0000 /* No details... */
263 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
264 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
265 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
266 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
267 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
268 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
269 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
270 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
271 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
272 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
273 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
274 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
275 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
276
277 /* Transmit Power flags available */
278 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
279 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
280
281 /* Retry limits and lifetime flags available */
282 #define IW_RETRY_ON 0x0000 /* No details... */
283 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
284 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
285 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
286 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
287 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
288 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
289 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
290
291 /****************************** TYPES ******************************/
292
293 /* --------------------------- SUBTYPES --------------------------- */
294 /*
295 * Generic format for most parameters that fit in an int
296 */
297 struct iw_param
298 {
299 __s32 value; /* The value of the parameter itself */
300 __u8 fixed; /* Hardware should not use auto select */
301 __u8 disabled; /* Disable the feature */
302 __u16 flags; /* Various specifc flags (if any) */
303 };
304
305 /*
306 * For all data larger than 16 octets, we need to use a
307 * pointer to memory alocated in user space.
308 */
309 struct iw_point
310 {
311 caddr_t pointer; /* Pointer to the data (in user space) */
312 __u16 length; /* number of fields or size in bytes */
313 __u16 flags; /* Optional params */
314 };
315
316 /*
317 * A frequency
318 * For numbers lower than 10^9, we encode the number in 'm' and
319 * set 'e' to 0
320 * For number greater than 10^9, we divide it by the lowest power
321 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
322 * The power of 10 is in 'e', the result of the division is in 'm'.
323 */
324 struct iw_freq
325 {
326 __u32 m; /* Mantissa */
327 __u16 e; /* Exponent */
328 __u8 i; /* List index (when in range struct) */
329 };
330
331 /*
332 * Quality of the link
333 */
334 struct iw_quality
335 {
336 __u8 qual; /* link quality (%retries, SNR or better...) */
337 __u8 level; /* signal level */
338 __u8 noise; /* noise level */
339 __u8 updated; /* Flags to know if updated */
340 };
341
342 /*
343 * Packet discarded in the wireless adapter due to
344 * "wireless" specific problems...
345 */
346 struct iw_discarded
347 {
348 __u32 nwid; /* Wrong nwid */
349 __u32 code; /* Unable to code/decode */
350 __u32 misc; /* Others cases */
351 };
352
353 /* ------------------------ WIRELESS STATS ------------------------ */
354 /*
355 * Wireless statistics (used for /proc/net/wireless)
356 */
357 struct iw_statistics
358 {
359 __u16 status; /* Status
360 * - device dependent for now */
361
362 struct iw_quality qual; /* Quality of the link
363 * (instant/mean/max) */
364 struct iw_discarded discard; /* Packet discarded counts */
365 };
366
367 /* ------------------------ IOCTL REQUEST ------------------------ */
368 /*
369 * The structure to exchange data for ioctl.
370 * This structure is the same as 'struct ifreq', but (re)defined for
371 * convenience...
372 *
373 * Note that it should fit on the same memory footprint !
374 * You should check this when increasing the above structures (16 octets)
375 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
376 */
377 struct iwreq
378 {
379 union
380 {
381 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
382 } ifr_ifrn;
383
384 /* Data part */
385 union
386 {
387 /* Config - generic */
388 char name[IFNAMSIZ];
389 /* Name : used to verify the presence of wireless extensions.
390 * Name of the protocol/provider... */
391
392 struct iw_point essid; /* Extended network name */
393 struct iw_param nwid; /* network id (or domain - the cell) */
394 struct iw_freq freq; /* frequency or channel :
395 * 0-1000 = channel
396 * > 1000 = frequency in Hz */
397
398 struct iw_param sens; /* signal level threshold */
399 struct iw_param bitrate; /* default bit rate */
400 struct iw_param txpower; /* default transmit power */
401 struct iw_param rts; /* RTS threshold threshold */
402 struct iw_param frag; /* Fragmentation threshold */
403 __u32 mode; /* Operation mode */
404 struct iw_param retry; /* Retry limits & lifetime */
405
406 struct iw_point encoding; /* Encoding stuff : tokens */
407 struct iw_param power; /* PM duration/timeout */
408
409 struct sockaddr ap_addr; /* Access point address */
410
411 struct iw_point data; /* Other large parameters */
412 } u;
413 };
414
415 /* -------------------------- IOCTL DATA -------------------------- */
416 /*
417 * For those ioctl which want to exchange mode data that what could
418 * fit in the above structure...
419 */
420
421 /*
422 * Range of parameters
423 */
424
425 struct iw_range
426 {
427 /* Informative stuff (to choose between different interface) */
428 __u32 throughput; /* To give an idea... */
429 /* In theory this value should be the maximum benchmarked
430 * TCP/IP throughput, because with most of these devices the
431 * bit rate is meaningless (overhead an co) to estimate how
432 * fast the connection will go and pick the fastest one.
433 * I suggest people to play with Netperf or any benchmark...
434 */
435
436 /* NWID (or domain id) */
437 __u32 min_nwid; /* Minimal NWID we are able to set */
438 __u32 max_nwid; /* Maximal NWID we are able to set */
439
440 /* Frequency */
441 __u16 num_channels; /* Number of channels [0; num - 1] */
442 __u8 num_frequency; /* Number of entry in the list */
443 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
444 /* Note : this frequency list doesn't need to fit channel numbers */
445
446 /* signal level threshold range */
447 __s32 sensitivity;
448
449 /* Quality of link & SNR stuff */
450 struct iw_quality max_qual; /* Quality of the link */
451
452 /* Rates */
453 __u8 num_bitrates; /* Number of entries in the list */
454 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
455
456 /* RTS threshold */
457 __s32 min_rts; /* Minimal RTS threshold */
458 __s32 max_rts; /* Maximal RTS threshold */
459
460 /* Frag threshold */
461 __s32 min_frag; /* Minimal frag threshold */
462 __s32 max_frag; /* Maximal frag threshold */
463
464 /* Power Management duration & timeout */
465 __s32 min_pmp; /* Minimal PM period */
466 __s32 max_pmp; /* Maximal PM period */
467 __s32 min_pmt; /* Minimal PM timeout */
468 __s32 max_pmt; /* Maximal PM timeout */
469 __u16 pmp_flags; /* How to decode max/min PM period */
470 __u16 pmt_flags; /* How to decode max/min PM timeout */
471 __u16 pm_capa; /* What PM options are supported */
472
473 /* Encoder stuff */
474 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
475 __u8 num_encoding_sizes; /* Number of entry in the list */
476 __u8 max_encoding_tokens; /* Max number of tokens */
477
478 /* Transmit power */
479 __u16 txpower_capa; /* What options are supported */
480 __u8 num_txpower; /* Number of entries in the list */
481 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
482
483 /* Wireless Extension version info */
484 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
485 __u8 we_version_source; /* Last update of source */
486
487 /* Retry limits and lifetime */
488 __u16 retry_capa; /* What retry options are supported */
489 __u16 retry_flags; /* How to decode max/min retry limit */
490 __u16 r_time_flags; /* How to decode max/min retry life */
491 __s32 min_retry; /* Minimal number of retries */
492 __s32 max_retry; /* Maximal number of retries */
493 __s32 min_r_time; /* Minimal retry lifetime */
494 __s32 max_r_time; /* Maximal retry lifetime */
495 };
496
497 /*
498 * Private ioctl interface information
499 */
500
501 struct iw_priv_args
502 {
503 __u32 cmd; /* Number of the ioctl to issue */
504 __u16 set_args; /* Type and number of args */
505 __u16 get_args; /* Type and number of args */
506 char name[IFNAMSIZ]; /* Name of the extension */
507 };
508
509 #endif /* _LINUX_WIRELESS_H */
+0
-570
src/lwe/wireless.12.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 12 5.10.01
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 */
7
8 #ifndef _LINUX_WIRELESS_H
9 #define _LINUX_WIRELESS_H
10
11 /************************** DOCUMENTATION **************************/
12 /*
13 * Basically, the wireless extensions are for now a set of standard ioctl
14 * call + /proc/net/wireless
15 *
16 * The entry /proc/net/wireless give statistics and information on the
17 * driver.
18 * This is better than having each driver having its entry because
19 * its centralised and we may remove the driver module safely.
20 *
21 * Ioctl are used to configure the driver and issue commands. This is
22 * better than command line options of insmod because we may want to
23 * change dynamically (while the driver is running) some parameters.
24 *
25 * The ioctl mechanimsm are copied from standard devices ioctl.
26 * We have the list of command plus a structure descibing the
27 * data exchanged...
28 * Note that to add these ioctl, I was obliged to modify :
29 * net/core/dev.c (two place + add include)
30 * net/ipv4/af_inet.c (one place + add include)
31 *
32 * /proc/net/wireless is a copy of /proc/net/dev.
33 * We have a structure for data passed from the driver to /proc/net/wireless
34 * Too add this, I've modified :
35 * net/core/dev.c (two other places)
36 * include/linux/netdevice.h (one place)
37 * include/linux/proc_fs.h (one place)
38 *
39 * Do not add here things that are redundant with other mechanisms
40 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
41 * wireless specific.
42 *
43 * These wireless extensions are not magic : each driver has to provide
44 * support for them...
45 *
46 * IMPORTANT NOTE : As everything in the kernel, this is very much a
47 * work in progress. Contact me if you have ideas of improvements...
48 */
49
50 /***************************** INCLUDES *****************************/
51
52 #include <linux/types.h> /* for "caddr_t" et al */
53 #include <linux/socket.h> /* for "struct sockaddr" et al */
54 #include <linux/if.h> /* for IFNAMSIZ and co... */
55
56 /**************************** CONSTANTS ****************************/
57
58 /* --------------------------- VERSION --------------------------- */
59 /*
60 * This constant is used to know the availability of the wireless
61 * extensions and to know which version of wireless extensions it is
62 * (there is some stuff that will be added in the future...)
63 * I just plan to increment with each new version.
64 */
65 #define WIRELESS_EXT 12
66
67 /*
68 * Changes :
69 *
70 * V2 to V3
71 * --------
72 * Alan Cox start some incompatibles changes. I've integrated a bit more.
73 * - Encryption renamed to Encode to avoid US regulation problems
74 * - Frequency changed from float to struct to avoid problems on old 386
75 *
76 * V3 to V4
77 * --------
78 * - Add sensitivity
79 *
80 * V4 to V5
81 * --------
82 * - Missing encoding definitions in range
83 * - Access points stuff
84 *
85 * V5 to V6
86 * --------
87 * - 802.11 support (ESSID ioctls)
88 *
89 * V6 to V7
90 * --------
91 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
92 *
93 * V7 to V8
94 * --------
95 * - Changed my e-mail address
96 * - More 802.11 support (nickname, rate, rts, frag)
97 * - List index in frequencies
98 *
99 * V8 to V9
100 * --------
101 * - Support for 'mode of operation' (ad-hoc, managed...)
102 * - Support for unicast and multicast power saving
103 * - Change encoding to support larger tokens (>64 bits)
104 * - Updated iw_params (disable, flags) and use it for NWID
105 * - Extracted iw_point from iwreq for clarity
106 *
107 * V9 to V10
108 * ---------
109 * - Add PM capability to range structure
110 * - Add PM modifier : MAX/MIN/RELATIVE
111 * - Add encoding option : IW_ENCODE_NOKEY
112 * - Add TxPower ioctls (work like TxRate)
113 *
114 * V10 to V11
115 * ----------
116 * - Add WE version in range (help backward/forward compatibility)
117 * - Add retry ioctls (work like PM)
118 *
119 * V11 to V12
120 * ----------
121 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
122 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
123 * - Add new statistics (frag, retry, beacon)
124 * - Add average quality (for user space calibration)
125 */
126
127 /* -------------------------- IOCTL LIST -------------------------- */
128
129 /* Basic operations */
130 #define SIOCSIWNAME 0x8B00 /* Unused */
131 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
132 #define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
133 #define SIOCGIWNWID 0x8B03 /* get network id */
134 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
135 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
136 #define SIOCSIWMODE 0x8B06 /* set operation mode */
137 #define SIOCGIWMODE 0x8B07 /* get operation mode */
138 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
139 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
140
141 /* Informative stuff */
142 #define SIOCSIWRANGE 0x8B0A /* Unused */
143 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
144 #define SIOCSIWPRIV 0x8B0C /* Unused */
145 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
146 #define SIOCSIWSTATS 0x8B0E /* Unused */
147 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
148
149 /* Mobile IP support */
150 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
151 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
152
153 /* Access Point manipulation */
154 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
155 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
156 #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
157
158 /* 802.11 specific support */
159 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
160 #define SIOCGIWESSID 0x8B1B /* get ESSID */
161 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
162 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
163 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
164 * within the 'iwreq' structure, so we need to use the 'data' member to
165 * point to a string in user space, like it is done for RANGE...
166 * The "flags" member indicate if the ESSID is active or not (promiscuous).
167 */
168
169 /* Other parameters useful in 802.11 and some other devices */
170 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
171 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
172 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
173 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
174 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
175 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
176 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
177 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
178 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
179 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
180
181 /* Encoding stuff (scrambling, hardware security, WEP...) */
182 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
183 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
184 /* Power saving stuff (power management, unicast and multicast) */
185 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
186 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
187
188 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
189
190 /* These 16 ioctl are wireless device private.
191 * Each driver is free to use them for whatever purpose it chooses,
192 * however the driver *must* export the description of those ioctls
193 * with SIOCGIWPRIV and *must* use arguments as defined below.
194 * If you don't follow those rules, DaveM is going to hate you (reason :
195 * it make mixed 32/64bit operation impossible).
196 */
197 #define SIOCIWFIRSTPRIV 0x8BE0
198 #define SIOCIWLASTPRIV 0x8BFF
199 /* Previously, we were using SIOCDEVPRIVATE, but we know have our
200 * separate range because of collisions with other tools such as
201 * 'mii-tool'.
202 * We now have 32 commands, so a bit more space ;-).
203 * Also, all 'odd' commands are only usable by root and don't return the
204 * content of ifr/iwr to user (but you are not obliged to use the set/get
205 * convention, just use every other two command).
206 * And I repeat : you are not obliged to use them with iwspy, but you
207 * must be compliant with it.
208 */
209
210 /* ------------------------- IOCTL STUFF ------------------------- */
211
212 /* The first and the last (range) */
213 #define SIOCIWFIRST 0x8B00
214 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
215
216 /* Even : get (world access), odd : set (root access) */
217 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
218 #define IW_IS_GET(cmd) ((cmd) & 0x1)
219
220 /* ------------------------- PRIVATE INFO ------------------------- */
221 /*
222 * The following is used with SIOCGIWPRIV. It allow a driver to define
223 * the interface (name, type of data) for its private ioctl.
224 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
225 */
226
227 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
228 #define IW_PRIV_TYPE_NONE 0x0000
229 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
230 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
231 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
232 #define IW_PRIV_TYPE_FLOAT 0x5000
233
234 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
235
236 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
237
238 /*
239 * Note : if the number of args is fixed and the size < 16 octets,
240 * instead of passing a pointer we will put args in the iwreq struct...
241 */
242
243 /* ----------------------- OTHER CONSTANTS ----------------------- */
244
245 /* Maximum frequencies in the range struct */
246 #define IW_MAX_FREQUENCIES 16
247 /* Note : if you have something like 80 frequencies,
248 * don't increase this constant and don't fill the frequency list.
249 * The user will be able to set by channel anyway... */
250
251 /* Maximum bit rates in the range struct */
252 #define IW_MAX_BITRATES 8
253
254 /* Maximum tx powers in the range struct */
255 #define IW_MAX_TXPOWER 8
256
257 /* Maximum of address that you may set with SPY */
258 #define IW_MAX_SPY 8
259
260 /* Maximum of address that you may get in the
261 list of access points in range */
262 #define IW_MAX_AP 8
263
264 /* Maximum size of the ESSID and NICKN strings */
265 #define IW_ESSID_MAX_SIZE 32
266
267 /* Modes of operation */
268 #define IW_MODE_AUTO 0 /* Let the driver decides */
269 #define IW_MODE_ADHOC 1 /* Single cell network */
270 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
271 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
272 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
273 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
274
275 /* Maximum number of size of encoding token available
276 * they are listed in the range structure */
277 #define IW_MAX_ENCODING_SIZES 8
278
279 /* Maximum size of the encoding token in bytes */
280 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
281
282 /* Flags for encoding (along with the token) */
283 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
284 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
285 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
286 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
287 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
288 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
289 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
290 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
291
292 /* Power management flags available (along with the value, if any) */
293 #define IW_POWER_ON 0x0000 /* No details... */
294 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
295 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
296 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
297 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
298 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
299 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
300 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
301 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
302 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
303 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
304 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
305 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
306 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
307
308 /* Transmit Power flags available */
309 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
310 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
311
312 /* Retry limits and lifetime flags available */
313 #define IW_RETRY_ON 0x0000 /* No details... */
314 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
315 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
316 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
317 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
318 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
319 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
320 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
321
322 /****************************** TYPES ******************************/
323
324 /* --------------------------- SUBTYPES --------------------------- */
325 /*
326 * Generic format for most parameters that fit in an int
327 */
328 struct iw_param
329 {
330 __s32 value; /* The value of the parameter itself */
331 __u8 fixed; /* Hardware should not use auto select */
332 __u8 disabled; /* Disable the feature */
333 __u16 flags; /* Various specifc flags (if any) */
334 };
335
336 /*
337 * For all data larger than 16 octets, we need to use a
338 * pointer to memory allocated in user space.
339 */
340 struct iw_point
341 {
342 caddr_t pointer; /* Pointer to the data (in user space) */
343 __u16 length; /* number of fields or size in bytes */
344 __u16 flags; /* Optional params */
345 };
346
347 /*
348 * A frequency
349 * For numbers lower than 10^9, we encode the number in 'm' and
350 * set 'e' to 0
351 * For number greater than 10^9, we divide it by the lowest power
352 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
353 * The power of 10 is in 'e', the result of the division is in 'm'.
354 */
355 struct iw_freq
356 {
357 __u32 m; /* Mantissa */
358 __u16 e; /* Exponent */
359 __u8 i; /* List index (when in range struct) */
360 };
361
362 /*
363 * Quality of the link
364 */
365 struct iw_quality
366 {
367 __u8 qual; /* link quality (%retries, SNR,
368 %missed beacons or better...) */
369 __u8 level; /* signal level (dBm) */
370 __u8 noise; /* noise level (dBm) */
371 __u8 updated; /* Flags to know if updated */
372 };
373
374 /*
375 * Packet discarded in the wireless adapter due to
376 * "wireless" specific problems...
377 * Note : the list of counter and statistics in net_device_stats
378 * is already pretty exhaustive, and you should use that first.
379 * This is only additional stats...
380 */
381 struct iw_discarded
382 {
383 __u32 nwid; /* Rx : Wrong nwid/essid */
384 __u32 code; /* Rx : Unable to code/decode (WEP) */
385 __u32 fragment; /* Rx : Can't perform MAC reassembly */
386 __u32 retries; /* Tx : Max MAC retries num reached */
387 __u32 misc; /* Others cases */
388 };
389
390 /*
391 * Packet/Time period missed in the wireless adapter due to
392 * "wireless" specific problems...
393 */
394 struct iw_missed
395 {
396 __u32 beacon; /* Missed beacons/superframe */
397 };
398
399 /* ------------------------ WIRELESS STATS ------------------------ */
400 /*
401 * Wireless statistics (used for /proc/net/wireless)
402 */
403 struct iw_statistics
404 {
405 __u16 status; /* Status
406 * - device dependent for now */
407
408 struct iw_quality qual; /* Quality of the link
409 * (instant/mean/max) */
410 struct iw_discarded discard; /* Packet discarded counts */
411 struct iw_missed miss; /* Packet missed counts */
412 };
413
414 /* ------------------------ IOCTL REQUEST ------------------------ */
415 /*
416 * The structure to exchange data for ioctl.
417 * This structure is the same as 'struct ifreq', but (re)defined for
418 * convenience...
419 *
420 * Note that it should fit on the same memory footprint !
421 * You should check this when increasing the above structures (16 octets)
422 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
423 */
424 struct iwreq
425 {
426 union
427 {
428 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
429 } ifr_ifrn;
430
431 /* Data part */
432 union
433 {
434 /* Config - generic */
435 char name[IFNAMSIZ];
436 /* Name : used to verify the presence of wireless extensions.
437 * Name of the protocol/provider... */
438
439 struct iw_point essid; /* Extended network name */
440 struct iw_param nwid; /* network id (or domain - the cell) */
441 struct iw_freq freq; /* frequency or channel :
442 * 0-1000 = channel
443 * > 1000 = frequency in Hz */
444
445 struct iw_param sens; /* signal level threshold */
446 struct iw_param bitrate; /* default bit rate */
447 struct iw_param txpower; /* default transmit power */
448 struct iw_param rts; /* RTS threshold threshold */
449 struct iw_param frag; /* Fragmentation threshold */
450 __u32 mode; /* Operation mode */
451 struct iw_param retry; /* Retry limits & lifetime */
452
453 struct iw_point encoding; /* Encoding stuff : tokens */
454 struct iw_param power; /* PM duration/timeout */
455
456 struct sockaddr ap_addr; /* Access point address */
457
458 struct iw_point data; /* Other large parameters */
459 } u;
460 };
461
462 /* -------------------------- IOCTL DATA -------------------------- */
463 /*
464 * For those ioctl which want to exchange mode data that what could
465 * fit in the above structure...
466 */
467
468 /*
469 * Range of parameters
470 */
471
472 struct iw_range
473 {
474 /* Informative stuff (to choose between different interface) */
475 __u32 throughput; /* To give an idea... */
476 /* In theory this value should be the maximum benchmarked
477 * TCP/IP throughput, because with most of these devices the
478 * bit rate is meaningless (overhead an co) to estimate how
479 * fast the connection will go and pick the fastest one.
480 * I suggest people to play with Netperf or any benchmark...
481 */
482
483 /* NWID (or domain id) */
484 __u32 min_nwid; /* Minimal NWID we are able to set */
485 __u32 max_nwid; /* Maximal NWID we are able to set */
486
487 /* Frequency */
488 __u16 num_channels; /* Number of channels [0; num - 1] */
489 __u8 num_frequency; /* Number of entry in the list */
490 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
491 /* Note : this frequency list doesn't need to fit channel numbers */
492
493 /* signal level threshold range */
494 __s32 sensitivity;
495
496 /* Quality of link & SNR stuff */
497 struct iw_quality max_qual; /* Quality of the link */
498
499 /* Rates */
500 __u8 num_bitrates; /* Number of entries in the list */
501 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
502
503 /* RTS threshold */
504 __s32 min_rts; /* Minimal RTS threshold */
505 __s32 max_rts; /* Maximal RTS threshold */
506
507 /* Frag threshold */
508 __s32 min_frag; /* Minimal frag threshold */
509 __s32 max_frag; /* Maximal frag threshold */
510
511 /* Power Management duration & timeout */
512 __s32 min_pmp; /* Minimal PM period */
513 __s32 max_pmp; /* Maximal PM period */
514 __s32 min_pmt; /* Minimal PM timeout */
515 __s32 max_pmt; /* Maximal PM timeout */
516 __u16 pmp_flags; /* How to decode max/min PM period */
517 __u16 pmt_flags; /* How to decode max/min PM timeout */
518 __u16 pm_capa; /* What PM options are supported */
519
520 /* Encoder stuff */
521 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
522 __u8 num_encoding_sizes; /* Number of entry in the list */
523 __u8 max_encoding_tokens; /* Max number of tokens */
524
525 /* Transmit power */
526 __u16 txpower_capa; /* What options are supported */
527 __u8 num_txpower; /* Number of entries in the list */
528 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
529
530 /* Wireless Extension version info */
531 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
532 __u8 we_version_source; /* Last update of source */
533
534 /* Retry limits and lifetime */
535 __u16 retry_capa; /* What retry options are supported */
536 __u16 retry_flags; /* How to decode max/min retry limit */
537 __u16 r_time_flags; /* How to decode max/min retry life */
538 __s32 min_retry; /* Minimal number of retries */
539 __s32 max_retry; /* Maximal number of retries */
540 __s32 min_r_time; /* Minimal retry lifetime */
541 __s32 max_r_time; /* Maximal retry lifetime */
542
543 /* Average quality of link & SNR */
544 struct iw_quality avg_qual; /* Quality of the link */
545 /* This should contain the average/typical values of the quality
546 * indicator. This should be the threshold between a "good" and
547 * a "bad" link (example : monitor going from green to orange).
548 * Currently, user space apps like quality monitors don't have any
549 * way to calibrate the measurement. With this, they can split
550 * the range between 0 and max_qual in different quality level
551 * (using a geometric subdivision centered on the average).
552 * I expect that people doing the user space apps will feedback
553 * us on which value we need to put in each driver...
554 */
555 };
556
557 /*
558 * Private ioctl interface information
559 */
560
561 struct iw_priv_args
562 {
563 __u32 cmd; /* Number of the ioctl to issue */
564 __u16 set_args; /* Type and number of args */
565 __u16 get_args; /* Type and number of args */
566 char name[IFNAMSIZ]; /* Name of the extension */
567 };
568
569 #endif /* _LINUX_WIRELESS_H */
+0
-599
src/lwe/wireless.13.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 13 6.12.01
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2001 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2001 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # include/linux/wireless.c
50 *
51 * Other comments :
52 * --------------
53 * Do not add here things that are redundant with other mechanisms
54 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
55 * wireless specific.
56 *
57 * These wireless extensions are not magic : each driver has to provide
58 * support for them...
59 *
60 * IMPORTANT NOTE : As everything in the kernel, this is very much a
61 * work in progress. Contact me if you have ideas of improvements...
62 */
63
64 /***************************** INCLUDES *****************************/
65
66 #include <linux/types.h> /* for "caddr_t" et al */
67 #include <linux/socket.h> /* for "struct sockaddr" et al */
68 #include <linux/if.h> /* for IFNAMSIZ and co... */
69
70 /***************************** VERSION *****************************/
71 /*
72 * This constant is used to know the availability of the wireless
73 * extensions and to know which version of wireless extensions it is
74 * (there is some stuff that will be added in the future...)
75 * I just plan to increment with each new version.
76 */
77 #define WIRELESS_EXT 13
78
79 /*
80 * Changes :
81 *
82 * V2 to V3
83 * --------
84 * Alan Cox start some incompatibles changes. I've integrated a bit more.
85 * - Encryption renamed to Encode to avoid US regulation problems
86 * - Frequency changed from float to struct to avoid problems on old 386
87 *
88 * V3 to V4
89 * --------
90 * - Add sensitivity
91 *
92 * V4 to V5
93 * --------
94 * - Missing encoding definitions in range
95 * - Access points stuff
96 *
97 * V5 to V6
98 * --------
99 * - 802.11 support (ESSID ioctls)
100 *
101 * V6 to V7
102 * --------
103 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
104 *
105 * V7 to V8
106 * --------
107 * - Changed my e-mail address
108 * - More 802.11 support (nickname, rate, rts, frag)
109 * - List index in frequencies
110 *
111 * V8 to V9
112 * --------
113 * - Support for 'mode of operation' (ad-hoc, managed...)
114 * - Support for unicast and multicast power saving
115 * - Change encoding to support larger tokens (>64 bits)
116 * - Updated iw_params (disable, flags) and use it for NWID
117 * - Extracted iw_point from iwreq for clarity
118 *
119 * V9 to V10
120 * ---------
121 * - Add PM capability to range structure
122 * - Add PM modifier : MAX/MIN/RELATIVE
123 * - Add encoding option : IW_ENCODE_NOKEY
124 * - Add TxPower ioctls (work like TxRate)
125 *
126 * V10 to V11
127 * ----------
128 * - Add WE version in range (help backward/forward compatibility)
129 * - Add retry ioctls (work like PM)
130 *
131 * V11 to V12
132 * ----------
133 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
134 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
135 * - Add new statistics (frag, retry, beacon)
136 * - Add average quality (for user space calibration)
137 *
138 * V12 to V13
139 * ----------
140 * - Document creation of new driver API.
141 * - Extract union iwreq_data from struct iwreq (for new driver API).
142 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
143 */
144
145 /**************************** CONSTANTS ****************************/
146
147 /* -------------------------- IOCTL LIST -------------------------- */
148
149 /* Basic operations */
150 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
151 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
152 #define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
153 #define SIOCGIWNWID 0x8B03 /* get network id */
154 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
155 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
156 #define SIOCSIWMODE 0x8B06 /* set operation mode */
157 #define SIOCGIWMODE 0x8B07 /* get operation mode */
158 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
159 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
160
161 /* Informative stuff */
162 #define SIOCSIWRANGE 0x8B0A /* Unused */
163 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
164 #define SIOCSIWPRIV 0x8B0C /* Unused */
165 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
166 #define SIOCSIWSTATS 0x8B0E /* Unused */
167 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
168
169 /* Mobile IP support */
170 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
171 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
172
173 /* Access Point manipulation */
174 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
175 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
176 #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
177
178 /* 802.11 specific support */
179 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
180 #define SIOCGIWESSID 0x8B1B /* get ESSID */
181 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
182 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
183 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
184 * within the 'iwreq' structure, so we need to use the 'data' member to
185 * point to a string in user space, like it is done for RANGE...
186 * The "flags" member indicate if the ESSID is active or not (promiscuous).
187 */
188
189 /* Other parameters useful in 802.11 and some other devices */
190 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
191 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
192 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
193 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
194 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
195 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
196 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
197 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
198 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
199 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
200
201 /* Encoding stuff (scrambling, hardware security, WEP...) */
202 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
203 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
204 /* Power saving stuff (power management, unicast and multicast) */
205 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
206 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
207
208 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
209
210 /* These 16 ioctl are wireless device private.
211 * Each driver is free to use them for whatever purpose it chooses,
212 * however the driver *must* export the description of those ioctls
213 * with SIOCGIWPRIV and *must* use arguments as defined below.
214 * If you don't follow those rules, DaveM is going to hate you (reason :
215 * it make mixed 32/64bit operation impossible).
216 */
217 #define SIOCIWFIRSTPRIV 0x8BE0
218 #define SIOCIWLASTPRIV 0x8BFF
219 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
220 * separate range because of collisions with other tools such as
221 * 'mii-tool'.
222 * We now have 32 commands, so a bit more space ;-).
223 * Also, all 'odd' commands are only usable by root and don't return the
224 * content of ifr/iwr to user (but you are not obliged to use the set/get
225 * convention, just use every other two command).
226 * And I repeat : you are not obliged to use them with iwspy, but you
227 * must be compliant with it.
228 */
229
230 /* ------------------------- IOCTL STUFF ------------------------- */
231
232 /* The first and the last (range) */
233 #define SIOCIWFIRST 0x8B00
234 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
235
236 /* Even : get (world access), odd : set (root access) */
237 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
238 #define IW_IS_GET(cmd) ((cmd) & 0x1)
239
240 /* ------------------------- PRIVATE INFO ------------------------- */
241 /*
242 * The following is used with SIOCGIWPRIV. It allow a driver to define
243 * the interface (name, type of data) for its private ioctl.
244 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
245 */
246
247 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
248 #define IW_PRIV_TYPE_NONE 0x0000
249 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
250 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
251 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
252 #define IW_PRIV_TYPE_FLOAT 0x5000
253
254 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
255
256 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
257
258 /*
259 * Note : if the number of args is fixed and the size < 16 octets,
260 * instead of passing a pointer we will put args in the iwreq struct...
261 */
262
263 /* ----------------------- OTHER CONSTANTS ----------------------- */
264
265 /* Maximum frequencies in the range struct */
266 #define IW_MAX_FREQUENCIES 16
267 /* Note : if you have something like 80 frequencies,
268 * don't increase this constant and don't fill the frequency list.
269 * The user will be able to set by channel anyway... */
270
271 /* Maximum bit rates in the range struct */
272 #define IW_MAX_BITRATES 8
273
274 /* Maximum tx powers in the range struct */
275 #define IW_MAX_TXPOWER 8
276
277 /* Maximum of address that you may set with SPY */
278 #define IW_MAX_SPY 8
279
280 /* Maximum of address that you may get in the
281 list of access points in range */
282 #define IW_MAX_AP 8
283
284 /* Maximum size of the ESSID and NICKN strings */
285 #define IW_ESSID_MAX_SIZE 32
286
287 /* Modes of operation */
288 #define IW_MODE_AUTO 0 /* Let the driver decides */
289 #define IW_MODE_ADHOC 1 /* Single cell network */
290 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
291 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
292 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
293 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
294
295 /* Maximum number of size of encoding token available
296 * they are listed in the range structure */
297 #define IW_MAX_ENCODING_SIZES 8
298
299 /* Maximum size of the encoding token in bytes */
300 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
301
302 /* Flags for encoding (along with the token) */
303 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
304 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
305 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
306 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
307 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
308 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
309 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
310 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
311
312 /* Power management flags available (along with the value, if any) */
313 #define IW_POWER_ON 0x0000 /* No details... */
314 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
315 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
316 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
317 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
318 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
319 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
320 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
321 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
322 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
323 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
324 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
325 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
326 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
327
328 /* Transmit Power flags available */
329 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
330 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
331
332 /* Retry limits and lifetime flags available */
333 #define IW_RETRY_ON 0x0000 /* No details... */
334 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
335 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
336 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
337 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
338 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
339 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
340 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
341
342 /****************************** TYPES ******************************/
343
344 /* --------------------------- SUBTYPES --------------------------- */
345 /*
346 * Generic format for most parameters that fit in an int
347 */
348 struct iw_param
349 {
350 __s32 value; /* The value of the parameter itself */
351 __u8 fixed; /* Hardware should not use auto select */
352 __u8 disabled; /* Disable the feature */
353 __u16 flags; /* Various specifc flags (if any) */
354 };
355
356 /*
357 * For all data larger than 16 octets, we need to use a
358 * pointer to memory allocated in user space.
359 */
360 struct iw_point
361 {
362 caddr_t pointer; /* Pointer to the data (in user space) */
363 __u16 length; /* number of fields or size in bytes */
364 __u16 flags; /* Optional params */
365 };
366
367 /*
368 * A frequency
369 * For numbers lower than 10^9, we encode the number in 'm' and
370 * set 'e' to 0
371 * For number greater than 10^9, we divide it by the lowest power
372 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
373 * The power of 10 is in 'e', the result of the division is in 'm'.
374 */
375 struct iw_freq
376 {
377 __u32 m; /* Mantissa */
378 __u16 e; /* Exponent */
379 __u8 i; /* List index (when in range struct) */
380 };
381
382 /*
383 * Quality of the link
384 */
385 struct iw_quality
386 {
387 __u8 qual; /* link quality (%retries, SNR,
388 %missed beacons or better...) */
389 __u8 level; /* signal level (dBm) */
390 __u8 noise; /* noise level (dBm) */
391 __u8 updated; /* Flags to know if updated */
392 };
393
394 /*
395 * Packet discarded in the wireless adapter due to
396 * "wireless" specific problems...
397 * Note : the list of counter and statistics in net_device_stats
398 * is already pretty exhaustive, and you should use that first.
399 * This is only additional stats...
400 */
401 struct iw_discarded
402 {
403 __u32 nwid; /* Rx : Wrong nwid/essid */
404 __u32 code; /* Rx : Unable to code/decode (WEP) */
405 __u32 fragment; /* Rx : Can't perform MAC reassembly */
406 __u32 retries; /* Tx : Max MAC retries num reached */
407 __u32 misc; /* Others cases */
408 };
409
410 /*
411 * Packet/Time period missed in the wireless adapter due to
412 * "wireless" specific problems...
413 */
414 struct iw_missed
415 {
416 __u32 beacon; /* Missed beacons/superframe */
417 };
418
419 /* ------------------------ WIRELESS STATS ------------------------ */
420 /*
421 * Wireless statistics (used for /proc/net/wireless)
422 */
423 struct iw_statistics
424 {
425 __u16 status; /* Status
426 * - device dependent for now */
427
428 struct iw_quality qual; /* Quality of the link
429 * (instant/mean/max) */
430 struct iw_discarded discard; /* Packet discarded counts */
431 struct iw_missed miss; /* Packet missed counts */
432 };
433
434 /* ------------------------ IOCTL REQUEST ------------------------ */
435 /*
436 * This structure defines the payload of an ioctl, and is used
437 * below.
438 *
439 * Note that this structure should fit on the memory footprint
440 * of iwreq (which is the same as ifreq), which mean a max size of
441 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
442 * You should check this when increasing the structures defined
443 * above in this file...
444 */
445 union iwreq_data
446 {
447 /* Config - generic */
448 char name[IFNAMSIZ];
449 /* Name : used to verify the presence of wireless extensions.
450 * Name of the protocol/provider... */
451
452 struct iw_point essid; /* Extended network name */
453 struct iw_param nwid; /* network id (or domain - the cell) */
454 struct iw_freq freq; /* frequency or channel :
455 * 0-1000 = channel
456 * > 1000 = frequency in Hz */
457
458 struct iw_param sens; /* signal level threshold */
459 struct iw_param bitrate; /* default bit rate */
460 struct iw_param txpower; /* default transmit power */
461 struct iw_param rts; /* RTS threshold threshold */
462 struct iw_param frag; /* Fragmentation threshold */
463 __u32 mode; /* Operation mode */
464 struct iw_param retry; /* Retry limits & lifetime */
465
466 struct iw_point encoding; /* Encoding stuff : tokens */
467 struct iw_param power; /* PM duration/timeout */
468
469 struct sockaddr ap_addr; /* Access point address */
470
471 struct iw_point data; /* Other large parameters */
472 };
473
474 /*
475 * The structure to exchange data for ioctl.
476 * This structure is the same as 'struct ifreq', but (re)defined for
477 * convenience...
478 * Do I need to remind you about structure size (32 octets) ?
479 */
480 struct iwreq
481 {
482 union
483 {
484 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
485 } ifr_ifrn;
486
487 /* Data part (defined just above) */
488 union iwreq_data u;
489 };
490
491 /* -------------------------- IOCTL DATA -------------------------- */
492 /*
493 * For those ioctl which want to exchange mode data that what could
494 * fit in the above structure...
495 */
496
497 /*
498 * Range of parameters
499 */
500
501 struct iw_range
502 {
503 /* Informative stuff (to choose between different interface) */
504 __u32 throughput; /* To give an idea... */
505 /* In theory this value should be the maximum benchmarked
506 * TCP/IP throughput, because with most of these devices the
507 * bit rate is meaningless (overhead an co) to estimate how
508 * fast the connection will go and pick the fastest one.
509 * I suggest people to play with Netperf or any benchmark...
510 */
511
512 /* NWID (or domain id) */
513 __u32 min_nwid; /* Minimal NWID we are able to set */
514 __u32 max_nwid; /* Maximal NWID we are able to set */
515
516 /* Frequency */
517 __u16 num_channels; /* Number of channels [0; num - 1] */
518 __u8 num_frequency; /* Number of entry in the list */
519 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
520 /* Note : this frequency list doesn't need to fit channel numbers */
521
522 /* signal level threshold range */
523 __s32 sensitivity;
524
525 /* Quality of link & SNR stuff */
526 struct iw_quality max_qual; /* Quality of the link */
527
528 /* Rates */
529 __u8 num_bitrates; /* Number of entries in the list */
530 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
531
532 /* RTS threshold */
533 __s32 min_rts; /* Minimal RTS threshold */
534 __s32 max_rts; /* Maximal RTS threshold */
535
536 /* Frag threshold */
537 __s32 min_frag; /* Minimal frag threshold */
538 __s32 max_frag; /* Maximal frag threshold */
539
540 /* Power Management duration & timeout */
541 __s32 min_pmp; /* Minimal PM period */
542 __s32 max_pmp; /* Maximal PM period */
543 __s32 min_pmt; /* Minimal PM timeout */
544 __s32 max_pmt; /* Maximal PM timeout */
545 __u16 pmp_flags; /* How to decode max/min PM period */
546 __u16 pmt_flags; /* How to decode max/min PM timeout */
547 __u16 pm_capa; /* What PM options are supported */
548
549 /* Encoder stuff */
550 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
551 __u8 num_encoding_sizes; /* Number of entry in the list */
552 __u8 max_encoding_tokens; /* Max number of tokens */
553
554 /* Transmit power */
555 __u16 txpower_capa; /* What options are supported */
556 __u8 num_txpower; /* Number of entries in the list */
557 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
558
559 /* Wireless Extension version info */
560 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
561 __u8 we_version_source; /* Last update of source */
562
563 /* Retry limits and lifetime */
564 __u16 retry_capa; /* What retry options are supported */
565 __u16 retry_flags; /* How to decode max/min retry limit */
566 __u16 r_time_flags; /* How to decode max/min retry life */
567 __s32 min_retry; /* Minimal number of retries */
568 __s32 max_retry; /* Maximal number of retries */
569 __s32 min_r_time; /* Minimal retry lifetime */
570 __s32 max_r_time; /* Maximal retry lifetime */
571
572 /* Average quality of link & SNR */
573 struct iw_quality avg_qual; /* Quality of the link */
574 /* This should contain the average/typical values of the quality
575 * indicator. This should be the threshold between a "good" and
576 * a "bad" link (example : monitor going from green to orange).
577 * Currently, user space apps like quality monitors don't have any
578 * way to calibrate the measurement. With this, they can split
579 * the range between 0 and max_qual in different quality level
580 * (using a geometric subdivision centered on the average).
581 * I expect that people doing the user space apps will feedback
582 * us on which value we need to put in each driver...
583 */
584 };
585
586 /*
587 * Private ioctl interface information
588 */
589
590 struct iw_priv_args
591 {
592 __u32 cmd; /* Number of the ioctl to issue */
593 __u16 set_args; /* Type and number of args */
594 __u16 get_args; /* Type and number of args */
595 char name[IFNAMSIZ]; /* Name of the extension */
596 };
597
598 #endif /* _LINUX_WIRELESS_H */
+0
-669
src/lwe/wireless.14.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 14 25.1.02
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # include/linux/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # include/linux/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 #include <linux/types.h> /* for "caddr_t" et al */
72 #include <linux/socket.h> /* for "struct sockaddr" et al */
73 #include <linux/if.h> /* for IFNAMSIZ and co... */
74
75 /***************************** VERSION *****************************/
76 /*
77 * This constant is used to know the availability of the wireless
78 * extensions and to know which version of wireless extensions it is
79 * (there is some stuff that will be added in the future...)
80 * I just plan to increment with each new version.
81 */
82 #define WIRELESS_EXT 14
83
84 /*
85 * Changes :
86 *
87 * V2 to V3
88 * --------
89 * Alan Cox start some incompatibles changes. I've integrated a bit more.
90 * - Encryption renamed to Encode to avoid US regulation problems
91 * - Frequency changed from float to struct to avoid problems on old 386
92 *
93 * V3 to V4
94 * --------
95 * - Add sensitivity
96 *
97 * V4 to V5
98 * --------
99 * - Missing encoding definitions in range
100 * - Access points stuff
101 *
102 * V5 to V6
103 * --------
104 * - 802.11 support (ESSID ioctls)
105 *
106 * V6 to V7
107 * --------
108 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
109 *
110 * V7 to V8
111 * --------
112 * - Changed my e-mail address
113 * - More 802.11 support (nickname, rate, rts, frag)
114 * - List index in frequencies
115 *
116 * V8 to V9
117 * --------
118 * - Support for 'mode of operation' (ad-hoc, managed...)
119 * - Support for unicast and multicast power saving
120 * - Change encoding to support larger tokens (>64 bits)
121 * - Updated iw_params (disable, flags) and use it for NWID
122 * - Extracted iw_point from iwreq for clarity
123 *
124 * V9 to V10
125 * ---------
126 * - Add PM capability to range structure
127 * - Add PM modifier : MAX/MIN/RELATIVE
128 * - Add encoding option : IW_ENCODE_NOKEY
129 * - Add TxPower ioctls (work like TxRate)
130 *
131 * V10 to V11
132 * ----------
133 * - Add WE version in range (help backward/forward compatibility)
134 * - Add retry ioctls (work like PM)
135 *
136 * V11 to V12
137 * ----------
138 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
139 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
140 * - Add new statistics (frag, retry, beacon)
141 * - Add average quality (for user space calibration)
142 *
143 * V12 to V13
144 * ----------
145 * - Document creation of new driver API.
146 * - Extract union iwreq_data from struct iwreq (for new driver API).
147 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
148 *
149 * V13 to V14
150 * ----------
151 * - Wireless Events support : define struct iw_event
152 * - Define additional specific event numbers
153 * - Add "addr" and "param" fields in union iwreq_data
154 * - AP scanning stuff (SIOCSIWSCAN and friends)
155 */
156
157 /**************************** CONSTANTS ****************************/
158
159 /* -------------------------- IOCTL LIST -------------------------- */
160
161 /* Basic operations */
162 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
163 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
164 #define SIOCSIWNWID 0x8B02 /* set network id (the cell) */
165 #define SIOCGIWNWID 0x8B03 /* get network id */
166 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
167 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
168 #define SIOCSIWMODE 0x8B06 /* set operation mode */
169 #define SIOCGIWMODE 0x8B07 /* get operation mode */
170 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
171 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
172
173 /* Informative stuff */
174 #define SIOCSIWRANGE 0x8B0A /* Unused */
175 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
176 #define SIOCSIWPRIV 0x8B0C /* Unused */
177 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
178 #define SIOCSIWSTATS 0x8B0E /* Unused */
179 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
180
181 /* Mobile IP support */
182 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
183 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
184
185 /* Access Point manipulation */
186 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
187 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
188 #define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */
189 #define SIOCSIWSCAN 0x8B18 /* trigger scanning */
190 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
191
192 /* 802.11 specific support */
193 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
194 #define SIOCGIWESSID 0x8B1B /* get ESSID */
195 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
196 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
197 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
198 * within the 'iwreq' structure, so we need to use the 'data' member to
199 * point to a string in user space, like it is done for RANGE...
200 * The "flags" member indicate if the ESSID is active or not (promiscuous).
201 */
202
203 /* Other parameters useful in 802.11 and some other devices */
204 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
205 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
206 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
207 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
208 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
209 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
210 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
211 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
212 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
213 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
214
215 /* Encoding stuff (scrambling, hardware security, WEP...) */
216 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
217 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
218 /* Power saving stuff (power management, unicast and multicast) */
219 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
220 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
221
222 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
223
224 /* These 16 ioctl are wireless device private.
225 * Each driver is free to use them for whatever purpose it chooses,
226 * however the driver *must* export the description of those ioctls
227 * with SIOCGIWPRIV and *must* use arguments as defined below.
228 * If you don't follow those rules, DaveM is going to hate you (reason :
229 * it make mixed 32/64bit operation impossible).
230 */
231 #define SIOCIWFIRSTPRIV 0x8BE0
232 #define SIOCIWLASTPRIV 0x8BFF
233 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
234 * separate range because of collisions with other tools such as
235 * 'mii-tool'.
236 * We now have 32 commands, so a bit more space ;-).
237 * Also, all 'odd' commands are only usable by root and don't return the
238 * content of ifr/iwr to user (but you are not obliged to use the set/get
239 * convention, just use every other two command).
240 * And I repeat : you are not obliged to use them with iwspy, but you
241 * must be compliant with it.
242 */
243
244 /* ------------------------- IOCTL STUFF ------------------------- */
245
246 /* The first and the last (range) */
247 #define SIOCIWFIRST 0x8B00
248 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
249
250 /* Even : get (world access), odd : set (root access) */
251 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
252 #define IW_IS_GET(cmd) ((cmd) & 0x1)
253
254 /* ----------------------- WIRELESS EVENTS ----------------------- */
255 /* Those are *NOT* ioctls, do not issue request on them !!! */
256 /* Most events use the same identifier as ioctl requests */
257
258 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
259 #define IWEVQUAL 0x8C01 /* Quality part of statistics */
260
261 #define IWEVFIRST 0x8C00
262
263 /* ------------------------- PRIVATE INFO ------------------------- */
264 /*
265 * The following is used with SIOCGIWPRIV. It allow a driver to define
266 * the interface (name, type of data) for its private ioctl.
267 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
268 */
269
270 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
271 #define IW_PRIV_TYPE_NONE 0x0000
272 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
273 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
274 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
275 #define IW_PRIV_TYPE_FLOAT 0x5000
276
277 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
278
279 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
280
281 /*
282 * Note : if the number of args is fixed and the size < 16 octets,
283 * instead of passing a pointer we will put args in the iwreq struct...
284 */
285
286 /* ----------------------- OTHER CONSTANTS ----------------------- */
287
288 /* Maximum frequencies in the range struct */
289 #define IW_MAX_FREQUENCIES 16
290 /* Note : if you have something like 80 frequencies,
291 * don't increase this constant and don't fill the frequency list.
292 * The user will be able to set by channel anyway... */
293
294 /* Maximum bit rates in the range struct */
295 #define IW_MAX_BITRATES 8
296
297 /* Maximum tx powers in the range struct */
298 #define IW_MAX_TXPOWER 8
299
300 /* Maximum of address that you may set with SPY */
301 #define IW_MAX_SPY 8
302
303 /* Maximum of address that you may get in the
304 list of access points in range */
305 #define IW_MAX_AP 8
306
307 /* Maximum size of the ESSID and NICKN strings */
308 #define IW_ESSID_MAX_SIZE 32
309
310 /* Modes of operation */
311 #define IW_MODE_AUTO 0 /* Let the driver decides */
312 #define IW_MODE_ADHOC 1 /* Single cell network */
313 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
314 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
315 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
316 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
317
318 /* Maximum number of size of encoding token available
319 * they are listed in the range structure */
320 #define IW_MAX_ENCODING_SIZES 8
321
322 /* Maximum size of the encoding token in bytes */
323 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
324
325 /* Flags for encoding (along with the token) */
326 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
327 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
328 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
329 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
330 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
331 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
332 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
333 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
334
335 /* Power management flags available (along with the value, if any) */
336 #define IW_POWER_ON 0x0000 /* No details... */
337 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
338 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
339 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
340 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
341 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
342 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
343 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
344 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
345 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
346 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
347 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
348 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
349 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
350
351 /* Transmit Power flags available */
352 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
353 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
354
355 /* Retry limits and lifetime flags available */
356 #define IW_RETRY_ON 0x0000 /* No details... */
357 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
358 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
359 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
360 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
361 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
362 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
363 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
364
365 /* Scanning request flags */
366 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
367 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
368 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
369 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
370 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
371 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
372 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
373 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
374 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
375 /* Maximum size of returned data */
376 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
377
378 /****************************** TYPES ******************************/
379
380 /* --------------------------- SUBTYPES --------------------------- */
381 /*
382 * Generic format for most parameters that fit in an int
383 */
384 struct iw_param
385 {
386 __s32 value; /* The value of the parameter itself */
387 __u8 fixed; /* Hardware should not use auto select */
388 __u8 disabled; /* Disable the feature */
389 __u16 flags; /* Various specifc flags (if any) */
390 };
391
392 /*
393 * For all data larger than 16 octets, we need to use a
394 * pointer to memory allocated in user space.
395 */
396 struct iw_point
397 {
398 caddr_t pointer; /* Pointer to the data (in user space) */
399 __u16 length; /* number of fields or size in bytes */
400 __u16 flags; /* Optional params */
401 };
402
403 /*
404 * A frequency
405 * For numbers lower than 10^9, we encode the number in 'm' and
406 * set 'e' to 0
407 * For number greater than 10^9, we divide it by the lowest power
408 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
409 * The power of 10 is in 'e', the result of the division is in 'm'.
410 */
411 struct iw_freq
412 {
413 __u32 m; /* Mantissa */
414 __u16 e; /* Exponent */
415 __u8 i; /* List index (when in range struct) */
416 };
417
418 /*
419 * Quality of the link
420 */
421 struct iw_quality
422 {
423 __u8 qual; /* link quality (%retries, SNR,
424 %missed beacons or better...) */
425 __u8 level; /* signal level (dBm) */
426 __u8 noise; /* noise level (dBm) */
427 __u8 updated; /* Flags to know if updated */
428 };
429
430 /*
431 * Packet discarded in the wireless adapter due to
432 * "wireless" specific problems...
433 * Note : the list of counter and statistics in net_device_stats
434 * is already pretty exhaustive, and you should use that first.
435 * This is only additional stats...
436 */
437 struct iw_discarded
438 {
439 __u32 nwid; /* Rx : Wrong nwid/essid */
440 __u32 code; /* Rx : Unable to code/decode (WEP) */
441 __u32 fragment; /* Rx : Can't perform MAC reassembly */
442 __u32 retries; /* Tx : Max MAC retries num reached */
443 __u32 misc; /* Others cases */
444 };
445
446 /*
447 * Packet/Time period missed in the wireless adapter due to
448 * "wireless" specific problems...
449 */
450 struct iw_missed
451 {
452 __u32 beacon; /* Missed beacons/superframe */
453 };
454
455 /* ------------------------ WIRELESS STATS ------------------------ */
456 /*
457 * Wireless statistics (used for /proc/net/wireless)
458 */
459 struct iw_statistics
460 {
461 __u16 status; /* Status
462 * - device dependent for now */
463
464 struct iw_quality qual; /* Quality of the link
465 * (instant/mean/max) */
466 struct iw_discarded discard; /* Packet discarded counts */
467 struct iw_missed miss; /* Packet missed counts */
468 };
469
470 /* ------------------------ IOCTL REQUEST ------------------------ */
471 /*
472 * This structure defines the payload of an ioctl, and is used
473 * below.
474 *
475 * Note that this structure should fit on the memory footprint
476 * of iwreq (which is the same as ifreq), which mean a max size of
477 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
478 * You should check this when increasing the structures defined
479 * above in this file...
480 */
481 union iwreq_data
482 {
483 /* Config - generic */
484 char name[IFNAMSIZ];
485 /* Name : used to verify the presence of wireless extensions.
486 * Name of the protocol/provider... */
487
488 struct iw_point essid; /* Extended network name */
489 struct iw_param nwid; /* network id (or domain - the cell) */
490 struct iw_freq freq; /* frequency or channel :
491 * 0-1000 = channel
492 * > 1000 = frequency in Hz */
493
494 struct iw_param sens; /* signal level threshold */
495 struct iw_param bitrate; /* default bit rate */
496 struct iw_param txpower; /* default transmit power */
497 struct iw_param rts; /* RTS threshold threshold */
498 struct iw_param frag; /* Fragmentation threshold */
499 __u32 mode; /* Operation mode */
500 struct iw_param retry; /* Retry limits & lifetime */
501
502 struct iw_point encoding; /* Encoding stuff : tokens */
503 struct iw_param power; /* PM duration/timeout */
504 struct iw_quality qual; /* Quality part of statistics */
505
506 struct sockaddr ap_addr; /* Access point address */
507 struct sockaddr addr; /* Destination address (hw) */
508
509 struct iw_param param; /* Other small parameters */
510 struct iw_point data; /* Other large parameters */
511 };
512
513 /*
514 * The structure to exchange data for ioctl.
515 * This structure is the same as 'struct ifreq', but (re)defined for
516 * convenience...
517 * Do I need to remind you about structure size (32 octets) ?
518 */
519 struct iwreq
520 {
521 union
522 {
523 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
524 } ifr_ifrn;
525
526 /* Data part (defined just above) */
527 union iwreq_data u;
528 };
529
530 /* -------------------------- IOCTL DATA -------------------------- */
531 /*
532 * For those ioctl which want to exchange mode data that what could
533 * fit in the above structure...
534 */
535
536 /*
537 * Range of parameters
538 */
539
540 struct iw_range
541 {
542 /* Informative stuff (to choose between different interface) */
543 __u32 throughput; /* To give an idea... */
544 /* In theory this value should be the maximum benchmarked
545 * TCP/IP throughput, because with most of these devices the
546 * bit rate is meaningless (overhead an co) to estimate how
547 * fast the connection will go and pick the fastest one.
548 * I suggest people to play with Netperf or any benchmark...
549 */
550
551 /* NWID (or domain id) */
552 __u32 min_nwid; /* Minimal NWID we are able to set */
553 __u32 max_nwid; /* Maximal NWID we are able to set */
554
555 /* Frequency */
556 __u16 num_channels; /* Number of channels [0; num - 1] */
557 __u8 num_frequency; /* Number of entry in the list */
558 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
559 /* Note : this frequency list doesn't need to fit channel numbers */
560
561 /* signal level threshold range */
562 __s32 sensitivity;
563
564 /* Quality of link & SNR stuff */
565 struct iw_quality max_qual; /* Quality of the link */
566
567 /* Rates */
568 __u8 num_bitrates; /* Number of entries in the list */
569 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
570
571 /* RTS threshold */
572 __s32 min_rts; /* Minimal RTS threshold */
573 __s32 max_rts; /* Maximal RTS threshold */
574
575 /* Frag threshold */
576 __s32 min_frag; /* Minimal frag threshold */
577 __s32 max_frag; /* Maximal frag threshold */
578
579 /* Power Management duration & timeout */
580 __s32 min_pmp; /* Minimal PM period */
581 __s32 max_pmp; /* Maximal PM period */
582 __s32 min_pmt; /* Minimal PM timeout */
583 __s32 max_pmt; /* Maximal PM timeout */
584 __u16 pmp_flags; /* How to decode max/min PM period */
585 __u16 pmt_flags; /* How to decode max/min PM timeout */
586 __u16 pm_capa; /* What PM options are supported */
587
588 /* Encoder stuff */
589 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
590 __u8 num_encoding_sizes; /* Number of entry in the list */
591 __u8 max_encoding_tokens; /* Max number of tokens */
592
593 /* Transmit power */
594 __u16 txpower_capa; /* What options are supported */
595 __u8 num_txpower; /* Number of entries in the list */
596 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
597
598 /* Wireless Extension version info */
599 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
600 __u8 we_version_source; /* Last update of source */
601
602 /* Retry limits and lifetime */
603 __u16 retry_capa; /* What retry options are supported */
604 __u16 retry_flags; /* How to decode max/min retry limit */
605 __u16 r_time_flags; /* How to decode max/min retry life */
606 __s32 min_retry; /* Minimal number of retries */
607 __s32 max_retry; /* Maximal number of retries */
608 __s32 min_r_time; /* Minimal retry lifetime */
609 __s32 max_r_time; /* Maximal retry lifetime */
610
611 /* Average quality of link & SNR */
612 struct iw_quality avg_qual; /* Quality of the link */
613 /* This should contain the average/typical values of the quality
614 * indicator. This should be the threshold between a "good" and
615 * a "bad" link (example : monitor going from green to orange).
616 * Currently, user space apps like quality monitors don't have any
617 * way to calibrate the measurement. With this, they can split
618 * the range between 0 and max_qual in different quality level
619 * (using a geometric subdivision centered on the average).
620 * I expect that people doing the user space apps will feedback
621 * us on which value we need to put in each driver...
622 */
623 };
624
625 /*
626 * Private ioctl interface information
627 */
628
629 struct iw_priv_args
630 {
631 __u32 cmd; /* Number of the ioctl to issue */
632 __u16 set_args; /* Type and number of args */
633 __u16 get_args; /* Type and number of args */
634 char name[IFNAMSIZ]; /* Name of the extension */
635 };
636
637 /* ----------------------- WIRELESS EVENTS ----------------------- */
638 /*
639 * Wireless events are carried through the rtnetlink socket to user
640 * space. They are encapsulated in the IFLA_WIRELESS field of
641 * a RTM_NEWLINK message.
642 */
643
644 /*
645 * A Wireless Event. Contains basically the same data as the ioctl...
646 */
647 struct iw_event
648 {
649 __u16 len; /* Real lenght of this stuff */
650 __u16 cmd; /* Wireless IOCTL */
651 union iwreq_data u; /* IOCTL fixed payload */
652 };
653
654 /* Size of the Event prefix (including padding and alignement junk) */
655 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
656 /* Size of the various events */
657 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
658 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
659 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
660 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
661 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
662 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
663 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
664
665 /* Note : in the case of iw_point, the extra data will come at the
666 * end of the event */
667
668 #endif /* _LINUX_WIRELESS_H */
+0
-698
src/lwe/wireless.15.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 15 12.7.02
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # include/linux/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # include/linux/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 #include <linux/types.h> /* for "caddr_t" et al */
72 #include <linux/socket.h> /* for "struct sockaddr" et al */
73 #include <linux/if.h> /* for IFNAMSIZ and co... */
74
75 /***************************** VERSION *****************************/
76 /*
77 * This constant is used to know the availability of the wireless
78 * extensions and to know which version of wireless extensions it is
79 * (there is some stuff that will be added in the future...)
80 * I just plan to increment with each new version.
81 */
82 #define WIRELESS_EXT 15
83
84 /*
85 * Changes :
86 *
87 * V2 to V3
88 * --------
89 * Alan Cox start some incompatibles changes. I've integrated a bit more.
90 * - Encryption renamed to Encode to avoid US regulation problems
91 * - Frequency changed from float to struct to avoid problems on old 386
92 *
93 * V3 to V4
94 * --------
95 * - Add sensitivity
96 *
97 * V4 to V5
98 * --------
99 * - Missing encoding definitions in range
100 * - Access points stuff
101 *
102 * V5 to V6
103 * --------
104 * - 802.11 support (ESSID ioctls)
105 *
106 * V6 to V7
107 * --------
108 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
109 *
110 * V7 to V8
111 * --------
112 * - Changed my e-mail address
113 * - More 802.11 support (nickname, rate, rts, frag)
114 * - List index in frequencies
115 *
116 * V8 to V9
117 * --------
118 * - Support for 'mode of operation' (ad-hoc, managed...)
119 * - Support for unicast and multicast power saving
120 * - Change encoding to support larger tokens (>64 bits)
121 * - Updated iw_params (disable, flags) and use it for NWID
122 * - Extracted iw_point from iwreq for clarity
123 *
124 * V9 to V10
125 * ---------
126 * - Add PM capability to range structure
127 * - Add PM modifier : MAX/MIN/RELATIVE
128 * - Add encoding option : IW_ENCODE_NOKEY
129 * - Add TxPower ioctls (work like TxRate)
130 *
131 * V10 to V11
132 * ----------
133 * - Add WE version in range (help backward/forward compatibility)
134 * - Add retry ioctls (work like PM)
135 *
136 * V11 to V12
137 * ----------
138 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
139 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
140 * - Add new statistics (frag, retry, beacon)
141 * - Add average quality (for user space calibration)
142 *
143 * V12 to V13
144 * ----------
145 * - Document creation of new driver API.
146 * - Extract union iwreq_data from struct iwreq (for new driver API).
147 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
148 *
149 * V13 to V14
150 * ----------
151 * - Wireless Events support : define struct iw_event
152 * - Define additional specific event numbers
153 * - Add "addr" and "param" fields in union iwreq_data
154 * - AP scanning stuff (SIOCSIWSCAN and friends)
155 *
156 * V14 to V15
157 * ----------
158 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
159 * - Make struct iw_freq signed (both m & e), add explicit padding
160 * - Add IWEVCUSTOM for driver specific event/scanning token
161 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
162 * - Add IW_TXPOW_RANGE for range of Tx Powers
163 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
164 * - Add IW_MODE_MONITOR for passive monitor
165 */
166
167 /**************************** CONSTANTS ****************************/
168
169 /* -------------------------- IOCTL LIST -------------------------- */
170
171 /* Wireless Identification */
172 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
173 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
174 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
175 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
176 * Don't put the name of your driver there, it's useless. */
177
178 /* Basic operations */
179 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
180 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
181 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
182 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
183 #define SIOCSIWMODE 0x8B06 /* set operation mode */
184 #define SIOCGIWMODE 0x8B07 /* get operation mode */
185 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
186 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
187
188 /* Informative stuff */
189 #define SIOCSIWRANGE 0x8B0A /* Unused */
190 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
191 #define SIOCSIWPRIV 0x8B0C /* Unused */
192 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
193 #define SIOCSIWSTATS 0x8B0E /* Unused */
194 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
195 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
196 * is never passed to the driver (i.e. the driver will never see it). */
197
198 /* Mobile IP support (statistics per MAC address) */
199 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
200 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
201
202 /* Access Point manipulation */
203 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
204 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
205 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
206 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
207 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
208
209 /* 802.11 specific support */
210 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
211 #define SIOCGIWESSID 0x8B1B /* get ESSID */
212 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
213 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
214 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
215 * within the 'iwreq' structure, so we need to use the 'data' member to
216 * point to a string in user space, like it is done for RANGE... */
217
218 /* Other parameters useful in 802.11 and some other devices */
219 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
220 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
221 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
222 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
223 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
224 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
225 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
226 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
227 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
228 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
229
230 /* Encoding stuff (scrambling, hardware security, WEP...) */
231 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
232 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
233 /* Power saving stuff (power management, unicast and multicast) */
234 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
235 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
236
237 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
238
239 /* These 16 ioctl are wireless device private.
240 * Each driver is free to use them for whatever purpose it chooses,
241 * however the driver *must* export the description of those ioctls
242 * with SIOCGIWPRIV and *must* use arguments as defined below.
243 * If you don't follow those rules, DaveM is going to hate you (reason :
244 * it make mixed 32/64bit operation impossible).
245 */
246 #define SIOCIWFIRSTPRIV 0x8BE0
247 #define SIOCIWLASTPRIV 0x8BFF
248 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
249 * separate range because of collisions with other tools such as
250 * 'mii-tool'.
251 * We now have 32 commands, so a bit more space ;-).
252 * Also, all 'odd' commands are only usable by root and don't return the
253 * content of ifr/iwr to user (but you are not obliged to use the set/get
254 * convention, just use every other two command).
255 * And I repeat : you are not obliged to use them with iwspy, but you
256 * must be compliant with it.
257 */
258
259 /* ------------------------- IOCTL STUFF ------------------------- */
260
261 /* The first and the last (range) */
262 #define SIOCIWFIRST 0x8B00
263 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
264
265 /* Even : get (world access), odd : set (root access) */
266 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
267 #define IW_IS_GET(cmd) ((cmd) & 0x1)
268
269 /* ----------------------- WIRELESS EVENTS ----------------------- */
270 /* Those are *NOT* ioctls, do not issue request on them !!! */
271 /* Most events use the same identifier as ioctl requests */
272
273 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
274 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
275 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
276 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
277 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
278
279 #define IWEVFIRST 0x8C00
280
281 /* ------------------------- PRIVATE INFO ------------------------- */
282 /*
283 * The following is used with SIOCGIWPRIV. It allow a driver to define
284 * the interface (name, type of data) for its private ioctl.
285 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
286 */
287
288 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
289 #define IW_PRIV_TYPE_NONE 0x0000
290 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
291 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
292 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
293 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
294 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
295
296 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */
297
298 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
299
300 /*
301 * Note : if the number of args is fixed and the size < 16 octets,
302 * instead of passing a pointer we will put args in the iwreq struct...
303 */
304
305 /* ----------------------- OTHER CONSTANTS ----------------------- */
306
307 /* Maximum frequencies in the range struct */
308 #define IW_MAX_FREQUENCIES 16
309 /* Note : if you have something like 80 frequencies,
310 * don't increase this constant and don't fill the frequency list.
311 * The user will be able to set by channel anyway... */
312
313 /* Maximum bit rates in the range struct */
314 #define IW_MAX_BITRATES 8
315
316 /* Maximum tx powers in the range struct */
317 #define IW_MAX_TXPOWER 8
318 /* Note : if you more than 8 TXPowers, just set the max and min or
319 * a few of them in the struct iw_range. */
320
321 /* Maximum of address that you may set with SPY */
322 #define IW_MAX_SPY 8 /* set */
323 #define IW_MAX_GET_SPY 64 /* get */
324
325 /* Maximum of address that you may get in the
326 list of access points in range */
327 #define IW_MAX_AP 8
328
329 /* Maximum size of the ESSID and NICKN strings */
330 #define IW_ESSID_MAX_SIZE 32
331
332 /* Modes of operation */
333 #define IW_MODE_AUTO 0 /* Let the driver decides */
334 #define IW_MODE_ADHOC 1 /* Single cell network */
335 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
336 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
337 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
338 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
339 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
340
341 /* Maximum number of size of encoding token available
342 * they are listed in the range structure */
343 #define IW_MAX_ENCODING_SIZES 8
344
345 /* Maximum size of the encoding token in bytes */
346 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
347
348 /* Flags for encoding (along with the token) */
349 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
350 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
351 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
352 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
353 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
354 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
355 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
356 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
357
358 /* Power management flags available (along with the value, if any) */
359 #define IW_POWER_ON 0x0000 /* No details... */
360 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
361 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
362 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
363 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
364 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
365 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
366 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
367 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
368 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
369 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
370 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
371 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
372 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
373
374 /* Transmit Power flags available */
375 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
376 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
377 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
378 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
379
380 /* Retry limits and lifetime flags available */
381 #define IW_RETRY_ON 0x0000 /* No details... */
382 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
383 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
384 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
385 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
386 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
387 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
388 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
389
390 /* Scanning request flags */
391 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
392 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
393 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
394 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
395 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
396 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
397 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
398 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
399 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
400 /* Maximum size of returned data */
401 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
402
403 /* Max number of char in custom event - use multiple of them if needed */
404 #define IW_CUSTOM_MAX 256 /* In bytes */
405
406 /****************************** TYPES ******************************/
407
408 /* --------------------------- SUBTYPES --------------------------- */
409 /*
410 * Generic format for most parameters that fit in an int
411 */
412 struct iw_param
413 {
414 __s32 value; /* The value of the parameter itself */
415 __u8 fixed; /* Hardware should not use auto select */
416 __u8 disabled; /* Disable the feature */
417 __u16 flags; /* Various specifc flags (if any) */
418 };
419
420 /*
421 * For all data larger than 16 octets, we need to use a
422 * pointer to memory allocated in user space.
423 */
424 struct iw_point
425 {
426 caddr_t pointer; /* Pointer to the data (in user space) */
427 __u16 length; /* number of fields or size in bytes */
428 __u16 flags; /* Optional params */
429 };
430
431 /*
432 * A frequency
433 * For numbers lower than 10^9, we encode the number in 'm' and
434 * set 'e' to 0
435 * For number greater than 10^9, we divide it by the lowest power
436 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
437 * The power of 10 is in 'e', the result of the division is in 'm'.
438 */
439 struct iw_freq
440 {
441 __s32 m; /* Mantissa */
442 __s16 e; /* Exponent */
443 __u8 i; /* List index (when in range struct) */
444 __u8 pad; /* Unused - just for alignement */
445 };
446
447 /*
448 * Quality of the link
449 */
450 struct iw_quality
451 {
452 __u8 qual; /* link quality (%retries, SNR,
453 %missed beacons or better...) */
454 __u8 level; /* signal level (dBm) */
455 __u8 noise; /* noise level (dBm) */
456 __u8 updated; /* Flags to know if updated */
457 };
458
459 /*
460 * Packet discarded in the wireless adapter due to
461 * "wireless" specific problems...
462 * Note : the list of counter and statistics in net_device_stats
463 * is already pretty exhaustive, and you should use that first.
464 * This is only additional stats...
465 */
466 struct iw_discarded
467 {
468 __u32 nwid; /* Rx : Wrong nwid/essid */
469 __u32 code; /* Rx : Unable to code/decode (WEP) */
470 __u32 fragment; /* Rx : Can't perform MAC reassembly */
471 __u32 retries; /* Tx : Max MAC retries num reached */
472 __u32 misc; /* Others cases */
473 };
474
475 /*
476 * Packet/Time period missed in the wireless adapter due to
477 * "wireless" specific problems...
478 */
479 struct iw_missed
480 {
481 __u32 beacon; /* Missed beacons/superframe */
482 };
483
484 /* ------------------------ WIRELESS STATS ------------------------ */
485 /*
486 * Wireless statistics (used for /proc/net/wireless)
487 */
488 struct iw_statistics
489 {
490 __u16 status; /* Status
491 * - device dependent for now */
492
493 struct iw_quality qual; /* Quality of the link
494 * (instant/mean/max) */
495 struct iw_discarded discard; /* Packet discarded counts */
496 struct iw_missed miss; /* Packet missed counts */
497 };
498
499 /* ------------------------ IOCTL REQUEST ------------------------ */
500 /*
501 * This structure defines the payload of an ioctl, and is used
502 * below.
503 *
504 * Note that this structure should fit on the memory footprint
505 * of iwreq (which is the same as ifreq), which mean a max size of
506 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
507 * You should check this when increasing the structures defined
508 * above in this file...
509 */
510 union iwreq_data
511 {
512 /* Config - generic */
513 char name[IFNAMSIZ];
514 /* Name : used to verify the presence of wireless extensions.
515 * Name of the protocol/provider... */
516
517 struct iw_point essid; /* Extended network name */
518 struct iw_param nwid; /* network id (or domain - the cell) */
519 struct iw_freq freq; /* frequency or channel :
520 * 0-1000 = channel
521 * > 1000 = frequency in Hz */
522
523 struct iw_param sens; /* signal level threshold */
524 struct iw_param bitrate; /* default bit rate */
525 struct iw_param txpower; /* default transmit power */
526 struct iw_param rts; /* RTS threshold threshold */
527 struct iw_param frag; /* Fragmentation threshold */
528 __u32 mode; /* Operation mode */
529 struct iw_param retry; /* Retry limits & lifetime */
530
531 struct iw_point encoding; /* Encoding stuff : tokens */
532 struct iw_param power; /* PM duration/timeout */
533 struct iw_quality qual; /* Quality part of statistics */
534
535 struct sockaddr ap_addr; /* Access point address */
536 struct sockaddr addr; /* Destination address (hw) */
537
538 struct iw_param param; /* Other small parameters */
539 struct iw_point data; /* Other large parameters */
540 };
541
542 /*
543 * The structure to exchange data for ioctl.
544 * This structure is the same as 'struct ifreq', but (re)defined for
545 * convenience...
546 * Do I need to remind you about structure size (32 octets) ?
547 */
548 struct iwreq
549 {
550 union
551 {
552 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
553 } ifr_ifrn;
554
555 /* Data part (defined just above) */
556 union iwreq_data u;
557 };
558
559 /* -------------------------- IOCTL DATA -------------------------- */
560 /*
561 * For those ioctl which want to exchange mode data that what could
562 * fit in the above structure...
563 */
564
565 /*
566 * Range of parameters
567 */
568
569 struct iw_range
570 {
571 /* Informative stuff (to choose between different interface) */
572 __u32 throughput; /* To give an idea... */
573 /* In theory this value should be the maximum benchmarked
574 * TCP/IP throughput, because with most of these devices the
575 * bit rate is meaningless (overhead an co) to estimate how
576 * fast the connection will go and pick the fastest one.
577 * I suggest people to play with Netperf or any benchmark...
578 */
579
580 /* NWID (or domain id) */
581 __u32 min_nwid; /* Minimal NWID we are able to set */
582 __u32 max_nwid; /* Maximal NWID we are able to set */
583
584 /* Frequency */
585 __u16 num_channels; /* Number of channels [0; num - 1] */
586 __u8 num_frequency; /* Number of entry in the list */
587 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
588 /* Note : this frequency list doesn't need to fit channel numbers */
589
590 /* signal level threshold range */
591 __s32 sensitivity;
592
593 /* Quality of link & SNR stuff */
594 struct iw_quality max_qual; /* Quality of the link */
595
596 /* Rates */
597 __u8 num_bitrates; /* Number of entries in the list */
598 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
599
600 /* RTS threshold */
601 __s32 min_rts; /* Minimal RTS threshold */
602 __s32 max_rts; /* Maximal RTS threshold */
603
604 /* Frag threshold */
605 __s32 min_frag; /* Minimal frag threshold */
606 __s32 max_frag; /* Maximal frag threshold */
607
608 /* Power Management duration & timeout */
609 __s32 min_pmp; /* Minimal PM period */
610 __s32 max_pmp; /* Maximal PM period */
611 __s32 min_pmt; /* Minimal PM timeout */
612 __s32 max_pmt; /* Maximal PM timeout */
613 __u16 pmp_flags; /* How to decode max/min PM period */
614 __u16 pmt_flags; /* How to decode max/min PM timeout */
615 __u16 pm_capa; /* What PM options are supported */
616
617 /* Encoder stuff */
618 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
619 __u8 num_encoding_sizes; /* Number of entry in the list */
620 __u8 max_encoding_tokens; /* Max number of tokens */
621
622 /* Transmit power */
623 __u16 txpower_capa; /* What options are supported */
624 __u8 num_txpower; /* Number of entries in the list */
625 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
626
627 /* Wireless Extension version info */
628 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
629 __u8 we_version_source; /* Last update of source */
630
631 /* Retry limits and lifetime */
632 __u16 retry_capa; /* What retry options are supported */
633 __u16 retry_flags; /* How to decode max/min retry limit */
634 __u16 r_time_flags; /* How to decode max/min retry life */
635 __s32 min_retry; /* Minimal number of retries */
636 __s32 max_retry; /* Maximal number of retries */
637 __s32 min_r_time; /* Minimal retry lifetime */
638 __s32 max_r_time; /* Maximal retry lifetime */
639
640 /* Average quality of link & SNR */
641 struct iw_quality avg_qual; /* Quality of the link */
642 /* This should contain the average/typical values of the quality
643 * indicator. This should be the threshold between a "good" and
644 * a "bad" link (example : monitor going from green to orange).
645 * Currently, user space apps like quality monitors don't have any
646 * way to calibrate the measurement. With this, they can split
647 * the range between 0 and max_qual in different quality level
648 * (using a geometric subdivision centered on the average).
649 * I expect that people doing the user space apps will feedback
650 * us on which value we need to put in each driver...
651 */
652 };
653
654 /*
655 * Private ioctl interface information
656 */
657
658 struct iw_priv_args
659 {
660 __u32 cmd; /* Number of the ioctl to issue */
661 __u16 set_args; /* Type and number of args */
662 __u16 get_args; /* Type and number of args */
663 char name[IFNAMSIZ]; /* Name of the extension */
664 };
665
666 /* ----------------------- WIRELESS EVENTS ----------------------- */
667 /*
668 * Wireless events are carried through the rtnetlink socket to user
669 * space. They are encapsulated in the IFLA_WIRELESS field of
670 * a RTM_NEWLINK message.
671 */
672
673 /*
674 * A Wireless Event. Contains basically the same data as the ioctl...
675 */
676 struct iw_event
677 {
678 __u16 len; /* Real lenght of this stuff */
679 __u16 cmd; /* Wireless IOCTL */
680 union iwreq_data u; /* IOCTL fixed payload */
681 };
682
683 /* Size of the Event prefix (including padding and alignement junk) */
684 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
685 /* Size of the various events */
686 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
687 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
688 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
689 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
690 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
691 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
692 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
693
694 /* Note : in the case of iw_point, the extra data will come at the
695 * end of the event */
696
697 #endif /* _LINUX_WIRELESS_H */
+0
-733
src/lwe/wireless.16.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 16 2.4.03
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # include/linux/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # include/linux/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* To minimise problems in user space, I might remove those headers
72 * at some point. Jean II */
73 #include <linux/types.h> /* for "caddr_t" et al */
74 #include <linux/socket.h> /* for "struct sockaddr" et al */
75 #include <linux/if.h> /* for IFNAMSIZ and co... */
76
77 /***************************** VERSION *****************************/
78 /*
79 * This constant is used to know the availability of the wireless
80 * extensions and to know which version of wireless extensions it is
81 * (there is some stuff that will be added in the future...)
82 * I just plan to increment with each new version.
83 */
84 #define WIRELESS_EXT 16
85
86 /*
87 * Changes :
88 *
89 * V2 to V3
90 * --------
91 * Alan Cox start some incompatibles changes. I've integrated a bit more.
92 * - Encryption renamed to Encode to avoid US regulation problems
93 * - Frequency changed from float to struct to avoid problems on old 386
94 *
95 * V3 to V4
96 * --------
97 * - Add sensitivity
98 *
99 * V4 to V5
100 * --------
101 * - Missing encoding definitions in range
102 * - Access points stuff
103 *
104 * V5 to V6
105 * --------
106 * - 802.11 support (ESSID ioctls)
107 *
108 * V6 to V7
109 * --------
110 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
111 *
112 * V7 to V8
113 * --------
114 * - Changed my e-mail address
115 * - More 802.11 support (nickname, rate, rts, frag)
116 * - List index in frequencies
117 *
118 * V8 to V9
119 * --------
120 * - Support for 'mode of operation' (ad-hoc, managed...)
121 * - Support for unicast and multicast power saving
122 * - Change encoding to support larger tokens (>64 bits)
123 * - Updated iw_params (disable, flags) and use it for NWID
124 * - Extracted iw_point from iwreq for clarity
125 *
126 * V9 to V10
127 * ---------
128 * - Add PM capability to range structure
129 * - Add PM modifier : MAX/MIN/RELATIVE
130 * - Add encoding option : IW_ENCODE_NOKEY
131 * - Add TxPower ioctls (work like TxRate)
132 *
133 * V10 to V11
134 * ----------
135 * - Add WE version in range (help backward/forward compatibility)
136 * - Add retry ioctls (work like PM)
137 *
138 * V11 to V12
139 * ----------
140 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
141 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
142 * - Add new statistics (frag, retry, beacon)
143 * - Add average quality (for user space calibration)
144 *
145 * V12 to V13
146 * ----------
147 * - Document creation of new driver API.
148 * - Extract union iwreq_data from struct iwreq (for new driver API).
149 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
150 *
151 * V13 to V14
152 * ----------
153 * - Wireless Events support : define struct iw_event
154 * - Define additional specific event numbers
155 * - Add "addr" and "param" fields in union iwreq_data
156 * - AP scanning stuff (SIOCSIWSCAN and friends)
157 *
158 * V14 to V15
159 * ----------
160 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
161 * - Make struct iw_freq signed (both m & e), add explicit padding
162 * - Add IWEVCUSTOM for driver specific event/scanning token
163 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
164 * - Add IW_TXPOW_RANGE for range of Tx Powers
165 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
166 * - Add IW_MODE_MONITOR for passive monitor
167 *
168 * V15 to V16
169 * ----------
170 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
171 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
172 * - Reshuffle struct iw_range for increases, add filler
173 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
174 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
175 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
176 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
177 */
178
179 /**************************** CONSTANTS ****************************/
180
181 /* -------------------------- IOCTL LIST -------------------------- */
182
183 /* Wireless Identification */
184 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
185 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
186 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
187 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
188 * Don't put the name of your driver there, it's useless. */
189
190 /* Basic operations */
191 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
192 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
193 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
194 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
195 #define SIOCSIWMODE 0x8B06 /* set operation mode */
196 #define SIOCGIWMODE 0x8B07 /* get operation mode */
197 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
198 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
199
200 /* Informative stuff */
201 #define SIOCSIWRANGE 0x8B0A /* Unused */
202 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
203 #define SIOCSIWPRIV 0x8B0C /* Unused */
204 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
205 #define SIOCSIWSTATS 0x8B0E /* Unused */
206 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
207 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
208 * is never passed to the driver (i.e. the driver will never see it). */
209
210 /* Spy support (statistics per MAC address - used for Mobile IP support) */
211 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
212 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
213 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
214 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
215
216 /* Access Point manipulation */
217 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
218 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
219 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
220 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
221 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
222
223 /* 802.11 specific support */
224 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
225 #define SIOCGIWESSID 0x8B1B /* get ESSID */
226 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
227 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
228 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
229 * within the 'iwreq' structure, so we need to use the 'data' member to
230 * point to a string in user space, like it is done for RANGE... */
231
232 /* Other parameters useful in 802.11 and some other devices */
233 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
234 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
235 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
236 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
237 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
238 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
239 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
240 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
241 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
242 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
243
244 /* Encoding stuff (scrambling, hardware security, WEP...) */
245 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
246 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
247 /* Power saving stuff (power management, unicast and multicast) */
248 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
249 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
250
251 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
252
253 /* These 16 ioctl are wireless device private.
254 * Each driver is free to use them for whatever purpose it chooses,
255 * however the driver *must* export the description of those ioctls
256 * with SIOCGIWPRIV and *must* use arguments as defined below.
257 * If you don't follow those rules, DaveM is going to hate you (reason :
258 * it make mixed 32/64bit operation impossible).
259 */
260 #define SIOCIWFIRSTPRIV 0x8BE0
261 #define SIOCIWLASTPRIV 0x8BFF
262 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
263 * separate range because of collisions with other tools such as
264 * 'mii-tool'.
265 * We now have 32 commands, so a bit more space ;-).
266 * Also, all 'odd' commands are only usable by root and don't return the
267 * content of ifr/iwr to user (but you are not obliged to use the set/get
268 * convention, just use every other two command).
269 * And I repeat : you are not obliged to use them with iwspy, but you
270 * must be compliant with it.
271 */
272
273 /* ------------------------- IOCTL STUFF ------------------------- */
274
275 /* The first and the last (range) */
276 #define SIOCIWFIRST 0x8B00
277 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
278
279 /* Even : get (world access), odd : set (root access) */
280 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
281 #define IW_IS_GET(cmd) ((cmd) & 0x1)
282
283 /* ----------------------- WIRELESS EVENTS ----------------------- */
284 /* Those are *NOT* ioctls, do not issue request on them !!! */
285 /* Most events use the same identifier as ioctl requests */
286
287 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
288 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
289 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
290 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
291 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
292
293 #define IWEVFIRST 0x8C00
294
295 /* ------------------------- PRIVATE INFO ------------------------- */
296 /*
297 * The following is used with SIOCGIWPRIV. It allow a driver to define
298 * the interface (name, type of data) for its private ioctl.
299 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
300 */
301
302 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
303 #define IW_PRIV_TYPE_NONE 0x0000
304 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
305 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
306 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
307 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
308 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
309
310 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
311
312 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
313
314 /*
315 * Note : if the number of args is fixed and the size < 16 octets,
316 * instead of passing a pointer we will put args in the iwreq struct...
317 */
318
319 /* ----------------------- OTHER CONSTANTS ----------------------- */
320
321 /* Maximum frequencies in the range struct */
322 #define IW_MAX_FREQUENCIES 32
323 /* Note : if you have something like 80 frequencies,
324 * don't increase this constant and don't fill the frequency list.
325 * The user will be able to set by channel anyway... */
326
327 /* Maximum bit rates in the range struct */
328 #define IW_MAX_BITRATES 32
329
330 /* Maximum tx powers in the range struct */
331 #define IW_MAX_TXPOWER 8
332 /* Note : if you more than 8 TXPowers, just set the max and min or
333 * a few of them in the struct iw_range. */
334
335 /* Maximum of address that you may set with SPY */
336 #define IW_MAX_SPY 8
337
338 /* Maximum of address that you may get in the
339 list of access points in range */
340 #define IW_MAX_AP 64
341
342 /* Maximum size of the ESSID and NICKN strings */
343 #define IW_ESSID_MAX_SIZE 32
344
345 /* Modes of operation */
346 #define IW_MODE_AUTO 0 /* Let the driver decides */
347 #define IW_MODE_ADHOC 1 /* Single cell network */
348 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
349 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
350 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
351 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
352 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
353
354 /* Maximum number of size of encoding token available
355 * they are listed in the range structure */
356 #define IW_MAX_ENCODING_SIZES 8
357
358 /* Maximum size of the encoding token in bytes */
359 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
360
361 /* Flags for encoding (along with the token) */
362 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
363 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
364 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
365 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
366 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
367 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
368 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
369 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
370 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
371
372 /* Power management flags available (along with the value, if any) */
373 #define IW_POWER_ON 0x0000 /* No details... */
374 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
375 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
376 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
377 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
378 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
379 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
380 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
381 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
382 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
383 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
384 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
385 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
386 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
387
388 /* Transmit Power flags available */
389 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
390 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
391 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
392 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
393
394 /* Retry limits and lifetime flags available */
395 #define IW_RETRY_ON 0x0000 /* No details... */
396 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
397 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
398 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
399 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
400 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
401 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
402 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
403
404 /* Scanning request flags */
405 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
406 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
407 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
408 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
409 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
410 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
411 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
412 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
413 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
414 /* Maximum size of returned data */
415 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
416
417 /* Max number of char in custom event - use multiple of them if needed */
418 #define IW_CUSTOM_MAX 256 /* In bytes */
419
420 /****************************** TYPES ******************************/
421
422 /* --------------------------- SUBTYPES --------------------------- */
423 /*
424 * Generic format for most parameters that fit in an int
425 */
426 struct iw_param
427 {
428 __s32 value; /* The value of the parameter itself */
429 __u8 fixed; /* Hardware should not use auto select */
430 __u8 disabled; /* Disable the feature */
431 __u16 flags; /* Various specifc flags (if any) */
432 };
433
434 /*
435 * For all data larger than 16 octets, we need to use a
436 * pointer to memory allocated in user space.
437 */
438 struct iw_point
439 {
440 caddr_t pointer; /* Pointer to the data (in user space) */
441 __u16 length; /* number of fields or size in bytes */
442 __u16 flags; /* Optional params */
443 };
444
445 /*
446 * A frequency
447 * For numbers lower than 10^9, we encode the number in 'm' and
448 * set 'e' to 0
449 * For number greater than 10^9, we divide it by the lowest power
450 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
451 * The power of 10 is in 'e', the result of the division is in 'm'.
452 */
453 struct iw_freq
454 {
455 __s32 m; /* Mantissa */
456 __s16 e; /* Exponent */
457 __u8 i; /* List index (when in range struct) */
458 __u8 pad; /* Unused - just for alignement */
459 };
460
461 /*
462 * Quality of the link
463 */
464 struct iw_quality
465 {
466 __u8 qual; /* link quality (%retries, SNR,
467 %missed beacons or better...) */
468 __u8 level; /* signal level (dBm) */
469 __u8 noise; /* noise level (dBm) */
470 __u8 updated; /* Flags to know if updated */
471 };
472
473 /*
474 * Packet discarded in the wireless adapter due to
475 * "wireless" specific problems...
476 * Note : the list of counter and statistics in net_device_stats
477 * is already pretty exhaustive, and you should use that first.
478 * This is only additional stats...
479 */
480 struct iw_discarded
481 {
482 __u32 nwid; /* Rx : Wrong nwid/essid */
483 __u32 code; /* Rx : Unable to code/decode (WEP) */
484 __u32 fragment; /* Rx : Can't perform MAC reassembly */
485 __u32 retries; /* Tx : Max MAC retries num reached */
486 __u32 misc; /* Others cases */
487 };
488
489 /*
490 * Packet/Time period missed in the wireless adapter due to
491 * "wireless" specific problems...
492 */
493 struct iw_missed
494 {
495 __u32 beacon; /* Missed beacons/superframe */
496 };
497
498 /*
499 * Quality range (for spy threshold)
500 */
501 struct iw_thrspy
502 {
503 struct sockaddr addr; /* Source address (hw/mac) */
504 struct iw_quality qual; /* Quality of the link */
505 struct iw_quality low; /* Low threshold */
506 struct iw_quality high; /* High threshold */
507 };
508
509 /* ------------------------ WIRELESS STATS ------------------------ */
510 /*
511 * Wireless statistics (used for /proc/net/wireless)
512 */
513 struct iw_statistics
514 {
515 __u16 status; /* Status
516 * - device dependent for now */
517
518 struct iw_quality qual; /* Quality of the link
519 * (instant/mean/max) */
520 struct iw_discarded discard; /* Packet discarded counts */
521 struct iw_missed miss; /* Packet missed counts */
522 };
523
524 /* ------------------------ IOCTL REQUEST ------------------------ */
525 /*
526 * This structure defines the payload of an ioctl, and is used
527 * below.
528 *
529 * Note that this structure should fit on the memory footprint
530 * of iwreq (which is the same as ifreq), which mean a max size of
531 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
532 * You should check this when increasing the structures defined
533 * above in this file...
534 */
535 union iwreq_data
536 {
537 /* Config - generic */
538 char name[IFNAMSIZ];
539 /* Name : used to verify the presence of wireless extensions.
540 * Name of the protocol/provider... */
541
542 struct iw_point essid; /* Extended network name */
543 struct iw_param nwid; /* network id (or domain - the cell) */
544 struct iw_freq freq; /* frequency or channel :
545 * 0-1000 = channel
546 * > 1000 = frequency in Hz */
547
548 struct iw_param sens; /* signal level threshold */
549 struct iw_param bitrate; /* default bit rate */
550 struct iw_param txpower; /* default transmit power */
551 struct iw_param rts; /* RTS threshold threshold */
552 struct iw_param frag; /* Fragmentation threshold */
553 __u32 mode; /* Operation mode */
554 struct iw_param retry; /* Retry limits & lifetime */
555
556 struct iw_point encoding; /* Encoding stuff : tokens */
557 struct iw_param power; /* PM duration/timeout */
558 struct iw_quality qual; /* Quality part of statistics */
559
560 struct sockaddr ap_addr; /* Access point address */
561 struct sockaddr addr; /* Destination address (hw/mac) */
562
563 struct iw_param param; /* Other small parameters */
564 struct iw_point data; /* Other large parameters */
565 };
566
567 /*
568 * The structure to exchange data for ioctl.
569 * This structure is the same as 'struct ifreq', but (re)defined for
570 * convenience...
571 * Do I need to remind you about structure size (32 octets) ?
572 */
573 struct iwreq
574 {
575 union
576 {
577 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
578 } ifr_ifrn;
579
580 /* Data part (defined just above) */
581 union iwreq_data u;
582 };
583
584 /* -------------------------- IOCTL DATA -------------------------- */
585 /*
586 * For those ioctl which want to exchange mode data that what could
587 * fit in the above structure...
588 */
589
590 /*
591 * Range of parameters
592 */
593
594 struct iw_range
595 {
596 /* Informative stuff (to choose between different interface) */
597 __u32 throughput; /* To give an idea... */
598 /* In theory this value should be the maximum benchmarked
599 * TCP/IP throughput, because with most of these devices the
600 * bit rate is meaningless (overhead an co) to estimate how
601 * fast the connection will go and pick the fastest one.
602 * I suggest people to play with Netperf or any benchmark...
603 */
604
605 /* NWID (or domain id) */
606 __u32 min_nwid; /* Minimal NWID we are able to set */
607 __u32 max_nwid; /* Maximal NWID we are able to set */
608
609 /* Old Frequency (backward compat - moved lower ) */
610 __u16 old_num_channels;
611 __u8 old_num_frequency;
612 /* Filler to keep "version" at the same offset */
613 __s32 old_freq[6];
614
615 /* signal level threshold range */
616 __s32 sensitivity;
617
618 /* Quality of link & SNR stuff */
619 /* Quality range (link, level, noise)
620 * If the quality is absolute, it will be in the range [0 ; max_qual],
621 * if the quality is dBm, it will be in the range [max_qual ; 0].
622 * Don't forget that we use 8 bit arithmetics... */
623 struct iw_quality max_qual; /* Quality of the link */
624 /* This should contain the average/typical values of the quality
625 * indicator. This should be the threshold between a "good" and
626 * a "bad" link (example : monitor going from green to orange).
627 * Currently, user space apps like quality monitors don't have any
628 * way to calibrate the measurement. With this, they can split
629 * the range between 0 and max_qual in different quality level
630 * (using a geometric subdivision centered on the average).
631 * I expect that people doing the user space apps will feedback
632 * us on which value we need to put in each driver... */
633 struct iw_quality avg_qual; /* Quality of the link */
634
635 /* Rates */
636 __u8 num_bitrates; /* Number of entries in the list */
637 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
638
639 /* RTS threshold */
640 __s32 min_rts; /* Minimal RTS threshold */
641 __s32 max_rts; /* Maximal RTS threshold */
642
643 /* Frag threshold */
644 __s32 min_frag; /* Minimal frag threshold */
645 __s32 max_frag; /* Maximal frag threshold */
646
647 /* Power Management duration & timeout */
648 __s32 min_pmp; /* Minimal PM period */
649 __s32 max_pmp; /* Maximal PM period */
650 __s32 min_pmt; /* Minimal PM timeout */
651 __s32 max_pmt; /* Maximal PM timeout */
652 __u16 pmp_flags; /* How to decode max/min PM period */
653 __u16 pmt_flags; /* How to decode max/min PM timeout */
654 __u16 pm_capa; /* What PM options are supported */
655
656 /* Encoder stuff */
657 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
658 __u8 num_encoding_sizes; /* Number of entry in the list */
659 __u8 max_encoding_tokens; /* Max number of tokens */
660 /* For drivers that need a "login/passwd" form */
661 __u8 encoding_login_index; /* token index for login token */
662
663 /* Transmit power */
664 __u16 txpower_capa; /* What options are supported */
665 __u8 num_txpower; /* Number of entries in the list */
666 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
667
668 /* Wireless Extension version info */
669 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
670 __u8 we_version_source; /* Last update of source */
671
672 /* Retry limits and lifetime */
673 __u16 retry_capa; /* What retry options are supported */
674 __u16 retry_flags; /* How to decode max/min retry limit */
675 __u16 r_time_flags; /* How to decode max/min retry life */
676 __s32 min_retry; /* Minimal number of retries */
677 __s32 max_retry; /* Maximal number of retries */
678 __s32 min_r_time; /* Minimal retry lifetime */
679 __s32 max_r_time; /* Maximal retry lifetime */
680
681 /* Frequency */
682 __u16 num_channels; /* Number of channels [0; num - 1] */
683 __u8 num_frequency; /* Number of entry in the list */
684 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
685 /* Note : this frequency list doesn't need to fit channel numbers,
686 * because each entry contain its channel index */
687 };
688
689 /*
690 * Private ioctl interface information
691 */
692
693 struct iw_priv_args
694 {
695 __u32 cmd; /* Number of the ioctl to issue */
696 __u16 set_args; /* Type and number of args */
697 __u16 get_args; /* Type and number of args */
698 char name[IFNAMSIZ]; /* Name of the extension */
699 };
700
701 /* ----------------------- WIRELESS EVENTS ----------------------- */
702 /*
703 * Wireless events are carried through the rtnetlink socket to user
704 * space. They are encapsulated in the IFLA_WIRELESS field of
705 * a RTM_NEWLINK message.
706 */
707
708 /*
709 * A Wireless Event. Contains basically the same data as the ioctl...
710 */
711 struct iw_event
712 {
713 __u16 len; /* Real lenght of this stuff */
714 __u16 cmd; /* Wireless IOCTL */
715 union iwreq_data u; /* IOCTL fixed payload */
716 };
717
718 /* Size of the Event prefix (including padding and alignement junk) */
719 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
720 /* Size of the various events */
721 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
722 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
723 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
724 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
725 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
726 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
727 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
728
729 /* Note : in the case of iw_point, the extra data will come at the
730 * end of the event */
731
732 #endif /* _LINUX_WIRELESS_H */
+0
-773
src/lwe/wireless.17.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 17 21.6.04
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # net/core/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # net/core/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* To minimise problems in user space, I might remove those headers
72 * at some point. Jean II */
73 #include <linux/types.h> /* for "caddr_t" et al */
74 #include <linux/socket.h> /* for "struct sockaddr" et al */
75 #include <linux/if.h> /* for IFNAMSIZ and co... */
76
77 /***************************** VERSION *****************************/
78 /*
79 * This constant is used to know the availability of the wireless
80 * extensions and to know which version of wireless extensions it is
81 * (there is some stuff that will be added in the future...)
82 * I just plan to increment with each new version.
83 */
84 #define WIRELESS_EXT 17
85
86 /*
87 * Changes :
88 *
89 * V2 to V3
90 * --------
91 * Alan Cox start some incompatibles changes. I've integrated a bit more.
92 * - Encryption renamed to Encode to avoid US regulation problems
93 * - Frequency changed from float to struct to avoid problems on old 386
94 *
95 * V3 to V4
96 * --------
97 * - Add sensitivity
98 *
99 * V4 to V5
100 * --------
101 * - Missing encoding definitions in range
102 * - Access points stuff
103 *
104 * V5 to V6
105 * --------
106 * - 802.11 support (ESSID ioctls)
107 *
108 * V6 to V7
109 * --------
110 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
111 *
112 * V7 to V8
113 * --------
114 * - Changed my e-mail address
115 * - More 802.11 support (nickname, rate, rts, frag)
116 * - List index in frequencies
117 *
118 * V8 to V9
119 * --------
120 * - Support for 'mode of operation' (ad-hoc, managed...)
121 * - Support for unicast and multicast power saving
122 * - Change encoding to support larger tokens (>64 bits)
123 * - Updated iw_params (disable, flags) and use it for NWID
124 * - Extracted iw_point from iwreq for clarity
125 *
126 * V9 to V10
127 * ---------
128 * - Add PM capability to range structure
129 * - Add PM modifier : MAX/MIN/RELATIVE
130 * - Add encoding option : IW_ENCODE_NOKEY
131 * - Add TxPower ioctls (work like TxRate)
132 *
133 * V10 to V11
134 * ----------
135 * - Add WE version in range (help backward/forward compatibility)
136 * - Add retry ioctls (work like PM)
137 *
138 * V11 to V12
139 * ----------
140 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
141 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
142 * - Add new statistics (frag, retry, beacon)
143 * - Add average quality (for user space calibration)
144 *
145 * V12 to V13
146 * ----------
147 * - Document creation of new driver API.
148 * - Extract union iwreq_data from struct iwreq (for new driver API).
149 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
150 *
151 * V13 to V14
152 * ----------
153 * - Wireless Events support : define struct iw_event
154 * - Define additional specific event numbers
155 * - Add "addr" and "param" fields in union iwreq_data
156 * - AP scanning stuff (SIOCSIWSCAN and friends)
157 *
158 * V14 to V15
159 * ----------
160 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
161 * - Make struct iw_freq signed (both m & e), add explicit padding
162 * - Add IWEVCUSTOM for driver specific event/scanning token
163 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
164 * - Add IW_TXPOW_RANGE for range of Tx Powers
165 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
166 * - Add IW_MODE_MONITOR for passive monitor
167 *
168 * V15 to V16
169 * ----------
170 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
171 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
172 * - Reshuffle struct iw_range for increases, add filler
173 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
174 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
175 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
176 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
177 *
178 * V16 to V17
179 * ----------
180 * - Add flags to frequency -> auto/fixed
181 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
182 * - Wireless Event capability in struct iw_range
183 * - Add support for relative TxPower (yick !)
184 */
185
186 /**************************** CONSTANTS ****************************/
187
188 /* -------------------------- IOCTL LIST -------------------------- */
189
190 /* Wireless Identification */
191 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
192 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
193 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
194 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
195 * Don't put the name of your driver there, it's useless. */
196
197 /* Basic operations */
198 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
199 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
200 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
201 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
202 #define SIOCSIWMODE 0x8B06 /* set operation mode */
203 #define SIOCGIWMODE 0x8B07 /* get operation mode */
204 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
205 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
206
207 /* Informative stuff */
208 #define SIOCSIWRANGE 0x8B0A /* Unused */
209 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
210 #define SIOCSIWPRIV 0x8B0C /* Unused */
211 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
212 #define SIOCSIWSTATS 0x8B0E /* Unused */
213 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
214 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
215 * is never passed to the driver (i.e. the driver will never see it). */
216
217 /* Spy support (statistics per MAC address - used for Mobile IP support) */
218 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
219 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
220 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
221 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
222
223 /* Access Point manipulation */
224 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
225 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
226 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
227 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
228 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
229
230 /* 802.11 specific support */
231 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
232 #define SIOCGIWESSID 0x8B1B /* get ESSID */
233 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
234 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
235 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
236 * within the 'iwreq' structure, so we need to use the 'data' member to
237 * point to a string in user space, like it is done for RANGE... */
238
239 /* Other parameters useful in 802.11 and some other devices */
240 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
241 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
242 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
243 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
244 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
245 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
246 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
247 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
248 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
249 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
250
251 /* Encoding stuff (scrambling, hardware security, WEP...) */
252 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
253 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
254 /* Power saving stuff (power management, unicast and multicast) */
255 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
256 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
257
258 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
259
260 /* These 32 ioctl are wireless device private, for 16 commands.
261 * Each driver is free to use them for whatever purpose it chooses,
262 * however the driver *must* export the description of those ioctls
263 * with SIOCGIWPRIV and *must* use arguments as defined below.
264 * If you don't follow those rules, DaveM is going to hate you (reason :
265 * it make mixed 32/64bit operation impossible).
266 */
267 #define SIOCIWFIRSTPRIV 0x8BE0
268 #define SIOCIWLASTPRIV 0x8BFF
269 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
270 * separate range because of collisions with other tools such as
271 * 'mii-tool'.
272 * We now have 32 commands, so a bit more space ;-).
273 * Also, all 'odd' commands are only usable by root and don't return the
274 * content of ifr/iwr to user (but you are not obliged to use the set/get
275 * convention, just use every other two command). More details in iwpriv.c.
276 * And I repeat : you are not forced to use them with iwpriv, but you
277 * must be compliant with it.
278 */
279
280 /* ------------------------- IOCTL STUFF ------------------------- */
281
282 /* The first and the last (range) */
283 #define SIOCIWFIRST 0x8B00
284 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
285
286 /* Even : get (world access), odd : set (root access) */
287 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
288 #define IW_IS_GET(cmd) ((cmd) & 0x1)
289
290 /* ----------------------- WIRELESS EVENTS ----------------------- */
291 /* Those are *NOT* ioctls, do not issue request on them !!! */
292 /* Most events use the same identifier as ioctl requests */
293
294 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
295 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
296 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
297 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
298 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
299
300 #define IWEVFIRST 0x8C00
301
302 /* ------------------------- PRIVATE INFO ------------------------- */
303 /*
304 * The following is used with SIOCGIWPRIV. It allow a driver to define
305 * the interface (name, type of data) for its private ioctl.
306 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
307 */
308
309 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
310 #define IW_PRIV_TYPE_NONE 0x0000
311 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
312 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
313 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
314 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
315 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
316
317 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
318
319 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
320
321 /*
322 * Note : if the number of args is fixed and the size < 16 octets,
323 * instead of passing a pointer we will put args in the iwreq struct...
324 */
325
326 /* ----------------------- OTHER CONSTANTS ----------------------- */
327
328 /* Maximum frequencies in the range struct */
329 #define IW_MAX_FREQUENCIES 32
330 /* Note : if you have something like 80 frequencies,
331 * don't increase this constant and don't fill the frequency list.
332 * The user will be able to set by channel anyway... */
333
334 /* Maximum bit rates in the range struct */
335 #define IW_MAX_BITRATES 32
336
337 /* Maximum tx powers in the range struct */
338 #define IW_MAX_TXPOWER 8
339 /* Note : if you more than 8 TXPowers, just set the max and min or
340 * a few of them in the struct iw_range. */
341
342 /* Maximum of address that you may set with SPY */
343 #define IW_MAX_SPY 8
344
345 /* Maximum of address that you may get in the
346 list of access points in range */
347 #define IW_MAX_AP 64
348
349 /* Maximum size of the ESSID and NICKN strings */
350 #define IW_ESSID_MAX_SIZE 32
351
352 /* Modes of operation */
353 #define IW_MODE_AUTO 0 /* Let the driver decides */
354 #define IW_MODE_ADHOC 1 /* Single cell network */
355 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
356 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
357 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
358 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
359 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
360
361 /* Statistics flags (bitmask in updated) */
362 #define IW_QUAL_QUAL_UPDATED 0x1 /* Value was updated since last read */
363 #define IW_QUAL_LEVEL_UPDATED 0x2
364 #define IW_QUAL_NOISE_UPDATED 0x4
365 #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
366 #define IW_QUAL_LEVEL_INVALID 0x20
367 #define IW_QUAL_NOISE_INVALID 0x40
368
369 /* Frequency flags */
370 #define IW_FREQ_AUTO 0x00 /* Let the driver decides */
371 #define IW_FREQ_FIXED 0x01 /* Force a specific value */
372
373 /* Maximum number of size of encoding token available
374 * they are listed in the range structure */
375 #define IW_MAX_ENCODING_SIZES 8
376
377 /* Maximum size of the encoding token in bytes */
378 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
379
380 /* Flags for encoding (along with the token) */
381 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
382 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
383 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
384 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
385 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
386 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
387 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
388 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
389 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
390
391 /* Power management flags available (along with the value, if any) */
392 #define IW_POWER_ON 0x0000 /* No details... */
393 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
394 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
395 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
396 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
397 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
398 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
399 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
400 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
401 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
402 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
403 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
404 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
405 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
406
407 /* Transmit Power flags available */
408 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
409 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
410 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
411 #define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
412 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
413
414 /* Retry limits and lifetime flags available */
415 #define IW_RETRY_ON 0x0000 /* No details... */
416 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
417 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
418 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
419 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
420 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
421 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
422 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
423
424 /* Scanning request flags */
425 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
426 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
427 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
428 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
429 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
430 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
431 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
432 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
433 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
434 /* Maximum size of returned data */
435 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
436
437 /* Max number of char in custom event - use multiple of them if needed */
438 #define IW_CUSTOM_MAX 256 /* In bytes */
439
440 /* Event capability macros - in (struct iw_range *)->event_capa
441 * Because we have more than 32 possible events, we use an array of
442 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
443 #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
444 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
445 (cmd - SIOCSIWCOMMIT))
446 #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
447 #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
448 /* Event capability constants - event autogenerated by the kernel
449 * This list is valid for most 802.11 devices, customise as needed... */
450 #define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
451 IW_EVENT_CAPA_MASK(0x8B06) | \
452 IW_EVENT_CAPA_MASK(0x8B1A))
453 #define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
454 /* "Easy" macro to set events in iw_range (less efficient) */
455 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
456 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
457
458
459 /****************************** TYPES ******************************/
460
461 /* --------------------------- SUBTYPES --------------------------- */
462 /*
463 * Generic format for most parameters that fit in an int
464 */
465 struct iw_param
466 {
467 __s32 value; /* The value of the parameter itself */
468 __u8 fixed; /* Hardware should not use auto select */
469 __u8 disabled; /* Disable the feature */
470 __u16 flags; /* Various specifc flags (if any) */
471 };
472
473 /*
474 * For all data larger than 16 octets, we need to use a
475 * pointer to memory allocated in user space.
476 */
477 struct iw_point
478 {
479 caddr_t pointer; /* Pointer to the data (in user space) */
480 __u16 length; /* number of fields or size in bytes */
481 __u16 flags; /* Optional params */
482 };
483
484 /*
485 * A frequency
486 * For numbers lower than 10^9, we encode the number in 'm' and
487 * set 'e' to 0
488 * For number greater than 10^9, we divide it by the lowest power
489 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
490 * The power of 10 is in 'e', the result of the division is in 'm'.
491 */
492 struct iw_freq
493 {
494 __s32 m; /* Mantissa */
495 __s16 e; /* Exponent */
496 __u8 i; /* List index (when in range struct) */
497 __u8 flags; /* Flags (fixed/auto) */
498 };
499
500 /*
501 * Quality of the link
502 */
503 struct iw_quality
504 {
505 __u8 qual; /* link quality (%retries, SNR,
506 %missed beacons or better...) */
507 __u8 level; /* signal level (dBm) */
508 __u8 noise; /* noise level (dBm) */
509 __u8 updated; /* Flags to know if updated */
510 };
511
512 /*
513 * Packet discarded in the wireless adapter due to
514 * "wireless" specific problems...
515 * Note : the list of counter and statistics in net_device_stats
516 * is already pretty exhaustive, and you should use that first.
517 * This is only additional stats...
518 */
519 struct iw_discarded
520 {
521 __u32 nwid; /* Rx : Wrong nwid/essid */
522 __u32 code; /* Rx : Unable to code/decode (WEP) */
523 __u32 fragment; /* Rx : Can't perform MAC reassembly */
524 __u32 retries; /* Tx : Max MAC retries num reached */
525 __u32 misc; /* Others cases */
526 };
527
528 /*
529 * Packet/Time period missed in the wireless adapter due to
530 * "wireless" specific problems...
531 */
532 struct iw_missed
533 {
534 __u32 beacon; /* Missed beacons/superframe */
535 };
536
537 /*
538 * Quality range (for spy threshold)
539 */
540 struct iw_thrspy
541 {
542 struct sockaddr addr; /* Source address (hw/mac) */
543 struct iw_quality qual; /* Quality of the link */
544 struct iw_quality low; /* Low threshold */
545 struct iw_quality high; /* High threshold */
546 };
547
548 /* ------------------------ WIRELESS STATS ------------------------ */
549 /*
550 * Wireless statistics (used for /proc/net/wireless)
551 */
552 struct iw_statistics
553 {
554 __u16 status; /* Status
555 * - device dependent for now */
556
557 struct iw_quality qual; /* Quality of the link
558 * (instant/mean/max) */
559 struct iw_discarded discard; /* Packet discarded counts */
560 struct iw_missed miss; /* Packet missed counts */
561 };
562
563 /* ------------------------ IOCTL REQUEST ------------------------ */
564 /*
565 * This structure defines the payload of an ioctl, and is used
566 * below.
567 *
568 * Note that this structure should fit on the memory footprint
569 * of iwreq (which is the same as ifreq), which mean a max size of
570 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
571 * You should check this when increasing the structures defined
572 * above in this file...
573 */
574 union iwreq_data
575 {
576 /* Config - generic */
577 char name[IFNAMSIZ];
578 /* Name : used to verify the presence of wireless extensions.
579 * Name of the protocol/provider... */
580
581 struct iw_point essid; /* Extended network name */
582 struct iw_param nwid; /* network id (or domain - the cell) */
583 struct iw_freq freq; /* frequency or channel :
584 * 0-1000 = channel
585 * > 1000 = frequency in Hz */
586
587 struct iw_param sens; /* signal level threshold */
588 struct iw_param bitrate; /* default bit rate */
589 struct iw_param txpower; /* default transmit power */
590 struct iw_param rts; /* RTS threshold threshold */
591 struct iw_param frag; /* Fragmentation threshold */
592 __u32 mode; /* Operation mode */
593 struct iw_param retry; /* Retry limits & lifetime */
594
595 struct iw_point encoding; /* Encoding stuff : tokens */
596 struct iw_param power; /* PM duration/timeout */
597 struct iw_quality qual; /* Quality part of statistics */
598
599 struct sockaddr ap_addr; /* Access point address */
600 struct sockaddr addr; /* Destination address (hw/mac) */
601
602 struct iw_param param; /* Other small parameters */
603 struct iw_point data; /* Other large parameters */
604 };
605
606 /*
607 * The structure to exchange data for ioctl.
608 * This structure is the same as 'struct ifreq', but (re)defined for
609 * convenience...
610 * Do I need to remind you about structure size (32 octets) ?
611 */
612 struct iwreq
613 {
614 union
615 {
616 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
617 } ifr_ifrn;
618
619 /* Data part (defined just above) */
620 union iwreq_data u;
621 };
622
623 /* -------------------------- IOCTL DATA -------------------------- */
624 /*
625 * For those ioctl which want to exchange mode data that what could
626 * fit in the above structure...
627 */
628
629 /*
630 * Range of parameters
631 */
632
633 struct iw_range
634 {
635 /* Informative stuff (to choose between different interface) */
636 __u32 throughput; /* To give an idea... */
637 /* In theory this value should be the maximum benchmarked
638 * TCP/IP throughput, because with most of these devices the
639 * bit rate is meaningless (overhead an co) to estimate how
640 * fast the connection will go and pick the fastest one.
641 * I suggest people to play with Netperf or any benchmark...
642 */
643
644 /* NWID (or domain id) */
645 __u32 min_nwid; /* Minimal NWID we are able to set */
646 __u32 max_nwid; /* Maximal NWID we are able to set */
647
648 /* Old Frequency (backward compat - moved lower ) */
649 __u16 old_num_channels;
650 __u8 old_num_frequency;
651
652 /* Wireless event capability bitmasks */
653 __u32 event_capa[6];
654
655 /* signal level threshold range */
656 __s32 sensitivity;
657
658 /* Quality of link & SNR stuff */
659 /* Quality range (link, level, noise)
660 * If the quality is absolute, it will be in the range [0 ; max_qual],
661 * if the quality is dBm, it will be in the range [max_qual ; 0].
662 * Don't forget that we use 8 bit arithmetics... */
663 struct iw_quality max_qual; /* Quality of the link */
664 /* This should contain the average/typical values of the quality
665 * indicator. This should be the threshold between a "good" and
666 * a "bad" link (example : monitor going from green to orange).
667 * Currently, user space apps like quality monitors don't have any
668 * way to calibrate the measurement. With this, they can split
669 * the range between 0 and max_qual in different quality level
670 * (using a geometric subdivision centered on the average).
671 * I expect that people doing the user space apps will feedback
672 * us on which value we need to put in each driver... */
673 struct iw_quality avg_qual; /* Quality of the link */
674
675 /* Rates */
676 __u8 num_bitrates; /* Number of entries in the list */
677 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
678
679 /* RTS threshold */
680 __s32 min_rts; /* Minimal RTS threshold */
681 __s32 max_rts; /* Maximal RTS threshold */
682
683 /* Frag threshold */
684 __s32 min_frag; /* Minimal frag threshold */
685 __s32 max_frag; /* Maximal frag threshold */
686
687 /* Power Management duration & timeout */
688 __s32 min_pmp; /* Minimal PM period */
689 __s32 max_pmp; /* Maximal PM period */
690 __s32 min_pmt; /* Minimal PM timeout */
691 __s32 max_pmt; /* Maximal PM timeout */
692 __u16 pmp_flags; /* How to decode max/min PM period */
693 __u16 pmt_flags; /* How to decode max/min PM timeout */
694 __u16 pm_capa; /* What PM options are supported */
695
696 /* Encoder stuff */
697 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
698 __u8 num_encoding_sizes; /* Number of entry in the list */
699 __u8 max_encoding_tokens; /* Max number of tokens */
700 /* For drivers that need a "login/passwd" form */
701 __u8 encoding_login_index; /* token index for login token */
702
703 /* Transmit power */
704 __u16 txpower_capa; /* What options are supported */
705 __u8 num_txpower; /* Number of entries in the list */
706 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
707
708 /* Wireless Extension version info */
709 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
710 __u8 we_version_source; /* Last update of source */
711
712 /* Retry limits and lifetime */
713 __u16 retry_capa; /* What retry options are supported */
714 __u16 retry_flags; /* How to decode max/min retry limit */
715 __u16 r_time_flags; /* How to decode max/min retry life */
716 __s32 min_retry; /* Minimal number of retries */
717 __s32 max_retry; /* Maximal number of retries */
718 __s32 min_r_time; /* Minimal retry lifetime */
719 __s32 max_r_time; /* Maximal retry lifetime */
720
721 /* Frequency */
722 __u16 num_channels; /* Number of channels [0; num - 1] */
723 __u8 num_frequency; /* Number of entry in the list */
724 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
725 /* Note : this frequency list doesn't need to fit channel numbers,
726 * because each entry contain its channel index */
727 };
728
729 /*
730 * Private ioctl interface information
731 */
732
733 struct iw_priv_args
734 {
735 __u32 cmd; /* Number of the ioctl to issue */
736 __u16 set_args; /* Type and number of args */
737 __u16 get_args; /* Type and number of args */
738 char name[IFNAMSIZ]; /* Name of the extension */
739 };
740
741 /* ----------------------- WIRELESS EVENTS ----------------------- */
742 /*
743 * Wireless events are carried through the rtnetlink socket to user
744 * space. They are encapsulated in the IFLA_WIRELESS field of
745 * a RTM_NEWLINK message.
746 */
747
748 /*
749 * A Wireless Event. Contains basically the same data as the ioctl...
750 */
751 struct iw_event
752 {
753 __u16 len; /* Real lenght of this stuff */
754 __u16 cmd; /* Wireless IOCTL */
755 union iwreq_data u; /* IOCTL fixed payload */
756 };
757
758 /* Size of the Event prefix (including padding and alignement junk) */
759 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
760 /* Size of the various events */
761 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
762 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
763 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
764 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
765 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
766 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
767 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
768
769 /* Note : in the case of iw_point, the extra data will come at the
770 * end of the event */
771
772 #endif /* _LINUX_WIRELESS_H */
+0
-1050
src/lwe/wireless.18.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 18 12.3.05
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # net/core/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # net/core/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* To minimise problems in user space, I might remove those headers
72 * at some point. Jean II */
73 #include <linux/types.h> /* for "caddr_t" et al */
74 #include <linux/socket.h> /* for "struct sockaddr" et al */
75 #include <linux/if.h> /* for IFNAMSIZ and co... */
76
77 /***************************** VERSION *****************************/
78 /*
79 * This constant is used to know the availability of the wireless
80 * extensions and to know which version of wireless extensions it is
81 * (there is some stuff that will be added in the future...)
82 * I just plan to increment with each new version.
83 */
84 #define WIRELESS_EXT 18
85
86 /*
87 * Changes :
88 *
89 * V2 to V3
90 * --------
91 * Alan Cox start some incompatibles changes. I've integrated a bit more.
92 * - Encryption renamed to Encode to avoid US regulation problems
93 * - Frequency changed from float to struct to avoid problems on old 386
94 *
95 * V3 to V4
96 * --------
97 * - Add sensitivity
98 *
99 * V4 to V5
100 * --------
101 * - Missing encoding definitions in range
102 * - Access points stuff
103 *
104 * V5 to V6
105 * --------
106 * - 802.11 support (ESSID ioctls)
107 *
108 * V6 to V7
109 * --------
110 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
111 *
112 * V7 to V8
113 * --------
114 * - Changed my e-mail address
115 * - More 802.11 support (nickname, rate, rts, frag)
116 * - List index in frequencies
117 *
118 * V8 to V9
119 * --------
120 * - Support for 'mode of operation' (ad-hoc, managed...)
121 * - Support for unicast and multicast power saving
122 * - Change encoding to support larger tokens (>64 bits)
123 * - Updated iw_params (disable, flags) and use it for NWID
124 * - Extracted iw_point from iwreq for clarity
125 *
126 * V9 to V10
127 * ---------
128 * - Add PM capability to range structure
129 * - Add PM modifier : MAX/MIN/RELATIVE
130 * - Add encoding option : IW_ENCODE_NOKEY
131 * - Add TxPower ioctls (work like TxRate)
132 *
133 * V10 to V11
134 * ----------
135 * - Add WE version in range (help backward/forward compatibility)
136 * - Add retry ioctls (work like PM)
137 *
138 * V11 to V12
139 * ----------
140 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
141 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
142 * - Add new statistics (frag, retry, beacon)
143 * - Add average quality (for user space calibration)
144 *
145 * V12 to V13
146 * ----------
147 * - Document creation of new driver API.
148 * - Extract union iwreq_data from struct iwreq (for new driver API).
149 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
150 *
151 * V13 to V14
152 * ----------
153 * - Wireless Events support : define struct iw_event
154 * - Define additional specific event numbers
155 * - Add "addr" and "param" fields in union iwreq_data
156 * - AP scanning stuff (SIOCSIWSCAN and friends)
157 *
158 * V14 to V15
159 * ----------
160 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
161 * - Make struct iw_freq signed (both m & e), add explicit padding
162 * - Add IWEVCUSTOM for driver specific event/scanning token
163 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
164 * - Add IW_TXPOW_RANGE for range of Tx Powers
165 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
166 * - Add IW_MODE_MONITOR for passive monitor
167 *
168 * V15 to V16
169 * ----------
170 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
171 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
172 * - Reshuffle struct iw_range for increases, add filler
173 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
174 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
175 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
176 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
177 *
178 * V16 to V17
179 * ----------
180 * - Add flags to frequency -> auto/fixed
181 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
182 * - Wireless Event capability in struct iw_range
183 * - Add support for relative TxPower (yick !)
184 *
185 * V17 to V18 (From Jouni Malinen <[email protected]>)
186 * ----------
187 * - Add support for WPA/WPA2
188 * - Add extended encoding configuration (SIOCSIWENCODEEXT and
189 * SIOCGIWENCODEEXT)
190 * - Add SIOCSIWGENIE/SIOCGIWGENIE
191 * - Add SIOCSIWMLME
192 * - Add SIOCSIWPMKSA
193 * - Add struct iw_range bit field for supported encoding capabilities
194 * - Add optional scan request parameters for SIOCSIWSCAN
195 * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
196 * related parameters (extensible up to 4096 parameter values)
197 * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
198 * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
199 */
200
201 /**************************** CONSTANTS ****************************/
202
203 /* -------------------------- IOCTL LIST -------------------------- */
204
205 /* Wireless Identification */
206 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
207 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
208 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
209 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
210 * Don't put the name of your driver there, it's useless. */
211
212 /* Basic operations */
213 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
214 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
215 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
216 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
217 #define SIOCSIWMODE 0x8B06 /* set operation mode */
218 #define SIOCGIWMODE 0x8B07 /* get operation mode */
219 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
220 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
221
222 /* Informative stuff */
223 #define SIOCSIWRANGE 0x8B0A /* Unused */
224 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
225 #define SIOCSIWPRIV 0x8B0C /* Unused */
226 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
227 #define SIOCSIWSTATS 0x8B0E /* Unused */
228 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
229 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
230 * is never passed to the driver (i.e. the driver will never see it). */
231
232 /* Spy support (statistics per MAC address - used for Mobile IP support) */
233 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
234 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
235 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
236 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
237
238 /* Access Point manipulation */
239 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
240 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
241 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
242 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
243 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
244
245 /* 802.11 specific support */
246 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
247 #define SIOCGIWESSID 0x8B1B /* get ESSID */
248 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
249 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
250 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
251 * within the 'iwreq' structure, so we need to use the 'data' member to
252 * point to a string in user space, like it is done for RANGE... */
253
254 /* Other parameters useful in 802.11 and some other devices */
255 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
256 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
257 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
258 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
259 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
260 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
261 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
262 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
263 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
264 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
265
266 /* Encoding stuff (scrambling, hardware security, WEP...) */
267 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
268 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
269 /* Power saving stuff (power management, unicast and multicast) */
270 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
271 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
272
273 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
274 * This ioctl uses struct iw_point and data buffer that includes IE id and len
275 * fields. More than one IE may be included in the request. Setting the generic
276 * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
277 * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
278 * are required to report the used IE as a wireless event, e.g., when
279 * associating with an AP. */
280 #define SIOCSIWGENIE 0x8B30 /* set generic IE */
281 #define SIOCGIWGENIE 0x8B31 /* get generic IE */
282
283 /* WPA : IEEE 802.11 MLME requests */
284 #define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
285 * struct iw_mlme */
286 /* WPA : Authentication mode parameters */
287 #define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
288 #define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
289
290 /* WPA : Extended version of encoding configuration */
291 #define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
292 #define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
293
294 /* WPA2 : PMKSA cache management */
295 #define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
296
297 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
298
299 /* These 32 ioctl are wireless device private, for 16 commands.
300 * Each driver is free to use them for whatever purpose it chooses,
301 * however the driver *must* export the description of those ioctls
302 * with SIOCGIWPRIV and *must* use arguments as defined below.
303 * If you don't follow those rules, DaveM is going to hate you (reason :
304 * it make mixed 32/64bit operation impossible).
305 */
306 #define SIOCIWFIRSTPRIV 0x8BE0
307 #define SIOCIWLASTPRIV 0x8BFF
308 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
309 * separate range because of collisions with other tools such as
310 * 'mii-tool'.
311 * We now have 32 commands, so a bit more space ;-).
312 * Also, all 'odd' commands are only usable by root and don't return the
313 * content of ifr/iwr to user (but you are not obliged to use the set/get
314 * convention, just use every other two command). More details in iwpriv.c.
315 * And I repeat : you are not forced to use them with iwpriv, but you
316 * must be compliant with it.
317 */
318
319 /* ------------------------- IOCTL STUFF ------------------------- */
320
321 /* The first and the last (range) */
322 #define SIOCIWFIRST 0x8B00
323 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
324
325 /* Even : get (world access), odd : set (root access) */
326 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
327 #define IW_IS_GET(cmd) ((cmd) & 0x1)
328
329 /* ----------------------- WIRELESS EVENTS ----------------------- */
330 /* Those are *NOT* ioctls, do not issue request on them !!! */
331 /* Most events use the same identifier as ioctl requests */
332
333 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
334 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
335 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
336 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
337 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
338 #define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
339 * (scan results); This includes id and
340 * length fields. One IWEVGENIE may
341 * contain more than one IE. Scan
342 * results may contain one or more
343 * IWEVGENIE events. */
344 #define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
345 * (struct iw_michaelmicfailure)
346 */
347 #define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
348 * The data includes id and length
349 * fields and may contain more than one
350 * IE. This event is required in
351 * Managed mode if the driver
352 * generates its own WPA/RSN IE. This
353 * should be sent just before
354 * IWEVREGISTERED event for the
355 * association. */
356 #define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
357 * Response. The data includes id and
358 * length fields and may contain more
359 * than one IE. This may be sent
360 * between IWEVASSOCREQIE and
361 * IWEVREGISTERED events for the
362 * association. */
363 #define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
364 * pre-authentication
365 * (struct iw_pmkid_cand) */
366
367 #define IWEVFIRST 0x8C00
368
369 /* ------------------------- PRIVATE INFO ------------------------- */
370 /*
371 * The following is used with SIOCGIWPRIV. It allow a driver to define
372 * the interface (name, type of data) for its private ioctl.
373 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
374 */
375
376 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
377 #define IW_PRIV_TYPE_NONE 0x0000
378 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
379 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
380 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
381 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
382 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
383
384 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
385
386 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
387
388 /*
389 * Note : if the number of args is fixed and the size < 16 octets,
390 * instead of passing a pointer we will put args in the iwreq struct...
391 */
392
393 /* ----------------------- OTHER CONSTANTS ----------------------- */
394
395 /* Maximum frequencies in the range struct */
396 #define IW_MAX_FREQUENCIES 32
397 /* Note : if you have something like 80 frequencies,
398 * don't increase this constant and don't fill the frequency list.
399 * The user will be able to set by channel anyway... */
400
401 /* Maximum bit rates in the range struct */
402 #define IW_MAX_BITRATES 32
403
404 /* Maximum tx powers in the range struct */
405 #define IW_MAX_TXPOWER 8
406 /* Note : if you more than 8 TXPowers, just set the max and min or
407 * a few of them in the struct iw_range. */
408
409 /* Maximum of address that you may set with SPY */
410 #define IW_MAX_SPY 8
411
412 /* Maximum of address that you may get in the
413 list of access points in range */
414 #define IW_MAX_AP 64
415
416 /* Maximum size of the ESSID and NICKN strings */
417 #define IW_ESSID_MAX_SIZE 32
418
419 /* Modes of operation */
420 #define IW_MODE_AUTO 0 /* Let the driver decides */
421 #define IW_MODE_ADHOC 1 /* Single cell network */
422 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
423 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
424 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
425 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
426 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
427
428 /* Statistics flags (bitmask in updated) */
429 #define IW_QUAL_QUAL_UPDATED 0x1 /* Value was updated since last read */
430 #define IW_QUAL_LEVEL_UPDATED 0x2
431 #define IW_QUAL_NOISE_UPDATED 0x4
432 #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
433 #define IW_QUAL_LEVEL_INVALID 0x20
434 #define IW_QUAL_NOISE_INVALID 0x40
435
436 /* Frequency flags */
437 #define IW_FREQ_AUTO 0x00 /* Let the driver decides */
438 #define IW_FREQ_FIXED 0x01 /* Force a specific value */
439
440 /* Maximum number of size of encoding token available
441 * they are listed in the range structure */
442 #define IW_MAX_ENCODING_SIZES 8
443
444 /* Maximum size of the encoding token in bytes */
445 #define IW_ENCODING_TOKEN_MAX 32 /* 256 bits (for now) */
446
447 /* Flags for encoding (along with the token) */
448 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
449 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
450 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
451 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
452 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
453 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
454 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
455 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
456 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
457
458 /* Power management flags available (along with the value, if any) */
459 #define IW_POWER_ON 0x0000 /* No details... */
460 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
461 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
462 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
463 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
464 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
465 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
466 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
467 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
468 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
469 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
470 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
471 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
472 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
473
474 /* Transmit Power flags available */
475 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
476 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
477 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
478 #define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
479 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
480
481 /* Retry limits and lifetime flags available */
482 #define IW_RETRY_ON 0x0000 /* No details... */
483 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
484 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
485 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
486 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
487 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
488 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
489 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
490
491 /* Scanning request flags */
492 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
493 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
494 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
495 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
496 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
497 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
498 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
499 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
500 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
501 /* struct iw_scan_req scan_type */
502 #define IW_SCAN_TYPE_ACTIVE 0
503 #define IW_SCAN_TYPE_PASSIVE 1
504 /* Maximum size of returned data */
505 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
506
507 /* Max number of char in custom event - use multiple of them if needed */
508 #define IW_CUSTOM_MAX 256 /* In bytes */
509
510 /* Generic information element */
511 #define IW_GENERIC_IE_MAX 1024
512
513 /* MLME requests (SIOCSIWMLME / struct iw_mlme) */
514 #define IW_MLME_DEAUTH 0
515 #define IW_MLME_DISASSOC 1
516
517 /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
518 #define IW_AUTH_INDEX 0x0FFF
519 #define IW_AUTH_FLAGS 0xF000
520 /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
521 * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
522 * parameter that is being set/get to; value will be read/written to
523 * struct iw_param value field) */
524 #define IW_AUTH_WPA_VERSION 0
525 #define IW_AUTH_CIPHER_PAIRWISE 1
526 #define IW_AUTH_CIPHER_GROUP 2
527 #define IW_AUTH_KEY_MGMT 3
528 #define IW_AUTH_TKIP_COUNTERMEASURES 4
529 #define IW_AUTH_DROP_UNENCRYPTED 5
530 #define IW_AUTH_80211_AUTH_ALG 6
531 #define IW_AUTH_WPA_ENABLED 7
532 #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
533 #define IW_AUTH_ROAMING_CONTROL 9
534 #define IW_AUTH_PRIVACY_INVOKED 10
535
536 /* IW_AUTH_WPA_VERSION values (bit field) */
537 #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
538 #define IW_AUTH_WPA_VERSION_WPA 0x00000002
539 #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
540
541 /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
542 #define IW_AUTH_CIPHER_NONE 0x00000001
543 #define IW_AUTH_CIPHER_WEP40 0x00000002
544 #define IW_AUTH_CIPHER_TKIP 0x00000004
545 #define IW_AUTH_CIPHER_CCMP 0x00000008
546 #define IW_AUTH_CIPHER_WEP104 0x00000010
547
548 /* IW_AUTH_KEY_MGMT values (bit field) */
549 #define IW_AUTH_KEY_MGMT_802_1X 1
550 #define IW_AUTH_KEY_MGMT_PSK 2
551
552 /* IW_AUTH_80211_AUTH_ALG values (bit field) */
553 #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
554 #define IW_AUTH_ALG_SHARED_KEY 0x00000002
555 #define IW_AUTH_ALG_LEAP 0x00000004
556
557 /* IW_AUTH_ROAMING_CONTROL values */
558 #define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
559 #define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
560 * control */
561
562 /* SIOCSIWENCODEEXT definitions */
563 #define IW_ENCODE_SEQ_MAX_SIZE 8
564 /* struct iw_encode_ext ->alg */
565 #define IW_ENCODE_ALG_NONE 0
566 #define IW_ENCODE_ALG_WEP 1
567 #define IW_ENCODE_ALG_TKIP 2
568 #define IW_ENCODE_ALG_CCMP 3
569 /* struct iw_encode_ext ->ext_flags */
570 #define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
571 #define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
572 #define IW_ENCODE_EXT_GROUP_KEY 0x00000004
573 #define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
574
575 /* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
576 #define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
577 #define IW_MICFAILURE_GROUP 0x00000004
578 #define IW_MICFAILURE_PAIRWISE 0x00000008
579 #define IW_MICFAILURE_STAKEY 0x00000010
580 #define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
581 */
582
583 /* Bit field values for enc_capa in struct iw_range */
584 #define IW_ENC_CAPA_WPA 0x00000001
585 #define IW_ENC_CAPA_WPA2 0x00000002
586 #define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
587 #define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
588
589 /* Event capability macros - in (struct iw_range *)->event_capa
590 * Because we have more than 32 possible events, we use an array of
591 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
592 #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
593 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
594 (cmd - SIOCSIWCOMMIT))
595 #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
596 #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
597 /* Event capability constants - event autogenerated by the kernel
598 * This list is valid for most 802.11 devices, customise as needed... */
599 #define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
600 IW_EVENT_CAPA_MASK(0x8B06) | \
601 IW_EVENT_CAPA_MASK(0x8B1A))
602 #define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
603 /* "Easy" macro to set events in iw_range (less efficient) */
604 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
605 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
606
607
608 /****************************** TYPES ******************************/
609
610 /* --------------------------- SUBTYPES --------------------------- */
611 /*
612 * Generic format for most parameters that fit in an int
613 */
614 struct iw_param
615 {
616 __s32 value; /* The value of the parameter itself */
617 __u8 fixed; /* Hardware should not use auto select */
618 __u8 disabled; /* Disable the feature */
619 __u16 flags; /* Various specifc flags (if any) */
620 };
621
622 /*
623 * For all data larger than 16 octets, we need to use a
624 * pointer to memory allocated in user space.
625 */
626 struct iw_point
627 {
628 void __user *pointer; /* Pointer to the data (in user space) */
629 __u16 length; /* number of fields or size in bytes */
630 __u16 flags; /* Optional params */
631 };
632
633 /*
634 * A frequency
635 * For numbers lower than 10^9, we encode the number in 'm' and
636 * set 'e' to 0
637 * For number greater than 10^9, we divide it by the lowest power
638 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
639 * The power of 10 is in 'e', the result of the division is in 'm'.
640 */
641 struct iw_freq
642 {
643 __s32 m; /* Mantissa */
644 __s16 e; /* Exponent */
645 __u8 i; /* List index (when in range struct) */
646 __u8 flags; /* Flags (fixed/auto) */
647 };
648
649 /*
650 * Quality of the link
651 */
652 struct iw_quality
653 {
654 __u8 qual; /* link quality (%retries, SNR,
655 %missed beacons or better...) */
656 __u8 level; /* signal level (dBm) */
657 __u8 noise; /* noise level (dBm) */
658 __u8 updated; /* Flags to know if updated */
659 };
660
661 /*
662 * Packet discarded in the wireless adapter due to
663 * "wireless" specific problems...
664 * Note : the list of counter and statistics in net_device_stats
665 * is already pretty exhaustive, and you should use that first.
666 * This is only additional stats...
667 */
668 struct iw_discarded
669 {
670 __u32 nwid; /* Rx : Wrong nwid/essid */
671 __u32 code; /* Rx : Unable to code/decode (WEP) */
672 __u32 fragment; /* Rx : Can't perform MAC reassembly */
673 __u32 retries; /* Tx : Max MAC retries num reached */
674 __u32 misc; /* Others cases */
675 };
676
677 /*
678 * Packet/Time period missed in the wireless adapter due to
679 * "wireless" specific problems...
680 */
681 struct iw_missed
682 {
683 __u32 beacon; /* Missed beacons/superframe */
684 };
685
686 /*
687 * Quality range (for spy threshold)
688 */
689 struct iw_thrspy
690 {
691 struct sockaddr addr; /* Source address (hw/mac) */
692 struct iw_quality qual; /* Quality of the link */
693 struct iw_quality low; /* Low threshold */
694 struct iw_quality high; /* High threshold */
695 };
696
697 /*
698 * Optional data for scan request
699 *
700 * Note: these optional parameters are controlling parameters for the
701 * scanning behavior, these do not apply to getting scan results
702 * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
703 * provide a merged results with all BSSes even if the previous scan
704 * request limited scanning to a subset, e.g., by specifying an SSID.
705 * Especially, scan results are required to include an entry for the
706 * current BSS if the driver is in Managed mode and associated with an AP.
707 */
708 struct iw_scan_req
709 {
710 __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
711 __u8 essid_len;
712 __u8 num_channels; /* num entries in channel_list;
713 * 0 = scan all allowed channels */
714 __u8 flags; /* reserved as padding; use zero, this may
715 * be used in the future for adding flags
716 * to request different scan behavior */
717 struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
718 * individual address of a specific BSS */
719
720 /*
721 * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
722 * the current ESSID. This allows scan requests for specific ESSID
723 * without having to change the current ESSID and potentially breaking
724 * the current association.
725 */
726 __u8 essid[IW_ESSID_MAX_SIZE];
727
728 /*
729 * Optional parameters for changing the default scanning behavior.
730 * These are based on the MLME-SCAN.request from IEEE Std 802.11.
731 * TU is 1.024 ms. If these are set to 0, driver is expected to use
732 * reasonable default values. min_channel_time defines the time that
733 * will be used to wait for the first reply on each channel. If no
734 * replies are received, next channel will be scanned after this. If
735 * replies are received, total time waited on the channel is defined by
736 * max_channel_time.
737 */
738 __u32 min_channel_time; /* in TU */
739 __u32 max_channel_time; /* in TU */
740
741 struct iw_freq channel_list[IW_MAX_FREQUENCIES];
742 };
743
744 /* ------------------------- WPA SUPPORT ------------------------- */
745
746 /*
747 * Extended data structure for get/set encoding (this is used with
748 * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
749 * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
750 * only the data contents changes (key data -> this structure, including
751 * key data).
752 *
753 * If the new key is the first group key, it will be set as the default
754 * TX key. Otherwise, default TX key index is only changed if
755 * IW_ENCODE_EXT_SET_TX_KEY flag is set.
756 *
757 * Key will be changed with SIOCSIWENCODEEXT in all cases except for
758 * special "change TX key index" operation which is indicated by setting
759 * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
760 *
761 * tx_seq/rx_seq are only used when respective
762 * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
763 * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
764 * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
765 * used only by an Authenticator (AP or an IBSS station) to get the
766 * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
767 * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
768 * debugging/testing.
769 */
770 struct iw_encode_ext
771 {
772 __u32 ext_flags; /* IW_ENCODE_EXT_* */
773 __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
774 __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
775 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
776 * (group) keys or unicast address for
777 * individual keys */
778 __u16 alg; /* IW_ENCODE_ALG_* */
779 __u16 key_len;
780 __u8 key[0];
781 };
782
783 /* SIOCSIWMLME data */
784 struct iw_mlme
785 {
786 __u16 cmd; /* IW_MLME_* */
787 __u16 reason_code;
788 struct sockaddr addr;
789 };
790
791 /* SIOCSIWPMKSA data */
792 #define IW_PMKSA_ADD 1
793 #define IW_PMKSA_REMOVE 2
794 #define IW_PMKSA_FLUSH 3
795
796 #define IW_PMKID_LEN 16
797
798 struct iw_pmksa
799 {
800 __u32 cmd; /* IW_PMKSA_* */
801 struct sockaddr bssid;
802 __u8 pmkid[IW_PMKID_LEN];
803 };
804
805 /* IWEVMICHAELMICFAILURE data */
806 struct iw_michaelmicfailure
807 {
808 __u32 flags;
809 struct sockaddr src_addr;
810 __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
811 };
812
813 /* IWEVPMKIDCAND data */
814 #define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
815 struct iw_pmkid_cand
816 {
817 __u32 flags; /* IW_PMKID_CAND_* */
818 __u32 index; /* the smaller the index, the higher the
819 * priority */
820 struct sockaddr bssid;
821 };
822
823 /* ------------------------ WIRELESS STATS ------------------------ */
824 /*
825 * Wireless statistics (used for /proc/net/wireless)
826 */
827 struct iw_statistics
828 {
829 __u16 status; /* Status
830 * - device dependent for now */
831
832 struct iw_quality qual; /* Quality of the link
833 * (instant/mean/max) */
834 struct iw_discarded discard; /* Packet discarded counts */
835 struct iw_missed miss; /* Packet missed counts */
836 };
837
838 /* ------------------------ IOCTL REQUEST ------------------------ */
839 /*
840 * This structure defines the payload of an ioctl, and is used
841 * below.
842 *
843 * Note that this structure should fit on the memory footprint
844 * of iwreq (which is the same as ifreq), which mean a max size of
845 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
846 * You should check this when increasing the structures defined
847 * above in this file...
848 */
849 union iwreq_data
850 {
851 /* Config - generic */
852 char name[IFNAMSIZ];
853 /* Name : used to verify the presence of wireless extensions.
854 * Name of the protocol/provider... */
855
856 struct iw_point essid; /* Extended network name */
857 struct iw_param nwid; /* network id (or domain - the cell) */
858 struct iw_freq freq; /* frequency or channel :
859 * 0-1000 = channel
860 * > 1000 = frequency in Hz */
861
862 struct iw_param sens; /* signal level threshold */
863 struct iw_param bitrate; /* default bit rate */
864 struct iw_param txpower; /* default transmit power */
865 struct iw_param rts; /* RTS threshold threshold */
866 struct iw_param frag; /* Fragmentation threshold */
867 __u32 mode; /* Operation mode */
868 struct iw_param retry; /* Retry limits & lifetime */
869
870 struct iw_point encoding; /* Encoding stuff : tokens */
871 struct iw_param power; /* PM duration/timeout */
872 struct iw_quality qual; /* Quality part of statistics */
873
874 struct sockaddr ap_addr; /* Access point address */
875 struct sockaddr addr; /* Destination address (hw/mac) */
876
877 struct iw_param param; /* Other small parameters */
878 struct iw_point data; /* Other large parameters */
879 };
880
881 /*
882 * The structure to exchange data for ioctl.
883 * This structure is the same as 'struct ifreq', but (re)defined for
884 * convenience...
885 * Do I need to remind you about structure size (32 octets) ?
886 */
887 struct iwreq
888 {
889 union
890 {
891 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
892 } ifr_ifrn;
893
894 /* Data part (defined just above) */
895 union iwreq_data u;
896 };
897
898 /* -------------------------- IOCTL DATA -------------------------- */
899 /*
900 * For those ioctl which want to exchange mode data that what could
901 * fit in the above structure...
902 */
903
904 /*
905 * Range of parameters
906 */
907
908 struct iw_range
909 {
910 /* Informative stuff (to choose between different interface) */
911 __u32 throughput; /* To give an idea... */
912 /* In theory this value should be the maximum benchmarked
913 * TCP/IP throughput, because with most of these devices the
914 * bit rate is meaningless (overhead an co) to estimate how
915 * fast the connection will go and pick the fastest one.
916 * I suggest people to play with Netperf or any benchmark...
917 */
918
919 /* NWID (or domain id) */
920 __u32 min_nwid; /* Minimal NWID we are able to set */
921 __u32 max_nwid; /* Maximal NWID we are able to set */
922
923 /* Old Frequency (backward compat - moved lower ) */
924 __u16 old_num_channels;
925 __u8 old_num_frequency;
926
927 /* Wireless event capability bitmasks */
928 __u32 event_capa[6];
929
930 /* signal level threshold range */
931 __s32 sensitivity;
932
933 /* Quality of link & SNR stuff */
934 /* Quality range (link, level, noise)
935 * If the quality is absolute, it will be in the range [0 ; max_qual],
936 * if the quality is dBm, it will be in the range [max_qual ; 0].
937 * Don't forget that we use 8 bit arithmetics... */
938 struct iw_quality max_qual; /* Quality of the link */
939 /* This should contain the average/typical values of the quality
940 * indicator. This should be the threshold between a "good" and
941 * a "bad" link (example : monitor going from green to orange).
942 * Currently, user space apps like quality monitors don't have any
943 * way to calibrate the measurement. With this, they can split
944 * the range between 0 and max_qual in different quality level
945 * (using a geometric subdivision centered on the average).
946 * I expect that people doing the user space apps will feedback
947 * us on which value we need to put in each driver... */
948 struct iw_quality avg_qual; /* Quality of the link */
949
950 /* Rates */
951 __u8 num_bitrates; /* Number of entries in the list */
952 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
953
954 /* RTS threshold */
955 __s32 min_rts; /* Minimal RTS threshold */
956 __s32 max_rts; /* Maximal RTS threshold */
957
958 /* Frag threshold */
959 __s32 min_frag; /* Minimal frag threshold */
960 __s32 max_frag; /* Maximal frag threshold */
961
962 /* Power Management duration & timeout */
963 __s32 min_pmp; /* Minimal PM period */
964 __s32 max_pmp; /* Maximal PM period */
965 __s32 min_pmt; /* Minimal PM timeout */
966 __s32 max_pmt; /* Maximal PM timeout */
967 __u16 pmp_flags; /* How to decode max/min PM period */
968 __u16 pmt_flags; /* How to decode max/min PM timeout */
969 __u16 pm_capa; /* What PM options are supported */
970
971 /* Encoder stuff */
972 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
973 __u8 num_encoding_sizes; /* Number of entry in the list */
974 __u8 max_encoding_tokens; /* Max number of tokens */
975 /* For drivers that need a "login/passwd" form */
976 __u8 encoding_login_index; /* token index for login token */
977
978 /* Transmit power */
979 __u16 txpower_capa; /* What options are supported */
980 __u8 num_txpower; /* Number of entries in the list */
981 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
982
983 /* Wireless Extension version info */
984 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
985 __u8 we_version_source; /* Last update of source */
986
987 /* Retry limits and lifetime */
988 __u16 retry_capa; /* What retry options are supported */
989 __u16 retry_flags; /* How to decode max/min retry limit */
990 __u16 r_time_flags; /* How to decode max/min retry life */
991 __s32 min_retry; /* Minimal number of retries */
992 __s32 max_retry; /* Maximal number of retries */
993 __s32 min_r_time; /* Minimal retry lifetime */
994 __s32 max_r_time; /* Maximal retry lifetime */
995
996 /* Frequency */
997 __u16 num_channels; /* Number of channels [0; num - 1] */
998 __u8 num_frequency; /* Number of entry in the list */
999 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
1000 /* Note : this frequency list doesn't need to fit channel numbers,
1001 * because each entry contain its channel index */
1002
1003 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1004 };
1005
1006 /*
1007 * Private ioctl interface information
1008 */
1009
1010 struct iw_priv_args
1011 {
1012 __u32 cmd; /* Number of the ioctl to issue */
1013 __u16 set_args; /* Type and number of args */
1014 __u16 get_args; /* Type and number of args */
1015 char name[IFNAMSIZ]; /* Name of the extension */
1016 };
1017
1018 /* ----------------------- WIRELESS EVENTS ----------------------- */
1019 /*
1020 * Wireless events are carried through the rtnetlink socket to user
1021 * space. They are encapsulated in the IFLA_WIRELESS field of
1022 * a RTM_NEWLINK message.
1023 */
1024
1025 /*
1026 * A Wireless Event. Contains basically the same data as the ioctl...
1027 */
1028 struct iw_event
1029 {
1030 __u16 len; /* Real lenght of this stuff */
1031 __u16 cmd; /* Wireless IOCTL */
1032 union iwreq_data u; /* IOCTL fixed payload */
1033 };
1034
1035 /* Size of the Event prefix (including padding and alignement junk) */
1036 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
1037 /* Size of the various events */
1038 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
1039 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
1040 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
1041 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point))
1042 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
1043 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
1044 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
1045
1046 /* Note : in the case of iw_point, the extra data will come at the
1047 * end of the event */
1048
1049 #endif /* _LINUX_WIRELESS_H */
+0
-1069
src/lwe/wireless.19.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 19 18.3.05
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # net/core/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # net/core/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* Do not put any header in this file, this creates a mess when
72 * exported to user space. Most users have included all the
73 * relevant headers anyway... Jean II */
74 /*#include <linux/types.h>*/ /* for "caddr_t" et al */
75 /*#include <linux/socket.h>*/ /* for "struct sockaddr" et al */
76 /*#include <linux/if.h>*/ /* for IFNAMSIZ and co... */
77
78 /***************************** VERSION *****************************/
79 /*
80 * This constant is used to know the availability of the wireless
81 * extensions and to know which version of wireless extensions it is
82 * (there is some stuff that will be added in the future...)
83 * I just plan to increment with each new version.
84 */
85 #define WIRELESS_EXT 19
86
87 /*
88 * Changes :
89 *
90 * V2 to V3
91 * --------
92 * Alan Cox start some incompatibles changes. I've integrated a bit more.
93 * - Encryption renamed to Encode to avoid US regulation problems
94 * - Frequency changed from float to struct to avoid problems on old 386
95 *
96 * V3 to V4
97 * --------
98 * - Add sensitivity
99 *
100 * V4 to V5
101 * --------
102 * - Missing encoding definitions in range
103 * - Access points stuff
104 *
105 * V5 to V6
106 * --------
107 * - 802.11 support (ESSID ioctls)
108 *
109 * V6 to V7
110 * --------
111 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
112 *
113 * V7 to V8
114 * --------
115 * - Changed my e-mail address
116 * - More 802.11 support (nickname, rate, rts, frag)
117 * - List index in frequencies
118 *
119 * V8 to V9
120 * --------
121 * - Support for 'mode of operation' (ad-hoc, managed...)
122 * - Support for unicast and multicast power saving
123 * - Change encoding to support larger tokens (>64 bits)
124 * - Updated iw_params (disable, flags) and use it for NWID
125 * - Extracted iw_point from iwreq for clarity
126 *
127 * V9 to V10
128 * ---------
129 * - Add PM capability to range structure
130 * - Add PM modifier : MAX/MIN/RELATIVE
131 * - Add encoding option : IW_ENCODE_NOKEY
132 * - Add TxPower ioctls (work like TxRate)
133 *
134 * V10 to V11
135 * ----------
136 * - Add WE version in range (help backward/forward compatibility)
137 * - Add retry ioctls (work like PM)
138 *
139 * V11 to V12
140 * ----------
141 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
142 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
143 * - Add new statistics (frag, retry, beacon)
144 * - Add average quality (for user space calibration)
145 *
146 * V12 to V13
147 * ----------
148 * - Document creation of new driver API.
149 * - Extract union iwreq_data from struct iwreq (for new driver API).
150 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
151 *
152 * V13 to V14
153 * ----------
154 * - Wireless Events support : define struct iw_event
155 * - Define additional specific event numbers
156 * - Add "addr" and "param" fields in union iwreq_data
157 * - AP scanning stuff (SIOCSIWSCAN and friends)
158 *
159 * V14 to V15
160 * ----------
161 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
162 * - Make struct iw_freq signed (both m & e), add explicit padding
163 * - Add IWEVCUSTOM for driver specific event/scanning token
164 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
165 * - Add IW_TXPOW_RANGE for range of Tx Powers
166 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
167 * - Add IW_MODE_MONITOR for passive monitor
168 *
169 * V15 to V16
170 * ----------
171 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
172 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
173 * - Reshuffle struct iw_range for increases, add filler
174 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
175 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
176 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
177 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
178 *
179 * V16 to V17
180 * ----------
181 * - Add flags to frequency -> auto/fixed
182 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
183 * - Wireless Event capability in struct iw_range
184 * - Add support for relative TxPower (yick !)
185 *
186 * V17 to V18 (From Jouni Malinen <[email protected]>)
187 * ----------
188 * - Add support for WPA/WPA2
189 * - Add extended encoding configuration (SIOCSIWENCODEEXT and
190 * SIOCGIWENCODEEXT)
191 * - Add SIOCSIWGENIE/SIOCGIWGENIE
192 * - Add SIOCSIWMLME
193 * - Add SIOCSIWPMKSA
194 * - Add struct iw_range bit field for supported encoding capabilities
195 * - Add optional scan request parameters for SIOCSIWSCAN
196 * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
197 * related parameters (extensible up to 4096 parameter values)
198 * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
199 * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
200 *
201 * V18 to V19
202 * ----------
203 * - Remove (struct iw_point *)->pointer from events and streams
204 * - Remove header includes to help user space
205 * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
206 * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
207 * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
208 * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
209 */
210
211 /**************************** CONSTANTS ****************************/
212
213 /* -------------------------- IOCTL LIST -------------------------- */
214
215 /* Wireless Identification */
216 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
217 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
218 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
219 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
220 * Don't put the name of your driver there, it's useless. */
221
222 /* Basic operations */
223 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
224 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
225 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
226 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
227 #define SIOCSIWMODE 0x8B06 /* set operation mode */
228 #define SIOCGIWMODE 0x8B07 /* get operation mode */
229 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
230 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
231
232 /* Informative stuff */
233 #define SIOCSIWRANGE 0x8B0A /* Unused */
234 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
235 #define SIOCSIWPRIV 0x8B0C /* Unused */
236 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
237 #define SIOCSIWSTATS 0x8B0E /* Unused */
238 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
239 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
240 * is never passed to the driver (i.e. the driver will never see it). */
241
242 /* Spy support (statistics per MAC address - used for Mobile IP support) */
243 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
244 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
245 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
246 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
247
248 /* Access Point manipulation */
249 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
250 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
251 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
252 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
253 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
254
255 /* 802.11 specific support */
256 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
257 #define SIOCGIWESSID 0x8B1B /* get ESSID */
258 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
259 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
260 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
261 * within the 'iwreq' structure, so we need to use the 'data' member to
262 * point to a string in user space, like it is done for RANGE... */
263
264 /* Other parameters useful in 802.11 and some other devices */
265 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
266 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
267 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
268 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
269 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
270 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
271 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
272 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
273 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
274 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
275
276 /* Encoding stuff (scrambling, hardware security, WEP...) */
277 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
278 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
279 /* Power saving stuff (power management, unicast and multicast) */
280 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
281 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
282
283 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
284 * This ioctl uses struct iw_point and data buffer that includes IE id and len
285 * fields. More than one IE may be included in the request. Setting the generic
286 * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
287 * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
288 * are required to report the used IE as a wireless event, e.g., when
289 * associating with an AP. */
290 #define SIOCSIWGENIE 0x8B30 /* set generic IE */
291 #define SIOCGIWGENIE 0x8B31 /* get generic IE */
292
293 /* WPA : IEEE 802.11 MLME requests */
294 #define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
295 * struct iw_mlme */
296 /* WPA : Authentication mode parameters */
297 #define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
298 #define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
299
300 /* WPA : Extended version of encoding configuration */
301 #define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
302 #define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
303
304 /* WPA2 : PMKSA cache management */
305 #define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
306
307 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
308
309 /* These 32 ioctl are wireless device private, for 16 commands.
310 * Each driver is free to use them for whatever purpose it chooses,
311 * however the driver *must* export the description of those ioctls
312 * with SIOCGIWPRIV and *must* use arguments as defined below.
313 * If you don't follow those rules, DaveM is going to hate you (reason :
314 * it make mixed 32/64bit operation impossible).
315 */
316 #define SIOCIWFIRSTPRIV 0x8BE0
317 #define SIOCIWLASTPRIV 0x8BFF
318 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
319 * separate range because of collisions with other tools such as
320 * 'mii-tool'.
321 * We now have 32 commands, so a bit more space ;-).
322 * Also, all 'odd' commands are only usable by root and don't return the
323 * content of ifr/iwr to user (but you are not obliged to use the set/get
324 * convention, just use every other two command). More details in iwpriv.c.
325 * And I repeat : you are not forced to use them with iwpriv, but you
326 * must be compliant with it.
327 */
328
329 /* ------------------------- IOCTL STUFF ------------------------- */
330
331 /* The first and the last (range) */
332 #define SIOCIWFIRST 0x8B00
333 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
334 #define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
335
336 /* Even : get (world access), odd : set (root access) */
337 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
338 #define IW_IS_GET(cmd) ((cmd) & 0x1)
339
340 /* ----------------------- WIRELESS EVENTS ----------------------- */
341 /* Those are *NOT* ioctls, do not issue request on them !!! */
342 /* Most events use the same identifier as ioctl requests */
343
344 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
345 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
346 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
347 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
348 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
349 #define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
350 * (scan results); This includes id and
351 * length fields. One IWEVGENIE may
352 * contain more than one IE. Scan
353 * results may contain one or more
354 * IWEVGENIE events. */
355 #define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
356 * (struct iw_michaelmicfailure)
357 */
358 #define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
359 * The data includes id and length
360 * fields and may contain more than one
361 * IE. This event is required in
362 * Managed mode if the driver
363 * generates its own WPA/RSN IE. This
364 * should be sent just before
365 * IWEVREGISTERED event for the
366 * association. */
367 #define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
368 * Response. The data includes id and
369 * length fields and may contain more
370 * than one IE. This may be sent
371 * between IWEVASSOCREQIE and
372 * IWEVREGISTERED events for the
373 * association. */
374 #define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
375 * pre-authentication
376 * (struct iw_pmkid_cand) */
377
378 #define IWEVFIRST 0x8C00
379 #define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
380
381 /* ------------------------- PRIVATE INFO ------------------------- */
382 /*
383 * The following is used with SIOCGIWPRIV. It allow a driver to define
384 * the interface (name, type of data) for its private ioctl.
385 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
386 */
387
388 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
389 #define IW_PRIV_TYPE_NONE 0x0000
390 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
391 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
392 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
393 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
394 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
395
396 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
397
398 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
399
400 /*
401 * Note : if the number of args is fixed and the size < 16 octets,
402 * instead of passing a pointer we will put args in the iwreq struct...
403 */
404
405 /* ----------------------- OTHER CONSTANTS ----------------------- */
406
407 /* Maximum frequencies in the range struct */
408 #define IW_MAX_FREQUENCIES 32
409 /* Note : if you have something like 80 frequencies,
410 * don't increase this constant and don't fill the frequency list.
411 * The user will be able to set by channel anyway... */
412
413 /* Maximum bit rates in the range struct */
414 #define IW_MAX_BITRATES 32
415
416 /* Maximum tx powers in the range struct */
417 #define IW_MAX_TXPOWER 8
418 /* Note : if you more than 8 TXPowers, just set the max and min or
419 * a few of them in the struct iw_range. */
420
421 /* Maximum of address that you may set with SPY */
422 #define IW_MAX_SPY 8
423
424 /* Maximum of address that you may get in the
425 list of access points in range */
426 #define IW_MAX_AP 64
427
428 /* Maximum size of the ESSID and NICKN strings */
429 #define IW_ESSID_MAX_SIZE 32
430
431 /* Modes of operation */
432 #define IW_MODE_AUTO 0 /* Let the driver decides */
433 #define IW_MODE_ADHOC 1 /* Single cell network */
434 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
435 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
436 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
437 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
438 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
439
440 /* Statistics flags (bitmask in updated) */
441 #define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
442 #define IW_QUAL_LEVEL_UPDATED 0x02
443 #define IW_QUAL_NOISE_UPDATED 0x04
444 #define IW_QUAL_ALL_UPDATED 0x07
445 #define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
446 #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
447 #define IW_QUAL_LEVEL_INVALID 0x20
448 #define IW_QUAL_NOISE_INVALID 0x40
449 #define IW_QUAL_ALL_INVALID 0x70
450
451 /* Frequency flags */
452 #define IW_FREQ_AUTO 0x00 /* Let the driver decides */
453 #define IW_FREQ_FIXED 0x01 /* Force a specific value */
454
455 /* Maximum number of size of encoding token available
456 * they are listed in the range structure */
457 #define IW_MAX_ENCODING_SIZES 8
458
459 /* Maximum size of the encoding token in bytes */
460 #define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
461
462 /* Flags for encoding (along with the token) */
463 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
464 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
465 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
466 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
467 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
468 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
469 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
470 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
471 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
472
473 /* Power management flags available (along with the value, if any) */
474 #define IW_POWER_ON 0x0000 /* No details... */
475 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
476 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
477 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
478 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
479 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
480 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
481 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
482 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
483 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
484 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
485 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
486 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
487 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
488
489 /* Transmit Power flags available */
490 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
491 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
492 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
493 #define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
494 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
495
496 /* Retry limits and lifetime flags available */
497 #define IW_RETRY_ON 0x0000 /* No details... */
498 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
499 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
500 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
501 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
502 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
503 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
504 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
505
506 /* Scanning request flags */
507 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
508 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
509 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
510 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
511 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
512 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
513 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
514 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
515 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
516 /* struct iw_scan_req scan_type */
517 #define IW_SCAN_TYPE_ACTIVE 0
518 #define IW_SCAN_TYPE_PASSIVE 1
519 /* Maximum size of returned data */
520 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
521
522 /* Max number of char in custom event - use multiple of them if needed */
523 #define IW_CUSTOM_MAX 256 /* In bytes */
524
525 /* Generic information element */
526 #define IW_GENERIC_IE_MAX 1024
527
528 /* MLME requests (SIOCSIWMLME / struct iw_mlme) */
529 #define IW_MLME_DEAUTH 0
530 #define IW_MLME_DISASSOC 1
531
532 /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
533 #define IW_AUTH_INDEX 0x0FFF
534 #define IW_AUTH_FLAGS 0xF000
535 /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
536 * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
537 * parameter that is being set/get to; value will be read/written to
538 * struct iw_param value field) */
539 #define IW_AUTH_WPA_VERSION 0
540 #define IW_AUTH_CIPHER_PAIRWISE 1
541 #define IW_AUTH_CIPHER_GROUP 2
542 #define IW_AUTH_KEY_MGMT 3
543 #define IW_AUTH_TKIP_COUNTERMEASURES 4
544 #define IW_AUTH_DROP_UNENCRYPTED 5
545 #define IW_AUTH_80211_AUTH_ALG 6
546 #define IW_AUTH_WPA_ENABLED 7
547 #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
548 #define IW_AUTH_ROAMING_CONTROL 9
549 #define IW_AUTH_PRIVACY_INVOKED 10
550
551 /* IW_AUTH_WPA_VERSION values (bit field) */
552 #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
553 #define IW_AUTH_WPA_VERSION_WPA 0x00000002
554 #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
555
556 /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
557 #define IW_AUTH_CIPHER_NONE 0x00000001
558 #define IW_AUTH_CIPHER_WEP40 0x00000002
559 #define IW_AUTH_CIPHER_TKIP 0x00000004
560 #define IW_AUTH_CIPHER_CCMP 0x00000008
561 #define IW_AUTH_CIPHER_WEP104 0x00000010
562
563 /* IW_AUTH_KEY_MGMT values (bit field) */
564 #define IW_AUTH_KEY_MGMT_802_1X 1
565 #define IW_AUTH_KEY_MGMT_PSK 2
566
567 /* IW_AUTH_80211_AUTH_ALG values (bit field) */
568 #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
569 #define IW_AUTH_ALG_SHARED_KEY 0x00000002
570 #define IW_AUTH_ALG_LEAP 0x00000004
571
572 /* IW_AUTH_ROAMING_CONTROL values */
573 #define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
574 #define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
575 * control */
576
577 /* SIOCSIWENCODEEXT definitions */
578 #define IW_ENCODE_SEQ_MAX_SIZE 8
579 /* struct iw_encode_ext ->alg */
580 #define IW_ENCODE_ALG_NONE 0
581 #define IW_ENCODE_ALG_WEP 1
582 #define IW_ENCODE_ALG_TKIP 2
583 #define IW_ENCODE_ALG_CCMP 3
584 /* struct iw_encode_ext ->ext_flags */
585 #define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
586 #define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
587 #define IW_ENCODE_EXT_GROUP_KEY 0x00000004
588 #define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
589
590 /* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
591 #define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
592 #define IW_MICFAILURE_GROUP 0x00000004
593 #define IW_MICFAILURE_PAIRWISE 0x00000008
594 #define IW_MICFAILURE_STAKEY 0x00000010
595 #define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
596 */
597
598 /* Bit field values for enc_capa in struct iw_range */
599 #define IW_ENC_CAPA_WPA 0x00000001
600 #define IW_ENC_CAPA_WPA2 0x00000002
601 #define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
602 #define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
603
604 /* Event capability macros - in (struct iw_range *)->event_capa
605 * Because we have more than 32 possible events, we use an array of
606 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
607 #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
608 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
609 (cmd - SIOCSIWCOMMIT))
610 #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
611 #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
612 /* Event capability constants - event autogenerated by the kernel
613 * This list is valid for most 802.11 devices, customise as needed... */
614 #define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
615 IW_EVENT_CAPA_MASK(0x8B06) | \
616 IW_EVENT_CAPA_MASK(0x8B1A))
617 #define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
618 /* "Easy" macro to set events in iw_range (less efficient) */
619 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
620 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
621
622
623 /****************************** TYPES ******************************/
624
625 /* --------------------------- SUBTYPES --------------------------- */
626 /*
627 * Generic format for most parameters that fit in an int
628 */
629 struct iw_param
630 {
631 __s32 value; /* The value of the parameter itself */
632 __u8 fixed; /* Hardware should not use auto select */
633 __u8 disabled; /* Disable the feature */
634 __u16 flags; /* Various specifc flags (if any) */
635 };
636
637 /*
638 * For all data larger than 16 octets, we need to use a
639 * pointer to memory allocated in user space.
640 */
641 struct iw_point
642 {
643 void __user *pointer; /* Pointer to the data (in user space) */
644 __u16 length; /* number of fields or size in bytes */
645 __u16 flags; /* Optional params */
646 };
647
648 /*
649 * A frequency
650 * For numbers lower than 10^9, we encode the number in 'm' and
651 * set 'e' to 0
652 * For number greater than 10^9, we divide it by the lowest power
653 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
654 * The power of 10 is in 'e', the result of the division is in 'm'.
655 */
656 struct iw_freq
657 {
658 __s32 m; /* Mantissa */
659 __s16 e; /* Exponent */
660 __u8 i; /* List index (when in range struct) */
661 __u8 flags; /* Flags (fixed/auto) */
662 };
663
664 /*
665 * Quality of the link
666 */
667 struct iw_quality
668 {
669 __u8 qual; /* link quality (%retries, SNR,
670 %missed beacons or better...) */
671 __u8 level; /* signal level (dBm) */
672 __u8 noise; /* noise level (dBm) */
673 __u8 updated; /* Flags to know if updated */
674 };
675
676 /*
677 * Packet discarded in the wireless adapter due to
678 * "wireless" specific problems...
679 * Note : the list of counter and statistics in net_device_stats
680 * is already pretty exhaustive, and you should use that first.
681 * This is only additional stats...
682 */
683 struct iw_discarded
684 {
685 __u32 nwid; /* Rx : Wrong nwid/essid */
686 __u32 code; /* Rx : Unable to code/decode (WEP) */
687 __u32 fragment; /* Rx : Can't perform MAC reassembly */
688 __u32 retries; /* Tx : Max MAC retries num reached */
689 __u32 misc; /* Others cases */
690 };
691
692 /*
693 * Packet/Time period missed in the wireless adapter due to
694 * "wireless" specific problems...
695 */
696 struct iw_missed
697 {
698 __u32 beacon; /* Missed beacons/superframe */
699 };
700
701 /*
702 * Quality range (for spy threshold)
703 */
704 struct iw_thrspy
705 {
706 struct sockaddr addr; /* Source address (hw/mac) */
707 struct iw_quality qual; /* Quality of the link */
708 struct iw_quality low; /* Low threshold */
709 struct iw_quality high; /* High threshold */
710 };
711
712 /*
713 * Optional data for scan request
714 *
715 * Note: these optional parameters are controlling parameters for the
716 * scanning behavior, these do not apply to getting scan results
717 * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
718 * provide a merged results with all BSSes even if the previous scan
719 * request limited scanning to a subset, e.g., by specifying an SSID.
720 * Especially, scan results are required to include an entry for the
721 * current BSS if the driver is in Managed mode and associated with an AP.
722 */
723 struct iw_scan_req
724 {
725 __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
726 __u8 essid_len;
727 __u8 num_channels; /* num entries in channel_list;
728 * 0 = scan all allowed channels */
729 __u8 flags; /* reserved as padding; use zero, this may
730 * be used in the future for adding flags
731 * to request different scan behavior */
732 struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
733 * individual address of a specific BSS */
734
735 /*
736 * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
737 * the current ESSID. This allows scan requests for specific ESSID
738 * without having to change the current ESSID and potentially breaking
739 * the current association.
740 */
741 __u8 essid[IW_ESSID_MAX_SIZE];
742
743 /*
744 * Optional parameters for changing the default scanning behavior.
745 * These are based on the MLME-SCAN.request from IEEE Std 802.11.
746 * TU is 1.024 ms. If these are set to 0, driver is expected to use
747 * reasonable default values. min_channel_time defines the time that
748 * will be used to wait for the first reply on each channel. If no
749 * replies are received, next channel will be scanned after this. If
750 * replies are received, total time waited on the channel is defined by
751 * max_channel_time.
752 */
753 __u32 min_channel_time; /* in TU */
754 __u32 max_channel_time; /* in TU */
755
756 struct iw_freq channel_list[IW_MAX_FREQUENCIES];
757 };
758
759 /* ------------------------- WPA SUPPORT ------------------------- */
760
761 /*
762 * Extended data structure for get/set encoding (this is used with
763 * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
764 * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
765 * only the data contents changes (key data -> this structure, including
766 * key data).
767 *
768 * If the new key is the first group key, it will be set as the default
769 * TX key. Otherwise, default TX key index is only changed if
770 * IW_ENCODE_EXT_SET_TX_KEY flag is set.
771 *
772 * Key will be changed with SIOCSIWENCODEEXT in all cases except for
773 * special "change TX key index" operation which is indicated by setting
774 * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
775 *
776 * tx_seq/rx_seq are only used when respective
777 * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
778 * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
779 * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
780 * used only by an Authenticator (AP or an IBSS station) to get the
781 * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
782 * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
783 * debugging/testing.
784 */
785 struct iw_encode_ext
786 {
787 __u32 ext_flags; /* IW_ENCODE_EXT_* */
788 __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
789 __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
790 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
791 * (group) keys or unicast address for
792 * individual keys */
793 __u16 alg; /* IW_ENCODE_ALG_* */
794 __u16 key_len;
795 __u8 key[0];
796 };
797
798 /* SIOCSIWMLME data */
799 struct iw_mlme
800 {
801 __u16 cmd; /* IW_MLME_* */
802 __u16 reason_code;
803 struct sockaddr addr;
804 };
805
806 /* SIOCSIWPMKSA data */
807 #define IW_PMKSA_ADD 1
808 #define IW_PMKSA_REMOVE 2
809 #define IW_PMKSA_FLUSH 3
810
811 #define IW_PMKID_LEN 16
812
813 struct iw_pmksa
814 {
815 __u32 cmd; /* IW_PMKSA_* */
816 struct sockaddr bssid;
817 __u8 pmkid[IW_PMKID_LEN];
818 };
819
820 /* IWEVMICHAELMICFAILURE data */
821 struct iw_michaelmicfailure
822 {
823 __u32 flags;
824 struct sockaddr src_addr;
825 __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
826 };
827
828 /* IWEVPMKIDCAND data */
829 #define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
830 struct iw_pmkid_cand
831 {
832 __u32 flags; /* IW_PMKID_CAND_* */
833 __u32 index; /* the smaller the index, the higher the
834 * priority */
835 struct sockaddr bssid;
836 };
837
838 /* ------------------------ WIRELESS STATS ------------------------ */
839 /*
840 * Wireless statistics (used for /proc/net/wireless)
841 */
842 struct iw_statistics
843 {
844 __u16 status; /* Status
845 * - device dependent for now */
846
847 struct iw_quality qual; /* Quality of the link
848 * (instant/mean/max) */
849 struct iw_discarded discard; /* Packet discarded counts */
850 struct iw_missed miss; /* Packet missed counts */
851 };
852
853 /* ------------------------ IOCTL REQUEST ------------------------ */
854 /*
855 * This structure defines the payload of an ioctl, and is used
856 * below.
857 *
858 * Note that this structure should fit on the memory footprint
859 * of iwreq (which is the same as ifreq), which mean a max size of
860 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
861 * You should check this when increasing the structures defined
862 * above in this file...
863 */
864 union iwreq_data
865 {
866 /* Config - generic */
867 char name[IFNAMSIZ];
868 /* Name : used to verify the presence of wireless extensions.
869 * Name of the protocol/provider... */
870
871 struct iw_point essid; /* Extended network name */
872 struct iw_param nwid; /* network id (or domain - the cell) */
873 struct iw_freq freq; /* frequency or channel :
874 * 0-1000 = channel
875 * > 1000 = frequency in Hz */
876
877 struct iw_param sens; /* signal level threshold */
878 struct iw_param bitrate; /* default bit rate */
879 struct iw_param txpower; /* default transmit power */
880 struct iw_param rts; /* RTS threshold threshold */
881 struct iw_param frag; /* Fragmentation threshold */
882 __u32 mode; /* Operation mode */
883 struct iw_param retry; /* Retry limits & lifetime */
884
885 struct iw_point encoding; /* Encoding stuff : tokens */
886 struct iw_param power; /* PM duration/timeout */
887 struct iw_quality qual; /* Quality part of statistics */
888
889 struct sockaddr ap_addr; /* Access point address */
890 struct sockaddr addr; /* Destination address (hw/mac) */
891
892 struct iw_param param; /* Other small parameters */
893 struct iw_point data; /* Other large parameters */
894 };
895
896 /*
897 * The structure to exchange data for ioctl.
898 * This structure is the same as 'struct ifreq', but (re)defined for
899 * convenience...
900 * Do I need to remind you about structure size (32 octets) ?
901 */
902 struct iwreq
903 {
904 union
905 {
906 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
907 } ifr_ifrn;
908
909 /* Data part (defined just above) */
910 union iwreq_data u;
911 };
912
913 /* -------------------------- IOCTL DATA -------------------------- */
914 /*
915 * For those ioctl which want to exchange mode data that what could
916 * fit in the above structure...
917 */
918
919 /*
920 * Range of parameters
921 */
922
923 struct iw_range
924 {
925 /* Informative stuff (to choose between different interface) */
926 __u32 throughput; /* To give an idea... */
927 /* In theory this value should be the maximum benchmarked
928 * TCP/IP throughput, because with most of these devices the
929 * bit rate is meaningless (overhead an co) to estimate how
930 * fast the connection will go and pick the fastest one.
931 * I suggest people to play with Netperf or any benchmark...
932 */
933
934 /* NWID (or domain id) */
935 __u32 min_nwid; /* Minimal NWID we are able to set */
936 __u32 max_nwid; /* Maximal NWID we are able to set */
937
938 /* Old Frequency (backward compat - moved lower ) */
939 __u16 old_num_channels;
940 __u8 old_num_frequency;
941
942 /* Wireless event capability bitmasks */
943 __u32 event_capa[6];
944
945 /* signal level threshold range */
946 __s32 sensitivity;
947
948 /* Quality of link & SNR stuff */
949 /* Quality range (link, level, noise)
950 * If the quality is absolute, it will be in the range [0 ; max_qual],
951 * if the quality is dBm, it will be in the range [max_qual ; 0].
952 * Don't forget that we use 8 bit arithmetics... */
953 struct iw_quality max_qual; /* Quality of the link */
954 /* This should contain the average/typical values of the quality
955 * indicator. This should be the threshold between a "good" and
956 * a "bad" link (example : monitor going from green to orange).
957 * Currently, user space apps like quality monitors don't have any
958 * way to calibrate the measurement. With this, they can split
959 * the range between 0 and max_qual in different quality level
960 * (using a geometric subdivision centered on the average).
961 * I expect that people doing the user space apps will feedback
962 * us on which value we need to put in each driver... */
963 struct iw_quality avg_qual; /* Quality of the link */
964
965 /* Rates */
966 __u8 num_bitrates; /* Number of entries in the list */
967 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
968
969 /* RTS threshold */
970 __s32 min_rts; /* Minimal RTS threshold */
971 __s32 max_rts; /* Maximal RTS threshold */
972
973 /* Frag threshold */
974 __s32 min_frag; /* Minimal frag threshold */
975 __s32 max_frag; /* Maximal frag threshold */
976
977 /* Power Management duration & timeout */
978 __s32 min_pmp; /* Minimal PM period */
979 __s32 max_pmp; /* Maximal PM period */
980 __s32 min_pmt; /* Minimal PM timeout */
981 __s32 max_pmt; /* Maximal PM timeout */
982 __u16 pmp_flags; /* How to decode max/min PM period */
983 __u16 pmt_flags; /* How to decode max/min PM timeout */
984 __u16 pm_capa; /* What PM options are supported */
985
986 /* Encoder stuff */
987 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
988 __u8 num_encoding_sizes; /* Number of entry in the list */
989 __u8 max_encoding_tokens; /* Max number of tokens */
990 /* For drivers that need a "login/passwd" form */
991 __u8 encoding_login_index; /* token index for login token */
992
993 /* Transmit power */
994 __u16 txpower_capa; /* What options are supported */
995 __u8 num_txpower; /* Number of entries in the list */
996 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
997
998 /* Wireless Extension version info */
999 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
1000 __u8 we_version_source; /* Last update of source */
1001
1002 /* Retry limits and lifetime */
1003 __u16 retry_capa; /* What retry options are supported */
1004 __u16 retry_flags; /* How to decode max/min retry limit */
1005 __u16 r_time_flags; /* How to decode max/min retry life */
1006 __s32 min_retry; /* Minimal number of retries */
1007 __s32 max_retry; /* Maximal number of retries */
1008 __s32 min_r_time; /* Minimal retry lifetime */
1009 __s32 max_r_time; /* Maximal retry lifetime */
1010
1011 /* Frequency */
1012 __u16 num_channels; /* Number of channels [0; num - 1] */
1013 __u8 num_frequency; /* Number of entry in the list */
1014 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
1015 /* Note : this frequency list doesn't need to fit channel numbers,
1016 * because each entry contain its channel index */
1017
1018 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1019 };
1020
1021 /*
1022 * Private ioctl interface information
1023 */
1024
1025 struct iw_priv_args
1026 {
1027 __u32 cmd; /* Number of the ioctl to issue */
1028 __u16 set_args; /* Type and number of args */
1029 __u16 get_args; /* Type and number of args */
1030 char name[IFNAMSIZ]; /* Name of the extension */
1031 };
1032
1033 /* ----------------------- WIRELESS EVENTS ----------------------- */
1034 /*
1035 * Wireless events are carried through the rtnetlink socket to user
1036 * space. They are encapsulated in the IFLA_WIRELESS field of
1037 * a RTM_NEWLINK message.
1038 */
1039
1040 /*
1041 * A Wireless Event. Contains basically the same data as the ioctl...
1042 */
1043 struct iw_event
1044 {
1045 __u16 len; /* Real lenght of this stuff */
1046 __u16 cmd; /* Wireless IOCTL */
1047 union iwreq_data u; /* IOCTL fixed payload */
1048 };
1049
1050 /* Size of the Event prefix (including padding and alignement junk) */
1051 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
1052 /* Size of the various events */
1053 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
1054 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
1055 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
1056 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
1057 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
1058 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
1059
1060 /* iw_point events are special. First, the payload (extra data) come at
1061 * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
1062 * we omit the pointer, so start at an offset. */
1063 #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
1064 (char *) NULL)
1065 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1066 IW_EV_POINT_OFF)
1067
1068 #endif /* _LINUX_WIRELESS_H */
+0
-1073
src/lwe/wireless.20.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 20 17.2.06
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # net/core/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # net/core/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* Do not put any header in this file, this creates a mess when
72 * exported to user space. Most users have included all the
73 * relevant headers anyway... Jean II */
74 /*#include <linux/types.h>*/ /* for "caddr_t" et al */
75 /*#include <linux/socket.h>*/ /* for "struct sockaddr" et al */
76 /*#include <linux/if.h>*/ /* for IFNAMSIZ and co... */
77
78 /***************************** VERSION *****************************/
79 /*
80 * This constant is used to know the availability of the wireless
81 * extensions and to know which version of wireless extensions it is
82 * (there is some stuff that will be added in the future...)
83 * I just plan to increment with each new version.
84 */
85 #define WIRELESS_EXT 20
86
87 /*
88 * Changes :
89 *
90 * V2 to V3
91 * --------
92 * Alan Cox start some incompatibles changes. I've integrated a bit more.
93 * - Encryption renamed to Encode to avoid US regulation problems
94 * - Frequency changed from float to struct to avoid problems on old 386
95 *
96 * V3 to V4
97 * --------
98 * - Add sensitivity
99 *
100 * V4 to V5
101 * --------
102 * - Missing encoding definitions in range
103 * - Access points stuff
104 *
105 * V5 to V6
106 * --------
107 * - 802.11 support (ESSID ioctls)
108 *
109 * V6 to V7
110 * --------
111 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
112 *
113 * V7 to V8
114 * --------
115 * - Changed my e-mail address
116 * - More 802.11 support (nickname, rate, rts, frag)
117 * - List index in frequencies
118 *
119 * V8 to V9
120 * --------
121 * - Support for 'mode of operation' (ad-hoc, managed...)
122 * - Support for unicast and multicast power saving
123 * - Change encoding to support larger tokens (>64 bits)
124 * - Updated iw_params (disable, flags) and use it for NWID
125 * - Extracted iw_point from iwreq for clarity
126 *
127 * V9 to V10
128 * ---------
129 * - Add PM capability to range structure
130 * - Add PM modifier : MAX/MIN/RELATIVE
131 * - Add encoding option : IW_ENCODE_NOKEY
132 * - Add TxPower ioctls (work like TxRate)
133 *
134 * V10 to V11
135 * ----------
136 * - Add WE version in range (help backward/forward compatibility)
137 * - Add retry ioctls (work like PM)
138 *
139 * V11 to V12
140 * ----------
141 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
142 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
143 * - Add new statistics (frag, retry, beacon)
144 * - Add average quality (for user space calibration)
145 *
146 * V12 to V13
147 * ----------
148 * - Document creation of new driver API.
149 * - Extract union iwreq_data from struct iwreq (for new driver API).
150 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
151 *
152 * V13 to V14
153 * ----------
154 * - Wireless Events support : define struct iw_event
155 * - Define additional specific event numbers
156 * - Add "addr" and "param" fields in union iwreq_data
157 * - AP scanning stuff (SIOCSIWSCAN and friends)
158 *
159 * V14 to V15
160 * ----------
161 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
162 * - Make struct iw_freq signed (both m & e), add explicit padding
163 * - Add IWEVCUSTOM for driver specific event/scanning token
164 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
165 * - Add IW_TXPOW_RANGE for range of Tx Powers
166 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
167 * - Add IW_MODE_MONITOR for passive monitor
168 *
169 * V15 to V16
170 * ----------
171 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
172 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
173 * - Reshuffle struct iw_range for increases, add filler
174 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
175 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
176 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
177 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
178 *
179 * V16 to V17
180 * ----------
181 * - Add flags to frequency -> auto/fixed
182 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
183 * - Wireless Event capability in struct iw_range
184 * - Add support for relative TxPower (yick !)
185 *
186 * V17 to V18 (From Jouni Malinen <[email protected]>)
187 * ----------
188 * - Add support for WPA/WPA2
189 * - Add extended encoding configuration (SIOCSIWENCODEEXT and
190 * SIOCGIWENCODEEXT)
191 * - Add SIOCSIWGENIE/SIOCGIWGENIE
192 * - Add SIOCSIWMLME
193 * - Add SIOCSIWPMKSA
194 * - Add struct iw_range bit field for supported encoding capabilities
195 * - Add optional scan request parameters for SIOCSIWSCAN
196 * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
197 * related parameters (extensible up to 4096 parameter values)
198 * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
199 * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
200 *
201 * V18 to V19
202 * ----------
203 * - Remove (struct iw_point *)->pointer from events and streams
204 * - Remove header includes to help user space
205 * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
206 * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
207 * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
208 * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
209 *
210 * V19 to V20
211 * ----------
212 * - RtNetlink requests support (SET/GET)
213 */
214
215 /**************************** CONSTANTS ****************************/
216
217 /* -------------------------- IOCTL LIST -------------------------- */
218
219 /* Wireless Identification */
220 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
221 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
222 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
223 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
224 * Don't put the name of your driver there, it's useless. */
225
226 /* Basic operations */
227 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
228 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
229 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
230 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
231 #define SIOCSIWMODE 0x8B06 /* set operation mode */
232 #define SIOCGIWMODE 0x8B07 /* get operation mode */
233 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
234 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
235
236 /* Informative stuff */
237 #define SIOCSIWRANGE 0x8B0A /* Unused */
238 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
239 #define SIOCSIWPRIV 0x8B0C /* Unused */
240 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
241 #define SIOCSIWSTATS 0x8B0E /* Unused */
242 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
243 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
244 * is never passed to the driver (i.e. the driver will never see it). */
245
246 /* Spy support (statistics per MAC address - used for Mobile IP support) */
247 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
248 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
249 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
250 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
251
252 /* Access Point manipulation */
253 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
254 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
255 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
256 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
257 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
258
259 /* 802.11 specific support */
260 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
261 #define SIOCGIWESSID 0x8B1B /* get ESSID */
262 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
263 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
264 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
265 * within the 'iwreq' structure, so we need to use the 'data' member to
266 * point to a string in user space, like it is done for RANGE... */
267
268 /* Other parameters useful in 802.11 and some other devices */
269 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
270 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
271 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
272 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
273 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
274 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
275 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
276 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
277 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
278 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
279
280 /* Encoding stuff (scrambling, hardware security, WEP...) */
281 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
282 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
283 /* Power saving stuff (power management, unicast and multicast) */
284 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
285 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
286
287 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
288 * This ioctl uses struct iw_point and data buffer that includes IE id and len
289 * fields. More than one IE may be included in the request. Setting the generic
290 * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
291 * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
292 * are required to report the used IE as a wireless event, e.g., when
293 * associating with an AP. */
294 #define SIOCSIWGENIE 0x8B30 /* set generic IE */
295 #define SIOCGIWGENIE 0x8B31 /* get generic IE */
296
297 /* WPA : IEEE 802.11 MLME requests */
298 #define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
299 * struct iw_mlme */
300 /* WPA : Authentication mode parameters */
301 #define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
302 #define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
303
304 /* WPA : Extended version of encoding configuration */
305 #define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
306 #define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
307
308 /* WPA2 : PMKSA cache management */
309 #define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
310
311 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
312
313 /* These 32 ioctl are wireless device private, for 16 commands.
314 * Each driver is free to use them for whatever purpose it chooses,
315 * however the driver *must* export the description of those ioctls
316 * with SIOCGIWPRIV and *must* use arguments as defined below.
317 * If you don't follow those rules, DaveM is going to hate you (reason :
318 * it make mixed 32/64bit operation impossible).
319 */
320 #define SIOCIWFIRSTPRIV 0x8BE0
321 #define SIOCIWLASTPRIV 0x8BFF
322 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
323 * separate range because of collisions with other tools such as
324 * 'mii-tool'.
325 * We now have 32 commands, so a bit more space ;-).
326 * Also, all 'odd' commands are only usable by root and don't return the
327 * content of ifr/iwr to user (but you are not obliged to use the set/get
328 * convention, just use every other two command). More details in iwpriv.c.
329 * And I repeat : you are not forced to use them with iwpriv, but you
330 * must be compliant with it.
331 */
332
333 /* ------------------------- IOCTL STUFF ------------------------- */
334
335 /* The first and the last (range) */
336 #define SIOCIWFIRST 0x8B00
337 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
338 #define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
339
340 /* Even : get (world access), odd : set (root access) */
341 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
342 #define IW_IS_GET(cmd) ((cmd) & 0x1)
343
344 /* ----------------------- WIRELESS EVENTS ----------------------- */
345 /* Those are *NOT* ioctls, do not issue request on them !!! */
346 /* Most events use the same identifier as ioctl requests */
347
348 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
349 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
350 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
351 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
352 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
353 #define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
354 * (scan results); This includes id and
355 * length fields. One IWEVGENIE may
356 * contain more than one IE. Scan
357 * results may contain one or more
358 * IWEVGENIE events. */
359 #define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
360 * (struct iw_michaelmicfailure)
361 */
362 #define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
363 * The data includes id and length
364 * fields and may contain more than one
365 * IE. This event is required in
366 * Managed mode if the driver
367 * generates its own WPA/RSN IE. This
368 * should be sent just before
369 * IWEVREGISTERED event for the
370 * association. */
371 #define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
372 * Response. The data includes id and
373 * length fields and may contain more
374 * than one IE. This may be sent
375 * between IWEVASSOCREQIE and
376 * IWEVREGISTERED events for the
377 * association. */
378 #define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
379 * pre-authentication
380 * (struct iw_pmkid_cand) */
381
382 #define IWEVFIRST 0x8C00
383 #define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
384
385 /* ------------------------- PRIVATE INFO ------------------------- */
386 /*
387 * The following is used with SIOCGIWPRIV. It allow a driver to define
388 * the interface (name, type of data) for its private ioctl.
389 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
390 */
391
392 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
393 #define IW_PRIV_TYPE_NONE 0x0000
394 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
395 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
396 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
397 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
398 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
399
400 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
401
402 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
403
404 /*
405 * Note : if the number of args is fixed and the size < 16 octets,
406 * instead of passing a pointer we will put args in the iwreq struct...
407 */
408
409 /* ----------------------- OTHER CONSTANTS ----------------------- */
410
411 /* Maximum frequencies in the range struct */
412 #define IW_MAX_FREQUENCIES 32
413 /* Note : if you have something like 80 frequencies,
414 * don't increase this constant and don't fill the frequency list.
415 * The user will be able to set by channel anyway... */
416
417 /* Maximum bit rates in the range struct */
418 #define IW_MAX_BITRATES 32
419
420 /* Maximum tx powers in the range struct */
421 #define IW_MAX_TXPOWER 8
422 /* Note : if you more than 8 TXPowers, just set the max and min or
423 * a few of them in the struct iw_range. */
424
425 /* Maximum of address that you may set with SPY */
426 #define IW_MAX_SPY 8
427
428 /* Maximum of address that you may get in the
429 list of access points in range */
430 #define IW_MAX_AP 64
431
432 /* Maximum size of the ESSID and NICKN strings */
433 #define IW_ESSID_MAX_SIZE 32
434
435 /* Modes of operation */
436 #define IW_MODE_AUTO 0 /* Let the driver decides */
437 #define IW_MODE_ADHOC 1 /* Single cell network */
438 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
439 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
440 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
441 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
442 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
443
444 /* Statistics flags (bitmask in updated) */
445 #define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
446 #define IW_QUAL_LEVEL_UPDATED 0x02
447 #define IW_QUAL_NOISE_UPDATED 0x04
448 #define IW_QUAL_ALL_UPDATED 0x07
449 #define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
450 #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
451 #define IW_QUAL_LEVEL_INVALID 0x20
452 #define IW_QUAL_NOISE_INVALID 0x40
453 #define IW_QUAL_ALL_INVALID 0x70
454
455 /* Frequency flags */
456 #define IW_FREQ_AUTO 0x00 /* Let the driver decides */
457 #define IW_FREQ_FIXED 0x01 /* Force a specific value */
458
459 /* Maximum number of size of encoding token available
460 * they are listed in the range structure */
461 #define IW_MAX_ENCODING_SIZES 8
462
463 /* Maximum size of the encoding token in bytes */
464 #define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
465
466 /* Flags for encoding (along with the token) */
467 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
468 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
469 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
470 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
471 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
472 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
473 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
474 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
475 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
476
477 /* Power management flags available (along with the value, if any) */
478 #define IW_POWER_ON 0x0000 /* No details... */
479 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
480 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
481 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
482 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
483 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
484 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
485 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
486 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
487 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
488 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
489 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
490 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
491 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
492
493 /* Transmit Power flags available */
494 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
495 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
496 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
497 #define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
498 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
499
500 /* Retry limits and lifetime flags available */
501 #define IW_RETRY_ON 0x0000 /* No details... */
502 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
503 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
504 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
505 #define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */
506 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
507 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
508 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
509
510 /* Scanning request flags */
511 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
512 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
513 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
514 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
515 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
516 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
517 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
518 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
519 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
520 /* struct iw_scan_req scan_type */
521 #define IW_SCAN_TYPE_ACTIVE 0
522 #define IW_SCAN_TYPE_PASSIVE 1
523 /* Maximum size of returned data */
524 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
525
526 /* Max number of char in custom event - use multiple of them if needed */
527 #define IW_CUSTOM_MAX 256 /* In bytes */
528
529 /* Generic information element */
530 #define IW_GENERIC_IE_MAX 1024
531
532 /* MLME requests (SIOCSIWMLME / struct iw_mlme) */
533 #define IW_MLME_DEAUTH 0
534 #define IW_MLME_DISASSOC 1
535
536 /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
537 #define IW_AUTH_INDEX 0x0FFF
538 #define IW_AUTH_FLAGS 0xF000
539 /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
540 * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
541 * parameter that is being set/get to; value will be read/written to
542 * struct iw_param value field) */
543 #define IW_AUTH_WPA_VERSION 0
544 #define IW_AUTH_CIPHER_PAIRWISE 1
545 #define IW_AUTH_CIPHER_GROUP 2
546 #define IW_AUTH_KEY_MGMT 3
547 #define IW_AUTH_TKIP_COUNTERMEASURES 4
548 #define IW_AUTH_DROP_UNENCRYPTED 5
549 #define IW_AUTH_80211_AUTH_ALG 6
550 #define IW_AUTH_WPA_ENABLED 7
551 #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
552 #define IW_AUTH_ROAMING_CONTROL 9
553 #define IW_AUTH_PRIVACY_INVOKED 10
554
555 /* IW_AUTH_WPA_VERSION values (bit field) */
556 #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
557 #define IW_AUTH_WPA_VERSION_WPA 0x00000002
558 #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
559
560 /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
561 #define IW_AUTH_CIPHER_NONE 0x00000001
562 #define IW_AUTH_CIPHER_WEP40 0x00000002
563 #define IW_AUTH_CIPHER_TKIP 0x00000004
564 #define IW_AUTH_CIPHER_CCMP 0x00000008
565 #define IW_AUTH_CIPHER_WEP104 0x00000010
566
567 /* IW_AUTH_KEY_MGMT values (bit field) */
568 #define IW_AUTH_KEY_MGMT_802_1X 1
569 #define IW_AUTH_KEY_MGMT_PSK 2
570
571 /* IW_AUTH_80211_AUTH_ALG values (bit field) */
572 #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
573 #define IW_AUTH_ALG_SHARED_KEY 0x00000002
574 #define IW_AUTH_ALG_LEAP 0x00000004
575
576 /* IW_AUTH_ROAMING_CONTROL values */
577 #define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
578 #define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
579 * control */
580
581 /* SIOCSIWENCODEEXT definitions */
582 #define IW_ENCODE_SEQ_MAX_SIZE 8
583 /* struct iw_encode_ext ->alg */
584 #define IW_ENCODE_ALG_NONE 0
585 #define IW_ENCODE_ALG_WEP 1
586 #define IW_ENCODE_ALG_TKIP 2
587 #define IW_ENCODE_ALG_CCMP 3
588 /* struct iw_encode_ext ->ext_flags */
589 #define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
590 #define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
591 #define IW_ENCODE_EXT_GROUP_KEY 0x00000004
592 #define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
593
594 /* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
595 #define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
596 #define IW_MICFAILURE_GROUP 0x00000004
597 #define IW_MICFAILURE_PAIRWISE 0x00000008
598 #define IW_MICFAILURE_STAKEY 0x00000010
599 #define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
600 */
601
602 /* Bit field values for enc_capa in struct iw_range */
603 #define IW_ENC_CAPA_WPA 0x00000001
604 #define IW_ENC_CAPA_WPA2 0x00000002
605 #define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
606 #define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
607
608 /* Event capability macros - in (struct iw_range *)->event_capa
609 * Because we have more than 32 possible events, we use an array of
610 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
611 #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
612 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
613 (cmd - SIOCSIWCOMMIT))
614 #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
615 #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
616 /* Event capability constants - event autogenerated by the kernel
617 * This list is valid for most 802.11 devices, customise as needed... */
618 #define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
619 IW_EVENT_CAPA_MASK(0x8B06) | \
620 IW_EVENT_CAPA_MASK(0x8B1A))
621 #define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
622 /* "Easy" macro to set events in iw_range (less efficient) */
623 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
624 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
625
626
627 /****************************** TYPES ******************************/
628
629 /* --------------------------- SUBTYPES --------------------------- */
630 /*
631 * Generic format for most parameters that fit in an int
632 */
633 struct iw_param
634 {
635 __s32 value; /* The value of the parameter itself */
636 __u8 fixed; /* Hardware should not use auto select */
637 __u8 disabled; /* Disable the feature */
638 __u16 flags; /* Various specifc flags (if any) */
639 };
640
641 /*
642 * For all data larger than 16 octets, we need to use a
643 * pointer to memory allocated in user space.
644 */
645 struct iw_point
646 {
647 void __user *pointer; /* Pointer to the data (in user space) */
648 __u16 length; /* number of fields or size in bytes */
649 __u16 flags; /* Optional params */
650 };
651
652 /*
653 * A frequency
654 * For numbers lower than 10^9, we encode the number in 'm' and
655 * set 'e' to 0
656 * For number greater than 10^9, we divide it by the lowest power
657 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
658 * The power of 10 is in 'e', the result of the division is in 'm'.
659 */
660 struct iw_freq
661 {
662 __s32 m; /* Mantissa */
663 __s16 e; /* Exponent */
664 __u8 i; /* List index (when in range struct) */
665 __u8 flags; /* Flags (fixed/auto) */
666 };
667
668 /*
669 * Quality of the link
670 */
671 struct iw_quality
672 {
673 __u8 qual; /* link quality (%retries, SNR,
674 %missed beacons or better...) */
675 __u8 level; /* signal level (dBm) */
676 __u8 noise; /* noise level (dBm) */
677 __u8 updated; /* Flags to know if updated */
678 };
679
680 /*
681 * Packet discarded in the wireless adapter due to
682 * "wireless" specific problems...
683 * Note : the list of counter and statistics in net_device_stats
684 * is already pretty exhaustive, and you should use that first.
685 * This is only additional stats...
686 */
687 struct iw_discarded
688 {
689 __u32 nwid; /* Rx : Wrong nwid/essid */
690 __u32 code; /* Rx : Unable to code/decode (WEP) */
691 __u32 fragment; /* Rx : Can't perform MAC reassembly */
692 __u32 retries; /* Tx : Max MAC retries num reached */
693 __u32 misc; /* Others cases */
694 };
695
696 /*
697 * Packet/Time period missed in the wireless adapter due to
698 * "wireless" specific problems...
699 */
700 struct iw_missed
701 {
702 __u32 beacon; /* Missed beacons/superframe */
703 };
704
705 /*
706 * Quality range (for spy threshold)
707 */
708 struct iw_thrspy
709 {
710 struct sockaddr addr; /* Source address (hw/mac) */
711 struct iw_quality qual; /* Quality of the link */
712 struct iw_quality low; /* Low threshold */
713 struct iw_quality high; /* High threshold */
714 };
715
716 /*
717 * Optional data for scan request
718 *
719 * Note: these optional parameters are controlling parameters for the
720 * scanning behavior, these do not apply to getting scan results
721 * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
722 * provide a merged results with all BSSes even if the previous scan
723 * request limited scanning to a subset, e.g., by specifying an SSID.
724 * Especially, scan results are required to include an entry for the
725 * current BSS if the driver is in Managed mode and associated with an AP.
726 */
727 struct iw_scan_req
728 {
729 __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
730 __u8 essid_len;
731 __u8 num_channels; /* num entries in channel_list;
732 * 0 = scan all allowed channels */
733 __u8 flags; /* reserved as padding; use zero, this may
734 * be used in the future for adding flags
735 * to request different scan behavior */
736 struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
737 * individual address of a specific BSS */
738
739 /*
740 * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
741 * the current ESSID. This allows scan requests for specific ESSID
742 * without having to change the current ESSID and potentially breaking
743 * the current association.
744 */
745 __u8 essid[IW_ESSID_MAX_SIZE];
746
747 /*
748 * Optional parameters for changing the default scanning behavior.
749 * These are based on the MLME-SCAN.request from IEEE Std 802.11.
750 * TU is 1.024 ms. If these are set to 0, driver is expected to use
751 * reasonable default values. min_channel_time defines the time that
752 * will be used to wait for the first reply on each channel. If no
753 * replies are received, next channel will be scanned after this. If
754 * replies are received, total time waited on the channel is defined by
755 * max_channel_time.
756 */
757 __u32 min_channel_time; /* in TU */
758 __u32 max_channel_time; /* in TU */
759
760 struct iw_freq channel_list[IW_MAX_FREQUENCIES];
761 };
762
763 /* ------------------------- WPA SUPPORT ------------------------- */
764
765 /*
766 * Extended data structure for get/set encoding (this is used with
767 * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
768 * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
769 * only the data contents changes (key data -> this structure, including
770 * key data).
771 *
772 * If the new key is the first group key, it will be set as the default
773 * TX key. Otherwise, default TX key index is only changed if
774 * IW_ENCODE_EXT_SET_TX_KEY flag is set.
775 *
776 * Key will be changed with SIOCSIWENCODEEXT in all cases except for
777 * special "change TX key index" operation which is indicated by setting
778 * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
779 *
780 * tx_seq/rx_seq are only used when respective
781 * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
782 * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
783 * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
784 * used only by an Authenticator (AP or an IBSS station) to get the
785 * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
786 * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
787 * debugging/testing.
788 */
789 struct iw_encode_ext
790 {
791 __u32 ext_flags; /* IW_ENCODE_EXT_* */
792 __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
793 __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
794 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
795 * (group) keys or unicast address for
796 * individual keys */
797 __u16 alg; /* IW_ENCODE_ALG_* */
798 __u16 key_len;
799 __u8 key[0];
800 };
801
802 /* SIOCSIWMLME data */
803 struct iw_mlme
804 {
805 __u16 cmd; /* IW_MLME_* */
806 __u16 reason_code;
807 struct sockaddr addr;
808 };
809
810 /* SIOCSIWPMKSA data */
811 #define IW_PMKSA_ADD 1
812 #define IW_PMKSA_REMOVE 2
813 #define IW_PMKSA_FLUSH 3
814
815 #define IW_PMKID_LEN 16
816
817 struct iw_pmksa
818 {
819 __u32 cmd; /* IW_PMKSA_* */
820 struct sockaddr bssid;
821 __u8 pmkid[IW_PMKID_LEN];
822 };
823
824 /* IWEVMICHAELMICFAILURE data */
825 struct iw_michaelmicfailure
826 {
827 __u32 flags;
828 struct sockaddr src_addr;
829 __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
830 };
831
832 /* IWEVPMKIDCAND data */
833 #define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
834 struct iw_pmkid_cand
835 {
836 __u32 flags; /* IW_PMKID_CAND_* */
837 __u32 index; /* the smaller the index, the higher the
838 * priority */
839 struct sockaddr bssid;
840 };
841
842 /* ------------------------ WIRELESS STATS ------------------------ */
843 /*
844 * Wireless statistics (used for /proc/net/wireless)
845 */
846 struct iw_statistics
847 {
848 __u16 status; /* Status
849 * - device dependent for now */
850
851 struct iw_quality qual; /* Quality of the link
852 * (instant/mean/max) */
853 struct iw_discarded discard; /* Packet discarded counts */
854 struct iw_missed miss; /* Packet missed counts */
855 };
856
857 /* ------------------------ IOCTL REQUEST ------------------------ */
858 /*
859 * This structure defines the payload of an ioctl, and is used
860 * below.
861 *
862 * Note that this structure should fit on the memory footprint
863 * of iwreq (which is the same as ifreq), which mean a max size of
864 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
865 * You should check this when increasing the structures defined
866 * above in this file...
867 */
868 union iwreq_data
869 {
870 /* Config - generic */
871 char name[IFNAMSIZ];
872 /* Name : used to verify the presence of wireless extensions.
873 * Name of the protocol/provider... */
874
875 struct iw_point essid; /* Extended network name */
876 struct iw_param nwid; /* network id (or domain - the cell) */
877 struct iw_freq freq; /* frequency or channel :
878 * 0-1000 = channel
879 * > 1000 = frequency in Hz */
880
881 struct iw_param sens; /* signal level threshold */
882 struct iw_param bitrate; /* default bit rate */
883 struct iw_param txpower; /* default transmit power */
884 struct iw_param rts; /* RTS threshold threshold */
885 struct iw_param frag; /* Fragmentation threshold */
886 __u32 mode; /* Operation mode */
887 struct iw_param retry; /* Retry limits & lifetime */
888
889 struct iw_point encoding; /* Encoding stuff : tokens */
890 struct iw_param power; /* PM duration/timeout */
891 struct iw_quality qual; /* Quality part of statistics */
892
893 struct sockaddr ap_addr; /* Access point address */
894 struct sockaddr addr; /* Destination address (hw/mac) */
895
896 struct iw_param param; /* Other small parameters */
897 struct iw_point data; /* Other large parameters */
898 };
899
900 /*
901 * The structure to exchange data for ioctl.
902 * This structure is the same as 'struct ifreq', but (re)defined for
903 * convenience...
904 * Do I need to remind you about structure size (32 octets) ?
905 */
906 struct iwreq
907 {
908 union
909 {
910 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
911 } ifr_ifrn;
912
913 /* Data part (defined just above) */
914 union iwreq_data u;
915 };
916
917 /* -------------------------- IOCTL DATA -------------------------- */
918 /*
919 * For those ioctl which want to exchange mode data that what could
920 * fit in the above structure...
921 */
922
923 /*
924 * Range of parameters
925 */
926
927 struct iw_range
928 {
929 /* Informative stuff (to choose between different interface) */
930 __u32 throughput; /* To give an idea... */
931 /* In theory this value should be the maximum benchmarked
932 * TCP/IP throughput, because with most of these devices the
933 * bit rate is meaningless (overhead an co) to estimate how
934 * fast the connection will go and pick the fastest one.
935 * I suggest people to play with Netperf or any benchmark...
936 */
937
938 /* NWID (or domain id) */
939 __u32 min_nwid; /* Minimal NWID we are able to set */
940 __u32 max_nwid; /* Maximal NWID we are able to set */
941
942 /* Old Frequency (backward compat - moved lower ) */
943 __u16 old_num_channels;
944 __u8 old_num_frequency;
945
946 /* Wireless event capability bitmasks */
947 __u32 event_capa[6];
948
949 /* signal level threshold range */
950 __s32 sensitivity;
951
952 /* Quality of link & SNR stuff */
953 /* Quality range (link, level, noise)
954 * If the quality is absolute, it will be in the range [0 ; max_qual],
955 * if the quality is dBm, it will be in the range [max_qual ; 0].
956 * Don't forget that we use 8 bit arithmetics... */
957 struct iw_quality max_qual; /* Quality of the link */
958 /* This should contain the average/typical values of the quality
959 * indicator. This should be the threshold between a "good" and
960 * a "bad" link (example : monitor going from green to orange).
961 * Currently, user space apps like quality monitors don't have any
962 * way to calibrate the measurement. With this, they can split
963 * the range between 0 and max_qual in different quality level
964 * (using a geometric subdivision centered on the average).
965 * I expect that people doing the user space apps will feedback
966 * us on which value we need to put in each driver... */
967 struct iw_quality avg_qual; /* Quality of the link */
968
969 /* Rates */
970 __u8 num_bitrates; /* Number of entries in the list */
971 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
972
973 /* RTS threshold */
974 __s32 min_rts; /* Minimal RTS threshold */
975 __s32 max_rts; /* Maximal RTS threshold */
976
977 /* Frag threshold */
978 __s32 min_frag; /* Minimal frag threshold */
979 __s32 max_frag; /* Maximal frag threshold */
980
981 /* Power Management duration & timeout */
982 __s32 min_pmp; /* Minimal PM period */
983 __s32 max_pmp; /* Maximal PM period */
984 __s32 min_pmt; /* Minimal PM timeout */
985 __s32 max_pmt; /* Maximal PM timeout */
986 __u16 pmp_flags; /* How to decode max/min PM period */
987 __u16 pmt_flags; /* How to decode max/min PM timeout */
988 __u16 pm_capa; /* What PM options are supported */
989
990 /* Encoder stuff */
991 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
992 __u8 num_encoding_sizes; /* Number of entry in the list */
993 __u8 max_encoding_tokens; /* Max number of tokens */
994 /* For drivers that need a "login/passwd" form */
995 __u8 encoding_login_index; /* token index for login token */
996
997 /* Transmit power */
998 __u16 txpower_capa; /* What options are supported */
999 __u8 num_txpower; /* Number of entries in the list */
1000 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
1001
1002 /* Wireless Extension version info */
1003 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
1004 __u8 we_version_source; /* Last update of source */
1005
1006 /* Retry limits and lifetime */
1007 __u16 retry_capa; /* What retry options are supported */
1008 __u16 retry_flags; /* How to decode max/min retry limit */
1009 __u16 r_time_flags; /* How to decode max/min retry life */
1010 __s32 min_retry; /* Minimal number of retries */
1011 __s32 max_retry; /* Maximal number of retries */
1012 __s32 min_r_time; /* Minimal retry lifetime */
1013 __s32 max_r_time; /* Maximal retry lifetime */
1014
1015 /* Frequency */
1016 __u16 num_channels; /* Number of channels [0; num - 1] */
1017 __u8 num_frequency; /* Number of entry in the list */
1018 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
1019 /* Note : this frequency list doesn't need to fit channel numbers,
1020 * because each entry contain its channel index */
1021
1022 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1023 };
1024
1025 /*
1026 * Private ioctl interface information
1027 */
1028
1029 struct iw_priv_args
1030 {
1031 __u32 cmd; /* Number of the ioctl to issue */
1032 __u16 set_args; /* Type and number of args */
1033 __u16 get_args; /* Type and number of args */
1034 char name[IFNAMSIZ]; /* Name of the extension */
1035 };
1036
1037 /* ----------------------- WIRELESS EVENTS ----------------------- */
1038 /*
1039 * Wireless events are carried through the rtnetlink socket to user
1040 * space. They are encapsulated in the IFLA_WIRELESS field of
1041 * a RTM_NEWLINK message.
1042 */
1043
1044 /*
1045 * A Wireless Event. Contains basically the same data as the ioctl...
1046 */
1047 struct iw_event
1048 {
1049 __u16 len; /* Real lenght of this stuff */
1050 __u16 cmd; /* Wireless IOCTL */
1051 union iwreq_data u; /* IOCTL fixed payload */
1052 };
1053
1054 /* Size of the Event prefix (including padding and alignement junk) */
1055 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
1056 /* Size of the various events */
1057 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
1058 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
1059 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
1060 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
1061 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
1062 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
1063
1064 /* iw_point events are special. First, the payload (extra data) come at
1065 * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
1066 * we omit the pointer, so start at an offset. */
1067 #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
1068 (char *) NULL)
1069 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1070 IW_EV_POINT_OFF)
1071
1072 #endif /* _LINUX_WIRELESS_H */
+0
-1139
src/lwe/wireless.22.h less more
0 /*
1 * This file define a set of standard wireless extensions
2 *
3 * Version : 22 16.3.07
4 *
5 * Authors : Jean Tourrilhes - HPL - <[email protected]>
6 * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
7 */
8
9 #ifndef _LINUX_WIRELESS_H
10 #define _LINUX_WIRELESS_H
11
12 /************************** DOCUMENTATION **************************/
13 /*
14 * Initial APIs (1996 -> onward) :
15 * -----------------------------
16 * Basically, the wireless extensions are for now a set of standard ioctl
17 * call + /proc/net/wireless
18 *
19 * The entry /proc/net/wireless give statistics and information on the
20 * driver.
21 * This is better than having each driver having its entry because
22 * its centralised and we may remove the driver module safely.
23 *
24 * Ioctl are used to configure the driver and issue commands. This is
25 * better than command line options of insmod because we may want to
26 * change dynamically (while the driver is running) some parameters.
27 *
28 * The ioctl mechanimsm are copied from standard devices ioctl.
29 * We have the list of command plus a structure descibing the
30 * data exchanged...
31 * Note that to add these ioctl, I was obliged to modify :
32 * # net/core/dev.c (two place + add include)
33 * # net/ipv4/af_inet.c (one place + add include)
34 *
35 * /proc/net/wireless is a copy of /proc/net/dev.
36 * We have a structure for data passed from the driver to /proc/net/wireless
37 * Too add this, I've modified :
38 * # net/core/dev.c (two other places)
39 * # include/linux/netdevice.h (one place)
40 * # include/linux/proc_fs.h (one place)
41 *
42 * New driver API (2002 -> onward) :
43 * -------------------------------
44 * This file is only concerned with the user space API and common definitions.
45 * The new driver API is defined and documented in :
46 * # include/net/iw_handler.h
47 *
48 * Note as well that /proc/net/wireless implementation has now moved in :
49 * # net/core/wireless.c
50 *
51 * Wireless Events (2002 -> onward) :
52 * --------------------------------
53 * Events are defined at the end of this file, and implemented in :
54 * # net/core/wireless.c
55 *
56 * Other comments :
57 * --------------
58 * Do not add here things that are redundant with other mechanisms
59 * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
60 * wireless specific.
61 *
62 * These wireless extensions are not magic : each driver has to provide
63 * support for them...
64 *
65 * IMPORTANT NOTE : As everything in the kernel, this is very much a
66 * work in progress. Contact me if you have ideas of improvements...
67 */
68
69 /***************************** INCLUDES *****************************/
70
71 /* This header is used in user-space, therefore need to be sanitised
72 * for that purpose. Those includes are usually not compatible with glibc.
73 * To know which includes to use in user-space, check iwlib.h. */
74 #ifdef __KERNEL__
75 #include <linux/types.h> /* for "caddr_t" et al */
76 #include <linux/socket.h> /* for "struct sockaddr" et al */
77 #include <linux/if.h> /* for IFNAMSIZ and co... */
78 #endif /* __KERNEL__ */
79
80 /***************************** VERSION *****************************/
81 /*
82 * This constant is used to know the availability of the wireless
83 * extensions and to know which version of wireless extensions it is
84 * (there is some stuff that will be added in the future...)
85 * I just plan to increment with each new version.
86 */
87 #define WIRELESS_EXT 22
88
89 /*
90 * Changes :
91 *
92 * V2 to V3
93 * --------
94 * Alan Cox start some incompatibles changes. I've integrated a bit more.
95 * - Encryption renamed to Encode to avoid US regulation problems
96 * - Frequency changed from float to struct to avoid problems on old 386
97 *
98 * V3 to V4
99 * --------
100 * - Add sensitivity
101 *
102 * V4 to V5
103 * --------
104 * - Missing encoding definitions in range
105 * - Access points stuff
106 *
107 * V5 to V6
108 * --------
109 * - 802.11 support (ESSID ioctls)
110 *
111 * V6 to V7
112 * --------
113 * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
114 *
115 * V7 to V8
116 * --------
117 * - Changed my e-mail address
118 * - More 802.11 support (nickname, rate, rts, frag)
119 * - List index in frequencies
120 *
121 * V8 to V9
122 * --------
123 * - Support for 'mode of operation' (ad-hoc, managed...)
124 * - Support for unicast and multicast power saving
125 * - Change encoding to support larger tokens (>64 bits)
126 * - Updated iw_params (disable, flags) and use it for NWID
127 * - Extracted iw_point from iwreq for clarity
128 *
129 * V9 to V10
130 * ---------
131 * - Add PM capability to range structure
132 * - Add PM modifier : MAX/MIN/RELATIVE
133 * - Add encoding option : IW_ENCODE_NOKEY
134 * - Add TxPower ioctls (work like TxRate)
135 *
136 * V10 to V11
137 * ----------
138 * - Add WE version in range (help backward/forward compatibility)
139 * - Add retry ioctls (work like PM)
140 *
141 * V11 to V12
142 * ----------
143 * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
144 * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
145 * - Add new statistics (frag, retry, beacon)
146 * - Add average quality (for user space calibration)
147 *
148 * V12 to V13
149 * ----------
150 * - Document creation of new driver API.
151 * - Extract union iwreq_data from struct iwreq (for new driver API).
152 * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
153 *
154 * V13 to V14
155 * ----------
156 * - Wireless Events support : define struct iw_event
157 * - Define additional specific event numbers
158 * - Add "addr" and "param" fields in union iwreq_data
159 * - AP scanning stuff (SIOCSIWSCAN and friends)
160 *
161 * V14 to V15
162 * ----------
163 * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
164 * - Make struct iw_freq signed (both m & e), add explicit padding
165 * - Add IWEVCUSTOM for driver specific event/scanning token
166 * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
167 * - Add IW_TXPOW_RANGE for range of Tx Powers
168 * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
169 * - Add IW_MODE_MONITOR for passive monitor
170 *
171 * V15 to V16
172 * ----------
173 * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
174 * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
175 * - Reshuffle struct iw_range for increases, add filler
176 * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
177 * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
178 * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
179 * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
180 *
181 * V16 to V17
182 * ----------
183 * - Add flags to frequency -> auto/fixed
184 * - Document (struct iw_quality *)->updated, add new flags (INVALID)
185 * - Wireless Event capability in struct iw_range
186 * - Add support for relative TxPower (yick !)
187 *
188 * V17 to V18 (From Jouni Malinen <[email protected]>)
189 * ----------
190 * - Add support for WPA/WPA2
191 * - Add extended encoding configuration (SIOCSIWENCODEEXT and
192 * SIOCGIWENCODEEXT)
193 * - Add SIOCSIWGENIE/SIOCGIWGENIE
194 * - Add SIOCSIWMLME
195 * - Add SIOCSIWPMKSA
196 * - Add struct iw_range bit field for supported encoding capabilities
197 * - Add optional scan request parameters for SIOCSIWSCAN
198 * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
199 * related parameters (extensible up to 4096 parameter values)
200 * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
201 * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
202 *
203 * V18 to V19
204 * ----------
205 * - Remove (struct iw_point *)->pointer from events and streams
206 * - Remove header includes to help user space
207 * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
208 * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
209 * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
210 * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
211 *
212 * V19 to V20
213 * ----------
214 * - RtNetlink requests support (SET/GET)
215 *
216 * V20 to V21
217 * ----------
218 * - Remove (struct net_device *)->get_wireless_stats()
219 * - Change length in ESSID and NICK to strlen() instead of strlen()+1
220 * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
221 * - Power/Retry relative values no longer * 100000
222 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
223 *
224 * V21 to V22
225 * ----------
226 * - Prevent leaking of kernel space in stream on 64 bits.
227 */
228
229 /**************************** CONSTANTS ****************************/
230
231 /* -------------------------- IOCTL LIST -------------------------- */
232
233 /* Wireless Identification */
234 #define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
235 #define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
236 /* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
237 * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
238 * Don't put the name of your driver there, it's useless. */
239
240 /* Basic operations */
241 #define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
242 #define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
243 #define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
244 #define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
245 #define SIOCSIWMODE 0x8B06 /* set operation mode */
246 #define SIOCGIWMODE 0x8B07 /* get operation mode */
247 #define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
248 #define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
249
250 /* Informative stuff */
251 #define SIOCSIWRANGE 0x8B0A /* Unused */
252 #define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
253 #define SIOCSIWPRIV 0x8B0C /* Unused */
254 #define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
255 #define SIOCSIWSTATS 0x8B0E /* Unused */
256 #define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
257 /* SIOCGIWSTATS is strictly used between user space and the kernel, and
258 * is never passed to the driver (i.e. the driver will never see it). */
259
260 /* Spy support (statistics per MAC address - used for Mobile IP support) */
261 #define SIOCSIWSPY 0x8B10 /* set spy addresses */
262 #define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
263 #define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
264 #define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
265
266 /* Access Point manipulation */
267 #define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
268 #define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
269 #define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
270 #define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
271 #define SIOCGIWSCAN 0x8B19 /* get scanning results */
272
273 /* 802.11 specific support */
274 #define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
275 #define SIOCGIWESSID 0x8B1B /* get ESSID */
276 #define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
277 #define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
278 /* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
279 * within the 'iwreq' structure, so we need to use the 'data' member to
280 * point to a string in user space, like it is done for RANGE... */
281
282 /* Other parameters useful in 802.11 and some other devices */
283 #define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
284 #define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
285 #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
286 #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
287 #define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
288 #define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
289 #define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
290 #define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
291 #define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
292 #define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
293
294 /* Encoding stuff (scrambling, hardware security, WEP...) */
295 #define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
296 #define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
297 /* Power saving stuff (power management, unicast and multicast) */
298 #define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
299 #define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
300 /* Modulation bitmask */
301 #define SIOCSIWMODUL 0x8B2E /* set Modulations settings */
302 #define SIOCGIWMODUL 0x8B2F /* get Modulations settings */
303
304 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
305 * This ioctl uses struct iw_point and data buffer that includes IE id and len
306 * fields. More than one IE may be included in the request. Setting the generic
307 * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
308 * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
309 * are required to report the used IE as a wireless event, e.g., when
310 * associating with an AP. */
311 #define SIOCSIWGENIE 0x8B30 /* set generic IE */
312 #define SIOCGIWGENIE 0x8B31 /* get generic IE */
313
314 /* WPA : IEEE 802.11 MLME requests */
315 #define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
316 * struct iw_mlme */
317 /* WPA : Authentication mode parameters */
318 #define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
319 #define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
320
321 /* WPA : Extended version of encoding configuration */
322 #define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
323 #define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
324
325 /* WPA2 : PMKSA cache management */
326 #define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
327
328 /* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
329
330 /* These 32 ioctl are wireless device private, for 16 commands.
331 * Each driver is free to use them for whatever purpose it chooses,
332 * however the driver *must* export the description of those ioctls
333 * with SIOCGIWPRIV and *must* use arguments as defined below.
334 * If you don't follow those rules, DaveM is going to hate you (reason :
335 * it make mixed 32/64bit operation impossible).
336 */
337 #define SIOCIWFIRSTPRIV 0x8BE0
338 #define SIOCIWLASTPRIV 0x8BFF
339 /* Previously, we were using SIOCDEVPRIVATE, but we now have our
340 * separate range because of collisions with other tools such as
341 * 'mii-tool'.
342 * We now have 32 commands, so a bit more space ;-).
343 * Also, all 'even' commands are only usable by root and don't return the
344 * content of ifr/iwr to user (but you are not obliged to use the set/get
345 * convention, just use every other two command). More details in iwpriv.c.
346 * And I repeat : you are not forced to use them with iwpriv, but you
347 * must be compliant with it.
348 */
349
350 /* ------------------------- IOCTL STUFF ------------------------- */
351
352 /* The first and the last (range) */
353 #define SIOCIWFIRST 0x8B00
354 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
355 #define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
356
357 /* Odd : get (world access), even : set (root access) */
358 #define IW_IS_SET(cmd) (!((cmd) & 0x1))
359 #define IW_IS_GET(cmd) ((cmd) & 0x1)
360
361 /* ----------------------- WIRELESS EVENTS ----------------------- */
362 /* Those are *NOT* ioctls, do not issue request on them !!! */
363 /* Most events use the same identifier as ioctl requests */
364
365 #define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
366 #define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
367 #define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
368 #define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
369 #define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
370 #define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
371 * (scan results); This includes id and
372 * length fields. One IWEVGENIE may
373 * contain more than one IE. Scan
374 * results may contain one or more
375 * IWEVGENIE events. */
376 #define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
377 * (struct iw_michaelmicfailure)
378 */
379 #define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
380 * The data includes id and length
381 * fields and may contain more than one
382 * IE. This event is required in
383 * Managed mode if the driver
384 * generates its own WPA/RSN IE. This
385 * should be sent just before
386 * IWEVREGISTERED event for the
387 * association. */
388 #define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
389 * Response. The data includes id and
390 * length fields and may contain more
391 * than one IE. This may be sent
392 * between IWEVASSOCREQIE and
393 * IWEVREGISTERED events for the
394 * association. */
395 #define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
396 * pre-authentication
397 * (struct iw_pmkid_cand) */
398
399 #define IWEVFIRST 0x8C00
400 #define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
401
402 /* ------------------------- PRIVATE INFO ------------------------- */
403 /*
404 * The following is used with SIOCGIWPRIV. It allow a driver to define
405 * the interface (name, type of data) for its private ioctl.
406 * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
407 */
408
409 #define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
410 #define IW_PRIV_TYPE_NONE 0x0000
411 #define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
412 #define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
413 #define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
414 #define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
415 #define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
416
417 #define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
418
419 #define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
420
421 /*
422 * Note : if the number of args is fixed and the size < 16 octets,
423 * instead of passing a pointer we will put args in the iwreq struct...
424 */
425
426 /* ----------------------- OTHER CONSTANTS ----------------------- */
427
428 /* Maximum frequencies in the range struct */
429 #define IW_MAX_FREQUENCIES 32
430 /* Note : if you have something like 80 frequencies,
431 * don't increase this constant and don't fill the frequency list.
432 * The user will be able to set by channel anyway... */
433
434 /* Maximum bit rates in the range struct */
435 #define IW_MAX_BITRATES 32
436
437 /* Maximum tx powers in the range struct */
438 #define IW_MAX_TXPOWER 8
439 /* Note : if you more than 8 TXPowers, just set the max and min or
440 * a few of them in the struct iw_range. */
441
442 /* Maximum of address that you may set with SPY */
443 #define IW_MAX_SPY 8
444
445 /* Maximum of address that you may get in the
446 list of access points in range */
447 #define IW_MAX_AP 64
448
449 /* Maximum size of the ESSID and NICKN strings */
450 #define IW_ESSID_MAX_SIZE 32
451
452 /* Modes of operation */
453 #define IW_MODE_AUTO 0 /* Let the driver decides */
454 #define IW_MODE_ADHOC 1 /* Single cell network */
455 #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
456 #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
457 #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
458 #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
459 #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
460
461 /* Statistics flags (bitmask in updated) */
462 #define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
463 #define IW_QUAL_LEVEL_UPDATED 0x02
464 #define IW_QUAL_NOISE_UPDATED 0x04
465 #define IW_QUAL_ALL_UPDATED 0x07
466 #define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
467 #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
468 #define IW_QUAL_LEVEL_INVALID 0x20
469 #define IW_QUAL_NOISE_INVALID 0x40
470 #define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
471 #define IW_QUAL_ALL_INVALID 0x70
472
473 /* Frequency flags */
474 #define IW_FREQ_AUTO 0x00 /* Let the driver decides */
475 #define IW_FREQ_FIXED 0x01 /* Force a specific value */
476
477 /* Maximum number of size of encoding token available
478 * they are listed in the range structure */
479 #define IW_MAX_ENCODING_SIZES 8
480
481 /* Maximum size of the encoding token in bytes */
482 #define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
483
484 /* Flags for encoding (along with the token) */
485 #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
486 #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
487 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
488 #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
489 #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
490 #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
491 #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
492 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
493 #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
494
495 /* Power management flags available (along with the value, if any) */
496 #define IW_POWER_ON 0x0000 /* No details... */
497 #define IW_POWER_TYPE 0xF000 /* Type of parameter */
498 #define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
499 #define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
500 #define IW_POWER_SAVING 0x4000 /* Value is relative (how aggressive)*/
501 #define IW_POWER_MODE 0x0F00 /* Power Management mode */
502 #define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
503 #define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
504 #define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
505 #define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
506 #define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
507 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
508 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
509 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
510 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
511
512 /* Transmit Power flags available */
513 #define IW_TXPOW_TYPE 0x00FF /* Type of value */
514 #define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
515 #define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
516 #define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
517 #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
518
519 /* Retry limits and lifetime flags available */
520 #define IW_RETRY_ON 0x0000 /* No details... */
521 #define IW_RETRY_TYPE 0xF000 /* Type of parameter */
522 #define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
523 #define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
524 #define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
525 #define IW_RETRY_MIN 0x0001 /* Value is a minimum */
526 #define IW_RETRY_MAX 0x0002 /* Value is a maximum */
527 #define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
528 #define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
529 #define IW_RETRY_LONG 0x0020 /* Value is for long packets */
530
531 /* Scanning request flags */
532 #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
533 #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
534 #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
535 #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
536 #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
537 #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
538 #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
539 #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
540 #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
541 /* struct iw_scan_req scan_type */
542 #define IW_SCAN_TYPE_ACTIVE 0
543 #define IW_SCAN_TYPE_PASSIVE 1
544 /* Maximum size of returned data */
545 #define IW_SCAN_MAX_DATA 4096 /* In bytes */
546
547 /* Max number of char in custom event - use multiple of them if needed */
548 #define IW_CUSTOM_MAX 256 /* In bytes */
549
550 /* Generic information element */
551 #define IW_GENERIC_IE_MAX 1024
552
553 /* MLME requests (SIOCSIWMLME / struct iw_mlme) */
554 #define IW_MLME_DEAUTH 0
555 #define IW_MLME_DISASSOC 1
556 #define IW_MLME_AUTH 2
557 #define IW_MLME_ASSOC 3
558
559 /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
560 #define IW_AUTH_INDEX 0x0FFF
561 #define IW_AUTH_FLAGS 0xF000
562 /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
563 * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
564 * parameter that is being set/get to; value will be read/written to
565 * struct iw_param value field) */
566 #define IW_AUTH_WPA_VERSION 0
567 #define IW_AUTH_CIPHER_PAIRWISE 1
568 #define IW_AUTH_CIPHER_GROUP 2
569 #define IW_AUTH_KEY_MGMT 3
570 #define IW_AUTH_TKIP_COUNTERMEASURES 4
571 #define IW_AUTH_DROP_UNENCRYPTED 5
572 #define IW_AUTH_80211_AUTH_ALG 6
573 #define IW_AUTH_WPA_ENABLED 7
574 #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
575 #define IW_AUTH_ROAMING_CONTROL 9
576 #define IW_AUTH_PRIVACY_INVOKED 10
577
578 /* IW_AUTH_WPA_VERSION values (bit field) */
579 #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
580 #define IW_AUTH_WPA_VERSION_WPA 0x00000002
581 #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
582
583 /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
584 #define IW_AUTH_CIPHER_NONE 0x00000001
585 #define IW_AUTH_CIPHER_WEP40 0x00000002
586 #define IW_AUTH_CIPHER_TKIP 0x00000004
587 #define IW_AUTH_CIPHER_CCMP 0x00000008
588 #define IW_AUTH_CIPHER_WEP104 0x00000010
589
590 /* IW_AUTH_KEY_MGMT values (bit field) */
591 #define IW_AUTH_KEY_MGMT_802_1X 1
592 #define IW_AUTH_KEY_MGMT_PSK 2
593
594 /* IW_AUTH_80211_AUTH_ALG values (bit field) */
595 #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
596 #define IW_AUTH_ALG_SHARED_KEY 0x00000002
597 #define IW_AUTH_ALG_LEAP 0x00000004
598
599 /* IW_AUTH_ROAMING_CONTROL values */
600 #define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
601 #define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
602 * control */
603
604 /* SIOCSIWENCODEEXT definitions */
605 #define IW_ENCODE_SEQ_MAX_SIZE 8
606 /* struct iw_encode_ext ->alg */
607 #define IW_ENCODE_ALG_NONE 0
608 #define IW_ENCODE_ALG_WEP 1
609 #define IW_ENCODE_ALG_TKIP 2
610 #define IW_ENCODE_ALG_CCMP 3
611 /* struct iw_encode_ext ->ext_flags */
612 #define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
613 #define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
614 #define IW_ENCODE_EXT_GROUP_KEY 0x00000004
615 #define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
616
617 /* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
618 #define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
619 #define IW_MICFAILURE_GROUP 0x00000004
620 #define IW_MICFAILURE_PAIRWISE 0x00000008
621 #define IW_MICFAILURE_STAKEY 0x00000010
622 #define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
623 */
624
625 /* Bit field values for enc_capa in struct iw_range */
626 #define IW_ENC_CAPA_WPA 0x00000001
627 #define IW_ENC_CAPA_WPA2 0x00000002
628 #define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
629 #define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
630
631 /* Event capability macros - in (struct iw_range *)->event_capa
632 * Because we have more than 32 possible events, we use an array of
633 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
634 #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
635 (cmd - SIOCIWFIRSTPRIV + 0x60) : \
636 (cmd - SIOCSIWCOMMIT))
637 #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
638 #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
639 /* Event capability constants - event autogenerated by the kernel
640 * This list is valid for most 802.11 devices, customise as needed... */
641 #define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
642 IW_EVENT_CAPA_MASK(0x8B06) | \
643 IW_EVENT_CAPA_MASK(0x8B1A))
644 #define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
645 /* "Easy" macro to set events in iw_range (less efficient) */
646 #define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
647 #define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
648
649 /* Modulations bitmasks */
650 #define IW_MODUL_ALL 0x00000000 /* Everything supported */
651 #define IW_MODUL_FH 0x00000001 /* Frequency Hopping */
652 #define IW_MODUL_DS 0x00000002 /* Original Direct Sequence */
653 #define IW_MODUL_CCK 0x00000004 /* 802.11b : 5.5 + 11 Mb/s */
654 #define IW_MODUL_11B (IW_MODUL_DS | IW_MODUL_CCK)
655 #define IW_MODUL_PBCC 0x00000008 /* TI : 5.5 + 11 + 22 Mb/s */
656 #define IW_MODUL_OFDM_A 0x00000010 /* 802.11a : 54 Mb/s */
657 #define IW_MODUL_11A (IW_MODUL_OFDM_A)
658 #define IW_MODUL_11AB (IW_MODUL_11B | IW_MODUL_11A)
659 #define IW_MODUL_OFDM_G 0x00000020 /* 802.11g : 54 Mb/s */
660 #define IW_MODUL_11G (IW_MODUL_11B | IW_MODUL_OFDM_G)
661 #define IW_MODUL_11AG (IW_MODUL_11G | IW_MODUL_11A)
662 #define IW_MODUL_TURBO 0x00000040 /* ATH : bonding, 108 Mb/s */
663 /* In here we should define MIMO stuff. Later... */
664 #define IW_MODUL_CUSTOM 0x40000000 /* Driver specific */
665
666 /* Bitrate flags available */
667 #define IW_BITRATE_TYPE 0x00FF /* Type of value */
668 #define IW_BITRATE_UNICAST 0x0001 /* Maximum/Fixed unicast bitrate */
669 #define IW_BITRATE_BROADCAST 0x0002 /* Fixed broadcast bitrate */
670
671 /****************************** TYPES ******************************/
672
673 /* --------------------------- SUBTYPES --------------------------- */
674 /*
675 * Generic format for most parameters that fit in an int
676 */
677 struct iw_param
678 {
679 __s32 value; /* The value of the parameter itself */
680 __u8 fixed; /* Hardware should not use auto select */
681 __u8 disabled; /* Disable the feature */
682 __u16 flags; /* Various specifc flags (if any) */
683 };
684
685 /*
686 * For all data larger than 16 octets, we need to use a
687 * pointer to memory allocated in user space.
688 */
689 struct iw_point
690 {
691 void __user *pointer; /* Pointer to the data (in user space) */
692 __u16 length; /* number of fields or size in bytes */
693 __u16 flags; /* Optional params */
694 };
695
696 /*
697 * A frequency
698 * For numbers lower than 10^9, we encode the number in 'm' and
699 * set 'e' to 0
700 * For number greater than 10^9, we divide it by the lowest power
701 * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
702 * The power of 10 is in 'e', the result of the division is in 'm'.
703 */
704 struct iw_freq
705 {
706 __s32 m; /* Mantissa */
707 __s16 e; /* Exponent */
708 __u8 i; /* List index (when in range struct) */
709 __u8 flags; /* Flags (fixed/auto) */
710 };
711
712 /*
713 * Quality of the link
714 */
715 struct iw_quality
716 {
717 __u8 qual; /* link quality (%retries, SNR,
718 %missed beacons or better...) */
719 __u8 level; /* signal level (dBm) */
720 __u8 noise; /* noise level (dBm) */
721 __u8 updated; /* Flags to know if updated */
722 };
723
724 /*
725 * Packet discarded in the wireless adapter due to
726 * "wireless" specific problems...
727 * Note : the list of counter and statistics in net_device_stats
728 * is already pretty exhaustive, and you should use that first.
729 * This is only additional stats...
730 */
731 struct iw_discarded
732 {
733 __u32 nwid; /* Rx : Wrong nwid/essid */
734 __u32 code; /* Rx : Unable to code/decode (WEP) */
735 __u32 fragment; /* Rx : Can't perform MAC reassembly */
736 __u32 retries; /* Tx : Max MAC retries num reached */
737 __u32 misc; /* Others cases */
738 };
739
740 /*
741 * Packet/Time period missed in the wireless adapter due to
742 * "wireless" specific problems...
743 */
744 struct iw_missed
745 {
746 __u32 beacon; /* Missed beacons/superframe */
747 };
748
749 /*
750 * Quality range (for spy threshold)
751 */
752 struct iw_thrspy
753 {
754 struct sockaddr addr; /* Source address (hw/mac) */
755 struct iw_quality qual; /* Quality of the link */
756 struct iw_quality low; /* Low threshold */
757 struct iw_quality high; /* High threshold */
758 };
759
760 /*
761 * Optional data for scan request
762 *
763 * Note: these optional parameters are controlling parameters for the
764 * scanning behavior, these do not apply to getting scan results
765 * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
766 * provide a merged results with all BSSes even if the previous scan
767 * request limited scanning to a subset, e.g., by specifying an SSID.
768 * Especially, scan results are required to include an entry for the
769 * current BSS if the driver is in Managed mode and associated with an AP.
770 */
771 struct iw_scan_req
772 {
773 __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
774 __u8 essid_len;
775 __u8 num_channels; /* num entries in channel_list;
776 * 0 = scan all allowed channels */
777 __u8 flags; /* reserved as padding; use zero, this may
778 * be used in the future for adding flags
779 * to request different scan behavior */
780 struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
781 * individual address of a specific BSS */
782
783 /*
784 * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
785 * the current ESSID. This allows scan requests for specific ESSID
786 * without having to change the current ESSID and potentially breaking
787 * the current association.
788 */
789 __u8 essid[IW_ESSID_MAX_SIZE];
790
791 /*
792 * Optional parameters for changing the default scanning behavior.
793 * These are based on the MLME-SCAN.request from IEEE Std 802.11.
794 * TU is 1.024 ms. If these are set to 0, driver is expected to use
795 * reasonable default values. min_channel_time defines the time that
796 * will be used to wait for the first reply on each channel. If no
797 * replies are received, next channel will be scanned after this. If
798 * replies are received, total time waited on the channel is defined by
799 * max_channel_time.
800 */
801 __u32 min_channel_time; /* in TU */
802 __u32 max_channel_time; /* in TU */
803
804 struct iw_freq channel_list[IW_MAX_FREQUENCIES];
805 };
806
807 /* ------------------------- WPA SUPPORT ------------------------- */
808
809 /*
810 * Extended data structure for get/set encoding (this is used with
811 * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
812 * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
813 * only the data contents changes (key data -> this structure, including
814 * key data).
815 *
816 * If the new key is the first group key, it will be set as the default
817 * TX key. Otherwise, default TX key index is only changed if
818 * IW_ENCODE_EXT_SET_TX_KEY flag is set.
819 *
820 * Key will be changed with SIOCSIWENCODEEXT in all cases except for
821 * special "change TX key index" operation which is indicated by setting
822 * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
823 *
824 * tx_seq/rx_seq are only used when respective
825 * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
826 * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
827 * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
828 * used only by an Authenticator (AP or an IBSS station) to get the
829 * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
830 * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
831 * debugging/testing.
832 */
833 struct iw_encode_ext
834 {
835 __u32 ext_flags; /* IW_ENCODE_EXT_* */
836 __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
837 __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
838 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
839 * (group) keys or unicast address for
840 * individual keys */
841 __u16 alg; /* IW_ENCODE_ALG_* */
842 __u16 key_len;
843 __u8 key[0];
844 };
845
846 /* SIOCSIWMLME data */
847 struct iw_mlme
848 {
849 __u16 cmd; /* IW_MLME_* */
850 __u16 reason_code;
851 struct sockaddr addr;
852 };
853
854 /* SIOCSIWPMKSA data */
855 #define IW_PMKSA_ADD 1
856 #define IW_PMKSA_REMOVE 2
857 #define IW_PMKSA_FLUSH 3
858
859 #define IW_PMKID_LEN 16
860
861 struct iw_pmksa
862 {
863 __u32 cmd; /* IW_PMKSA_* */
864 struct sockaddr bssid;
865 __u8 pmkid[IW_PMKID_LEN];
866 };
867
868 /* IWEVMICHAELMICFAILURE data */
869 struct iw_michaelmicfailure
870 {
871 __u32 flags;
872 struct sockaddr src_addr;
873 __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
874 };
875
876 /* IWEVPMKIDCAND data */
877 #define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
878 struct iw_pmkid_cand
879 {
880 __u32 flags; /* IW_PMKID_CAND_* */
881 __u32 index; /* the smaller the index, the higher the
882 * priority */
883 struct sockaddr bssid;
884 };
885
886 /* ------------------------ WIRELESS STATS ------------------------ */
887 /*
888 * Wireless statistics (used for /proc/net/wireless)
889 */
890 struct iw_statistics
891 {
892 __u16 status; /* Status
893 * - device dependent for now */
894
895 struct iw_quality qual; /* Quality of the link
896 * (instant/mean/max) */
897 struct iw_discarded discard; /* Packet discarded counts */
898 struct iw_missed miss; /* Packet missed counts */
899 };
900
901 /* ------------------------ IOCTL REQUEST ------------------------ */
902 /*
903 * This structure defines the payload of an ioctl, and is used
904 * below.
905 *
906 * Note that this structure should fit on the memory footprint
907 * of iwreq (which is the same as ifreq), which mean a max size of
908 * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
909 * You should check this when increasing the structures defined
910 * above in this file...
911 */
912 union iwreq_data
913 {
914 /* Config - generic */
915 char name[IFNAMSIZ];
916 /* Name : used to verify the presence of wireless extensions.
917 * Name of the protocol/provider... */
918
919 struct iw_point essid; /* Extended network name */
920 struct iw_param nwid; /* network id (or domain - the cell) */
921 struct iw_freq freq; /* frequency or channel :
922 * 0-1000 = channel
923 * > 1000 = frequency in Hz */
924
925 struct iw_param sens; /* signal level threshold */
926 struct iw_param bitrate; /* default bit rate */
927 struct iw_param txpower; /* default transmit power */
928 struct iw_param rts; /* RTS threshold threshold */
929 struct iw_param frag; /* Fragmentation threshold */
930 __u32 mode; /* Operation mode */
931 struct iw_param retry; /* Retry limits & lifetime */
932
933 struct iw_point encoding; /* Encoding stuff : tokens */
934 struct iw_param power; /* PM duration/timeout */
935 struct iw_quality qual; /* Quality part of statistics */
936
937 struct sockaddr ap_addr; /* Access point address */
938 struct sockaddr addr; /* Destination address (hw/mac) */
939
940 struct iw_param param; /* Other small parameters */
941 struct iw_point data; /* Other large parameters */
942 };
943
944 /*
945 * The structure to exchange data for ioctl.
946 * This structure is the same as 'struct ifreq', but (re)defined for
947 * convenience...
948 * Do I need to remind you about structure size (32 octets) ?
949 */
950 struct iwreq
951 {
952 union
953 {
954 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
955 } ifr_ifrn;
956
957 /* Data part (defined just above) */
958 union iwreq_data u;
959 };
960
961 /* -------------------------- IOCTL DATA -------------------------- */
962 /*
963 * For those ioctl which want to exchange mode data that what could
964 * fit in the above structure...
965 */
966
967 /*
968 * Range of parameters
969 */
970
971 struct iw_range
972 {
973 /* Informative stuff (to choose between different interface) */
974 __u32 throughput; /* To give an idea... */
975 /* In theory this value should be the maximum benchmarked
976 * TCP/IP throughput, because with most of these devices the
977 * bit rate is meaningless (overhead an co) to estimate how
978 * fast the connection will go and pick the fastest one.
979 * I suggest people to play with Netperf or any benchmark...
980 */
981
982 /* NWID (or domain id) */
983 __u32 min_nwid; /* Minimal NWID we are able to set */
984 __u32 max_nwid; /* Maximal NWID we are able to set */
985
986 /* Old Frequency (backward compat - moved lower ) */
987 __u16 old_num_channels;
988 __u8 old_num_frequency;
989
990 /* Wireless event capability bitmasks */
991 __u32 event_capa[6];
992
993 /* signal level threshold range */
994 __s32 sensitivity;
995
996 /* Quality of link & SNR stuff */
997 /* Quality range (link, level, noise)
998 * If the quality is absolute, it will be in the range [0 ; max_qual],
999 * if the quality is dBm, it will be in the range [max_qual ; 0].
1000 * Don't forget that we use 8 bit arithmetics... */
1001 struct iw_quality max_qual; /* Quality of the link */
1002 /* This should contain the average/typical values of the quality
1003 * indicator. This should be the threshold between a "good" and
1004 * a "bad" link (example : monitor going from green to orange).
1005 * Currently, user space apps like quality monitors don't have any
1006 * way to calibrate the measurement. With this, they can split
1007 * the range between 0 and max_qual in different quality level
1008 * (using a geometric subdivision centered on the average).
1009 * I expect that people doing the user space apps will feedback
1010 * us on which value we need to put in each driver... */
1011 struct iw_quality avg_qual; /* Quality of the link */
1012
1013 /* Rates */
1014 __u8 num_bitrates; /* Number of entries in the list */
1015 __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
1016
1017 /* RTS threshold */
1018 __s32 min_rts; /* Minimal RTS threshold */
1019 __s32 max_rts; /* Maximal RTS threshold */
1020
1021 /* Frag threshold */
1022 __s32 min_frag; /* Minimal frag threshold */
1023 __s32 max_frag; /* Maximal frag threshold */
1024
1025 /* Power Management duration & timeout */
1026 __s32 min_pmp; /* Minimal PM period */
1027 __s32 max_pmp; /* Maximal PM period */
1028 __s32 min_pmt; /* Minimal PM timeout */
1029 __s32 max_pmt; /* Maximal PM timeout */
1030 __u16 pmp_flags; /* How to decode max/min PM period */
1031 __u16 pmt_flags; /* How to decode max/min PM timeout */
1032 __u16 pm_capa; /* What PM options are supported */
1033
1034 /* Encoder stuff */
1035 __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
1036 __u8 num_encoding_sizes; /* Number of entry in the list */
1037 __u8 max_encoding_tokens; /* Max number of tokens */
1038 /* For drivers that need a "login/passwd" form */
1039 __u8 encoding_login_index; /* token index for login token */
1040
1041 /* Transmit power */
1042 __u16 txpower_capa; /* What options are supported */
1043 __u8 num_txpower; /* Number of entries in the list */
1044 __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
1045
1046 /* Wireless Extension version info */
1047 __u8 we_version_compiled; /* Must be WIRELESS_EXT */
1048 __u8 we_version_source; /* Last update of source */
1049
1050 /* Retry limits and lifetime */
1051 __u16 retry_capa; /* What retry options are supported */
1052 __u16 retry_flags; /* How to decode max/min retry limit */
1053 __u16 r_time_flags; /* How to decode max/min retry life */
1054 __s32 min_retry; /* Minimal number of retries */
1055 __s32 max_retry; /* Maximal number of retries */
1056 __s32 min_r_time; /* Minimal retry lifetime */
1057 __s32 max_r_time; /* Maximal retry lifetime */
1058
1059 /* Frequency */
1060 __u16 num_channels; /* Number of channels [0; num - 1] */
1061 __u8 num_frequency; /* Number of entry in the list */
1062 struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
1063 /* Note : this frequency list doesn't need to fit channel numbers,
1064 * because each entry contain its channel index */
1065
1066 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1067
1068 /* More power management stuff */
1069 __s32 min_pms; /* Minimal PM saving */
1070 __s32 max_pms; /* Maximal PM saving */
1071 __u16 pms_flags; /* How to decode max/min PM saving */
1072
1073 /* All available modulations for driver (hw may support less) */
1074 __s32 modul_capa; /* IW_MODUL_* bit field */
1075
1076 /* More bitrate stuff */
1077 __u32 bitrate_capa; /* Types of bitrates supported */
1078 };
1079
1080 /*
1081 * Private ioctl interface information
1082 */
1083
1084 struct iw_priv_args
1085 {
1086 __u32 cmd; /* Number of the ioctl to issue */
1087 __u16 set_args; /* Type and number of args */
1088 __u16 get_args; /* Type and number of args */
1089 char name[IFNAMSIZ]; /* Name of the extension */
1090 };
1091
1092 /* ----------------------- WIRELESS EVENTS ----------------------- */
1093 /*
1094 * Wireless events are carried through the rtnetlink socket to user
1095 * space. They are encapsulated in the IFLA_WIRELESS field of
1096 * a RTM_NEWLINK message.
1097 */
1098
1099 /*
1100 * A Wireless Event. Contains basically the same data as the ioctl...
1101 */
1102 struct iw_event
1103 {
1104 __u16 len; /* Real lenght of this stuff */
1105 __u16 cmd; /* Wireless IOCTL */
1106 union iwreq_data u; /* IOCTL fixed payload */
1107 };
1108
1109 /* Size of the Event prefix (including padding and alignement junk) */
1110 #define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
1111 /* Size of the various events */
1112 #define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
1113 #define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
1114 #define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
1115 #define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
1116 #define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
1117 #define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
1118
1119 /* iw_point events are special. First, the payload (extra data) come at
1120 * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
1121 * we omit the pointer, so start at an offset. */
1122 #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
1123 (char *) NULL)
1124 #define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1125 IW_EV_POINT_OFF)
1126
1127 /* Size of the Event prefix when packed in stream */
1128 #define IW_EV_LCP_PK_LEN (4)
1129 /* Size of the various events when packed in stream */
1130 #define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
1131 #define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32))
1132 #define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
1133 #define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
1134 #define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
1135 #define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
1136 #define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4)
1137
1138 #endif /* _LINUX_WIRELESS_H */
+0
-128
src/lwe/wireless.7 less more
0 .\" Jean Tourrilhes - HPL - 2002 - 2004
1 .\" wireless.7
2 .\"
3 .TH WIRELESS 7 "4 March 2004" "wireless-tools" "Linux Programmer's Manual"
4 .\"
5 .\" NAME part
6 .\"
7 .SH NAME
8 wireless \- Wireless Tools and Wireless Extensions
9 .\"
10 .\" SYNOPSIS part
11 .\"
12 .SH SYNOPSIS
13 .B iwconfig
14 .br
15 .B iwpriv \-a
16 .br
17 .\"
18 .\" DESCRIPTION part
19 .\"
20 .SH DESCRIPTION
21 The
22 .B Wireless Extensions
23 is an API allowing you manipulate Wireless LAN networking interfaces.
24 It is composed of a variety of tools and configuration files. It is
25 documented in more detail in the Linux Wireless LAN Howto.
26 .br
27 The
28 .B Wireless Tools
29 are used to change the configuration of wireless LAN networking
30 interfaces on the fly, to get their current configuration, to get
31 statistics and diagnose them. They are described in their own man
32 page, see below for references.
33 .br
34 .B Wireless configuration
35 is specific to each Linux distribution. This man page will contain in
36 the future the configuration procedure for a few common
37 distributions. For the time being, check the file DISTRIBUTIONS.txt
38 included with the Wireless Tools package.
39 .\"
40 .\" DEBIAN 3.0 part
41 .\"
42 .SH DEBIAN 3.0
43 In Debian 3.0 (and later) you can configure wireless LAN networking
44 devices using the network configuration tool
45 .BR ifupdown (8).
46 .TP
47 .B File :
48 .I /etc/network/interfaces
49 .TP
50 .B Form :
51 .RI wireless\- "<function> <value>"
52 .br
53 wireless\-essid Home
54 .br
55 wireless\-mode Ad\-Hoc
56 .TP
57 .B See also :
58 .I /etc/network/if\-pre\-up.d/wireless\-tools
59 .br
60 .I /usr/share/doc/wireless\-tools/README.Debian
61 .\"
62 .\" SuSE 8.0 part
63 .\"
64 .SH SuSE 8.0
65 SuSE 8.0 (and later) has integrated wireless configuration in their
66 network scripts.
67 .TP
68 .B Tool :
69 .B Yast2
70 .TP
71 .B File :
72 .I /etc/sysconfig/network/wireless
73 .br
74 .I /etc/sysconfig/network/ifcfg\-*
75 .TP
76 .B Form :
77 .RI WIRELESS_ "<function>" = "<value>"
78 .br
79 WIRELESS_ESSID="Home"
80 .br
81 WIRELESS_MODE=Ad\-Hoc
82 .TP
83 .B See also :
84 man ifup
85 .br
86 info scpm
87 .\"
88 .\" PCMCIA part
89 .\"
90 .SH ORIGINAL PCMCIA SCRIPTS
91 If you are using the original configuration scripts from the Pcmcia
92 package, you can use this method.
93 .TP
94 .B File :
95 .I /etc/pcmcia/wireless.opts
96 .TP
97 .B Form :
98 *,*,*,*)
99 .br
100 ESSID="Home"
101 .br
102 MODE="Ad-Hoc"
103 .br
104 ;;
105 .TP
106 .B See also :
107 .I /etc/pcmcia/wireless
108 .br
109 File
110 .I PCMCIA.txt
111 part of Wireless Tools package
112 .\"
113 .\" AUTHOR part
114 .\"
115 .SH AUTHOR
116 Jean Tourrilhes \- [email protected]
117 .br
118 .I http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/
119 .\"
120 .\" SEE ALSO part
121 .\"
122 .SH SEE ALSO
123 .BR iwconfig (8),
124 .BR iwlist (8),
125 .BR iwspy (8),
126 .BR iwpriv (8),
127 .BR iwevent (8).
6969 /* Remove previous pin */
7070 wps_registrar_invalidate_pin(wps->wps->registrar, wps->uuid_e);
7171
72 /* Build a new pin */
73 pin = build_wps_pin();
74 if(pin)
72 int add_result = 0;
73 if (get_pin_string_mode())
7574 {
75 /* Use an arbitrary string as WPS pin */
76 pin = strdup(get_static_p1());
7677 /* Add the new pin */
77 if(wps_registrar_add_pin(wps->wps->registrar, NULL, (const u8 *) pin, PIN_SIZE, 0) != 0)
78 add_result = wps_registrar_add_pin(wps->wps->registrar, NULL, (const u8 *) pin, strlen(pin), 0);
79 }
80 else
81 {
82 /* Build a new pin */
83 pin = build_wps_pin();
84 if(pin)
7885 {
79 free(pin);
80 pin = NULL;
86 /* Add the new pin */
87 add_result = wps_registrar_add_pin(wps->wps->registrar, NULL, (const u8 *) pin, PIN_SIZE, 0);
8188 }
89 }
90 if(add_result != 0)
91 {
92 free(pin);
93 pin = NULL;
8294 }
8395
8496 return pin;
8282 if(get_session())
8383 {
8484 answer = 'y';
85 }
86
87 /*
88 * Do not restore the session when arbitrary string pin is specified.
89 */
90 if(get_pin_string_mode())
91 {
92 answer = 'n';
8593 }
8694
8795 if(stat(file, &wpstat) == 0)
180188 size_t write_size = 0;
181189 int attempts = 0, ret_val = 0, i = 0;
182190 struct wps_data *wps = NULL;
191 int pin_string;
183192
184193 wps = get_wps();
185194 bssid = mac2str(get_bssid(), '\0');
186195 pretty_bssid = mac2str(get_bssid(), ':');
196 pin_string = get_pin_string_mode();
187197
188198 if(wps)
189199 {
191201 essid = wps->essid;
192202 }
193203
194 if(!bssid || !pretty_bssid)
195 {
196 cprintf(CRITICAL, "[X] ERROR: Failed to save session data (memory error).\n");
204 if(!bssid || !pretty_bssid || pin_string)
205 {
206 if (pin_string)
207 {
208 cprintf(VERBOSE, "[*] String pin was specified, nothing to save.\n");
209 }
210 else
211 {
212 cprintf(CRITICAL, "[X] ERROR: Failed to save session data (memory error).\n");
213 }
197214 }
198215 else
199216 {
158158 fprintf(stderr, "\t-h, --help Show help\n");
159159
160160 fprintf(stderr, "\nAdvanced Options:\n");
161 fprintf(stderr, "\t-p, --pin=<wps pin> Use the specified 4 or 8 digit WPS pin\n");
161 fprintf(stderr, "\t-p, --pin=<wps pin> Use the specified pin (may be arbitrary string or 4/8 digit WPS pin)\n");
162162 fprintf(stderr, "\t-d, --delay=<seconds> Set the delay between pin attempts [%d]\n", DEFAULT_DELAY);
163163 fprintf(stderr, "\t-l, --lock-delay=<seconds> Set the time to wait if the AP locks WPS pin attempts [%d]\n", DEFAULT_LOCK_DELAY);
164164 fprintf(stderr, "\t-g, --max-attempts=<num> Quit after num pin attempts\n");