aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2009-01-23 08:10:04 +0000
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2009-01-23 08:10:04 +0000
commit8402d701a9739bb207fe1edb8e682b3a95de4e51 (patch)
treef878d4ae804a49c816bd6115514e59d737cbb6b5
parentd5ebee1188081526470467e9c9200ca56c0a7cea (diff)
downloadlcd4linux-8402d701a9739bb207fe1edb8e682b3a95de4e51.tar.gz
wifi ioctl() fixed (ticket #144)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@978 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--plugin_wireless.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugin_wireless.c b/plugin_wireless.c
index 2983ce1..25adf26 100644
--- a/plugin_wireless.c
+++ b/plugin_wireless.c
@@ -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) {