aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2005-05-13 21:58:19 +0000
committerFelix Fietkau <nbd@openwrt.org>2005-05-13 21:58:19 +0000
commite9eca5c65183b832fe178d935310e2d8c0263898 (patch)
tree229006dcd1ffc1a002d80ff066f2e55c9699758b
parentae2cf4c8dba002b770679cf1b5fa19bb6ec4d7f8 (diff)
downloadupstream-e9eca5c65183b832fe178d935310e2d8c0263898.tar.gz
upstream-e9eca5c65183b832fe178d935310e2d8c0263898.tar.bz2
upstream-e9eca5c65183b832fe178d935310e2d8c0263898.zip
implement SIOCGIWENCODE in wlcompat (broadcom disabled the ioctl to get the wsec_info, so we have to read it from the chipset's shmem. got the offsets from linux-bcom4301)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@886 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--package/openwrt/wlcompat.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/package/openwrt/wlcompat.c b/package/openwrt/wlcompat.c
index 18ec93468e..01bfb0b437 100644
--- a/package/openwrt/wlcompat.c
+++ b/package/openwrt/wlcompat.c
@@ -43,6 +43,8 @@ const long channel_frequency[] = {
};
#define NUM_CHANNELS ( sizeof(channel_frequency) / sizeof(channel_frequency[0]) )
+
+
static int wlcompat_private_ioctl(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
@@ -101,6 +103,13 @@ static int wl_get_val(struct net_device *dev, char *var, void *val, int len)
return 0;
}
+int read_shmem(struct net_device *dev, int offset)
+{
+ if (wl_ioctl(dev, WLC_GET_SHMEM, &offset, sizeof(offset)) < 0)
+ return -EINVAL;
+
+ return offset;
+}
static int wlcompat_ioctl_getiwrange(struct net_device *dev,
char *extra)
@@ -397,17 +406,43 @@ static int wlcompat_ioctl(struct net_device *dev,
}
case SIOCGIWENCODE:
{
- int val = 0;
+ int val;
+
if (wl_ioctl(dev, WLC_GET_WEP, &val, sizeof(val)) < 0)
return -EINVAL;
+
if (val > 0) {
- wrqu->data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+ int key;
+
+ for (key = val = 0; (key < 4) && (val == 0); key++) {
+ val = key;
+ if (wl_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val)) < 0)
+ return -EINVAL;
+ }
+
+ wrqu->data.flags = IW_ENCODE_ENABLED;
+ if (key-- > 0) {
+ int magic_offset;
+ int16 buffer[8];
+
+ magic_offset = read_shmem(dev, 0x56) * 2;
+
+ wrqu->data.flags |= key + 1;
+ wrqu->data.length = 16;
+
+ for (val = 0; val < 8; val++) {
+ buffer[val] = read_shmem(dev, magic_offset + (key * 16) + val * 2);
+ }
+
+ memset(extra, 0, 16);
+ memcpy(extra, buffer, 16);
+ } else {
+ wrqu->data.flags |= IW_ENCODE_NOKEY;
+ }
} else {
wrqu->data.flags = IW_ENCODE_DISABLED;
}
-
-
break;
}