]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/staging/vt6656/iwctl.c
staging: vt6656: iwctl: space after if/for/while/switch
[mirror_ubuntu-zesty-kernel.git] / drivers / staging / vt6656 / iwctl.c
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * File: iwctl.c
20 *
21 * Purpose: wireless ext & ioctl functions
22 *
23 * Author: Lyndon Chen
24 *
25 * Date: July 5, 2006
26 *
27 * Functions:
28 *
29 * Revision History:
30 *
31 */
32
33 #include "device.h"
34 #include "ioctl.h"
35 #include "iocmd.h"
36 #include "mac.h"
37 #include "card.h"
38 #include "hostap.h"
39 #include "power.h"
40 #include "rf.h"
41
42 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
43 #include "iowpa.h"
44 #include "wpactl.h"
45 #endif
46
47 #include <net/iw_handler.h>
48
49 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
50 #define SUPPORTED_WIRELESS_EXT 18
51 #else
52 #define SUPPORTED_WIRELESS_EXT 17
53 #endif
54
55 static const long frequency_list[] = {
56 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
57 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
58 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
59 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
60 5700, 5745, 5765, 5785, 5805, 5825
61 };
62
63 static int msglevel = MSG_LEVEL_INFO;
64
65 struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
66 {
67 PSDevice pDevice = netdev_priv(dev);
68 long ldBm;
69
70 pDevice->wstats.status = pDevice->eOPMode;
71 if (pDevice->scStatistic.LinkQuality > 100)
72 pDevice->scStatistic.LinkQuality = 100;
73 pDevice->wstats.qual.qual =(BYTE)pDevice->scStatistic.LinkQuality;
74 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
75 pDevice->wstats.qual.level = ldBm;
76 pDevice->wstats.qual.noise = 0;
77 pDevice->wstats.qual.updated = 1;
78 pDevice->wstats.discard.nwid = 0;
79 pDevice->wstats.discard.code = 0;
80 pDevice->wstats.discard.fragment = 0;
81 pDevice->wstats.discard.retries = pDevice->scStatistic.dwTsrErr;
82 pDevice->wstats.discard.misc = 0;
83 pDevice->wstats.miss.beacon = 0;
84 return &pDevice->wstats;
85 }
86
87 /*
88 * Wireless Handler : get protocol name
89 */
90 int iwctl_giwname(struct net_device *dev, struct iw_request_info *info,
91 char *wrq, char *extra)
92 {
93 strcpy(wrq, "802.11-a/b/g");
94 return 0;
95 }
96
97 /*
98 * Wireless Handler : set scan
99 */
100 int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,
101 struct iw_point *wrq, char *extra)
102 {
103 PSDevice pDevice = netdev_priv(dev);
104 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
105 struct iw_scan_req *req = (struct iw_scan_req *)extra;
106 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
107 PWLAN_IE_SSID pItemSSID=NULL;
108
109 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
110 return -EINVAL;
111
112 PRINT_K(" SIOCSIWSCAN \n");
113
114 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
115 // In scanning..
116 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
117 return -EAGAIN;
118 }
119
120 if (pDevice->byReAssocCount > 0) { //reject scan when re-associating!
121 //send scan event to wpa_Supplicant
122 union iwreq_data wrqu;
123 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
124 memset(&wrqu, 0, sizeof(wrqu));
125 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
126 return 0;
127 }
128
129 spin_lock_irq(&pDevice->lock);
130
131 BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
132
133 //mike add: active scan OR passive scan OR desire_ssid scan
134 if (wrq->length == sizeof(struct iw_scan_req)) {
135 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
136 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
137 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
138 pItemSSID->byElementID = WLAN_EID_SSID;
139 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
140 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
141 if (req->essid_len>0)
142 pItemSSID->len = req->essid_len - 1;
143 }
144 else
145 pItemSSID->len = req->essid_len;
146 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
147 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
148 ((PWLAN_IE_SSID)abyScanSSID)->len);
149 bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
150 spin_unlock_irq(&pDevice->lock);
151
152 return 0;
153 }
154 else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
155 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
156 }
157 }
158 else { //active scan
159 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
160 }
161
162 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
163 bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
164 spin_unlock_irq(&pDevice->lock);
165
166 return 0;
167 }
168
169 /*
170 * Wireless Handler : get scan results
171 */
172 int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
173 struct iw_point *wrq, char *extra)
174 {
175 int ii;
176 int jj;
177 int kk;
178 PSDevice pDevice = netdev_priv(dev);
179 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
180 PKnownBSS pBSS;
181 PWLAN_IE_SSID pItemSSID;
182 PWLAN_IE_SUPP_RATES pSuppRates;
183 PWLAN_IE_SUPP_RATES pExtSuppRates;
184 char *current_ev = extra;
185 char *end_buf = extra + IW_SCAN_MAX_DATA;
186 char *current_val = NULL;
187 struct iw_event iwe;
188 long ldBm;
189 char buf[MAX_WPA_IE_LEN * 2 + 30];
190
191 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n");
192
193 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
194 // In scanning..
195 return -EAGAIN;
196 }
197 pBSS = &(pMgmt->sBSSList[0]);
198 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
199 if (current_ev >= end_buf)
200 break;
201 pBSS = &(pMgmt->sBSSList[jj]);
202 if (pBSS->bActive) {
203 //ADD mac address
204 memset(&iwe, 0, sizeof(iwe));
205 iwe.cmd = SIOCGIWAP;
206 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
207 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
208 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
209 //ADD ssid
210 memset(&iwe, 0, sizeof(iwe));
211 iwe.cmd = SIOCGIWESSID;
212 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
213 iwe.u.data.length = pItemSSID->len;
214 iwe.u.data.flags = 1;
215 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
216 //ADD mode
217 memset(&iwe, 0, sizeof(iwe));
218 iwe.cmd = SIOCGIWMODE;
219 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
220 iwe.u.mode = IW_MODE_INFRA;
221 }
222 else {
223 iwe.u.mode = IW_MODE_ADHOC;
224 }
225 iwe.len = IW_EV_UINT_LEN;
226 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
227 //ADD frequency
228 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
229 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
230 memset(&iwe, 0, sizeof(iwe));
231 iwe.cmd = SIOCGIWFREQ;
232 iwe.u.freq.m = pBSS->uChannel;
233 iwe.u.freq.e = 0;
234 iwe.u.freq.i = 0;
235 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
236 {
237 int f = (int)pBSS->uChannel - 1;
238 if (f < 0)f = 0;
239 iwe.u.freq.m = frequency_list[f] * 100000;
240 iwe.u.freq.e = 1;
241 }
242 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
243 //ADD quality
244 memset(&iwe, 0, sizeof(iwe));
245 iwe.cmd = IWEVQUAL;
246 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
247 iwe.u.qual.level = ldBm;
248 iwe.u.qual.noise = 0;
249
250 if (-ldBm<50){
251 iwe.u.qual.qual = 100;
252 }else if (-ldBm > 90) {
253 iwe.u.qual.qual = 0;
254 }else {
255 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
256 }
257 iwe.u.qual.updated=7;
258
259 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
260 //ADD encryption
261 memset(&iwe, 0, sizeof(iwe));
262 iwe.cmd = SIOCGIWENCODE;
263 iwe.u.data.length = 0;
264 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
265 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
266 }else {
267 iwe.u.data.flags = IW_ENCODE_DISABLED;
268 }
269 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
270
271 memset(&iwe, 0, sizeof(iwe));
272 iwe.cmd = SIOCGIWRATE;
273 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
274 current_val = current_ev + IW_EV_LCP_LEN;
275
276 for (kk = 0 ; kk < 12 ; kk++) {
277 if (pSuppRates->abyRates[kk] == 0)
278 break;
279 // Bit rate given in 500 kb/s units (+ 0x80)
280 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
281 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
282 }
283 for (kk = 0 ; kk < 8 ; kk++) {
284 if (pExtSuppRates->abyRates[kk] == 0)
285 break;
286 // Bit rate given in 500 kb/s units (+ 0x80)
287 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
288 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
289 }
290
291 if ((current_val - current_ev) > IW_EV_LCP_LEN)
292 current_ev = current_val;
293
294 memset(&iwe, 0, sizeof(iwe));
295 iwe.cmd = IWEVCUSTOM;
296 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
297 iwe.u.data.length = strlen(buf);
298 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
299
300 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
301 memset(&iwe, 0, sizeof(iwe));
302 iwe.cmd = IWEVGENIE;
303 iwe.u.data.length = pBSS->wWPALen;
304 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
305 }
306
307 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
308 memset(&iwe, 0, sizeof(iwe));
309 iwe.cmd = IWEVGENIE;
310 iwe.u.data.length = pBSS->wRSNLen;
311 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
312 }
313
314 }
315 }// for
316 wrq->length = current_ev - extra;
317 return 0;
318 }
319
320 /*
321 * Wireless Handler : set frequence or channel
322 */
323 int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
324 struct iw_freq *wrq, char *extra)
325 {
326 PSDevice pDevice = netdev_priv(dev);
327 int rc = 0;
328
329 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
330
331 // If setting by frequency, convert to a channel
332 if ((wrq->e == 1) &&
333 (wrq->m >= (int)2.412e8) &&
334 (wrq->m <= (int)2.487e8)) {
335 int f = wrq->m / 100000;
336 int c = 0;
337 while ((c < 14) && (f != frequency_list[c]))
338 c++;
339 wrq->e = 0;
340 wrq->m = c + 1;
341 }
342 // Setting by channel number
343 if ((wrq->m > 14) || (wrq->e > 0))
344 rc = -EOPNOTSUPP;
345 else {
346 int channel = wrq->m;
347 if ((channel < 1) || (channel > 14)) {
348 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
349 rc = -EINVAL;
350 } else {
351 // Yes ! We can set it !!!
352 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
353 pDevice->uChannel = channel;
354 }
355 }
356
357 return rc;
358 }
359
360 /*
361 * Wireless Handler : get frequence or channel
362 */
363 int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
364 struct iw_freq *wrq, char *extra)
365 {
366 PSDevice pDevice = netdev_priv(dev);
367 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
368
369 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
370
371 #ifdef WEXT_USECHANNELS
372 wrq->m = (int)pMgmt->uCurrChannel;
373 wrq->e = 0;
374 #else
375 {
376 int f = (int)pMgmt->uCurrChannel - 1;
377 if (f < 0)
378 f = 0;
379 wrq->m = frequency_list[f] * 100000;
380 wrq->e = 1;
381 }
382 #endif
383 return 0;
384 }
385
386 /*
387 * Wireless Handler : set operation mode
388 */
389 int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
390 __u32 *wmode, char *extra)
391 {
392 PSDevice pDevice = netdev_priv(dev);
393 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
394 int rc = 0;
395
396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
397
398 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
399 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
400 return rc;
401 }
402
403 switch (*wmode) {
404
405 case IW_MODE_ADHOC:
406 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
407 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
408 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
409 pDevice->bCommit = TRUE;
410 }
411 }
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
413 break;
414 case IW_MODE_AUTO:
415 case IW_MODE_INFRA:
416 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
417 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
418 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
419 pDevice->bCommit = TRUE;
420 }
421 }
422 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
423 break;
424 case IW_MODE_MASTER:
425
426 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
427 rc = -EOPNOTSUPP;
428 break;
429
430 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
431 pMgmt->eConfigMode = WMAC_CONFIG_AP;
432 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
433 pDevice->bCommit = TRUE;
434 }
435 }
436 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
437 break;
438
439 case IW_MODE_REPEAT:
440 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
441 rc = -EOPNOTSUPP;
442 break;
443 default:
444 rc = -EINVAL;
445 }
446
447 return rc;
448 }
449
450 /*
451 * Wireless Handler : get operation mode
452 */
453 void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info,
454 __u32 *wmode, char *extra)
455 {
456 PSDevice pDevice = netdev_priv(dev);
457 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
458
459
460 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
461 // If not managed, assume it's ad-hoc
462 switch (pMgmt->eConfigMode) {
463 case WMAC_CONFIG_ESS_STA:
464 *wmode = IW_MODE_INFRA;
465 break;
466 case WMAC_CONFIG_IBSS_STA:
467 *wmode = IW_MODE_ADHOC;
468 break;
469 case WMAC_CONFIG_AUTO:
470 *wmode = IW_MODE_INFRA;
471 break;
472 case WMAC_CONFIG_AP:
473 *wmode = IW_MODE_MASTER;
474 break;
475 default:
476 *wmode = IW_MODE_ADHOC;
477 }
478 }
479
480 /*
481 * Wireless Handler : get capability range
482 */
483 void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
484 struct iw_point *wrq, char *extra)
485 {
486 struct iw_range *range = (struct iw_range *)extra;
487 int i;
488 int k;
489 BYTE abySupportedRates[13] = {
490 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48,
491 0x60, 0x6C, 0x90
492 };
493
494 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE\n");
495 if (wrq->pointer) {
496 wrq->length = sizeof(struct iw_range);
497 memset(range, 0, sizeof(struct iw_range));
498 range->min_nwid = 0x0000;
499 range->max_nwid = 0x0000;
500 range->num_channels = 14;
501 // Should be based on cap_rid.country to give only
502 // what the current card support
503 k = 0;
504 for (i = 0; i < 14; i++) {
505 range->freq[k].i = i + 1; // List index
506 range->freq[k].m = frequency_list[i] * 100000;
507 range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
508 }
509 range->num_frequency = k;
510 // Hum... Should put the right values there
511 range->max_qual.qual = 100;
512 range->max_qual.level = 0;
513 range->max_qual.noise = 0;
514 range->sensitivity = 255;
515
516 for (i = 0 ; i < 13 ; i++) {
517 range->bitrate[i] = abySupportedRates[i] * 500000;
518 if (range->bitrate[i] == 0)
519 break;
520 }
521 range->num_bitrates = i;
522
523 // Set an indication of the max TCP throughput
524 // in bit/s that we can expect using this interface.
525 // May be use for QoS stuff... Jean II
526 if (i > 2)
527 range->throughput = 5 * 1000 * 1000;
528 else
529 range->throughput = 1.5 * 1000 * 1000;
530
531 range->min_rts = 0;
532 range->max_rts = 2312;
533 range->min_frag = 256;
534 range->max_frag = 2312;
535
536 // the encoding capabilities
537 range->num_encoding_sizes = 3;
538 // 64(40) bits WEP
539 range->encoding_size[0] = 5;
540 // 128(104) bits WEP
541 range->encoding_size[1] = 13;
542 // 256 bits for WPA-PSK
543 range->encoding_size[2] = 32;
544 // 4 keys are allowed
545 range->max_encoding_tokens = 4;
546
547 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
548 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
549
550 range->min_pmp = 0;
551 range->max_pmp = 1000000;// 1 secs
552 range->min_pmt = 0;
553 range->max_pmt = 1000000;// 1 secs
554 range->pmp_flags = IW_POWER_PERIOD;
555 range->pmt_flags = IW_POWER_TIMEOUT;
556 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
557
558 // Transmit Power - values are in mW
559 range->txpower[0] = 100;
560 range->num_txpower = 1;
561 range->txpower_capa = IW_TXPOW_MWATT;
562 range->we_version_source = SUPPORTED_WIRELESS_EXT;
563 range->we_version_compiled = WIRELESS_EXT;
564 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
565 range->retry_flags = IW_RETRY_LIMIT;
566 range->r_time_flags = IW_RETRY_LIFETIME;
567 range->min_retry = 1;
568 range->max_retry = 65535;
569 range->min_r_time = 1024;
570 range->max_r_time = 65535 * 1024;
571 // Experimental measurements - boundary 11/5.5 Mb/s
572 // Note : with or without the (local->rssi), results
573 // are somewhat different. - Jean II
574 range->avg_qual.qual = 6;
575 range->avg_qual.level = 176; // -80 dBm
576 range->avg_qual.noise = 0;
577 }
578 }
579
580 /*
581 * Wireless Handler : set ap mac address
582 */
583 int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
584 struct sockaddr *wrq, char *extra)
585 {
586 PSDevice pDevice = netdev_priv(dev);
587 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
588 int rc = 0;
589 BYTE ZeroBSSID[WLAN_BSSID_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
590
591 PRINT_K(" SIOCSIWAP \n");
592
593 if (wrq->sa_family != ARPHRD_ETHER)
594 rc = -EINVAL;
595 else {
596 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
597 //mike :add
598 if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
599 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
600 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
601 return rc;
602 }
603 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
604 // then ignore,because you don't known which one to be connect with??
605 {
606 unsigned ii;
607 unsigned uSameBssidNum = 0;
608 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
609 if (pMgmt->sBSSList[ii].bActive &&
610 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
611 pMgmt->abyDesireBSSID)) {
612 uSameBssidNum++;
613 }
614 }
615 if (uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
616 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
617 return rc;
618 }
619 }
620
621 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
622 pDevice->bCommit = TRUE;
623 }
624 }
625 return rc;
626 }
627
628 /*
629 * Wireless Handler : get ap mac address
630 */
631 int iwctl_giwap(struct net_device *dev, struct iw_request_info *info,
632 struct sockaddr *wrq, char *extra)
633 {
634 PSDevice pDevice = netdev_priv(dev);
635 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
636
637 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
638
639 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
640
641 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
642 memset(wrq->sa_data, 0, 6);
643
644 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
645 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
646 }
647
648 wrq->sa_family = ARPHRD_ETHER;
649 return 0;
650 }
651
652 /*
653 * Wireless Handler : get ap list
654 */
655 int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
656 struct iw_point *wrq, char *extra)
657 {
658 int ii;
659 int jj;
660 int rc = 0;
661 struct sockaddr sock[IW_MAX_AP];
662 struct iw_quality qual[IW_MAX_AP];
663 PSDevice pDevice = netdev_priv(dev);
664 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
665
666 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
667 // Only super-user can see AP list
668
669 if (!capable(CAP_NET_ADMIN)) {
670 rc = -EPERM;
671 return rc;
672 }
673
674 if (wrq->pointer) {
675 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
676
677 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
678 pBSS = &(pMgmt->sBSSList[ii]);
679 if (!pBSS->bActive)
680 continue;
681 if ( jj >= IW_MAX_AP)
682 break;
683 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
684 sock[jj].sa_family = ARPHRD_ETHER;
685 qual[jj].level = pBSS->uRSSI;
686 qual[jj].qual = qual[jj].noise = 0;
687 qual[jj].updated = 2;
688 jj++;
689 }
690
691 wrq->flags = 1; // Should be define'd
692 wrq->length = jj;
693 memcpy(extra, sock, sizeof(struct sockaddr)*jj);
694 memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
695 }
696 return rc;
697 }
698
699 /*
700 * Wireless Handler : set essid
701 */
702 int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
703 struct iw_point *wrq, char *extra)
704 {
705 PSDevice pDevice = netdev_priv(dev);
706 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
707 PWLAN_IE_SSID pItemSSID;
708
709 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
710 return -EINVAL;
711
712 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
713
714 pDevice->fWPA_Authened = FALSE;
715 // Check if we asked for `any'
716 if (wrq->flags == 0) {
717 // Just send an empty SSID list
718 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
719 memset(pMgmt->abyDesireBSSID, 0xFF,6);
720 PRINT_K("set essid to 'any' \n");
721 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
722 //Unknown desired AP,so here need not associate??
723 return 0;
724 #endif
725 } else {
726 // Set the SSID
727 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
728 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
729 pItemSSID->byElementID = WLAN_EID_SSID;
730
731 memcpy(pItemSSID->abySSID, extra, wrq->length);
732 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
733 if (wrq->length>0)
734 pItemSSID->len = wrq->length - 1;
735 }
736 else
737 pItemSSID->len = wrq->length;
738 PRINT_K("set essid to %s \n",pItemSSID->abySSID);
739
740 //mike:need clear desiredBSSID
741 if (pItemSSID->len==0) {
742 memset(pMgmt->abyDesireBSSID, 0xFF,6);
743 return 0;
744 }
745
746 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
747 //Wext wil order another command of siwap to link with desired AP,
748 //so here need not associate??
749 if (pDevice->bWPASuppWextEnabled == TRUE) {
750 /*******search if in hidden ssid mode ****/
751 PKnownBSS pCurr = NULL;
752 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
753 unsigned ii;
754 unsigned uSameBssidNum = 0;
755
756 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
757 pCurr = BSSpSearchBSSList(pDevice, NULL,
758 abyTmpDesireSSID,
759 pDevice->eConfigPHYMode
760 );
761
762 if (pCurr == NULL){
763 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
764 vResetCommandTimer((void *)pDevice);
765 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
766 bScheduleCommand((void *)pDevice,
767 WLAN_CMD_BSSID_SCAN,
768 pMgmt->abyDesireSSID);
769 bScheduleCommand((void *)pDevice,
770 WLAN_CMD_SSID,
771 pMgmt->abyDesireSSID);
772 }
773 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
774 // by means of judging if there are two same BSSID exist in list ?
775 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
776 if (pMgmt->sBSSList[ii].bActive &&
777 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
778 pCurr->abyBSSID)) {
779 uSameBssidNum++;
780 }
781 }
782 if (uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
783 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
784 vResetCommandTimer((void *)pDevice);
785 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
786 bScheduleCommand((void *)pDevice,
787 WLAN_CMD_BSSID_SCAN,
788 pMgmt->abyDesireSSID);
789 bScheduleCommand((void *)pDevice,
790 WLAN_CMD_SSID,
791 pMgmt->abyDesireSSID);
792 }
793 }
794 return 0;
795 }
796 #endif
797
798 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
799 }
800
801 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
802 pDevice->bCommit = TRUE;
803 }
804 return 0;
805 }
806
807 /*
808 * Wireless Handler : get essid
809 */
810 void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
811 struct iw_point *wrq, char *extra)
812 {
813 PSDevice pDevice = netdev_priv(dev);
814 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
815 PWLAN_IE_SSID pItemSSID;
816
817 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
818
819 // Note : if wrq->u.data.flags != 0, we should
820 // get the relevant SSID from the SSID list...
821
822 // Get the current SSID
823 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
824 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
825 extra[pItemSSID->len] = '\0';
826
827 wrq->length = pItemSSID->len;
828 wrq->flags = 1; // active
829 }
830
831 /*
832 * Wireless Handler : set data rate
833 */
834 int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
835 struct iw_param *wrq, char *extra)
836 {
837 PSDevice pDevice = netdev_priv(dev);
838 int rc = 0;
839 u8 brate = 0;
840 int i;
841 BYTE abySupportedRates[13] = {
842 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48,
843 0x60, 0x6C, 0x90
844 };
845
846
847 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
848 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
849 rc = -EINVAL;
850 return rc;
851 }
852
853 // First : get a valid bit rate value
854
855 // Which type of value
856 if ((wrq->value < 13) &&
857 (wrq->value >= 0)) {
858 // Setting by rate index
859 // Find value in the magic rate table
860 brate = wrq->value;
861 } else {
862 // Setting by frequency value
863 u8 normvalue = (u8) (wrq->value/500000);
864
865 // Check if rate is valid
866 for (i = 0 ; i < 13 ; i++) {
867 if (normvalue == abySupportedRates[i]) {
868 brate = i;
869 break;
870 }
871 }
872 }
873 // -1 designed the max rate (mostly auto mode)
874 if (wrq->value == -1) {
875 // Get the highest available rate
876 for (i = 0 ; i < 13 ; i++) {
877 if (abySupportedRates[i] == 0)
878 break;
879 }
880 if (i != 0)
881 brate = i - 1;
882
883 }
884 // Check that it is valid
885 // brate is index of abySupportedRates[]
886 if (brate > 13 ) {
887 rc = -EINVAL;
888 return rc;
889 }
890
891 // Now, check if we want a fixed or auto value
892 if (wrq->fixed != 0) {
893 // Fixed mode
894 // One rate, fixed
895 pDevice->bFixRate = TRUE;
896 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
897 pDevice->uConnectionRate = 3;
898 }
899 else {
900 pDevice->uConnectionRate = brate;
901 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
902 }
903
904 }
905 else {
906 pDevice->bFixRate = FALSE;
907 pDevice->uConnectionRate = 13;
908 }
909
910 return rc;
911 }
912
913 /*
914 * Wireless Handler : get data rate
915 */
916 void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
917 struct iw_param *wrq, char *extra)
918 {
919 PSDevice pDevice = netdev_priv(dev);
920 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
921
922 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
923 {
924 BYTE abySupportedRates[13] = {
925 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30,
926 0x48, 0x60, 0x6C, 0x90
927 };
928 int brate = 0;
929
930 if (pDevice->uConnectionRate < 13) {
931 brate = abySupportedRates[pDevice->uConnectionRate];
932 }else {
933 if (pDevice->byBBType == BB_TYPE_11B)
934 brate = 0x16;
935 if (pDevice->byBBType == BB_TYPE_11G)
936 brate = 0x6C;
937 if (pDevice->byBBType == BB_TYPE_11A)
938 brate = 0x6C;
939 }
940
941 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
942 if (pDevice->byBBType == BB_TYPE_11B)
943 brate = 0x16;
944 if (pDevice->byBBType == BB_TYPE_11G)
945 brate = 0x6C;
946 if (pDevice->byBBType == BB_TYPE_11A)
947 brate = 0x6C;
948 }
949 if (pDevice->uConnectionRate == 13)
950 brate = abySupportedRates[pDevice->wCurrentRate];
951 wrq->value = brate * 500000;
952 // If more than one rate, set auto
953 if (pDevice->bFixRate == TRUE)
954 wrq->fixed = TRUE;
955 }
956 }
957
958 /*
959 * Wireless Handler : set rts threshold
960 */
961 int iwctl_siwrts(struct net_device *dev, struct iw_param *wrq)
962 {
963 PSDevice pDevice = netdev_priv(dev);
964
965 if ((wrq->value < 0 || wrq->value > 2312) && !wrq->disabled)
966 return -EINVAL;
967
968 else if (wrq->disabled)
969 pDevice->wRTSThreshold = 2312;
970 else
971 pDevice->wRTSThreshold = wrq->value;
972
973 return 0;
974 }
975
976 /*
977 * Wireless Handler : get rts
978 */
979 int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
980 struct iw_param *wrq, char *extra)
981 {
982 PSDevice pDevice = netdev_priv(dev);
983
984 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
985 wrq->value = pDevice->wRTSThreshold;
986 wrq->disabled = (wrq->value >= 2312);
987 wrq->fixed = 1;
988
989 return 0;
990 }
991
992 /*
993 * Wireless Handler : set fragment threshold
994 */
995 int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
996 struct iw_param *wrq, char *extra)
997 {
998 PSDevice pDevice = netdev_priv(dev);
999 int rc = 0;
1000 int fthr = wrq->value;
1001
1002 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
1003
1004 if (wrq->disabled)
1005 fthr = 2312;
1006 if ((fthr < 256) || (fthr > 2312)) {
1007 rc = -EINVAL;
1008 }else {
1009 fthr &= ~0x1; // Get an even value
1010 pDevice->wFragmentationThreshold = (u16)fthr;
1011 }
1012 return rc;
1013 }
1014
1015 /*
1016 * Wireless Handler : get fragment threshold
1017 */
1018 int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
1019 struct iw_param *wrq, char *extra)
1020 {
1021 PSDevice pDevice = netdev_priv(dev);
1022
1023 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1024 wrq->value = pDevice->wFragmentationThreshold;
1025 wrq->disabled = (wrq->value >= 2312);
1026 wrq->fixed = 1;
1027
1028 return 0;
1029 }
1030
1031 /*
1032 * Wireless Handler : set retry threshold
1033 */
1034 int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
1035 struct iw_param *wrq, char *extra)
1036 {
1037 PSDevice pDevice = netdev_priv(dev);
1038 int rc = 0;
1039
1040 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1041
1042 if (wrq->disabled) {
1043 rc = -EINVAL;
1044 return rc;
1045 }
1046
1047 if (wrq->flags & IW_RETRY_LIMIT) {
1048 if (wrq->flags & IW_RETRY_MAX)
1049 pDevice->byLongRetryLimit = wrq->value;
1050 else if (wrq->flags & IW_RETRY_MIN)
1051 pDevice->byShortRetryLimit = wrq->value;
1052 else {
1053 // No modifier : set both
1054 pDevice->byShortRetryLimit = wrq->value;
1055 pDevice->byLongRetryLimit = wrq->value;
1056 }
1057 }
1058 if (wrq->flags & IW_RETRY_LIFETIME) {
1059 pDevice->wMaxTransmitMSDULifetime = wrq->value;
1060 }
1061 return rc;
1062 }
1063
1064 /*
1065 * Wireless Handler : get retry threshold
1066 */
1067 int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
1068 struct iw_param *wrq, char *extra)
1069 {
1070 PSDevice pDevice = netdev_priv(dev);
1071 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1072 wrq->disabled = 0; // Can't be disabled
1073
1074 // Note : by default, display the min retry number
1075 if ((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1076 wrq->flags = IW_RETRY_LIFETIME;
1077 wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
1078 } else if ((wrq->flags & IW_RETRY_MAX)) {
1079 wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1080 wrq->value = (int)pDevice->byLongRetryLimit;
1081 } else {
1082 wrq->flags = IW_RETRY_LIMIT;
1083 wrq->value = (int)pDevice->byShortRetryLimit;
1084 if ((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
1085 wrq->flags |= IW_RETRY_MIN;
1086 }
1087
1088 return 0;
1089 }
1090
1091 /*
1092 * Wireless Handler : set encode mode
1093 */
1094 int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
1095 struct iw_point *wrq, char *extra)
1096 {
1097 PSDevice pDevice = netdev_priv(dev);
1098 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1099 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1100 int ii;
1101 int uu;
1102 int rc = 0;
1103 int index = (wrq->flags & IW_ENCODE_INDEX);
1104
1105 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1106
1107 // Check the size of the key
1108 if (wrq->length > WLAN_WEP232_KEYLEN) {
1109 rc = -EINVAL;
1110 return rc;
1111 }
1112
1113 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1114 rc = -EINVAL;
1115 return rc;
1116 }
1117
1118 if (dwKeyIndex > 0)
1119 dwKeyIndex--;
1120
1121 // Send the key to the card
1122 if (wrq->length > 0) {
1123
1124 if (wrq->length == WLAN_WEP232_KEYLEN) {
1125 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1126 }
1127 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1128 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1129 }
1130 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1131 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1132 }
1133 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1134 memcpy(pDevice->abyKey, extra, wrq->length);
1135
1136 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1137 for (ii = 0; ii < wrq->length; ii++) {
1138 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1139 }
1140
1141 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1142 spin_lock_irq(&pDevice->lock);
1143 KeybSetDefaultKey( pDevice,
1144 &(pDevice->sKey),
1145 dwKeyIndex | (1 << 31),
1146 wrq->length,
1147 NULL,
1148 pDevice->abyKey,
1149 KEY_CTL_WEP
1150 );
1151 spin_unlock_irq(&pDevice->lock);
1152 }
1153 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1154 pDevice->uKeyLength = wrq->length;
1155 pDevice->bTransmitKey = TRUE;
1156 pDevice->bEncryptionEnable = TRUE;
1157 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1158
1159 // Do we want to just set the transmit key index ?
1160 if ( index < 4 ) {
1161 pDevice->byKeyIndex = index;
1162 } else if (!(wrq->flags & IW_ENCODE_MODE)) {
1163 rc = -EINVAL;
1164 return rc;
1165 }
1166 }
1167 // Read the flags
1168 if (wrq->flags & IW_ENCODE_DISABLED){
1169
1170 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1171 pMgmt->bShareKeyAlgorithm = FALSE;
1172 pDevice->bEncryptionEnable = FALSE;
1173 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1174 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1175 spin_lock_irq(&pDevice->lock);
1176 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
1177 MACvDisableKeyEntry(pDevice, uu);
1178 spin_unlock_irq(&pDevice->lock);
1179 }
1180 }
1181 if (wrq->flags & IW_ENCODE_RESTRICTED) {
1182 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1183 pMgmt->bShareKeyAlgorithm = TRUE;
1184 }
1185 if (wrq->flags & IW_ENCODE_OPEN) {
1186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1187 pMgmt->bShareKeyAlgorithm = FALSE;
1188 }
1189
1190 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1191 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1192 #endif
1193 return rc;
1194 }
1195
1196 int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
1197 struct iw_point *wrq, char *extra)
1198 {
1199 PSDevice pDevice = netdev_priv(dev);
1200 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1201 char abyKey[WLAN_WEP232_KEYLEN];
1202
1203 unsigned index = (unsigned)(wrq->flags & IW_ENCODE_INDEX);
1204 PSKeyItem pKey = NULL;
1205
1206 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1207
1208 if (index > WLAN_WEP_NKEYS) {
1209 return -EINVAL;
1210 }
1211 if (index<1){//get default key
1212 if (pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1213 index=pDevice->byKeyIndex;
1214 } else
1215 index=0;
1216 }else
1217 index--;
1218
1219 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1220 // Check encryption mode
1221 wrq->flags = IW_ENCODE_NOKEY;
1222 // Is WEP enabled ???
1223 if (pDevice->bEncryptionEnable)
1224 wrq->flags |= IW_ENCODE_ENABLED;
1225 else
1226 wrq->flags |= IW_ENCODE_DISABLED;
1227
1228 if (pMgmt->bShareKeyAlgorithm)
1229 wrq->flags |= IW_ENCODE_RESTRICTED;
1230 else
1231 wrq->flags |= IW_ENCODE_OPEN;
1232 wrq->length=0;
1233
1234 if ((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1235 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1236 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1237 wrq->length = pKey->uKeyLength;
1238 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1239 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1240 }
1241 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1242 wrq->length = pKey->uKeyLength;
1243 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1244 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1245 }
1246
1247 wrq->flags |= index+1;
1248 return 0;
1249 }
1250
1251 /*
1252 * Wireless Handler : set power mode
1253 */
1254 int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
1255 struct iw_param *wrq, char *extra)
1256 {
1257 PSDevice pDevice = netdev_priv(dev);
1258 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1259 int rc = 0;
1260
1261 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1262
1263 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1264 rc = -EINVAL;
1265 return rc;
1266 }
1267
1268 if (wrq->disabled) {
1269 pDevice->ePSMode = WMAC_POWER_CAM;
1270 PSvDisablePowerSaving(pDevice);
1271 return rc;
1272 }
1273 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1274 pDevice->ePSMode = WMAC_POWER_FAST;
1275 PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
1276
1277 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1278 pDevice->ePSMode = WMAC_POWER_FAST;
1279 PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
1280 }
1281 switch (wrq->flags & IW_POWER_MODE) {
1282 case IW_POWER_UNICAST_R:
1283 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1284 rc = -EINVAL;
1285 break;
1286 case IW_POWER_ALL_R:
1287 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1288 rc = -EINVAL;
1289 case IW_POWER_ON:
1290 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1291 break;
1292 default:
1293 rc = -EINVAL;
1294 }
1295
1296 return rc;
1297 }
1298
1299 /*
1300 * Wireless Handler : get power mode
1301 */
1302 int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
1303 struct iw_param *wrq, char *extra)
1304 {
1305 PSDevice pDevice = netdev_priv(dev);
1306 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1307 int mode = pDevice->ePSMode;
1308
1309 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1310
1311 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1312 return 0;
1313
1314 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1315 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1316 wrq->flags = IW_POWER_TIMEOUT;
1317 } else {
1318 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1319 wrq->flags = IW_POWER_PERIOD;
1320 }
1321 wrq->flags |= IW_POWER_ALL_R;
1322 return 0;
1323 }
1324
1325 /*
1326 * Wireless Handler : get Sensitivity
1327 */
1328 int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
1329 struct iw_param *wrq, char *extra)
1330 {
1331 PSDevice pDevice = netdev_priv(dev);
1332 long ldBm;
1333
1334 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1335 if (pDevice->bLinkPass == TRUE) {
1336 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1337 wrq->value = ldBm;
1338 }
1339 else {
1340 wrq->value = 0;
1341 }
1342 wrq->disabled = (wrq->value == 0);
1343 wrq->fixed = 1;
1344 return 0;
1345 }
1346
1347 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1348
1349 int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
1350 struct iw_param *wrq, char *extra)
1351 {
1352 PSDevice pDevice = netdev_priv(dev);
1353 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1354 int ret = 0;
1355 static int wpa_version = 0; //must be static to save the last value,einsn liu
1356 static int pairwise = 0;
1357
1358 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1359 switch (wrq->flags & IW_AUTH_INDEX) {
1360 case IW_AUTH_WPA_VERSION:
1361 wpa_version = wrq->value;
1362 if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1363 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1364 }
1365 else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1366 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1367 }
1368 else {
1369 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1370 }
1371 break;
1372 case IW_AUTH_CIPHER_PAIRWISE:
1373 pairwise = wrq->value;
1374 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
1375 if (pairwise == IW_AUTH_CIPHER_CCMP){
1376 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1377 }else if (pairwise == IW_AUTH_CIPHER_TKIP){
1378 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1379 } else if (pairwise == IW_AUTH_CIPHER_WEP40 ||
1380 pairwise == IW_AUTH_CIPHER_WEP104) {
1381 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1382 }else if (pairwise == IW_AUTH_CIPHER_NONE){
1383 //do nothing,einsn liu
1384 }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1385
1386 break;
1387 case IW_AUTH_CIPHER_GROUP:
1388 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
1389 if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1390 break;
1391 if (pairwise == IW_AUTH_CIPHER_NONE){
1392 if (wrq->value == IW_AUTH_CIPHER_CCMP){
1393 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1394 }else {
1395 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1396 }
1397 }
1398 break;
1399 case IW_AUTH_KEY_MGMT:
1400 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
1401 if (wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1402 if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
1403 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
1404 else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
1405 }else if (wpa_version == IW_AUTH_WPA_VERSION_WPA){
1406 if (wrq->value == 0){
1407 pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
1408 }else if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
1409 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
1410 else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
1411 }
1412 break;
1413 case IW_AUTH_TKIP_COUNTERMEASURES:
1414 break; /* FIXME */
1415 case IW_AUTH_DROP_UNENCRYPTED:
1416 break;
1417 case IW_AUTH_80211_AUTH_ALG:
1418 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
1419 if (wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1420 pMgmt->bShareKeyAlgorithm=FALSE;
1421 }else if (wrq->value==IW_AUTH_ALG_SHARED_KEY){
1422 pMgmt->bShareKeyAlgorithm=TRUE;
1423 }
1424 break;
1425 case IW_AUTH_WPA_ENABLED:
1426 break;
1427 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1428 break;
1429 case IW_AUTH_ROAMING_CONTROL:
1430 ret = -EOPNOTSUPP;
1431 break;
1432 case IW_AUTH_PRIVACY_INVOKED:
1433 pDevice->bEncryptionEnable = !!wrq->value;
1434 if (pDevice->bEncryptionEnable == FALSE){
1435 wpa_version = 0;
1436 pairwise = 0;
1437 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1438 pMgmt->bShareKeyAlgorithm = FALSE;
1439 pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
1440 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
1441 }
1442 break;
1443 default:
1444 ret = -EOPNOTSUPP;
1445 break;
1446 }
1447 return ret;
1448 }
1449
1450 int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info,
1451 struct iw_param *wrq, char *extra)
1452 {
1453 return -EOPNOTSUPP;
1454 }
1455
1456 int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,
1457 struct iw_point *wrq, char *extra)
1458 {
1459 PSDevice pDevice = netdev_priv(dev);
1460 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1461 int ret = 0;
1462
1463 if (wrq->length){
1464 if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
1465 ret = -EINVAL;
1466 goto out;
1467 }
1468 if (wrq->length > MAX_WPA_IE_LEN){
1469 ret = -ENOMEM;
1470 goto out;
1471 }
1472 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1473 if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
1474 ret = -EFAULT;
1475 goto out;
1476 }
1477 pMgmt->wWPAIELen = wrq->length;
1478 }else {
1479 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1480 pMgmt->wWPAIELen = 0;
1481 }
1482
1483 out://not completely ...not necessary in wpa_supplicant 0.5.8
1484 return ret;
1485 }
1486
1487 int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
1488 struct iw_point *wrq, char *extra)
1489 {
1490 PSDevice pDevice = netdev_priv(dev);
1491 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1492 int ret = 0;
1493 int space = wrq->length;
1494
1495 wrq->length = 0;
1496 if (pMgmt->wWPAIELen > 0){
1497 wrq->length = pMgmt->wWPAIELen;
1498 if (pMgmt->wWPAIELen <= space){
1499 if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
1500 ret = -EFAULT;
1501 }
1502 }else
1503 ret = -E2BIG;
1504 }
1505 return ret;
1506 }
1507
1508 int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
1509 struct iw_point *wrq, char *extra)
1510 {
1511 PSDevice pDevice = netdev_priv(dev);
1512 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1513 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
1514 struct viawget_wpa_param *param=NULL;
1515 //original member
1516 wpa_alg alg_name;
1517 u8 addr[6];
1518 int key_idx;
1519 int set_tx=0;
1520 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
1521 u8 key[64];
1522 size_t seq_len = 0;
1523 size_t key_len = 0;
1524 u8 *buf;
1525 size_t blen;
1526 u8 key_array[64];
1527 int ret = 0;
1528
1529 PRINT_K("SIOCSIWENCODEEXT...... \n");
1530
1531 blen = sizeof(*param);
1532 buf = kmalloc((int)blen, (int)GFP_KERNEL);
1533 if (buf == NULL)
1534 return -ENOMEM;
1535 memset(buf, 0, blen);
1536 param = (struct viawget_wpa_param *)buf;
1537
1538 //recover alg_name
1539 switch (ext->alg) {
1540 case IW_ENCODE_ALG_NONE:
1541 alg_name = WPA_ALG_NONE;
1542 break;
1543 case IW_ENCODE_ALG_WEP:
1544 alg_name = WPA_ALG_WEP;
1545 break;
1546 case IW_ENCODE_ALG_TKIP:
1547 alg_name = WPA_ALG_TKIP;
1548 break;
1549 case IW_ENCODE_ALG_CCMP:
1550 alg_name = WPA_ALG_CCMP;
1551 break;
1552 default:
1553 PRINT_K("Unknown alg = %d\n",ext->alg);
1554 ret= -ENOMEM;
1555 goto error;
1556 }
1557 //recover addr
1558 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
1559 //recover key_idx
1560 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
1561 //recover set_tx
1562 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
1563 set_tx = 1;
1564 //recover seq,seq_len
1565 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
1566 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
1567 memcpy(seq, ext->rx_seq, seq_len);
1568 }
1569 //recover key,key_len
1570 if (ext->key_len) {
1571 key_len=ext->key_len;
1572 memcpy(key, &ext->key[0], key_len);
1573 }
1574 memset(key_array, 0, 64);
1575 if ( key_len > 0) {
1576 memcpy(key_array, key, key_len);
1577 if (key_len == 32) {
1578 // notice ! the oder
1579 memcpy(&key_array[16], &key[24], 8);
1580 memcpy(&key_array[24], &key[16], 8);
1581 }
1582 }
1583
1584 /**************Translate iw_encode_ext to viawget_wpa_param****************/
1585 memcpy(param->addr, addr, ETH_ALEN);
1586 param->u.wpa_key.alg_name = (int)alg_name;
1587 param->u.wpa_key.set_tx = set_tx;
1588 param->u.wpa_key.key_index = key_idx;
1589 param->u.wpa_key.key_len = key_len;
1590 param->u.wpa_key.key = (u8 *)key_array;
1591 param->u.wpa_key.seq = (u8 *)seq;
1592 param->u.wpa_key.seq_len = seq_len;
1593
1594 //****set if current action is Network Manager count??
1595 //****this method is so foolish,but there is no other way???
1596 if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
1597 if (param->u.wpa_key.key_index ==0) {
1598 pDevice->bwextstep0 = TRUE;
1599 }
1600 if ((pDevice->bwextstep0 == TRUE) && (param->u.wpa_key.key_index == 1)) {
1601 pDevice->bwextstep0 = FALSE;
1602 pDevice->bwextstep1 = TRUE;
1603 }
1604 if ((pDevice->bwextstep1 == TRUE) && (param->u.wpa_key.key_index == 2)) {
1605 pDevice->bwextstep1 = FALSE;
1606 pDevice->bwextstep2 = TRUE;
1607 }
1608 if ((pDevice->bwextstep2 == TRUE)&&(param->u.wpa_key.key_index == 3)) {
1609 pDevice->bwextstep2 = FALSE;
1610 pDevice->bwextstep3 = TRUE;
1611 }
1612 }
1613 if (pDevice->bwextstep3 == TRUE) {
1614 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
1615 pDevice->bwextstep0 = FALSE;
1616 pDevice->bwextstep1 = FALSE;
1617 pDevice->bwextstep2 = FALSE;
1618 pDevice->bwextstep3 = FALSE;
1619 pDevice->bWPASuppWextEnabled = TRUE;
1620 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1621 KeyvInitTable(pDevice,&pDevice->sKey);
1622 }
1623 //******
1624 spin_lock_irq(&pDevice->lock);
1625 ret = wpa_set_keys(pDevice, param, TRUE);
1626 spin_unlock_irq(&pDevice->lock);
1627
1628 error:
1629 kfree(param);
1630 return ret;
1631 }
1632
1633 int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info,
1634 struct iw_point *wrq, char *extra)
1635 {
1636 return -EOPNOTSUPP;
1637 }
1638
1639 int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
1640 struct iw_point *wrq, char *extra)
1641 {
1642 PSDevice pDevice = netdev_priv(dev);
1643 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1644 struct iw_mlme *mlme = (struct iw_mlme *)extra;
1645 int ret = 0;
1646
1647 if (memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
1648 ret = -EINVAL;
1649 return ret;
1650 }
1651 switch (mlme->cmd){
1652 case IW_MLME_DEAUTH:
1653 case IW_MLME_DISASSOC:
1654 if (pDevice->bLinkPass == TRUE){
1655 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
1656 bScheduleCommand((void *)pDevice,
1657 WLAN_CMD_DISASSOCIATE,
1658 NULL);
1659 }
1660 break;
1661 default:
1662 ret = -EOPNOTSUPP;
1663 }
1664 return ret;
1665 }
1666
1667 #endif
1668
1669 static const iw_handler iwctl_handler[] = {
1670 (iw_handler)NULL, /* SIOCSIWCOMMIT */
1671 (iw_handler)NULL, // SIOCGIWNAME
1672 (iw_handler)NULL, // SIOCSIWNWID
1673 (iw_handler)NULL, // SIOCGIWNWID
1674 (iw_handler)NULL, // SIOCSIWFREQ
1675 (iw_handler)NULL, // SIOCGIWFREQ
1676 (iw_handler)NULL, // SIOCSIWMODE
1677 (iw_handler)NULL, // SIOCGIWMODE
1678 (iw_handler)NULL, // SIOCSIWSENS
1679 (iw_handler)NULL, // SIOCGIWSENS
1680 (iw_handler)NULL, // SIOCSIWRANGE
1681 (iw_handler)iwctl_giwrange, // SIOCGIWRANGE
1682 (iw_handler)NULL, // SIOCSIWPRIV
1683 (iw_handler)NULL, // SIOCGIWPRIV
1684 (iw_handler)NULL, // SIOCSIWSTATS
1685 (iw_handler)NULL, // SIOCGIWSTATS
1686 (iw_handler)NULL, // SIOCSIWSPY
1687 (iw_handler)NULL, // SIOCGIWSPY
1688 (iw_handler)NULL, // -- hole --
1689 (iw_handler)NULL, // -- hole --
1690 (iw_handler)NULL, // SIOCSIWAP
1691 (iw_handler)NULL, // SIOCGIWAP
1692 (iw_handler)NULL, // -- hole -- 0x16
1693 (iw_handler)NULL, // SIOCGIWAPLIST
1694 (iw_handler)iwctl_siwscan, // SIOCSIWSCAN
1695 (iw_handler)iwctl_giwscan, // SIOCGIWSCAN
1696 (iw_handler)NULL, // SIOCSIWESSID
1697 (iw_handler)NULL, // SIOCGIWESSID
1698 (iw_handler)NULL, // SIOCSIWNICKN
1699 (iw_handler)NULL, // SIOCGIWNICKN
1700 (iw_handler)NULL, // -- hole --
1701 (iw_handler)NULL, // -- hole --
1702 (iw_handler)NULL, // SIOCSIWRATE 0x20
1703 (iw_handler)NULL, // SIOCGIWRATE
1704 (iw_handler)NULL, // SIOCSIWRTS
1705 (iw_handler)NULL, // SIOCGIWRTS
1706 (iw_handler)NULL, // SIOCSIWFRAG
1707 (iw_handler)NULL, // SIOCGIWFRAG
1708 (iw_handler)NULL, // SIOCSIWTXPOW
1709 (iw_handler)NULL, // SIOCGIWTXPOW
1710 (iw_handler)NULL, // SIOCSIWRETRY
1711 (iw_handler)NULL, // SIOCGIWRETRY
1712 (iw_handler)NULL, // SIOCSIWENCODE
1713 (iw_handler)NULL, // SIOCGIWENCODE
1714 (iw_handler)NULL, // SIOCSIWPOWER
1715 (iw_handler)NULL, // SIOCGIWPOWER
1716 (iw_handler)NULL, // -- hole --
1717 (iw_handler)NULL, // -- hole --
1718 (iw_handler)NULL, // SIOCSIWGENIE
1719 (iw_handler)NULL, // SIOCGIWGENIE
1720 (iw_handler)NULL, // SIOCSIWAUTH
1721 (iw_handler)NULL, // SIOCGIWAUTH
1722 (iw_handler)NULL, // SIOCSIWENCODEEXT
1723 (iw_handler)NULL, // SIOCGIWENCODEEXT
1724 (iw_handler)NULL, // SIOCSIWPMKSA
1725 (iw_handler)NULL, // -- hole --
1726 };
1727
1728 static const iw_handler iwctl_private_handler[] = {
1729 NULL, // SIOCIWFIRSTPRIV
1730 };
1731
1732 struct iw_priv_args iwctl_private_args[] = {
1733 { IOCTL_CMD_SET,
1734 IW_PRIV_TYPE_CHAR | 1024, 0,
1735 "set"},
1736 };
1737
1738 const struct iw_handler_def iwctl_handler_def = {
1739 .get_wireless_stats = &iwctl_get_wireless_stats,
1740 .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
1741 .num_private = 0,
1742 .num_private_args = 0,
1743 .standard = (iw_handler *)iwctl_handler,
1744 .private = NULL,
1745 .private_args = NULL,
1746 };