add SIOCSIWFRAG and SIOCSIWRTS
[openwrt.git] / package / openwrt / wlcompat.c
index 52af95a..0dc3829 100644 (file)
@@ -129,6 +129,7 @@ static int wlcompat_ioctl(struct net_device *dev,
                        } else {
                                return -EINVAL;
                        }
+                       break;
                }
                case SIOCGIWAP:
                {
@@ -167,12 +168,24 @@ static int wlcompat_ioctl(struct net_device *dev,
                                return -EINVAL;
                        break;
                }
+               case SIOCSIWRTS:
+               {
+                       if (wl_ioctl(dev,WLC_SET_RTS,&(wrqu->rts.value),sizeof(int)) < 0) 
+                               return -EINVAL;
+                       break;
+               }
                case SIOCGIWFRAG:
                {
                        if (wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
                                return -EINVAL;
                        break;
                }
+               case SIOCSIWFRAG:
+               {
+                       if (wl_ioctl(dev,WLC_SET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
+                               return -EINVAL;
+                       break;
+               }
                case SIOCGIWTXPOW:
                {
                        wrqu->txpower.value = 0;
@@ -201,6 +214,81 @@ static int wlcompat_ioctl(struct net_device *dev,
                        return wlcompat_ioctl_getiwrange(dev, extra);
                        break;
                }
+               case SIOCSIWMODE:
+               {
+                       int ap = -1, infra = -1, passive = 0, wet = 0;
+                       
+                       switch (wrqu->mode) {
+                               case IW_MODE_MONITOR:
+                                       passive = 1;
+                                       break;
+                               case IW_MODE_ADHOC:
+                                       infra = 0;
+                                       ap = 0;
+                                       break;
+                               case IW_MODE_MASTER:
+                                       infra = 1;
+                                       ap = 1;
+                                       break;
+                               case IW_MODE_INFRA:
+                                       infra = 1;
+                                       ap = 0;
+                                       break;
+                               case IW_MODE_REPEAT:
+                                       infra = 1;
+                                       ap = 0;
+                                       wet = 1;
+                                       break;
+                               default:
+                                       return -EINVAL;
+                       }
+                       
+                       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 (wl_ioctl(dev, WLC_SET_WET, &wet, sizeof(wet)) < 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, wet, 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 (wl_ioctl(dev, WLC_GET_WET, &wet, sizeof(wet)) < 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 {
+                                       if (wet) {
+                                               wrqu->mode = IW_MODE_REPEAT;
+                                       } else {
+                                               wrqu->mode = IW_MODE_INFRA;
+                                       }
+                               }
+                       }
+                       break;
+               }
                default:
                {
                        return -EINVAL;
@@ -217,11 +305,11 @@ 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 */
+       NULL,                   /* SIOCSIWRANGE, unused */
        wlcompat_ioctl,         /* SIOCGIWRANGE */
        NULL,                   /* SIOCSIWPRIV */
        NULL,                   /* SIOCGIWPRIV */
@@ -245,9 +333,9 @@ static const iw_handler      wlcompat_handler[] = {
        NULL,                   /* -- hole -- */
        NULL,                   /* SIOCSIWRATE */
        NULL,                   /* SIOCGIWRATE */
-       NULL,                   /* SIOCSIWRTS */
+       wlcompat_ioctl,         /* SIOCSIWRTS */
        wlcompat_ioctl,         /* SIOCGIWRTS */
-       NULL,                   /* SIOCSIWFRAG */
+       wlcompat_ioctl,         /* SIOCSIWFRAG */
        wlcompat_ioctl,         /* SIOCGIWFRAG */
        wlcompat_ioctl,         /* SIOCSIWTXPOW */
        wlcompat_ioctl,         /* SIOCGIWTXPOW */
This page took 0.028355 seconds and 4 git commands to generate.