summaryrefslogtreecommitdiff
path: root/openwrt
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2005-04-08 16:53:57 +0000
committerFelix Fietkau <nbd@openwrt.org>2005-04-08 16:53:57 +0000
commit7b8cda835efbec46ab4c546b02113279d28e01b6 (patch)
treeb5ed04ccc02ab83259a1e5e23c415022eb22a78c /openwrt
parent4bd4fa94196c1335bb672bfa4caadaef8ac15ccb (diff)
downloadmtk-20170518-7b8cda835efbec46ab4c546b02113279d28e01b6.zip
mtk-20170518-7b8cda835efbec46ab4c546b02113279d28e01b6.tar.gz
mtk-20170518-7b8cda835efbec46ab4c546b02113279d28e01b6.tar.bz2
add SIOCGIWMODE and SIOCSIWMODE
SVN-Revision: 586
Diffstat (limited to 'openwrt')
-rw-r--r--openwrt/package/openwrt/wlcompat.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/openwrt/package/openwrt/wlcompat.c b/openwrt/package/openwrt/wlcompat.c
index 52af95a..ebed8c3 100644
--- a/openwrt/package/openwrt/wlcompat.c
+++ b/openwrt/package/openwrt/wlcompat.c
@@ -201,6 +201,75 @@ static int wlcompat_ioctl(struct net_device *dev,
return wlcompat_ioctl_getiwrange(dev, extra);
break;
}
+ case SIOCSIWMODE:
+ {
+ int ap = -1, infra = -1, passive = -1;
+
+ switch (wrqu->mode) {
+ case IW_MODE_MONITOR:
+ passive = 1;
+ break;
+ case IW_MODE_ADHOC:
+ passive = 0;
+ infra = 0;
+ ap = 0;
+ break;
+ case IW_MODE_MASTER:
+ passive = 0;
+ infra = 1;
+ ap = 1;
+ break;
+ case IW_MODE_INFRA:
+ passive = 0;
+ infra = 1;
+ ap = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (passive >= 0) {
+ if (wl_ioctl(dev, WLC_SET_PASSIVE, &passive, sizeof(passive)) < 0)
+ return -EINVAL;
+ if (wl_ioctl(dev, WLC_SET_MONITOR, &passive, sizeof(passive)) < 0)
+ return -EINVAL;
+ }
+ if (ap >= 0)
+ if (wl_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap)) < 0)
+ return -EINVAL;
+ if (infra >= 0)
+ if (wl_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra)) < 0)
+ return -EINVAL;
+
+ break;
+
+ }
+ case SIOCGIWMODE:
+ {
+ int ap, infra, passive;
+
+ if (wl_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap)) < 0)
+ return -EINVAL;
+
+ if (wl_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra)) < 0)
+ return -EINVAL;
+
+ if (wl_ioctl(dev, WLC_GET_PASSIVE, &passive, sizeof(passive)) < 0)
+ return -EINVAL;
+
+ if (passive) {
+ wrqu->mode = IW_MODE_MONITOR;
+ } else if (!infra) {
+ wrqu->mode = IW_MODE_ADHOC;
+ } else {
+ if (ap) {
+ wrqu->mode = IW_MODE_MASTER;
+ } else {
+ wrqu->mode = IW_MODE_INFRA;
+ }
+ }
+ break;
+ }
default:
{
return -EINVAL;
@@ -217,8 +286,8 @@ static const iw_handler wlcompat_handler[] = {
NULL, /* SIOCGIWNWID */
wlcompat_ioctl, /* SIOCSIWFREQ */
wlcompat_ioctl, /* SIOCGIWFREQ */
- NULL, /* SIOCSIWMODE */
- NULL, /* SIOCGIWMODE */
+ wlcompat_ioctl, /* SIOCSIWMODE */
+ wlcompat_ioctl, /* SIOCGIWMODE */
NULL, /* SIOCSIWSENS */
NULL, /* SIOCGIWSENS */
NULL, /* SIOCSIWRANGE */