6 * Common header for the wireless tools...
12 /************************** DOCUMENTATION **************************/
17 /* --------------------------- HISTORY --------------------------- */
19 * wireless 16 : (Jean Tourrilhes)
21 * o iwconfig, iwpriv & iwspy
23 * wireless 17 : (Justin Seger)
25 * o Compile under glibc fix
26 * o merge iwpriv in iwconfig
27 * o Add Wavelan roaming support
28 * o Update man page of iwconfig
32 * (From Andreas Neuhaus <andy@fasta.fh-dortmund.de>)
33 * o Many fix to remove "core dumps" in iwconfig
34 * o Remove useless headers in iwconfig
35 * o CHAR wide private ioctl
36 * (From Jean Tourrilhes)
37 * o Create iwcommon.h and iwcommon.c
38 * o Separate iwpriv again for user interface issues
39 * The folllowing didn't make sense and crashed :
40 * iwconfig eth0 priv sethisto 12 15 nwid 100
41 * o iwspy no longer depend on net-tools-1.2.0
42 * o Reorganisation of the code, cleanup
43 * o Add ESSID stuff in iwconfig
44 * o Add display of level & noise in dBm (stats in iwconfig)
45 * o Update man page of iwconfig and iwpriv
46 * o Add xwireless (didn't check if it compiles)
47 * (From Dean W. Gehnert <deang@tpi.com>)
49 * (Jan Rafaj <rafaj@cedric.vabo.cz>)
50 * o Cosmetic changes (sensitivity relative, freq list)
51 * o Frequency computation on double
52 * o Compile clean on libc5
53 * (From Jean Tourrilhes)
54 * o Move listing of frequencies to iwspy
55 * o Add AP address stuff in iwconfig
56 * o Add AP list stuff in iwspy
60 * (From Jean Tourrilhes)
61 * o Allow for sensitivity in dBm (if < 0) [iwconfig]
62 * o Formatting changes in displaying ap address in [iwconfig]
63 * o Slightly improved man pages and usage display
64 * o Add channel number for each frequency in list [iwspy]
65 * o Add nickname... [iwconfig]
66 * o Add "port" private ioctl shortcut [iwpriv]
67 * o If signal level = 0, no range or dBms [iwconfig]
68 * o I think I now got set/get char strings right in [iwpriv]
69 * (From Thomas Ekstrom <tomeck@thelogic.com>)
70 * o Fix a very obscure bug in [iwspy]
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 ;-)
94 /* ----------------------------- TODO ----------------------------- */
100 * Make disable a per encryption key modifier if some hardware
102 * Should not mention "Access Point" but something different when
107 * Remove 'port' and 'roam' cruft now that we have mode in iwconfig
119 * What about some graphical tools ?
122 /***************************** INCLUDES *****************************/
124 /* Standard headers */
125 #include <sys/types.h>
126 #include <sys/ioctl.h>
135 #include <netdb.h> /* gethostbyname, getnetbyname */
137 /* This is our header selection. Try to hide the mess and the misery :-(
138 * Please choose only one of the define...
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
144 /* Kernel headers 2.2.X + Glibc 2.0 - Debian 2.1 */
145 #undef KLUDGE_HEADERS
147 /* Kernel headers 2.0.X + libc5 - old systems */
150 #ifdef KLUDGE_HEADERS
151 #include <socketbits.h>
152 #endif /* KLUDGE_HEADERS */
154 #if defined(KLUDGE_HEADERS) || defined(GLIBC_HEADERS)
155 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
156 #include <linux/socket.h> /* For AF_INET & struct sockaddr */
157 #include <linux/in.h> /* For struct sockaddr_in */
158 #endif /* KLUDGE_HEADERS || GLIBC_HEADERS */
161 #include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */
162 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
163 #include <linux/in.h> /* For struct sockaddr_in */
164 #endif /* LIBC5_HEADERS */
166 /* Wireless extensions */
167 #include <linux/wireless.h>
170 #error "Wireless Extension v9 or newer required :-(\n\
171 Use Wireless Tools v19 or update your kernel headers"
174 /****************************** DEBUG ******************************/
177 /************************ CONSTANTS & MACROS ************************/
179 /* Some usefull constants */
184 /****************************** TYPES ******************************/
187 typedef struct iw_statistics iwstats;
188 typedef struct iw_range iwrange;
189 typedef struct iw_param iwparam;
190 typedef struct iw_freq iwfreq;
191 typedef struct iw_priv_args iwprivargs;
192 typedef struct sockaddr sockaddr;
194 /* Structure for storing all wireless information for each device */
195 typedef struct wireless_info
197 char name[IFNAMSIZ]; /* Wireless/protocol name */
199 iwparam nwid; /* Network ID */
201 float freq; /* Frequency/channel */
203 iwparam sens; /* sensitivity */
205 unsigned char key[IW_ENCODING_TOKEN_MAX]; /* Encoding key used */
206 int key_size; /* Number of bytes */
207 int key_flags; /* Various flags */
210 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
212 char nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */
214 sockaddr ap_addr; /* Access point address */
216 iwparam bitrate; /* Bit rate in bps */
218 iwparam rts; /* RTS threshold in bytes */
220 iwparam frag; /* Fragmentation threshold in bytes */
222 int mode; /* Operation mode */
224 iwparam power; /* Power management parameters */
233 /**************************** PROTOTYPES ****************************/
235 * All the functions in iwcommon.c
237 /* ---------------------- SOCKET SUBROUTINES -----------------------*/
240 /* --------------------- WIRELESS SUBROUTINES ----------------------*/
242 get_range_info(int skfd,
246 get_priv_info(int skfd,
249 /* -------------------- FREQUENCY SUBROUTINES --------------------- */
251 float2freq(double in,
254 freq2float(iwfreq * in);
255 /* --------------------- ADDRESS SUBROUTINES ---------------------- */
257 check_addr_type(int skfd,
260 pr_ether(unsigned char *ptr);
262 in_ether(char *bufp, struct sockaddr *sap);
264 in_inet(char *bufp, struct sockaddr *sap);
269 struct sockaddr *sap);
270 /* ----------------------- MISC SUBROUTINES ------------------------ */
274 /**************************** VARIABLES ****************************/
276 #endif /* IWCOMMON_H */