4 * Jean II - HPLB 97->99 - HPL 99->01
6 * Common header for the Wireless Extension library...
8 * This file is released under the GPL license.
14 /*#include "CHANGELOG.h"*/
16 /***************************** INCLUDES *****************************/
18 /* Standard headers */
19 #include <sys/types.h>
20 #include <sys/ioctl.h>
29 #include <netdb.h> /* gethostbyname, getnetbyname */
31 /* This is our header selection. Try to hide the mess and the misery :-(
32 * The selection has been moved in the Makefile, here we have only
33 * the ugly part. Don't look, you would go blind ;-) */
36 #include <socketbits.h>
37 #endif /* KLUDGE_HEADERS */
39 #if defined(KLUDGE_HEADERS) || defined(GLIBC_HEADERS)
40 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
41 #include <linux/socket.h> /* For AF_INET & struct sockaddr */
42 #include <linux/in.h> /* For struct sockaddr_in */
43 #endif /* KLUDGE_HEADERS || GLIBC_HEADERS */
45 #ifdef GLIBC22_HEADERS
46 /* Added by Ross G. Miller <Ross_Miller@baylor.edu>, 3/28/01 */
47 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
48 #include <linux/socket.h> /* For AF_INET & struct sockaddr */
49 #include <sys/socket.h>
50 #endif /* GLIBC22_HEADERS */
53 #include <sys/socket.h> /* For AF_INET & struct sockaddr & socket() */
54 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
55 #include <linux/in.h> /* For struct sockaddr_in */
56 #endif /* LIBC5_HEADERS */
58 #ifdef PRIVATE_WE_HEADER
59 /* Private copy of Wireless extensions */
61 #else /* PRIVATE_WE_HEADER */
62 /* System wide Wireless extensions */
63 #include <linux/wireless.h>
64 #endif /* PRIVATE_WE_HEADER */
67 #error "Wireless Extension v9 or newer required :-(\
68 Use Wireless Tools v19 or update your kernel headers"
71 #warning "Wireless Extension v11 recommended...\
72 You may update your kernel and/or system headers to get the new features..."
75 /****************************** DEBUG ******************************/
78 /************************ CONSTANTS & MACROS ************************/
80 /* Some usefull constants */
85 /* Backward compatibility for Wireless Extension 9 */
86 #ifndef IW_POWER_MODIFIER
87 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
88 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
89 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
90 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
91 #endif IW_POWER_MODIFIER
93 #ifndef IW_ENCODE_NOKEY
94 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not here */
95 #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
96 #endif IW_ENCODE_NOKEY
98 /****************************** TYPES ******************************/
101 typedef struct iw_statistics iwstats;
102 typedef struct iw_range iwrange;
103 typedef struct iw_param iwparam;
104 typedef struct iw_freq iwfreq;
105 typedef struct iw_quality iwqual;
106 typedef struct iw_priv_args iwprivargs;
107 typedef struct sockaddr sockaddr;
109 /* Structure for storing all wireless information for each device
110 * This is pretty exhaustive... */
111 typedef struct wireless_info
113 char name[IFNAMSIZ]; /* Wireless/protocol name */
115 iwparam nwid; /* Network ID */
117 float freq; /* Frequency/channel */
119 iwparam sens; /* sensitivity */
121 unsigned char key[IW_ENCODING_TOKEN_MAX]; /* Encoding key used */
122 int key_size; /* Number of bytes */
123 int key_flags; /* Various flags */
126 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
128 char nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */
130 sockaddr ap_addr; /* Access point address */
132 iwparam bitrate; /* Bit rate in bps */
134 iwparam rts; /* RTS threshold in bytes */
136 iwparam frag; /* Fragmentation threshold in bytes */
138 int mode; /* Operation mode */
140 iwparam power; /* Power management parameters */
142 iwparam txpower; /* Transmit Power in dBm */
144 iwparam retry; /* Retry limit or lifetime */
153 /* Structure for storing all wireless information for each device
154 * This is a cut down version of the one above, containing only
155 * the things *truly* needed to configure a card.
156 * Don't add other junk, I'll remove it... */
157 typedef struct wireless_config
159 char name[IFNAMSIZ]; /* Wireless/protocol name */
161 iwparam nwid; /* Network ID */
163 float freq; /* Frequency/channel */
165 unsigned char key[IW_ENCODING_TOKEN_MAX]; /* Encoding key used */
166 int key_size; /* Number of bytes */
167 int key_flags; /* Various flags */
170 char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
172 int mode; /* Operation mode */
175 /**************************** PROTOTYPES ****************************/
177 * All the functions in iwcommon.c
179 /* ---------------------- SOCKET SUBROUTINES -----------------------*/
181 iw_sockets_open(void);
182 /* --------------------- WIRELESS SUBROUTINES ----------------------*/
184 iw_get_range_info(int skfd,
188 iw_get_priv_info(int skfd,
192 iw_get_basic_config(int skfd,
194 wireless_config * info);
196 iw_set_basic_config(int skfd,
198 wireless_config * info);
199 /* -------------------- FREQUENCY SUBROUTINES --------------------- */
201 iw_float2freq(double in,
204 iw_freq2float(iwfreq * in);
205 /* ---------------------- POWER SUBROUTINES ----------------------- */
207 iw_dbm2mwatt(int in);
209 iw_mwatt2dbm(int in);
210 /* -------------------- STATISTICS SUBROUTINES -------------------- */
212 iw_get_stats(int skfd,
216 iw_print_stats(char * buffer,
220 /* --------------------- ENCODING SUBROUTINES --------------------- */
222 iw_print_key(char * buffer,
226 /* ----------------- POWER MANAGEMENT SUBROUTINES ----------------- */
228 iw_print_pm_value(char * buffer,
232 iw_print_pm_mode(char * buffer,
234 /* --------------- RETRY LIMIT/LIFETIME SUBROUTINES --------------- */
235 #if WIRELESS_EXT > 10
237 iw_print_retry_value(char * buffer,
241 /* --------------------- ADDRESS SUBROUTINES ---------------------- */
243 iw_check_addr_type(int skfd,
246 iw_pr_ether(char *buffer, unsigned char *ptr);
248 iw_in_ether(char *bufp, struct sockaddr *sap);
250 iw_in_inet(char *bufp, struct sockaddr *sap);
255 struct sockaddr * sap);
256 /* ----------------------- MISC SUBROUTINES ------------------------ */
258 iw_byte_size(int args);
260 /**************************** VARIABLES ****************************/
262 extern const char * iw_operation_mode[];
263 #define IW_NUM_OPER_MODE 6