Uniformize package Makefile,
[openwrt.git] / package / openwrt / wlcompat.c
index eb85a9e..3f2f407 100644 (file)
@@ -1,5 +1,26 @@
-// insert header here
-// mbm. gpl.
+/*
+ * wlcompat.c
+ *
+ * Copyright (C) 2005 Mike Baker,
+ *                    Felix Fietkau <nbd@vd-s.ath.cx>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * $Id$
+ */
+
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -11,8 +32,6 @@
 #include <net/iw_handler.h>
 #include <wlioctl.h>
 
-#define DEBUG
-
 static struct net_device *dev;
 char buf[WLC_IOCTL_MAXLEN];
 
@@ -137,7 +156,7 @@ static int wlcompat_get_scan(struct net_device *dev,
        char *current_val;
        char *end_buf = extra + IW_SCAN_MAX_DATA;
        struct iw_event iwe;
-       int i;
+       int i, j;
 
        if (wl_ioctl(dev, WLC_SCAN_RESULTS, buf, WLC_IOCTL_MAXLEN) < 0)
                return -EAGAIN;
@@ -178,8 +197,8 @@ static int wlcompat_get_scan(struct net_device *dev,
                current_val = current_ev + IW_EV_LCP_LEN;
                iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
                
-               for(i = 0 ; i < bss_info->rateset.count ; i++) {
-                       iwe.u.bitrate.value = ((bss_info->rateset.rates[i] & 0x7f) * 500000);
+               for(j = 0 ; j < bss_info->rateset.count ; j++) {
+                       iwe.u.bitrate.value = ((bss_info->rateset.rates[j] & 0x7f) * 500000);
                        current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
                }
                if((current_val - current_ev) > IW_EV_LCP_LEN)
@@ -316,7 +335,18 @@ static int wlcompat_ioctl(struct net_device *dev,
                }
                case SIOCGIWENCODE:
                {
-                       wrqu->data.flags = IW_ENCODE_DISABLED;
+                       int val = 0;
+                       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;
+                       } else {
+                               wrqu->data.flags = IW_ENCODE_DISABLED;
+                       }
+                               
+                               
+                       
                        break;
                }
                case SIOCGIWRANGE:
@@ -467,19 +497,35 @@ static const struct iw_handler_def      wlcompat_handler_def =
 
 #ifdef DEBUG
 static int (*old_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
+void print_buffer(int len, unsigned char *buf) {
+       int x;
+       if (buf != NULL) {
+               for (x=0;x<len && x<180 ;x++) {
+                       if ((x % 4) == 0)
+                               printk(" ");
+                       printk("%02X",buf[x]);
+               }
+       } else {
+               printk(" NULL");
+       }
+       printk("\n");
+
+}
 static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
-       int ret = old_ioctl(dev,ifr,cmd);
+       int ret = 0;
        printk("dev: %s ioctl: 0x%04x\n",dev->name,cmd);
        if (cmd==SIOCDEVPRIVATE) {
-               int x;
                wl_ioctl_t *ioc = (wl_ioctl_t *)ifr->ifr_data;
                unsigned char *buf = ioc->buf;
                printk("   cmd: %d buf: 0x%08x len: %d\n",ioc->cmd,&(ioc->buf),ioc->len);
-               printk("   ->");
-               for (x=0;x<ioc->len && x<128 ;x++) {
-                       printk("%02X",buf[x]);
-               }
-               printk("\n");
+               printk("   send: ->");
+               print_buffer(ioc->len, buf);
+               ret = old_ioctl(dev,ifr,cmd);
+               printk("   recv: ->");
+               print_buffer(ioc->len, buf);
+               printk("   ret: %d\n", ret);
+       } else {
+               ret = old_ioctl(dev,ifr,cmd);
        }
        return ret;
 }
This page took 0.027245 seconds and 4 git commands to generate.