Commit 3d5d5ac0 authored by Jean Tourrilhes's avatar Jean Tourrilhes Committed by Jeff Garzik

[PATCH] ray_cs : WE-17 support

        This adds support for WE-17 to the ray_cs driver. Tested
with 2.6.13 (with real HW).
Signed-off-by: default avatarJean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 6582c164
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
#define WIRELESS_SPY /* Enable spying addresses */ #define WIRELESS_SPY /* Enable spying addresses */
/* Definitions we need for spy */ /* Definitions we need for spy */
typedef struct iw_statistics iw_stats; typedef struct iw_statistics iw_stats;
typedef struct iw_quality iw_qual;
typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */ typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
#include "rayctl.h" #include "rayctl.h"
...@@ -101,7 +100,6 @@ static int ray_dev_close(struct net_device *dev); ...@@ -101,7 +100,6 @@ static int ray_dev_close(struct net_device *dev);
static int ray_dev_config(struct net_device *dev, struct ifmap *map); static int ray_dev_config(struct net_device *dev, struct ifmap *map);
static struct net_device_stats *ray_get_stats(struct net_device *dev); static struct net_device_stats *ray_get_stats(struct net_device *dev);
static int ray_dev_init(struct net_device *dev); static int ray_dev_init(struct net_device *dev);
static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static struct ethtool_ops netdev_ethtool_ops; static struct ethtool_ops netdev_ethtool_ops;
...@@ -114,9 +112,8 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, ...@@ -114,9 +112,8 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type, static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type,
unsigned char *data); unsigned char *data);
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len); static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */
static iw_stats * ray_get_wireless_stats(struct net_device * dev); static iw_stats * ray_get_wireless_stats(struct net_device * dev);
#endif /* WIRELESS_EXT > 7 */ static const struct iw_handler_def ray_handler_def;
/***** Prototypes for raylink functions **************************************/ /***** Prototypes for raylink functions **************************************/
static int asc_to_int(char a); static int asc_to_int(char a);
...@@ -373,11 +370,12 @@ static dev_link_t *ray_attach(void) ...@@ -373,11 +370,12 @@ static dev_link_t *ray_attach(void)
dev->hard_start_xmit = &ray_dev_start_xmit; dev->hard_start_xmit = &ray_dev_start_xmit;
dev->set_config = &ray_dev_config; dev->set_config = &ray_dev_config;
dev->get_stats = &ray_get_stats; dev->get_stats = &ray_get_stats;
dev->do_ioctl = &ray_dev_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */ dev->wireless_handlers = &ray_handler_def;
dev->get_wireless_stats = ray_get_wireless_stats; #ifdef WIRELESS_SPY
#endif local->wireless_data.spy_data = &local->spy_data;
dev->wireless_data = &local->wireless_data;
#endif /* WIRELESS_SPY */
dev->set_multicast_list = &set_multicast_list; dev->set_multicast_list = &set_multicast_list;
...@@ -1201,248 +1199,296 @@ static struct ethtool_ops netdev_ethtool_ops = { ...@@ -1201,248 +1199,296 @@ static struct ethtool_ops netdev_ethtool_ops = {
/*====================================================================*/ /*====================================================================*/
static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*------------------------------------------------------------------*/
/*
* Wireless Handler : get protocol name
*/
static int ray_get_name(struct net_device *dev,
struct iw_request_info *info,
char *cwrq,
char *extra)
{ {
ray_dev_t *local = (ray_dev_t *)dev->priv; strcpy(cwrq, "IEEE 802.11-FH");
dev_link_t *link = local->finder; return 0;
int err = 0; }
#if WIRELESS_EXT > 7
struct iwreq *wrq = (struct iwreq *) ifr;
#endif /* WIRELESS_EXT > 7 */
#ifdef WIRELESS_SPY
struct sockaddr address[IW_MAX_SPY];
#endif /* WIRELESS_SPY */
if (!(link->state & DEV_PRESENT)) {
DEBUG(2,"ray_dev_ioctl - device not present\n");
return -1;
}
DEBUG(2,"ray_cs IOCTL dev=%p, ifr=%p, cmd = 0x%x\n",dev,ifr,cmd);
/* Validate the command */
switch (cmd)
{
#if WIRELESS_EXT > 7
/* --------------- WIRELESS EXTENSIONS --------------- */
/* Get name */
case SIOCGIWNAME:
strcpy(wrq->u.name, "IEEE 802.11-FH");
break;
/* Get frequency/channel */ /*------------------------------------------------------------------*/
case SIOCGIWFREQ: /*
wrq->u.freq.m = local->sparm.b5.a_hop_pattern; * Wireless Handler : set frequency
wrq->u.freq.e = 0; */
break; static int ray_set_freq(struct net_device *dev,
struct iw_request_info *info,
struct iw_freq *fwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
int err = -EINPROGRESS; /* Call commit handler */
/* Set frequency/channel */
case SIOCSIWFREQ:
/* Reject if card is already initialised */ /* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM) if(local->card_status != CARD_AWAITING_PARAM)
{ return -EBUSY;
err = -EBUSY;
break;
}
/* Setting by channel number */ /* Setting by channel number */
if ((wrq->u.freq.m > USA_HOP_MOD) || (wrq->u.freq.e > 0)) if ((fwrq->m > USA_HOP_MOD) || (fwrq->e > 0))
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
else else
local->sparm.b5.a_hop_pattern = wrq->u.freq.m; local->sparm.b5.a_hop_pattern = fwrq->m;
break;
/* Get current network name (ESSID) */ return err;
case SIOCGIWESSID: }
if (wrq->u.data.pointer)
{
char essid[IW_ESSID_MAX_SIZE + 1];
/* Get the essid that was set */
memcpy(essid, local->sparm.b5.a_current_ess_id,
IW_ESSID_MAX_SIZE);
essid[IW_ESSID_MAX_SIZE] = '\0';
/* Push it out ! */ /*------------------------------------------------------------------*/
wrq->u.data.length = strlen(essid) + 1; /*
wrq->u.data.flags = 1; /* active */ * Wireless Handler : get frequency
if (copy_to_user(wrq->u.data.pointer, essid, sizeof(essid))) */
err = -EFAULT; static int ray_get_freq(struct net_device *dev,
} struct iw_request_info *info,
break; struct iw_freq *fwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
fwrq->m = local->sparm.b5.a_hop_pattern;
fwrq->e = 0;
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : set ESSID
*/
static int ray_set_essid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *dwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
/* Set desired network name (ESSID) */
case SIOCSIWESSID:
/* Reject if card is already initialised */ /* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM) if(local->card_status != CARD_AWAITING_PARAM)
{ return -EBUSY;
err = -EBUSY;
break;
}
if (wrq->u.data.pointer)
{
char card_essid[IW_ESSID_MAX_SIZE + 1];
/* Check if we asked for `any' */ /* Check if we asked for `any' */
if(wrq->u.data.flags == 0) if(dwrq->flags == 0) {
{
/* Corey : can you do that ? */ /* Corey : can you do that ? */
err = -EOPNOTSUPP; return -EOPNOTSUPP;
} } else {
else
{
/* Check the size of the string */ /* Check the size of the string */
if(wrq->u.data.length > if(dwrq->length > IW_ESSID_MAX_SIZE + 1) {
IW_ESSID_MAX_SIZE + 1) return -E2BIG;
{
err = -E2BIG;
break;
} }
if (copy_from_user(card_essid,
wrq->u.data.pointer,
wrq->u.data.length)) {
err = -EFAULT;
break;
}
card_essid[IW_ESSID_MAX_SIZE] = '\0';
/* Set the ESSID in the card */ /* Set the ESSID in the card */
memcpy(local->sparm.b5.a_current_ess_id, card_essid, memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);
IW_ESSID_MAX_SIZE); memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length);
}
} }
break;
/* Get current Access Point (BSSID in our case) */ return -EINPROGRESS; /* Call commit handler */
case SIOCGIWAP: }
memcpy(wrq->u.ap_addr.sa_data, local->bss_id, ETH_ALEN);
wrq->u.ap_addr.sa_family = ARPHRD_ETHER;
break;
/* Get the current bit-rate */ /*------------------------------------------------------------------*/
case SIOCGIWRATE: /*
if(local->net_default_tx_rate == 3) * Wireless Handler : get ESSID
wrq->u.bitrate.value = 2000000; /* Hum... */ */
else static int ray_get_essid(struct net_device *dev,
wrq->u.bitrate.value = local->net_default_tx_rate * 500000; struct iw_request_info *info,
wrq->u.bitrate.fixed = 0; /* We are in auto mode */ struct iw_point *dwrq,
break; char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
/* Get the essid that was set */
memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
extra[IW_ESSID_MAX_SIZE] = '\0';
/* Push it out ! */
dwrq->length = strlen(extra) + 1;
dwrq->flags = 1; /* active */
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : get AP address
*/
static int ray_get_wap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *awrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
memcpy(awrq->sa_data, local->bss_id, ETH_ALEN);
awrq->sa_family = ARPHRD_ETHER;
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : set Bit-Rate
*/
static int ray_set_rate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* Set the desired bit-rate */
case SIOCSIWRATE:
/* Check if rate is in range */ /* Check if rate is in range */
if((wrq->u.bitrate.value != 1000000) && if((vwrq->value != 1000000) && (vwrq->value != 2000000))
(wrq->u.bitrate.value != 2000000)) return -EINVAL;
{
err = -EINVAL;
break;
}
/* Hack for 1.5 Mb/s instead of 2 Mb/s */ /* Hack for 1.5 Mb/s instead of 2 Mb/s */
if((local->fw_ver == 0x55) && /* Please check */ if((local->fw_ver == 0x55) && /* Please check */
(wrq->u.bitrate.value == 2000000)) (vwrq->value == 2000000))
local->net_default_tx_rate = 3; local->net_default_tx_rate = 3;
else else
local->net_default_tx_rate = wrq->u.bitrate.value/500000; local->net_default_tx_rate = vwrq->value/500000;
break;
/* Get the current RTS threshold */ return 0;
case SIOCGIWRTS: }
wrq->u.rts.value = (local->sparm.b5.a_rts_threshold[0] << 8)
+ local->sparm.b5.a_rts_threshold[1];
#if WIRELESS_EXT > 8
wrq->u.rts.disabled = (wrq->u.rts.value == 32767);
#endif /* WIRELESS_EXT > 8 */
wrq->u.rts.fixed = 1;
break;
/* Set the desired RTS threshold */ /*------------------------------------------------------------------*/
case SIOCSIWRTS: /*
{ * Wireless Handler : get Bit-Rate
int rthr = wrq->u.rts.value; */
static int ray_get_rate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
if(local->net_default_tx_rate == 3)
vwrq->value = 2000000; /* Hum... */
else
vwrq->value = local->net_default_tx_rate * 500000;
vwrq->fixed = 0; /* We are in auto mode */
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : set RTS threshold
*/
static int ray_set_rts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
int rthr = vwrq->value;
/* Reject if card is already initialised */ /* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM) if(local->card_status != CARD_AWAITING_PARAM)
{ return -EBUSY;
err = -EBUSY;
break;
}
/* if(wrq->u.rts.fixed == 0) we should complain */ /* if(wrq->u.rts.fixed == 0) we should complain */
#if WIRELESS_EXT > 8 if(vwrq->disabled)
if(wrq->u.rts.disabled)
rthr = 32767; rthr = 32767;
else else {
#endif /* WIRELESS_EXT > 8 */
if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */ if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
{ return -EINVAL;
err = -EINVAL;
break;
} }
local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF; local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF; local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;
}
break;
/* Get the current fragmentation threshold */ return -EINPROGRESS; /* Call commit handler */
case SIOCGIWFRAG: }
wrq->u.frag.value = (local->sparm.b5.a_frag_threshold[0] << 8)
+ local->sparm.b5.a_frag_threshold[1];
#if WIRELESS_EXT > 8
wrq->u.frag.disabled = (wrq->u.frag.value == 32767);
#endif /* WIRELESS_EXT > 8 */
wrq->u.frag.fixed = 1;
break;
/* Set the desired fragmentation threshold */
case SIOCSIWFRAG: /*------------------------------------------------------------------*/
{ /*
int fthr = wrq->u.frag.value; * Wireless Handler : get RTS threshold
*/
static int ray_get_rts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8)
+ local->sparm.b5.a_rts_threshold[1];
vwrq->disabled = (vwrq->value == 32767);
vwrq->fixed = 1;
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : set Fragmentation threshold
*/
static int ray_set_frag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
int fthr = vwrq->value;
/* Reject if card is already initialised */ /* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM) if(local->card_status != CARD_AWAITING_PARAM)
{ return -EBUSY;
err = -EBUSY;
break;
}
/* if(wrq->u.frag.fixed == 0) should complain */ /* if(wrq->u.frag.fixed == 0) should complain */
#if WIRELESS_EXT > 8 if(vwrq->disabled)
if(wrq->u.frag.disabled)
fthr = 32767; fthr = 32767;
else else {
#endif /* WIRELESS_EXT > 8 */
if((fthr < 256) || (fthr > 2347)) /* To check out ! */ if((fthr < 256) || (fthr > 2347)) /* To check out ! */
{ return -EINVAL;
err = -EINVAL;
break;
} }
local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF; local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF; local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;
}
break;
#endif /* WIRELESS_EXT > 7 */ return -EINPROGRESS; /* Call commit handler */
#if WIRELESS_EXT > 8 }
/* Get the current mode of operation */ /*------------------------------------------------------------------*/
case SIOCGIWMODE: /*
if(local->sparm.b5.a_network_type) * Wireless Handler : get Fragmentation threshold
wrq->u.mode = IW_MODE_INFRA; */
else static int ray_get_frag(struct net_device *dev,
wrq->u.mode = IW_MODE_ADHOC; struct iw_request_info *info,
break; struct iw_param *vwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
/* Set the current mode of operation */ vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8)
case SIOCSIWMODE: + local->sparm.b5.a_frag_threshold[1];
{ vwrq->disabled = (vwrq->value == 32767);
vwrq->fixed = 1;
return 0;
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : set Mode of Operation
*/
static int ray_set_mode(struct net_device *dev,
struct iw_request_info *info,
__u32 *uwrq,
char *extra)
{
ray_dev_t *local = (ray_dev_t *)dev->priv;
int err = -EINPROGRESS; /* Call commit handler */
char card_mode = 1; char card_mode = 1;
/* Reject if card is already initialised */ /* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM) if(local->card_status != CARD_AWAITING_PARAM)
{ return -EBUSY;
err = -EBUSY;
break;
}
switch (wrq->u.mode) switch (*uwrq)
{ {
case IW_MODE_ADHOC: case IW_MODE_ADHOC:
card_mode = 0; card_mode = 0;
...@@ -1453,184 +1499,120 @@ static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -1453,184 +1499,120 @@ static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
default: default:
err = -EINVAL; err = -EINVAL;
} }
}
break;
#endif /* WIRELESS_EXT > 8 */ return err;
#if WIRELESS_EXT > 7 }
/* ------------------ IWSPY SUPPORT ------------------ */
/* Define the range (variations) of above parameters */
case SIOCGIWRANGE:
/* Basic checking... */
if(wrq->u.data.pointer != (caddr_t) 0)
{
struct iw_range range;
memset((char *) &range, 0, sizeof(struct iw_range));
/* Set the length (very important for backward compatibility) */
wrq->u.data.length = sizeof(struct iw_range);
#if WIRELESS_EXT > 10
/* Set the Wireless Extension versions */
range.we_version_compiled = WIRELESS_EXT;
range.we_version_source = 9;
#endif /* WIRELESS_EXT > 10 */
/* Set information in the range struct */
range.throughput = 1.1 * 1000 * 1000; /* Put the right number here */
range.num_channels = hop_pattern_length[(int)country];
range.num_frequency = 0;
range.max_qual.qual = 0;
range.max_qual.level = 255; /* What's the correct value ? */
range.max_qual.noise = 255; /* Idem */
range.num_bitrates = 2;
range.bitrate[0] = 1000000; /* 1 Mb/s */
range.bitrate[1] = 2000000; /* 2 Mb/s */
/* Copy structure to the user buffer */
if(copy_to_user(wrq->u.data.pointer, &range,
sizeof(struct iw_range)))
err = -EFAULT;
}
break;
#ifdef WIRELESS_SPY /*------------------------------------------------------------------*/
/* Set addresses to spy */ /*
case SIOCSIWSPY: * Wireless Handler : get Mode of Operation
/* Check the number of addresses */ */
if(wrq->u.data.length > IW_MAX_SPY) static int ray_get_mode(struct net_device *dev,
{ struct iw_request_info *info,
err = -E2BIG; __u32 *uwrq,
break; char *extra)
} {
local->spy_number = wrq->u.data.length; ray_dev_t *local = (ray_dev_t *)dev->priv;
/* If there is some addresses to copy */ if(local->sparm.b5.a_network_type)
if(local->spy_number > 0) *uwrq = IW_MODE_INFRA;
{ else
int i; *uwrq = IW_MODE_ADHOC;
/* Copy addresses to the driver */ return 0;
if(copy_from_user(address, wrq->u.data.pointer, }
sizeof(struct sockaddr) * local->spy_number))
{
err = -EFAULT;
break;
}
/* Copy addresses to the lp structure */ /*------------------------------------------------------------------*/
for(i = 0; i < local->spy_number; i++) /*
memcpy(local->spy_address[i], address[i].sa_data, ETH_ALEN); * Wireless Handler : get range info
*/
static int ray_get_range(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *dwrq,
char *extra)
{
struct iw_range *range = (struct iw_range *) extra;
/* Reset structure... */ memset((char *) range, 0, sizeof(struct iw_range));
memset(local->spy_stat, 0x00, sizeof(iw_qual) * IW_MAX_SPY);
#ifdef DEBUG_IOCTL_INFO /* Set the length (very important for backward compatibility) */
printk(KERN_DEBUG "SetSpy - Set of new addresses is :\n"); dwrq->length = sizeof(struct iw_range);
for(i = 0; i < local->spy_number; i++)
printk(KERN_DEBUG "%02X:%02X:%02X:%02X:%02X:%02X\n",
local->spy_address[i][0],
local->spy_address[i][1],
local->spy_address[i][2],
local->spy_address[i][3],
local->spy_address[i][4],
local->spy_address[i][5]);
#endif /* DEBUG_IOCTL_INFO */
}
break;
/* Get the spy list and spy stats */ /* Set the Wireless Extension versions */
case SIOCGIWSPY: range->we_version_compiled = WIRELESS_EXT;
/* Set the number of addresses */ range->we_version_source = 9;
wrq->u.data.length = local->spy_number;
/* If the user want to have the addresses back... */ /* Set information in the range struct */
if((local->spy_number > 0) && (wrq->u.data.pointer != (caddr_t) 0)) range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
{ range->num_channels = hop_pattern_length[(int)country];
int i; range->num_frequency = 0;
range->max_qual.qual = 0;
range->max_qual.level = 255; /* What's the correct value ? */
range->max_qual.noise = 255; /* Idem */
range->num_bitrates = 2;
range->bitrate[0] = 1000000; /* 1 Mb/s */
range->bitrate[1] = 2000000; /* 2 Mb/s */
return 0;
}
/* Copy addresses from the lp structure */ /*------------------------------------------------------------------*/
for(i = 0; i < local->spy_number; i++) /*
{ * Wireless Private Handler : set framing mode
memcpy(address[i].sa_data, local->spy_address[i], ETH_ALEN); */
address[i].sa_family = ARPHRD_ETHER; static int ray_set_framing(struct net_device *dev,
} struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
{
translate = *(extra); /* Set framing mode */
/* Copy addresses to the user buffer */ return 0;
if(copy_to_user(wrq->u.data.pointer, address, }
sizeof(struct sockaddr) * local->spy_number))
{
err = -EFAULT;
break;
}
/* Copy stats to the user buffer (just after) */ /*------------------------------------------------------------------*/
if(copy_to_user(wrq->u.data.pointer + /*
(sizeof(struct sockaddr) * local->spy_number), * Wireless Private Handler : get framing mode
local->spy_stat, sizeof(iw_qual) * local->spy_number)) */
{ static int ray_get_framing(struct net_device *dev,
err = -EFAULT; struct iw_request_info *info,
break; union iwreq_data *wrqu,
} char *extra)
{
*(extra) = translate;
/* Reset updated flags */ return 0;
for(i = 0; i < local->spy_number; i++) }
local->spy_stat[i].updated = 0x0;
} /* if(pointer != NULL) */
break; /*------------------------------------------------------------------*/
#endif /* WIRELESS_SPY */ /*
* Wireless Private Handler : get country
*/
static int ray_get_country(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
{
*(extra) = country;
/* ------------------ PRIVATE IOCTL ------------------ */ return 0;
#ifndef SIOCIWFIRSTPRIV }
#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
#endif /* SIOCIWFIRSTPRIV */
#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
case SIOCSIPFRAMING:
if(!capable(CAP_NET_ADMIN)) /* For private IOCTLs, we need to check permissions */
{
err = -EPERM;
break;
}
translate = *(wrq->u.name); /* Set framing mode */
break;
case SIOCGIPFRAMING:
*(wrq->u.name) = translate;
break;
case SIOCGIPCOUNTRY:
*(wrq->u.name) = country;
break;
case SIOCGIWPRIV:
/* Export our "private" intercace */
if(wrq->u.data.pointer != (caddr_t) 0)
{
struct iw_priv_args priv[] =
{ /* cmd, set_args, get_args, name */
{ SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "set_framing" },
{ SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_framing" },
{ SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_country" },
};
/* Set the number of ioctl available */
wrq->u.data.length = 3;
/* Copy structure to the user buffer */
if(copy_to_user(wrq->u.data.pointer, (u_char *) priv,
sizeof(priv)))
err = -EFAULT;
}
break;
#endif /* WIRELESS_EXT > 7 */
/*------------------------------------------------------------------*/
/*
* Commit handler : called after a bunch of SET operations
*/
static int ray_commit(struct net_device *dev,
struct iw_request_info *info, /* NULL */
void *zwrq, /* NULL */
char *extra) /* NULL */
{
return 0;
}
default: /*------------------------------------------------------------------*/
DEBUG(0,"ray_dev_ioctl cmd = 0x%x\n", cmd); /*
err = -EOPNOTSUPP; * Stats handler : return Wireless Stats
} */
return err;
} /* end ray_dev_ioctl */
/*===========================================================================*/
#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */
static iw_stats * ray_get_wireless_stats(struct net_device * dev) static iw_stats * ray_get_wireless_stats(struct net_device * dev)
{ {
ray_dev_t * local = (ray_dev_t *) dev->priv; ray_dev_t * local = (ray_dev_t *) dev->priv;
...@@ -1642,13 +1624,13 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev) ...@@ -1642,13 +1624,13 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
local->wstats.status = local->card_status; local->wstats.status = local->card_status;
#ifdef WIRELESS_SPY #ifdef WIRELESS_SPY
if((local->spy_number > 0) && (local->sparm.b5.a_network_type == 0)) if((local->spy_data.spy_number > 0) && (local->sparm.b5.a_network_type == 0))
{ {
/* Get it from the first node in spy list */ /* Get it from the first node in spy list */
local->wstats.qual.qual = local->spy_stat[0].qual; local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;
local->wstats.qual.level = local->spy_stat[0].level; local->wstats.qual.level = local->spy_data.spy_stat[0].level;
local->wstats.qual.noise = local->spy_stat[0].noise; local->wstats.qual.noise = local->spy_data.spy_stat[0].noise;
local->wstats.qual.updated = local->spy_stat[0].updated; local->wstats.qual.updated = local->spy_data.spy_stat[0].updated;
} }
#endif /* WIRELESS_SPY */ #endif /* WIRELESS_SPY */
...@@ -1659,7 +1641,65 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev) ...@@ -1659,7 +1641,65 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
return &local->wstats; return &local->wstats;
} /* end ray_get_wireless_stats */ } /* end ray_get_wireless_stats */
#endif /* WIRELESS_EXT > 7 */
/*------------------------------------------------------------------*/
/*
* Structures to export the Wireless Handlers
*/
static const iw_handler ray_handler[] = {
[SIOCSIWCOMMIT-SIOCIWFIRST] (iw_handler) ray_commit,
[SIOCGIWNAME -SIOCIWFIRST] (iw_handler) ray_get_name,
[SIOCSIWFREQ -SIOCIWFIRST] (iw_handler) ray_set_freq,
[SIOCGIWFREQ -SIOCIWFIRST] (iw_handler) ray_get_freq,
[SIOCSIWMODE -SIOCIWFIRST] (iw_handler) ray_set_mode,
[SIOCGIWMODE -SIOCIWFIRST] (iw_handler) ray_get_mode,
[SIOCGIWRANGE -SIOCIWFIRST] (iw_handler) ray_get_range,
#ifdef WIRELESS_SPY
[SIOCSIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_set_spy,
[SIOCGIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_get_spy,
[SIOCSIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_set_thrspy,
[SIOCGIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_get_thrspy,
#endif /* WIRELESS_SPY */
[SIOCGIWAP -SIOCIWFIRST] (iw_handler) ray_get_wap,
[SIOCSIWESSID -SIOCIWFIRST] (iw_handler) ray_set_essid,
[SIOCGIWESSID -SIOCIWFIRST] (iw_handler) ray_get_essid,
[SIOCSIWRATE -SIOCIWFIRST] (iw_handler) ray_set_rate,
[SIOCGIWRATE -SIOCIWFIRST] (iw_handler) ray_get_rate,
[SIOCSIWRTS -SIOCIWFIRST] (iw_handler) ray_set_rts,
[SIOCGIWRTS -SIOCIWFIRST] (iw_handler) ray_get_rts,
[SIOCSIWFRAG -SIOCIWFIRST] (iw_handler) ray_set_frag,
[SIOCGIWFRAG -SIOCIWFIRST] (iw_handler) ray_get_frag,
};
#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
static const iw_handler ray_private_handler[] = {
[0] (iw_handler) ray_set_framing,
[1] (iw_handler) ray_get_framing,
[3] (iw_handler) ray_get_country,
};
static const struct iw_priv_args ray_private_args[] = {
/* cmd, set_args, get_args, name */
{ SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "set_framing" },
{ SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_framing" },
{ SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_country" },
};
static const struct iw_handler_def ray_handler_def =
{
.num_standard = sizeof(ray_handler)/sizeof(iw_handler),
.num_private = sizeof(ray_private_handler)/sizeof(iw_handler),
.num_private_args = sizeof(ray_private_args)/sizeof(struct iw_priv_args),
.standard = ray_handler,
.private = ray_private_handler,
.private_args = ray_private_args,
.get_wireless_stats = ray_get_wireless_stats,
};
/*===========================================================================*/ /*===========================================================================*/
static int ray_open(struct net_device *dev) static int ray_open(struct net_device *dev)
{ {
...@@ -2392,20 +2432,15 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i ...@@ -2392,20 +2432,15 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
/*local->wstats.qual.noise = none ? */ /*local->wstats.qual.noise = none ? */
local->wstats.qual.updated = 0x2; local->wstats.qual.updated = 0x2;
} }
/* Now, for the addresses in the spy list */ /* Now, update the spy stuff */
{ {
int i; struct iw_quality wstats;
/* Look all addresses */ wstats.level = siglev;
for(i = 0; i < local->spy_number; i++) /* wstats.noise = none ? */
/* If match */ /* wstats.qual = none ? */
if(!memcmp(linksrcaddr, local->spy_address[i], ETH_ALEN)) wstats.updated = 0x2;
{ /* Update spy records */
/* Update statistics */ wireless_spy_update(dev, linksrcaddr, &wstats);
/*local->spy_stat[i].qual = none ? */
local->spy_stat[i].level = siglev;
/*local->spy_stat[i].noise = none ? */
local->spy_stat[i].updated = 0x2;
}
} }
#endif /* WIRELESS_SPY */ #endif /* WIRELESS_SPY */
} /* end rx_data */ } /* end rx_data */
......
...@@ -63,13 +63,10 @@ typedef struct ray_dev_t { ...@@ -63,13 +63,10 @@ typedef struct ray_dev_t {
UCHAR last_rsl; UCHAR last_rsl;
int beacon_rxed; int beacon_rxed;
struct beacon_rx last_bcn; struct beacon_rx last_bcn;
#ifdef WIRELESS_EXT
iw_stats wstats; /* Wireless specific stats */ iw_stats wstats; /* Wireless specific stats */
#endif
#ifdef WIRELESS_SPY #ifdef WIRELESS_SPY
int spy_number; /* Number of addresses to spy */ struct iw_spy_data spy_data;
mac_addr spy_address[IW_MAX_SPY + 1]; /* The addresses to spy */ struct iw_public_data wireless_data;
iw_qual spy_stat[IW_MAX_SPY + 1]; /* Statistics gathered */
#endif /* WIRELESS_SPY */ #endif /* WIRELESS_SPY */
} ray_dev_t; } ray_dev_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment