lib: report byte counters as 64 bit values
[project/iwinfo.git] / iwinfo_wl.c
index c7517ecea661b6f753700288917d17c4f8ac7093..9ec78cd2119f48934493610c50691401fc55bfef 100644 (file)
@@ -18,6 +18,9 @@
  * This code is based on the wlc.c utility published by OpenWrt.org .
  */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include "iwinfo.h"
 #include "api/broadcom.h"
 
@@ -141,6 +144,18 @@ static int wl_get_channel(const char *ifname, int *buf)
        return wl_ioctl(ifname, WLC_GET_CHANNEL, buf, sizeof(buf));
 }
 
+static int wl_get_center_chan1(const char *ifname, int *buf)
+{
+       /* Not Supported */
+       return -1;
+}
+
+static int wl_get_center_chan2(const char *ifname, int *buf)
+{
+       /* Not Supported */
+       return -1;
+}
+
 static int wl_get_frequency(const char *ifname, int *buf)
 {
        return wext_ops.frequency(ifname, buf);
@@ -702,15 +717,19 @@ static int wl_get_txpower_offset(const char *ifname, int *buf)
 {
        FILE *p;
        char off[8];
+       struct stat s;
 
        *buf = 0;
 
-       if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+       if (!stat("/usr/sbin/nvram", &s) && (s.st_mode & S_IXUSR))
        {
-               if (fread(off, 1, sizeof(off), p))
-                       *buf = strtoul(off, NULL, 16);
+               if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+               {
+                       if (fread(off, 1, sizeof(off), p))
+                               *buf = strtoul(off, NULL, 16);
 
-               pclose(p);
+                       pclose(p);
+               }
        }
 
        return 0;
@@ -727,6 +746,8 @@ const struct iwinfo_ops wl_ops = {
        .name             = "wl",
        .probe            = wl_probe,
        .channel          = wl_get_channel,
+       .center_chan1     = wl_get_center_chan1,
+       .center_chan2     = wl_get_center_chan2,
        .frequency        = wl_get_frequency,
        .frequency_offset = wl_get_frequency_offset,
        .txpower          = wl_get_txpower,