From bc8b1b75dd55f6e3912f79609a22c2555df49745 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2006 20:46:00 +0000 Subject: 2006-09-25 Stefan Siegl * linux/dev/glue/net.c (device_get_status): Reworked to not read from STATUS. Fill `struct iw_point' correctly if necessary. --- linux/dev/glue/net.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'linux') diff --git a/linux/dev/glue/net.c b/linux/dev/glue/net.c index f0bd650..9f154b7 100644 --- a/linux/dev/glue/net.c +++ b/linux/dev/glue/net.c @@ -543,24 +543,26 @@ device_get_status (void *d, dev_flavor_t flavor, dev_status_t status, int result; - if((flavor == SIOCGIWRANGE || flavor == SIOCGIWENCODE + if (flavor == SIOCGIWRANGE || flavor == SIOCGIWENCODE || flavor == SIOCGIWESSID || flavor == SIOCGIWNICKN || flavor == SIOCGIWSPY) - && ((struct iwreq *) status)->u.data.pointer) { + /* + * These ioctls require an `iw_point' as their argument (i.e. + * they want to return some data to userspace. + * Therefore supply some sane values and carry the data back + * to userspace right behind the `struct iwreq'. + */ struct iw_point *iwp = &((struct iwreq *) status)->u.data; + iwp->length = *count * sizeof (dev_status_t) - sizeof (struct ifreq); + iwp->pointer = (void *) status + sizeof (struct ifreq); - /* safety check whether the status array is long enough ... */ - if(*count * sizeof(int) < sizeof(struct ifreq) + iwp->length) - return D_INVALID_OPERATION; - - /* make sure, iwp->pointer points to the correct address */ - iwp->pointer = (void *) status + sizeof(struct ifreq); + result = dev->do_ioctl (dev, (struct ifreq *) status, flavor); - result = dev->do_ioctl(dev, (struct ifreq *) status, flavor); - /* *count = (sizeof(struct ifreq) + iwp->length) / sizeof(int); - * if(iwp->length % sizeof(int)) *count ++; - */ + *count = ((sizeof (struct ifreq) + iwp->length) + / sizeof (dev_status_t)); + if (iwp->length % sizeof (dev_status_t)) + (*count) ++; } else { -- cgit v1.2.3