libs/iwinfo: return bitrate in kilobits to properly handle .5 rates
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 26 Aug 2009 01:35:42 +0000 (01:35 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 26 Aug 2009 01:35:42 +0000 (01:35 +0000)
libs/iwinfo/src/dummy.lua
libs/iwinfo/src/iwinfo_madwifi.c
libs/iwinfo/src/iwinfo_wext.c
libs/iwinfo/src/iwinfo_wext_scan.c
libs/iwinfo/src/iwinfo_wl.c

index 9c81748..c9a359a 100644 (file)
@@ -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()
index e09d49b..e2bde1c 100644 (file)
@@ -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;
                }
 
index 311fd8e..387cb13 100644 (file)
@@ -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;
        }
 
index 7c461b5..2023623 100644 (file)
@@ -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) &range;
        wrq.u.data.length  = sizeof(struct iw_range);
        wrq.u.data.flags   = 0; 
index 8387b9f..8519dbc 100644 (file)
@@ -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;
 }