#define DEBUG
static struct net_device *dev;
+char buf[WLC_IOCTL_MAXLEN];
/* The frequency of each channel in MHz */
const long channel_frequency[] = {
range->pmt_flags = IW_POWER_TIMEOUT;
range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
+ range->min_pmp = 0;
+ range->max_pmp = 65535000;
+ range->min_pmt = 0;
+ range->max_pmt = 65535 * 1000;
+
range->min_rts = 0;
if (wl_ioctl(dev, WLC_GET_RTS, &range->max_rts, sizeof(int)) < 0)
range->max_rts = 2347;
if (wl_ioctl(dev, WLC_GET_FRAG, &range->max_frag, sizeof(int)) < 0)
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_set_scan(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra)
+{
+ int ap = 0, oldap = 0;
+ wl_scan_params_t params;
+
+ memset(¶ms, 0, sizeof(params));
+
+ /* use defaults (same parameters as wl scan) */
+ memset(¶ms.bssid, 0xff, sizeof(params.bssid));
+ params.bss_type = DOT11_BSSTYPE_ANY;
+ params.scan_type = -1;
+ params.nprobes = -1;
+ params.active_time = -1;
+ params.passive_time = -1;
+ params.home_time = -1;
+
+ /* can only scan in STA mode */
+ wl_ioctl(dev, WLC_GET_AP, &oldap, sizeof(oldap));
+ if (oldap > 0)
+ wl_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap));
+
+ if (wl_ioctl(dev, WLC_SCAN, ¶ms, 64) < 0)
+ return -EINVAL;
+
+ if (oldap > 0)
+ wl_ioctl(dev, WLC_SET_AP, &oldap, sizeof(oldap));
+
+ return 0;
+}
+
+
+static int wlcompat_get_scan(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra)
+{
+ wl_scan_results_t *results = (wl_scan_results_t *) buf;
+ wl_bss_info_t *bss_info;
+ char *info_ptr;
+ char *current_ev = extra;
+ char *current_val;
+ char *end_buf = extra + IW_SCAN_MAX_DATA;
+ struct iw_event iwe;
+ int i;
+
+ if (wl_ioctl(dev, WLC_SCAN_RESULTS, buf, WLC_IOCTL_MAXLEN) < 0)
+ return -EAGAIN;
+
+ bss_info = &(results->bss_info[0]);
+ info_ptr = (char *) bss_info;
+ for (i = 0; i < results->count; i++) {
+
+ /* send the cell address (must be sent first) */
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(&iwe.u.ap_addr.sa_data, &bss_info->BSSID, sizeof(bss_info->BSSID));
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
+
+ /* send the ESSID */
+ iwe.cmd = SIOCGIWESSID;
+ iwe.u.data.length = bss_info->SSID_len;
+ if (iwe.u.data.length > IW_ESSID_MAX_SIZE)
+ iwe.u.data.length = IW_ESSID_MAX_SIZE;
+ iwe.u.data.flags = 1;
+ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, bss_info->SSID);
+
+ /* send frequency/channel info */
+ iwe.cmd = SIOCGIWFREQ;
+ iwe.u.freq.e = 0;
+ iwe.u.freq.m = bss_info->channel;
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
+
+ /* add quality statistics */
+ iwe.cmd = IWEVQUAL;
+ iwe.u.qual.level = bss_info->RSSI;
+ iwe.u.qual.noise = bss_info->phy_noise;
+ iwe.u.qual.qual = 0;
+ current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+
+ /* send rate information */
+ iwe.cmd = SIOCGIWRATE;
+ 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);
+ 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)
+ current_ev = current_val;
+
+ info_ptr += sizeof(wl_bss_info_t);
+ if (bss_info->ie_length % 4)
+ info_ptr += bss_info->ie_length + 4 - (bss_info->ie_length % 4);
+ else
+ info_ptr += bss_info->ie_length;
+ bss_info = (wl_bss_info_t *) info_ptr;
+ }
+
+ wrqu->data.length = (current_ev - extra);
+ wrqu->data.flags = 0;
+
+ return 0;
+}
+
static int wlcompat_ioctl(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
} else {
return -EINVAL;
}
+ break;
}
case SIOCGIWAP:
{
return -EINVAL;
break;
}
+ case SIOCSIWRTS:
+ {
+ if (wl_ioctl(dev,WLC_SET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
+ return -EINVAL;
+ break;
+ }
case SIOCGIWFRAG:
{
if (wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
return -EINVAL;
break;
}
+ case SIOCSIWFRAG:
+ {
+ if (wl_ioctl(dev,WLC_SET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
+ return -EINVAL;
+ break;
+ }
case SIOCGIWTXPOW:
{
wrqu->txpower.value = 0;
wlcompat_ioctl, /* SIOCGIWMODE */
NULL, /* SIOCSIWSENS */
NULL, /* SIOCGIWSENS */
- NULL, /* SIOCSIWRANGE */
+ NULL, /* SIOCSIWRANGE, unused */
wlcompat_ioctl, /* SIOCGIWRANGE */
NULL, /* SIOCSIWPRIV */
NULL, /* SIOCGIWPRIV */
wlcompat_ioctl, /* SIOCGIWAP */
NULL, /* -- hole -- */
NULL, /* SIOCGIWAPLIST */
- NULL, /* -- hole -- */
- NULL, /* -- hole -- */
+ wlcompat_set_scan, /* SIOCSIWSCAN */
+ wlcompat_get_scan, /* SIOCGIWSCAN */
wlcompat_ioctl, /* SIOCSIWESSID */
wlcompat_ioctl, /* SIOCGIWESSID */
NULL, /* SIOCSIWNICKN */
NULL, /* -- hole -- */
NULL, /* SIOCSIWRATE */
NULL, /* SIOCGIWRATE */
- NULL, /* SIOCSIWRTS */
+ wlcompat_ioctl, /* SIOCSIWRTS */
wlcompat_ioctl, /* SIOCGIWRTS */
- NULL, /* SIOCSIWFRAG */
+ wlcompat_ioctl, /* SIOCSIWFRAG */
wlcompat_ioctl, /* SIOCGIWFRAG */
wlcompat_ioctl, /* SIOCSIWTXPOW */
wlcompat_ioctl, /* SIOCGIWTXPOW */