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