add SIOCGIWRANGE

SVN-Revision: 578
This commit is contained in:
Felix Fietkau 2005-04-08 11:45:39 +00:00
parent b7d92815a6
commit 46259ab4a2

View File

@ -6,6 +6,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/wireless.h>
#include <net/iw_handler.h> #include <net/iw_handler.h>
#include <wlioctl.h> #include <wlioctl.h>
@ -14,6 +15,13 @@
static struct net_device *dev; static struct net_device *dev;
/* The frequency of each channel in MHz */
const long channel_frequency[] = {
2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484
};
#define NUM_CHANNELS ( sizeof(channel_frequency) / sizeof(channel_frequency[0]) )
static int wl_ioctl(struct net_device *dev, int cmd, void *buf, int len) static int wl_ioctl(struct net_device *dev, int cmd, void *buf, int len)
{ {
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
@ -31,12 +39,59 @@ static int wl_ioctl(struct net_device *dev, int cmd, void *buf, int len)
return ret; return ret;
} }
static int wlcompat_ioctl_getiwrange(struct net_device *dev,
char *extra)
{
int i, k;
struct iw_range *range;
range = (struct iw_range *) extra;
range->we_version_compiled = WIRELESS_EXT;
range->we_version_source = WIRELESS_EXT;
range->min_nwid = range->max_nwid = 0;
range->num_channels = NUM_CHANNELS;
k = 0;
for (i = 0; i < NUM_CHANNELS; i++) {
range->freq[k].i = i + 1;
range->freq[k].m = channel_frequency[i] * 100000;
range->freq[k].e = 1;
k++;
if (k >= IW_MAX_FREQUENCIES)
break;
}
range->num_frequency = k;
range->sensitivity = 3;
/* nbd: don't know what this means, but other drivers set it this way */
range->pmp_flags = IW_POWER_PERIOD;
range->pmt_flags = IW_POWER_TIMEOUT;
range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
range->min_rts = 0;
range->max_rts = 2347;
range->min_frag = 256;
range->max_frag = 2346;
range->min_pmp = 0;
range->max_pmp = 65535000;
range->min_pmt = 0;
range->max_pmt = 65535 * 1000;
range->txpower_capa = IW_TXPOW_MWATT;
return 0;
}
static int wlcompat_ioctl(struct net_device *dev, static int wlcompat_ioctl(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
union iwreq_data *wrqu, union iwreq_data *wrqu,
char *extra) char *extra)
{ {
int err = 0;
switch (info->cmd) { switch (info->cmd) {
case SIOCGIWNAME: case SIOCGIWNAME:
strcpy(wrqu->name, "IEEE 802.11-DS"); strcpy(wrqu->name, "IEEE 802.11-DS");
@ -88,12 +143,18 @@ static int wlcompat_ioctl(struct net_device *dev,
wrqu->data.flags = IW_ENCODE_DISABLED; wrqu->data.flags = IW_ENCODE_DISABLED;
break; break;
} }
case SIOCGIWRANGE:
{
err = wlcompat_ioctl_getiwrange(dev, extra);
break;
}
} }
return 0;
return err;
} }
static const iw_handler wlcompat_handler[] = { static const iw_handler wlcompat_handler[] = {
NULL, /* SIOCSIWNAME */ NULL, /* SIOCSIWCOMMIT */
wlcompat_ioctl, /* SIOCGIWNAME */ wlcompat_ioctl, /* SIOCGIWNAME */
NULL, /* SIOCSIWNWID */ NULL, /* SIOCSIWNWID */
NULL, /* SIOCGIWNWID */ NULL, /* SIOCGIWNWID */
@ -104,7 +165,7 @@ static const iw_handler wlcompat_handler[] = {
NULL, /* SIOCSIWSENS */ NULL, /* SIOCSIWSENS */
NULL, /* SIOCGIWSENS */ NULL, /* SIOCGIWSENS */
NULL, /* SIOCSIWRANGE */ NULL, /* SIOCSIWRANGE */
NULL, /* SIOCGIWRANGE */ wlcompat_ioctl, /* SIOCGIWRANGE */
NULL, /* SIOCSIWPRIV */ NULL, /* SIOCSIWPRIV */
NULL, /* SIOCGIWPRIV */ NULL, /* SIOCGIWPRIV */
NULL, /* SIOCSIWSTATS */ NULL, /* SIOCSIWSTATS */