From e66ab6bd2ca3bf51f6951e9b293b7742cd1a86a1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 Aug 2009 01:35:42 +0000 Subject: [PATCH 1/1] libs/iwinfo: return bitrate in kilobits to properly handle .5 rates --- libs/iwinfo/src/dummy.lua | 4 ++-- libs/iwinfo/src/iwinfo_madwifi.c | 2 +- libs/iwinfo/src/iwinfo_wext.c | 2 +- libs/iwinfo/src/iwinfo_wext_scan.c | 6 +----- libs/iwinfo/src/iwinfo_wl.c | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libs/iwinfo/src/dummy.lua b/libs/iwinfo/src/dummy.lua index 9c8174881..c9a359a2b 100644 --- a/libs/iwinfo/src/dummy.lua +++ b/libs/iwinfo/src/dummy.lua @@ -15,7 +15,7 @@ function dummy.frequency() end function dummy.bitrate() - return 36 + return 36000 end function dummy.signal() @@ -27,7 +27,7 @@ function dummy.noise() end function dummy.quality() - return 11 + return 50 end function dummy.quality_max() diff --git a/libs/iwinfo/src/iwinfo_madwifi.c b/libs/iwinfo/src/iwinfo_madwifi.c index e09d49b1e..e2bde1c14 100644 --- a/libs/iwinfo/src/iwinfo_madwifi.c +++ b/libs/iwinfo/src/iwinfo_madwifi.c @@ -175,7 +175,7 @@ int madwifi_get_bitrate(const char *ifname, int *buf) } while (len >= sizeof(struct ieee80211req_sta_info)); } - *buf = (rate == 0 || rate_count == 0) ? 0 : (rate / rate_count); + *buf = (rate == 0 || rate_count == 0) ? 0 : (rate / rate_count) * 1000; return 0; } diff --git a/libs/iwinfo/src/iwinfo_wext.c b/libs/iwinfo/src/iwinfo_wext.c index 311fd8ebb..387cb13b4 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 / 1000000); + *buf = (wrq.u.bitrate.value / 1000); return 0; } diff --git a/libs/iwinfo/src/iwinfo_wext_scan.c b/libs/iwinfo/src/iwinfo_wext_scan.c index 7c461b5e7..202362336 100644 --- a/libs/iwinfo/src/iwinfo_wext_scan.c +++ b/libs/iwinfo/src/iwinfo_wext_scan.c @@ -349,7 +349,7 @@ static inline void wext_fill_wpa(unsigned char *iebuf, int buflen, struct iwinfo } -static inline int wext_fill_entry(struct stream_descr *stream, struct iw_event *event, +static inline void wext_fill_entry(struct stream_descr *stream, struct iw_event *event, struct iw_range *iw_range, int has_range, struct iwinfo_scanlist_entry *e) { int i; @@ -458,8 +458,6 @@ static inline int wext_fill_entry(struct stream_descr *stream, struct iw_event * break; } - - return 0; } @@ -467,7 +465,6 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len) { struct iwreq wrq; struct iw_scan_req scanopt; /* Options for 'set' */ - //int scanflags = 0; /* Flags for scan */ unsigned char *buffer = NULL; /* Results */ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */ struct iw_range range; @@ -478,7 +475,6 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len) int entrylen = 0; struct iwinfo_scanlist_entry e; - //IWINFO_BUFSIZE wrq.u.data.pointer = (caddr_t) ⦥ wrq.u.data.length = sizeof(struct iw_range); wrq.u.data.flags = 0; diff --git a/libs/iwinfo/src/iwinfo_wl.c b/libs/iwinfo/src/iwinfo_wl.c index 8387b9f4c..8519dbc56 100644 --- a/libs/iwinfo/src/iwinfo_wl.c +++ b/libs/iwinfo/src/iwinfo_wl.c @@ -139,7 +139,7 @@ int wl_get_bitrate(const char *ifname, int *buf) int rate = 0; if( !(ret = wl_ioctl(ifname, WLC_GET_RATE, &rate, sizeof(rate))) && (rate > 0)) - *buf = rate / 2; + *buf = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0); return ret; } -- 2.11.0