libertas: convert setuserscan from wlanconfig to debugfs
Marcelo Tosatti
mtosatti at redhat.unroutablecom
Tue Nov 28 02:56:39 EST 2006
Commit: c43fdd2363870e5ab09d92920708668435e4a607
Parent: e5a74acc9bef47f7d950b3fd4600d46117fff4d5
commit c43fdd2363870e5ab09d92920708668435e4a607
Author: Marcelo Tosatti <mtosatti at redhat.com>
AuthorDate: Sun Nov 19 03:24:07 2006 -0200
Commit: Marcelo Tosatti <mtosatti at redhat.com>
CommitDate: Sun Nov 19 03:24:07 2006 -0200
libertas: convert setuserscan from wlanconfig to debugfs
Subject says it all.
Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
---
drivers/net/wireless/libertas/wlan_debugfs.c | 205 ++++++++++++++++++++++++++
drivers/net/wireless/libertas/wlan_dev.h | 1
drivers/net/wireless/libertas/wlan_ioctl.c | 9 -
drivers/net/wireless/libertas/wlan_scan.c | 2
drivers/net/wireless/libertas/wlan_scan.h | 3
drivers/net/wireless/libertas/wlan_wext.c | 12 --
drivers/net/wireless/libertas/wlan_wext.h | 3
7 files changed, 209 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/libertas/wlan_debugfs.c b/drivers/net/wireless/libertas/wlan_debugfs.c
index 020e70a..17128d0 100644
--- a/drivers/net/wireless/libertas/wlan_debugfs.c
+++ b/drivers/net/wireless/libertas/wlan_debugfs.c
@@ -218,6 +218,195 @@ out_unlock:
return count;
}
+int libertas_parse_chan(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg, int dur)
+{
+ char *start, *end, *hold, *str;
+ int i = 0;
+
+ start = strstr(buf, "chan=");
+ if (!start)
+ return -EINVAL;
+ start += 5;
+ end = strstr(start, " ");
+ if (!end)
+ end = buf + count;
+ hold = kzalloc((end - start)+1, GFP_KERNEL);
+ if (!hold)
+ return -ENOMEM;
+ strncpy(hold, start, end - start);
+ hold[(end-start)+1] = '\0';
+ while(hold && (str = strsep(&hold, ","))) {
+ int chan;
+ char band, passive = 0;
+ sscanf(str, "%d%c%c", &chan, &band, &passive);
+ scan_cfg->chanList[i].chanNumber = chan;
+ scan_cfg->chanList[i].scanType = passive ? 1 : 0;
+ if (band == 'b' || band == 'g')
+ scan_cfg->chanList[i].radioType = 0;
+ else if (band == 'a')
+ scan_cfg->chanList[i].radioType = 1;
+
+ scan_cfg->chanList[i].scanTime = dur;
+ i++;
+ }
+
+ kfree(hold);
+ return i;
+}
+
+static void libertas_parse_bssid(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold;
+ unsigned int mac[ETH_ALEN];
+ int i;
+
+ hold = strstr(buf, "bssid=");
+ if (!hold)
+ return;
+ hold += 6;
+ sscanf(hold, "%2x:%2x:%2x:%2x:%2x:%2x", mac, mac+1, mac+2, mac+3,
+ mac+4, mac+5);
+ for(i=0;i<ETH_ALEN;i++)
+ scan_cfg->specificBSSID[i] = mac[i];
+}
+
+static void libertas_parse_ssid(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold, *end;
+ ssize_t size;
+
+ hold = strstr(buf, "ssid=");
+ if (!hold)
+ return;
+ hold += 5;
+ end = strstr(hold, " ");
+ if (!end)
+ end = buf + count - 1;
+
+ size = min(IW_ESSID_MAX_SIZE, end - hold);
+ strncpy(scan_cfg->specificSSID, hold, size);
+
+ return;
+}
+
+static void libertas_parse_keep(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold;
+ int val;
+
+ hold = strstr(buf, "keep=");
+ if (!hold)
+ return;
+ hold += 5;
+ sscanf(hold, "%d", &val);
+
+ if (val != 0)
+ val = 1;
+
+ scan_cfg->keepPreviousScan = val;
+ return;
+}
+
+static int libertas_parse_dur(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold;
+ int val;
+
+ hold = strstr(buf, "dur=");
+ if (!hold)
+ return 0;
+ hold += 4;
+ sscanf(hold, "%d", &val);
+
+ return val;
+}
+
+static void libertas_parse_probes(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold;
+ int val;
+
+ hold = strstr(buf, "probes=");
+ if (!hold)
+ return;
+ hold += 7;
+ sscanf(hold, "%d", &val);
+
+ scan_cfg->numProbes = val;
+
+ return;
+}
+
+static void libertas_parse_type(char *buf, size_t count,
+ struct wlan_ioctl_user_scan_cfg *scan_cfg)
+{
+ char *hold;
+ int val;
+
+ hold = strstr(buf, "type=");
+ if (!hold)
+ return;
+ hold += 5;
+ sscanf(hold, "%d", &val);
+
+ /* type=1,2 or 3 */
+ if (val < 1 || val > 3)
+ return;
+
+ scan_cfg->bssType = val;
+
+ return;
+}
+
+static ssize_t libertas_setuserscan(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+ struct wlan_ioctl_user_scan_cfg *scan_cfg;
+ union iwreq_data wrqu;
+ int dur;
+
+ scan_cfg = kzalloc(sizeof(struct wlan_ioctl_user_scan_cfg), GFP_KERNEL);
+ if (!scan_cfg)
+ return -ENOMEM;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+
+ scan_cfg->bssType = WLAN_SCAN_BSS_TYPE_ANY;
+
+ dur = libertas_parse_dur(buf, count, scan_cfg);
+ libertas_parse_chan(buf, count, scan_cfg, dur);
+ libertas_parse_bssid(buf, count, scan_cfg);
+ libertas_parse_ssid(buf, count, scan_cfg);
+ libertas_parse_keep(buf, count, scan_cfg);
+ libertas_parse_probes(buf, count, scan_cfg);
+ libertas_parse_type(buf, count, scan_cfg);
+
+ wlan_scan_networks(priv, scan_cfg);
+
+ memset(&wrqu, 0x00, sizeof(union iwreq_data));
+ wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, NULL);
+
+out_unlock:
+ up(&big_buffer_sem);
+ kfree(scan_cfg);
+ return count;
+}
+
static struct file_operations libertas_devinfo_fops = {
.owner = THIS_MODULE,
@@ -246,6 +435,12 @@ static struct file_operations libertas_e
.write = libertas_extscan,
};
+static struct file_operations libertas_setuserscan_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = libertas_setuserscan,
+};
+
void libertas_debugfs_init(void)
{
if (!libertas_dir)
@@ -293,11 +488,15 @@ void libertas_debugfs_init_one(wlan_priv
priv,
&libertas_extscan_fops);
+ priv->debugfs_setuserscan = debugfs_create_file("setuserscan", 0600,
+ priv->debugfs_dir,
+ priv,
+ &libertas_setuserscan_fops);
+
#ifdef PROC_DEBUG
libertas_debug_init(priv, dev);
#endif
-
exit:
return;
}
@@ -308,6 +507,10 @@ #ifdef PROC_DEBUG
debugfs_remove(priv->debugfs_debug);
#endif
debugfs_remove(priv->debugfs_devinfo);
+ debugfs_remove(priv->debugfs_getscantable);
+ debugfs_remove(priv->debugfs_sleepparams);
+ debugfs_remove(priv->debugfs_extscan);
+ debugfs_remove(priv->debugfs_setuserscan);
debugfs_remove(priv->debugfs_dir);
}
diff --git a/drivers/net/wireless/libertas/wlan_dev.h b/drivers/net/wireless/libertas/wlan_dev.h
index 1d75139..102e30d 100644
--- a/drivers/net/wireless/libertas/wlan_dev.h
+++ b/drivers/net/wireless/libertas/wlan_dev.h
@@ -175,6 +175,7 @@ struct _wlan_private {
struct dentry *debugfs_getscantable;
struct dentry *debugfs_sleepparams;
struct dentry *debugfs_extscan;
+ struct dentry *debugfs_setuserscan;
const struct firmware *firmware;
struct device *hotplug_device;
diff --git a/drivers/net/wireless/libertas/wlan_ioctl.c b/drivers/net/wireless/libertas/wlan_ioctl.c
index 17ff747..4c84863 100644
--- a/drivers/net/wireless/libertas/wlan_ioctl.c
+++ b/drivers/net/wireless/libertas/wlan_ioctl.c
@@ -2660,15 +2660,6 @@ #define MAX_U16_VAL 65535
}
break;
- case WLAN_SET_GET_2K:
- switch ((int)wrq->u.data.flags) {
- case WLAN_SET_USER_SCAN:
- ret = libertas_set_user_scan_ioctl(priv, wrq);
- break;
- default:
- ret = -EOPNOTSUPP;
- }
- break;
default:
ret = -EINVAL;
break;
diff --git a/drivers/net/wireless/libertas/wlan_scan.c b/drivers/net/wireless/libertas/wlan_scan.c
index 59d6dfd..d820651 100644
--- a/drivers/net/wireless/libertas/wlan_scan.c
+++ b/drivers/net/wireless/libertas/wlan_scan.c
@@ -790,7 +790,7 @@ static int wlan_scan_channel_list(wlan_p
*
* @return WLAN_STATUS_SUCCESS or < 0 if error
*/
-static int wlan_scan_networks(wlan_private * priv,
+int wlan_scan_networks(wlan_private * priv,
const struct wlan_ioctl_user_scan_cfg * pUserScanIn)
{
wlan_adapter *Adapter = priv->adapter;
diff --git a/drivers/net/wireless/libertas/wlan_scan.h b/drivers/net/wireless/libertas/wlan_scan.h
index da5fd91..ee85385 100644
--- a/drivers/net/wireless/libertas/wlan_scan.h
+++ b/drivers/net/wireless/libertas/wlan_scan.h
@@ -229,6 +229,9 @@ extern int libertas_cmd_80211_scan(wlan_
extern int libertas_ret_80211_scan(wlan_private * priv,
struct HostCmd_DS_COMMAND *resp);
+int wlan_scan_networks(wlan_private * priv,
+ const struct wlan_ioctl_user_scan_cfg * pUserScanIn);
+
struct ifreq;
#ifdef __KERNEL__
diff --git a/drivers/net/wireless/libertas/wlan_wext.c b/drivers/net/wireless/libertas/wlan_wext.c
index 6688731..ff8c3b8 100644
--- a/drivers/net/wireless/libertas/wlan_wext.c
+++ b/drivers/net/wireless/libertas/wlan_wext.c
@@ -1675,18 +1675,6 @@ #endif /* REASSOCIATION */
IW_PRIV_TYPE_INT | 16,
IW_PRIV_TYPE_INT | 16,
"getrxinfo"},
-
- {
- WLAN_SET_GET_2K, /* IOCTL : 14 */
- IW_PRIV_TYPE_BYTE | 2000,
- IW_PRIV_TYPE_BYTE | 2000,
- ""},
-
- {
- WLAN_SET_USER_SCAN,
- IW_PRIV_TYPE_BYTE | 2000,
- IW_PRIV_TYPE_BYTE | 2000,
- "setuserscan"},
};
/**
diff --git a/drivers/net/wireless/libertas/wlan_wext.h b/drivers/net/wireless/libertas/wlan_wext.h
index 355a67d..f3054a3 100644
--- a/drivers/net/wireless/libertas/wlan_wext.h
+++ b/drivers/net/wireless/libertas/wlan_wext.h
@@ -74,9 +74,6 @@ #define GETLOG_BUFSIZE 300
#define WLANSCAN_TYPE (WLANIOCTL + 11)
-#define WLAN_SET_GET_2K (WLANIOCTL + 13)
-#define WLAN_SET_USER_SCAN 1
-
#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15)
#define WLANGETREGION 1
#define WLAN_GET_LISTEN_INTERVAL 2
More information about the Commits-kernel
mailing list