add wl_ioctl error handling
SVN-Revision: 583
This commit is contained in:
parent
2b2148884e
commit
ae9f767734
1 changed files with 34 additions and 26 deletions
|
@ -90,8 +90,6 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
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");
|
||||||
|
@ -99,7 +97,10 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
case SIOCGIWFREQ:
|
case SIOCGIWFREQ:
|
||||||
{
|
{
|
||||||
channel_info_t ci;
|
channel_info_t ci;
|
||||||
wl_ioctl(dev,WLC_GET_CHANNEL, &ci, sizeof(ci));
|
|
||||||
|
if (wl_ioctl(dev,WLC_GET_CHANNEL, &ci, sizeof(ci)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
wrqu->freq.m = ci.target_channel;
|
wrqu->freq.m = ci.target_channel;
|
||||||
wrqu->freq.e = 0;
|
wrqu->freq.e = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -112,29 +113,33 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
while ((channel < NUM_CHANNELS + 1) && (f != channel_frequency[channel]))
|
while ((channel < NUM_CHANNELS + 1) && (f != channel_frequency[channel]))
|
||||||
channel++;
|
channel++;
|
||||||
|
|
||||||
if (channel == NUM_CHANNELS) { // channel not found
|
if (channel == NUM_CHANNELS) // channel not found
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
} else {
|
|
||||||
wrqu->freq.e = 0;
|
wrqu->freq.e = 0;
|
||||||
wrqu->freq.m = channel + 1;
|
wrqu->freq.m = channel + 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((wrqu->freq.e == 0) && (wrqu->freq.m < 1000)) {
|
if ((wrqu->freq.e == 0) && (wrqu->freq.m < 1000)) {
|
||||||
wl_ioctl(dev, WLC_SET_CHANNEL, &wrqu->freq.m, sizeof(int));
|
if (wl_ioctl(dev, WLC_SET_CHANNEL, &wrqu->freq.m, sizeof(int)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SIOCGIWAP:
|
case SIOCGIWAP:
|
||||||
{
|
{
|
||||||
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
||||||
wl_ioctl(dev,WLC_GET_BSSID,wrqu->ap_addr.sa_data,6);
|
if (wl_ioctl(dev,WLC_GET_BSSID,wrqu->ap_addr.sa_data,6) < 0)
|
||||||
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIOCGIWESSID:
|
case SIOCGIWESSID:
|
||||||
{
|
{
|
||||||
wlc_ssid_t ssid;
|
wlc_ssid_t ssid;
|
||||||
wl_ioctl(dev,WLC_GET_SSID, &ssid, sizeof(wlc_ssid_t));
|
|
||||||
|
if (wl_ioctl(dev,WLC_GET_SSID, &ssid, sizeof(wlc_ssid_t)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
wrqu->essid.flags = wrqu->data.flags = 1;
|
wrqu->essid.flags = wrqu->data.flags = 1;
|
||||||
wrqu->essid.length = wrqu->data.length = ssid.SSID_len + 1;
|
wrqu->essid.length = wrqu->data.length = ssid.SSID_len + 1;
|
||||||
memcpy(extra,ssid.SSID,ssid.SSID_len + 1);
|
memcpy(extra,ssid.SSID,ssid.SSID_len + 1);
|
||||||
|
@ -148,23 +153,27 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
if (ssid.SSID_len > WLC_ESSID_MAX_SIZE)
|
if (ssid.SSID_len > WLC_ESSID_MAX_SIZE)
|
||||||
ssid.SSID_len = WLC_ESSID_MAX_SIZE;
|
ssid.SSID_len = WLC_ESSID_MAX_SIZE;
|
||||||
memcpy(ssid.SSID, extra, ssid.SSID_len);
|
memcpy(ssid.SSID, extra, ssid.SSID_len);
|
||||||
wl_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(ssid));
|
if (wl_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(ssid)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIOCGIWRTS:
|
case SIOCGIWRTS:
|
||||||
{
|
{
|
||||||
wl_ioctl(dev,WLC_GET_RTS,&(wrqu->rts.value),sizeof(int));
|
if (wl_ioctl(dev,WLC_GET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIOCGIWFRAG:
|
case SIOCGIWFRAG:
|
||||||
{
|
{
|
||||||
wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int));
|
if (wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIOCGIWTXPOW:
|
case SIOCGIWTXPOW:
|
||||||
{
|
{
|
||||||
wrqu->txpower.value = 0;
|
wrqu->txpower.value = 0;
|
||||||
wl_ioctl(dev,WLC_GET_TXPWR, &(wrqu->txpower.value), sizeof(int));
|
if (wl_ioctl(dev,WLC_GET_TXPWR, &(wrqu->txpower.value), sizeof(int)) < 0)
|
||||||
|
return -EINVAL;
|
||||||
wrqu->txpower.fixed = 0;
|
wrqu->txpower.fixed = 0;
|
||||||
wrqu->txpower.disabled = 0;
|
wrqu->txpower.disabled = 0;
|
||||||
wrqu->txpower.flags = IW_TXPOW_MWATT;
|
wrqu->txpower.flags = IW_TXPOW_MWATT;
|
||||||
|
@ -172,11 +181,11 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
}
|
}
|
||||||
case SIOCSIWTXPOW:
|
case SIOCSIWTXPOW:
|
||||||
{
|
{
|
||||||
if (wrqu->txpower.flags != IW_TXPOW_MWATT) {
|
if (wrqu->txpower.flags != IW_TXPOW_MWATT)
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
} else {
|
|
||||||
wl_ioctl(dev, WLC_SET_TXPWR, &wrqu->txpower.value, sizeof(int));
|
if (wl_ioctl(dev, WLC_SET_TXPWR, &wrqu->txpower.value, sizeof(int)) < 0)
|
||||||
}
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
case SIOCGIWENCODE:
|
case SIOCGIWENCODE:
|
||||||
{
|
{
|
||||||
|
@ -185,17 +194,16 @@ static int wlcompat_ioctl(struct net_device *dev,
|
||||||
}
|
}
|
||||||
case SIOCGIWRANGE:
|
case SIOCGIWRANGE:
|
||||||
{
|
{
|
||||||
err = wlcompat_ioctl_getiwrange(dev, extra);
|
return wlcompat_ioctl_getiwrange(dev, extra);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const iw_handler wlcompat_handler[] = {
|
static const iw_handler wlcompat_handler[] = {
|
||||||
|
|
Loading…
Reference in a new issue