blob: e6f8c18523394d1e895108caab3c0ff4cb519897 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
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
34#if !defined(__DEVICE_H__)
35#include "device.h"
36#endif
37#if !defined(__IOCTL_H__)
38#include "ioctl.h"
39#endif
40#if !defined(__IOCMD_H__)
41#include "iocmd.h"
42#endif
43#if !defined(__MAC_H__)
44#include "mac.h"
45#endif
46#if !defined(__CARD_H__)
47#include "card.h"
48#endif
49#if !defined(__HOSTAP_H__)
50#include "hostap.h"
51#endif
52#if !defined(__UMEM_H__)
53#include "umem.h"
54#endif
55#if !defined(__POWER_H__)
56#include "power.h"
57#endif
58#if !defined(__RF_H__)
59#include "rf.h"
60#endif
61
62#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
63#if !defined(__IOWPA_H__)
64#include "iowpa.h"
65#endif
66#if !defined(__WPACTL_H__)
67#include "wpactl.h"
68#endif
69#endif
70
71#if WIRELESS_EXT > 12
72#include <net/iw_handler.h>
73#endif
74
75
76/*--------------------- Static Definitions -------------------------*/
77
78//2008-0409-07, <Add> by Einsn Liu
79#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
80#define SUPPORTED_WIRELESS_EXT 18
81#else
82#define SUPPORTED_WIRELESS_EXT 17
83#endif
84
85#ifdef WIRELESS_EXT
86
87static const long frequency_list[] = {
88 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
89 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
90 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
91 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
92 5700, 5745, 5765, 5785, 5805, 5825
93 };
94
95#endif
96
97
98/*--------------------- Static Classes ----------------------------*/
99
100
101//static int msglevel =MSG_LEVEL_DEBUG;
102static int msglevel =MSG_LEVEL_INFO;
103
104
105/*--------------------- Static Variables --------------------------*/
106/*--------------------- Static Functions --------------------------*/
107
108/*--------------------- Export Variables --------------------------*/
109
110#ifdef WIRELESS_EXT
111
112#if WIRELESS_EXT > 12
113
114struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
115{
Forest Bond1e28efa2009-06-13 07:38:50 -0400116 PSDevice pDevice = netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400117 long ldBm;
118
119 pDevice->wstats.status = pDevice->eOPMode;
120 #ifdef Calcu_LinkQual
121 #if 0
122 if(pDevice->byBBType == BB_TYPE_11B) {
123 if(pDevice->byCurrSQ > 120)
124 pDevice->scStatistic.LinkQuality = 100;
125 else
126 pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
127 }
128 else if(pDevice->byBBType == BB_TYPE_11G) {
129 if(pDevice->byCurrSQ < 20)
130 pDevice->scStatistic.LinkQuality = 100;
131 else if(pDevice->byCurrSQ >96)
132 pDevice->scStatistic.LinkQuality = 0;
133 else
134 pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
135 }
136 if(pDevice->bLinkPass !=TRUE)
137 pDevice->scStatistic.LinkQuality = 0;
138 #endif
139 if(pDevice->scStatistic.LinkQuality > 100)
140 pDevice->scStatistic.LinkQuality = 100;
141 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
142 #else
143 pDevice->wstats.qual.qual = pDevice->byCurrSQ;
144 #endif
145 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
146 pDevice->wstats.qual.level = ldBm;
147 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
148 pDevice->wstats.qual.noise = 0;
149 pDevice->wstats.qual.updated = 1;
150 pDevice->wstats.discard.nwid = 0;
151 pDevice->wstats.discard.code = 0;
152 pDevice->wstats.discard.fragment = 0;
153 pDevice->wstats.discard.retries = pDevice->scStatistic.dwTsrErr;
154 pDevice->wstats.discard.misc = 0;
155 pDevice->wstats.miss.beacon = 0;
156
157 return &pDevice->wstats;
158}
159
160#endif
161
162
163
164/*------------------------------------------------------------------*/
165
166
167static int iwctl_commit(struct net_device *dev,
168 struct iw_request_info *info,
169 void *wrq,
170 char *extra)
171{
172//2008-0409-02, <Mark> by Einsn Liu
173/*
174#ifdef Safe_Close
Forest Bond1e28efa2009-06-13 07:38:50 -0400175 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400176 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
177 return -EINVAL;
178#endif
179*/
180 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
181
182 return 0;
183
184}
185
186/*
187 * Wireless Handler : get protocol name
188 */
189
190int iwctl_giwname(struct net_device *dev,
191 struct iw_request_info *info,
192 char *wrq,
193 char *extra)
194{
195 strcpy(wrq, "802.11-a/b/g");
196 return 0;
197}
198
199int iwctl_giwnwid(struct net_device *dev,
200 struct iw_request_info *info,
201 struct iw_param *wrq,
202 char *extra)
203{
204 //wrq->value = 0x100;
205 //wrq->disabled = 0;
206 //wrq->fixed = 1;
207 //return 0;
208 return -EOPNOTSUPP;
209}
210#if WIRELESS_EXT > 13
211
212/*
213 * Wireless Handler : set scan
214 */
215
216int iwctl_siwscan(struct net_device *dev,
217 struct iw_request_info *info,
218 struct iw_point *wrq,
219 char *extra)
220{
Forest Bond1e28efa2009-06-13 07:38:50 -0400221 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400222 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
223 struct iw_scan_req *req = (struct iw_scan_req *)extra;
224 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
225 PWLAN_IE_SSID pItemSSID=NULL;
226
227//2008-0920-01<Add>by MikeLiu
228 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
229 return -EINVAL;
230
231 PRINT_K(" SIOCSIWSCAN \n");
232
233if (pMgmt->eScanState == WMAC_IS_SCANNING) {
234 // In scanning..
235 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
236 return -EAGAIN;
237 }
238
239if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
240//send scan event to wpa_Supplicant
241 union iwreq_data wrqu;
242 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
243 memset(&wrqu, 0, sizeof(wrqu));
244 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
245 return 0;
246}
247
248 spin_lock_irq(&pDevice->lock);
249
250 #ifdef update_BssList
251 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
252 #endif
253
254//mike add: active scan OR passive scan OR desire_ssid scan
255 if(wrq->length == sizeof(struct iw_scan_req)) {
256 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
257 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
258 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
259 pItemSSID->byElementID = WLAN_EID_SSID;
260 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
261 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
262 if(req->essid_len>0)
263 pItemSSID->len = req->essid_len - 1;
264 }
265 else
266 pItemSSID->len = req->essid_len;
267 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
268 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
269 ((PWLAN_IE_SSID)abyScanSSID)->len);
270 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
271 spin_unlock_irq(&pDevice->lock);
272
273 return 0;
274 }
275 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
276 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
277 }
278 }
279 else { //active scan
280 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
281 }
282
283 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
284 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
285 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
286 spin_unlock_irq(&pDevice->lock);
287
288 return 0;
289}
290
291
292/*
293 * Wireless Handler : get scan results
294 */
295
296int iwctl_giwscan(struct net_device *dev,
297 struct iw_request_info *info,
298 struct iw_point *wrq,
299 char *extra)
300{
301 int ii, jj, kk;
Forest Bond1e28efa2009-06-13 07:38:50 -0400302 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400303 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
304 PKnownBSS pBSS;
305 PWLAN_IE_SSID pItemSSID;
306 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
307 char *current_ev = extra;
308 char *end_buf = extra + IW_SCAN_MAX_DATA;
309 char *current_val = NULL;
310 struct iw_event iwe;
311 long ldBm;
312#if WIRELESS_EXT > 14
313 char buf[MAX_WPA_IE_LEN * 2 + 30];
314#endif /* WIRELESS_EXT > 14 */
315
316//2008-0409-02, <Mark> by Einsn Liu
317/*
318#ifdef Safe_Close
319 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
320 return -EINVAL;
321#endif
322*/
323 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
324
325 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
326 // In scanning..
327 return -EAGAIN;
328 }
329 pBSS = &(pMgmt->sBSSList[0]);
330 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
331 if (current_ev >= end_buf)
332 break;
333 pBSS = &(pMgmt->sBSSList[jj]);
334 if (pBSS->bActive) {
335 //ADD mac address
336 memset(&iwe, 0, sizeof(iwe));
337 iwe.cmd = SIOCGIWAP;
338 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
339 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
340 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
341 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
342 #else
343 current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
344 #endif
345 //ADD ssid
346 memset(&iwe, 0, sizeof(iwe));
347 iwe.cmd = SIOCGIWESSID;
348 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
349 iwe.u.data.length = pItemSSID->len;
350 iwe.u.data.flags = 1;
351 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
352 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
353 #else
354 current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pItemSSID->abySSID);
355 #endif
356 //ADD mode
357 memset(&iwe, 0, sizeof(iwe));
358 iwe.cmd = SIOCGIWMODE;
359 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
360 iwe.u.mode = IW_MODE_INFRA;
361 }
362 else {
363 iwe.u.mode = IW_MODE_ADHOC;
364 }
365 iwe.len = IW_EV_UINT_LEN;
366 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
367 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
368 #else
369 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
370 #endif
371 //ADD frequency
372 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
373 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
374 memset(&iwe, 0, sizeof(iwe));
375 iwe.cmd = SIOCGIWFREQ;
376 iwe.u.freq.m = pBSS->uChannel;
377 iwe.u.freq.e = 0;
378 iwe.u.freq.i = 0;
379 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
380 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
381 #else
382 current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
383 #endif
384 //2008-0409-04, <Add> by Einsn Liu
385 {
386 int f = (int)pBSS->uChannel - 1;
387 if(f < 0)f = 0;
388 iwe.u.freq.m = frequency_list[f] * 100000;
389 iwe.u.freq.e = 1;
390 }
391 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
392 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
393 #else
394 current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
395 #endif
396 //ADD quality
397 memset(&iwe, 0, sizeof(iwe));
398 iwe.cmd = IWEVQUAL;
399 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
400 iwe.u.qual.level = ldBm;
401 iwe.u.qual.noise = 0;
402//2008-0409-01, <Add> by Einsn Liu
403 if(-ldBm<50){
404 iwe.u.qual.qual = 100;
405 }else if(-ldBm > 90) {
406 iwe.u.qual.qual = 0;
407 }else {
408 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
409 }
410 iwe.u.qual.updated=7;
411
412//2008-0409-01, <Mark> by Einsn Liu
413/*
414//2008-0220-03, <Modify> by Einsn Liu
415 if(pDevice->bLinkPass== TRUE && IS_ETH_ADDRESS_EQUAL(pBSS->abyBSSID, pMgmt->abyCurrBSSID)){
416 #ifdef Calcu_LinkQual
417 #if 0
418 if(pDevice->byBBType == BB_TYPE_11B) {
419 if(pDevice->byCurrSQ > 120)
420 pDevice->scStatistic.LinkQuality = 100;
421 else
422 pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
423 }
424 else if(pDevice->byBBType == BB_TYPE_11G) {
425 if(pDevice->byCurrSQ < 20)
426 pDevice->scStatistic.LinkQuality = 100;
427 else if(pDevice->byCurrSQ >96)
428 pDevice->scStatistic.LinkQuality = 0;
429 else
430 pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
431 }
432 if(pDevice->bLinkPass !=TRUE)
433 pDevice->scStatistic.LinkQuality = 0;
434 #endif
435 if(pDevice->scStatistic.LinkQuality > 100)
436 pDevice->scStatistic.LinkQuality = 100;
437 iwe.u.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
438 #else
439 iwe.u.qual.qual = pDevice->byCurrSQ;
440 #endif
441 }else {
442 iwe.u.qual.qual = 0;
443 }
444*/
445 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
446 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
447 #else
448 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
449 #endif
450 //ADD encryption
451 memset(&iwe, 0, sizeof(iwe));
452 iwe.cmd = SIOCGIWENCODE;
453 iwe.u.data.length = 0;
454 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
455 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
456 }else {
457 iwe.u.data.flags = IW_ENCODE_DISABLED;
458 }
459 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
460 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
461 #else
462 current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pItemSSID->abySSID);
463 #endif
464
465 memset(&iwe, 0, sizeof(iwe));
466 iwe.cmd = SIOCGIWRATE;
467 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
468 current_val = current_ev + IW_EV_LCP_LEN;
469
470 for (kk = 0 ; kk < 12 ; kk++) {
471 if (pSuppRates->abyRates[kk] == 0)
472 break;
473 // Bit rate given in 500 kb/s units (+ 0x80)
474 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
475 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
476 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
477 #else
478 current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
479 #endif
480 }
481 for (kk = 0 ; kk < 8 ; kk++) {
482 if (pExtSuppRates->abyRates[kk] == 0)
483 break;
484 // Bit rate given in 500 kb/s units (+ 0x80)
485 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
486 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
487 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
488 #else
489 current_val = iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
490 #endif
491 }
492
493 if((current_val - current_ev) > IW_EV_LCP_LEN)
494 current_ev = current_val;
495
496#if WIRELESS_EXT > 14
497 memset(&iwe, 0, sizeof(iwe));
498 iwe.cmd = IWEVCUSTOM;
499 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
500 iwe.u.data.length = strlen(buf);
501 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
502 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
503 #else
504 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
505 #endif
506
507#if WIRELESS_EXT > 17
508 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
509 memset(&iwe, 0, sizeof(iwe));
510 iwe.cmd = IWEVGENIE;
511 iwe.u.data.length = pBSS->wWPALen;
512 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
513 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
514 #else
515 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, pBSS->byWPAIE);
516 #endif
517 }
518
519 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
520 memset(&iwe, 0, sizeof(iwe));
521 iwe.cmd = IWEVGENIE;
522 iwe.u.data.length = pBSS->wRSNLen;
523 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
524 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
525 #else
526 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, pBSS->byRSNIE);
527 #endif
528 }
529
530#else // WIRELESS_EXT > 17
531 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
532 u8 *p = buf;
533 memset(&iwe, 0, sizeof(iwe));
534 iwe.cmd = IWEVCUSTOM;
535 p += sprintf(p, "wpa_ie=");
536 for (ii = 0; ii < pBSS->wWPALen; ii++) {
537 p += sprintf(p, "%02x", pBSS->byWPAIE[ii]);
538 }
539 iwe.u.data.length = strlen(buf);
540 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
541 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
542 #else
543 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
544 #endif
545 }
546
547
548 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
549 u8 *p = buf;
550 memset(&iwe, 0, sizeof(iwe));
551 iwe.cmd = IWEVCUSTOM;
552 p += sprintf(p, "rsn_ie=");
553 for (ii = 0; ii < pBSS->wRSNLen; ii++) {
554 p += sprintf(p, "%02x", pBSS->byRSNIE[ii]);
555 }
556 iwe.u.data.length = strlen(buf);
557 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) //mike add
558 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
559 #else
560 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
561 #endif
562 }
563#endif
564#endif
565 }
566 }// for
567
568 wrq->length = current_ev - extra;
569 return 0;
570
571}
572
573#endif /* WIRELESS_EXT > 13 */
574
575
576/*
577 * Wireless Handler : set frequence or channel
578 */
579
580int iwctl_siwfreq(struct net_device *dev,
581 struct iw_request_info *info,
582 struct iw_freq *wrq,
583 char *extra)
584{
Forest Bond1e28efa2009-06-13 07:38:50 -0400585 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400586 int rc = 0;
587
588 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
589
590 // If setting by frequency, convert to a channel
591 if((wrq->e == 1) &&
592 (wrq->m >= (int) 2.412e8) &&
593 (wrq->m <= (int) 2.487e8)) {
594 int f = wrq->m / 100000;
595 int c = 0;
596 while((c < 14) && (f != frequency_list[c]))
597 c++;
598 wrq->e = 0;
599 wrq->m = c + 1;
600 }
601 // Setting by channel number
602 if((wrq->m > 14) || (wrq->e > 0))
603 rc = -EOPNOTSUPP;
604 else {
605 int channel = wrq->m;
606 if((channel < 1) || (channel > 14)) {
607 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
608 rc = -EINVAL;
609 } else {
610 // Yes ! We can set it !!!
611 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
612 pDevice->uChannel = channel;
613 }
614 }
615
616 return rc;
617}
618
619/*
620 * Wireless Handler : get frequence or channel
621 */
622
623int iwctl_giwfreq(struct net_device *dev,
624 struct iw_request_info *info,
625 struct iw_freq *wrq,
626 char *extra)
627{
Forest Bond1e28efa2009-06-13 07:38:50 -0400628 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400629 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
630
631 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
632
633#ifdef WEXT_USECHANNELS
634 wrq->m = (int)pMgmt->uCurrChannel;
635 wrq->e = 0;
636#else
637 {
638 int f = (int)pMgmt->uCurrChannel - 1;
639 if(f < 0)
640 f = 0;
641 wrq->m = frequency_list[f] * 100000;
642 wrq->e = 1;
643 }
644#endif
645
646 return 0;
647}
648
649/*
650 * Wireless Handler : set operation mode
651 */
652
653int iwctl_siwmode(struct net_device *dev,
654 struct iw_request_info *info,
655 __u32 *wmode,
656 char *extra)
657{
Forest Bond1e28efa2009-06-13 07:38:50 -0400658 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400659 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
660 int rc = 0;
661
662 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
663
664 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
665 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
666 return rc;
667 }
668
669 switch(*wmode) {
670
671 case IW_MODE_ADHOC:
672 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
673 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
674 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
675 pDevice->bCommit = TRUE;
676 }
677 }
678 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
679 break;
680 case IW_MODE_AUTO:
681 case IW_MODE_INFRA:
682 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
683 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
684 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
685 pDevice->bCommit = TRUE;
686 }
687 }
688 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
689 break;
690 case IW_MODE_MASTER:
691
692 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
693 rc = -EOPNOTSUPP;
694 break;
695
696 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
697 pMgmt->eConfigMode = WMAC_CONFIG_AP;
698 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
699 pDevice->bCommit = TRUE;
700 }
701 }
702 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
703 break;
704
705 case IW_MODE_REPEAT:
706 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
707 rc = -EOPNOTSUPP;
708 break;
709 default:
710 rc = -EINVAL;
711 }
712
713 return rc;
714}
715
716/*
717 * Wireless Handler : get operation mode
718 */
719
720int iwctl_giwmode(struct net_device *dev,
721 struct iw_request_info *info,
722 __u32 *wmode,
723 char *extra)
724{
Forest Bond1e28efa2009-06-13 07:38:50 -0400725 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400726 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
727
728
729 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
730 // If not managed, assume it's ad-hoc
731 switch (pMgmt->eConfigMode) {
732 case WMAC_CONFIG_ESS_STA:
733 *wmode = IW_MODE_INFRA;
734 break;
735 case WMAC_CONFIG_IBSS_STA:
736 *wmode = IW_MODE_ADHOC;
737 break;
738 case WMAC_CONFIG_AUTO:
739 *wmode = IW_MODE_INFRA;
740 break;
741 case WMAC_CONFIG_AP:
742 *wmode = IW_MODE_MASTER;
743 break;
744 default:
745 *wmode = IW_MODE_ADHOC;
746 }
747
748 return 0;
749}
750
751
752/*
753 * Wireless Handler : get capability range
754 */
755
756int iwctl_giwrange(struct net_device *dev,
757 struct iw_request_info *info,
758 struct iw_point *wrq,
759 char *extra)
760{
761 struct iw_range *range = (struct iw_range *) extra;
762 int i,k;
763 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
764//2008-0409-02, <Mark> by Einsn Liu
765/*
766 #ifdef Safe_Close
Forest Bond1e28efa2009-06-13 07:38:50 -0400767 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400768 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
769 return -EINVAL;
770#endif
771 */
772
773 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
774 if (wrq->pointer) {
775 wrq->length = sizeof(struct iw_range);
776 memset(range, 0, sizeof(struct iw_range));
777 range->min_nwid = 0x0000;
778 range->max_nwid = 0x0000;
779 range->num_channels = 14;
780 // Should be based on cap_rid.country to give only
781 // what the current card support
782 k = 0;
783 for(i = 0; i < 14; i++) {
784 range->freq[k].i = i + 1; // List index
785 range->freq[k].m = frequency_list[i] * 100000;
786 range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
787 }
788 range->num_frequency = k;
789 // Hum... Should put the right values there
790 #ifdef Calcu_LinkQual
791 range->max_qual.qual = 100;
792 #else
793 range->max_qual.qual = 255;
794 #endif
795 range->max_qual.level = 0;
796 range->max_qual.noise = 0;
797 range->sensitivity = 255;
798
799 for(i = 0 ; i < 13 ; i++) {
800 range->bitrate[i] = abySupportedRates[i] * 500000;
801 if(range->bitrate[i] == 0)
802 break;
803 }
804 range->num_bitrates = i;
805
806 // Set an indication of the max TCP throughput
807 // in bit/s that we can expect using this interface.
808 // May be use for QoS stuff... Jean II
809 if(i > 2)
810 range->throughput = 5 * 1000 * 1000;
811 else
812 range->throughput = 1.5 * 1000 * 1000;
813
814 range->min_rts = 0;
815 range->max_rts = 2312;
816 range->min_frag = 256;
817 range->max_frag = 2312;
818
819
820 // the encoding capabilities
821 range->num_encoding_sizes = 3;
822 // 64(40) bits WEP
823 range->encoding_size[0] = 5;
824 // 128(104) bits WEP
825 range->encoding_size[1] = 13;
826 // 256 bits for WPA-PSK
827 range->encoding_size[2] = 32;
828 // 4 keys are allowed
829 range->max_encoding_tokens = 4;
830
831#if WIRELESS_EXT > 17
832 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
833 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
834#endif
835
836#if WIRELESS_EXT > 9
837 range->min_pmp = 0;
838 range->max_pmp = 1000000;// 1 secs
839 range->min_pmt = 0;
840 range->max_pmt = 1000000;// 1 secs
841 range->pmp_flags = IW_POWER_PERIOD;
842 range->pmt_flags = IW_POWER_TIMEOUT;
843 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
844
845 // Transmit Power - values are in mW
846
847 range->txpower[0] = 100;
848 range->num_txpower = 1;
849 range->txpower_capa = IW_TXPOW_MWATT;
850#endif // WIRELESS_EXT > 9
851#if WIRELESS_EXT > 10
852 range->we_version_source = SUPPORTED_WIRELESS_EXT;
853 range->we_version_compiled = WIRELESS_EXT;
854 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
855 range->retry_flags = IW_RETRY_LIMIT;
856 range->r_time_flags = IW_RETRY_LIFETIME;
857 range->min_retry = 1;
858 range->max_retry = 65535;
859 range->min_r_time = 1024;
860 range->max_r_time = 65535 * 1024;
861#endif // WIRELESS_EXT > 10
862#if WIRELESS_EXT > 11
863 // Experimental measurements - boundary 11/5.5 Mb/s
864 // Note : with or without the (local->rssi), results
865 // are somewhat different. - Jean II
866 range->avg_qual.qual = 6;
867 range->avg_qual.level = 176; // -80 dBm
868 range->avg_qual.noise = 0;
869#endif // WIRELESS_EXT > 11
870 }
871
872
873 return 0;
874}
875
876
877/*
878 * Wireless Handler : set ap mac address
879 */
880
881int iwctl_siwap(struct net_device *dev,
882 struct iw_request_info *info,
883 struct sockaddr *wrq,
884 char *extra)
885{
Forest Bond1e28efa2009-06-13 07:38:50 -0400886 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400887 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
888 int rc = 0;
889 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
890
891 PRINT_K(" SIOCSIWAP \n");
892
893 if (wrq->sa_family != ARPHRD_ETHER)
894 rc = -EINVAL;
895 else {
896 memset(pMgmt->abyDesireBSSID, 0xFF, 6);
897 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
898
899 //mike :add
900 if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) ||
901 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
902 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
903 return rc;
904 }
905 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
906 // then ignore,because you don't known which one to be connect with??
907 {
908 UINT ii , uSameBssidNum=0;
909 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
910 if (pMgmt->sBSSList[ii].bActive &&
911 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) {
912 uSameBssidNum++;
913 }
914 }
915 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
916 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
917 return rc;
918 }
919 }
920
921 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
922 pDevice->bCommit = TRUE;
923 }
924 }
925 return rc;
926}
927
928/*
929 * Wireless Handler : get ap mac address
930 */
931
932int iwctl_giwap(struct net_device *dev,
933 struct iw_request_info *info,
934 struct sockaddr *wrq,
935 char *extra)
936{
Forest Bond1e28efa2009-06-13 07:38:50 -0400937 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400938 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
939
940
941 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
942
943 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
944
945//20080123-02,<Modify> by Einsn Liu
946 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
947 // if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode == WMAC_MODE_ESS_STA))
948 memset(wrq->sa_data, 0, 6);
949
950 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
951 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
952 }
953
954 wrq->sa_family = ARPHRD_ETHER;
955
956 return 0;
957
958}
959
960
961/*
962 * Wireless Handler : get ap list
963 */
964
965int iwctl_giwaplist(struct net_device *dev,
966 struct iw_request_info *info,
967 struct iw_point *wrq,
968 char *extra)
969{
970 int ii,jj, rc = 0;
971 struct sockaddr sock[IW_MAX_AP];
972 struct iw_quality qual[IW_MAX_AP];
Forest Bond1e28efa2009-06-13 07:38:50 -0400973 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400974 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
975
976
977 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
978 // Only super-user can see AP list
979
980 if (!capable(CAP_NET_ADMIN)) {
981 rc = -EPERM;
982 return rc;
983 }
984
985 if (wrq->pointer) {
986
987 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
988
989 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
990 pBSS = &(pMgmt->sBSSList[ii]);
991 if (!pBSS->bActive)
992 continue;
993 if ( jj >= IW_MAX_AP)
994 break;
995 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
996 sock[jj].sa_family = ARPHRD_ETHER;
997 qual[jj].level = pBSS->uRSSI;
998 qual[jj].qual = qual[jj].noise = 0;
999 qual[jj].updated = 2;
1000 jj++;
1001 }
1002
1003 wrq->flags = 1; // Should be define'd
1004 wrq->length = jj;
1005 memcpy(extra, sock, sizeof(struct sockaddr)*jj);
1006 memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
1007 }
1008
1009 return rc;
1010}
1011
1012
1013/*
1014 * Wireless Handler : set essid
1015 */
1016
1017int iwctl_siwessid(struct net_device *dev,
1018 struct iw_request_info *info,
1019 struct iw_point *wrq,
1020 char *extra)
1021{
Forest Bond1e28efa2009-06-13 07:38:50 -04001022 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001023 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1024 PWLAN_IE_SSID pItemSSID;
1025
1026//2008-0920-01<Add>by MikeLiu
1027 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
1028 return -EINVAL;
1029
1030 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
1031
1032 pDevice->fWPA_Authened = FALSE;
1033 // Check if we asked for `any'
1034 if(wrq->flags == 0) {
1035 // Just send an empty SSID list
1036 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1037 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1038 PRINT_K("set essid to 'any' \n");
1039 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1040 //Unknown desired AP,so here need not associate??
1041 return 0;
1042 #endif
1043 } else {
1044 // Set the SSID
1045 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1046 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
1047 pItemSSID->byElementID = WLAN_EID_SSID;
1048
1049 memcpy(pItemSSID->abySSID, extra, wrq->length);
1050 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
1051 if(wrq->length>0)
1052 pItemSSID->len = wrq->length - 1;
1053 }
1054 else
1055 pItemSSID->len = wrq->length;
1056 PRINT_K("set essid to %s \n",pItemSSID->abySSID);
1057
1058 //mike:need clear desiredBSSID
1059 if(pItemSSID->len==0) {
1060 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1061 return 0;
1062 }
1063
1064#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1065 //Wext wil order another command of siwap to link with desired AP,
1066 //so here need not associate??
1067 if(pDevice->bWPASuppWextEnabled == TRUE) {
1068 /*******search if in hidden ssid mode ****/
1069 {
1070 PKnownBSS pCurr = NULL;
1071 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
1072 UINT ii , uSameBssidNum=0;
1073
1074 memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID));
1075 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
1076 pCurr = BSSpSearchBSSList(pDevice,
1077 NULL,
1078 abyTmpDesireSSID,
1079 pDevice->eConfigPHYMode
1080 );
1081
1082 if (pCurr == NULL){
1083 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
1084 vResetCommandTimer((HANDLE) pDevice);
1085 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
1086 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
1087 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
1088 }
1089 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
1090 // by means of judging if there are two same BSSID exist in list ?
1091 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
1092 if (pMgmt->sBSSList[ii].bActive &&
1093 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
1094 uSameBssidNum++;
1095 }
1096 }
1097 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
1098 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
1099 vResetCommandTimer((HANDLE) pDevice);
1100 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
1101 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
1102 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
1103 }
1104 }
1105 }
1106 return 0;
1107 }
1108 #endif
1109
1110 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
1111 }
1112
1113 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1114 pDevice->bCommit = TRUE;
1115 }
1116
1117
1118 return 0;
1119}
1120
1121
1122/*
1123 * Wireless Handler : get essid
1124 */
1125
1126int iwctl_giwessid(struct net_device *dev,
1127 struct iw_request_info *info,
1128 struct iw_point *wrq,
1129 char *extra)
1130{
1131
Forest Bond1e28efa2009-06-13 07:38:50 -04001132 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001133 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1134 PWLAN_IE_SSID pItemSSID;
1135
1136 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
1137
1138 // Note : if wrq->u.data.flags != 0, we should
1139 // get the relevant SSID from the SSID list...
1140
1141 // Get the current SSID
1142 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
1143 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
1144 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
1145 extra[pItemSSID->len] = '\0';
1146 //2008-0409-03, <Add> by Einsn Liu
1147 #if WIRELESS_EXT < 21
1148 wrq->length = pItemSSID->len + 1;
1149 #else
1150 wrq->length = pItemSSID->len;
1151 #endif
1152 wrq->flags = 1; // active
1153
1154
1155 return 0;
1156}
1157
1158/*
1159 * Wireless Handler : set data rate
1160 */
1161
1162int iwctl_siwrate(struct net_device *dev,
1163 struct iw_request_info *info,
1164 struct iw_param *wrq,
1165 char *extra)
1166{
Forest Bond1e28efa2009-06-13 07:38:50 -04001167 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001168 int rc = 0;
1169 u8 brate = 0;
1170 int i;
1171 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1172
1173
1174 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
1175 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1176 rc = -EINVAL;
1177 return rc;
1178 }
1179
1180 // First : get a valid bit rate value
1181
1182 // Which type of value
1183 if((wrq->value < 13) &&
1184 (wrq->value >= 0)) {
1185 // Setting by rate index
1186 // Find value in the magic rate table
1187 brate = wrq->value;
1188 } else {
1189 // Setting by frequency value
1190 u8 normvalue = (u8) (wrq->value/500000);
1191
1192 // Check if rate is valid
1193 for(i = 0 ; i < 13 ; i++) {
1194 if(normvalue == abySupportedRates[i]) {
1195 brate = i;
1196 break;
1197 }
1198 }
1199 }
1200 // -1 designed the max rate (mostly auto mode)
1201 if(wrq->value == -1) {
1202 // Get the highest available rate
1203 for(i = 0 ; i < 13 ; i++) {
1204 if(abySupportedRates[i] == 0)
1205 break;
1206 }
1207 if(i != 0)
1208 brate = i - 1;
1209
1210 }
1211 // Check that it is valid
1212 // brate is index of abySupportedRates[]
1213 if(brate > 13 ) {
1214 rc = -EINVAL;
1215 return rc;
1216 }
1217
1218 // Now, check if we want a fixed or auto value
1219 if(wrq->fixed != 0) {
1220 // Fixed mode
1221 // One rate, fixed
1222 pDevice->bFixRate = TRUE;
1223 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
1224 pDevice->uConnectionRate = 3;
1225 }
1226 else {
1227 pDevice->uConnectionRate = brate;
1228 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
1229 }
1230
1231 }
1232 else {
1233 pDevice->bFixRate = FALSE;
1234 pDevice->uConnectionRate = 13;
1235 }
1236
1237 return rc;
1238}
1239
1240/*
1241 * Wireless Handler : get data rate
1242 */
1243
1244int iwctl_giwrate(struct net_device *dev,
1245 struct iw_request_info *info,
1246 struct iw_param *wrq,
1247 char *extra)
1248{
Forest Bond1e28efa2009-06-13 07:38:50 -04001249 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001250 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1251
1252 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
1253 {
1254 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1255 int brate = 0;
1256 if (pDevice->uConnectionRate < 13) {
1257 brate = abySupportedRates[pDevice->uConnectionRate];
1258 }else {
1259 if (pDevice->byBBType == BB_TYPE_11B)
1260 brate = 0x16;
1261 if (pDevice->byBBType == BB_TYPE_11G)
1262 brate = 0x6C;
1263 if (pDevice->byBBType == BB_TYPE_11A)
1264 brate = 0x6C;
1265 }
1266
1267 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1268 if (pDevice->byBBType == BB_TYPE_11B)
1269 brate = 0x16;
1270 if (pDevice->byBBType == BB_TYPE_11G)
1271 brate = 0x6C;
1272 if (pDevice->byBBType == BB_TYPE_11A)
1273 brate = 0x6C;
1274 }
1275 if (pDevice->uConnectionRate == 13)
1276 brate = abySupportedRates[pDevice->wCurrentRate];
1277 wrq->value = brate * 500000;
1278 // If more than one rate, set auto
1279 if (pDevice->bFixRate == TRUE)
1280 wrq->fixed = TRUE;
1281 }
1282
1283
1284 return 0;
1285}
1286
1287
1288
1289/*
1290 * Wireless Handler : set rts threshold
1291 */
1292
1293int iwctl_siwrts(struct net_device *dev,
1294 struct iw_request_info *info,
1295 struct iw_param *wrq,
1296 char *extra)
1297{
Forest Bond1e28efa2009-06-13 07:38:50 -04001298 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001299 int rc = 0;
1300
1301 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
1302
1303 {
1304 int rthr = wrq->value;
1305 if(wrq->disabled)
1306 rthr = 2312;
1307 if((rthr < 0) || (rthr > 2312)) {
1308 rc = -EINVAL;
1309 }else {
1310 pDevice->wRTSThreshold = rthr;
1311 }
1312 }
1313
1314 return 0;
1315}
1316
1317/*
1318 * Wireless Handler : get rts
1319 */
1320
1321int iwctl_giwrts(struct net_device *dev,
1322 struct iw_request_info *info,
1323 struct iw_param *wrq,
1324 char *extra)
1325{
Forest Bond1e28efa2009-06-13 07:38:50 -04001326 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001327
1328 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
1329 wrq->value = pDevice->wRTSThreshold;
1330 wrq->disabled = (wrq->value >= 2312);
1331 wrq->fixed = 1;
1332
1333 return 0;
1334}
1335
1336/*
1337 * Wireless Handler : set fragment threshold
1338 */
1339
1340int iwctl_siwfrag(struct net_device *dev,
1341 struct iw_request_info *info,
1342 struct iw_param *wrq,
1343 char *extra)
1344{
Forest Bond1e28efa2009-06-13 07:38:50 -04001345 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001346 int rc = 0;
1347 int fthr = wrq->value;
1348
1349
1350 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
1351
1352
1353 if (wrq->disabled)
1354 fthr = 2312;
1355 if((fthr < 256) || (fthr > 2312)) {
1356 rc = -EINVAL;
1357 }else {
1358 fthr &= ~0x1; // Get an even value
1359 pDevice->wFragmentationThreshold = (u16)fthr;
1360 }
1361
1362 return rc;
1363}
1364
1365/*
1366 * Wireless Handler : get fragment threshold
1367 */
1368
1369int iwctl_giwfrag(struct net_device *dev,
1370 struct iw_request_info *info,
1371 struct iw_param *wrq,
1372 char *extra)
1373{
Forest Bond1e28efa2009-06-13 07:38:50 -04001374 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001375
1376 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1377 wrq->value = pDevice->wFragmentationThreshold;
1378 wrq->disabled = (wrq->value >= 2312);
1379 wrq->fixed = 1;
1380
1381 return 0;
1382}
1383
1384
1385
1386/*
1387 * Wireless Handler : set retry threshold
1388 */
1389int iwctl_siwretry(struct net_device *dev,
1390 struct iw_request_info *info,
1391 struct iw_param *wrq,
1392 char *extra)
1393{
Forest Bond1e28efa2009-06-13 07:38:50 -04001394 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001395 int rc = 0;
1396
1397
1398 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1399
1400 if (wrq->disabled) {
1401 rc = -EINVAL;
1402 return rc;
1403 }
1404
1405 if (wrq->flags & IW_RETRY_LIMIT) {
1406 if(wrq->flags & IW_RETRY_MAX)
1407 pDevice->byLongRetryLimit = wrq->value;
1408 else if (wrq->flags & IW_RETRY_MIN)
1409 pDevice->byShortRetryLimit = wrq->value;
1410 else {
1411 // No modifier : set both
1412 pDevice->byShortRetryLimit = wrq->value;
1413 pDevice->byLongRetryLimit = wrq->value;
1414 }
1415 }
1416 if (wrq->flags & IW_RETRY_LIFETIME) {
1417 pDevice->wMaxTransmitMSDULifetime = wrq->value;
1418 }
1419
1420
1421 return rc;
1422}
1423
1424/*
1425 * Wireless Handler : get retry threshold
1426 */
1427int iwctl_giwretry(struct net_device *dev,
1428 struct iw_request_info *info,
1429 struct iw_param *wrq,
1430 char *extra)
1431{
Forest Bond1e28efa2009-06-13 07:38:50 -04001432 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1434 wrq->disabled = 0; // Can't be disabled
1435
1436 // Note : by default, display the min retry number
1437 if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1438 wrq->flags = IW_RETRY_LIFETIME;
1439 wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
1440 } else if((wrq->flags & IW_RETRY_MAX)) {
1441 wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1442 wrq->value = (int)pDevice->byLongRetryLimit;
1443 } else {
1444 wrq->flags = IW_RETRY_LIMIT;
1445 wrq->value = (int)pDevice->byShortRetryLimit;
1446 if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
1447 wrq->flags |= IW_RETRY_MIN;
1448 }
1449
1450
1451 return 0;
1452}
1453
1454
1455/*
1456 * Wireless Handler : set encode mode
1457 */
1458int iwctl_siwencode(struct net_device *dev,
1459 struct iw_request_info *info,
1460 struct iw_point *wrq,
1461 char *extra)
1462{
Forest Bond1e28efa2009-06-13 07:38:50 -04001463 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001464 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1465 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1466 int ii,uu, rc = 0;
1467 int index = (wrq->flags & IW_ENCODE_INDEX);
1468
1469
1470 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1471
1472 // Check the size of the key
1473 if (wrq->length > WLAN_WEP232_KEYLEN) {
1474 rc = -EINVAL;
1475 return rc;
1476 }
1477
1478 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1479 rc = -EINVAL;
1480 return rc;
1481 }
1482
1483 if (dwKeyIndex > 0)
1484 dwKeyIndex--;
1485
1486 // Send the key to the card
1487 if (wrq->length > 0) {
1488
1489 if (wrq->length == WLAN_WEP232_KEYLEN) {
1490 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1491 }
1492 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1493 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1494 }
1495 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1496 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1497 }
1498 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1499 memcpy(pDevice->abyKey, extra, wrq->length);
1500
1501 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1502 for (ii = 0; ii < wrq->length; ii++) {
1503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1504 }
1505
1506 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1507 spin_lock_irq(&pDevice->lock);
1508 KeybSetDefaultKey( pDevice,
1509 &(pDevice->sKey),
1510 dwKeyIndex | (1 << 31),
1511 wrq->length,
1512 NULL,
1513 pDevice->abyKey,
1514 KEY_CTL_WEP
1515 );
1516 spin_unlock_irq(&pDevice->lock);
1517 }
1518 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1519 pDevice->uKeyLength = wrq->length;
1520 pDevice->bTransmitKey = TRUE;
1521 pDevice->bEncryptionEnable = TRUE;
1522 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1523
1524 // Do we want to just set the transmit key index ?
1525 if ( index < 4 ) {
1526 pDevice->byKeyIndex = index;
1527 }
1528 else if(!wrq->flags & IW_ENCODE_MODE) {
1529 rc = -EINVAL;
1530 return rc;
1531 }
1532 }
1533 // Read the flags
1534 if(wrq->flags & IW_ENCODE_DISABLED){
1535
1536 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1537 pMgmt->bShareKeyAlgorithm = FALSE;
1538 pDevice->bEncryptionEnable = FALSE;
1539 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1540 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1541 spin_lock_irq(&pDevice->lock);
1542 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1543 MACvDisableKeyEntry(pDevice,uu);
1544 spin_unlock_irq(&pDevice->lock);
1545 }
1546 }
1547 if(wrq->flags & IW_ENCODE_RESTRICTED) {
1548 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1549 pMgmt->bShareKeyAlgorithm = TRUE;
1550 }
1551 if(wrq->flags & IW_ENCODE_OPEN) {
1552 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1553 pMgmt->bShareKeyAlgorithm = FALSE;
1554 }
1555
1556#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1557 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1558#endif
1559
1560 return rc;
1561}
1562
1563/*
1564 * Wireless Handler : get encode mode
1565 */
1566//2008-0409-06, <Mark> by Einsn Liu
1567 /*
1568int iwctl_giwencode(struct net_device *dev,
1569 struct iw_request_info *info,
1570 struct iw_point *wrq,
1571 char *extra)
1572{
Forest Bond1e28efa2009-06-13 07:38:50 -04001573 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001574 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1575 int rc = 0;
1576 char abyKey[WLAN_WEP232_KEYLEN];
1577 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1578 PSKeyItem pKey = NULL;
1579
1580 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1581
1582
1583 memset(abyKey, 0, sizeof(abyKey));
1584 // Check encryption mode
1585 wrq->flags = IW_ENCODE_NOKEY;
1586 // Is WEP enabled ???
1587 if (pDevice->bEncryptionEnable)
1588 wrq->flags |= IW_ENCODE_ENABLED;
1589 else
1590 wrq->flags |= IW_ENCODE_DISABLED;
1591
1592 if (pMgmt->bShareKeyAlgorithm)
1593 wrq->flags |= IW_ENCODE_RESTRICTED;
1594 else
1595 wrq->flags |= IW_ENCODE_OPEN;
1596
1597 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1598 wrq->length = pKey->uKeyLength;
1599 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1600 }
1601 else {
1602 rc = -EINVAL;
1603 return rc;
1604 }
1605 wrq->flags |= index;
1606 // Copy the key to the user buffer
1607 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1608 return 0;
1609}
1610*/
1611
1612//2008-0409-06, <Add> by Einsn Liu
1613
1614int iwctl_giwencode(struct net_device *dev,
1615 struct iw_request_info *info,
1616 struct iw_point *wrq,
1617 char *extra)
1618{
Forest Bond1e28efa2009-06-13 07:38:50 -04001619 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001620 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1621 char abyKey[WLAN_WEP232_KEYLEN];
1622
1623 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1624 PSKeyItem pKey = NULL;
1625
1626 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1627
1628 if (index > WLAN_WEP_NKEYS) {
1629 return -EINVAL;
1630 }
1631 if(index<1){//get default key
1632 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1633 index=pDevice->byKeyIndex;
1634 } else
1635 index=0;
1636 }else
1637 index--;
1638
1639 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1640 // Check encryption mode
1641 wrq->flags = IW_ENCODE_NOKEY;
1642 // Is WEP enabled ???
1643 if (pDevice->bEncryptionEnable)
1644 wrq->flags |= IW_ENCODE_ENABLED;
1645 else
1646 wrq->flags |= IW_ENCODE_DISABLED;
1647
1648 if (pMgmt->bShareKeyAlgorithm)
1649 wrq->flags |= IW_ENCODE_RESTRICTED;
1650 else
1651 wrq->flags |= IW_ENCODE_OPEN;
1652 wrq->length=0;
1653
1654 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1655 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1656 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1657 wrq->length = pKey->uKeyLength;
1658 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1659 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1660 }
1661 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1662 wrq->length = pKey->uKeyLength;
1663 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1664 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1665 }
1666
1667 wrq->flags |= index+1;
1668
1669 return 0;
1670}
1671
1672
1673/*
1674 * Wireless Handler : set power mode
1675 */
1676int iwctl_siwpower(struct net_device *dev,
1677 struct iw_request_info *info,
1678 struct iw_param *wrq,
1679 char *extra)
1680{
Forest Bond1e28efa2009-06-13 07:38:50 -04001681 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001682 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1683 int rc = 0;
1684
1685 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1686
1687 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1688 rc = -EINVAL;
1689 return rc;
1690 }
1691
1692 if (wrq->disabled) {
1693 pDevice->ePSMode = WMAC_POWER_CAM;
1694 PSvDisablePowerSaving(pDevice);
1695 return rc;
1696 }
1697 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1698 pDevice->ePSMode = WMAC_POWER_FAST;
1699 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1700
1701 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1702 pDevice->ePSMode = WMAC_POWER_FAST;
1703 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1704 }
1705 switch (wrq->flags & IW_POWER_MODE) {
1706 case IW_POWER_UNICAST_R:
1707 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1708 rc = -EINVAL;
1709 break;
1710 case IW_POWER_ALL_R:
1711 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1712 rc = -EINVAL;
1713 case IW_POWER_ON:
1714 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1715 break;
1716 default:
1717 rc = -EINVAL;
1718 }
1719
1720 return rc;
1721}
1722
1723/*
1724 * Wireless Handler : get power mode
1725 */
1726int iwctl_giwpower(struct net_device *dev,
1727 struct iw_request_info *info,
1728 struct iw_param *wrq,
1729 char *extra)
1730{
Forest Bond1e28efa2009-06-13 07:38:50 -04001731 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001732 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1733 int mode = pDevice->ePSMode;
1734
1735
1736 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1737
1738
1739 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1740 return 0;
1741
1742 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1743 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1744 wrq->flags = IW_POWER_TIMEOUT;
1745 } else {
1746 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1747 wrq->flags = IW_POWER_PERIOD;
1748 }
1749 wrq->flags |= IW_POWER_ALL_R;
1750
1751 return 0;
1752}
1753
1754
1755/*
1756 * Wireless Handler : get Sensitivity
1757 */
1758int iwctl_giwsens(struct net_device *dev,
1759 struct iw_request_info *info,
1760 struct iw_param *wrq,
1761 char *extra)
1762{
Forest Bond1e28efa2009-06-13 07:38:50 -04001763 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001764 long ldBm;
1765
1766 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1767 if (pDevice->bLinkPass == TRUE) {
1768 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1769 wrq->value = ldBm;
1770 }
1771 else {
1772 wrq->value = 0;
1773 };
1774 wrq->disabled = (wrq->value == 0);
1775 wrq->fixed = 1;
1776
1777
1778 return 0;
1779}
1780
1781//2008-0409-07, <Add> by Einsn Liu
1782#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1783
1784int iwctl_siwauth(struct net_device *dev,
1785 struct iw_request_info *info,
1786 struct iw_param *wrq,
1787 char *extra)
1788{
Forest Bond1e28efa2009-06-13 07:38:50 -04001789 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001790 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1791 int ret=0;
1792 static int wpa_version=0; //must be static to save the last value,einsn liu
1793 static int pairwise=0;
1794
1795 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1796 switch (wrq->flags & IW_AUTH_INDEX) {
1797 case IW_AUTH_WPA_VERSION:
1798 wpa_version = wrq->value;
1799 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1800 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1801 //pDevice->bWPADEVUp = FALSE;
1802 }
1803 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1804 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1805 }
1806 else {
1807 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1808 }
1809 //pDevice->bWPASuppWextEnabled =TRUE;
1810 break;
1811 case IW_AUTH_CIPHER_PAIRWISE:
1812 pairwise = wrq->value;
1813 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
1814 if(pairwise == IW_AUTH_CIPHER_CCMP){
1815 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1816 }else if(pairwise == IW_AUTH_CIPHER_TKIP){
1817 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1818 }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
1819 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1820 }else if(pairwise == IW_AUTH_CIPHER_NONE){
1821 //do nothing,einsn liu
1822 }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1823
1824 break;
1825 case IW_AUTH_CIPHER_GROUP:
1826 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
1827 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1828 break;
1829 if(pairwise == IW_AUTH_CIPHER_NONE){
1830 if(wrq->value == IW_AUTH_CIPHER_CCMP){
1831 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1832 }else {
1833 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1834 }
1835 }
1836 break;
1837 case IW_AUTH_KEY_MGMT:
1838 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
1839 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1840 if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1841 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
1842 else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
1843 }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
1844 if(wrq->value == 0){
1845 pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
1846 }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1847 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
1848 else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
1849 }
1850
1851 break;
1852 case IW_AUTH_TKIP_COUNTERMEASURES:
1853 break; /* FIXME */
1854 case IW_AUTH_DROP_UNENCRYPTED:
1855 break;
1856 case IW_AUTH_80211_AUTH_ALG:
1857 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
1858 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1859 pMgmt->bShareKeyAlgorithm=FALSE;
1860 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
1861 pMgmt->bShareKeyAlgorithm=TRUE;
1862 }
1863 break;
1864 case IW_AUTH_WPA_ENABLED:
1865 //pDevice->bWPADEVUp = !! wrq->value;
1866 //if(pDevice->bWPADEVUp==TRUE)
1867 // printk("iwctl_siwauth:set WPADEV to enable sucessful*******\n");
1868 //else
1869 // printk("iwctl_siwauth:set WPADEV to enable fail?????\n");
1870 break;
1871 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1872 break;
1873 case IW_AUTH_ROAMING_CONTROL:
1874 ret = -EOPNOTSUPP;
1875 break;
1876 case IW_AUTH_PRIVACY_INVOKED:
1877 pDevice->bEncryptionEnable = !!wrq->value;
1878 if(pDevice->bEncryptionEnable == FALSE){
1879 wpa_version = 0;
1880 pairwise = 0;
1881 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1882 pMgmt->bShareKeyAlgorithm = FALSE;
1883 pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
1884 //pDevice->bWPADEVUp = FALSE;
1885 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
1886 }
1887
1888 break;
1889 default:
1890 ret = -EOPNOTSUPP;
1891 break;
1892 }
1893/*
1894 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1895 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1896 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1897 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1898 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1899 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1900 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADEVUp = %s\n",pDevice->bWPADEVUp?"TRUE":"FALSE");
1901*/
1902 return ret;
1903}
1904
1905
1906int iwctl_giwauth(struct net_device *dev,
1907 struct iw_request_info *info,
1908 struct iw_param *wrq,
1909 char *extra)
1910{
1911 return -EOPNOTSUPP;
1912}
1913
1914
1915
1916int iwctl_siwgenie(struct net_device *dev,
1917 struct iw_request_info *info,
1918 struct iw_point *wrq,
1919 char *extra)
1920{
Forest Bond1e28efa2009-06-13 07:38:50 -04001921 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001922 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1923 int ret=0;
1924
1925 if(wrq->length){
1926 if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
1927 ret = -EINVAL;
1928 goto out;
1929 }
1930 if(wrq->length > MAX_WPA_IE_LEN){
1931 ret = -ENOMEM;
1932 goto out;
1933 }
1934 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1935 if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
1936 ret = -EFAULT;
1937 goto out;
1938 }
1939 pMgmt->wWPAIELen = wrq->length;
1940 }else {
1941 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1942 pMgmt->wWPAIELen = 0;
1943 }
1944
1945 out://not completely ...not necessary in wpa_supplicant 0.5.8
1946 return 0;
1947}
1948
1949int iwctl_giwgenie(struct net_device *dev,
1950 struct iw_request_info *info,
1951 struct iw_point *wrq,
1952 char *extra)
1953{
Forest Bond1e28efa2009-06-13 07:38:50 -04001954 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001955 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1956 int ret=0;
1957 int space = wrq->length;
1958
1959 wrq->length = 0;
1960 if(pMgmt->wWPAIELen > 0){
1961 wrq->length = pMgmt->wWPAIELen;
1962 if(pMgmt->wWPAIELen <= space){
1963 if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
1964 ret = -EFAULT;
1965 }
1966 }else
1967 ret = -E2BIG;
1968 }
1969
1970 return ret;
1971}
1972
1973
1974int iwctl_siwencodeext(struct net_device *dev,
1975 struct iw_request_info *info,
1976 struct iw_point *wrq,
1977 char *extra)
1978{
Forest Bond1e28efa2009-06-13 07:38:50 -04001979 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001980 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1981 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
1982 struct viawget_wpa_param *param=NULL;
1983//original member
1984 wpa_alg alg_name;
1985 u8 addr[6];
1986 int key_idx, set_tx=0;
1987 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
1988 u8 key[64];
1989 size_t seq_len=0,key_len=0;
1990//
1991 // int ii;
1992 u8 *buf;
1993 size_t blen;
1994 u8 key_array[64];
1995 int ret=0;
1996
1997PRINT_K("SIOCSIWENCODEEXT...... \n");
1998
1999blen = sizeof(*param);
2000buf = kmalloc((int)blen, (int)GFP_KERNEL);
2001if (buf == NULL)
2002 return -ENOMEM;
2003memset(buf, 0, blen);
2004param = (struct viawget_wpa_param *) buf;
2005
2006//recover alg_name
2007switch (ext->alg) {
2008 case IW_ENCODE_ALG_NONE:
2009 alg_name = WPA_ALG_NONE;
2010 break;
2011 case IW_ENCODE_ALG_WEP:
2012 alg_name = WPA_ALG_WEP;
2013 break;
2014 case IW_ENCODE_ALG_TKIP:
2015 alg_name = WPA_ALG_TKIP;
2016 break;
2017 case IW_ENCODE_ALG_CCMP:
2018 alg_name = WPA_ALG_CCMP;
2019 break;
2020 default:
2021 PRINT_K("Unknown alg = %d\n",ext->alg);
2022 ret= -ENOMEM;
2023 goto error;
2024 }
2025//recover addr
2026 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
2027//recover key_idx
2028 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
2029//recover set_tx
2030if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2031 set_tx = 1;
2032//recover seq,seq_len
2033 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
2034 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
2035 memcpy(seq, ext->rx_seq, seq_len);
2036 }
2037//recover key,key_len
2038if(ext->key_len) {
2039 key_len=ext->key_len;
2040 memcpy(key, &ext->key[0], key_len);
2041 }
2042
2043memset(key_array, 0, 64);
2044if ( key_len > 0) {
2045 memcpy(key_array, key, key_len);
2046 if (key_len == 32) {
2047 // notice ! the oder
2048 memcpy(&key_array[16], &key[24], 8);
2049 memcpy(&key_array[24], &key[16], 8);
2050 }
2051 }
2052
2053/**************Translate iw_encode_ext to viawget_wpa_param****************/
2054memcpy(param->addr, addr, ETH_ALEN);
2055param->u.wpa_key.alg_name = (int)alg_name;
2056param->u.wpa_key.set_tx = set_tx;
2057param->u.wpa_key.key_index = key_idx;
2058param->u.wpa_key.key_len = key_len;
2059param->u.wpa_key.key = (u8 *)key_array;
2060param->u.wpa_key.seq = (u8 *)seq;
2061param->u.wpa_key.seq_len = seq_len;
2062
2063#if 0
2064printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
2065printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
2066 param->addr[0],param->addr[1],param->addr[2],
2067 param->addr[3],param->addr[4],param->addr[5]);
2068printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
2069printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
2070printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
2071printk("param->u.wpa_key.key =");
2072for(ii=0;ii<param->u.wpa_key.key_len;ii++)
2073 printk("%02x:",param->u.wpa_key.key[ii]);
2074 printk("\n");
2075printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
2076printk("param->u.wpa_key.seq =");
2077for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
2078 printk("%02x:",param->u.wpa_key.seq[ii]);
2079 printk("\n");
2080
2081printk("...........\n");
2082#endif
2083//****set if current action is Network Manager count??
2084//****this method is so foolish,but there is no other way???
2085if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
2086 if(param->u.wpa_key.key_index ==0) {
2087 pDevice->bwextstep0 = TRUE;
2088 }
2089 if((pDevice->bwextstep0 = TRUE)&&(param->u.wpa_key.key_index ==1)) {
2090 pDevice->bwextstep0 = FALSE;
2091 pDevice->bwextstep1 = TRUE;
2092 }
2093 if((pDevice->bwextstep1 = TRUE)&&(param->u.wpa_key.key_index ==2)) {
2094 pDevice->bwextstep1 = FALSE;
2095 pDevice->bwextstep2 = TRUE;
2096 }
2097 if((pDevice->bwextstep2 = TRUE)&&(param->u.wpa_key.key_index ==3)) {
2098 pDevice->bwextstep2 = FALSE;
2099 pDevice->bwextstep3 = TRUE;
2100 }
2101 }
2102if(pDevice->bwextstep3 == TRUE) {
2103 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2104 pDevice->bwextstep0 = FALSE;
2105 pDevice->bwextstep1 = FALSE;
2106 pDevice->bwextstep2 = FALSE;
2107 pDevice->bwextstep3 = FALSE;
2108 pDevice->bWPASuppWextEnabled = TRUE;
2109 memset(pMgmt->abyDesireBSSID, 0xFF,6);
2110 KeyvInitTable(pDevice,&pDevice->sKey);
2111 }
2112//******
2113
2114 spin_lock_irq(&pDevice->lock);
2115 ret = wpa_set_keys(pDevice, param, TRUE);
2116 spin_unlock_irq(&pDevice->lock);
2117
2118error:
2119kfree(param);
2120 return ret;
2121}
2122
2123
2124
2125int iwctl_giwencodeext(struct net_device *dev,
2126 struct iw_request_info *info,
2127 struct iw_point *wrq,
2128 char *extra)
2129{
2130 return -EOPNOTSUPP;;
2131}
2132
2133int iwctl_siwmlme(struct net_device *dev,
2134 struct iw_request_info * info,
2135 struct iw_point *wrq,
2136 char *extra)
2137{
Forest Bond1e28efa2009-06-13 07:38:50 -04002138 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04002139 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
2140 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2141 //u16 reason = cpu_to_le16(mlme->reason_code);
2142 int ret = 0;
2143
2144 if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
2145 ret = -EINVAL;
2146 return ret;
2147 }
2148 switch(mlme->cmd){
2149 case IW_MLME_DEAUTH:
2150 //this command seems to be not complete,please test it --einsnliu
2151 //printk("iwctl_siwmlme--->send DEAUTH\n");
2152 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2153 //break;
2154 case IW_MLME_DISASSOC:
2155 if(pDevice->bLinkPass == TRUE){
2156 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
2157 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
2158 }
2159 break;
2160 default:
2161 ret = -EOPNOTSUPP;
2162 }
2163
2164 return ret;
2165
2166}
2167
2168#endif
2169//End Add --//2008-0409-07, <Add> by Einsn Liu
2170
2171
2172
2173/*------------------------------------------------------------------*/
2174/*
2175 * Structures to export the Wireless Handlers
2176 */
2177
2178
2179#if WIRELESS_EXT > 12
2180
2181/*
2182static const iw_handler iwctl_handler[] =
2183{
2184 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2185 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2186 (iw_handler) NULL, // SIOCSIWNWID
2187 (iw_handler) NULL, // SIOCGIWNWID
2188 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2189 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2190 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2191 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2192 (iw_handler) NULL, // SIOCSIWSENS
2193 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2194 (iw_handler) NULL, // SIOCSIWRANGE
2195 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2196 (iw_handler) NULL, // SIOCSIWPRIV
2197 (iw_handler) NULL, // SIOCGIWPRIV
2198 (iw_handler) NULL, // SIOCSIWSTATS
2199 (iw_handler) NULL, // SIOCGIWSTATS
2200 (iw_handler) NULL, // SIOCSIWSPY
2201 (iw_handler) NULL, // SIOCGIWSPY
2202 (iw_handler) NULL, // -- hole --
2203 (iw_handler) NULL, // -- hole --
2204 (iw_handler) iwctl_siwap, // SIOCSIWAP
2205 (iw_handler) iwctl_giwap, // SIOCGIWAP
2206 (iw_handler) NULL, // -- hole -- 0x16
2207 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2208#if WIRELESS_EXT > 13
2209 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2210 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2211#else
2212 (iw_handler) NULL,
2213 (iw_handler) NULL,
2214#endif
2215 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2216 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2217 (iw_handler) NULL, // SIOCSIWNICKN
2218 (iw_handler) NULL, // SIOCGIWNICKN
2219 (iw_handler) NULL, // -- hole --
2220 (iw_handler) NULL, // -- hole --
2221 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2222 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2223 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2224 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2225 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2226 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2227 (iw_handler) NULL, // SIOCSIWTXPOW
2228 (iw_handler) NULL, // SIOCGIWTXPOW
2229 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2230 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2231 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2232 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2233 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2234 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2235#if WIRELESS_EXT > 17
2236 (iw_handler) NULL, // -- hole --
2237 (iw_handler) NULL, // -- hole --
2238 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2239 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2240 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2241 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2242 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2243 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2244 (iw_handler) NULL, // SIOCSIWPMKSA
2245 (iw_handler) NULL, // -- hole --
2246#endif // WIRELESS_EXT > 17
2247
2248};
2249*/
2250
2251static const iw_handler iwctl_handler[] =
2252{
2253 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2254 (iw_handler) NULL, // SIOCGIWNAME
2255 (iw_handler) NULL, // SIOCSIWNWID
2256 (iw_handler) NULL, // SIOCGIWNWID
2257 (iw_handler) NULL, // SIOCSIWFREQ
2258 (iw_handler) NULL, // SIOCGIWFREQ
2259 (iw_handler) NULL, // SIOCSIWMODE
2260 (iw_handler) NULL, // SIOCGIWMODE
2261 (iw_handler) NULL, // SIOCSIWSENS
2262 (iw_handler) NULL, // SIOCGIWSENS
2263 (iw_handler) NULL, // SIOCSIWRANGE
2264 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2265 (iw_handler) NULL, // SIOCSIWPRIV
2266 (iw_handler) NULL, // SIOCGIWPRIV
2267 (iw_handler) NULL, // SIOCSIWSTATS
2268 (iw_handler) NULL, // SIOCGIWSTATS
2269 (iw_handler) NULL, // SIOCSIWSPY
2270 (iw_handler) NULL, // SIOCGIWSPY
2271 (iw_handler) NULL, // -- hole --
2272 (iw_handler) NULL, // -- hole --
2273 (iw_handler) NULL, // SIOCSIWAP
2274 (iw_handler) NULL, // SIOCGIWAP
2275 (iw_handler) NULL, // -- hole -- 0x16
2276 (iw_handler) NULL, // SIOCGIWAPLIST
2277#if WIRELESS_EXT > 13
2278 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2279 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2280#else
2281 (iw_handler) NULL,
2282 (iw_handler) NULL,
2283#endif
2284 (iw_handler) NULL, // SIOCSIWESSID
2285 (iw_handler) NULL, // SIOCGIWESSID
2286 (iw_handler) NULL, // SIOCSIWNICKN
2287 (iw_handler) NULL, // SIOCGIWNICKN
2288 (iw_handler) NULL, // -- hole --
2289 (iw_handler) NULL, // -- hole --
2290 (iw_handler) NULL, // SIOCSIWRATE 0x20
2291 (iw_handler) NULL, // SIOCGIWRATE
2292 (iw_handler) NULL, // SIOCSIWRTS
2293 (iw_handler) NULL, // SIOCGIWRTS
2294 (iw_handler) NULL, // SIOCSIWFRAG
2295 (iw_handler) NULL, // SIOCGIWFRAG
2296 (iw_handler) NULL, // SIOCSIWTXPOW
2297 (iw_handler) NULL, // SIOCGIWTXPOW
2298 (iw_handler) NULL, // SIOCSIWRETRY
2299 (iw_handler) NULL, // SIOCGIWRETRY
2300 (iw_handler) NULL, // SIOCSIWENCODE
2301 (iw_handler) NULL, // SIOCGIWENCODE
2302 (iw_handler) NULL, // SIOCSIWPOWER
2303 (iw_handler) NULL, // SIOCGIWPOWER
2304//2008-0409-07, <Add> by Einsn Liu
2305#if WIRELESS_EXT > 17
2306 (iw_handler) NULL, // -- hole --
2307 (iw_handler) NULL, // -- hole --
2308 (iw_handler) NULL, // SIOCSIWGENIE
2309 (iw_handler) NULL, // SIOCGIWGENIE
2310 (iw_handler) NULL, // SIOCSIWAUTH
2311 (iw_handler) NULL, // SIOCGIWAUTH
2312 (iw_handler) NULL, // SIOCSIWENCODEEXT
2313 (iw_handler) NULL, // SIOCGIWENCODEEXT
2314 (iw_handler) NULL, // SIOCSIWPMKSA
2315 (iw_handler) NULL, // -- hole --
2316#endif // WIRELESS_EXT > 17
2317};
2318
2319
2320static const iw_handler iwctl_private_handler[] =
2321{
2322 NULL, // SIOCIWFIRSTPRIV
2323};
2324
2325
2326struct iw_priv_args iwctl_private_args[] = {
2327{ IOCTL_CMD_SET,
2328 IW_PRIV_TYPE_CHAR | 1024, 0,
2329 "set"},
2330};
2331
2332
2333
2334const struct iw_handler_def iwctl_handler_def =
2335{
2336#if WIRELESS_EXT > 16
2337 .get_wireless_stats = &iwctl_get_wireless_stats,
2338#endif
2339 .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
2340// .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2341// .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2342 .num_private = 0,
2343 .num_private_args = 0,
2344 .standard = (iw_handler *) iwctl_handler,
2345// .private = (iw_handler *) iwctl_private_handler,
2346// .private_args = (struct iw_priv_args *)iwctl_private_args,
2347 .private = NULL,
2348 .private_args = NULL,
2349};
2350
2351
2352#endif // WIRELESS_EXT > 12
2353
2354
2355#endif // WIRELESS_EXT