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]
73 /* ----------------------------- TODO ----------------------------- */
79 * Use new 802.11 parameters (rate, rts, frag)...
94 /***************************** INCLUDES *****************************/
96 /* Standard headers */
97 #include <sys/types.h>
98 #include <sys/ioctl.h>
107 #include <netdb.h> /* gethostbyname, getnetbyname */
109 /* This is our header selection. Try to hide the mess and the misery :-(
110 * Please choose only one of the define...
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 */
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 */
123 /* Wireless extensions */
124 #include <linux/wireless.h>
126 #endif /* KER2_2_HEADERS */
129 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
130 #include <linux/socket.h> /* For AF_INET & struct sockaddr */
131 #include <linux/in.h> /* For struct sockaddr_in */
133 /* Wireless extensions */
134 #include <linux/wireless.h>
136 #endif /* LINUX_HEADERS */
139 #include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */
140 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
141 #include <linux/in.h> /* For struct sockaddr_in */
143 /* Wireless extensions */
144 #include <linux/wireless.h>
146 #endif /* LIBC5_HEADERS */
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 ! */
154 /* Wireless extensions */
155 #include "wireless.h"
157 #endif /* PRIVATE_HEADERS */
160 /****************************** DEBUG ******************************/
163 /************************ CONSTANTS & MACROS ************************/
165 /* Some usefull constants */
171 #ifndef IW_ESSID_MAX_SIZE
172 #define IW_ESSID_MAX_SIZE 32 /* Should be in wireless.h */
175 #define IW_MAX_AP 8 /* Should be in wireless.h */
178 /****************************** TYPES ******************************/
181 typedef struct iw_statistics iwstats;
182 typedef struct iw_range iwrange;
183 typedef struct iw_freq iwfreq;
184 typedef struct iw_priv_args iwprivargs;
185 typedef struct sockaddr sockaddr;
187 /* Structure for storing all wireless information for each device */
188 typedef struct wireless_info
190 char name[IFNAMSIZ]; /* Wireless/protocol name */
193 u_long nwid; /* Network ID */
195 float freq; /* Frequency/channel */
197 int sens; /* sensitivity */
199 int enc_method; /* encoding method or off */
200 long long enc_key; /* key used */
203 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
205 char nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */
207 sockaddr ap_addr; /* Access point address */
209 long bitrate; /* Bit rate in bps */
210 int bitrate_fixed; /* Fixed or auto */
212 long rts; /* RTS threshold in bytes */
213 int rts_fixed; /* Fixed or auto */
215 long frag; /* Fragmentation threshold in bytes */
216 int frag_fixed; /* Fixed or auto */
225 /**************************** PROTOTYPES ****************************/
227 * All the functions in iwcommon.c
229 /* ---------------------- SOCKET SUBROUTINES -----------------------*/
232 /* --------------------- WIRELESS SUBROUTINES ----------------------*/
234 get_range_info(int skfd,
238 get_priv_info(int skfd,
241 /* -------------------- FREQUENCY SUBROUTINES --------------------- */
243 float2freq(double in,
246 freq2float(iwfreq * in);
247 /* --------------------- ADDRESS SUBROUTINES ---------------------- */
249 check_addr_type(int skfd,
252 pr_ether(unsigned char *ptr);
254 in_ether(char *bufp, struct sockaddr *sap);
256 in_inet(char *bufp, struct sockaddr *sap);
261 struct sockaddr *sap);
262 /* ----------------------- MISC SUBROUTINES ------------------------ */
266 /**************************** VARIABLES ****************************/
268 #endif /* IWCOMMON_H */