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