diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-08-24 05:54:38 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-08-24 05:54:38 +0000 |
commit | 12f582bcc7dc8ab447c01e2cfa939caa7dfa321b (patch) | |
tree | ac2f8917d2dbbd4413f68c09a1c19d3b4ae21ebe /libs/iwinfo/src/iwinfo_wext.c | |
parent | 1c8db37e8b93855530102ded098daa95076f981b (diff) |
libs/iwinfo: implement wifi scans
Diffstat (limited to 'libs/iwinfo/src/iwinfo_wext.c')
-rw-r--r-- | libs/iwinfo/src/iwinfo_wext.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/libs/iwinfo/src/iwinfo_wext.c b/libs/iwinfo/src/iwinfo_wext.c index 24be10fa9d..311fd8ebbe 100644 --- a/libs/iwinfo/src/iwinfo_wext.c +++ b/libs/iwinfo/src/iwinfo_wext.c @@ -189,7 +189,7 @@ int wext_get_bitrate(const char *ifname, int *buf) if(wext_ioctl(ifname, SIOCGIWRATE, &wrq) >= 0) { - *buf = wrq.u.bitrate.value; + *buf = (wrq.u.bitrate.value / 1000000); return 0; } @@ -199,12 +199,36 @@ int wext_get_bitrate(const char *ifname, int *buf) int wext_get_channel(const char *ifname, int *buf) { struct iwreq wrq; + struct iw_range range; + double freq; + int i; if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0) { - /* FIXME: iwlib has some strange workarounds here, maybe we need them as well... */ - *buf = (int) wext_freq2float(&wrq.u.freq); - return 0; + if( wrq.u.freq.m >= 1000 ) + { + freq = wext_freq2float(&wrq.u.freq); + wrq.u.data.pointer = (caddr_t) ⦥ + wrq.u.data.length = sizeof(struct iw_range); + wrq.u.data.flags = 0; + + if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) + { + for(i = 0; i < range.num_frequency; i++) + { + if( wext_freq2float(&range.freq[i]) == freq ) + { + *buf = range.freq[i].i; + return 0; + } + } + } + } + else + { + *buf = wrq.u.freq.m; + return 0; + } } return -1; |