Changeset 5248
- Timestamp:
- 08/09/09 15:24:43 (4 years ago)
- Location:
- luci/trunk/libs/iwinfo/src
- Files:
-
- 7 modified
-
iwinfo_lualib.c (modified) (6 diffs)
-
iwinfo_madwifi.c (modified) (1 diff)
-
iwinfo_madwifi.h (modified) (1 diff)
-
iwinfo_wext.c (modified) (2 diffs)
-
iwinfo_wext.h (modified) (2 diffs)
-
iwinfo_wl.c (modified) (1 diff)
-
iwinfo_wl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/iwinfo/src/iwinfo_lualib.c
r5244 r5248 78 78 /* Broadcom */ 79 79 LUA_WRAP_INT(wl,channel) 80 LUA_WRAP_INT(wl,frequency) 80 81 LUA_WRAP_INT(wl,bitrate) 81 82 LUA_WRAP_INT(wl,signal) … … 91 92 /* Madwifi */ 92 93 LUA_WRAP_INT(madwifi,channel) 94 LUA_WRAP_INT(madwifi,frequency) 93 95 LUA_WRAP_INT(madwifi,bitrate) 94 96 LUA_WRAP_INT(madwifi,signal) … … 104 106 /* Wext */ 105 107 LUA_WRAP_INT(wext,channel) 108 LUA_WRAP_INT(wext,frequency) 106 109 LUA_WRAP_INT(wext,bitrate) 107 110 LUA_WRAP_INT(wext,signal) … … 118 121 static const luaL_reg R_wl[] = { 119 122 LUA_REG(wl,channel), 123 LUA_REG(wl,frequency), 120 124 LUA_REG(wl,bitrate), 121 125 LUA_REG(wl,signal), … … 134 138 static const luaL_reg R_madwifi[] = { 135 139 LUA_REG(madwifi,channel), 140 LUA_REG(madwifi,frequency), 136 141 LUA_REG(madwifi,bitrate), 137 142 LUA_REG(madwifi,signal), … … 150 155 static const luaL_reg R_wext[] = { 151 156 LUA_REG(wext,channel), 157 LUA_REG(wext,frequency), 152 158 LUA_REG(wext,bitrate), 153 159 LUA_REG(wext,signal), -
luci/trunk/libs/iwinfo/src/iwinfo_madwifi.c
r5244 r5248 128 128 } 129 129 130 int madwifi_get_frequency(const char *ifname, int *buf) 131 { 132 struct iwreq wrq; 133 134 if( madwifi_ioctl(&wrq, ifname, SIOCGIWFREQ, NULL, 0) >= 0 ) 135 { 136 *buf = (uint16_t)(wrq.u.freq.m / 100000); 137 return 0; 138 } 139 140 return -1; 141 } 142 130 143 int madwifi_get_bitrate(const char *ifname, int *buf) 131 144 { -
luci/trunk/libs/iwinfo/src/iwinfo_madwifi.h
r5244 r5248 28 28 int madwifi_get_bssid(const char *ifname, char *buf); 29 29 int madwifi_get_channel(const char *ifname, int *buf); 30 int madwifi_get_frequency(const char *ifname, int *buf); 30 31 int madwifi_get_bitrate(const char *ifname, int *buf); 31 32 int madwifi_get_signal(const char *ifname, int *buf); -
luci/trunk/libs/iwinfo/src/iwinfo_wext.c
r5244 r5248 33 33 } 34 34 35 static int wext_freq2mhz(const struct iw_freq *in) 36 { 37 int i, mhz; 38 39 if( in->e == 6 ) 40 { 41 return in->m; 42 } 43 else 44 { 45 mhz = in->m; 46 for(i = 0; i < in->e; i++) 47 mhz *= 10; 48 49 return (int)(mhz / 100000); 50 } 51 } 52 35 53 static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq) 36 54 { … … 158 176 } 159 177 178 int wext_get_frequency(const char *ifname, int *buf) 179 { 180 struct iwreq wrq; 181 struct iw_range range; 182 int i, channel; 183 184 if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0) 185 { 186 /* We got a channel number instead ... */ 187 if( wrq.u.freq.m < 1000 ) 188 { 189 channel = wrq.u.freq.m; 190 wrq.u.data.pointer = (caddr_t) ⦥ 191 wrq.u.data.length = sizeof(struct iw_range); 192 wrq.u.data.flags = 0; 193 194 if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) 195 { 196 for(i = 0; i < range.num_frequency; i++) 197 { 198 if( range.freq[i].i == channel ) 199 { 200 *buf = wext_freq2mhz(&range.freq[i]); 201 return 0; 202 } 203 } 204 } 205 } 206 else 207 { 208 *buf = wext_freq2mhz(&wrq.u.freq); 209 return 0; 210 } 211 } 212 213 return -1; 214 } 215 160 216 int wext_get_signal(const char *ifname, int *buf) 161 217 { -
luci/trunk/libs/iwinfo/src/iwinfo_wext.h
r5244 r5248 20 20 #define __IWINFO_WEXT_H_ 21 21 22 #include <sys/types.h> 23 #include <sys/stat.h> 24 #include <unistd.h> 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include <string.h> 28 #include <fcntl.h> 29 #include <glob.h> 30 #include <ctype.h> 31 #include <stdint.h> 32 33 #include <sys/ioctl.h> 34 #include <net/if.h> 35 #include <errno.h> 36 22 #include "iwinfo.h" 37 23 #include "include/wext.h" 38 24 … … 42 28 int wext_get_bssid(const char *ifname, char *buf); 43 29 int wext_get_channel(const char *ifname, int *buf); 30 int wext_get_frequency(const char *ifname, int *buf); 44 31 int wext_get_bitrate(const char *ifname, int *buf); 45 32 int wext_get_signal(const char *ifname, int *buf); -
luci/trunk/libs/iwinfo/src/iwinfo_wl.c
r5245 r5248 127 127 { 128 128 return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf)); 129 } 130 131 int wl_get_frequency(const char *ifname, int *buf) 132 { 133 return wext_get_frequency(ifname, buf); 129 134 } 130 135 -
luci/trunk/libs/iwinfo/src/iwinfo_wl.h
r5244 r5248 28 28 int wl_get_bssid(const char *ifname, char *buf); 29 29 int wl_get_channel(const char *ifname, int *buf); 30 int wl_get_frequency(const char *ifname, int *buf); 30 31 int wl_get_bitrate(const char *ifname, int *buf); 31 32 int wl_get_signal(const char *ifname, int *buf);
