00001 /* 00002 * vifctl/iw_compat.h 00003 * $Rev: 1259 $ 00004 * 00005 * Copyright (C) 2009 Reto Gantenbein <reto.gantenbein@gmail.com> 00006 * Copyright (C) 1997-2007 Jean Tourrilhes <jt@hpl.hp.com> 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License version 2 as 00010 * published by the Free Software Foundation. 00011 */ 00012 00013 #ifndef IWLIB_H // if iwlib.h included we don't need this 00014 00024 #ifndef __IW_COMPAT_H 00025 #define __IW_COMPAT_H 00026 00027 /* INCLUDES *******************************************************************/ 00028 00029 #include <netinet/in.h> // struct in_addr (for wireless.h) 00030 #include <linux/wireless.h> // iw_range, iw_freq, iw_param, ... 00031 #include <net/ethernet.h> // ether_addr 00032 #include <string.h> // memcmp() 00033 00034 00035 /* CONSTANTS & MACROS *********************************************************/ 00036 00038 #define WE_VERSION WIRELESS_EXT // get WE version from wireless.h 00039 00040 /* Define error types (compatible to iwconfig.c) */ 00041 #define IWERR_ARG_NUM -2 00042 #define IWERR_ARG_TYPE -3 00043 #define IWERR_ARG_SIZE -4 00044 #define IWERR_ARG_CONFLICT -5 00045 #define IWERR_SET_EXT -6 00046 #define IWERR_GET_EXT -7 00048 /* Some usefull constants */ 00049 #define KILO 1e3 00050 #define MEGA 1e6 00051 #define GIGA 1e9 00052 00053 /* Shortcuts */ 00054 typedef struct iw_statistics iwstats; 00055 typedef struct iw_range iwrange; 00056 typedef struct iw_param iwparam; 00057 typedef struct iw_freq iwfreq; 00058 typedef struct iw_quality iwqual; 00059 typedef struct iw_priv_args iwprivargs; 00060 typedef struct sockaddr sockaddr; 00061 00066 typedef struct wireless_config 00067 { 00068 char name[IFNAMSIZ + 1]; 00069 int has_nwid; 00070 iwparam nwid; 00071 int has_freq; 00072 double freq; 00073 int freq_flags; 00074 int has_key; 00075 unsigned char key[IW_ENCODING_TOKEN_MAX]; 00076 int key_size; 00077 int key_flags; 00078 int has_essid; 00079 int essid_on; 00080 char essid[IW_ESSID_MAX_SIZE + 1]; 00081 int has_mode; 00082 int mode; 00083 } 00084 wireless_config; 00085 00091 typedef struct wireless_info 00092 { 00093 struct wireless_config b; 00095 int has_sens; 00096 iwparam sens; 00097 int has_nickname; 00098 char nickname[IW_ESSID_MAX_SIZE + 1]; 00099 int has_ap_addr; 00100 sockaddr ap_addr; 00101 int has_bitrate; 00102 iwparam bitrate; 00103 int has_rts; 00104 iwparam rts; 00105 int has_frag; 00106 iwparam frag; 00107 int has_power; 00108 iwparam power; 00109 int has_txpower; 00110 iwparam txpower; 00111 int has_retry; 00112 iwparam retry; 00114 /* Stats */ 00115 iwstats stats; 00116 int has_stats; 00117 iwrange range; 00118 int has_range; 00119 00120 /* Auth params for WPA/802.1x/802.11i */ 00121 int auth_key_mgmt; 00122 int has_auth_key_mgmt; 00123 int auth_cipher_pairwise; 00124 int has_auth_cipher_pairwise; 00125 int auth_cipher_group; 00126 int has_auth_cipher_group; 00127 } 00128 wireless_info; 00129 00130 00131 /* HELPER SUBROUTINES *********************************************************/ 00132 int 00133 iw_get_param_state(struct iw_param * par); 00134 00135 00136 /* ADDRESS SUBROUTINES ********************************************************/ 00137 00141 static inline int 00142 iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2) 00143 { 00144 return memcmp(eth1, eth2, sizeof(*eth1)); 00145 } 00146 00147 void 00148 iw_ether_ntop(const struct ether_addr *eth, char *buf); 00149 00150 char * 00151 iw_sawap_ntop(const struct sockaddr *sap, char *buf); 00152 00153 00154 /* FREQUENCY SUBROUTINES ******************************************************/ 00155 00156 void 00157 iw_float2freq(double in, iwfreq *out); 00158 00159 double 00160 iw_freq2float(const iwfreq *in); 00161 00162 00163 /* TXPOWER SUBROUTINES ********************************************************/ 00164 00165 int16_t 00166 dbm2mw(int16_t in); 00167 00168 #endif // __IW_COMPAT_H 00169 #endif // IWLIB_H