2
* Linux Wireless Extensions support
4
* Copyright 2008, Broadcom Corporation
7
* Unless you and Broadcom execute a separate written software license
8
* agreement governing use of this software, this software is licensed to you
9
* under the terms of the GNU General Public License version 2, available at
10
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"), with the
11
* following added to such license:
12
* As a special exception, the copyright holders of this software give you
13
* permission to link this software with independent modules, regardless of the
14
* license terms of these independent modules, and to copy and distribute the
15
* resulting executable under terms of your choice, provided that you also meet,
16
* for each linked independent module, the terms and conditions of the license
17
* of that module. An independent module is a module which is not derived from
20
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
25
* $Id: wl_iw.c,v 1.63.2.25.4.4 2009/04/20 19:22:00 Exp $
35
#include <bcmendian.h>
36
#include <proto/ethernet.h>
38
#include <linux/if_arp.h>
39
#include <asm/uaccess.h>
41
typedef void wlc_info_t;
42
typedef void wl_info_t;
43
typedef const struct si_pub si_t;
49
extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
50
uint32 reason, char* stringBuf, uint buflen);
52
#define MAX_IOCTL_LEN 600
58
#define htodchanspec(i) i
59
#define dtohchanspec(i) i
61
#ifdef CONFIG_WIRELESS_EXT
62
extern struct iw_statistics *wl_get_wireless_stats(struct net_device *dev);
66
#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
67
#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
70
static void swap_key_from_BE(
74
key->index = htod32(key->index);
75
key->len = htod32(key->len);
76
key->algo = htod32(key->algo);
77
key->flags = htod32(key->flags);
78
key->rxiv.hi = htod32(key->rxiv.hi);
79
key->rxiv.lo = htod16(key->rxiv.lo);
80
key->iv_initialized = htod32(key->iv_initialized);
83
static void swap_key_to_BE(
87
key->index = dtoh32(key->index);
88
key->len = dtoh32(key->len);
89
key->algo = dtoh32(key->algo);
90
key->flags = dtoh32(key->flags);
91
key->rxiv.hi = dtoh32(key->rxiv.hi);
92
key->rxiv.lo = dtoh16(key->rxiv.lo);
93
key->iv_initialized = dtoh32(key->iv_initialized);
98
struct net_device *dev,
109
memset(&ioc, 0, sizeof(ioc));
114
strcpy(ifr.ifr_name, dev->name);
115
ifr.ifr_data = (caddr_t) &ioc;
121
ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
129
struct net_device *dev,
133
char buf[WLC_IOCTL_SMLEN];
137
len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
140
return (dev_wlc_ioctl(dev, WLC_SET_VAR, buf, len));
143
#if WIRELESS_EXT > 17
146
struct net_device *dev,
150
char ioctlbuf[WLC_IOCTL_SMLEN];
153
buflen = bcm_mkiovar(name, buf, len, ioctlbuf, sizeof(ioctlbuf));
156
return (dev_wlc_ioctl(dev, WLC_SET_VAR, ioctlbuf, buflen));
162
struct net_device *dev,
164
char *buf, int buflen)
166
char ioctlbuf[MAX_IOCTL_LEN];
171
len = bcm_mkiovar(name, NULL, 0, ioctlbuf, sizeof(ioctlbuf));
173
error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf, MAX_IOCTL_LEN);
175
bcopy(ioctlbuf, buf, buflen);
182
struct net_device *dev,
187
char buf[WLC_IOCTL_SMLEN];
195
len = bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf));
197
error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
199
*retval = dtoh32(var.val);
204
#if WIRELESS_EXT < 13
205
struct iw_request_info
211
typedef int (*iw_handler)(struct net_device *dev, struct iw_request_info *info,
212
void *wrqu, char *extra);
215
#if WIRELESS_EXT > 12
218
struct net_device *dev,
219
struct iw_request_info *info,
220
union iwreq_data *wrqu,
224
int dc = *(int *)extra;
227
error = dev_wlc_intvar_set(dev, "leddc", dc);
233
struct net_device *dev,
234
struct iw_request_info *info,
235
union iwreq_data *wrqu,
239
int mode = *(int *)extra;
243
error = dev_wlc_intvar_set(dev, "vlan_mode", mode);
249
struct net_device *dev,
250
struct iw_request_info *info,
251
union iwreq_data *wrqu,
255
int pm = *(int *)extra;
259
error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
266
struct net_device *dev,
267
struct iw_request_info *info,
274
struct sockaddr bssid;
276
WL_TRACE(("%s: SIOCSIWCOMMIT\n", dev->name));
278
if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid))))
281
ssid.SSID_len = dtoh32(ssid.SSID_len);
286
bzero(&bssid, sizeof(struct sockaddr));
287
if ((error = dev_wlc_ioctl(dev, WLC_REASSOC, &bssid, ETHER_ADDR_LEN))) {
288
WL_ERROR(("Invalid ioctl data.\n"));
297
struct net_device *dev,
298
struct iw_request_info *info,
299
union iwreq_data *cwrq,
307
WL_TRACE(("%s: SIOCGIWNAME\n", dev->name));
310
if ((err = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &phytype, sizeof(phytype))) < 0)
312
if ((err = dev_wlc_ioctl(dev, WLC_GET_BANDLIST, band, sizeof(band))) < 0)
315
band[0] = dtoh32(band[0]);
323
case WLC_PHY_TYPE_LP:
338
snprintf(cwrq->name, IFNAMSIZ, "IEEE 802.11%s", cap);
344
struct net_device *dev,
345
struct iw_request_info *info,
346
struct iw_freq *fwrq,
353
WL_TRACE(("%s: SIOCSIWFREQ\n", dev->name));
355
if (fwrq->e == 0 && fwrq->m < MAXCHANNEL) {
365
} else if (fwrq->e < 6) {
366
while (fwrq->e++ < 6)
370
if (fwrq->m > 4000 && fwrq->m < 5000)
371
sf = WF_CHAN_FACTOR_4_G;
373
chan = wf_mhz2channel(fwrq->m, sf);
376
if ((error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan))))
384
struct net_device *dev,
385
struct iw_request_info *info,
386
struct iw_freq *fwrq,
393
WL_TRACE(("%s: SIOCGIWFREQ\n", dev->name));
395
if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
398
fwrq->m = dtoh32(ci.hw_channel);
405
struct net_device *dev,
406
struct iw_request_info *info,
411
int infra = 0, ap = 0, error = 0;
413
WL_TRACE(("%s: SIOCSIWMODE\n", dev->name));
428
infra = htod32(infra);
431
if ((error = dev_wlc_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra))) ||
432
(error = dev_wlc_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap))))
440
struct net_device *dev,
441
struct iw_request_info *info,
446
int error, infra = 0, ap = 0;
448
WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
450
if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
451
(error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
454
infra = dtoh32(infra);
456
*uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
463
struct net_device *dev,
464
struct iw_request_info *info,
465
struct iw_point *dwrq,
469
struct iw_range *range = (struct iw_range *) extra;
470
int channels[MAXCHANNEL+1];
471
wl_uint32_list_t *list = (wl_uint32_list_t *) channels;
472
wl_rateset_t rateset;
476
WL_TRACE(("%s: SIOCGIWRANGE\n", dev->name));
481
dwrq->length = sizeof(struct iw_range);
482
memset(range, 0, sizeof(range));
484
range->min_nwid = range->max_nwid = 0;
486
list->count = htod32(MAXCHANNEL);
487
if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, sizeof(channels))))
489
for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
490
range->freq[i].i = dtoh32(list->element[i]);
492
ch = dtoh32(list->element[i]);
493
if (ch <= CH_MAX_2G_CHANNEL)
494
sf = WF_CHAN_FACTOR_2_4_G;
496
sf = WF_CHAN_FACTOR_5_G;
498
range->freq[i].m = wf_channel2mhz(ch, sf);
499
range->freq[i].e = 6;
501
range->num_frequency = range->num_channels = i;
503
range->max_qual.qual = 5;
505
range->max_qual.level = 0x100 - 200;
507
range->max_qual.noise = 0x100 - 200;
509
range->sensitivity = 65535;
511
#if WIRELESS_EXT > 11
513
range->avg_qual.qual = 3;
515
range->avg_qual.level = 0x100 + WL_IW_RSSI_GOOD;
517
range->avg_qual.noise = 0x100 - 75;
520
if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
522
rateset.count = dtoh32(rateset.count);
523
range->num_bitrates = rateset.count;
524
for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
525
range->bitrate[i] = (rateset.rates[i] & 0x7f) * 500000;
527
if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i))))
530
if (i == WLC_PHY_TYPE_A)
531
range->throughput = 24000000;
533
range->throughput = 1500000;
536
range->max_rts = 2347;
537
range->min_frag = 256;
538
range->max_frag = 2346;
540
range->max_encoding_tokens = DOT11_MAX_DEFAULT_KEYS;
541
range->num_encoding_sizes = 4;
542
range->encoding_size[0] = WEP1_KEY_SIZE;
543
range->encoding_size[1] = WEP128_KEY_SIZE;
544
#if WIRELESS_EXT > 17
545
range->encoding_size[2] = TKIP_KEY_SIZE;
547
range->encoding_size[2] = 0;
549
range->encoding_size[3] = AES_KEY_SIZE;
555
range->pmp_flags = 0;
558
range->num_txpower = 2;
559
range->txpower[0] = 1;
560
range->txpower[1] = 255;
561
range->txpower_capa = IW_TXPOW_MWATT;
563
#if WIRELESS_EXT > 10
564
range->we_version_compiled = WIRELESS_EXT;
565
range->we_version_source = 19;
567
range->retry_capa = IW_RETRY_LIMIT;
568
range->retry_flags = IW_RETRY_LIMIT;
569
range->r_time_flags = 0;
571
range->min_retry = 1;
572
range->max_retry = 255;
574
range->min_r_time = 0;
575
range->max_r_time = 0;
578
#if WIRELESS_EXT > 17
579
range->enc_capa = IW_ENC_CAPA_WPA;
580
range->enc_capa |= IW_ENC_CAPA_CIPHER_TKIP;
581
range->enc_capa |= IW_ENC_CAPA_CIPHER_CCMP;
582
range->enc_capa |= IW_ENC_CAPA_WPA2;
589
rssi_to_qual(int rssi)
591
if (rssi <= WL_IW_RSSI_NO_SIGNAL)
593
else if (rssi <= WL_IW_RSSI_VERY_LOW)
595
else if (rssi <= WL_IW_RSSI_LOW)
597
else if (rssi <= WL_IW_RSSI_GOOD)
599
else if (rssi <= WL_IW_RSSI_VERY_GOOD)
607
struct net_device *dev,
608
struct iw_request_info *info,
609
struct iw_point *dwrq,
613
wl_iw_t *iw = dev->priv;
614
struct sockaddr *addr = (struct sockaddr *) extra;
617
WL_TRACE(("%s: SIOCSIWSPY\n", dev->name));
622
iw->spy_num = MIN(ARRAYSIZE(iw->spy_addr), dwrq->length);
623
for (i = 0; i < iw->spy_num; i++)
624
memcpy(&iw->spy_addr[i], addr[i].sa_data, ETHER_ADDR_LEN);
625
memset(iw->spy_qual, 0, sizeof(iw->spy_qual));
632
struct net_device *dev,
633
struct iw_request_info *info,
634
struct iw_point *dwrq,
638
wl_iw_t *iw = dev->priv;
639
struct sockaddr *addr = (struct sockaddr *) extra;
640
struct iw_quality *qual = (struct iw_quality *) &addr[iw->spy_num];
643
WL_TRACE(("%s: SIOCGIWSPY\n", dev->name));
648
dwrq->length = iw->spy_num;
649
for (i = 0; i < iw->spy_num; i++) {
650
memcpy(addr[i].sa_data, &iw->spy_addr[i], ETHER_ADDR_LEN);
651
addr[i].sa_family = AF_UNIX;
652
memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality));
653
iw->spy_qual[i].updated = 0;
661
struct net_device *dev,
662
struct iw_request_info *info,
663
struct sockaddr *awrq,
672
WL_TRACE(("%s: SIOCSIWAP\n", dev->name));
674
if (awrq->sa_family != ARPHRD_ETHER) {
675
WL_ERROR(("Invalid Header...sa_family\n"));
679
if (ETHER_ISBCAST(awrq->sa_data) || ETHER_ISNULLADDR(awrq->sa_data)) {
682
bzero(&scbval, sizeof(scb_val_t));
683
dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
687
if ((error = dev_wlc_ioctl(dev, WLC_REASSOC, awrq->sa_data, ETHER_ADDR_LEN))) {
688
WL_ERROR(("Invalid ioctl data.\n"));
697
struct net_device *dev,
698
struct iw_request_info *info,
699
struct sockaddr *awrq,
703
WL_TRACE(("%s: SIOCGIWAP\n", dev->name));
705
awrq->sa_family = ARPHRD_ETHER;
706
memset(awrq->sa_data, 0, ETHER_ADDR_LEN);
708
(void) dev_wlc_ioctl(dev, WLC_GET_BSSID, awrq->sa_data, ETHER_ADDR_LEN);
713
#if WIRELESS_EXT > 17
716
struct net_device *dev,
717
struct iw_request_info *info,
718
struct sockaddr *awrq,
722
struct iw_mlme *mlme;
726
WL_TRACE(("%s: SIOCSIWMLME\n", dev->name));
728
mlme = (struct iw_mlme *)extra;
730
WL_ERROR(("Invalid ioctl data.\n"));
734
scbval.val = mlme->reason_code;
735
bcopy(&mlme->addr.sa_data, &scbval.ea, ETHER_ADDR_LEN);
737
if (mlme->cmd == IW_MLME_DISASSOC) {
738
scbval.val = htod32(scbval.val);
739
error = dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
741
else if (mlme->cmd == IW_MLME_DEAUTH) {
742
scbval.val = htod32(scbval.val);
743
error = dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
747
WL_ERROR(("Invalid ioctl data.\n"));
757
struct net_device *dev,
758
struct iw_request_info *info,
759
struct iw_point *dwrq,
763
wl_scan_results_t *list;
764
struct sockaddr *addr = (struct sockaddr *) extra;
765
struct iw_quality qual[IW_MAX_AP];
766
wl_bss_info_t *bi = NULL;
768
uint buflen = dwrq->length;
770
WL_TRACE(("%s: SIOCGIWAPLIST\n", dev->name));
775
list = kmalloc(buflen, GFP_KERNEL);
778
memset(list, 0, buflen);
779
list->buflen = htod32(buflen);
780
if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen))) {
781
WL_ERROR(("%d: Scan results error %d\n", __LINE__, error));
785
list->buflen = dtoh32(list->buflen);
786
list->version = dtoh32(list->version);
787
list->count = dtoh32(list->count);
788
ASSERT(list->version == WL_BSS_INFO_VERSION);
790
for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
791
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
792
ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
795
if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
798
memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
799
addr[dwrq->length].sa_family = ARPHRD_ETHER;
800
qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
801
qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
802
qual[dwrq->length].noise = 0x100 + bi->phy_noise;
804
#if WIRELESS_EXT > 18
805
qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
807
qual[dwrq->length].updated = 7;
816
memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
824
#if WIRELESS_EXT > 13
827
struct net_device *dev,
828
struct iw_request_info *info,
829
union iwreq_data *wrqu,
835
WL_TRACE(("%s: SIOCSIWSCAN\n", dev->name));
837
memset(&ssid, 0, sizeof(ssid));
839
#if WIRELESS_EXT > 17
841
if (wrqu->data.length == sizeof(struct iw_scan_req)) {
842
if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
843
struct iw_scan_req *req = (struct iw_scan_req *)extra;
844
ssid.SSID_len = MIN(sizeof(ssid.SSID), req->essid_len);
845
memcpy(ssid.SSID, req->essid, ssid.SSID_len);
846
ssid.SSID_len = htod32(ssid.SSID_len);
851
(void) dev_wlc_ioctl(dev, WLC_SCAN, &ssid, sizeof(ssid));
856
#if WIRELESS_EXT > 17
858
ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
864
!bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x01"), 4)) {
870
*tlvs_len -= (int)(ie - *tlvs);
877
ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
883
!bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x04"), 4)) {
889
*tlvs_len -= (int)(ie - *tlvs);
898
struct net_device *dev,
899
struct iw_request_info *info,
900
struct iw_point *dwrq,
905
wl_scan_results_t *list;
907
wl_bss_info_t *bi = NULL;
909
char *event = extra, *end = extra + IW_SCAN_MAX_DATA, *value;
910
uint buflen = dwrq->length;
912
WL_TRACE(("%s: SIOCGIWSCAN\n", dev->name));
917
if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
919
ci.scan_channel = dtoh32(ci.scan_channel);
923
list = kmalloc(buflen, GFP_KERNEL);
926
memset(list, 0, buflen);
927
list->buflen = htod32(buflen);
928
if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen))) {
932
list->buflen = dtoh32(list->buflen);
933
list->version = dtoh32(list->version);
934
list->count = dtoh32(list->count);
936
ASSERT(list->version == WL_BSS_INFO_VERSION);
938
for (i = 0; i < list->count && i < IW_MAX_AP; i++) {
939
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
940
ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
944
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
945
memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
946
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
948
iwe.u.data.length = dtoh32(bi->SSID_len);
949
iwe.cmd = SIOCGIWESSID;
950
iwe.u.data.flags = 1;
951
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
953
if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
954
iwe.cmd = SIOCGIWMODE;
955
if (dtoh16(bi->capability) & DOT11_CAP_ESS)
956
iwe.u.mode = IW_MODE_INFRA;
958
iwe.u.mode = IW_MODE_ADHOC;
959
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
962
iwe.cmd = SIOCGIWFREQ;
963
iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
964
CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
965
WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
967
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
970
iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
971
iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
972
iwe.u.qual.noise = 0x100 + bi->phy_noise;
973
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
975
#if WIRELESS_EXT > 17
980
uint8 *ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
981
int ptr_len = bi->ie_length;
982
if ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_RSN_ID))) {
984
iwe.u.data.length = ie->len + 2;
985
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
987
ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
988
while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
990
if (ie_is_wps_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
992
iwe.u.data.length = ie->len + 2;
993
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
998
ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
999
ptr_len = bi->ie_length;
1000
while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
1001
if (ie_is_wpa_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
1002
iwe.cmd = IWEVGENIE;
1003
iwe.u.data.length = ie->len + 2;
1004
event = IWE_STREAM_ADD_POINT(info, event,
1005
end, &iwe, (char *)ie);
1013
iwe.cmd = SIOCGIWENCODE;
1014
if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
1015
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1017
iwe.u.data.flags = IW_ENCODE_DISABLED;
1018
iwe.u.data.length = 0;
1019
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
1021
if (bi->rateset.count) {
1022
value = event + IW_EV_LCP_LEN;
1023
iwe.cmd = SIOCGIWRATE;
1025
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
1026
for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
1027
iwe.u.bitrate.value = (bi->rateset.rates[j] & 0x7f) * 500000;
1028
value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
1037
dwrq->length = event - extra;
1046
struct net_device *dev,
1047
struct iw_request_info *info,
1048
struct iw_point *dwrq,
1055
WL_TRACE(("%s: SIOCSIWESSID\n", dev->name));
1057
memset(&ssid, 0, sizeof(ssid));
1058
if (dwrq->length && extra) {
1059
#if WIRELESS_EXT > 20
1060
ssid.SSID_len = MIN(sizeof(ssid.SSID), dwrq->length);
1062
ssid.SSID_len = MIN(sizeof(ssid.SSID), dwrq->length-1);
1064
memcpy(ssid.SSID, extra, ssid.SSID_len);
1065
ssid.SSID_len = htod32(ssid.SSID_len);
1067
if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(ssid))))
1075
struct net_device *dev,
1076
struct iw_request_info *info,
1077
struct iw_point *dwrq,
1084
WL_TRACE(("%s: SIOCGIWESSID\n", dev->name));
1089
if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid)))) {
1090
WL_ERROR(("Error getting the SSID\n"));
1094
ssid.SSID_len = dtoh32(ssid.SSID_len);
1096
memcpy(extra, ssid.SSID, ssid.SSID_len);
1098
dwrq->length = ssid.SSID_len;
1107
struct net_device *dev,
1108
struct iw_request_info *info,
1109
struct iw_point *dwrq,
1113
wl_iw_t *iw = dev->priv;
1115
WL_TRACE(("%s: SIOCSIWNICKN\n", dev->name));
1120
if (dwrq->length > sizeof(iw->nickname))
1123
memcpy(iw->nickname, extra, dwrq->length);
1124
iw->nickname[dwrq->length - 1] = '\0';
1131
struct net_device *dev,
1132
struct iw_request_info *info,
1133
struct iw_point *dwrq,
1137
wl_iw_t *iw = dev->priv;
1139
WL_TRACE(("%s: SIOCGIWNICKN\n", dev->name));
1144
strcpy(extra, iw->nickname);
1145
dwrq->length = strlen(extra) + 1;
1150
static int wl_iw_set_rate(
1151
struct net_device *dev,
1152
struct iw_request_info *info,
1153
struct iw_param *vwrq,
1157
wl_rateset_t rateset;
1158
int error, rate, i, error_bg, error_a;
1160
WL_TRACE(("%s: SIOCSIWRATE\n", dev->name));
1162
if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
1165
rateset.count = dtoh32(rateset.count);
1167
if (vwrq->value < 0) {
1169
rate = rateset.rates[rateset.count - 1] & 0x7f;
1170
} else if (vwrq->value < rateset.count) {
1172
rate = rateset.rates[vwrq->value] & 0x7f;
1175
rate = vwrq->value / 500000;
1180
error_bg = dev_wlc_intvar_set(dev, "bg_rate", rate);
1181
error_a = dev_wlc_intvar_set(dev, "a_rate", rate);
1183
if (error_bg && error_a)
1184
return (error_bg | error_a);
1187
error_bg = dev_wlc_intvar_set(dev, "bg_rate", 0);
1189
error_a = dev_wlc_intvar_set(dev, "a_rate", 0);
1191
if (error_bg && error_a)
1192
return (error_bg | error_a);
1194
for (i = 0; i < rateset.count; i++)
1195
if ((rateset.rates[i] & 0x7f) > rate)
1197
rateset.count = htod32(i);
1199
if ((error = dev_wlc_ioctl(dev, WLC_SET_RATESET, &rateset, sizeof(rateset))))
1206
static int wl_iw_get_rate(
1207
struct net_device *dev,
1208
struct iw_request_info *info,
1209
struct iw_param *vwrq,
1215
WL_TRACE(("%s: SIOCGIWRATE\n", dev->name));
1217
if ((error = dev_wlc_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate))))
1219
rate = dtoh32(rate);
1220
vwrq->value = (rate & 0x7f) * 500000;
1227
struct net_device *dev,
1228
struct iw_request_info *info,
1229
struct iw_param *vwrq,
1235
WL_TRACE(("%s: SIOCSIWRTS\n", dev->name));
1238
rts = DOT11_DEFAULT_RTS_LEN;
1239
else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_RTS_LEN)
1244
if ((error = dev_wlc_intvar_set(dev, "rtsthresh", rts)))
1252
struct net_device *dev,
1253
struct iw_request_info *info,
1254
struct iw_param *vwrq,
1260
WL_TRACE(("%s: SIOCGIWRTS\n", dev->name));
1262
if ((error = dev_wlc_intvar_get(dev, "rtsthresh", &rts)))
1266
vwrq->disabled = (rts >= DOT11_DEFAULT_RTS_LEN);
1274
struct net_device *dev,
1275
struct iw_request_info *info,
1276
struct iw_param *vwrq,
1282
WL_TRACE(("%s: SIOCSIWFRAG\n", dev->name));
1285
frag = DOT11_DEFAULT_FRAG_LEN;
1286
else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_FRAG_LEN)
1291
if ((error = dev_wlc_intvar_set(dev, "fragthresh", frag)))
1299
struct net_device *dev,
1300
struct iw_request_info *info,
1301
struct iw_param *vwrq,
1305
int error, fragthreshold;
1307
WL_TRACE(("%s: SIOCGIWFRAG\n", dev->name));
1309
if ((error = dev_wlc_intvar_get(dev, "fragthresh", &fragthreshold)))
1312
vwrq->value = fragthreshold;
1313
vwrq->disabled = (fragthreshold >= DOT11_DEFAULT_FRAG_LEN);
1321
struct net_device *dev,
1322
struct iw_request_info *info,
1323
struct iw_param *vwrq,
1329
WL_TRACE(("%s: SIOCSIWTXPOW\n", dev->name));
1331
disable = vwrq->disabled ? WL_RADIO_SW_DISABLE : 0;
1332
disable += WL_RADIO_SW_DISABLE << 16;
1334
disable = htod32(disable);
1335
if ((error = dev_wlc_ioctl(dev, WLC_SET_RADIO, &disable, sizeof(disable))))
1338
if (disable & WL_RADIO_SW_DISABLE)
1341
if (!(vwrq->flags & IW_TXPOW_MWATT))
1344
if (vwrq->value < 0)
1347
if (vwrq->value > 0xffff) txpwrmw = 0xffff;
1348
else txpwrmw = (uint16)vwrq->value;
1350
error = dev_wlc_intvar_set(dev, "qtxpower", (int)(bcm_mw_to_qdbm(txpwrmw)));
1356
struct net_device *dev,
1357
struct iw_request_info *info,
1358
struct iw_param *vwrq,
1362
int error, disable, txpwrdbm;
1365
WL_TRACE(("%s: SIOCGIWTXPOW\n", dev->name));
1367
if ((error = dev_wlc_ioctl(dev, WLC_GET_RADIO, &disable, sizeof(disable))) ||
1368
(error = dev_wlc_intvar_get(dev, "qtxpower", &txpwrdbm)))
1371
disable = dtoh32(disable);
1372
result = (uint8)(txpwrdbm & ~WL_TXPWR_OVERRIDE);
1373
vwrq->value = (int32)bcm_qdbm_to_mw(result);
1375
vwrq->disabled = (disable & (WL_RADIO_SW_DISABLE | WL_RADIO_HW_DISABLE)) ? 1 : 0;
1376
vwrq->flags = IW_TXPOW_MWATT;
1381
#if WIRELESS_EXT > 10
1384
struct net_device *dev,
1385
struct iw_request_info *info,
1386
struct iw_param *vwrq,
1390
int error, lrl, srl;
1392
WL_TRACE(("%s: SIOCSIWRETRY\n", dev->name));
1394
if (vwrq->disabled || (vwrq->flags & IW_RETRY_LIFETIME))
1397
if (vwrq->flags & IW_RETRY_LIMIT) {
1399
if ((vwrq->flags & IW_RETRY_MAX) || !(vwrq->flags & IW_RETRY_MIN)) {
1400
lrl = htod32(vwrq->value);
1401
if ((error = dev_wlc_ioctl(dev, WLC_SET_LRL, &lrl, sizeof(lrl))))
1405
if ((vwrq->flags & IW_RETRY_MIN) || !(vwrq->flags & IW_RETRY_MAX)) {
1406
srl = htod32(vwrq->value);
1407
if ((error = dev_wlc_ioctl(dev, WLC_SET_SRL, &srl, sizeof(srl))))
1417
struct net_device *dev,
1418
struct iw_request_info *info,
1419
struct iw_param *vwrq,
1423
int error, lrl, srl;
1425
WL_TRACE(("%s: SIOCGIWRETRY\n", dev->name));
1429
if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
1432
if ((error = dev_wlc_ioctl(dev, WLC_GET_LRL, &lrl, sizeof(lrl))) ||
1433
(error = dev_wlc_ioctl(dev, WLC_GET_SRL, &srl, sizeof(srl))))
1439
if (vwrq->flags & IW_RETRY_MAX) {
1440
vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1443
vwrq->flags = IW_RETRY_LIMIT;
1446
vwrq->flags |= IW_RETRY_MIN;
1455
struct net_device *dev,
1456
struct iw_request_info *info,
1457
struct iw_point *dwrq,
1462
int error, val, wsec;
1464
WL_TRACE(("%s: SIOCSIWENCODE\n", dev->name));
1466
memset(&key, 0, sizeof(key));
1468
if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
1470
for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
1471
val = htod32(key.index);
1472
if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
1479
if (key.index == DOT11_MAX_DEFAULT_KEYS)
1482
key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1483
if (key.index >= DOT11_MAX_DEFAULT_KEYS)
1487
wsec = (dwrq->flags & IW_ENCODE_DISABLED) ? 0 : WEP_ENABLED;
1489
if ((error = dev_wlc_intvar_set(dev, "wsec", wsec)))
1492
if (!extra || !dwrq->length || (dwrq->flags & IW_ENCODE_NOKEY)) {
1494
val = htod32(key.index);
1495
if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &val, sizeof(val))))
1498
key.len = dwrq->length;
1500
if (dwrq->length > sizeof(key.data))
1503
memcpy(key.data, extra, dwrq->length);
1505
key.flags = WL_PRIMARY_KEY;
1508
key.algo = CRYPTO_ALGO_WEP1;
1510
case WEP128_KEY_SIZE:
1511
key.algo = CRYPTO_ALGO_WEP128;
1513
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
1515
key.algo = CRYPTO_ALGO_TKIP;
1519
key.algo = CRYPTO_ALGO_AES_CCM;
1525
swap_key_from_BE(&key);
1526
if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key))))
1530
val = (dwrq->flags & IW_ENCODE_RESTRICTED) ? 1 : 0;
1532
if ((error = dev_wlc_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val))))
1540
struct net_device *dev,
1541
struct iw_request_info *info,
1542
struct iw_point *dwrq,
1547
int error, val, wsec, auth;
1549
WL_TRACE(("%s: SIOCGIWENCODE\n", dev->name));
1551
bzero(&key, sizeof(wl_wsec_key_t));
1553
if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
1555
for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
1557
if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
1564
key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1566
if (key.index >= DOT11_MAX_DEFAULT_KEYS)
1569
if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY, &key, sizeof(key))) ||
1570
(error = dev_wlc_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec))) ||
1571
(error = dev_wlc_ioctl(dev, WLC_GET_AUTH, &auth, sizeof(auth))))
1574
swap_key_to_BE(&key);
1576
wsec = dtoh32(wsec);
1577
auth = dtoh32(auth);
1579
dwrq->length = MIN(IW_ENCODING_TOKEN_MAX, key.len);
1581
dwrq->flags = key.index + 1;
1582
if (!(wsec & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))) {
1584
dwrq->flags |= IW_ENCODE_DISABLED;
1588
dwrq->flags |= IW_ENCODE_RESTRICTED;
1591
if (dwrq->length && extra)
1592
memcpy(extra, key.data, dwrq->length);
1599
struct net_device *dev,
1600
struct iw_request_info *info,
1601
struct iw_param *vwrq,
1607
WL_TRACE(("%s: SIOCSIWPOWER\n", dev->name));
1609
pm = vwrq->disabled ? PM_OFF : PM_MAX;
1612
if ((error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm))))
1620
struct net_device *dev,
1621
struct iw_request_info *info,
1622
struct iw_param *vwrq,
1628
WL_TRACE(("%s: SIOCGIWPOWER\n", dev->name));
1630
if ((error = dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))))
1634
vwrq->disabled = pm ? 0 : 1;
1635
vwrq->flags = IW_POWER_ALL_R;
1640
#if WIRELESS_EXT > 17
1643
struct net_device *dev,
1644
struct iw_request_info *info,
1645
struct iw_point *iwp,
1649
WL_TRACE(("%s: SIOCSIWGENIE\n", dev->name));
1650
dev_wlc_bufvar_set(dev, "wpaie", extra, iwp->length);
1656
struct net_device *dev,
1657
struct iw_request_info *info,
1658
struct iw_point *iwp,
1662
WL_TRACE(("%s: SIOCGIWGENIE\n", dev->name));
1664
dev_wlc_bufvar_get(dev, "wpaie", extra, iwp->length);
1669
wl_iw_set_encodeext(
1670
struct net_device *dev,
1671
struct iw_request_info *info,
1672
struct iw_point *dwrq,
1678
struct iw_encode_ext *iwe;
1680
WL_TRACE(("%s: SIOCSIWENCODEEXT\n", dev->name));
1682
memset(&key, 0, sizeof(key));
1683
iwe = (struct iw_encode_ext *)extra;
1685
if (dwrq->flags & IW_ENCODE_DISABLED) {
1690
if (dwrq->flags & IW_ENCODE_INDEX)
1691
key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1693
key.len = iwe->key_len;
1695
if (!ETHER_ISMULTI(iwe->addr.sa_data))
1696
bcopy((void *)&iwe->addr.sa_data, (char *)&key.ea, ETHER_ADDR_LEN);
1699
if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
1700
WL_WSEC(("Changing the the primary Key to %d\n", key.index));
1702
key.index = htod32(key.index);
1703
error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY,
1704
&key.index, sizeof(key.index));
1710
swap_key_from_BE(&key);
1711
dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
1715
if (iwe->key_len > sizeof(key.data))
1718
WL_WSEC(("Setting the key index %d\n", key.index));
1719
if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
1720
WL_WSEC(("key is a Primary Key\n"));
1721
key.flags = WL_PRIMARY_KEY;
1724
bcopy((void *)iwe->key, key.data, iwe->key_len);
1726
if (iwe->alg == IW_ENCODE_ALG_TKIP) {
1728
bcopy(&key.data[24], keybuf, sizeof(keybuf));
1729
bcopy(&key.data[16], &key.data[24], sizeof(keybuf));
1730
bcopy(keybuf, &key.data[16], sizeof(keybuf));
1733
if (iwe->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
1735
ivptr = (uchar *)iwe->rx_seq;
1736
key.rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) |
1737
(ivptr[3] << 8) | ivptr[2];
1738
key.rxiv.lo = (ivptr[1] << 8) | ivptr[0];
1739
key.iv_initialized = TRUE;
1743
case IW_ENCODE_ALG_NONE:
1744
key.algo = CRYPTO_ALGO_OFF;
1746
case IW_ENCODE_ALG_WEP:
1747
if (iwe->key_len == WEP1_KEY_SIZE)
1748
key.algo = CRYPTO_ALGO_WEP1;
1750
key.algo = CRYPTO_ALGO_WEP128;
1752
case IW_ENCODE_ALG_TKIP:
1753
key.algo = CRYPTO_ALGO_TKIP;
1755
case IW_ENCODE_ALG_CCMP:
1756
key.algo = CRYPTO_ALGO_AES_CCM;
1761
swap_key_from_BE(&key);
1762
error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
1770
wl_iw_get_encodeext(
1771
struct net_device *dev,
1772
struct iw_request_info *info,
1773
struct iw_param *vwrq,
1777
WL_TRACE(("%s: SIOCGIWENCODEEXT\n", dev->name));
1783
struct net_device *dev,
1784
struct iw_request_info *info,
1785
struct iw_param *vwrq,
1793
wl_iw_t *iw = dev->priv;
1795
WL_TRACE(("%s: SIOCSIWAUTH\n", dev->name));
1797
paramid = vwrq->flags & IW_AUTH_INDEX;
1798
paramval = vwrq->value;
1801
case IW_AUTH_WPA_VERSION:
1803
if (paramval & IW_AUTH_WPA_VERSION_DISABLED)
1804
val = WPA_AUTH_DISABLED;
1805
else if (paramval & (IW_AUTH_WPA_VERSION_WPA))
1806
val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED;
1807
else if (paramval & IW_AUTH_WPA_VERSION_WPA2)
1808
val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
1809
WL_ERROR(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
1810
if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
1813
case IW_AUTH_CIPHER_PAIRWISE:
1814
case IW_AUTH_CIPHER_GROUP:
1815
if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
1818
if (paramval & (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
1820
if (paramval & IW_AUTH_CIPHER_TKIP)
1821
val |= TKIP_ENABLED;
1822
if (paramval & IW_AUTH_CIPHER_CCMP)
1825
if (paramid == IW_AUTH_CIPHER_PAIRWISE)
1830
if ((error = dev_wlc_intvar_set(dev, "wsec", val)))
1835
case IW_AUTH_KEY_MGMT:
1836
if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
1839
if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
1840
if (paramval & IW_AUTH_KEY_MGMT_PSK)
1843
val = WPA_AUTH_UNSPECIFIED;
1845
else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) {
1846
if (paramval & IW_AUTH_KEY_MGMT_PSK)
1847
val = WPA2_AUTH_PSK;
1849
val = WPA2_AUTH_UNSPECIFIED;
1851
WL_ERROR(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
1852
if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
1855
case IW_AUTH_TKIP_COUNTERMEASURES:
1856
dev_wlc_bufvar_set(dev, "tkip_countermeasures", (char *)¶mval, 1);
1859
case IW_AUTH_80211_AUTH_ALG:
1861
WL_ERROR(("Setting the D11auth %d\n", paramval));
1862
if (paramval & IW_AUTH_ALG_OPEN_SYSTEM)
1864
else if (paramval & IW_AUTH_ALG_SHARED_KEY)
1868
if (!error && (error = dev_wlc_intvar_set(dev, "auth", val)))
1872
case IW_AUTH_WPA_ENABLED:
1873
if (paramval == 0) {
1874
if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
1876
if (val & (TKIP_ENABLED | AES_ENABLED)) {
1877
val &= ~(TKIP_ENABLED | AES_ENABLED);
1878
dev_wlc_intvar_set(dev, "wsec", val);
1881
WL_ERROR(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
1882
dev_wlc_intvar_set(dev, "wpa_auth", val);
1888
case IW_AUTH_DROP_UNENCRYPTED:
1889
dev_wlc_bufvar_set(dev, "wsec_restrict", (char *)¶mval, 1);
1892
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1893
dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
1896
#if WIRELESS_EXT > 17
1897
case IW_AUTH_ROAMING_CONTROL:
1898
WL_ERROR(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
1901
case IW_AUTH_PRIVACY_INVOKED:
1902
WL_ERROR(("%s: IW_AUTH_PRIVACY_INVOKED\n", __FUNCTION__));
1910
#define VAL_PSK(_val) (((_val) & WPA_AUTH_PSK) || ((_val) & WPA2_AUTH_PSK))
1914
struct net_device *dev,
1915
struct iw_request_info *info,
1916
struct iw_param *vwrq,
1924
wl_iw_t *iw = dev->priv;
1926
WL_TRACE(("%s: SIOCGIWAUTH\n", dev->name));
1928
paramid = vwrq->flags & IW_AUTH_INDEX;
1931
case IW_AUTH_WPA_VERSION:
1933
if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
1935
if (val & (WPA_AUTH_NONE | WPA_AUTH_DISABLED))
1936
paramval = IW_AUTH_WPA_VERSION_DISABLED;
1937
else if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED))
1938
paramval = IW_AUTH_WPA_VERSION_WPA;
1939
else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED))
1940
paramval = IW_AUTH_WPA_VERSION_WPA2;
1942
case IW_AUTH_CIPHER_PAIRWISE:
1943
case IW_AUTH_CIPHER_GROUP:
1944
if (paramid == IW_AUTH_CIPHER_PAIRWISE)
1951
if (val & WEP_ENABLED)
1952
paramval |= (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104);
1953
if (val & TKIP_ENABLED)
1954
paramval |= (IW_AUTH_CIPHER_TKIP);
1955
if (val & AES_ENABLED)
1956
paramval |= (IW_AUTH_CIPHER_CCMP);
1959
paramval = IW_AUTH_CIPHER_NONE;
1961
case IW_AUTH_KEY_MGMT:
1963
if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
1966
paramval = IW_AUTH_KEY_MGMT_PSK;
1968
paramval = IW_AUTH_KEY_MGMT_802_1X;
1971
case IW_AUTH_TKIP_COUNTERMEASURES:
1972
dev_wlc_bufvar_get(dev, "tkip_countermeasures", (char *)¶mval, 1);
1975
case IW_AUTH_DROP_UNENCRYPTED:
1976
dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)¶mval, 1);
1979
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1980
dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
1983
case IW_AUTH_80211_AUTH_ALG:
1985
if ((error = dev_wlc_intvar_get(dev, "auth", &val)))
1988
paramval = IW_AUTH_ALG_OPEN_SYSTEM;
1990
paramval = IW_AUTH_ALG_SHARED_KEY;
1992
case IW_AUTH_WPA_ENABLED:
1993
if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
2000
#if WIRELESS_EXT > 17
2001
case IW_AUTH_ROAMING_CONTROL:
2002
WL_ERROR(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
2005
case IW_AUTH_PRIVACY_INVOKED:
2006
WL_ERROR(("%s: IW_AUTH_PRIVACY_INVOKED\n", __FUNCTION__));
2010
vwrq->value = paramval;
2015
static const iw_handler wl_iw_handler[] =
2017
(iw_handler) wl_iw_config_commit,
2018
(iw_handler) wl_iw_get_name,
2021
(iw_handler) wl_iw_set_freq,
2022
(iw_handler) wl_iw_get_freq,
2023
(iw_handler) wl_iw_set_mode,
2024
(iw_handler) wl_iw_get_mode,
2028
(iw_handler) wl_iw_get_range,
2033
(iw_handler) wl_iw_set_spy,
2034
(iw_handler) wl_iw_get_spy,
2037
(iw_handler) wl_iw_set_wap,
2038
(iw_handler) wl_iw_get_wap,
2039
#if WIRELESS_EXT > 17
2040
(iw_handler) wl_iw_mlme,
2044
(iw_handler) wl_iw_get_aplist,
2045
#if WIRELESS_EXT > 13
2046
(iw_handler) wl_iw_set_scan,
2047
(iw_handler) wl_iw_get_scan,
2052
(iw_handler) wl_iw_set_essid,
2053
(iw_handler) wl_iw_get_essid,
2054
(iw_handler) wl_iw_set_nick,
2055
(iw_handler) wl_iw_get_nick,
2058
(iw_handler) wl_iw_set_rate,
2059
(iw_handler) wl_iw_get_rate,
2060
(iw_handler) wl_iw_set_rts,
2061
(iw_handler) wl_iw_get_rts,
2062
(iw_handler) wl_iw_set_frag,
2063
(iw_handler) wl_iw_get_frag,
2064
(iw_handler) wl_iw_set_txpow,
2065
(iw_handler) wl_iw_get_txpow,
2066
#if WIRELESS_EXT > 10
2067
(iw_handler) wl_iw_set_retry,
2068
(iw_handler) wl_iw_get_retry,
2070
(iw_handler) wl_iw_set_encode,
2071
(iw_handler) wl_iw_get_encode,
2072
(iw_handler) wl_iw_set_power,
2073
(iw_handler) wl_iw_get_power,
2074
#if WIRELESS_EXT > 17
2077
(iw_handler) wl_iw_set_wpaie,
2078
(iw_handler) wl_iw_get_wpaie,
2079
(iw_handler) wl_iw_set_wpaauth,
2080
(iw_handler) wl_iw_get_wpaauth,
2081
(iw_handler) wl_iw_set_encodeext,
2082
(iw_handler) wl_iw_get_encodeext,
2087
#if WIRELESS_EXT > 12
2089
WL_IW_SET_LEDDC = SIOCIWFIRSTPRIV,
2094
static iw_handler wl_iw_priv_handler[] = {
2100
static struct iw_priv_args wl_iw_priv_args[] = {
2103
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2109
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2115
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2121
const struct iw_handler_def wl_iw_handler_def =
2123
.num_standard = ARRAYSIZE(wl_iw_handler),
2124
.num_private = ARRAY_SIZE(wl_iw_priv_handler),
2125
.num_private_args = ARRAY_SIZE(wl_iw_priv_args),
2126
.standard = (iw_handler *) wl_iw_handler,
2127
.private = wl_iw_priv_handler,
2128
.private_args = wl_iw_priv_args,
2129
#if WIRELESS_EXT >= 19
2130
get_wireless_stats: wl_get_wireless_stats,
2137
struct net_device *dev,
2142
struct iwreq *wrq = (struct iwreq *) rq;
2143
struct iw_request_info info;
2146
int token_size = 1, max_tokens = 0, ret = 0;
2148
if (cmd < SIOCIWFIRST ||
2149
IW_IOCTL_IDX(cmd) >= ARRAYSIZE(wl_iw_handler) ||
2150
!(handler = wl_iw_handler[IW_IOCTL_IDX(cmd)]))
2159
max_tokens = IW_ESSID_MAX_SIZE + 1;
2164
#if WIRELESS_EXT > 17
2165
case SIOCSIWENCODEEXT:
2166
case SIOCGIWENCODEEXT:
2168
max_tokens = IW_ENCODING_TOKEN_MAX;
2172
max_tokens = sizeof(struct iw_range);
2176
token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
2177
max_tokens = IW_MAX_AP;
2180
#if WIRELESS_EXT > 13
2182
max_tokens = IW_SCAN_MAX_DATA;
2187
token_size = sizeof(struct sockaddr);
2188
max_tokens = IW_MAX_SPY;
2192
token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
2193
max_tokens = IW_MAX_SPY;
2198
if (max_tokens && wrq->u.data.pointer) {
2199
if (wrq->u.data.length > max_tokens)
2202
if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL)))
2205
if (copy_from_user(extra, wrq->u.data.pointer, wrq->u.data.length * token_size)) {
2214
ret = handler(dev, &info, &wrq->u, extra);
2217
if (copy_to_user(wrq->u.data.pointer, extra, wrq->u.data.length * token_size)) {
2229
wl_iw_conn_status_str(uint32 event_type, uint32 status, uint32 reason,
2230
char* stringBuf, uint buflen)
2232
typedef struct conn_fail_event_map_t {
2236
const char* outName;
2237
const char* outCause;
2238
} conn_fail_event_map_t;
2240
# define WL_IW_DONT_CARE 9999
2241
const conn_fail_event_map_t event_map [] = {
2243
{WLC_E_SET_SSID, WLC_E_STATUS_SUCCESS, WL_IW_DONT_CARE,
2245
{WLC_E_SET_SSID, WLC_E_STATUS_NO_NETWORKS, WL_IW_DONT_CARE,
2246
"Conn", "NoNetworks"},
2247
{WLC_E_SET_SSID, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
2248
"Conn", "ConfigMismatch"},
2249
{WLC_E_PRUNE, WL_IW_DONT_CARE, WLC_E_PRUNE_ENCR_MISMATCH,
2250
"Conn", "EncrypMismatch"},
2251
{WLC_E_PRUNE, WL_IW_DONT_CARE, WLC_E_RSN_MISMATCH,
2252
"Conn", "RsnMismatch"},
2253
{WLC_E_AUTH, WLC_E_STATUS_TIMEOUT, WL_IW_DONT_CARE,
2254
"Conn", "AuthTimeout"},
2255
{WLC_E_AUTH, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
2256
"Conn", "AuthFail"},
2257
{WLC_E_AUTH, WLC_E_STATUS_NO_ACK, WL_IW_DONT_CARE,
2258
"Conn", "AuthNoAck"},
2259
{WLC_E_REASSOC, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
2260
"Conn", "ReassocFail"},
2261
{WLC_E_REASSOC, WLC_E_STATUS_TIMEOUT, WL_IW_DONT_CARE,
2262
"Conn", "ReassocTimeout"},
2263
{WLC_E_REASSOC, WLC_E_STATUS_ABORT, WL_IW_DONT_CARE,
2264
"Conn", "ReassocAbort"},
2265
{WLC_E_DEAUTH_IND, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
2267
{WLC_E_DISASSOC_IND, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
2268
"Conn", "DisassocInd"},
2269
{WLC_E_DISASSOC, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
2273
const char* name = "";
2274
const char* cause = NULL;
2277
for (i = 0; i < sizeof(event_map)/sizeof(event_map[0]); i++) {
2278
const conn_fail_event_map_t* row = &event_map[i];
2279
if (row->inEvent == event_type &&
2280
(row->inStatus == status || row->inStatus == WL_IW_DONT_CARE) &&
2281
(row->inReason == reason || row->inReason == WL_IW_DONT_CARE)) {
2282
name = row->outName;
2283
cause = row->outCause;
2289
memset(stringBuf, 0, buflen);
2290
snprintf(stringBuf, buflen, "%s %s %02d %02d",
2291
name, cause, status, reason);
2292
WL_INFORM(("Connection status: %s\n", stringBuf));
2299
#if (WIRELESS_EXT > 14)
2302
wl_iw_check_conn_fail(wl_event_msg_t *e, char* stringBuf, uint buflen)
2304
uint32 event = e->event_type;
2305
uint32 status = e->status;
2306
uint32 reason = e->reason;
2308
if (wl_iw_conn_status_str(event, status, reason, stringBuf, buflen)) {
2317
#ifndef IW_CUSTOM_MAX
2318
#define IW_CUSTOM_MAX 256
2322
wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
2324
#if WIRELESS_EXT > 13
2325
union iwreq_data wrqu;
2326
char extra[IW_CUSTOM_MAX + 1];
2328
uint32 event_type = e->event_type;
2329
uint16 flags = e->flags;
2331
memset(&wrqu, 0, sizeof(wrqu));
2332
memset(extra, 0, sizeof(extra));
2334
memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
2335
wrqu.addr.sa_family = ARPHRD_ETHER;
2337
switch (event_type) {
2341
#if WIRELESS_EXT > 14
2343
case WLC_E_ASSOC_IND:
2344
case WLC_E_REASSOC_IND:
2345
cmd = IWEVREGISTERED;
2347
case WLC_E_DEAUTH_IND:
2348
case WLC_E_DISASSOC_IND:
2350
wrqu.data.length = strlen(extra);
2351
bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
2352
bzero(&extra, ETHER_ADDR_LEN);
2355
case WLC_E_NDIS_LINK:
2357
wrqu.data.length = strlen(extra);
2358
if (!(flags & WLC_EVENT_MSG_LINK)) {
2359
bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
2360
bzero(&extra, ETHER_ADDR_LEN);
2364
#if WIRELESS_EXT > 17
2365
case WLC_E_MIC_ERROR: {
2366
struct iw_michaelmicfailure *micerrevt = (struct iw_michaelmicfailure *)&extra;
2367
cmd = IWEVMICHAELMICFAILURE;
2368
wrqu.data.length = sizeof(struct iw_michaelmicfailure);
2369
if (flags & WLC_EVENT_MSG_GROUP)
2370
micerrevt->flags |= IW_MICFAILURE_GROUP;
2372
micerrevt->flags |= IW_MICFAILURE_PAIRWISE;
2373
memcpy(micerrevt->src_addr.sa_data, &e->addr, ETHER_ADDR_LEN);
2374
micerrevt->src_addr.sa_family = ARPHRD_ETHER;
2378
case WLC_E_PMKID_CACHE: {
2381
struct iw_pmkid_cand *iwpmkidcand = (struct iw_pmkid_cand *)&extra;
2382
pmkid_cand_list_t *pmkcandlist;
2383
pmkid_cand_t *pmkidcand;
2386
cmd = IWEVPMKIDCAND;
2388
count = ntoh32(pmkcandlist->npmkid_cand);
2389
wrqu.data.length = sizeof(struct iw_pmkid_cand);
2390
pmkidcand = pmkcandlist->pmkid_cand;
2392
bzero(iwpmkidcand, sizeof(struct iw_pmkid_cand));
2393
if (pmkidcand->preauth)
2394
iwpmkidcand->flags |= IW_PMKID_CAND_PREAUTH;
2395
bcopy(&pmkidcand->BSSID, &iwpmkidcand->bssid.sa_data,
2397
wireless_send_event(dev, cmd, &wrqu, extra);
2410
wireless_send_event(dev, cmd, &wrqu, extra);
2412
#if WIRELESS_EXT > 14
2414
memset(extra, 0, sizeof(extra));
2415
if (wl_iw_check_conn_fail(e, extra, sizeof(extra))) {
2417
wrqu.data.length = strlen(extra);
2418
wireless_send_event(dev, cmd, &wrqu, extra);
2425
int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
2434
if ((res = dev_wlc_ioctl(dev, WLC_GET_PHY_NOISE, &phy_noise, sizeof(phy_noise))))
2437
phy_noise = dtoh32(phy_noise);
2438
WL_TRACE(("wl_iw_get_wireless_stats phy noise=%d\n *****", phy_noise));
2441
if ((res = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t))))
2444
rssi = dtoh32(scb_val.val);
2445
WL_TRACE(("wl_iw_get_wireless_stats rssi=%d ****** \n", rssi));
2446
if (rssi <= WL_IW_RSSI_NO_SIGNAL)
2447
wstats->qual.qual = 0;
2448
else if (rssi <= WL_IW_RSSI_VERY_LOW)
2449
wstats->qual.qual = 1;
2450
else if (rssi <= WL_IW_RSSI_LOW)
2451
wstats->qual.qual = 2;
2452
else if (rssi <= WL_IW_RSSI_GOOD)
2453
wstats->qual.qual = 3;
2454
else if (rssi <= WL_IW_RSSI_VERY_GOOD)
2455
wstats->qual.qual = 4;
2457
wstats->qual.qual = 5;
2459
wstats->qual.level = 0x100 + rssi;
2460
wstats->qual.noise = 0x100 + phy_noise;
2461
#if WIRELESS_EXT > 18
2462
wstats->qual.updated |= (IW_QUAL_ALL_UPDATED | IW_QUAL_DBM);
2464
wstats->qual.updated |= 7;
2467
#if WIRELESS_EXT > 11
2468
WL_TRACE(("wl_iw_get_wireless_stats counters=%d\n *****", (int)sizeof(wl_cnt_t)));
2470
memset(&cnt, 0, sizeof(wl_cnt_t));
2471
res = dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, sizeof(wl_cnt_t));
2474
WL_ERROR(("wl_iw_get_wireless_stats counters failed error=%d ****** \n", res));
2478
cnt.version = dtoh16(cnt.version);
2479
if (cnt.version != WL_CNT_T_VERSION) {
2480
WL_TRACE(("\tIncorrect version of counters struct: expected %d; got %d\n",
2481
WL_CNT_T_VERSION, cnt.version));
2485
wstats->discard.nwid = 0;
2486
wstats->discard.code = dtoh32(cnt.rxundec);
2487
wstats->discard.fragment = dtoh32(cnt.rxfragerr);
2488
wstats->discard.retries = dtoh32(cnt.txfail);
2489
wstats->discard.misc = dtoh32(cnt.rxrunt) + dtoh32(cnt.rxgiant);
2490
wstats->miss.beacon = 0;
2492
WL_TRACE(("wl_iw_get_wireless_stats counters txframe=%d txbyte=%d\n",
2493
dtoh32(cnt.txframe), dtoh32(cnt.txbyte)));
2494
WL_TRACE(("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n", dtoh32(cnt.rxfrmtoolong)));
2495
WL_TRACE(("wl_iw_get_wireless_stats counters rxbadplcp=%d\n", dtoh32(cnt.rxbadplcp)));
2496
WL_TRACE(("wl_iw_get_wireless_stats counters rxundec=%d\n", dtoh32(cnt.rxundec)));
2497
WL_TRACE(("wl_iw_get_wireless_stats counters rxfragerr=%d\n", dtoh32(cnt.rxfragerr)));
2498
WL_TRACE(("wl_iw_get_wireless_stats counters txfail=%d\n", dtoh32(cnt.txfail)));
2499
WL_TRACE(("wl_iw_get_wireless_stats counters rxrunt=%d\n", dtoh32(cnt.rxrunt)));
2500
WL_TRACE(("wl_iw_get_wireless_stats counters rxgiant=%d\n", dtoh32(cnt.rxgiant)));