X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/9ce0730f9d3707d8696607d3354104e10f6a6c8a..0f9f93a6c4a3f65e6647e7c687a145c0dba0e197:/package/openwrt/wlcompat.c?ds=sidebyside diff --git a/package/openwrt/wlcompat.c b/package/openwrt/wlcompat.c index 1719a67a7..d010e2bc8 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) @@ -305,10 +314,15 @@ static int wlcompat_ioctl(struct net_device *dev, } case SIOCSIWAP: { + int ap = 0; + if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) return -EINVAL; - if (wl_ioctl(dev,WLC_SET_BSSID,wrqu->ap_addr.sa_data,6) < 0) + if (wl_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap)) < 0) + return -EINVAL; + + if (wl_ioctl(dev, (ap ? WLC_SET_BSSID : WLC_REASSOC), wrqu->ap_addr.sa_data, 6) < 0) return -EINVAL; break; @@ -397,17 +411,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; } @@ -599,6 +639,34 @@ static int wlcompat_private_ioctl(struct net_device *dev, break; } + case WLCOMPAT_SET_ANTDIV: + { + if (wl_ioctl(dev, WLC_SET_ANTDIV, value, sizeof(int)) < 0) + return -EINVAL; + + break; + } + case WLCOMPAT_GET_ANTDIV: + { + if (wl_ioctl(dev, WLC_GET_ANTDIV, extra, sizeof(int)) < 0) + return -EINVAL; + + break; + } + case WLCOMPAT_SET_TXANT: + { + if (wl_ioctl(dev, WLC_SET_TXANT, value, sizeof(int)) < 0) + return -EINVAL; + + break; + } + case WLCOMPAT_GET_TXANT: + { + if (wl_ioctl(dev, WLC_GET_TXANT, extra, sizeof(int)) < 0) + return -EINVAL; + + break; + } default: { return -EINVAL; @@ -629,7 +697,27 @@ static const struct iw_priv_args wlcompat_private_args[] = 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_txpwr_force" - } + }, + { WLCOMPAT_SET_ANTDIV, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + 0, + "set_antdiv" + }, + { WLCOMPAT_GET_ANTDIV, + 0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_antdiv" + }, + { WLCOMPAT_SET_TXANT, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + 0, + "set_txant" + }, + { WLCOMPAT_GET_TXANT, + 0, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + "get_txant" + }, }; static const iw_handler wlcompat_private[] =