external/wireless-tools
修订版 | bcc23ab3dacbe0d30b7b5e8adb7badbe2e254a7d (tree) |
---|---|
时间 | 2016-10-12 05:49:10 |
作者 | chris-kirby <chris.kirby@hpe....> |
Commiter | chris-kirby |
v20
@@ -1,35 +1,66 @@ | ||
1 | +Very important note : | |
2 | +------------------- | |
3 | + This release of the Wireless Tools is not compatible with Wireless | |
4 | + Extensions earlier than 9. | |
5 | + Kernels that support this version of the Wireless Tools are listed | |
6 | + below. For all kernels before that, please use the version v19 of | |
7 | + the Wireless Tools. | |
8 | + If your kernel has the relevant Wireless Extensions but the tools | |
9 | + refuse to compile, then your kernel headers in /usr/include are | |
10 | + pointing to the wrong place (very common with Debian). | |
11 | + | |
1 | 12 | You need : |
2 | 13 | -------- |
3 | - o A kernel supporting wireless extensions | |
4 | - -> from 2.1.17 onward | |
5 | - -> from 2.0.30 onward | |
6 | - -> patch available for 1.2.13 | |
14 | + o Compiler and development environment | |
15 | + o A kernel supporting wireless extensions version 9 or higher | |
16 | + -> from 2.2.14 onward | |
17 | + -> from 2.3.24 onward | |
7 | 18 | Note : CONFIG_NET_RADIO must be enabled |
8 | - o Driver supporting wireless extensions | |
9 | - -> Wavelan isa from kernel 2.1.17 onward | |
10 | - -> Wavelan pcmcia from pcmcia 2.9.2 onward | |
11 | - -> Netwave pcmcia from pcmcia 2.9.12 onward | |
19 | + o A driver supporting wireless extensions | |
20 | + -> Wavelan isa from kernels above | |
21 | + -> Wavelan pcmcia from pcmcia 3.1.2 onward | |
22 | + -> Netwave pcmcia from pcmcia 3.1.2 onward | |
12 | 23 | -> Wavelan IEEE pcmcia drivers |
13 | 24 | -> Proxim RangeLan2/Symphony driver |
14 | 25 | -> Patch your favourite driver |
15 | 26 | Note : more recent kernels and drivers are likely to support |
16 | 27 | more wireless extension features... |
17 | 28 | |
29 | +Recommended versions : | |
30 | +-------------------- | |
31 | + This are the latest updates of the Wireless Extensions : | |
32 | + o Kernel (wireless extension definition) : | |
33 | + -> Kernel 2.2.14 onward | |
34 | + -> Kernel 2.3.24 onward | |
35 | + o Drivers with wireless extension support : | |
36 | + -> Wavelan isa from kernels above | |
37 | + -> Wavelan pcmcia from pcmcia 3.1.1 onward | |
38 | + -> Netwave pcmcia from pcmcia 3.1.2 onward | |
39 | + -> Wavelan IEEE pcmcia GPL driver (wvlan) 1.0.1 onward | |
40 | + -> Wavelan IEEE pcmcia binary driver (wavelan2) v4.00 onward | |
41 | + -> Proxim RangeLan2/Symphony driver 1.4.3 onward | |
42 | + | |
18 | 43 | Compile wireless tools : |
19 | 44 | ---------------------- |
20 | - In theory, a make should suffice. | |
21 | - In practice, there is big troubles with the headers. Depending | |
22 | -on which version of the kernel headers (might be different from | |
23 | -kernel) and library headers you have, you need to play with the | |
24 | -options buried in iwcommon.h. | |
45 | + In theory, a "make" should suffice. | |
46 | + In practice, there is big troubles with the headers. If you | |
47 | +have glibc and kernel 2.2.X headers, that should be all | |
48 | +right. Depending on which version of the kernel headers (might be | |
49 | +different from kernel) and library headers you have, you need to play | |
50 | +with the options buried in iwcommon.h. | |
51 | + Note : as some internal data structures change from kernel to | |
52 | +kernel, you are advised to not use the precompiled version but to | |
53 | +recompile your own. | |
54 | + "xwireless" is not currently in a compilable state. | |
25 | 55 | |
56 | +Installation : | |
57 | +------------ | |
58 | + I advise to copy the executable (iwconfig, iwspy and iwpriv) | |
59 | +in /usr/local/bin or /usr/local/sbin. The man pages (iwconfig.8, | |
60 | +iwspy.8 and iwpriv.8) should be copied in /usr/local/man/man8 or | |
61 | +/usr/man/man8. | |
26 | 62 | |
27 | -This package was originally created by: | |
28 | - | |
29 | - Jean <jt@hpl.hp.com> | |
30 | 63 | |
31 | -And is now being maintained by: | |
32 | - Justin Seger <jseger@media.mit.edu> | |
64 | +List of contributors and changelog is in iwcommon.h. | |
33 | 65 | |
34 | -It seem that I've been taking over ! | |
35 | 66 | Jean <jt@hpl.hp.com> |
@@ -3,29 +3,47 @@ the Wireless Extensions. The Wireless Extension is an interface | ||
3 | 3 | allowing you to set Wireless LAN specific parameters and get the |
4 | 4 | specific stats. |
5 | 5 | |
6 | +INSTALL | |
7 | +------- | |
8 | + Installation instruction and requirements. | |
9 | + | |
10 | +man pages (iwconfig.8, iwpriv.8, iwspy.8) | |
11 | +--------- | |
12 | + As far as I know, the man pages are the most complete, up to | |
13 | +date and accurate documentation of the wireless tools, and you really | |
14 | +should read them. | |
15 | + They can either be copied in a location where the command | |
16 | +"man" will find them, or can be read with the command : | |
17 | + nroff -man xxx.8 | more | |
18 | + | |
19 | +web page | |
20 | +-------- | |
21 | + You'll find a lot of useful info on : | |
22 | + http://web.hpl.hp.com/personal/Jean_Tourrilhes/Linux/ | |
23 | + | |
6 | 24 | iwconfig.c |
7 | 25 | ---------- |
8 | - The main wireless tool. Used for device configuration. | |
9 | - You need of course to compile it. | |
10 | - This also includes the functionality previously contained in iwpriv.c. | |
11 | - It allows you to access device specific extensions. | |
26 | + The main wireless tool. Used for device configuration and to see | |
27 | + the most common parameters. | |
12 | 28 | |
13 | 29 | iwspy.c |
14 | 30 | ------- |
15 | 31 | Mobile IP support test and allow get get stats per MAC address |
16 | - (instead of globally). | |
32 | + (instead of globally). Also display available bit rates and | |
33 | + frequencies. | |
17 | 34 | |
18 | 35 | iwpriv.c |
19 | 36 | -------- |
20 | - Manipulate driver private ioctls. | |
37 | + Manipulate driver private ioctls (all that is not available in | |
38 | + iwconfig). These are device specific parameters. | |
21 | 39 | |
22 | 40 | xwireless.c |
23 | 41 | ----------- |
24 | 42 | Graphical tool for the Netwave created by Dag Brattli <dagb@cs.uit.no> |
25 | 43 | |
26 | 44 | |
27 | - The man page should describe adequately the behaviour of the tools. | |
28 | 45 | The list of changes, credits and errata notes are in |
29 | -iwcommon.h. Compilation might be tricky. | |
46 | +iwcommon.h. Compilation might be tricky, see iwcommon.h for header | |
47 | +problems... | |
30 | 48 | |
31 | 49 | Jean <jt@hpl.hp.com> |
@@ -1,96 +0,0 @@ | ||
1 | -/* This whole file is flaky */ | |
2 | -/* This is all we need to compile and can't find only in linux headers. | |
3 | - * So, I did copy past here... | |
4 | - */ | |
5 | -#define __u8 unsigned char | |
6 | -#define __u16 unsigned short | |
7 | -#define __u32 unsigned long /* Hum, and on Alpha ? */ | |
8 | -#define __u64 unsigned long long /* Unsure about this one */ | |
9 | - | |
10 | -#define IFNAMSIZ 16 | |
11 | -#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ | |
12 | -#define ETH_ALEN 6 /* Octets in one ethernet addr */ | |
13 | - | |
14 | -/* | |
15 | - * Interface request structure used for socket | |
16 | - * ioctl's. All interface ioctl's must have parameter | |
17 | - * definitions which begin with ifr_name. The | |
18 | - * remainder may be interface specific. | |
19 | - */ | |
20 | -struct ifreq | |
21 | -{ | |
22 | -#define IFHWADDRLEN 6 | |
23 | -#define IFNAMSIZ 16 | |
24 | - union | |
25 | - { | |
26 | - char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
27 | - } ifr_ifrn; | |
28 | - | |
29 | - union { | |
30 | - struct sockaddr ifru_addr; | |
31 | - struct sockaddr ifru_dstaddr; | |
32 | - struct sockaddr ifru_broadaddr; | |
33 | - struct sockaddr ifru_netmask; | |
34 | - struct sockaddr ifru_hwaddr; | |
35 | - short ifru_flags; | |
36 | - int ifru_metric; | |
37 | - int ifru_mtu; | |
38 | -#if 0 | |
39 | - struct ifmap ifru_map; | |
40 | -#endif | |
41 | - char ifru_slave[IFNAMSIZ]; /* Just fits the size */ | |
42 | - caddr_t ifru_data; | |
43 | - } ifr_ifru; | |
44 | -}; | |
45 | -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ | |
46 | -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ | |
47 | -#define ifr_addr ifr_ifru.ifru_addr /* address */ | |
48 | - | |
49 | -/* | |
50 | - * Structure used in SIOCGIFCONF request. | |
51 | - * Used to retrieve interface configuration | |
52 | - * for machine (useful for programs which | |
53 | - * must know all networks accessible). | |
54 | - */ | |
55 | -struct ifconf | |
56 | -{ | |
57 | - int ifc_len; /* size of buffer */ | |
58 | - union | |
59 | - { | |
60 | - caddr_t ifcu_buf; | |
61 | - struct ifreq *ifcu_req; | |
62 | - } ifc_ifcu; | |
63 | -}; | |
64 | -#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ | |
65 | -#define ifc_req ifc_ifcu.ifcu_req /* array of structures */ | |
66 | - | |
67 | -/* Internet address. */ | |
68 | -struct in_addr { | |
69 | - __u32 s_addr; | |
70 | -}; | |
71 | - | |
72 | -/* Address to accept any incoming messages. */ | |
73 | -#define INADDR_ANY ((unsigned long int) 0x00000000) | |
74 | - | |
75 | -/* Structure describing an Internet (IP) socket address. */ | |
76 | -#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ | |
77 | -struct sockaddr_in { | |
78 | - short int sin_family; /* Address family */ | |
79 | - unsigned short int sin_port; /* Port number */ | |
80 | - struct in_addr sin_addr; /* Internet address */ | |
81 | - | |
82 | - /* Pad to size of `struct sockaddr'. */ | |
83 | - unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - | |
84 | - sizeof(unsigned short int) - sizeof(struct in_addr)]; | |
85 | -}; | |
86 | - | |
87 | -#define ATF_COM 0x02 /* completed entry (ha valid) */ | |
88 | -/* ARP ioctl request. */ | |
89 | -struct arpreq { | |
90 | - struct sockaddr arp_pa; /* protocol address */ | |
91 | - struct sockaddr arp_ha; /* hardware address */ | |
92 | - int arp_flags; /* flags */ | |
93 | - struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ | |
94 | - char arp_dev[16]; | |
95 | -}; | |
96 | - |
@@ -68,6 +68,27 @@ | ||
68 | 68 | * o I think I now got set/get char strings right in [iwpriv] |
69 | 69 | * (From Thomas Ekstrom <tomeck@thelogic.com>) |
70 | 70 | * o Fix a very obscure bug in [iwspy] |
71 | + * | |
72 | + * wireless 20 : | |
73 | + * ----------- | |
74 | + * (From Jean Tourrilhes) | |
75 | + * o Remove all #ifdef WIRELESS ugliness, but add a #error : | |
76 | + * we require Wireless Extensions 9 or nothing ! [all] | |
77 | + * o Switch to new 'nwid' definition (specific -> iw_param) [iwconfig] | |
78 | + * o Rewriten totally the encryption support [iwconfig] | |
79 | + * - Multiple keys, through key index | |
80 | + * - Flexible/multiple key size, and remove 64bits upper limit | |
81 | + * - Open/Restricted modes | |
82 | + * - Enter keys as ASCII strings | |
83 | + * o List key sizes supported and all keys in [iwspy] | |
84 | + * o Mode of operation support (ad-hoc, managed...) [iwconfig] | |
85 | + * o Use '=' to indicate fixed instead of ugly '(f)' [iwconfig] | |
86 | + * o Ability to disable RTS & frag (off), now the right way [iwconfig] | |
87 | + * o Auto as an input modifier for bitrate [iwconfig] | |
88 | + * o Power Management support [iwconfig] | |
89 | + * - set timeout or period and its value | |
90 | + * - Reception mode (unicast/multicast/all) | |
91 | + * o Updated man pages with all that ;-) | |
71 | 92 | */ |
72 | 93 | |
73 | 94 | /* ----------------------------- TODO ----------------------------- */ |
@@ -76,11 +97,14 @@ | ||
76 | 97 | * |
77 | 98 | * iwconfig : |
78 | 99 | * -------- |
79 | - * Use new 802.11 parameters (rate, rts, frag)... | |
100 | + * Make disable a per encryption key modifier if some hardware | |
101 | + * requires it. | |
102 | + * Should not mention "Access Point" but something different when | |
103 | + * in ad-hoc mode. | |
80 | 104 | * |
81 | 105 | * iwpriv : |
82 | 106 | * ------ |
83 | - * ? | |
107 | + * Remove 'port' and 'roam' cruft now that we have mode in iwconfig | |
84 | 108 | * |
85 | 109 | * iwspy : |
86 | 110 | * ----- |
@@ -88,7 +112,11 @@ | ||
88 | 112 | * |
89 | 113 | * Doc & man pages : |
90 | 114 | * --------------- |
91 | - * ? | |
115 | + * Update main doc. | |
116 | + * | |
117 | + * Other : | |
118 | + * ----- | |
119 | + * What about some graphical tools ? | |
92 | 120 | */ |
93 | 121 | |
94 | 122 | /***************************** INCLUDES *****************************/ |
@@ -109,53 +137,39 @@ | ||
109 | 137 | /* This is our header selection. Try to hide the mess and the misery :-( |
110 | 138 | * Please choose only one of the define... |
111 | 139 | */ |
112 | -#define KER2_2_HEADERS /* Kernel 2.2.X + Glibc - ok for most people */ | |
113 | -#undef LINUX_HEADERS /* Kernel 2.0.X + Glibc - Debian 2.0, RH5 */ | |
114 | -#undef LIBC5_HEADERS /* Kernel 2.0.X + libc5 - old systems */ | |
115 | -#undef PRIVATE_HEADERS /* Ugly last resort case */ | |
140 | +/* Kernel headers 2.0.X + Glibc 2.0 - Debian 2.0, RH5 | |
141 | + * Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH6.1 */ | |
142 | +#define GLIBC_HEADERS | |
116 | 143 | |
117 | -#ifdef KER2_2_HEADERS | |
118 | -#include <socketbits.h> | |
119 | -#include <linux/if_arp.h> /* For ARPHRD_ETHER */ | |
120 | -#include <linux/socket.h> /* For AF_INET & struct sockaddr */ | |
121 | -#include <linux/in.h> /* For struct sockaddr_in */ | |
144 | +/* Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 */ | |
145 | +#undef KLUDGE_HEADERS | |
122 | 146 | |
123 | -/* Wireless extensions */ | |
124 | -#include <linux/wireless.h> | |
147 | +/* Kernel headers 2.0.X + libc5 - old systems */ | |
148 | +#undef LIBC5_HEADERS | |
125 | 149 | |
126 | -#endif /* KER2_2_HEADERS */ | |
150 | +#ifdef KLUDGE_HEADERS | |
151 | +#include <socketbits.h> | |
152 | +#endif /* KLUDGE_HEADERS */ | |
127 | 153 | |
128 | -#ifdef LINUX_HEADERS | |
154 | +#if defined(KLUDGE_HEADERS) || defined(GLIBC_HEADERS) | |
129 | 155 | #include <linux/if_arp.h> /* For ARPHRD_ETHER */ |
130 | 156 | #include <linux/socket.h> /* For AF_INET & struct sockaddr */ |
131 | 157 | #include <linux/in.h> /* For struct sockaddr_in */ |
132 | - | |
133 | -/* Wireless extensions */ | |
134 | -#include <linux/wireless.h> | |
135 | - | |
136 | -#endif /* LINUX_HEADERS */ | |
158 | +#endif /* KLUDGE_HEADERS || GLIBC_HEADERS */ | |
137 | 159 | |
138 | 160 | #ifdef LIBC5_HEADERS |
139 | 161 | #include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */ |
140 | 162 | #include <linux/if_arp.h> /* For ARPHRD_ETHER */ |
141 | 163 | #include <linux/in.h> /* For struct sockaddr_in */ |
142 | - | |
143 | -/* Wireless extensions */ | |
144 | -#include <linux/wireless.h> | |
145 | - | |
146 | 164 | #endif /* LIBC5_HEADERS */ |
147 | 165 | |
148 | -#ifdef PRIVATE_HEADERS | |
149 | -#include <sys/types.h> | |
150 | -#include <sys/socket.h> | |
151 | -#include <socketbits.h> | |
152 | -#include "compat.h" /* Don't ask ! */ | |
153 | - | |
154 | 166 | /* Wireless extensions */ |
155 | -#include "wireless.h" | |
156 | - | |
157 | -#endif /* PRIVATE_HEADERS */ | |
167 | +#include <linux/wireless.h> | |
158 | 168 | |
169 | +#if WIRELESS_EXT < 8 | |
170 | +#error "Wireless Extension v9 or newer required :-(\n\ | |
171 | +Use Wireless Tools v19 or update your kernel headers" | |
172 | +#endif | |
159 | 173 | |
160 | 174 | /****************************** DEBUG ******************************/ |
161 | 175 |
@@ -167,19 +181,12 @@ | ||
167 | 181 | #define MEGA 1e6 |
168 | 182 | #define GIGA 1e9 |
169 | 183 | |
170 | -/* Some hack */ | |
171 | -#ifndef IW_ESSID_MAX_SIZE | |
172 | -#define IW_ESSID_MAX_SIZE 32 /* Should be in wireless.h */ | |
173 | -#endif | |
174 | -#ifndef IW_MAX_AP | |
175 | -#define IW_MAX_AP 8 /* Should be in wireless.h */ | |
176 | -#endif | |
177 | - | |
178 | 184 | /****************************** TYPES ******************************/ |
179 | 185 | |
180 | 186 | /* Shortcuts */ |
181 | 187 | typedef struct iw_statistics iwstats; |
182 | 188 | typedef struct iw_range iwrange; |
189 | +typedef struct iw_param iwparam; | |
183 | 190 | typedef struct iw_freq iwfreq; |
184 | 191 | typedef struct iw_priv_args iwprivargs; |
185 | 192 | typedef struct sockaddr sockaddr; |
@@ -189,15 +196,15 @@ typedef struct wireless_info | ||
189 | 196 | { |
190 | 197 | char name[IFNAMSIZ]; /* Wireless/protocol name */ |
191 | 198 | int has_nwid; |
192 | - int nwid_on; | |
193 | - u_long nwid; /* Network ID */ | |
199 | + iwparam nwid; /* Network ID */ | |
194 | 200 | int has_freq; |
195 | 201 | float freq; /* Frequency/channel */ |
196 | 202 | int has_sens; |
197 | - int sens; /* sensitivity */ | |
198 | - int has_enc; | |
199 | - int enc_method; /* encoding method or off */ | |
200 | - long long enc_key; /* key used */ | |
203 | + iwparam sens; /* sensitivity */ | |
204 | + int has_key; | |
205 | + unsigned char key[IW_ENCODING_TOKEN_MAX]; /* Encoding key used */ | |
206 | + int key_size; /* Number of bytes */ | |
207 | + int key_flags; /* Various flags */ | |
201 | 208 | int has_essid; |
202 | 209 | int essid_on; |
203 | 210 | char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */ |
@@ -206,14 +213,15 @@ typedef struct wireless_info | ||
206 | 213 | int has_ap_addr; |
207 | 214 | sockaddr ap_addr; /* Access point address */ |
208 | 215 | int has_bitrate; |
209 | - long bitrate; /* Bit rate in bps */ | |
210 | - int bitrate_fixed; /* Fixed or auto */ | |
216 | + iwparam bitrate; /* Bit rate in bps */ | |
211 | 217 | int has_rts; |
212 | - long rts; /* RTS threshold in bytes */ | |
213 | - int rts_fixed; /* Fixed or auto */ | |
218 | + iwparam rts; /* RTS threshold in bytes */ | |
214 | 219 | int has_frag; |
215 | - long frag; /* Fragmentation threshold in bytes */ | |
216 | - int frag_fixed; /* Fixed or auto */ | |
220 | + iwparam frag; /* Fragmentation threshold in bytes */ | |
221 | + int has_mode; | |
222 | + int mode; /* Operation mode */ | |
223 | + int has_power; | |
224 | + iwparam power; /* Power management parameters */ | |
217 | 225 | |
218 | 226 | /* Stats */ |
219 | 227 | iwstats stats; |
@@ -15,9 +15,11 @@ iwconfig \- configure a wireless network interface | ||
15 | 15 | .br |
16 | 16 | .BI "iwconfig " interface " [essid " X "] [nwid " N "] [freq " F "] [channel " C ] |
17 | 17 | .br |
18 | -.BI " [sens " S "] [enc " E "] [ap " A "] [nick " NN ] | |
18 | +.BI " [sens " S "] [mode " M "] [ap " A "] [nick " NN ] | |
19 | 19 | .br |
20 | 20 | .BI " [rate " R "] [rts " RT "] [frag " FT ] |
21 | +.br | |
22 | +.BI " [enc " E "] [key " K "] [power " P ] | |
21 | 23 | .\" |
22 | 24 | .\" DESCRIPTION part |
23 | 25 | .\" |
@@ -51,8 +53,14 @@ As opposed to the NWID which defines a single cell, the ESSID defines | ||
51 | 53 | a group of cell connected via repeaters or infrastructure, where the |
52 | 54 | user may roam. With some card, you may disable the ESSID checking |
53 | 55 | (ESSID promiscuous) with |
54 | -.IR off " (and " on | |
56 | +.IR off " or " any " (and " on | |
55 | 57 | to reenable it). |
58 | +.br | |
59 | +.B Examples : | |
60 | +.br | |
61 | +.I " iwconfig eth0 essid any" | |
62 | +.br | |
63 | +.I " iwconfig eth0 essid ""My Network"" | |
56 | 64 | .TP |
57 | 65 | .BR nwid / domain |
58 | 66 | Set the Network ID (in some products it is also called Domain ID). As |
@@ -62,11 +70,17 @@ identify nodes belonguing to the same cell. With some card, you may | ||
62 | 70 | disable the Network ID checking (NWID promiscuous) with |
63 | 71 | .IR off " (and " on |
64 | 72 | to reenable it). |
73 | +.br | |
74 | +.B Examples : | |
75 | +.br | |
76 | +.I " iwconfig eth0 nwid AB34 | |
77 | +.br | |
78 | +.I " iwconfig eth0 nwid off" | |
65 | 79 | .TP |
66 | 80 | .BR freq / channel |
67 | 81 | Set the operating frequency or channel in the device. Value below 1000 |
68 | 82 | are the channel number, value over this is the frequency in Hz. You |
69 | -must prepend the suffix k, M or G to the value (for example, "2.46G" | |
83 | +must append the suffix k, M or G to the value (for example, "2.46G" | |
70 | 84 | for 2.46 GHz frequency), or add enough '0'. |
71 | 85 | .br |
72 | 86 | Channels are usually numbered starting at 1, |
@@ -75,6 +89,12 @@ and you may use | ||
75 | 89 | to get the total number of channels and list the available |
76 | 90 | frequencies. Depending on regulations, some frequencies/channels may |
77 | 91 | not be available. |
92 | +.br | |
93 | +.B Examples : | |
94 | +.br | |
95 | +.I " iwconfig eth0 freq 2.422G" | |
96 | +.br | |
97 | +.I " iwconfig eth0 channel 3" | |
78 | 98 | .TP |
79 | 99 | .B sens |
80 | 100 | Set the sensitivity threshold. This is the lowest signal level for |
@@ -88,40 +108,73 @@ With some hardware, this parameter also control the defer threshold | ||
88 | 108 | (lowest signal level for which we consider the channel busy) and the |
89 | 109 | handover threshold (lowest signal level where we stay associated with |
90 | 110 | the current access point). |
111 | +.br | |
112 | +.B Example : | |
113 | +.br | |
114 | +.I " iwconfig eth0 sens -80" | |
91 | 115 | .TP |
92 | -.B enc | |
93 | -Set the encryption or scrambing key (the syntax is | |
94 | -.IR XXXX-XXXX-XXXX-XXXX " or " XXXXXXXX ). | |
95 | -Used also to control the encryption feature | |
96 | -.RI ( on / off ). | |
116 | +.B mode | |
117 | +Set the operating mode of the device, which depends on the network | |
118 | +topology. The mode can be | |
119 | +.I Ad-hoc | |
120 | +(network composed of only one cell and without Access Point), | |
121 | +.I Managed | |
122 | +(network composed of many cells, with roaming or with an Access Point), | |
123 | +.I Master | |
124 | +(the node is the synchronisation master or act as an Access Point), | |
125 | +.I Repeater | |
126 | +(the node forward packets on the air), | |
127 | +.I Secondary | |
128 | +(the node act as a backup master/repeater) or | |
129 | +.IR Auto . | |
130 | +.br | |
131 | +.B Example : | |
132 | +.br | |
133 | +.I " iwconfig eth0 mode Managed" | |
97 | 134 | .TP |
98 | 135 | .B ap |
99 | 136 | Register to the Access Point given by the address, if it is |
100 | 137 | possible. When the quality of the connection goes too low, the driver |
101 | 138 | may revert back to automatic mode. |
139 | +.br | |
140 | +.B Example : | |
141 | +.br | |
142 | +.I " iwconfig eth0 ap 00:60:1D:01:23:45" | |
102 | 143 | .TP |
103 | -.BR nick [ name ] | |
144 | +.BR nick [name] | |
104 | 145 | Set the nickname, or the station name. Most 802.11 products do define |
105 | 146 | it, but this is not used as far as the protocols (MAC, IP, TCP) are |
106 | 147 | concerned and completely accessory as far as configuration goes. In |
107 | 148 | fact only some diagnostic tools may use it. |
149 | +.br | |
150 | +.B Example : | |
151 | +.br | |
152 | +.I " iwconfig eth0 nickname ""My Linux Node"" | |
108 | 153 | .TP |
109 | -.BR rate / bit [ rate ] | |
154 | +.BR rate / bit [rate] | |
110 | 155 | For cards supporting multiple bit rates, set the bit-rate in b/s. The |
111 | 156 | bit-rate is the speed at which bits are transmitted over the medium, |
112 | 157 | the user speed of the link is lower due to medium sharing and |
113 | 158 | overhead. |
114 | 159 | .br |
115 | -You must prepend the suffix k, M or G to the value (decimal multiplier | |
160 | +You must append the suffix k, M or G to the value (decimal multiplier | |
116 | 161 | : 10^3, 10^6 and 10^9 b/s), or add enough '0'. Values below 1000 are |
117 | 162 | card specific, usually an index in the bit-rate list. Use |
118 | 163 | .I auto |
119 | 164 | to select the automatic bit-rate mode (fallback to lower rate on noisy |
120 | 165 | channels), which is the default for most cards, and |
121 | 166 | .I fixed |
122 | -to revert back to fixed setting. | |
167 | +to revert back to fixed setting. If you specify a bit-rate value and append | |
168 | +.IR auto , | |
169 | +the driver will use all bit lower and equal than this value. | |
170 | +.br | |
171 | +.B Examples : | |
172 | +.br | |
173 | +.I " iwconfig eth0 rate 11M" | |
174 | +.br | |
175 | +.I " iwconfig eth0 rate auto" | |
123 | 176 | .TP |
124 | -.BR rts [ _threshold ] | |
177 | +.BR rts [_threshold] | |
125 | 178 | RTS/CTS adds a handshake before each packet transmission to make sure |
126 | 179 | that the channel is clear. This adds overhead, but increase |
127 | 180 | performance in case of hidden nodes or large number of active |
@@ -129,14 +182,89 @@ nodes. This parameters set the size of the smallest packet for which | ||
129 | 182 | the node sends RTS, a value equal to the maximum packet size disable |
130 | 183 | the scheme. You may also set this parameter to |
131 | 184 | .IR auto ", " fixed " or " off . |
185 | +.br | |
186 | +.B Examples : | |
187 | +.br | |
188 | +.I " iwconfig eth0 rts 250" | |
189 | +.br | |
190 | +.I " iwconfig eth0 rts off" | |
132 | 191 | .TP |
133 | -.BR frag [ mentation_threshold ] | |
192 | +.BR frag [mentation_threshold] | |
134 | 193 | Fragmentation allow to split a IP packet in a burst of smaller |
135 | 194 | fragments transmitted on the medium. In most cases this adds overhead, |
136 | 195 | but in very noisy environment this reduce the error penalty. This |
137 | 196 | parameter set the maximum fragment size, a value equal to the maximum |
138 | 197 | packet size disable the scheme. You may also set this parameter to |
139 | 198 | .IR auto ", " fixed " or " off . |
199 | +.br | |
200 | +.B Examples : | |
201 | +.br | |
202 | +.I " iwconfig eth0 frag 512" | |
203 | +.br | |
204 | +.I " iwconfig eth0 frag off" | |
205 | +.TP | |
206 | +.BR key / enc [ryption] | |
207 | +Used to manipulate encryption or scrambling keys and encryption mode. | |
208 | +.br | |
209 | +To set the current encryption key, just enter the key in hex digits as | |
210 | +.IR XXXX-XXXX-XXXX-XXXX " or " XXXXXXXX . | |
211 | +To set a key other than the current key, append | |
212 | +.I [index] | |
213 | +to the key itself. You can also enter the key as an ASCII string by | |
214 | +using the | |
215 | +.I s: | |
216 | +prefix. | |
217 | +.br | |
218 | +To change which key is the current active key, just enter | |
219 | +.I [index] | |
220 | +(without entering any key value). | |
221 | +.br | |
222 | +.IR off " and " on | |
223 | +disable and reenable encryption, | |
224 | +.I open | |
225 | +set the system in open mode (accept non-encrypted packets) and | |
226 | +.I restricted | |
227 | +discard non-encrypted packets. | |
228 | +.br | |
229 | +.B Examples : | |
230 | +.br | |
231 | +.I " iwconfig eth0 key 0123-4567-89" | |
232 | +.br | |
233 | +.I " iwconfig eth0 key s:password [2]" | |
234 | +.br | |
235 | +.I " iwconfig eth0 key [2] open" | |
236 | +.br | |
237 | +.I " iwconfig eth0 key off" | |
238 | +.TP | |
239 | +.BR power | |
240 | +Used to manipulate power management scheme parameters and mode. | |
241 | +.br | |
242 | +To set the period between wake up, enter | |
243 | +.IR "period `value'" . | |
244 | +To set the timeout before going back to sleep, enter | |
245 | +.IR "timeout `value'" . | |
246 | +By defaults, those values are in seconds, append the suffix m or u to | |
247 | +specify values un milliseconds or microseconds. | |
248 | +.br | |
249 | +.IR off " and " on | |
250 | +disable and reenable power management. Finally, you may set the power | |
251 | +management mode to | |
252 | +.I all | |
253 | +(receive all packets), | |
254 | +.I unicast | |
255 | +(receive unicast packets only, discard multicast and broadcast) and | |
256 | +.I multicast | |
257 | +(receive multicast and broadcast only, discard unicast packets). | |
258 | +.br | |
259 | +.B Examples : | |
260 | +.br | |
261 | +.I " iwconfig eth0 power period 2" | |
262 | +.br | |
263 | +.I " iwconfig eth0 power 500m unicast" | |
264 | +.br | |
265 | +.I " iwconfig eth0 power timeout 300u all" | |
266 | +.br | |
267 | +.I " iwconfig eth0 power off" | |
140 | 268 | .\" |
141 | 269 | .\" DISPLAY part |
142 | 270 | .\" |
@@ -154,16 +282,27 @@ the | ||
154 | 282 | (or channel), the |
155 | 283 | .BR sensitivity , |
156 | 284 | the |
285 | +.B mode | |
286 | +of operation, the | |
157 | 287 | .B Access Point |
158 | 288 | address, the |
159 | 289 | .B bit-rate |
160 | -(with | |
161 | -.B (f) | |
162 | -if fixed), the | |
290 | +the | |
163 | 291 | .BR "RTS threshold" ", the " "fragmentation threshold" , |
164 | -and the | |
292 | +the | |
165 | 293 | .B encryption key |
166 | -(depending on availability). See above for explanations. | |
294 | +and the | |
295 | +.B power management | |
296 | +settings (depending on availability). | |
297 | +.br | |
298 | +See above for explanations of what these parameters mean. | |
299 | +.br | |
300 | +If the label for bitrate is followed by | |
301 | +.RB ` = ', | |
302 | +it means that the parameter is fixed and forced to that value, if it | |
303 | +is followed by | |
304 | +.RB ` : ' | |
305 | +it is only the current value (device in normal auto mode). | |
167 | 306 | .PP |
168 | 307 | If |
169 | 308 | .I /proc/net/wireless |
@@ -172,7 +311,8 @@ exists, | ||
172 | 311 | will also display its content : |
173 | 312 | .TP |
174 | 313 | .B Link quality |
175 | -Quality of the link or the modulation (how good the received signal is). | |
314 | +Quality of the link or the modulation (what is the level of contention | |
315 | +or interference, or how good the received signal is). | |
176 | 316 | .TP |
177 | 317 | .B Signal level |
178 | 318 | Received signal strength (how strong the received signal is). |
@@ -193,7 +333,7 @@ Other packets lost in relation with specific wireless operations. | ||
193 | 333 | .\" AUTHOR part |
194 | 334 | .\" |
195 | 335 | .SH AUTHOR |
196 | -Jean Tourrilhes \- jt@hplb.hpl.hp.com | |
336 | +Jean Tourrilhes \- jt@hpl.hp.com | |
197 | 337 | .\" |
198 | 338 | .\" FILES part |
199 | 339 | .\" |
@@ -10,6 +10,14 @@ | ||
10 | 10 | |
11 | 11 | #include "iwcommon.h" /* Header */ |
12 | 12 | |
13 | +/**************************** VARIABLES ****************************/ | |
14 | +char * operation_mode[] = { "Auto", | |
15 | + "Ad-Hoc", | |
16 | + "Managed", | |
17 | + "Master", | |
18 | + "Repeater", | |
19 | + "Secondary" }; | |
20 | + | |
13 | 21 | /************************* MISC SUBROUTINES **************************/ |
14 | 22 | |
15 | 23 | /*------------------------------------------------------------------*/ |
@@ -43,40 +51,59 @@ static int | ||
43 | 51 | iw_getstats(char * ifname, |
44 | 52 | iwstats * stats) |
45 | 53 | { |
46 | - FILE *f=fopen("/proc/net/wireless","r"); | |
47 | - char buf[256]; | |
48 | - char *bp; | |
54 | + FILE * f=fopen("/proc/net/wireless","r"); | |
55 | + char buf[256]; | |
56 | + char * bp; | |
57 | + int t; | |
49 | 58 | if(f==NULL) |
50 | - return -1; | |
59 | + return -1; | |
60 | + /* Loop on all devices */ | |
51 | 61 | while(fgets(buf,255,f)) |
52 | - { | |
53 | - bp=buf; | |
54 | - while(*bp&&isspace(*bp)) | |
55 | - bp++; | |
56 | - if(strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':') | |
62 | + { | |
63 | + bp=buf; | |
64 | + while(*bp&&isspace(*bp)) | |
65 | + bp++; | |
66 | + /* Is it the good device ? */ | |
67 | + if(strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':') | |
57 | 68 | { |
58 | - bp=strchr(bp,':'); | |
59 | - bp++; | |
60 | - bp = strtok(bp, " ."); | |
61 | - sscanf(bp, "%X", (unsigned int *)&stats->status); | |
62 | - bp = strtok(NULL, " ."); | |
63 | - sscanf(bp, "%d", (unsigned int *)&stats->qual.qual); | |
64 | - bp = strtok(NULL, " ."); | |
65 | - sscanf(bp, "%d", (unsigned int *)&stats->qual.level); | |
66 | - bp = strtok(NULL, " ."); | |
67 | - sscanf(bp, "%d", (unsigned int *)&stats->qual.noise); | |
68 | - bp = strtok(NULL, " ."); | |
69 | - sscanf(bp, "%d", &stats->discard.nwid); | |
70 | - bp = strtok(NULL, " ."); | |
71 | - sscanf(bp, "%d", &stats->discard.code); | |
72 | - bp = strtok(NULL, " ."); | |
73 | - sscanf(bp, "%d", &stats->discard.misc); | |
74 | - fclose(f); | |
75 | - return 0; | |
69 | + /* Skip ethX: */ | |
70 | + bp=strchr(bp,':'); | |
71 | + bp++; | |
72 | + /* -- status -- */ | |
73 | + bp = strtok(bp, " "); | |
74 | + sscanf(bp, "%X", &t); | |
75 | + stats->status = (unsigned short) t; | |
76 | + /* -- link quality -- */ | |
77 | + bp = strtok(NULL, " "); | |
78 | + if(strchr(bp,'.') != NULL) | |
79 | + stats->qual.updated |= 1; | |
80 | + sscanf(bp, "%d", &t); | |
81 | + stats->qual.qual = (unsigned char) t; | |
82 | + /* -- signal level -- */ | |
83 | + bp = strtok(NULL, " "); | |
84 | + if(strchr(bp,'.') != NULL) | |
85 | + stats->qual.updated |= 2; | |
86 | + sscanf(bp, "%d", &t); | |
87 | + stats->qual.level = (unsigned char) t; | |
88 | + /* -- noise level -- */ | |
89 | + bp = strtok(NULL, " "); | |
90 | + if(strchr(bp,'.') != NULL) | |
91 | + stats->qual.updated += 4; | |
92 | + sscanf(bp, "%d", &t); | |
93 | + stats->qual.noise = (unsigned char) t; | |
94 | + /* -- discarded packets -- */ | |
95 | + bp = strtok(NULL, " "); | |
96 | + sscanf(bp, "%d", &stats->discard.nwid); | |
97 | + bp = strtok(NULL, " "); | |
98 | + sscanf(bp, "%d", &stats->discard.code); | |
99 | + bp = strtok(NULL, " "); | |
100 | + sscanf(bp, "%d", &stats->discard.misc); | |
101 | + fclose(f); | |
102 | + return 0; | |
76 | 103 | } |
77 | - } | |
104 | + } | |
78 | 105 | fclose(f); |
79 | - return 0; | |
106 | + return -1; | |
80 | 107 | } |
81 | 108 | |
82 | 109 | /*------------------------------------------------------------------*/ |
@@ -107,8 +134,7 @@ get_info(int skfd, | ||
107 | 134 | if(ioctl(skfd, SIOCGIWNWID, &wrq) >= 0) |
108 | 135 | { |
109 | 136 | info->has_nwid = 1; |
110 | - info->nwid_on = wrq.u.nwid.on; | |
111 | - info->nwid = wrq.u.nwid.nwid; | |
137 | + memcpy(&(info->nwid), &(wrq.u.nwid), sizeof(iwparam)); | |
112 | 138 | } |
113 | 139 | |
114 | 140 | /* Get frequency / channel */ |
@@ -124,24 +150,26 @@ get_info(int skfd, | ||
124 | 150 | if(ioctl(skfd, SIOCGIWSENS, &wrq) >= 0) |
125 | 151 | { |
126 | 152 | info->has_sens = 1; |
127 | - info->sens = wrq.u.sensitivity; | |
153 | + memcpy(&(info->sens), &(wrq.u.sens), sizeof(iwparam)); | |
128 | 154 | } |
129 | 155 | |
130 | - /* Get encryption information */ | |
131 | - strcpy(wrq.ifr_name, ifname); | |
132 | - if(ioctl(skfd, SIOCGIWENCODE, &wrq) >= 0) | |
133 | - { | |
134 | - info->has_enc = 1; | |
135 | - info->enc_method = wrq.u.encoding.method; | |
136 | - info->enc_key = wrq.u.encoding.code; | |
137 | - } | |
138 | - | |
139 | -#if WIRELESS_EXT > 5 | |
140 | - /* Get ESSID */ | |
156 | + /* Get encryption information */ | |
141 | 157 | strcpy(wrq.ifr_name, ifname); |
142 | - wrq.u.data.pointer = (caddr_t) info->essid; | |
158 | + wrq.u.data.pointer = (caddr_t) info->key; | |
143 | 159 | wrq.u.data.length = 0; |
144 | 160 | wrq.u.data.flags = 0; |
161 | + if(ioctl(skfd, SIOCGIWENCODE, &wrq) >= 0) | |
162 | + { | |
163 | + info->has_key = 1; | |
164 | + info->key_size = wrq.u.data.length; | |
165 | + info->key_flags = wrq.u.data.flags; | |
166 | + } | |
167 | + | |
168 | + /* Get ESSID */ | |
169 | + strcpy(wrq.ifr_name, ifname); | |
170 | + wrq.u.essid.pointer = (caddr_t) info->essid; | |
171 | + wrq.u.essid.length = 0; | |
172 | + wrq.u.essid.flags = 0; | |
145 | 173 | if(ioctl(skfd, SIOCGIWESSID, &wrq) >= 0) |
146 | 174 | { |
147 | 175 | info->has_essid = 1; |
@@ -155,14 +183,12 @@ get_info(int skfd, | ||
155 | 183 | info->has_ap_addr = 1; |
156 | 184 | memcpy(&(info->ap_addr), &(wrq.u.ap_addr), sizeof (sockaddr)); |
157 | 185 | } |
158 | -#endif /* WIRELESS_EXT > 5 */ | |
159 | 186 | |
160 | -#if WIRELESS_EXT > 7 | |
161 | 187 | /* Get NickName */ |
162 | 188 | strcpy(wrq.ifr_name, ifname); |
163 | - wrq.u.data.pointer = (caddr_t) info->nickname; | |
164 | - wrq.u.data.length = 0; | |
165 | - wrq.u.data.flags = 0; | |
189 | + wrq.u.essid.pointer = (caddr_t) info->nickname; | |
190 | + wrq.u.essid.length = 0; | |
191 | + wrq.u.essid.flags = 0; | |
166 | 192 | if(ioctl(skfd, SIOCGIWNICKN, &wrq) >= 0) |
167 | 193 | if(wrq.u.data.length > 1) |
168 | 194 | info->has_nickname = 1; |
@@ -172,8 +198,7 @@ get_info(int skfd, | ||
172 | 198 | if(ioctl(skfd, SIOCGIWRATE, &wrq) >= 0) |
173 | 199 | { |
174 | 200 | info->has_bitrate = 1; |
175 | - info->bitrate_fixed = wrq.u.bitrate.fixed; | |
176 | - info->bitrate = wrq.u.bitrate.value; | |
201 | + memcpy(&(info->bitrate), &(wrq.u.bitrate), sizeof(iwparam)); | |
177 | 202 | } |
178 | 203 | |
179 | 204 | /* Get RTS threshold */ |
@@ -181,22 +206,36 @@ get_info(int skfd, | ||
181 | 206 | if(ioctl(skfd, SIOCGIWRTS, &wrq) >= 0) |
182 | 207 | { |
183 | 208 | info->has_rts = 1; |
184 | - info->rts_fixed = wrq.u.rts.fixed; | |
185 | - info->rts = wrq.u.rts.value; | |
209 | + memcpy(&(info->rts), &(wrq.u.rts), sizeof(iwparam)); | |
186 | 210 | } |
187 | 211 | |
188 | - /* Get fragmentation thershold */ | |
212 | + /* Get fragmentation threshold */ | |
189 | 213 | strcpy(wrq.ifr_name, ifname); |
190 | 214 | if(ioctl(skfd, SIOCGIWFRAG, &wrq) >= 0) |
191 | 215 | { |
192 | 216 | info->has_frag = 1; |
193 | - info->frag_fixed = wrq.u.frag.fixed; | |
194 | - info->frag = wrq.u.frag.value; | |
217 | + memcpy(&(info->frag), &(wrq.u.frag), sizeof(iwparam)); | |
218 | + } | |
219 | + | |
220 | + /* Get operation mode */ | |
221 | + strcpy(wrq.ifr_name, ifname); | |
222 | + if(ioctl(skfd, SIOCGIWMODE, &wrq) >= 0) | |
223 | + { | |
224 | + if((wrq.u.mode < 6) && (wrq.u.mode >= 0)) | |
225 | + info->has_mode = 1; | |
226 | + info->mode = wrq.u.mode; | |
227 | + } | |
228 | + | |
229 | + /* Get Power Management settings */ | |
230 | + strcpy(wrq.ifr_name, ifname); | |
231 | + if(ioctl(skfd, SIOCGIWPOWER, &wrq) >= 0) | |
232 | + { | |
233 | + info->has_power = 1; | |
234 | + memcpy(&(info->power), &(wrq.u.power), sizeof(iwparam)); | |
195 | 235 | } |
196 | -#endif /* WIRELESS_EXT > 7 */ | |
197 | 236 | |
198 | 237 | /* Get stats */ |
199 | - if(iw_getstats(ifname, &(info->stats)) == 0) | |
238 | + if(iw_getstats(ifname, &(info->stats)) >= 0) | |
200 | 239 | { |
201 | 240 | info->has_stats = 1; |
202 | 241 | } |
@@ -242,10 +281,10 @@ display_info(struct wireless_info * info, | ||
242 | 281 | { |
243 | 282 | /* Note : should display right number of digit according to info |
244 | 283 | * in range structure */ |
245 | - if(info->nwid_on) | |
246 | - printf("NWID:%lX ", info->nwid); | |
247 | - else | |
284 | + if(info->nwid.disabled) | |
248 | 285 | printf("NWID:off/any "); |
286 | + else | |
287 | + printf("NWID:%X ", info->nwid.value); | |
249 | 288 | } |
250 | 289 | |
251 | 290 | /* Display frequency / channel */ |
@@ -270,14 +309,31 @@ display_info(struct wireless_info * info, | ||
270 | 309 | /* Display sensitivity */ |
271 | 310 | if(info->has_sens) |
272 | 311 | { |
312 | + /* Fixed ? */ | |
313 | + if(info->sens.fixed) | |
314 | + printf("Sensitivity="); | |
315 | + else | |
316 | + printf("Sensitivity:"); | |
317 | + | |
273 | 318 | if(info->has_range) |
274 | 319 | /* Display in dBm ? */ |
275 | - if(info->sens < 0) | |
276 | - printf("Sensitivity:%d dBm ", info->sens); | |
320 | + if(info->sens.value < 0) | |
321 | + printf("%d dBm ", info->sens.value); | |
277 | 322 | else |
278 | - printf("Sensitivity:%d/%d ", info->sens, info->range.sensitivity); | |
323 | + printf("%d/%d ", info->sens.value, info->range.sensitivity); | |
279 | 324 | else |
280 | - printf("Sensitivity:%d ", info->sens); | |
325 | + printf("%d ", info->sens.value); | |
326 | + } | |
327 | + | |
328 | + /* Display the current mode of operation */ | |
329 | + if(info->has_mode) | |
330 | + { | |
331 | + /* A bit of clever formatting */ | |
332 | + if((info->has_nwid + 2*info->has_freq + 2*info->has_sens | |
333 | + + !info->has_essid) > 4) | |
334 | + printf("\n "); | |
335 | + | |
336 | + printf("Mode:%s ", operation_mode[info->mode]); | |
281 | 337 | } |
282 | 338 | |
283 | 339 | /* Display the address of the current Access Point */ |
@@ -285,7 +341,7 @@ display_info(struct wireless_info * info, | ||
285 | 341 | { |
286 | 342 | /* A bit of clever formatting */ |
287 | 343 | if((info->has_nwid + 2*info->has_freq + 2*info->has_sens |
288 | - + !info->has_essid) > 3) | |
344 | + + info->has_mode + !info->has_essid) > 3) | |
289 | 345 | printf("\n "); |
290 | 346 | |
291 | 347 | printf("Access Point: %s", pr_ether(info->ap_addr.sa_data)); |
@@ -296,78 +352,148 @@ display_info(struct wireless_info * info, | ||
296 | 352 | /* Display the currently used/set bit-rate */ |
297 | 353 | if(info->has_bitrate) |
298 | 354 | { |
299 | - printf("Bit Rate:"); | |
300 | - if(info->bitrate >= GIGA) | |
301 | - printf("%g Gb/s", info->bitrate / GIGA); | |
355 | + /* Fixed ? */ | |
356 | + if(info->bitrate.fixed) | |
357 | + printf("Bit Rate="); | |
302 | 358 | else |
303 | - if(info->bitrate >= MEGA) | |
304 | - printf("%g Mb/s", info->bitrate / MEGA); | |
305 | - else | |
306 | - printf("%g kb/s", info->bitrate / KILO); | |
359 | + printf("Bit Rate:"); | |
307 | 360 | |
308 | - /* Fixed ? */ | |
309 | - if(info->bitrate_fixed) | |
310 | - printf(" (f) "); | |
361 | + if(info->bitrate.value >= GIGA) | |
362 | + printf("%gGb/s", info->bitrate.value / GIGA); | |
311 | 363 | else |
312 | - printf(" "); | |
364 | + if(info->bitrate.value >= MEGA) | |
365 | + printf("%gMb/s", info->bitrate.value / MEGA); | |
366 | + else | |
367 | + printf("%gkb/s", info->bitrate.value / KILO); | |
368 | + printf(" "); | |
313 | 369 | } |
314 | 370 | |
315 | 371 | /* Display the RTS threshold */ |
316 | 372 | if(info->has_rts) |
317 | 373 | { |
318 | - printf("RTS thr:%ld B", info->rts); | |
319 | - | |
320 | - /* Fixed ? */ | |
321 | - if(info->rts_fixed) | |
322 | - printf(" (f) "); | |
374 | + /* Disabled ? */ | |
375 | + if(info->rts.disabled) | |
376 | + printf("RTS thr:off "); | |
323 | 377 | else |
324 | - printf(" "); | |
378 | + { | |
379 | + /* Fixed ? */ | |
380 | + if(info->rts.fixed) | |
381 | + printf("RTS thr="); | |
382 | + else | |
383 | + printf("RTS thr:"); | |
384 | + | |
385 | + printf("%d B ", info->rts.value); | |
386 | + } | |
325 | 387 | } |
326 | 388 | |
327 | 389 | /* Display the fragmentation threshold */ |
328 | - if(info->has_bitrate) | |
390 | + if(info->has_frag) | |
329 | 391 | { |
330 | - printf("Frag thr:%ld B", info->frag); | |
331 | - | |
332 | - /* Fixed ? */ | |
333 | - if(info->frag_fixed) | |
334 | - printf(" (f) "); | |
392 | + /* Disabled ? */ | |
393 | + if(info->frag.disabled) | |
394 | + printf("Fragment thr:off "); | |
335 | 395 | else |
336 | - printf(" "); | |
396 | + { | |
397 | + /* Fixed ? */ | |
398 | + if(info->frag.fixed) | |
399 | + printf("Fragment thr="); | |
400 | + else | |
401 | + printf("Fragment thr:"); | |
402 | + | |
403 | + printf("%d B ", info->frag.value); | |
404 | + } | |
337 | 405 | } |
338 | 406 | |
339 | 407 | /* Formating */ |
340 | 408 | if((info->has_bitrate) || (info->has_rts) || (info->has_bitrate)) |
341 | 409 | printf("\n "); |
342 | 410 | |
343 | - if(info->has_enc) | |
411 | + /* Display encryption information */ | |
412 | + /* Note : we display only the "current" key, use iwspy to list all keys */ | |
413 | + if(info->has_key) | |
344 | 414 | { |
345 | 415 | printf("Encryption key:"); |
346 | - if(info->enc_method) | |
416 | + if((info->key_flags & IW_ENCODE_DISABLED) || (info->key_size == 0)) | |
417 | + printf("off\n "); | |
418 | + else | |
347 | 419 | { |
348 | - int i = 0; | |
349 | - u_short parts[4]; | |
350 | - long long key = info->enc_key; | |
420 | + int i; | |
351 | 421 | |
352 | - for(i = 3; i >= 0; i--) | |
422 | + printf("%.2X", info->key[0]); | |
423 | + for(i = 1; i < info->key_size; i++) | |
353 | 424 | { |
354 | - parts[i] = key & 0xFFFF; | |
355 | - key >>= 16; | |
425 | + if((i & 0x1) == 0) | |
426 | + printf("-"); | |
427 | + printf("%.2X", info->key[i]); | |
356 | 428 | } |
357 | 429 | |
358 | - i = 0; | |
359 | - while((parts[i] == 0) && (i < 3)) | |
360 | - i++; | |
361 | - for(; i < 3; i++) | |
362 | - printf("%.4X-", parts[i]); | |
363 | - printf("%.4X", parts[3]); | |
364 | - | |
365 | - if(info->enc_method > 1) | |
366 | - printf(" (%d)", info->enc_method); | |
430 | + /* Other info... */ | |
431 | + if((info->key_flags & IW_ENCODE_INDEX) > 1) | |
432 | + printf(" [%d]", info->key_flags & IW_ENCODE_INDEX); | |
433 | + if(info->key_flags & IW_ENCODE_RESTRICTED) | |
434 | + printf(" Encryption mode:restricted"); | |
435 | + if(info->key_flags & IW_ENCODE_OPEN) | |
436 | + printf(" Encryption mode:open"); | |
367 | 437 | printf("\n "); |
368 | 438 | } |
439 | + } | |
440 | + | |
441 | + /* Display Power Management information */ | |
442 | + /* Note : we display only one parameter, period or timeout. If a device | |
443 | + * (such as HiperLan) has both, we would need to be a bit more clever... */ | |
444 | + if(info->has_power) /* I hope the device has power ;-) */ | |
445 | + { | |
446 | + printf("Power Management"); | |
447 | + /* Disabled ? */ | |
448 | + if(info->power.disabled) | |
449 | + printf(":off\n "); | |
369 | 450 | else |
370 | - printf("off\n "); | |
451 | + { | |
452 | + /* Let's check the value and its type */ | |
453 | + if(info->power.flags & IW_POWER_TYPE) | |
454 | + { | |
455 | + /* Type */ | |
456 | + if(info->power.flags & IW_POWER_TIMEOUT) | |
457 | + printf(" timeout:"); | |
458 | + else | |
459 | + printf(" period:"); | |
460 | + | |
461 | + /* Display value with units */ | |
462 | + if(info->power.value >= (int) MEGA) | |
463 | + printf("%gs ", ((double) info->power.value) / MEGA); | |
464 | + else | |
465 | + if(info->power.value >= (int) KILO) | |
466 | + printf("%gms ", ((double) info->power.value) / KILO); | |
467 | + else | |
468 | + printf("%dus ", info->power.value); | |
469 | + } | |
470 | + | |
471 | + /* Let's check the mode */ | |
472 | + switch(info->power.flags & IW_POWER_MODE) | |
473 | + { | |
474 | + case IW_POWER_UNICAST_R: | |
475 | + printf(" mode:Unicast received"); | |
476 | + break; | |
477 | + case IW_POWER_MULTICAST_R: | |
478 | + printf(" mode:Multicast received"); | |
479 | + break; | |
480 | + case IW_POWER_ALL_R: | |
481 | + printf(" mode:All packets received"); | |
482 | + break; | |
483 | + case IW_POWER_FORCE_S: | |
484 | + printf(" mode:Force sending"); | |
485 | + break; | |
486 | + case IW_POWER_REPEATER: | |
487 | + printf(" mode:Repeat multicasts"); | |
488 | + break; | |
489 | + default: | |
490 | + } | |
491 | + | |
492 | + /* Let's check if nothing (simply on) */ | |
493 | + if(info->power.flags == IW_POWER_ON) | |
494 | + printf(":on"); | |
495 | + printf("\n "); | |
496 | + } | |
371 | 497 | } |
372 | 498 | |
373 | 499 | if(info->has_stats) |
@@ -487,7 +613,7 @@ set_info(int skfd, /* The socket */ | ||
487 | 613 | iw_usage(); |
488 | 614 | if((!strcasecmp(args[i], "off")) || |
489 | 615 | (!strcasecmp(args[i], "any"))) |
490 | - wrq.u.nwid.on = 0; | |
616 | + wrq.u.nwid.disabled = 1; | |
491 | 617 | else |
492 | 618 | if(!strcasecmp(args[i], "on")) |
493 | 619 | { |
@@ -498,14 +624,15 @@ set_info(int skfd, /* The socket */ | ||
498 | 624 | return(-1); |
499 | 625 | } |
500 | 626 | strcpy(wrq.ifr_name, ifname); |
501 | - wrq.u.nwid.on = 1; | |
627 | + wrq.u.nwid.disabled = 0; | |
502 | 628 | } |
503 | 629 | else |
504 | - if(sscanf(args[i], "%lX", (unsigned long *) &(wrq.u.nwid.nwid)) | |
630 | + if(sscanf(args[i], "%lX", (unsigned long *) &(wrq.u.nwid.value)) | |
505 | 631 | != 1) |
506 | 632 | iw_usage(); |
507 | 633 | else |
508 | - wrq.u.nwid.on = 1; | |
634 | + wrq.u.nwid.disabled = 0; | |
635 | + wrq.u.nwid.fixed = 1; | |
509 | 636 | |
510 | 637 | if(ioctl(skfd, SIOCSIWNWID, &wrq) < 0) |
511 | 638 | { |
@@ -544,7 +671,7 @@ set_info(int skfd, /* The socket */ | ||
544 | 671 | { |
545 | 672 | if(++i >= count) |
546 | 673 | iw_usage(); |
547 | - if(sscanf(args[i], "%d", &(wrq.u.sensitivity)) != 1) | |
674 | + if(sscanf(args[i], "%d", &(wrq.u.sens.value)) != 1) | |
548 | 675 | iw_usage(); |
549 | 676 | |
550 | 677 | if(ioctl(skfd, SIOCSIWSENS, &wrq) < 0) |
@@ -556,51 +683,111 @@ set_info(int skfd, /* The socket */ | ||
556 | 683 | } |
557 | 684 | |
558 | 685 | /* ---------- Set encryption stuff ---------- */ |
559 | - if(!strncmp(args[i], "enc", 3 )) | |
686 | + if((!strncmp(args[i], "enc", 3)) || | |
687 | + (!strcmp(args[i], "key"))) | |
560 | 688 | { |
561 | - unsigned long long key = 0; | |
689 | + unsigned char key[IW_ENCODING_TOKEN_MAX]; | |
562 | 690 | |
563 | 691 | if(++i >= count) |
564 | 692 | iw_usage(); |
565 | 693 | |
566 | - if(!strcasecmp(args[i], "off")) | |
567 | - wrq.u.encoding.method = 0; | |
694 | + if(!strcasecmp(args[i], "on")) | |
695 | + { | |
696 | + /* Get old encryption information */ | |
697 | + wrq.u.data.pointer = (caddr_t) key; | |
698 | + wrq.u.data.length = 0; | |
699 | + wrq.u.data.flags = 0; | |
700 | + if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0) | |
701 | + { | |
702 | + fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno)); | |
703 | + return(-1); | |
704 | + } | |
705 | + strcpy(wrq.ifr_name, ifname); | |
706 | + wrq.u.data.flags &= ~IW_ENCODE_DISABLED; /* Enable */ | |
707 | + } | |
568 | 708 | else |
569 | 709 | { |
570 | - if(!strcasecmp(args[i], "on")) | |
710 | + char * buff; | |
711 | + char * p; | |
712 | + int temp; | |
713 | + int k = 0; | |
714 | + int gotone = 1; | |
715 | + | |
716 | + wrq.u.data.pointer = (caddr_t) NULL; | |
717 | + wrq.u.data.flags = 0; | |
718 | + wrq.u.data.length = 0; | |
719 | + | |
720 | + /* -- Check for the key -- */ | |
721 | + if(!strncmp(args[i], "s:", 2)) | |
571 | 722 | { |
572 | - /* Get old encryption information */ | |
573 | - if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0) | |
574 | - { | |
575 | - fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno)); | |
576 | - return(-1); | |
577 | - } | |
578 | - strcpy(wrq.ifr_name, ifname); | |
723 | + /* First case : as an ASCII string */ | |
724 | + wrq.u.data.length = strlen(args[i] + 2); | |
725 | + if(wrq.u.data.length > IW_ENCODING_TOKEN_MAX) | |
726 | + wrq.u.data.length = IW_ENCODING_TOKEN_MAX; | |
727 | + strncpy(key, args[i] + 2, wrq.u.data.length); | |
728 | + wrq.u.data.pointer = (caddr_t) key; | |
729 | + ++i; | |
730 | + gotone = 1; | |
579 | 731 | } |
580 | 732 | else |
581 | 733 | { |
582 | - char * buff; | |
583 | - char * p; | |
584 | - u_long temp; | |
585 | - | |
586 | - p = buff = malloc(strlen(args[i] + 1)); | |
734 | + /* Second case : has hexadecimal digits */ | |
735 | + p = buff = malloc(strlen(args[i]) + 1); | |
587 | 736 | strcpy(buff, args[i]); |
588 | 737 | |
589 | - p = strtok(buff, "-:;.,*#"); | |
738 | + p = strtok(buff, "-:;.,"); | |
590 | 739 | while(p != (char *) NULL) |
591 | 740 | { |
592 | - key = key << 16; | |
593 | - if(sscanf(p, "%lX", &temp) != 1) | |
594 | - iw_usage(); | |
595 | - key += temp; | |
596 | - p = strtok((char *) NULL, "-:;.,*#"); | |
741 | + if(sscanf(p, "%2X", &temp) != 1) | |
742 | + { | |
743 | + gotone = 0; | |
744 | + break; | |
745 | + } | |
746 | + key[k++] = (unsigned char) (temp & 0xFF); | |
747 | + if(strlen(p) > 2) /* Token not finished yet */ | |
748 | + p += 2; | |
749 | + else | |
750 | + p = strtok((char *) NULL, "-:;.,"); | |
597 | 751 | } |
598 | - | |
599 | 752 | free(buff); |
600 | - wrq.u.encoding.code = key; | |
753 | + | |
754 | + if(gotone) | |
755 | + { | |
756 | + ++i; | |
757 | + wrq.u.data.length = k; | |
758 | + wrq.u.data.pointer = (caddr_t) key; | |
759 | + } | |
601 | 760 | } |
602 | - /* TODO : check for "(method)" in args list */ | |
603 | - wrq.u.encoding.method = 1; | |
761 | + | |
762 | + /* -- Check for token index -- */ | |
763 | + if((i < count) && | |
764 | + (sscanf(args[i], "[%d]", &temp) == 1) && | |
765 | + (temp > 0) && (temp < IW_ENCODE_INDEX)) | |
766 | + { | |
767 | + wrq.u.encoding.flags |= temp; | |
768 | + ++i; | |
769 | + gotone = 1; | |
770 | + } | |
771 | + | |
772 | + /* -- Check the various flags -- */ | |
773 | + if(i < count) | |
774 | + { | |
775 | + if(!strcasecmp(args[i], "off")) | |
776 | + wrq.u.data.flags |= IW_ENCODE_DISABLED; | |
777 | + if(!strcasecmp(args[i], "open")) | |
778 | + wrq.u.data.flags |= IW_ENCODE_OPEN; | |
779 | + if(!strncasecmp(args[i], "restricted", 5)) | |
780 | + wrq.u.data.flags |= IW_ENCODE_RESTRICTED; | |
781 | + if(wrq.u.data.flags & IW_ENCODE_FLAGS) | |
782 | + { | |
783 | + ++i; | |
784 | + gotone = 1; | |
785 | + } | |
786 | + } | |
787 | + | |
788 | + if(!gotone) | |
789 | + iw_usage(); | |
790 | + --i; | |
604 | 791 | } |
605 | 792 | |
606 | 793 | if(ioctl(skfd, SIOCSIWENCODE, &wrq) < 0) |
@@ -612,7 +799,6 @@ set_info(int skfd, /* The socket */ | ||
612 | 799 | continue; |
613 | 800 | } |
614 | 801 | |
615 | -#if WIRELESS_EXT > 5 | |
616 | 802 | /* ---------- Set ESSID ---------- */ |
617 | 803 | if(!strcasecmp(args[i], "essid")) |
618 | 804 | { |
@@ -624,23 +810,23 @@ set_info(int skfd, /* The socket */ | ||
624 | 810 | if((!strcasecmp(args[i], "off")) || |
625 | 811 | (!strcasecmp(args[i], "any"))) |
626 | 812 | { |
627 | - wrq.u.data.flags = 0; | |
813 | + wrq.u.essid.flags = 0; | |
628 | 814 | essid[0] = '\0'; |
629 | 815 | } |
630 | 816 | else |
631 | 817 | if(!strcasecmp(args[i], "on")) |
632 | 818 | { |
633 | 819 | /* Get old essid */ |
634 | - wrq.u.data.pointer = (caddr_t) essid; | |
635 | - wrq.u.data.length = 0; | |
636 | - wrq.u.data.flags = 0; | |
820 | + wrq.u.essid.pointer = (caddr_t) essid; | |
821 | + wrq.u.essid.length = 0; | |
822 | + wrq.u.essid.flags = 0; | |
637 | 823 | if(ioctl(skfd, SIOCGIWESSID, &wrq) < 0) |
638 | 824 | { |
639 | 825 | fprintf(stderr, "SIOCGIWESSID: %s\n", strerror(errno)); |
640 | 826 | return(-1); |
641 | 827 | } |
642 | 828 | strcpy(wrq.ifr_name, ifname); |
643 | - wrq.u.data.flags = 1; | |
829 | + wrq.u.essid.flags = 1; | |
644 | 830 | } |
645 | 831 | else |
646 | 832 | if(strlen(args[i]) > IW_ESSID_MAX_SIZE) |
@@ -651,12 +837,12 @@ set_info(int skfd, /* The socket */ | ||
651 | 837 | } |
652 | 838 | else |
653 | 839 | { |
654 | - wrq.u.data.flags = 1; | |
840 | + wrq.u.essid.flags = 1; | |
655 | 841 | strcpy(essid, args[i]); |
656 | 842 | } |
657 | 843 | |
658 | - wrq.u.data.pointer = (caddr_t) essid; | |
659 | - wrq.u.data.length = strlen(essid) + 1; | |
844 | + wrq.u.essid.pointer = (caddr_t) essid; | |
845 | + wrq.u.essid.length = strlen(essid) + 1; | |
660 | 846 | if(ioctl(skfd, SIOCSIWESSID, &wrq) < 0) |
661 | 847 | { |
662 | 848 | fprintf(stderr, "SIOCSIWESSID: %s\n", strerror(errno)); |
@@ -689,9 +875,7 @@ set_info(int skfd, /* The socket */ | ||
689 | 875 | } |
690 | 876 | continue; |
691 | 877 | } |
692 | -#endif /* WIRELESS_EXT > 5 */ | |
693 | 878 | |
694 | -#if WIRELESS_EXT > 7 | |
695 | 879 | /* ---------- Set NickName ---------- */ |
696 | 880 | if(!strncmp(args[i], "nick", 4)) |
697 | 881 | { |
@@ -705,8 +889,8 @@ set_info(int skfd, /* The socket */ | ||
705 | 889 | iw_usage(); |
706 | 890 | } |
707 | 891 | |
708 | - wrq.u.data.pointer = (caddr_t) args[i]; | |
709 | - wrq.u.data.length = strlen(args[i]) + 1; | |
892 | + wrq.u.essid.pointer = (caddr_t) args[i]; | |
893 | + wrq.u.essid.length = strlen(args[i]) + 1; | |
710 | 894 | if(ioctl(skfd, SIOCSIWNICKN, &wrq) < 0) |
711 | 895 | { |
712 | 896 | fprintf(stderr, "SIOCSIWNICKN: %s\n", strerror(errno)); |
@@ -719,8 +903,7 @@ set_info(int skfd, /* The socket */ | ||
719 | 903 | if((!strncmp(args[i], "bit", 3)) || |
720 | 904 | (!strcmp(args[i], "rate"))) |
721 | 905 | { |
722 | - i++; | |
723 | - if(i >= count) | |
906 | + if(++i >= count) | |
724 | 907 | iw_usage(); |
725 | 908 | if(!strcasecmp(args[i], "auto")) |
726 | 909 | { |
@@ -738,6 +921,7 @@ set_info(int skfd, /* The socket */ | ||
738 | 921 | return(-1); |
739 | 922 | } |
740 | 923 | strcpy(wrq.ifr_name, ifname); |
924 | + wrq.u.bitrate.fixed = 1; | |
741 | 925 | } |
742 | 926 | else /* Should be a numeric value */ |
743 | 927 | { |
@@ -749,8 +933,16 @@ set_info(int skfd, /* The socket */ | ||
749 | 933 | if(index(args[i], 'M')) brate *= MEGA; |
750 | 934 | if(index(args[i], 'k')) brate *= KILO; |
751 | 935 | wrq.u.bitrate.value = (long) brate; |
936 | + wrq.u.bitrate.fixed = 1; | |
937 | + | |
938 | + /* Check for an additional argument */ | |
939 | + if(((i+1) < count) && | |
940 | + (!strcasecmp(args[i+1], "auto"))) | |
941 | + { | |
942 | + wrq.u.bitrate.fixed = 0; | |
943 | + ++i; | |
944 | + } | |
752 | 945 | } |
753 | - wrq.u.bitrate.fixed = 1; | |
754 | 946 | } |
755 | 947 | |
756 | 948 | if(ioctl(skfd, SIOCSIWRATE, &wrq) < 0) |
@@ -762,37 +954,36 @@ set_info(int skfd, /* The socket */ | ||
762 | 954 | } |
763 | 955 | |
764 | 956 | /* ---------- Set RTS threshold ---------- */ |
765 | - if(!strncmp(args[i], "rts", 3)) | |
957 | + if(!strncasecmp(args[i], "rts", 3)) | |
766 | 958 | { |
767 | 959 | i++; |
768 | 960 | if(i >= count) |
769 | 961 | iw_usage(); |
770 | - if(!strcasecmp(args[i], "auto")) | |
771 | - { | |
772 | - wrq.u.rts.value = -1; | |
773 | - wrq.u.rts.fixed = 0; | |
774 | - } | |
962 | + wrq.u.rts.value = -1; | |
963 | + wrq.u.rts.fixed = 1; | |
964 | + wrq.u.rts.disabled = 0; | |
965 | + if(!strcasecmp(args[i], "off")) | |
966 | + wrq.u.rts.disabled = 1; /* i.e. max size */ | |
775 | 967 | else |
776 | - { | |
777 | - if(!strcasecmp(args[i], "fixed")) | |
778 | - { | |
779 | - /* Get old RTS threshold */ | |
780 | - if(ioctl(skfd, SIOCGIWRTS, &wrq) < 0) | |
781 | - { | |
782 | - fprintf(stderr, "SIOCGIWRTS: %s\n", strerror(errno)); | |
783 | - return(-1); | |
784 | - } | |
785 | - strcpy(wrq.ifr_name, ifname); | |
786 | - } | |
787 | - else | |
788 | - if(!strcasecmp(args[i], "off")) | |
789 | - wrq.u.rts.value = -1; /* i.e. max size */ | |
968 | + if(!strcasecmp(args[i], "auto")) | |
969 | + wrq.u.rts.fixed = 0; | |
970 | + else | |
971 | + { | |
972 | + if(!strcasecmp(args[i], "fixed")) | |
973 | + { | |
974 | + /* Get old RTS threshold */ | |
975 | + if(ioctl(skfd, SIOCGIWRTS, &wrq) < 0) | |
976 | + { | |
977 | + fprintf(stderr, "SIOCGIWRTS: %s\n", strerror(errno)); | |
978 | + return(-1); | |
979 | + } | |
980 | + strcpy(wrq.ifr_name, ifname); | |
981 | + wrq.u.rts.fixed = 1; | |
982 | + } | |
790 | 983 | else /* Should be a numeric value */ |
791 | 984 | if(sscanf(args[i], "%ld", (unsigned long *) &(wrq.u.rts.value)) |
792 | 985 | != 1) |
793 | 986 | iw_usage(); |
794 | - | |
795 | - wrq.u.rts.fixed = 1; | |
796 | 987 | } |
797 | 988 | |
798 | 989 | if(ioctl(skfd, SIOCSIWRTS, &wrq) < 0) |
@@ -809,32 +1000,31 @@ set_info(int skfd, /* The socket */ | ||
809 | 1000 | i++; |
810 | 1001 | if(i >= count) |
811 | 1002 | iw_usage(); |
812 | - if(!strcasecmp(args[i], "auto")) | |
813 | - { | |
814 | - wrq.u.frag.value = -1; | |
815 | - wrq.u.frag.fixed = 0; | |
816 | - } | |
1003 | + wrq.u.frag.value = -1; | |
1004 | + wrq.u.frag.fixed = 1; | |
1005 | + wrq.u.frag.disabled = 0; | |
1006 | + if(!strcasecmp(args[i], "off")) | |
1007 | + wrq.u.frag.disabled = 1; /* i.e. max size */ | |
817 | 1008 | else |
818 | - { | |
819 | - if(!strcasecmp(args[i], "fixed")) | |
820 | - { | |
821 | - /* Get old fragmentation threshold */ | |
822 | - if(ioctl(skfd, SIOCGIWFRAG, &wrq) < 0) | |
823 | - { | |
824 | - fprintf(stderr, "SIOCGIWFRAG: %s\n", strerror(errno)); | |
825 | - return(-1); | |
826 | - } | |
827 | - strcpy(wrq.ifr_name, ifname); | |
828 | - } | |
829 | - else | |
830 | - if(!strcasecmp(args[i], "off")) | |
831 | - wrq.u.frag.value = -1; /* i.e. max size */ | |
1009 | + if(!strcasecmp(args[i], "auto")) | |
1010 | + wrq.u.frag.fixed = 0; | |
1011 | + else | |
1012 | + { | |
1013 | + if(!strcasecmp(args[i], "fixed")) | |
1014 | + { | |
1015 | + /* Get old fragmentation threshold */ | |
1016 | + if(ioctl(skfd, SIOCGIWFRAG, &wrq) < 0) | |
1017 | + { | |
1018 | + fprintf(stderr, "SIOCGIWFRAG: %s\n", strerror(errno)); | |
1019 | + return(-1); | |
1020 | + } | |
1021 | + strcpy(wrq.ifr_name, ifname); | |
1022 | + wrq.u.frag.fixed = 1; | |
1023 | + } | |
832 | 1024 | else /* Should be a numeric value */ |
833 | 1025 | if(sscanf(args[i], "%ld", (unsigned long *) &(wrq.u.frag.value)) |
834 | 1026 | != 1) |
835 | 1027 | iw_usage(); |
836 | - | |
837 | - wrq.u.frag.fixed = 1; | |
838 | 1028 | } |
839 | 1029 | |
840 | 1030 | if(ioctl(skfd, SIOCSIWFRAG, &wrq) < 0) |
@@ -844,8 +1034,124 @@ set_info(int skfd, /* The socket */ | ||
844 | 1034 | } |
845 | 1035 | continue; |
846 | 1036 | } |
847 | -#endif /* WIRELESS_EXT > 7 */ | |
848 | 1037 | |
1038 | + /* ---------- Set operation mode ---------- */ | |
1039 | + if(!strcmp(args[i], "mode")) | |
1040 | + { | |
1041 | + int k; | |
1042 | + | |
1043 | + i++; | |
1044 | + if(i >= count) | |
1045 | + iw_usage(); | |
1046 | + | |
1047 | + if(sscanf(args[i], "%d", &k) != 1) | |
1048 | + { | |
1049 | + k = 0; | |
1050 | + while(k < 6 && strncasecmp(args[i], operation_mode[k], 3)) | |
1051 | + k++; | |
1052 | + } | |
1053 | + if((k > 5) || (k < 0)) | |
1054 | + iw_usage(); | |
1055 | + | |
1056 | + wrq.u.mode = k; | |
1057 | + if(ioctl(skfd, SIOCSIWMODE, &wrq) < 0) | |
1058 | + { | |
1059 | + fprintf(stderr, "SIOCSIWMODE: %s\n", strerror(errno)); | |
1060 | + return(-1); | |
1061 | + } | |
1062 | + continue; | |
1063 | + } | |
1064 | + | |
1065 | + /* ---------- Set Power Management ---------- */ | |
1066 | + if(!strncmp(args[i], "power", 3)) | |
1067 | + { | |
1068 | + if(++i >= count) | |
1069 | + iw_usage(); | |
1070 | + | |
1071 | + if(!strcasecmp(args[i], "off")) | |
1072 | + wrq.u.power.disabled = 1; /* i.e. max size */ | |
1073 | + else | |
1074 | + if(!strcasecmp(args[i], "on")) | |
1075 | + { | |
1076 | + /* Get old Power info */ | |
1077 | + if(ioctl(skfd, SIOCGIWPOWER, &wrq) < 0) | |
1078 | + { | |
1079 | + fprintf(stderr, "SIOCGIWFRAG: %s\n", strerror(errno)); | |
1080 | + return(-1); | |
1081 | + } | |
1082 | + strcpy(wrq.ifr_name, ifname); | |
1083 | + wrq.u.power.disabled = 0; | |
1084 | + } | |
1085 | + else | |
1086 | + { | |
1087 | + double temp; | |
1088 | + int gotone = 0; | |
1089 | + /* Default - nope */ | |
1090 | + wrq.u.power.flags = IW_POWER_ON; | |
1091 | + wrq.u.power.disabled = 0; | |
1092 | + | |
1093 | + /* Check value modifier */ | |
1094 | + if(!strcasecmp(args[i], "period")) | |
1095 | + { | |
1096 | + wrq.u.power.flags = IW_POWER_PERIOD; | |
1097 | + if(++i >= count) | |
1098 | + iw_usage(); | |
1099 | + } | |
1100 | + else | |
1101 | + if(!strcasecmp(args[i], "timeout")) | |
1102 | + { | |
1103 | + wrq.u.power.flags = IW_POWER_TIMEOUT; | |
1104 | + if(++i >= count) | |
1105 | + iw_usage(); | |
1106 | + } | |
1107 | + | |
1108 | + /* Is there any value to grab ? */ | |
1109 | + if(sscanf(args[i], "%lg", &(temp)) == 1) | |
1110 | + { | |
1111 | + temp *= MEGA; /* default = s */ | |
1112 | + if(index(args[i], 'u')) temp /= MEGA; | |
1113 | + if(index(args[i], 'm')) temp /= KILO; | |
1114 | + wrq.u.power.value = (long) temp; | |
1115 | + if(wrq.u.power.flags == IW_POWER_ON) | |
1116 | + wrq.u.power.flags = IW_POWER_PERIOD; | |
1117 | + ++i; | |
1118 | + gotone = 1; | |
1119 | + } | |
1120 | + | |
1121 | + /* Now, check the mode */ | |
1122 | + if(i < count) | |
1123 | + { | |
1124 | + if(!strcasecmp(args[i], "all")) | |
1125 | + wrq.u.power.flags |= IW_POWER_ALL_R; | |
1126 | + if(!strncasecmp(args[i], "unicast", 4)) | |
1127 | + wrq.u.power.flags |= IW_POWER_UNICAST_R; | |
1128 | + if(!strncasecmp(args[i], "multicast", 5)) | |
1129 | + wrq.u.power.flags |= IW_POWER_MULTICAST_R; | |
1130 | + if(!strncasecmp(args[i], "force", 5)) | |
1131 | + wrq.u.power.flags |= IW_POWER_FORCE_S; | |
1132 | + if(!strcasecmp(args[i], "repeat")) | |
1133 | + wrq.u.power.flags |= IW_POWER_REPEATER; | |
1134 | + if(wrq.u.power.flags & IW_POWER_MODE) | |
1135 | + { | |
1136 | + ++i; | |
1137 | + gotone = 1; | |
1138 | + } | |
1139 | + } | |
1140 | + if(!gotone) | |
1141 | + iw_usage(); | |
1142 | + --i; | |
1143 | + } | |
1144 | + | |
1145 | + if(ioctl(skfd, SIOCSIWPOWER, &wrq) < 0) | |
1146 | + { | |
1147 | + fprintf(stderr, "SIOCSIWPOWER(%d): %s\n", | |
1148 | + errno, strerror(errno)); | |
1149 | + return(-1); | |
1150 | + } | |
1151 | + continue; | |
1152 | + } | |
1153 | + | |
1154 | + /* ---------- Other ---------- */ | |
849 | 1155 | /* Here we have an unrecognised arg... */ |
850 | 1156 | fprintf(stderr, "Invalid argument : %s\n", args[i]); |
851 | 1157 | iw_usage(); |
@@ -18,7 +18,7 @@ network interface | ||
18 | 18 | .br |
19 | 19 | .BI "iwpriv " interface " roam " {on,off} |
20 | 20 | .br |
21 | -.BI "iwpriv " interface " port " [ N ] | |
21 | +.BI "iwpriv " interface " port " {ad-hoc,managed,N} | |
22 | 22 | .\" |
23 | 23 | .\" DESCRIPTION part |
24 | 24 | .\" |
@@ -55,8 +55,8 @@ driver. | ||
55 | 55 | .TP |
56 | 56 | .B port |
57 | 57 | Read or configure the port type. Call the private commands |
58 | -.IR gport_type " and " sport_type . | |
59 | -Found in the | |
58 | +.IR gport_type ", " sport_type ", " get_port " or " set_port | |
59 | +found in the | |
60 | 60 | .IR wavelan2_cs " and " wvlan_cs " drivers." |
61 | 61 | .TP |
62 | 62 | .I private-command |
@@ -21,7 +21,7 @@ iw_usage(void) | ||
21 | 21 | { |
22 | 22 | fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n"); |
23 | 23 | fprintf(stderr, " interface [roam {on|off}]\n"); |
24 | - fprintf(stderr, " interface [port [n]]\n"); | |
24 | + fprintf(stderr, " interface [port {ad-hoc|managed|N}]\n"); | |
25 | 25 | exit(1); |
26 | 26 | } |
27 | 27 |
@@ -386,6 +386,7 @@ port_type(int skfd, /* Socket */ | ||
386 | 386 | iwprivargs priv[16]; |
387 | 387 | int number; |
388 | 388 | char ptype = 0; |
389 | + char * modes[] = { "invalid", "managed (BSS)", "reserved", "ad-hoc" }; | |
389 | 390 | |
390 | 391 | /* Read the private ioctls */ |
391 | 392 | number = get_priv_info(skfd, ifname, priv); |
@@ -403,7 +404,8 @@ port_type(int skfd, /* Socket */ | ||
403 | 404 | { |
404 | 405 | /* So, we just want to see the current value... */ |
405 | 406 | k = -1; |
406 | - while((++k < number) && strcmp(priv[k].name, "gport_type")); | |
407 | + while((++k < number) && strcmp(priv[k].name, "gport_type") && | |
408 | + strcmp(priv[k].name, "get_port")); | |
407 | 409 | if(k == number) |
408 | 410 | { |
409 | 411 | fprintf(stderr, "This device doesn't support getting port type\n"); |
@@ -420,7 +422,8 @@ port_type(int skfd, /* Socket */ | ||
420 | 422 | ptype = *wrq.u.name; |
421 | 423 | |
422 | 424 | /* Display it */ |
423 | - printf("%-8.8s Port type is %d.\n\n", ifname, ptype); | |
425 | + printf("%-8.8s Current port mode is %s <port type is %d>.\n\n", | |
426 | + ifname, modes[(int) ptype], ptype); | |
424 | 427 | |
425 | 428 | return(0); |
426 | 429 | } |
@@ -429,11 +432,20 @@ port_type(int skfd, /* Socket */ | ||
429 | 432 | iw_usage(); |
430 | 433 | |
431 | 434 | /* Read it */ |
432 | - if(sscanf(args[i], "%d", (int *) &ptype) != 1) | |
433 | - iw_usage(); | |
435 | + /* As a string... */ | |
436 | + k = 0; | |
437 | + while((k < 4) && strncasecmp(args[i], modes[k], 2)) | |
438 | + k++; | |
439 | + if(k < 4) | |
440 | + ptype = k; | |
441 | + else | |
442 | + /* ...or as an integer */ | |
443 | + if(sscanf(args[i], "%d", (int *) &ptype) != 1) | |
444 | + iw_usage(); | |
434 | 445 | |
435 | 446 | k = -1; |
436 | - while((++k < number) && strcmp(priv[k].name, "sport_type")); | |
447 | + while((++k < number) && strcmp(priv[k].name, "sport_type") && | |
448 | + strcmp(priv[k].name, "set_port")); | |
437 | 449 | if(k == number) |
438 | 450 | { |
439 | 451 | fprintf(stderr, "This device doesn't support setting port type\n"); |
@@ -445,7 +457,7 @@ port_type(int skfd, /* Socket */ | ||
445 | 457 | |
446 | 458 | if(ioctl(skfd, priv[k].cmd, &wrq) < 0) |
447 | 459 | { |
448 | - fprintf(stderr, "Invalid port type\n"); | |
460 | + fprintf(stderr, "Invalid port type (or setting not allowed)\n"); | |
449 | 461 | exit(0); |
450 | 462 | } |
451 | 463 |
@@ -22,6 +22,8 @@ iwspy \- Get wireless statistics from specific nodes | ||
22 | 22 | .BI "iwspy " interface " ap" |
23 | 23 | .br |
24 | 24 | .BI "iwspy " interface " rate" |
25 | +.br | |
26 | +.BI "iwspy " interface " keys" | |
25 | 27 | .\" |
26 | 28 | .\" DESCRIPTION part |
27 | 29 | .\" |
@@ -82,8 +84,12 @@ displayed and channel numbers. | ||
82 | 84 | Give the list of Access Points in range, and optionally the quality of |
83 | 85 | link to them. |
84 | 86 | .TP |
85 | -.BR rate / bit [ rate ] | |
87 | +.BR rate / bit [rate] | |
86 | 88 | List the bit-rates supported by the device. |
89 | +.TP | |
90 | +.BR keys / enc [ryption] | |
91 | +List the encryption key sizes supported and display all the encryption | |
92 | +keys availables in the device. | |
87 | 93 | .\" |
88 | 94 | .\" FILES part |
89 | 95 | .\" |
@@ -150,11 +150,7 @@ print_freq_info(int skfd, | ||
150 | 150 | /* Print them all */ |
151 | 151 | for(k = 0; k < range.num_frequency; k++) |
152 | 152 | { |
153 | -#if WIRELESS_EXT > 7 | |
154 | - printf("\t Channel %.2d : ", range.freq[k].i); | |
155 | -#else | |
156 | - printf("\t "); | |
157 | -#endif | |
153 | + printf("\t Channel %.2d : ", range.freq[k].i); | |
158 | 154 | freq = freq2float(&(range.freq[k])); |
159 | 155 | if(freq >= GIGA) |
160 | 156 | printf("%g GHz\n", freq / GIGA); |
@@ -199,7 +195,6 @@ print_freq_devices(int skfd) | ||
199 | 195 | print_freq_info(skfd, ifr->ifr_name); |
200 | 196 | } |
201 | 197 | |
202 | -#if WIRELESS_EXT > 5 | |
203 | 198 | /*------------------------------------------------------------------*/ |
204 | 199 | /* |
205 | 200 | * Display the list of ap addresses and the associated stats |
@@ -310,9 +305,7 @@ print_ap_devices(int skfd) | ||
310 | 305 | for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++) |
311 | 306 | print_ap_info(skfd, ifr->ifr_name); |
312 | 307 | } |
313 | -#endif /* WIRELESS_EXT > 5 */ | |
314 | 308 | |
315 | -#if WIRELESS_EXT > 7 | |
316 | 309 | /*------------------------------------------------------------------*/ |
317 | 310 | /* |
318 | 311 | * Print the number of available bitrates for the device |
@@ -385,7 +378,103 @@ print_bitrate_devices(int skfd) | ||
385 | 378 | for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++) |
386 | 379 | print_bitrate_info(skfd, ifr->ifr_name); |
387 | 380 | } |
388 | -#endif /* WIRELESS_EXT > 7 */ | |
381 | + | |
382 | +/*------------------------------------------------------------------*/ | |
383 | +/* | |
384 | + * Print the number of available bitrates for the device | |
385 | + */ | |
386 | +static void | |
387 | +print_keys_info(int skfd, | |
388 | + char * ifname) | |
389 | +{ | |
390 | + struct iwreq wrq; | |
391 | + struct iw_range range; | |
392 | + unsigned char key[IW_ENCODING_TOKEN_MAX]; | |
393 | + int k; | |
394 | + | |
395 | + strncpy(wrq.ifr_name, ifname, IFNAMSIZ); | |
396 | + wrq.u.data.pointer = (caddr_t) ⦥ | |
397 | + wrq.u.data.length = 0; | |
398 | + wrq.u.data.flags = 0; | |
399 | + if(ioctl(skfd, SIOCGIWRANGE, &wrq) < 0) | |
400 | + fprintf(stderr, "%-8.8s no encryption keys information.\n\n", | |
401 | + ifname); | |
402 | + else | |
403 | + { | |
404 | + printf("%-8.8s ", ifname); | |
405 | + if((range.num_encoding_sizes > 0) && | |
406 | + (range.num_encoding_sizes < IW_MAX_ENCODING_SIZES)) | |
407 | + { | |
408 | + printf("%d key sizes : %d", range.num_encoding_sizes, | |
409 | + range.encoding_size[0] * 8); | |
410 | + /* Print them all */ | |
411 | + for(k = 1; k < range.num_encoding_sizes; k++) | |
412 | + printf(", %d", range.encoding_size[k] * 8); | |
413 | + printf("bits\n "); | |
414 | + } | |
415 | + printf("%d keys available :\n", range.max_encoding_tokens); | |
416 | + for(k = 1; k <= range.max_encoding_tokens; k++) | |
417 | + { | |
418 | + strcpy(wrq.ifr_name, ifname); | |
419 | + wrq.u.data.pointer = (caddr_t) key; | |
420 | + wrq.u.data.length = 0; | |
421 | + wrq.u.data.flags = k; | |
422 | + if(ioctl(skfd, SIOCGIWENCODE, &wrq) < 0) | |
423 | + { | |
424 | + fprintf(stderr, "SIOCGIWENCODE: %s\n", strerror(errno)); | |
425 | + break; | |
426 | + } | |
427 | + if((wrq.u.data.flags & IW_ENCODE_DISABLED) || | |
428 | + (wrq.u.data.length == 0)) | |
429 | + printf("\t\t[%d]: off\n", k); | |
430 | + else | |
431 | + { | |
432 | + int i; | |
433 | + | |
434 | + printf("\t\t[%d]: %.2X", k, key[0]); | |
435 | + for(i = 1; i < wrq.u.data.length; i++) | |
436 | + { | |
437 | + if((i & 0x1) == 0) | |
438 | + printf("-"); | |
439 | + printf("%.2X", key[i]); | |
440 | + } | |
441 | + | |
442 | + /* Other info... */ | |
443 | + printf(" (%d bits)", wrq.u.data.length * 8); | |
444 | + printf("\n"); | |
445 | + } | |
446 | + } | |
447 | + | |
448 | + printf("\n\n"); | |
449 | + } | |
450 | +} | |
451 | + | |
452 | +/*------------------------------------------------------------------*/ | |
453 | +/* | |
454 | + * Get bit-rate info on all devices and print it on the screen | |
455 | + */ | |
456 | +static void | |
457 | +print_keys_devices(int skfd) | |
458 | +{ | |
459 | + char buff[1024]; | |
460 | + struct ifconf ifc; | |
461 | + struct ifreq *ifr; | |
462 | + int i; | |
463 | + | |
464 | + /* Get list of active devices */ | |
465 | + ifc.ifc_len = sizeof(buff); | |
466 | + ifc.ifc_buf = buff; | |
467 | + if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0) | |
468 | + { | |
469 | + fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno)); | |
470 | + return; | |
471 | + } | |
472 | + ifr = ifc.ifc_req; | |
473 | + | |
474 | + /* Print them */ | |
475 | + for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++) | |
476 | + print_keys_info(skfd, ifr->ifr_name); | |
477 | +} | |
389 | 478 | |
390 | 479 | /************************* SETTING ROUTINES **************************/ |
391 | 480 |
@@ -528,7 +617,6 @@ main(int argc, | ||
528 | 617 | exit(0); |
529 | 618 | } |
530 | 619 | |
531 | -#if WIRELESS_EXT > 5 | |
532 | 620 | /* Access Point list */ |
533 | 621 | if(!strcasecmp(argv[1], "ap")) |
534 | 622 | { |
@@ -536,9 +624,7 @@ main(int argc, | ||
536 | 624 | close(skfd); |
537 | 625 | exit(0); |
538 | 626 | } |
539 | -#endif /* WIRELESS_EXT > 5 */ | |
540 | 627 | |
541 | -#if WIRELESS_EXT > 7 | |
542 | 628 | /* Bit-rate list */ |
543 | 629 | if((!strncmp(argv[1], "bit", 3)) || |
544 | 630 | (!strcmp(argv[1], "rate"))) |
@@ -547,7 +633,15 @@ main(int argc, | ||
547 | 633 | close(skfd); |
548 | 634 | exit(0); |
549 | 635 | } |
550 | -#endif /* WIRELESS_EXT > 7 */ | |
636 | + | |
637 | + /* Encryption key list */ | |
638 | + if((!strncmp(argv[1], "enc", 3)) || | |
639 | + (!strncmp(argv[1], "key", 3))) | |
640 | + { | |
641 | + print_keys_devices(skfd); | |
642 | + close(skfd); | |
643 | + exit(0); | |
644 | + } | |
551 | 645 | |
552 | 646 | /* The device name must be the first argument */ |
553 | 647 | /* Name only : show spy list for that device only */ |
@@ -568,7 +662,6 @@ main(int argc, | ||
568 | 662 | exit(0); |
569 | 663 | } |
570 | 664 | |
571 | -#if WIRELESS_EXT > 5 | |
572 | 665 | /* Access Point list */ |
573 | 666 | if(!strcasecmp(argv[2], "ap")) |
574 | 667 | { |
@@ -576,9 +669,7 @@ main(int argc, | ||
576 | 669 | close(skfd); |
577 | 670 | exit(0); |
578 | 671 | } |
579 | -#endif /* WIRELESS_EXT > 5 */ | |
580 | 672 | |
581 | -#if WIRELESS_EXT > 7 | |
582 | 673 | /* Access Point list */ |
583 | 674 | if((!strncmp(argv[2], "bit", 3)) || |
584 | 675 | (!strcmp(argv[2], "rate"))) |
@@ -587,7 +678,15 @@ main(int argc, | ||
587 | 678 | close(skfd); |
588 | 679 | exit(0); |
589 | 680 | } |
590 | -#endif /* WIRELESS_EXT > 7 */ | |
681 | + | |
682 | + /* Access Point list */ | |
683 | + if((!strncmp(argv[2], "enc", 3)) || | |
684 | + (!strncmp(argv[2], "key", 3))) | |
685 | + { | |
686 | + print_keys_info(skfd, argv[1]); | |
687 | + close(skfd); | |
688 | + exit(0); | |
689 | + } | |
591 | 690 | |
592 | 691 | /* Otherwise, it's a list of address to set in the spy list */ |
593 | 692 | goterr = set_spy_info(skfd, argv + 2, argc - 2, argv[1]); |
@@ -0,0 +1,105 @@ | ||
1 | +#define MAX_KEY_SIZE 16 | |
2 | +#define MAX_KEYS 8 | |
3 | +int key_on = 0; | |
4 | +int key_open = 1; | |
5 | +int key_current = 0; | |
6 | +char key_table[MAX_KEYS][MAX_KEY_SIZE]; | |
7 | +int key_size[MAX_KEYS]; | |
8 | + | |
9 | +#if WIRELESS_EXT > 8 | |
10 | + case SIOCSIWENCODE: | |
11 | + /* Basic checking... */ | |
12 | + if(wrq->u.encoding.pointer != (caddr_t) 0) | |
13 | + { | |
14 | + int index = (wrq->u.encoding.flags & IW_ENCODE_INDEX) - 1; | |
15 | + | |
16 | + /* Check the size of the key */ | |
17 | + if(wrq->u.encoding.length > MAX_KEY_SIZE) | |
18 | + { | |
19 | + ret = -EINVAL; | |
20 | + break; | |
21 | + } | |
22 | + | |
23 | + /* Check the index */ | |
24 | + if((index < 0) || (index >= MAX_KEYS)) | |
25 | + index = key_current; | |
26 | + | |
27 | + /* Copy the key in the driver */ | |
28 | + if(copy_from_user(key_table[index], wrq->u.encoding.pointer, | |
29 | + wrq->u.encoding.length)) | |
30 | + { | |
31 | + key_size[index] = 0; | |
32 | + ret = -EFAULT; | |
33 | + break; | |
34 | + } | |
35 | + key_size[index] = wrq->u.encoding.length; | |
36 | + key_on = 1; | |
37 | + } | |
38 | + else | |
39 | + { | |
40 | + int index = (wrq->u.encoding.flags & IW_ENCODE_INDEX) - 1; | |
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 | + ret = -EINVAL; | |
51 | + } | |
52 | + } | |
53 | + | |
54 | + /* Read the flags */ | |
55 | + if(wrq->u.encoding.flags & IW_ENCODE_DISABLED) | |
56 | + key_on = 0; /* disable encryption */ | |
57 | + if(wrq->u.encoding.flags & IW_ENCODE_RESTRICTED) | |
58 | + key_open = 0; /* disable open mode */ | |
59 | + if(wrq->u.encoding.flags & IW_ENCODE_OPEN) | |
60 | + key_open = 1; /* enable open mode */ | |
61 | + | |
62 | + break; | |
63 | + | |
64 | + case SIOCGIWENCODE: | |
65 | + /* only super-user can see encryption key */ | |
66 | + if(!suser()) | |
67 | + { | |
68 | + ret = -EPERM; | |
69 | + break; | |
70 | + } | |
71 | + | |
72 | + /* Basic checking... */ | |
73 | + if(wrq->u.encoding.pointer != (caddr_t) 0) | |
74 | + { | |
75 | + int index = (wrq->u.encoding.flags & IW_ENCODE_INDEX) - 1; | |
76 | + | |
77 | + /* Set the flags */ | |
78 | + wrq->u.encoding.flags = 0; | |
79 | + if(key_on == 0) | |
80 | + wrq->u.encoding.flags |= IW_ENCODE_DISABLED; | |
81 | + if(key_open == 0) | |
82 | + wrq->u.encoding.flags |= IW_ENCODE_RESTRICTED; | |
83 | + else | |
84 | + wrq->u.encoding.flags |= IW_ENCODE_OPEN; | |
85 | + | |
86 | + /* Which key do we want */ | |
87 | + if((index < 0) || (index >= MAX_KEYS)) | |
88 | + index = key_current; | |
89 | + wrq->u.encoding.flags |= index + 1; | |
90 | + | |
91 | + /* Copy the key to the user buffer */ | |
92 | + wrq->u.encoding.length = key_size[index]; | |
93 | + if(copy_to_user(wrq->u.encoding.pointer, key_table[index], | |
94 | + key_size[index])) | |
95 | + ret = -EFAULT; | |
96 | + } | |
97 | + break; | |
98 | +#endif /* WIRELESS_EXT > 8 */ | |
99 | + | |
100 | +#if WIRELESS_EXT > 8 | |
101 | + range.encoding_size[0] = 8; /* DES = 64 bits key */ | |
102 | + range.encoding_size[1] = 16; | |
103 | + range.num_encoding_sizes = 2; | |
104 | + range.max_encoding_tokens = 8; | |
105 | +#endif /* WIRELESS_EXT > 8 */ |
@@ -1,347 +0,0 @@ | ||
1 | -/* | |
2 | - * This file define a set of standard wireless extensions | |
3 | - * | |
4 | - * Version : 7 23.4.99 | |
5 | - * | |
6 | - * Authors : Jean Tourrilhes - HPLB - <jt@hplb.hpl.hp.com> | |
7 | - */ | |
8 | - | |
9 | -#ifndef _LINUX_WIRELESS_H | |
10 | -#define _LINUX_WIRELESS_H | |
11 | - | |
12 | -/************************** DOCUMENTATION **************************/ | |
13 | -/* | |
14 | - * Basically, the wireless extensions are for now a set of standard ioctl | |
15 | - * call + /proc/net/wireless | |
16 | - * | |
17 | - * The entry /proc/net/wireless give statistics and information on the | |
18 | - * driver. | |
19 | - * This is better than having each driver having its entry because | |
20 | - * its centralised and we may remove the driver module safely. | |
21 | - * | |
22 | - * Ioctl are used to configure the driver and issue commands. This is | |
23 | - * better than command line options of insmod because we may want to | |
24 | - * change dynamically (while the driver is running) some parameters. | |
25 | - * | |
26 | - * The ioctl mechanimsm are copied from standard devices ioctl. | |
27 | - * We have the list of command plus a structure descibing the | |
28 | - * data exchanged... | |
29 | - * Note that to add these ioctl, I was obliged to modify : | |
30 | - * net/core/dev.c (two place + add include) | |
31 | - * net/ipv4/af_inet.c (one place + add include) | |
32 | - * | |
33 | - * /proc/net/wireless is a copy of /proc/net/dev. | |
34 | - * We have a structure for data passed from the driver to /proc/net/wireless | |
35 | - * Too add this, I've modified : | |
36 | - * net/core/dev.c (two other places) | |
37 | - * include/linux/netdevice.h (one place) | |
38 | - * include/linux/proc_fs.h (one place) | |
39 | - * | |
40 | - * Do not add here things that are redundant with other mechanisms | |
41 | - * (drivers init, ifconfig, /proc/net/dev, ...) and with are not | |
42 | - * wireless specific. | |
43 | - * | |
44 | - * These wireless extensions are not magic : each driver has to provide | |
45 | - * support for them... | |
46 | - * | |
47 | - * IMPORTANT NOTE : As everything in the kernel, this is very much a | |
48 | - * work in progress. Contact me if you have ideas of improvements... | |
49 | - */ | |
50 | - | |
51 | -/***************************** INCLUDES *****************************/ | |
52 | - | |
53 | -#if 0 | |
54 | -#include <linux/types.h> /* for "caddr_t" et al */ | |
55 | -#include <linux/socket.h> /* for "struct sockaddr" et al */ | |
56 | -#include <linux/if.h> /* for IFNAMSIZ and co... */ | |
57 | -#endif | |
58 | - | |
59 | -/**************************** CONSTANTS ****************************/ | |
60 | - | |
61 | -/* --------------------------- VERSION --------------------------- */ | |
62 | -/* | |
63 | - * This constant is used to know the availability of the wireless | |
64 | - * extensions and to know which version of wireless extensions it is | |
65 | - * (there is some stuff that will be added in the future...) | |
66 | - * I just plan to increment with each new version. | |
67 | - */ | |
68 | -#define WIRELESS_EXT 6 | |
69 | - | |
70 | -/* | |
71 | - * Changes : | |
72 | - * | |
73 | - * V2 to V3 | |
74 | - * -------- | |
75 | - * Alan Cox start some incompatibles changes. I've integrated a bit more. | |
76 | - * - Encryption renamed to Encode to avoid US regulation problems | |
77 | - * - Frequency changed from float to struct to avoid problems on old 386 | |
78 | - * | |
79 | - * V3 to V4 | |
80 | - * -------- | |
81 | - * - Add sensitivity | |
82 | - * | |
83 | - * V4 to V5 | |
84 | - * -------- | |
85 | - * - Missing encoding definitions in range | |
86 | - * - Access points stuff | |
87 | - * | |
88 | - * V5 to V6 | |
89 | - * -------- | |
90 | - * - 802.11 support (ESSID ioctls) | |
91 | - * | |
92 | - * V6 to V7 | |
93 | - * -------- | |
94 | - * - define IW_ESSID_MAX_SIZE and IW_MAX_AP | |
95 | - */ | |
96 | - | |
97 | -/* -------------------------- IOCTL LIST -------------------------- */ | |
98 | - | |
99 | -/* Basic operations */ | |
100 | -#define SIOCSIWNAME 0x8B00 /* Unused ??? */ | |
101 | -#define SIOCGIWNAME 0x8B01 /* get name */ | |
102 | -#define SIOCSIWNWID 0x8B02 /* set network id */ | |
103 | -#define SIOCGIWNWID 0x8B03 /* get network id */ | |
104 | -#define SIOCSIWFREQ 0x8B04 /* set channel/frequency */ | |
105 | -#define SIOCGIWFREQ 0x8B05 /* get channel/frequency */ | |
106 | -#define SIOCSIWENCODE 0x8B06 /* set encoding info */ | |
107 | -#define SIOCGIWENCODE 0x8B07 /* get encoding info */ | |
108 | -#define SIOCSIWSENS 0x8B08 /* set sensitivity */ | |
109 | -#define SIOCGIWSENS 0x8B09 /* get sensitivity */ | |
110 | - | |
111 | -/* Informative stuff */ | |
112 | -#define SIOCSIWRANGE 0x8B0A /* Unused ??? */ | |
113 | -#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */ | |
114 | -#define SIOCSIWPRIV 0x8B0C /* Unused ??? */ | |
115 | -#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */ | |
116 | - | |
117 | -/* Mobile IP support */ | |
118 | -#define SIOCSIWSPY 0x8B10 /* set spy addresses */ | |
119 | -#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */ | |
120 | - | |
121 | -/* Access Point manipulation */ | |
122 | -#define SIOCSIWAP 0x8B14 /* set access point hardware addresses */ | |
123 | -#define SIOCGIWAP 0x8B15 /* get access point hardware addresses */ | |
124 | -#define SIOCGIWAPLIST 0x8B17 /* get list of access point in range */ | |
125 | - | |
126 | -/* 802.11 specific support */ | |
127 | -#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */ | |
128 | -#define SIOCGIWESSID 0x8B1B /* get ESSID */ | |
129 | -/* As the ESSID is a string up to 32 bytes long, it doesn't fit within the | |
130 | - * 'iwreq' structure, so we need to use the 'data' member to point to a | |
131 | - * string in user space, like it is done for RANGE... | |
132 | - * The "flags" member indicate if the ESSID is active or not. | |
133 | - */ | |
134 | - | |
135 | -/* ------------------------- IOCTL STUFF ------------------------- */ | |
136 | - | |
137 | -/* The first and the last (range) */ | |
138 | -#define SIOCIWFIRST 0x8B00 | |
139 | -#define SIOCIWLAST 0x8B1B | |
140 | - | |
141 | -/* Even : get (world access), odd : set (root access) */ | |
142 | -#define IW_IS_SET(cmd) (!((cmd) & 0x1)) | |
143 | -#define IW_IS_GET(cmd) ((cmd) & 0x1) | |
144 | - | |
145 | -/* ------------------------- PRIVATE INFO ------------------------- */ | |
146 | -/* | |
147 | - * The following is used with SIOCGIWPRIV. It allow a driver to define | |
148 | - * the interface (name, type of data) for its private ioctl. | |
149 | - * Privates ioctl are SIOCDEVPRIVATE -> SIOCDEVPRIVATE + 0xF | |
150 | - */ | |
151 | - | |
152 | -#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */ | |
153 | -#define IW_PRIV_TYPE_NONE 0x0000 | |
154 | -#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */ | |
155 | -#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */ | |
156 | -#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */ | |
157 | -#define IW_PRIV_TYPE_FLOAT 0x5000 | |
158 | - | |
159 | -#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed nuber of args */ | |
160 | - | |
161 | -#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */ | |
162 | - | |
163 | -/* | |
164 | - * Note : if the number of args is fixed and the size < 16 octets, | |
165 | - * instead of passing a pointer we will put args in the iwreq struct... | |
166 | - */ | |
167 | - | |
168 | -/* ----------------------- OTHER CONSTANTS ----------------------- */ | |
169 | - | |
170 | -/* Maximum frequencies in the range struct */ | |
171 | -#define IW_MAX_FREQUENCIES 16 | |
172 | -/* Note : if you have something like 80 frequencies, | |
173 | - * don't increase this constant and don't fill the frequency list. | |
174 | - * The user will be able to set by channel anyway... */ | |
175 | - | |
176 | -/* Maximum of address that you may set with SPY */ | |
177 | -#define IW_MAX_SPY 8 | |
178 | - | |
179 | -/* Maximum of address that you may get in the | |
180 | - list of access points in range */ | |
181 | -#define IW_MAX_AP 8 | |
182 | - | |
183 | -/* Maximum size of the ESSID string */ | |
184 | -#define IW_ESSID_MAX_SIZE 32 | |
185 | - | |
186 | -/****************************** TYPES ******************************/ | |
187 | - | |
188 | -/* --------------------------- SUBTYPES --------------------------- */ | |
189 | -/* | |
190 | - * A frequency | |
191 | - * For numbers lower than 10^9, we encode the number in 'mant' and | |
192 | - * set 'exp' to 0 | |
193 | - * For number greater than 10^9, we divide it by a power of 10. | |
194 | - * The power of 10 is in 'exp', the result is in 'mant'. | |
195 | - */ | |
196 | -struct iw_freq | |
197 | -{ | |
198 | - __u32 m; /* Mantissa */ | |
199 | - __u16 e; /* Exponent */ | |
200 | -}; | |
201 | - | |
202 | -/* | |
203 | - * Quality of the link | |
204 | - */ | |
205 | -struct iw_quality | |
206 | -{ | |
207 | - __u8 qual; /* link quality (SNR or better...) */ | |
208 | - __u8 level; /* signal level */ | |
209 | - __u8 noise; /* noise level */ | |
210 | - __u8 updated; /* Flags to know if updated */ | |
211 | -}; | |
212 | - | |
213 | -/* | |
214 | - * Packet discarded in the wireless adapter due to | |
215 | - * "wireless" specific problems... | |
216 | - */ | |
217 | -struct iw_discarded | |
218 | -{ | |
219 | - __u32 nwid; /* Wrong nwid */ | |
220 | - __u32 code; /* Unable to code/decode */ | |
221 | - __u32 misc; /* Others cases */ | |
222 | -}; | |
223 | - | |
224 | -/* | |
225 | - * Encoding information (setting and so on) | |
226 | - * Encoding might be hardware encryption, scrambing or others | |
227 | - */ | |
228 | -struct iw_encoding | |
229 | -{ | |
230 | - __u8 method; /* Algorithm number / key used */ | |
231 | - __u64 code; /* Data/key used for algorithm */ | |
232 | -}; | |
233 | - | |
234 | - | |
235 | -/* ------------------------ WIRELESS STATS ------------------------ */ | |
236 | -/* | |
237 | - * Wireless statistics (used for /proc/net/wireless) | |
238 | - */ | |
239 | -struct iw_statistics | |
240 | -{ | |
241 | - __u8 status; /* Status | |
242 | - * - device dependent for now */ | |
243 | - | |
244 | - struct iw_quality qual; /* Quality of the link | |
245 | - * (instant/mean/max) */ | |
246 | - struct iw_discarded discard; /* Packet discarded counts */ | |
247 | -}; | |
248 | - | |
249 | -/* ------------------------ IOCTL REQUEST ------------------------ */ | |
250 | -/* | |
251 | - * The structure to exchange data for ioctl. | |
252 | - * This structure is the same as 'struct ifreq', but (re)defined for | |
253 | - * convenience... | |
254 | - * | |
255 | - * Note that it should fit on the same memory footprint ! | |
256 | - * You should check this when increasing the above structures (16 octets) | |
257 | - * 16 octets = 128 bits. Warning, pointers might be 64 bits wide... | |
258 | - */ | |
259 | -struct iwreq | |
260 | -{ | |
261 | - union | |
262 | - { | |
263 | - char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
264 | - } ifr_ifrn; | |
265 | - | |
266 | - /* Data part */ | |
267 | - union | |
268 | - { | |
269 | - /* Config - generic */ | |
270 | - char name[IFNAMSIZ]; | |
271 | - /* Name : used to verify the presence of wireless extensions. | |
272 | - * Name of the protocol/provider... */ | |
273 | - | |
274 | - struct /* network id (or domain) : used to to */ | |
275 | - { /* create logical channels on the air */ | |
276 | - __u32 nwid; /* value */ | |
277 | - __u8 on; /* active/unactive nwid */ | |
278 | - } nwid; | |
279 | - | |
280 | - struct iw_freq freq; /* frequency or channel : | |
281 | - * 0-1000 = channel | |
282 | - * > 1000 = frequency in Hz */ | |
283 | - | |
284 | - struct iw_encoding encoding; /* Encoding stuff */ | |
285 | - | |
286 | - __u32 sensitivity; /* signal level threshold */ | |
287 | - | |
288 | - struct sockaddr ap_addr; /* Access point address */ | |
289 | - | |
290 | - struct /* For all data bigger than 16 octets */ | |
291 | - { | |
292 | - caddr_t pointer; /* Pointer to the data | |
293 | - * (in user space) */ | |
294 | - __u16 length; /* fields or byte size */ | |
295 | - __u16 flags; /* Optional params */ | |
296 | - } data; | |
297 | - } u; | |
298 | -}; | |
299 | - | |
300 | -/* -------------------------- IOCTL DATA -------------------------- */ | |
301 | -/* | |
302 | - * For those ioctl which want to exchange mode data that what could | |
303 | - * fit in the above structure... | |
304 | - */ | |
305 | - | |
306 | -/* | |
307 | - * Range of parameters | |
308 | - */ | |
309 | - | |
310 | -struct iw_range | |
311 | -{ | |
312 | - /* Informative stuff (to choose between different interface) */ | |
313 | - __u32 throughput; /* To give an idea... */ | |
314 | - | |
315 | - /* NWID (or domain id) */ | |
316 | - __u32 min_nwid; /* Minimal NWID we are able to set */ | |
317 | - __u32 max_nwid; /* Maximal NWID we are able to set */ | |
318 | - | |
319 | - /* Frequency */ | |
320 | - __u16 num_channels; /* Number of channels [0; num - 1] */ | |
321 | - __u8 num_frequency; /* Number of entry in the list */ | |
322 | - struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */ | |
323 | - /* Note : this frequency list doesn't need to fit channel numbers */ | |
324 | - | |
325 | - /* signal level threshold range */ | |
326 | - __u32 sensitivity; | |
327 | - | |
328 | - /* Quality of link & SNR stuff */ | |
329 | - struct iw_quality max_qual; /* Quality of the link */ | |
330 | - | |
331 | - /* Encoder stuff */ | |
332 | - struct iw_encoding max_encoding; /* Encoding max range */ | |
333 | -}; | |
334 | - | |
335 | -/* | |
336 | - * Private ioctl interface information | |
337 | - */ | |
338 | - | |
339 | -struct iw_priv_args | |
340 | -{ | |
341 | - __u32 cmd; /* Number of the ioctl to issue */ | |
342 | - __u16 set_args; /* Type and number of args */ | |
343 | - __u16 get_args; /* Type and number of args */ | |
344 | - char name[IFNAMSIZ]; /* Name of the extension */ | |
345 | -}; | |
346 | - | |
347 | -#endif /* _LINUX_WIRELESS_H */ |