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