blob: 67db85a19d18986a93f12fdd74e4629e47177073 [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
Forest Bond92b96792009-06-13 07:38:31 -040033#include "device.h"
Forest Bond92b96792009-06-13 07:38:31 -040034#include "ioctl.h"
Forest Bond92b96792009-06-13 07:38:31 -040035#include "iocmd.h"
Forest Bond92b96792009-06-13 07:38:31 -040036#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040037#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040038#include "hostap.h"
Forest Bond92b96792009-06-13 07:38:31 -040039#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040040#include "rf.h"
Forest Bond92b96792009-06-13 07:38:31 -040041
42#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
Forest Bond92b96792009-06-13 07:38:31 -040043#include "iowpa.h"
Forest Bond92b96792009-06-13 07:38:31 -040044#include "wpactl.h"
45#endif
Forest Bond92b96792009-06-13 07:38:31 -040046
Forest Bond92b96792009-06-13 07:38:31 -040047#include <net/iw_handler.h>
Forest Bond92b96792009-06-13 07:38:31 -040048
49
50/*--------------------- Static Definitions -------------------------*/
51
52//2008-0409-07, <Add> by Einsn Liu
53#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
54#define SUPPORTED_WIRELESS_EXT 18
55#else
56#define SUPPORTED_WIRELESS_EXT 17
57#endif
58
Forest Bond92b96792009-06-13 07:38:31 -040059static const long frequency_list[] = {
60 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
61 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
62 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
63 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
64 5700, 5745, 5765, 5785, 5805, 5825
65 };
66
Forest Bond92b96792009-06-13 07:38:31 -040067
68/*--------------------- Static Classes ----------------------------*/
69
70
71//static int msglevel =MSG_LEVEL_DEBUG;
72static int msglevel =MSG_LEVEL_INFO;
73
74
75/*--------------------- Static Variables --------------------------*/
76/*--------------------- Static Functions --------------------------*/
77
78/*--------------------- Export Variables --------------------------*/
79
Forest Bond92b96792009-06-13 07:38:31 -040080struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
81{
Forest Bond1e28efa2009-06-13 07:38:50 -040082 PSDevice pDevice = netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -040083 long ldBm;
84
85 pDevice->wstats.status = pDevice->eOPMode;
86 #ifdef Calcu_LinkQual
Forest Bond92b96792009-06-13 07:38:31 -040087 if(pDevice->scStatistic.LinkQuality > 100)
88 pDevice->scStatistic.LinkQuality = 100;
89 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
90 #else
91 pDevice->wstats.qual.qual = pDevice->byCurrSQ;
92 #endif
93 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
94 pDevice->wstats.qual.level = ldBm;
95 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
96 pDevice->wstats.qual.noise = 0;
97 pDevice->wstats.qual.updated = 1;
98 pDevice->wstats.discard.nwid = 0;
99 pDevice->wstats.discard.code = 0;
100 pDevice->wstats.discard.fragment = 0;
101 pDevice->wstats.discard.retries = pDevice->scStatistic.dwTsrErr;
102 pDevice->wstats.discard.misc = 0;
103 pDevice->wstats.miss.beacon = 0;
104
105 return &pDevice->wstats;
106}
107
Forest Bond92b96792009-06-13 07:38:31 -0400108
109
110/*------------------------------------------------------------------*/
111
112
113static int iwctl_commit(struct net_device *dev,
114 struct iw_request_info *info,
115 void *wrq,
116 char *extra)
117{
118//2008-0409-02, <Mark> by Einsn Liu
119/*
120#ifdef Safe_Close
Forest Bond1e28efa2009-06-13 07:38:50 -0400121 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400122 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
123 return -EINVAL;
124#endif
125*/
126 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
127
128 return 0;
129
130}
131
132/*
133 * Wireless Handler : get protocol name
134 */
135
136int iwctl_giwname(struct net_device *dev,
137 struct iw_request_info *info,
138 char *wrq,
139 char *extra)
140{
141 strcpy(wrq, "802.11-a/b/g");
142 return 0;
143}
144
145int iwctl_giwnwid(struct net_device *dev,
146 struct iw_request_info *info,
147 struct iw_param *wrq,
148 char *extra)
149{
150 //wrq->value = 0x100;
151 //wrq->disabled = 0;
152 //wrq->fixed = 1;
153 //return 0;
154 return -EOPNOTSUPP;
155}
Forest Bond92b96792009-06-13 07:38:31 -0400156/*
157 * Wireless Handler : set scan
158 */
159
160int iwctl_siwscan(struct net_device *dev,
161 struct iw_request_info *info,
162 struct iw_point *wrq,
163 char *extra)
164{
Forest Bond1e28efa2009-06-13 07:38:50 -0400165 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400166 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
167 struct iw_scan_req *req = (struct iw_scan_req *)extra;
168 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
169 PWLAN_IE_SSID pItemSSID=NULL;
170
171//2008-0920-01<Add>by MikeLiu
172 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
173 return -EINVAL;
174
175 PRINT_K(" SIOCSIWSCAN \n");
176
177if (pMgmt->eScanState == WMAC_IS_SCANNING) {
178 // In scanning..
179 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
180 return -EAGAIN;
181 }
182
183if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
184//send scan event to wpa_Supplicant
185 union iwreq_data wrqu;
186 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
187 memset(&wrqu, 0, sizeof(wrqu));
188 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
189 return 0;
190}
191
192 spin_lock_irq(&pDevice->lock);
193
Andres More0cbd8d92010-05-06 20:34:29 -0300194#ifdef update_BssList
195 BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass);
196#endif
Forest Bond92b96792009-06-13 07:38:31 -0400197
198//mike add: active scan OR passive scan OR desire_ssid scan
199 if(wrq->length == sizeof(struct iw_scan_req)) {
200 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
201 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
202 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
203 pItemSSID->byElementID = WLAN_EID_SSID;
204 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
205 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
206 if(req->essid_len>0)
207 pItemSSID->len = req->essid_len - 1;
208 }
209 else
210 pItemSSID->len = req->essid_len;
211 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
212 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
213 ((PWLAN_IE_SSID)abyScanSSID)->len);
Andres More0cbd8d92010-05-06 20:34:29 -0300214 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400215 spin_unlock_irq(&pDevice->lock);
216
217 return 0;
218 }
219 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
220 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
221 }
222 }
223 else { //active scan
224 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
225 }
226
227 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
228 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
Andres More0cbd8d92010-05-06 20:34:29 -0300229 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
Forest Bond92b96792009-06-13 07:38:31 -0400230 spin_unlock_irq(&pDevice->lock);
231
232 return 0;
233}
234
235
236/*
237 * Wireless Handler : get scan results
238 */
239
240int iwctl_giwscan(struct net_device *dev,
241 struct iw_request_info *info,
242 struct iw_point *wrq,
243 char *extra)
244{
245 int ii, jj, kk;
Forest Bond1e28efa2009-06-13 07:38:50 -0400246 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400247 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
248 PKnownBSS pBSS;
249 PWLAN_IE_SSID pItemSSID;
250 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
251 char *current_ev = extra;
252 char *end_buf = extra + IW_SCAN_MAX_DATA;
253 char *current_val = NULL;
254 struct iw_event iwe;
255 long ldBm;
Forest Bond92b96792009-06-13 07:38:31 -0400256 char buf[MAX_WPA_IE_LEN * 2 + 30];
Forest Bond92b96792009-06-13 07:38:31 -0400257
258//2008-0409-02, <Mark> by Einsn Liu
259/*
260#ifdef Safe_Close
261 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
262 return -EINVAL;
263#endif
264*/
265 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
266
267 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
268 // In scanning..
269 return -EAGAIN;
270 }
271 pBSS = &(pMgmt->sBSSList[0]);
272 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
273 if (current_ev >= end_buf)
274 break;
275 pBSS = &(pMgmt->sBSSList[jj]);
276 if (pBSS->bActive) {
277 //ADD mac address
278 memset(&iwe, 0, sizeof(iwe));
279 iwe.cmd = SIOCGIWAP;
280 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
281 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400282 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400283 //ADD ssid
284 memset(&iwe, 0, sizeof(iwe));
285 iwe.cmd = SIOCGIWESSID;
286 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
287 iwe.u.data.length = pItemSSID->len;
288 iwe.u.data.flags = 1;
Forest Bond92b96792009-06-13 07:38:31 -0400289 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
Forest Bond92b96792009-06-13 07:38:31 -0400290 //ADD mode
291 memset(&iwe, 0, sizeof(iwe));
292 iwe.cmd = SIOCGIWMODE;
293 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
294 iwe.u.mode = IW_MODE_INFRA;
295 }
296 else {
297 iwe.u.mode = IW_MODE_ADHOC;
298 }
299 iwe.len = IW_EV_UINT_LEN;
Forest Bond92b96792009-06-13 07:38:31 -0400300 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400301 //ADD frequency
302 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
303 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
304 memset(&iwe, 0, sizeof(iwe));
305 iwe.cmd = SIOCGIWFREQ;
306 iwe.u.freq.m = pBSS->uChannel;
307 iwe.u.freq.e = 0;
308 iwe.u.freq.i = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400309 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400310 //2008-0409-04, <Add> by Einsn Liu
311 {
312 int f = (int)pBSS->uChannel - 1;
313 if(f < 0)f = 0;
314 iwe.u.freq.m = frequency_list[f] * 100000;
315 iwe.u.freq.e = 1;
316 }
Forest Bond92b96792009-06-13 07:38:31 -0400317 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400318 //ADD quality
319 memset(&iwe, 0, sizeof(iwe));
320 iwe.cmd = IWEVQUAL;
321 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
322 iwe.u.qual.level = ldBm;
323 iwe.u.qual.noise = 0;
324//2008-0409-01, <Add> by Einsn Liu
325 if(-ldBm<50){
326 iwe.u.qual.qual = 100;
327 }else if(-ldBm > 90) {
328 iwe.u.qual.qual = 0;
329 }else {
330 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
331 }
332 iwe.u.qual.updated=7;
333
Forest Bond92b96792009-06-13 07:38:31 -0400334 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400335 //ADD encryption
336 memset(&iwe, 0, sizeof(iwe));
337 iwe.cmd = SIOCGIWENCODE;
338 iwe.u.data.length = 0;
339 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
340 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
341 }else {
342 iwe.u.data.flags = IW_ENCODE_DISABLED;
343 }
Forest Bond92b96792009-06-13 07:38:31 -0400344 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
Forest Bond92b96792009-06-13 07:38:31 -0400345
346 memset(&iwe, 0, sizeof(iwe));
347 iwe.cmd = SIOCGIWRATE;
348 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
349 current_val = current_ev + IW_EV_LCP_LEN;
350
351 for (kk = 0 ; kk < 12 ; kk++) {
352 if (pSuppRates->abyRates[kk] == 0)
353 break;
354 // Bit rate given in 500 kb/s units (+ 0x80)
355 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
Forest Bond92b96792009-06-13 07:38:31 -0400356 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400357 }
358 for (kk = 0 ; kk < 8 ; kk++) {
359 if (pExtSuppRates->abyRates[kk] == 0)
360 break;
361 // Bit rate given in 500 kb/s units (+ 0x80)
362 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
Forest Bond92b96792009-06-13 07:38:31 -0400363 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
Forest Bond92b96792009-06-13 07:38:31 -0400364 }
365
366 if((current_val - current_ev) > IW_EV_LCP_LEN)
367 current_ev = current_val;
368
Forest Bond92b96792009-06-13 07:38:31 -0400369 memset(&iwe, 0, sizeof(iwe));
370 iwe.cmd = IWEVCUSTOM;
371 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
372 iwe.u.data.length = strlen(buf);
Forest Bond92b96792009-06-13 07:38:31 -0400373 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
Forest Bond92b96792009-06-13 07:38:31 -0400374
Forest Bond92b96792009-06-13 07:38:31 -0400375 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
376 memset(&iwe, 0, sizeof(iwe));
377 iwe.cmd = IWEVGENIE;
378 iwe.u.data.length = pBSS->wWPALen;
Forest Bond92b96792009-06-13 07:38:31 -0400379 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
Forest Bond92b96792009-06-13 07:38:31 -0400380 }
381
382 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
383 memset(&iwe, 0, sizeof(iwe));
384 iwe.cmd = IWEVGENIE;
385 iwe.u.data.length = pBSS->wRSNLen;
Forest Bond92b96792009-06-13 07:38:31 -0400386 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
Forest Bond92b96792009-06-13 07:38:31 -0400387 }
388
Forest Bond92b96792009-06-13 07:38:31 -0400389 }
390 }// for
391
392 wrq->length = current_ev - extra;
393 return 0;
394
395}
396
Forest Bond92b96792009-06-13 07:38:31 -0400397
398/*
399 * Wireless Handler : set frequence or channel
400 */
401
402int iwctl_siwfreq(struct net_device *dev,
403 struct iw_request_info *info,
404 struct iw_freq *wrq,
405 char *extra)
406{
Forest Bond1e28efa2009-06-13 07:38:50 -0400407 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400408 int rc = 0;
409
410 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
411
412 // If setting by frequency, convert to a channel
413 if((wrq->e == 1) &&
414 (wrq->m >= (int) 2.412e8) &&
415 (wrq->m <= (int) 2.487e8)) {
416 int f = wrq->m / 100000;
417 int c = 0;
418 while((c < 14) && (f != frequency_list[c]))
419 c++;
420 wrq->e = 0;
421 wrq->m = c + 1;
422 }
423 // Setting by channel number
424 if((wrq->m > 14) || (wrq->e > 0))
425 rc = -EOPNOTSUPP;
426 else {
427 int channel = wrq->m;
428 if((channel < 1) || (channel > 14)) {
429 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
430 rc = -EINVAL;
431 } else {
432 // Yes ! We can set it !!!
433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
434 pDevice->uChannel = channel;
435 }
436 }
437
438 return rc;
439}
440
441/*
442 * Wireless Handler : get frequence or channel
443 */
444
445int iwctl_giwfreq(struct net_device *dev,
446 struct iw_request_info *info,
447 struct iw_freq *wrq,
448 char *extra)
449{
Forest Bond1e28efa2009-06-13 07:38:50 -0400450 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400451 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
452
453 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
454
455#ifdef WEXT_USECHANNELS
456 wrq->m = (int)pMgmt->uCurrChannel;
457 wrq->e = 0;
458#else
459 {
460 int f = (int)pMgmt->uCurrChannel - 1;
461 if(f < 0)
462 f = 0;
463 wrq->m = frequency_list[f] * 100000;
464 wrq->e = 1;
465 }
466#endif
467
468 return 0;
469}
470
471/*
472 * Wireless Handler : set operation mode
473 */
474
475int iwctl_siwmode(struct net_device *dev,
476 struct iw_request_info *info,
477 __u32 *wmode,
478 char *extra)
479{
Forest Bond1e28efa2009-06-13 07:38:50 -0400480 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400481 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
482 int rc = 0;
483
484 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
485
486 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
488 return rc;
489 }
490
491 switch(*wmode) {
492
493 case IW_MODE_ADHOC:
494 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
495 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
496 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
497 pDevice->bCommit = TRUE;
498 }
499 }
500 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
501 break;
502 case IW_MODE_AUTO:
503 case IW_MODE_INFRA:
504 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
505 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
506 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
507 pDevice->bCommit = TRUE;
508 }
509 }
510 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
511 break;
512 case IW_MODE_MASTER:
513
514 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
515 rc = -EOPNOTSUPP;
516 break;
517
518 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
519 pMgmt->eConfigMode = WMAC_CONFIG_AP;
520 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
521 pDevice->bCommit = TRUE;
522 }
523 }
524 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
525 break;
526
527 case IW_MODE_REPEAT:
528 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
529 rc = -EOPNOTSUPP;
530 break;
531 default:
532 rc = -EINVAL;
533 }
534
535 return rc;
536}
537
538/*
539 * Wireless Handler : get operation mode
540 */
541
542int iwctl_giwmode(struct net_device *dev,
543 struct iw_request_info *info,
544 __u32 *wmode,
545 char *extra)
546{
Forest Bond1e28efa2009-06-13 07:38:50 -0400547 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400548 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
549
550
551 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
552 // If not managed, assume it's ad-hoc
553 switch (pMgmt->eConfigMode) {
554 case WMAC_CONFIG_ESS_STA:
555 *wmode = IW_MODE_INFRA;
556 break;
557 case WMAC_CONFIG_IBSS_STA:
558 *wmode = IW_MODE_ADHOC;
559 break;
560 case WMAC_CONFIG_AUTO:
561 *wmode = IW_MODE_INFRA;
562 break;
563 case WMAC_CONFIG_AP:
564 *wmode = IW_MODE_MASTER;
565 break;
566 default:
567 *wmode = IW_MODE_ADHOC;
568 }
569
570 return 0;
571}
572
573
574/*
575 * Wireless Handler : get capability range
576 */
577
578int iwctl_giwrange(struct net_device *dev,
579 struct iw_request_info *info,
580 struct iw_point *wrq,
581 char *extra)
582{
583 struct iw_range *range = (struct iw_range *) extra;
584 int i,k;
585 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
586//2008-0409-02, <Mark> by Einsn Liu
587/*
588 #ifdef Safe_Close
Forest Bond1e28efa2009-06-13 07:38:50 -0400589 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400590 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
591 return -EINVAL;
592#endif
593 */
594
595 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
596 if (wrq->pointer) {
597 wrq->length = sizeof(struct iw_range);
598 memset(range, 0, sizeof(struct iw_range));
599 range->min_nwid = 0x0000;
600 range->max_nwid = 0x0000;
601 range->num_channels = 14;
602 // Should be based on cap_rid.country to give only
603 // what the current card support
604 k = 0;
Andres More33d33e422010-05-19 23:50:00 -0300605 for (i = 0; i < 14; i++) {
Forest Bond92b96792009-06-13 07:38:31 -0400606 range->freq[k].i = i + 1; // List index
607 range->freq[k].m = frequency_list[i] * 100000;
608 range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
609 }
610 range->num_frequency = k;
611 // Hum... Should put the right values there
612 #ifdef Calcu_LinkQual
613 range->max_qual.qual = 100;
614 #else
615 range->max_qual.qual = 255;
616 #endif
617 range->max_qual.level = 0;
618 range->max_qual.noise = 0;
619 range->sensitivity = 255;
620
Andres More33d33e422010-05-19 23:50:00 -0300621 for (i = 0 ; i < 13 ; i++) {
Forest Bond92b96792009-06-13 07:38:31 -0400622 range->bitrate[i] = abySupportedRates[i] * 500000;
623 if(range->bitrate[i] == 0)
624 break;
625 }
626 range->num_bitrates = i;
627
628 // Set an indication of the max TCP throughput
629 // in bit/s that we can expect using this interface.
630 // May be use for QoS stuff... Jean II
631 if(i > 2)
632 range->throughput = 5 * 1000 * 1000;
633 else
634 range->throughput = 1.5 * 1000 * 1000;
635
636 range->min_rts = 0;
637 range->max_rts = 2312;
638 range->min_frag = 256;
639 range->max_frag = 2312;
640
641
642 // the encoding capabilities
643 range->num_encoding_sizes = 3;
644 // 64(40) bits WEP
645 range->encoding_size[0] = 5;
646 // 128(104) bits WEP
647 range->encoding_size[1] = 13;
648 // 256 bits for WPA-PSK
649 range->encoding_size[2] = 32;
650 // 4 keys are allowed
651 range->max_encoding_tokens = 4;
652
Forest Bond92b96792009-06-13 07:38:31 -0400653 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
654 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
Forest Bond92b96792009-06-13 07:38:31 -0400655
Forest Bond92b96792009-06-13 07:38:31 -0400656 range->min_pmp = 0;
657 range->max_pmp = 1000000;// 1 secs
658 range->min_pmt = 0;
659 range->max_pmt = 1000000;// 1 secs
660 range->pmp_flags = IW_POWER_PERIOD;
661 range->pmt_flags = IW_POWER_TIMEOUT;
662 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
663
664 // Transmit Power - values are in mW
665
666 range->txpower[0] = 100;
667 range->num_txpower = 1;
668 range->txpower_capa = IW_TXPOW_MWATT;
Forest Bond92b96792009-06-13 07:38:31 -0400669 range->we_version_source = SUPPORTED_WIRELESS_EXT;
670 range->we_version_compiled = WIRELESS_EXT;
671 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
672 range->retry_flags = IW_RETRY_LIMIT;
673 range->r_time_flags = IW_RETRY_LIFETIME;
674 range->min_retry = 1;
675 range->max_retry = 65535;
676 range->min_r_time = 1024;
677 range->max_r_time = 65535 * 1024;
Forest Bond92b96792009-06-13 07:38:31 -0400678 // Experimental measurements - boundary 11/5.5 Mb/s
679 // Note : with or without the (local->rssi), results
680 // are somewhat different. - Jean II
681 range->avg_qual.qual = 6;
682 range->avg_qual.level = 176; // -80 dBm
683 range->avg_qual.noise = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400684 }
685
686
687 return 0;
688}
689
690
691/*
692 * Wireless Handler : set ap mac address
693 */
694
695int iwctl_siwap(struct net_device *dev,
696 struct iw_request_info *info,
697 struct sockaddr *wrq,
698 char *extra)
699{
Forest Bond1e28efa2009-06-13 07:38:50 -0400700 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400701 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
702 int rc = 0;
703 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
704
705 PRINT_K(" SIOCSIWAP \n");
706
707 if (wrq->sa_family != ARPHRD_ETHER)
708 rc = -EINVAL;
709 else {
Forest Bond92b96792009-06-13 07:38:31 -0400710 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
711
712 //mike :add
Andres More4b50fb42010-06-22 21:57:42 -0300713 if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
Forest Bond92b96792009-06-13 07:38:31 -0400714 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
715 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
716 return rc;
717 }
718 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
719 // then ignore,because you don't known which one to be connect with??
720 {
Andres Morecc856e62010-05-17 21:34:01 -0300721 unsigned int ii, uSameBssidNum = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400722 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
723 if (pMgmt->sBSSList[ii].bActive &&
Andres More4722a262010-06-23 20:38:10 -0300724 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
725 pMgmt->abyDesireBSSID)) {
Forest Bond92b96792009-06-13 07:38:31 -0400726 uSameBssidNum++;
727 }
728 }
729 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
730 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
731 return rc;
732 }
733 }
734
735 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
736 pDevice->bCommit = TRUE;
737 }
738 }
739 return rc;
740}
741
742/*
743 * Wireless Handler : get ap mac address
744 */
745
746int iwctl_giwap(struct net_device *dev,
747 struct iw_request_info *info,
748 struct sockaddr *wrq,
749 char *extra)
750{
Forest Bond1e28efa2009-06-13 07:38:50 -0400751 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400752 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
753
754
755 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
756
757 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
758
759//20080123-02,<Modify> by Einsn Liu
760 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
761 // if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode == WMAC_MODE_ESS_STA))
762 memset(wrq->sa_data, 0, 6);
763
764 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
765 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
766 }
767
768 wrq->sa_family = ARPHRD_ETHER;
769
770 return 0;
771
772}
773
774
775/*
776 * Wireless Handler : get ap list
777 */
778
779int iwctl_giwaplist(struct net_device *dev,
780 struct iw_request_info *info,
781 struct iw_point *wrq,
782 char *extra)
783{
784 int ii,jj, rc = 0;
785 struct sockaddr sock[IW_MAX_AP];
786 struct iw_quality qual[IW_MAX_AP];
Forest Bond1e28efa2009-06-13 07:38:50 -0400787 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400788 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
789
790
791 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
792 // Only super-user can see AP list
793
794 if (!capable(CAP_NET_ADMIN)) {
795 rc = -EPERM;
796 return rc;
797 }
798
799 if (wrq->pointer) {
800
801 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
802
803 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
804 pBSS = &(pMgmt->sBSSList[ii]);
805 if (!pBSS->bActive)
806 continue;
807 if ( jj >= IW_MAX_AP)
808 break;
809 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
810 sock[jj].sa_family = ARPHRD_ETHER;
811 qual[jj].level = pBSS->uRSSI;
812 qual[jj].qual = qual[jj].noise = 0;
813 qual[jj].updated = 2;
814 jj++;
815 }
816
817 wrq->flags = 1; // Should be define'd
818 wrq->length = jj;
819 memcpy(extra, sock, sizeof(struct sockaddr)*jj);
820 memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
821 }
822
823 return rc;
824}
825
826
827/*
828 * Wireless Handler : set essid
829 */
830
831int iwctl_siwessid(struct net_device *dev,
832 struct iw_request_info *info,
833 struct iw_point *wrq,
834 char *extra)
835{
Forest Bond1e28efa2009-06-13 07:38:50 -0400836 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400837 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
838 PWLAN_IE_SSID pItemSSID;
839
840//2008-0920-01<Add>by MikeLiu
841 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
842 return -EINVAL;
843
844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
845
846 pDevice->fWPA_Authened = FALSE;
847 // Check if we asked for `any'
848 if(wrq->flags == 0) {
849 // Just send an empty SSID list
850 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
851 memset(pMgmt->abyDesireBSSID, 0xFF,6);
852 PRINT_K("set essid to 'any' \n");
853 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
854 //Unknown desired AP,so here need not associate??
855 return 0;
856 #endif
857 } else {
858 // Set the SSID
859 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
860 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
861 pItemSSID->byElementID = WLAN_EID_SSID;
862
863 memcpy(pItemSSID->abySSID, extra, wrq->length);
864 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
865 if(wrq->length>0)
866 pItemSSID->len = wrq->length - 1;
867 }
868 else
869 pItemSSID->len = wrq->length;
870 PRINT_K("set essid to %s \n",pItemSSID->abySSID);
871
872 //mike:need clear desiredBSSID
873 if(pItemSSID->len==0) {
874 memset(pMgmt->abyDesireBSSID, 0xFF,6);
875 return 0;
876 }
877
878#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
879 //Wext wil order another command of siwap to link with desired AP,
880 //so here need not associate??
881 if(pDevice->bWPASuppWextEnabled == TRUE) {
882 /*******search if in hidden ssid mode ****/
883 {
884 PKnownBSS pCurr = NULL;
885 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
Andres Morecc856e62010-05-17 21:34:01 -0300886 unsigned int ii, uSameBssidNum = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400887
Forest Bond92b96792009-06-13 07:38:31 -0400888 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
889 pCurr = BSSpSearchBSSList(pDevice,
890 NULL,
891 abyTmpDesireSSID,
892 pDevice->eConfigPHYMode
893 );
894
895 if (pCurr == NULL){
896 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
Andres More0cbd8d92010-05-06 20:34:29 -0300897 vResetCommandTimer((void *) pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400898 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
Andres More0cbd8d92010-05-06 20:34:29 -0300899 bScheduleCommand((void *) pDevice,
900 WLAN_CMD_BSSID_SCAN,
901 pMgmt->abyDesireSSID);
902 bScheduleCommand((void *) pDevice,
903 WLAN_CMD_SSID,
904 pMgmt->abyDesireSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400905 }
906 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
907 // by means of judging if there are two same BSSID exist in list ?
908 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
909 if (pMgmt->sBSSList[ii].bActive &&
Andres More4722a262010-06-23 20:38:10 -0300910 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
911 pCurr->abyBSSID)) {
Forest Bond92b96792009-06-13 07:38:31 -0400912 uSameBssidNum++;
913 }
914 }
915 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
916 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
Andres More0cbd8d92010-05-06 20:34:29 -0300917 vResetCommandTimer((void *) pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400918 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
Andres More0cbd8d92010-05-06 20:34:29 -0300919 bScheduleCommand((void *) pDevice,
920 WLAN_CMD_BSSID_SCAN,
921 pMgmt->abyDesireSSID);
922 bScheduleCommand((void *) pDevice,
923 WLAN_CMD_SSID,
924 pMgmt->abyDesireSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400925 }
926 }
927 }
928 return 0;
929 }
930 #endif
931
932 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
933 }
934
935 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
936 pDevice->bCommit = TRUE;
937 }
938
939
940 return 0;
941}
942
943
944/*
945 * Wireless Handler : get essid
946 */
947
948int iwctl_giwessid(struct net_device *dev,
949 struct iw_request_info *info,
950 struct iw_point *wrq,
951 char *extra)
952{
953
Forest Bond1e28efa2009-06-13 07:38:50 -0400954 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400955 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
956 PWLAN_IE_SSID pItemSSID;
957
958 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
959
960 // Note : if wrq->u.data.flags != 0, we should
961 // get the relevant SSID from the SSID list...
962
963 // Get the current SSID
964 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
965 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
966 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
967 extra[pItemSSID->len] = '\0';
968 //2008-0409-03, <Add> by Einsn Liu
Forest Bond92b96792009-06-13 07:38:31 -0400969 wrq->length = pItemSSID->len;
Forest Bond92b96792009-06-13 07:38:31 -0400970 wrq->flags = 1; // active
971
972
973 return 0;
974}
975
976/*
977 * Wireless Handler : set data rate
978 */
979
980int iwctl_siwrate(struct net_device *dev,
981 struct iw_request_info *info,
982 struct iw_param *wrq,
983 char *extra)
984{
Forest Bond1e28efa2009-06-13 07:38:50 -0400985 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -0400986 int rc = 0;
987 u8 brate = 0;
988 int i;
989 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
990
991
992 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
993 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
994 rc = -EINVAL;
995 return rc;
996 }
997
998 // First : get a valid bit rate value
999
1000 // Which type of value
1001 if((wrq->value < 13) &&
1002 (wrq->value >= 0)) {
1003 // Setting by rate index
1004 // Find value in the magic rate table
1005 brate = wrq->value;
1006 } else {
1007 // Setting by frequency value
1008 u8 normvalue = (u8) (wrq->value/500000);
1009
1010 // Check if rate is valid
Andres More33d33e422010-05-19 23:50:00 -03001011 for (i = 0 ; i < 13 ; i++) {
Forest Bond92b96792009-06-13 07:38:31 -04001012 if(normvalue == abySupportedRates[i]) {
1013 brate = i;
1014 break;
1015 }
1016 }
1017 }
1018 // -1 designed the max rate (mostly auto mode)
1019 if(wrq->value == -1) {
1020 // Get the highest available rate
Andres More33d33e422010-05-19 23:50:00 -03001021 for (i = 0 ; i < 13 ; i++) {
Forest Bond92b96792009-06-13 07:38:31 -04001022 if(abySupportedRates[i] == 0)
1023 break;
1024 }
1025 if(i != 0)
1026 brate = i - 1;
1027
1028 }
1029 // Check that it is valid
1030 // brate is index of abySupportedRates[]
1031 if(brate > 13 ) {
1032 rc = -EINVAL;
1033 return rc;
1034 }
1035
1036 // Now, check if we want a fixed or auto value
1037 if(wrq->fixed != 0) {
1038 // Fixed mode
1039 // One rate, fixed
1040 pDevice->bFixRate = TRUE;
1041 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
1042 pDevice->uConnectionRate = 3;
1043 }
1044 else {
1045 pDevice->uConnectionRate = brate;
1046 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
1047 }
1048
1049 }
1050 else {
1051 pDevice->bFixRate = FALSE;
1052 pDevice->uConnectionRate = 13;
1053 }
1054
1055 return rc;
1056}
1057
1058/*
1059 * Wireless Handler : get data rate
1060 */
1061
1062int iwctl_giwrate(struct net_device *dev,
1063 struct iw_request_info *info,
1064 struct iw_param *wrq,
1065 char *extra)
1066{
Forest Bond1e28efa2009-06-13 07:38:50 -04001067 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001068 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1069
1070 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
1071 {
1072 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1073 int brate = 0;
1074 if (pDevice->uConnectionRate < 13) {
1075 brate = abySupportedRates[pDevice->uConnectionRate];
1076 }else {
1077 if (pDevice->byBBType == BB_TYPE_11B)
1078 brate = 0x16;
1079 if (pDevice->byBBType == BB_TYPE_11G)
1080 brate = 0x6C;
1081 if (pDevice->byBBType == BB_TYPE_11A)
1082 brate = 0x6C;
1083 }
1084
1085 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1086 if (pDevice->byBBType == BB_TYPE_11B)
1087 brate = 0x16;
1088 if (pDevice->byBBType == BB_TYPE_11G)
1089 brate = 0x6C;
1090 if (pDevice->byBBType == BB_TYPE_11A)
1091 brate = 0x6C;
1092 }
1093 if (pDevice->uConnectionRate == 13)
1094 brate = abySupportedRates[pDevice->wCurrentRate];
1095 wrq->value = brate * 500000;
1096 // If more than one rate, set auto
1097 if (pDevice->bFixRate == TRUE)
1098 wrq->fixed = TRUE;
1099 }
1100
1101
1102 return 0;
1103}
1104
1105
1106
1107/*
1108 * Wireless Handler : set rts threshold
1109 */
1110
1111int iwctl_siwrts(struct net_device *dev,
1112 struct iw_request_info *info,
1113 struct iw_param *wrq,
1114 char *extra)
1115{
Forest Bond1e28efa2009-06-13 07:38:50 -04001116 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001117 int rc = 0;
1118
1119 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
1120
1121 {
1122 int rthr = wrq->value;
1123 if(wrq->disabled)
1124 rthr = 2312;
1125 if((rthr < 0) || (rthr > 2312)) {
1126 rc = -EINVAL;
1127 }else {
1128 pDevice->wRTSThreshold = rthr;
1129 }
1130 }
1131
1132 return 0;
1133}
1134
1135/*
1136 * Wireless Handler : get rts
1137 */
1138
1139int iwctl_giwrts(struct net_device *dev,
1140 struct iw_request_info *info,
1141 struct iw_param *wrq,
1142 char *extra)
1143{
Forest Bond1e28efa2009-06-13 07:38:50 -04001144 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001145
1146 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
1147 wrq->value = pDevice->wRTSThreshold;
1148 wrq->disabled = (wrq->value >= 2312);
1149 wrq->fixed = 1;
1150
1151 return 0;
1152}
1153
1154/*
1155 * Wireless Handler : set fragment threshold
1156 */
1157
1158int iwctl_siwfrag(struct net_device *dev,
1159 struct iw_request_info *info,
1160 struct iw_param *wrq,
1161 char *extra)
1162{
Forest Bond1e28efa2009-06-13 07:38:50 -04001163 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001164 int rc = 0;
1165 int fthr = wrq->value;
1166
1167
1168 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
1169
1170
1171 if (wrq->disabled)
1172 fthr = 2312;
1173 if((fthr < 256) || (fthr > 2312)) {
1174 rc = -EINVAL;
1175 }else {
1176 fthr &= ~0x1; // Get an even value
1177 pDevice->wFragmentationThreshold = (u16)fthr;
1178 }
1179
1180 return rc;
1181}
1182
1183/*
1184 * Wireless Handler : get fragment threshold
1185 */
1186
1187int iwctl_giwfrag(struct net_device *dev,
1188 struct iw_request_info *info,
1189 struct iw_param *wrq,
1190 char *extra)
1191{
Forest Bond1e28efa2009-06-13 07:38:50 -04001192 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001193
1194 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1195 wrq->value = pDevice->wFragmentationThreshold;
1196 wrq->disabled = (wrq->value >= 2312);
1197 wrq->fixed = 1;
1198
1199 return 0;
1200}
1201
1202
1203
1204/*
1205 * Wireless Handler : set retry threshold
1206 */
1207int iwctl_siwretry(struct net_device *dev,
1208 struct iw_request_info *info,
1209 struct iw_param *wrq,
1210 char *extra)
1211{
Forest Bond1e28efa2009-06-13 07:38:50 -04001212 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001213 int rc = 0;
1214
1215
1216 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1217
1218 if (wrq->disabled) {
1219 rc = -EINVAL;
1220 return rc;
1221 }
1222
1223 if (wrq->flags & IW_RETRY_LIMIT) {
1224 if(wrq->flags & IW_RETRY_MAX)
1225 pDevice->byLongRetryLimit = wrq->value;
1226 else if (wrq->flags & IW_RETRY_MIN)
1227 pDevice->byShortRetryLimit = wrq->value;
1228 else {
1229 // No modifier : set both
1230 pDevice->byShortRetryLimit = wrq->value;
1231 pDevice->byLongRetryLimit = wrq->value;
1232 }
1233 }
1234 if (wrq->flags & IW_RETRY_LIFETIME) {
1235 pDevice->wMaxTransmitMSDULifetime = wrq->value;
1236 }
1237
1238
1239 return rc;
1240}
1241
1242/*
1243 * Wireless Handler : get retry threshold
1244 */
1245int iwctl_giwretry(struct net_device *dev,
1246 struct iw_request_info *info,
1247 struct iw_param *wrq,
1248 char *extra)
1249{
Forest Bond1e28efa2009-06-13 07:38:50 -04001250 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001251 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1252 wrq->disabled = 0; // Can't be disabled
1253
1254 // Note : by default, display the min retry number
1255 if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1256 wrq->flags = IW_RETRY_LIFETIME;
1257 wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
1258 } else if((wrq->flags & IW_RETRY_MAX)) {
1259 wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1260 wrq->value = (int)pDevice->byLongRetryLimit;
1261 } else {
1262 wrq->flags = IW_RETRY_LIMIT;
1263 wrq->value = (int)pDevice->byShortRetryLimit;
1264 if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
1265 wrq->flags |= IW_RETRY_MIN;
1266 }
1267
1268
1269 return 0;
1270}
1271
1272
1273/*
1274 * Wireless Handler : set encode mode
1275 */
1276int iwctl_siwencode(struct net_device *dev,
1277 struct iw_request_info *info,
1278 struct iw_point *wrq,
1279 char *extra)
1280{
Forest Bond1e28efa2009-06-13 07:38:50 -04001281 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001282 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1283 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1284 int ii,uu, rc = 0;
1285 int index = (wrq->flags & IW_ENCODE_INDEX);
1286
1287
1288 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1289
1290 // Check the size of the key
1291 if (wrq->length > WLAN_WEP232_KEYLEN) {
1292 rc = -EINVAL;
1293 return rc;
1294 }
1295
1296 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1297 rc = -EINVAL;
1298 return rc;
1299 }
1300
1301 if (dwKeyIndex > 0)
1302 dwKeyIndex--;
1303
1304 // Send the key to the card
1305 if (wrq->length > 0) {
1306
1307 if (wrq->length == WLAN_WEP232_KEYLEN) {
1308 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1309 }
1310 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1311 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1312 }
1313 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1314 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1315 }
1316 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1317 memcpy(pDevice->abyKey, extra, wrq->length);
1318
1319 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1320 for (ii = 0; ii < wrq->length; ii++) {
1321 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1322 }
1323
1324 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1325 spin_lock_irq(&pDevice->lock);
1326 KeybSetDefaultKey( pDevice,
1327 &(pDevice->sKey),
1328 dwKeyIndex | (1 << 31),
1329 wrq->length,
1330 NULL,
1331 pDevice->abyKey,
1332 KEY_CTL_WEP
1333 );
1334 spin_unlock_irq(&pDevice->lock);
1335 }
1336 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1337 pDevice->uKeyLength = wrq->length;
1338 pDevice->bTransmitKey = TRUE;
1339 pDevice->bEncryptionEnable = TRUE;
1340 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1341
1342 // Do we want to just set the transmit key index ?
1343 if ( index < 4 ) {
1344 pDevice->byKeyIndex = index;
Julia Lawall2e9ab1e2009-07-27 21:59:48 +02001345 } else if (!(wrq->flags & IW_ENCODE_MODE)) {
Forest Bond92b96792009-06-13 07:38:31 -04001346 rc = -EINVAL;
1347 return rc;
1348 }
1349 }
1350 // Read the flags
1351 if(wrq->flags & IW_ENCODE_DISABLED){
1352
1353 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1354 pMgmt->bShareKeyAlgorithm = FALSE;
1355 pDevice->bEncryptionEnable = FALSE;
1356 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1357 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1358 spin_lock_irq(&pDevice->lock);
Andres More33d33e422010-05-19 23:50:00 -03001359 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
1360 MACvDisableKeyEntry(pDevice, uu);
Forest Bond92b96792009-06-13 07:38:31 -04001361 spin_unlock_irq(&pDevice->lock);
1362 }
1363 }
1364 if(wrq->flags & IW_ENCODE_RESTRICTED) {
1365 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1366 pMgmt->bShareKeyAlgorithm = TRUE;
1367 }
1368 if(wrq->flags & IW_ENCODE_OPEN) {
1369 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1370 pMgmt->bShareKeyAlgorithm = FALSE;
1371 }
1372
1373#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1374 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1375#endif
1376
1377 return rc;
1378}
1379
1380/*
1381 * Wireless Handler : get encode mode
1382 */
1383//2008-0409-06, <Mark> by Einsn Liu
1384 /*
1385int iwctl_giwencode(struct net_device *dev,
1386 struct iw_request_info *info,
1387 struct iw_point *wrq,
1388 char *extra)
1389{
Forest Bond1e28efa2009-06-13 07:38:50 -04001390 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001391 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1392 int rc = 0;
1393 char abyKey[WLAN_WEP232_KEYLEN];
Andres Morecc856e62010-05-17 21:34:01 -03001394 unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
Forest Bond92b96792009-06-13 07:38:31 -04001395 PSKeyItem pKey = NULL;
1396
1397 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1398
1399
1400 memset(abyKey, 0, sizeof(abyKey));
1401 // Check encryption mode
1402 wrq->flags = IW_ENCODE_NOKEY;
1403 // Is WEP enabled ???
1404 if (pDevice->bEncryptionEnable)
1405 wrq->flags |= IW_ENCODE_ENABLED;
1406 else
1407 wrq->flags |= IW_ENCODE_DISABLED;
1408
1409 if (pMgmt->bShareKeyAlgorithm)
1410 wrq->flags |= IW_ENCODE_RESTRICTED;
1411 else
1412 wrq->flags |= IW_ENCODE_OPEN;
1413
1414 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1415 wrq->length = pKey->uKeyLength;
1416 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1417 }
1418 else {
1419 rc = -EINVAL;
1420 return rc;
1421 }
1422 wrq->flags |= index;
1423 // Copy the key to the user buffer
1424 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1425 return 0;
1426}
1427*/
1428
1429//2008-0409-06, <Add> by Einsn Liu
1430
1431int iwctl_giwencode(struct net_device *dev,
1432 struct iw_request_info *info,
1433 struct iw_point *wrq,
1434 char *extra)
1435{
Forest Bond1e28efa2009-06-13 07:38:50 -04001436 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001437 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1438 char abyKey[WLAN_WEP232_KEYLEN];
1439
Andres Morecc856e62010-05-17 21:34:01 -03001440 unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
Forest Bond92b96792009-06-13 07:38:31 -04001441 PSKeyItem pKey = NULL;
1442
1443 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1444
1445 if (index > WLAN_WEP_NKEYS) {
1446 return -EINVAL;
1447 }
1448 if(index<1){//get default key
1449 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1450 index=pDevice->byKeyIndex;
1451 } else
1452 index=0;
1453 }else
1454 index--;
1455
1456 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1457 // Check encryption mode
1458 wrq->flags = IW_ENCODE_NOKEY;
1459 // Is WEP enabled ???
1460 if (pDevice->bEncryptionEnable)
1461 wrq->flags |= IW_ENCODE_ENABLED;
1462 else
1463 wrq->flags |= IW_ENCODE_DISABLED;
1464
1465 if (pMgmt->bShareKeyAlgorithm)
1466 wrq->flags |= IW_ENCODE_RESTRICTED;
1467 else
1468 wrq->flags |= IW_ENCODE_OPEN;
1469 wrq->length=0;
1470
1471 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1472 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1473 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1474 wrq->length = pKey->uKeyLength;
1475 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1476 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1477 }
1478 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1479 wrq->length = pKey->uKeyLength;
1480 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1481 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1482 }
1483
1484 wrq->flags |= index+1;
1485
1486 return 0;
1487}
1488
1489
1490/*
1491 * Wireless Handler : set power mode
1492 */
1493int iwctl_siwpower(struct net_device *dev,
1494 struct iw_request_info *info,
1495 struct iw_param *wrq,
1496 char *extra)
1497{
Forest Bond1e28efa2009-06-13 07:38:50 -04001498 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001499 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1500 int rc = 0;
1501
1502 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1503
1504 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1505 rc = -EINVAL;
1506 return rc;
1507 }
1508
1509 if (wrq->disabled) {
1510 pDevice->ePSMode = WMAC_POWER_CAM;
1511 PSvDisablePowerSaving(pDevice);
1512 return rc;
1513 }
1514 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1515 pDevice->ePSMode = WMAC_POWER_FAST;
Andres More0cbd8d92010-05-06 20:34:29 -03001516 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
Forest Bond92b96792009-06-13 07:38:31 -04001517
1518 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1519 pDevice->ePSMode = WMAC_POWER_FAST;
Andres More0cbd8d92010-05-06 20:34:29 -03001520 PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
Forest Bond92b96792009-06-13 07:38:31 -04001521 }
1522 switch (wrq->flags & IW_POWER_MODE) {
1523 case IW_POWER_UNICAST_R:
1524 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1525 rc = -EINVAL;
1526 break;
1527 case IW_POWER_ALL_R:
1528 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1529 rc = -EINVAL;
1530 case IW_POWER_ON:
1531 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1532 break;
1533 default:
1534 rc = -EINVAL;
1535 }
1536
1537 return rc;
1538}
1539
1540/*
1541 * Wireless Handler : get power mode
1542 */
1543int iwctl_giwpower(struct net_device *dev,
1544 struct iw_request_info *info,
1545 struct iw_param *wrq,
1546 char *extra)
1547{
Forest Bond1e28efa2009-06-13 07:38:50 -04001548 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001549 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1550 int mode = pDevice->ePSMode;
1551
1552
1553 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1554
1555
1556 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1557 return 0;
1558
1559 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1560 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1561 wrq->flags = IW_POWER_TIMEOUT;
1562 } else {
1563 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1564 wrq->flags = IW_POWER_PERIOD;
1565 }
1566 wrq->flags |= IW_POWER_ALL_R;
1567
1568 return 0;
1569}
1570
1571
1572/*
1573 * Wireless Handler : get Sensitivity
1574 */
1575int iwctl_giwsens(struct net_device *dev,
1576 struct iw_request_info *info,
1577 struct iw_param *wrq,
1578 char *extra)
1579{
Forest Bond1e28efa2009-06-13 07:38:50 -04001580 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001581 long ldBm;
1582
1583 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1584 if (pDevice->bLinkPass == TRUE) {
1585 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1586 wrq->value = ldBm;
1587 }
1588 else {
1589 wrq->value = 0;
1590 };
1591 wrq->disabled = (wrq->value == 0);
1592 wrq->fixed = 1;
1593
1594
1595 return 0;
1596}
1597
1598//2008-0409-07, <Add> by Einsn Liu
1599#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1600
1601int iwctl_siwauth(struct net_device *dev,
1602 struct iw_request_info *info,
1603 struct iw_param *wrq,
1604 char *extra)
1605{
Forest Bond1e28efa2009-06-13 07:38:50 -04001606 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001607 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1608 int ret=0;
1609 static int wpa_version=0; //must be static to save the last value,einsn liu
1610 static int pairwise=0;
1611
1612 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1613 switch (wrq->flags & IW_AUTH_INDEX) {
1614 case IW_AUTH_WPA_VERSION:
1615 wpa_version = wrq->value;
1616 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1617 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1618 //pDevice->bWPADEVUp = FALSE;
1619 }
1620 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1621 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1622 }
1623 else {
1624 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1625 }
1626 //pDevice->bWPASuppWextEnabled =TRUE;
1627 break;
1628 case IW_AUTH_CIPHER_PAIRWISE:
1629 pairwise = wrq->value;
1630 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
1631 if(pairwise == IW_AUTH_CIPHER_CCMP){
1632 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1633 }else if(pairwise == IW_AUTH_CIPHER_TKIP){
1634 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1635 }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
1636 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1637 }else if(pairwise == IW_AUTH_CIPHER_NONE){
1638 //do nothing,einsn liu
1639 }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1640
1641 break;
1642 case IW_AUTH_CIPHER_GROUP:
1643 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
1644 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1645 break;
1646 if(pairwise == IW_AUTH_CIPHER_NONE){
1647 if(wrq->value == IW_AUTH_CIPHER_CCMP){
1648 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1649 }else {
1650 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1651 }
1652 }
1653 break;
1654 case IW_AUTH_KEY_MGMT:
1655 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
1656 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1657 if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1658 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
1659 else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
1660 }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
1661 if(wrq->value == 0){
1662 pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
1663 }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1664 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
1665 else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
1666 }
1667
1668 break;
1669 case IW_AUTH_TKIP_COUNTERMEASURES:
1670 break; /* FIXME */
1671 case IW_AUTH_DROP_UNENCRYPTED:
1672 break;
1673 case IW_AUTH_80211_AUTH_ALG:
1674 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
1675 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1676 pMgmt->bShareKeyAlgorithm=FALSE;
1677 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
1678 pMgmt->bShareKeyAlgorithm=TRUE;
1679 }
1680 break;
1681 case IW_AUTH_WPA_ENABLED:
1682 //pDevice->bWPADEVUp = !! wrq->value;
1683 //if(pDevice->bWPADEVUp==TRUE)
André Goddard Rosabbc9a992009-11-14 13:09:06 -02001684 // printk("iwctl_siwauth:set WPADEV to enable successful*******\n");
Forest Bond92b96792009-06-13 07:38:31 -04001685 //else
1686 // printk("iwctl_siwauth:set WPADEV to enable fail?????\n");
1687 break;
1688 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1689 break;
1690 case IW_AUTH_ROAMING_CONTROL:
1691 ret = -EOPNOTSUPP;
1692 break;
1693 case IW_AUTH_PRIVACY_INVOKED:
1694 pDevice->bEncryptionEnable = !!wrq->value;
1695 if(pDevice->bEncryptionEnable == FALSE){
1696 wpa_version = 0;
1697 pairwise = 0;
1698 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1699 pMgmt->bShareKeyAlgorithm = FALSE;
1700 pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
1701 //pDevice->bWPADEVUp = FALSE;
1702 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
1703 }
1704
1705 break;
1706 default:
1707 ret = -EOPNOTSUPP;
1708 break;
1709 }
1710/*
1711 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1712 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1713 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1714 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1715 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1716 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1717 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADEVUp = %s\n",pDevice->bWPADEVUp?"TRUE":"FALSE");
1718*/
1719 return ret;
1720}
1721
1722
1723int iwctl_giwauth(struct net_device *dev,
1724 struct iw_request_info *info,
1725 struct iw_param *wrq,
1726 char *extra)
1727{
1728 return -EOPNOTSUPP;
1729}
1730
1731
1732
1733int iwctl_siwgenie(struct net_device *dev,
1734 struct iw_request_info *info,
1735 struct iw_point *wrq,
1736 char *extra)
1737{
Forest Bond1e28efa2009-06-13 07:38:50 -04001738 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001739 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1740 int ret=0;
1741
1742 if(wrq->length){
1743 if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
1744 ret = -EINVAL;
1745 goto out;
1746 }
1747 if(wrq->length > MAX_WPA_IE_LEN){
1748 ret = -ENOMEM;
1749 goto out;
1750 }
1751 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1752 if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
1753 ret = -EFAULT;
1754 goto out;
1755 }
1756 pMgmt->wWPAIELen = wrq->length;
1757 }else {
1758 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1759 pMgmt->wWPAIELen = 0;
1760 }
1761
1762 out://not completely ...not necessary in wpa_supplicant 0.5.8
1763 return 0;
1764}
1765
1766int iwctl_giwgenie(struct net_device *dev,
1767 struct iw_request_info *info,
1768 struct iw_point *wrq,
1769 char *extra)
1770{
Forest Bond1e28efa2009-06-13 07:38:50 -04001771 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001772 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1773 int ret=0;
1774 int space = wrq->length;
1775
1776 wrq->length = 0;
1777 if(pMgmt->wWPAIELen > 0){
1778 wrq->length = pMgmt->wWPAIELen;
1779 if(pMgmt->wWPAIELen <= space){
1780 if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
1781 ret = -EFAULT;
1782 }
1783 }else
1784 ret = -E2BIG;
1785 }
1786
1787 return ret;
1788}
1789
1790
1791int iwctl_siwencodeext(struct net_device *dev,
1792 struct iw_request_info *info,
1793 struct iw_point *wrq,
1794 char *extra)
1795{
Forest Bond1e28efa2009-06-13 07:38:50 -04001796 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001797 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1798 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
1799 struct viawget_wpa_param *param=NULL;
1800//original member
1801 wpa_alg alg_name;
1802 u8 addr[6];
1803 int key_idx, set_tx=0;
1804 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
1805 u8 key[64];
1806 size_t seq_len=0,key_len=0;
1807//
1808 // int ii;
1809 u8 *buf;
1810 size_t blen;
1811 u8 key_array[64];
1812 int ret=0;
1813
1814PRINT_K("SIOCSIWENCODEEXT...... \n");
1815
1816blen = sizeof(*param);
1817buf = kmalloc((int)blen, (int)GFP_KERNEL);
1818if (buf == NULL)
1819 return -ENOMEM;
1820memset(buf, 0, blen);
1821param = (struct viawget_wpa_param *) buf;
1822
1823//recover alg_name
1824switch (ext->alg) {
1825 case IW_ENCODE_ALG_NONE:
1826 alg_name = WPA_ALG_NONE;
1827 break;
1828 case IW_ENCODE_ALG_WEP:
1829 alg_name = WPA_ALG_WEP;
1830 break;
1831 case IW_ENCODE_ALG_TKIP:
1832 alg_name = WPA_ALG_TKIP;
1833 break;
1834 case IW_ENCODE_ALG_CCMP:
1835 alg_name = WPA_ALG_CCMP;
1836 break;
1837 default:
1838 PRINT_K("Unknown alg = %d\n",ext->alg);
1839 ret= -ENOMEM;
1840 goto error;
1841 }
1842//recover addr
1843 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
1844//recover key_idx
1845 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
1846//recover set_tx
1847if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
1848 set_tx = 1;
1849//recover seq,seq_len
1850 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
1851 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
1852 memcpy(seq, ext->rx_seq, seq_len);
1853 }
1854//recover key,key_len
1855if(ext->key_len) {
1856 key_len=ext->key_len;
1857 memcpy(key, &ext->key[0], key_len);
1858 }
1859
1860memset(key_array, 0, 64);
1861if ( key_len > 0) {
1862 memcpy(key_array, key, key_len);
1863 if (key_len == 32) {
1864 // notice ! the oder
1865 memcpy(&key_array[16], &key[24], 8);
1866 memcpy(&key_array[24], &key[16], 8);
1867 }
1868 }
1869
1870/**************Translate iw_encode_ext to viawget_wpa_param****************/
1871memcpy(param->addr, addr, ETH_ALEN);
1872param->u.wpa_key.alg_name = (int)alg_name;
1873param->u.wpa_key.set_tx = set_tx;
1874param->u.wpa_key.key_index = key_idx;
1875param->u.wpa_key.key_len = key_len;
1876param->u.wpa_key.key = (u8 *)key_array;
1877param->u.wpa_key.seq = (u8 *)seq;
1878param->u.wpa_key.seq_len = seq_len;
1879
Forest Bond92b96792009-06-13 07:38:31 -04001880//****set if current action is Network Manager count??
1881//****this method is so foolish,but there is no other way???
1882if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
1883 if(param->u.wpa_key.key_index ==0) {
1884 pDevice->bwextstep0 = TRUE;
1885 }
1886 if((pDevice->bwextstep0 = TRUE)&&(param->u.wpa_key.key_index ==1)) {
1887 pDevice->bwextstep0 = FALSE;
1888 pDevice->bwextstep1 = TRUE;
1889 }
1890 if((pDevice->bwextstep1 = TRUE)&&(param->u.wpa_key.key_index ==2)) {
1891 pDevice->bwextstep1 = FALSE;
1892 pDevice->bwextstep2 = TRUE;
1893 }
1894 if((pDevice->bwextstep2 = TRUE)&&(param->u.wpa_key.key_index ==3)) {
1895 pDevice->bwextstep2 = FALSE;
1896 pDevice->bwextstep3 = TRUE;
1897 }
1898 }
1899if(pDevice->bwextstep3 == TRUE) {
1900 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
1901 pDevice->bwextstep0 = FALSE;
1902 pDevice->bwextstep1 = FALSE;
1903 pDevice->bwextstep2 = FALSE;
1904 pDevice->bwextstep3 = FALSE;
1905 pDevice->bWPASuppWextEnabled = TRUE;
1906 memset(pMgmt->abyDesireBSSID, 0xFF,6);
1907 KeyvInitTable(pDevice,&pDevice->sKey);
1908 }
1909//******
1910
1911 spin_lock_irq(&pDevice->lock);
1912 ret = wpa_set_keys(pDevice, param, TRUE);
1913 spin_unlock_irq(&pDevice->lock);
1914
1915error:
1916kfree(param);
1917 return ret;
1918}
1919
1920
1921
1922int iwctl_giwencodeext(struct net_device *dev,
1923 struct iw_request_info *info,
1924 struct iw_point *wrq,
1925 char *extra)
1926{
1927 return -EOPNOTSUPP;;
1928}
1929
1930int iwctl_siwmlme(struct net_device *dev,
1931 struct iw_request_info * info,
1932 struct iw_point *wrq,
1933 char *extra)
1934{
Forest Bond1e28efa2009-06-13 07:38:50 -04001935 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001936 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1937 struct iw_mlme *mlme = (struct iw_mlme *)extra;
1938 //u16 reason = cpu_to_le16(mlme->reason_code);
1939 int ret = 0;
1940
1941 if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
1942 ret = -EINVAL;
1943 return ret;
1944 }
1945 switch(mlme->cmd){
1946 case IW_MLME_DEAUTH:
1947 //this command seems to be not complete,please test it --einsnliu
1948 //printk("iwctl_siwmlme--->send DEAUTH\n");
Andres More0cbd8d92010-05-06 20:34:29 -03001949 /* bScheduleCommand((void *) pDevice,
1950 WLAN_CMD_DEAUTH,
1951 (PBYTE)&reason); */
Forest Bond92b96792009-06-13 07:38:31 -04001952 //break;
1953 case IW_MLME_DISASSOC:
1954 if(pDevice->bLinkPass == TRUE){
1955 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
Andres More0cbd8d92010-05-06 20:34:29 -03001956 bScheduleCommand((void *) pDevice,
1957 WLAN_CMD_DISASSOCIATE,
1958 NULL);
Forest Bond92b96792009-06-13 07:38:31 -04001959 }
1960 break;
1961 default:
1962 ret = -EOPNOTSUPP;
1963 }
1964
1965 return ret;
1966
1967}
1968
1969#endif
1970//End Add --//2008-0409-07, <Add> by Einsn Liu
1971
1972
1973
1974/*------------------------------------------------------------------*/
1975/*
1976 * Structures to export the Wireless Handlers
1977 */
1978
1979
Forest Bond92b96792009-06-13 07:38:31 -04001980/*
1981static const iw_handler iwctl_handler[] =
1982{
1983 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
1984 (iw_handler) iwctl_giwname, // SIOCGIWNAME
1985 (iw_handler) NULL, // SIOCSIWNWID
1986 (iw_handler) NULL, // SIOCGIWNWID
1987 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
1988 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
1989 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
1990 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
1991 (iw_handler) NULL, // SIOCSIWSENS
1992 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
1993 (iw_handler) NULL, // SIOCSIWRANGE
1994 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
1995 (iw_handler) NULL, // SIOCSIWPRIV
1996 (iw_handler) NULL, // SIOCGIWPRIV
1997 (iw_handler) NULL, // SIOCSIWSTATS
1998 (iw_handler) NULL, // SIOCGIWSTATS
1999 (iw_handler) NULL, // SIOCSIWSPY
2000 (iw_handler) NULL, // SIOCGIWSPY
2001 (iw_handler) NULL, // -- hole --
2002 (iw_handler) NULL, // -- hole --
2003 (iw_handler) iwctl_siwap, // SIOCSIWAP
2004 (iw_handler) iwctl_giwap, // SIOCGIWAP
2005 (iw_handler) NULL, // -- hole -- 0x16
2006 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
Forest Bond92b96792009-06-13 07:38:31 -04002007 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2008 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
Forest Bond92b96792009-06-13 07:38:31 -04002009 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2010 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2011 (iw_handler) NULL, // SIOCSIWNICKN
2012 (iw_handler) NULL, // SIOCGIWNICKN
2013 (iw_handler) NULL, // -- hole --
2014 (iw_handler) NULL, // -- hole --
2015 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2016 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2017 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2018 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2019 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2020 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2021 (iw_handler) NULL, // SIOCSIWTXPOW
2022 (iw_handler) NULL, // SIOCGIWTXPOW
2023 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2024 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2025 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2026 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2027 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2028 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
Forest Bond92b96792009-06-13 07:38:31 -04002029 (iw_handler) NULL, // -- hole --
2030 (iw_handler) NULL, // -- hole --
2031 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2032 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2033 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2034 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2035 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2036 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2037 (iw_handler) NULL, // SIOCSIWPMKSA
2038 (iw_handler) NULL, // -- hole --
Forest Bond92b96792009-06-13 07:38:31 -04002039
2040};
2041*/
2042
2043static const iw_handler iwctl_handler[] =
2044{
2045 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2046 (iw_handler) NULL, // SIOCGIWNAME
2047 (iw_handler) NULL, // SIOCSIWNWID
2048 (iw_handler) NULL, // SIOCGIWNWID
2049 (iw_handler) NULL, // SIOCSIWFREQ
2050 (iw_handler) NULL, // SIOCGIWFREQ
2051 (iw_handler) NULL, // SIOCSIWMODE
2052 (iw_handler) NULL, // SIOCGIWMODE
2053 (iw_handler) NULL, // SIOCSIWSENS
2054 (iw_handler) NULL, // SIOCGIWSENS
2055 (iw_handler) NULL, // SIOCSIWRANGE
2056 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2057 (iw_handler) NULL, // SIOCSIWPRIV
2058 (iw_handler) NULL, // SIOCGIWPRIV
2059 (iw_handler) NULL, // SIOCSIWSTATS
2060 (iw_handler) NULL, // SIOCGIWSTATS
2061 (iw_handler) NULL, // SIOCSIWSPY
2062 (iw_handler) NULL, // SIOCGIWSPY
2063 (iw_handler) NULL, // -- hole --
2064 (iw_handler) NULL, // -- hole --
2065 (iw_handler) NULL, // SIOCSIWAP
2066 (iw_handler) NULL, // SIOCGIWAP
2067 (iw_handler) NULL, // -- hole -- 0x16
2068 (iw_handler) NULL, // SIOCGIWAPLIST
Forest Bond92b96792009-06-13 07:38:31 -04002069 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2070 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
Forest Bond92b96792009-06-13 07:38:31 -04002071 (iw_handler) NULL, // SIOCSIWESSID
2072 (iw_handler) NULL, // SIOCGIWESSID
2073 (iw_handler) NULL, // SIOCSIWNICKN
2074 (iw_handler) NULL, // SIOCGIWNICKN
2075 (iw_handler) NULL, // -- hole --
2076 (iw_handler) NULL, // -- hole --
2077 (iw_handler) NULL, // SIOCSIWRATE 0x20
2078 (iw_handler) NULL, // SIOCGIWRATE
2079 (iw_handler) NULL, // SIOCSIWRTS
2080 (iw_handler) NULL, // SIOCGIWRTS
2081 (iw_handler) NULL, // SIOCSIWFRAG
2082 (iw_handler) NULL, // SIOCGIWFRAG
2083 (iw_handler) NULL, // SIOCSIWTXPOW
2084 (iw_handler) NULL, // SIOCGIWTXPOW
2085 (iw_handler) NULL, // SIOCSIWRETRY
2086 (iw_handler) NULL, // SIOCGIWRETRY
2087 (iw_handler) NULL, // SIOCSIWENCODE
2088 (iw_handler) NULL, // SIOCGIWENCODE
2089 (iw_handler) NULL, // SIOCSIWPOWER
2090 (iw_handler) NULL, // SIOCGIWPOWER
Forest Bond92b96792009-06-13 07:38:31 -04002091 (iw_handler) NULL, // -- hole --
2092 (iw_handler) NULL, // -- hole --
2093 (iw_handler) NULL, // SIOCSIWGENIE
2094 (iw_handler) NULL, // SIOCGIWGENIE
2095 (iw_handler) NULL, // SIOCSIWAUTH
2096 (iw_handler) NULL, // SIOCGIWAUTH
2097 (iw_handler) NULL, // SIOCSIWENCODEEXT
2098 (iw_handler) NULL, // SIOCGIWENCODEEXT
2099 (iw_handler) NULL, // SIOCSIWPMKSA
2100 (iw_handler) NULL, // -- hole --
Forest Bond92b96792009-06-13 07:38:31 -04002101};
2102
2103
2104static const iw_handler iwctl_private_handler[] =
2105{
2106 NULL, // SIOCIWFIRSTPRIV
2107};
2108
2109
2110struct iw_priv_args iwctl_private_args[] = {
2111{ IOCTL_CMD_SET,
2112 IW_PRIV_TYPE_CHAR | 1024, 0,
2113 "set"},
2114};
2115
2116
2117
2118const struct iw_handler_def iwctl_handler_def =
2119{
Forest Bond92b96792009-06-13 07:38:31 -04002120 .get_wireless_stats = &iwctl_get_wireless_stats,
Forest Bond92b96792009-06-13 07:38:31 -04002121 .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
2122// .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2123// .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2124 .num_private = 0,
2125 .num_private_args = 0,
2126 .standard = (iw_handler *) iwctl_handler,
2127// .private = (iw_handler *) iwctl_private_handler,
2128// .private_args = (struct iw_priv_args *)iwctl_private_args,
2129 .private = NULL,
2130 .private_args = NULL,
2131};