aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_wireless.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugin_wireless.c')
-rw-r--r--plugin_wireless.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/plugin_wireless.c b/plugin_wireless.c
index 7eec871..0ee38d1 100644
--- a/plugin_wireless.c
+++ b/plugin_wireless.c
@@ -1,5 +1,5 @@
-/* $Id: plugin_wireless.c 738 2007-01-16 08:30:24Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/plugin_wireless.c $
+/* $Id: plugin_wireless.c 1136 2010-11-28 16:07:16Z mzuther $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/plugin_wireless.c $
*
* Wireless Extension plugin
*
@@ -54,12 +54,13 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
+#include <math.h>
#include <sys/ioctl.h>
#include <net/if_arp.h>
#include <linux/if.h>
#include <linux/wireless.h>
-#include <math.h>
#include "debug.h"
#include "plugin.h"
@@ -119,11 +120,19 @@ int do_ioctl(const int sock, /* Socket to the kernel */
const int request, /* WE ID */
struct iwreq *pwrq)
{ /* Fixed part of the request */
+ int ret;
+
/* Set device name */
strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
/* Do the request */
- return (ioctl(sock, request, pwrq));
+ ret = ioctl(sock, request, pwrq);
+ if (ret < 0) {
+ debug("ioctl(0x%04x) failed: %d '%s'", request, errno, strerror(errno));
+ }
+
+ return ret;
+
}
int get_range_info(const int sock, const char *ifname, struct iw_range *range)
@@ -455,7 +464,7 @@ static int get_stats(const char *dev, const char *key)
}
req.u.data.pointer = (caddr_t) & stats;
- req.u.data.length = 0;
+ req.u.data.length = sizeof(stats);
req.u.data.flags = 1; /* Clear updated flag */
if (do_ioctl(sock, dev, SIOCGIWSTATS, &req) < 0) {
@@ -481,7 +490,7 @@ static int get_stats(const char *dev, const char *key)
} else {
qprintf(qprintf_buffer, sizeof(qprintf_buffer), "%d/%d", stats.qual.level, range.max_qual.level);
- qprintf(key_buffer, sizeof(key_buffer), "%s.%s", dev, KEY_LEVEL);;
+ qprintf(key_buffer, sizeof(key_buffer), "%s.%s", dev, KEY_LEVEL);
hash_put(&wireless, key_buffer, qprintf_buffer);
qprintf(qprintf_buffer, sizeof(qprintf_buffer), "%d/%d", stats.qual.noise, range.max_qual.noise);