/*
* Wireless Tools
*
- * Jean II - HPLB 97->99 - HPL 99->04
+ * Jean II - HPLB 97->99 - HPL 99->09
*
* Common header for the Wireless Extension library...
*
* This file is released under the GPL license.
- * Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com>
+ * Copyright (c) 1997-2009 Jean Tourrilhes <jt@hpl.hp.com>
*/
#ifndef IWLIB_H
#define IWLIB_H
-/*#include "CHANGELOG.h"*/
-
/***************************** INCLUDES *****************************/
/* Standard headers */
#include <unistd.h>
/* This is our header selection. Try to hide the mess and the misery :-(
- * Don't look, you would go blind ;-) */
-
-#ifndef LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif
-
-/* Kernel headers 2.4.X + Glibc 2.2 - Mandrake 8.0, Debian 2.3, RH 7.1
- * Kernel headers 2.2.X + Glibc 2.2 - Slackware 8.0 */
-#if defined(__GLIBC__) \
- && __GLIBC__ == 2 \
- && __GLIBC_MINOR__ >= 2 \
- && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
-#define HEADERS_GENERIC
-
-/* Kernel headers 2.4.X + Glibc 2.1 - Debian 2.2 upgraded, RH 7.0
- * Kernel headers 2.2.X + Glibc 2.1 - Debian 2.2, RH 6.1 */
-#elif defined(__GLIBC__) \
- && __GLIBC__ == 2 \
- && __GLIBC_MINOR__ == 1 \
- && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
-#define HEADERS_GENERIC
-#define HEADERS_KERNEL
-
-/* Unsupported combination */
-#else
-#error "Your kernel/libc combination is not supported"
-#endif
+ * Don't look, you would go blind ;-)
+ * Note : compatibility with *old* distributions has been removed,
+ * you will need Glibc 2.2 and older to compile (which means
+ * Mandrake 8.0, Debian 2.3, RH 7.1 or older).
+ */
-#ifdef HEADERS_GENERIC
-/* Proposed by Dr. Michael Rietz <rietz@mail.amps.de>, 27.3.2 */
+/* Set of headers proposed by Dr. Michael Rietz <rietz@mail.amps.de>, 27.3.2 */
#include <net/if_arp.h> /* For ARPHRD_ETHER */
#include <sys/socket.h> /* For AF_INET & struct sockaddr */
#include <netinet/in.h> /* For struct sockaddr_in */
#include <netinet/if_ether.h>
-#endif /* HEADERS_GENERIC */
/* Fixup to be able to include kernel includes in userspace.
* Basically, kill the sparse annotations... Jean II */
#include <linux/types.h> /* for "caddr_t" et al */
-#ifdef HEADERS_KERNEL
-/* Traditionally we have used kernel headers, included in wireless.h */
-#include <linux/socket.h> /* for "struct sockaddr" et al */
-#include <linux/if.h> /* for IFNAMSIZ and co... */
-#else /* !HEADERS_KERNEL */
/* Glibc systems headers are supposedly less problematic than kernel ones */
#include <sys/socket.h> /* for "struct sockaddr" et al */
#include <net/if.h> /* for IFNAMSIZ and co... */
-#endif /* !HEADERS_KERNEL */
/* Private copy of Wireless extensions (in this directoty) */
#include "wireless.h"
-/* Make gcc understant that when we say inline, we mean it.
- * I really hate when the compiler is trying to be more clever than me,
- * because in this case gcc is not able to figure out functions with a
- * single call site, so not only I have to tag those functions inline
- * by hand, but then it refuse to inline them properly.
- * Total saving for iwevent : 150B = 0.7%.
- * Fortunately, in gcc 3.4, they now automatically inline static functions
- * with a single call site. Hurrah !
- * Jean II */
-#undef IW_GCC_HAS_BROKEN_INLINE
-#if __GNUC__ == 3
-#if __GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 4
-#define IW_GCC_HAS_BROKEN_INLINE 1
-#endif /* __GNUC_MINOR__ */
-#endif /* __GNUC__ */
-/* However, gcc 4.0 has introduce a new "feature", when compiling with
- * '-Os', it does not want to inline iw_ether_cmp() and friends.
- * So, we need to fix inline again !
- * Jean II */
-#if __GNUC__ == 4
-#define IW_GCC_HAS_BROKEN_INLINE 1
-#endif /* __GNUC__ */
-/* Now, really fix the inline */
-#ifdef IW_GCC_HAS_BROKEN_INLINE
-#ifdef inline
-#undef inline
-#endif /* inline */
-#define inline inline __attribute__((always_inline))
-#endif /* IW_GCC_HAS_BROKEN_INLINE */
-
#ifdef __cplusplus
extern "C" {
#endif
-/****************************** DEBUG ******************************/
-
-
/************************ CONSTANTS & MACROS ************************/
/* Various versions information */
/* Recommended Wireless Extension version */
-#define WE_VERSION 20
+#define WE_VERSION 22
/* Maximum forward compatibility built in this version of WT */
-#define WE_MAX_VERSION 21
+#define WE_MAX_VERSION 22
/* Version of Wireless Tools */
-#define WT_VERSION 28
-
-/* Paths */
-#define PROC_NET_WIRELESS "/proc/net/wireless"
-#define PROC_NET_DEV "/proc/net/dev"
-
-/* Some usefull constants */
-#define KILO 1e3
-#define MEGA 1e6
-#define GIGA 1e9
-/* For doing log10/exp10 without libm */
-#define LOG10_MAGIC 1.25892541179
-
-/* Backward compatibility for network headers */
-#ifndef ARPHRD_IEEE80211
-#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
-#endif /* ARPHRD_IEEE80211 */
+#define WT_VERSION 30
/****************************** TYPES ******************************/
int key_flags; /* Various flags */
int has_essid;
int essid_on;
- char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
+ char essid[IW_ESSID_MAX_SIZE + 2]; /* ESSID (extended network) */
+ int essid_len;
int has_mode;
int mode; /* Operation mode */
} wireless_config;
int has_sens;
iwparam sens; /* sensitivity */
int has_nickname;
- char nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */
+ char nickname[IW_ESSID_MAX_SIZE + 2]; /* NickName */
int has_ap_addr;
sockaddr ap_addr; /* Access point address */
int has_bitrate;
struct wireless_config b; /* Basic information */
iwstats stats; /* Signal strength */
int has_stats;
+ iwparam maxbitrate; /* Max bit rate in bps */
+ int has_maxbitrate;
} wireless_scan;
/*
char * args[],
int count);
+/* Describe a modulation */
+typedef struct iw_modul_descr
+{
+ unsigned int mask; /* Modulation bitmask */
+ char cmd[8]; /* Short name */
+ char * verbose; /* Verbose description */
+} iw_modul_descr;
+
/**************************** PROTOTYPES ****************************/
/*
- * All the functions in iwcommon.c
+ * All the functions in iwlib.c
*/
/* ---------------------- SOCKET SUBROUTINES -----------------------*/
int
iw_protocol_compare(const char * protocol1,
const char * protocol2);
+/* ---------------------- ESSID SUBROUTINES ---------------------- */
+void
+ iw_essid_escape(char * dest,
+ const char * src,
+ const int slen);
+int
+ iw_essid_unescape(char * dest,
+ const char * src);
/* -------------------- FREQUENCY SUBROUTINES --------------------- */
void
iw_float2freq(double in,
iw_print_pm_value(char * buffer,
int buflen,
int value,
- int flags);
+ int flags,
+ int we_version);
void
iw_print_pm_mode(char * buffer,
int buflen,
iw_print_retry_value(char * buffer,
int buflen,
int value,
- int flags);
+ int flags,
+ int we_version);
/* ----------------------- TIME SUBROUTINES ----------------------- */
void
iw_print_timeval(char * buffer,
int
iw_check_if_addr_type(int skfd,
const char * ifname);
-#if 0
-int
- iw_check_addr_type(int skfd,
- const char * ifname);
-#endif
-#if 0
-int
- iw_get_mac_addr(int skfd,
- const char * name,
- struct ether_addr * eth,
- unsigned short * ptype);
-#endif
char *
iw_mac_ntop(const unsigned char * mac,
int maclen,
/* Modes as human readable strings */
extern const char * const iw_operation_mode[];
#define IW_NUM_OPER_MODE 7
+#define IW_NUM_OPER_MODE_EXT 8
+
+/* Modulations as human readable strings */
+extern const struct iw_modul_descr iw_modul_list[];
+#define IW_SIZE_MODUL_LIST 16
/************************* INLINE FUNTIONS *************************/
/*
* Functions that are so simple that it's more efficient inlining them
+ * Most inline are private because gcc is fussy about inline...
*/
/*
/*
* Wrapper to push some Wireless Parameter in the driver
*/
-static inline int
+static inline __attribute__((always_inline)) int
iw_set_ext(int skfd, /* Socket to the kernel */
const char * ifname, /* Device name */
int request, /* WE ID */
/*
* Wrapper to extract some Wireless Parameter out of the driver
*/
-static inline int
+static inline __attribute__((always_inline)) int
iw_get_ext(int skfd, /* Socket to the kernel */
const char * ifname, /* Device name */
int request, /* WE ID */
close(skfd);
}
-/*------------------------------------------------------------------*/
-/*
- * Display an Ethernet Socket Address in readable format.
- */
-static inline char *
-iw_saether_ntop(const struct sockaddr *sap, char* bufp)
-{
- iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp);
- return bufp;
-}
-/*------------------------------------------------------------------*/
-/*
- * Input an Ethernet Socket Address and convert to binary.
- */
-static inline int
-iw_saether_aton(const char *bufp, struct sockaddr *sap)
-{
- sap->sa_family = ARPHRD_ETHER;
- return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data);
-}
-
-/*------------------------------------------------------------------*/
-/*
- * Create an Ethernet broadcast address
- */
-static inline void
-iw_broad_ether(struct sockaddr *sap)
-{
- sap->sa_family = ARPHRD_ETHER;
- memset((char *) sap->sa_data, 0xFF, ETH_ALEN);
-}
-
-/*------------------------------------------------------------------*/
-/*
- * Create an Ethernet NULL address
- */
-static inline void
-iw_null_ether(struct sockaddr *sap)
-{
- sap->sa_family = ARPHRD_ETHER;
- memset((char *) sap->sa_data, 0x00, ETH_ALEN);
-}
-
-/*------------------------------------------------------------------*/
-/*
- * Compare two ethernet addresses
- */
-static inline int
-iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2)
-{
- return memcmp(eth1, eth2, sizeof(*eth1));
-}
-
#ifdef __cplusplus
}
#endif