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