2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
21 * Purpose: wireless ext & ioctl functions
34 #if !defined(__DEVICE_H__)
37 #if !defined(__IOCTL_H__)
40 #if !defined(__IOCMD_H__)
43 #if !defined(__MAC_H__)
46 #if !defined(__CARD_H__)
49 #if !defined(__HOSTAP_H__)
52 #if !defined(__UMEM_H__)
55 #if !defined(__POWER_H__)
58 #if !defined(__RF_H__)
62 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
63 #if !defined(__IOWPA_H__)
66 #if !defined(__WPACTL_H__)
72 #include <net/iw_handler.h>
74 extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
76 /*--------------------- Static Definitions -------------------------*/
78 //2008-0409-07, <Add> by Einsn Liu
79 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
80 #define SUPPORTED_WIRELESS_EXT 18
82 #define SUPPORTED_WIRELESS_EXT 17
87 static const long frequency_list[] = {
88 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
89 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
90 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
91 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
92 5700, 5745, 5765, 5785, 5805, 5825
98 /*--------------------- Static Classes ----------------------------*/
101 //static int msglevel =MSG_LEVEL_DEBUG;
102 static int msglevel =MSG_LEVEL_INFO;
105 /*--------------------- Static Variables --------------------------*/
106 /*--------------------- Static Functions --------------------------*/
108 /*--------------------- Export Variables --------------------------*/
112 #if WIRELESS_EXT > 12
114 struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
116 PSDevice pDevice = netdev_priv(dev);
118 pDevice->wstats.status = pDevice->eOPMode;
119 #ifdef Calcu_LinkQual
121 if(pDevice->byBBType == BB_TYPE_11B) {
122 if(pDevice->byCurrSQ > 120)
123 pDevice->scStatistic.LinkQuality = 100;
125 pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
127 else if(pDevice->byBBType == BB_TYPE_11G) {
128 if(pDevice->byCurrSQ < 20)
129 pDevice->scStatistic.LinkQuality = 100;
130 else if(pDevice->byCurrSQ >96)
131 pDevice->scStatistic.LinkQuality = 0;
133 pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
135 if(pDevice->bLinkPass !=TRUE)
136 pDevice->scStatistic.LinkQuality = 0;
138 if(pDevice->scStatistic.LinkQuality > 100)
139 pDevice->scStatistic.LinkQuality = 100;
140 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
142 pDevice->wstats.qual.qual = pDevice->byCurrSQ;
144 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
145 pDevice->wstats.qual.level = ldBm;
146 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
147 pDevice->wstats.qual.noise = 0;
148 pDevice->wstats.qual.updated = 1;
149 pDevice->wstats.discard.nwid = 0;
150 pDevice->wstats.discard.code = 0;
151 pDevice->wstats.discard.fragment = 0;
152 pDevice->wstats.discard.retries = (U32)pDevice->scStatistic.dwTsrErr;
153 pDevice->wstats.discard.misc = 0;
154 pDevice->wstats.miss.beacon = 0;
156 return &pDevice->wstats;
163 /*------------------------------------------------------------------*/
166 static int iwctl_commit(struct net_device *dev,
167 struct iw_request_info *info,
171 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
178 * Wireless Handler : get protocol name
181 int iwctl_giwname(struct net_device *dev,
182 struct iw_request_info *info,
186 strcpy(wrq, "802.11-a/b/g");
190 int iwctl_giwnwid(struct net_device *dev,
191 struct iw_request_info *info,
192 struct iw_param *wrq,
195 //wrq->value = 0x100;
201 #if WIRELESS_EXT > 13
204 * Wireless Handler : set scan
207 int iwctl_siwscan(struct net_device *dev,
208 struct iw_request_info *info,
209 struct iw_point *wrq,
212 PSDevice pDevice = (PSDevice)netdev_priv(dev);
213 struct iw_scan_req *req = (struct iw_scan_req *)extra;
214 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
215 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
216 PWLAN_IE_SSID pItemSSID=NULL;
217 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSCAN \n");
220 if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
221 //send scan event to wpa_Supplicant
222 union iwreq_data wrqu;
223 printk("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
224 memset(&wrqu, 0, sizeof(wrqu));
225 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
229 spin_lock_irq(&pDevice->lock);
230 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
232 //mike add: active scan OR passive scan OR desire_ssid scan
233 if(wrq->length == sizeof(struct iw_scan_req)) {
234 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
235 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
236 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
237 pItemSSID->byElementID = WLAN_EID_SSID;
238 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
239 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
241 pItemSSID->len = req->essid_len - 1;
244 pItemSSID->len = req->essid_len;
245 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
246 printk("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
247 ((PWLAN_IE_SSID)abyScanSSID)->len);
248 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
249 spin_unlock_irq(&pDevice->lock);
253 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
254 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
258 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
261 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
262 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
263 spin_unlock_irq(&pDevice->lock);
270 * Wireless Handler : get scan results
273 int iwctl_giwscan(struct net_device *dev,
274 struct iw_request_info *info,
275 struct iw_point *wrq,
279 PSDevice pDevice = (PSDevice)netdev_priv(dev);
280 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
282 PWLAN_IE_SSID pItemSSID;
283 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
284 char *current_ev = extra;
285 char *end_buf = extra + IW_SCAN_MAX_DATA;
286 char *current_val = NULL;
289 #if WIRELESS_EXT > 14
290 char buf[MAX_WPA_IE_LEN * 2 + 30];
291 #endif /* WIRELESS_EXT > 14 */
294 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
296 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
300 pBSS = &(pMgmt->sBSSList[0]);
301 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
302 if (current_ev >= end_buf)
304 pBSS = &(pMgmt->sBSSList[jj]);
306 memset(&iwe, 0, sizeof(iwe));
308 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
309 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
310 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
312 memset(&iwe, 0, sizeof(iwe));
313 iwe.cmd = SIOCGIWESSID;
314 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
315 iwe.u.data.length = pItemSSID->len;
316 iwe.u.data.flags = 1;
317 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
319 memset(&iwe, 0, sizeof(iwe));
320 iwe.cmd = SIOCGIWMODE;
321 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
322 iwe.u.mode = IW_MODE_INFRA;
325 iwe.u.mode = IW_MODE_ADHOC;
327 iwe.len = IW_EV_UINT_LEN;
328 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
330 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
331 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
332 memset(&iwe, 0, sizeof(iwe));
333 iwe.cmd = SIOCGIWFREQ;
334 iwe.u.freq.m = pBSS->uChannel;
337 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
340 //2008-0409-04, <Add> by Einsn Liu
342 int f = (int)pBSS->uChannel - 1;
344 iwe.u.freq.m = frequency_list[f] * 100000;
347 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
349 memset(&iwe, 0, sizeof(iwe));
351 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
352 iwe.u.qual.level = ldBm;
353 iwe.u.qual.noise = 0;
354 //2008-0409-01, <Add> by Einsn Liu
356 iwe.u.qual.qual = 100;
357 }else if(-ldBm > 90) {
360 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
362 iwe.u.qual.updated=7;
364 // iwe.u.qual.qual = 0;
365 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
367 memset(&iwe, 0, sizeof(iwe));
368 iwe.cmd = SIOCGIWENCODE;
369 iwe.u.data.length = 0;
370 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
371 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
373 iwe.u.data.flags = IW_ENCODE_DISABLED;
375 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
377 memset(&iwe, 0, sizeof(iwe));
378 iwe.cmd = SIOCGIWRATE;
379 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
380 current_val = current_ev + IW_EV_LCP_LEN;
382 for (kk = 0 ; kk < 12 ; kk++) {
383 if (pSuppRates->abyRates[kk] == 0)
385 // Bit rate given in 500 kb/s units (+ 0x80)
386 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
387 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
389 for (kk = 0 ; kk < 8 ; kk++) {
390 if (pExtSuppRates->abyRates[kk] == 0)
392 // Bit rate given in 500 kb/s units (+ 0x80)
393 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
394 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
397 if((current_val - current_ev) > IW_EV_LCP_LEN)
398 current_ev = current_val;
400 #if WIRELESS_EXT > 14
401 memset(&iwe, 0, sizeof(iwe));
402 iwe.cmd = IWEVCUSTOM;
403 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
404 iwe.u.data.length = strlen(buf);
405 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
407 #if WIRELESS_EXT > 17
408 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
409 memset(&iwe, 0, sizeof(iwe));
411 iwe.u.data.length = pBSS->wWPALen;
412 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
415 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
416 memset(&iwe, 0, sizeof(iwe));
418 iwe.u.data.length = pBSS->wRSNLen;
419 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
422 #else // WIRELESS_EXT > 17
423 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
425 memset(&iwe, 0, sizeof(iwe));
426 iwe.cmd = IWEVCUSTOM;
427 p += sprintf(p, "wpa_ie=");
428 for (ii = 0; ii < pBSS->wWPALen; ii++) {
429 p += sprintf(p, "%02x", pBSS->byWPAIE[ii]);
431 iwe.u.data.length = strlen(buf);
432 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
436 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
438 memset(&iwe, 0, sizeof(iwe));
439 iwe.cmd = IWEVCUSTOM;
440 p += sprintf(p, "rsn_ie=");
441 for (ii = 0; ii < pBSS->wRSNLen; ii++) {
442 p += sprintf(p, "%02x", pBSS->byRSNIE[ii]);
444 iwe.u.data.length = strlen(buf);
445 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
452 wrq->length = current_ev - extra;
457 #endif /* WIRELESS_EXT > 13 */
461 * Wireless Handler : set frequence or channel
464 int iwctl_siwfreq(struct net_device *dev,
465 struct iw_request_info *info,
469 PSDevice pDevice = (PSDevice)netdev_priv(dev);
472 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
474 // If setting by frequency, convert to a channel
476 (wrq->m >= (int) 2.412e8) &&
477 (wrq->m <= (int) 2.487e8)) {
478 int f = wrq->m / 100000;
480 while((c < 14) && (f != frequency_list[c]))
485 // Setting by channel number
486 if((wrq->m > 14) || (wrq->e > 0))
489 int channel = wrq->m;
490 if((channel < 1) || (channel > 14)) {
491 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
494 // Yes ! We can set it !!!
495 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
496 pDevice->uChannel = channel;
497 //2007-0207-04,<Add> by EinsnLiu
498 //Make change effect at once
499 pDevice->bCommit = TRUE;
507 * Wireless Handler : get frequence or channel
510 int iwctl_giwfreq(struct net_device *dev,
511 struct iw_request_info *info,
515 PSDevice pDevice = (PSDevice)netdev_priv(dev);
516 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
518 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
520 #ifdef WEXT_USECHANNELS
521 wrq->m = (int)pMgmt->uCurrChannel;
525 int f = (int)pMgmt->uCurrChannel - 1;
528 wrq->m = frequency_list[f] * 100000;
537 * Wireless Handler : set operation mode
540 int iwctl_siwmode(struct net_device *dev,
541 struct iw_request_info *info,
545 PSDevice pDevice = (PSDevice)netdev_priv(dev);
546 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
549 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
551 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
552 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
559 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
560 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
561 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
562 pDevice->bCommit = TRUE;
565 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
569 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
570 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
571 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
572 pDevice->bCommit = TRUE;
575 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
579 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
583 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
584 pMgmt->eConfigMode = WMAC_CONFIG_AP;
585 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
586 pDevice->bCommit = TRUE;
589 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
593 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
604 * Wireless Handler : get operation mode
607 int iwctl_giwmode(struct net_device *dev,
608 struct iw_request_info *info,
612 PSDevice pDevice = (PSDevice)netdev_priv(dev);
613 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
616 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
617 // If not managed, assume it's ad-hoc
618 switch (pMgmt->eConfigMode) {
619 case WMAC_CONFIG_ESS_STA:
620 *wmode = IW_MODE_INFRA;
622 case WMAC_CONFIG_IBSS_STA:
623 *wmode = IW_MODE_ADHOC;
625 case WMAC_CONFIG_AUTO:
626 *wmode = IW_MODE_INFRA;
629 *wmode = IW_MODE_MASTER;
632 *wmode = IW_MODE_ADHOC;
640 * Wireless Handler : get capability range
643 int iwctl_giwrange(struct net_device *dev,
644 struct iw_request_info *info,
645 struct iw_point *wrq,
648 struct iw_range *range = (struct iw_range *) extra;
650 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
653 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
655 wrq->length = sizeof(struct iw_range);
656 memset(range, 0, sizeof(struct iw_range));
657 range->min_nwid = 0x0000;
658 range->max_nwid = 0x0000;
659 range->num_channels = 14;
660 // Should be based on cap_rid.country to give only
661 // what the current card support
663 for(i = 0; i < 14; i++) {
664 range->freq[k].i = i + 1; // List index
665 range->freq[k].m = frequency_list[i] * 100000;
666 range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
668 range->num_frequency = k;
669 // Hum... Should put the right values there
670 #ifdef Calcu_LinkQual
671 range->max_qual.qual = 100;
673 range->max_qual.qual = 255;
675 range->max_qual.level = 0;
676 range->max_qual.noise = 0;
677 range->sensitivity = 255;
679 for(i = 0 ; i < 13 ; i++) {
680 range->bitrate[i] = abySupportedRates[i] * 500000;
681 if(range->bitrate[i] == 0)
684 range->num_bitrates = i;
686 // Set an indication of the max TCP throughput
687 // in bit/s that we can expect using this interface.
688 // May be use for QoS stuff... Jean II
690 range->throughput = 5 * 1000 * 1000;
692 range->throughput = 1.5 * 1000 * 1000;
695 range->max_rts = 2312;
696 range->min_frag = 256;
697 range->max_frag = 2312;
700 // the encoding capabilities
701 range->num_encoding_sizes = 3;
703 range->encoding_size[0] = 5;
705 range->encoding_size[1] = 13;
706 // 256 bits for WPA-PSK
707 range->encoding_size[2] = 32;
708 // 4 keys are allowed
709 range->max_encoding_tokens = 4;
711 #if WIRELESS_EXT > 17
712 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
713 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
718 range->max_pmp = 1000000;// 1 secs
720 range->max_pmt = 1000000;// 1 secs
721 range->pmp_flags = IW_POWER_PERIOD;
722 range->pmt_flags = IW_POWER_TIMEOUT;
723 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
725 // Transmit Power - values are in mW
727 range->txpower[0] = 100;
728 range->num_txpower = 1;
729 range->txpower_capa = IW_TXPOW_MWATT;
730 #endif // WIRELESS_EXT > 9
731 #if WIRELESS_EXT > 10
732 range->we_version_source = SUPPORTED_WIRELESS_EXT;
733 range->we_version_compiled = WIRELESS_EXT;
734 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
735 range->retry_flags = IW_RETRY_LIMIT;
736 range->r_time_flags = IW_RETRY_LIFETIME;
737 range->min_retry = 1;
738 range->max_retry = 65535;
739 range->min_r_time = 1024;
740 range->max_r_time = 65535 * 1024;
741 #endif // WIRELESS_EXT > 10
742 #if WIRELESS_EXT > 11
743 // Experimental measurements - boundary 11/5.5 Mb/s
744 // Note : with or without the (local->rssi), results
745 // are somewhat different. - Jean II
746 range->avg_qual.qual = 6;
747 range->avg_qual.level = 176; // -80 dBm
748 range->avg_qual.noise = 0;
749 #endif // WIRELESS_EXT > 11
758 * Wireless Handler : set ap mac address
761 int iwctl_siwap(struct net_device *dev,
762 struct iw_request_info *info,
763 struct sockaddr *wrq,
766 PSDevice pDevice = (PSDevice)netdev_priv(dev);
767 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
769 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
771 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAP \n");
772 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
774 printk("SIOCSIWAP(??)-->In scanning...\n");
777 if (wrq->sa_family != ARPHRD_ETHER)
780 memset(pMgmt->abyDesireBSSID, 0xFF, 6);
781 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
782 //2008-0409-05, <Add> by Einsn Liu
783 if((pDevice->bLinkPass == TRUE) &&
784 (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6)== 0)){
788 if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) ||
789 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
790 printk("SIOCSIWAP:invalid desired BSSID return!\n");
793 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
794 // then ignore,because you don't known which one to be connect with??
796 UINT ii , uSameBssidNum=0;
797 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
798 if (pMgmt->sBSSList[ii].bActive &&
799 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) {
803 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
804 printk("SIOCSIWAP:ignore for desired AP in hidden mode\n");
808 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
809 pDevice->bCommit = TRUE;
816 * Wireless Handler : get ap mac address
819 int iwctl_giwap(struct net_device *dev,
820 struct iw_request_info *info,
821 struct sockaddr *wrq,
824 PSDevice pDevice = (PSDevice)netdev_priv(dev);
825 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
828 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
830 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
831 //2008-0410,<Modify> by Einsn Liu
832 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
833 memset(wrq->sa_data, 0, 6);
835 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
836 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
839 wrq->sa_family = ARPHRD_ETHER;
847 * Wireless Handler : get ap list
850 int iwctl_giwaplist(struct net_device *dev,
851 struct iw_request_info *info,
852 struct iw_point *wrq,
856 struct sockaddr sock[IW_MAX_AP];
857 struct iw_quality qual[IW_MAX_AP];
858 PSDevice pDevice = (PSDevice)netdev_priv(dev);
859 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
862 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
863 // Only super-user can see AP list
865 if (!capable(CAP_NET_ADMIN)) {
872 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
874 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
875 pBSS = &(pMgmt->sBSSList[ii]);
878 if ( jj >= IW_MAX_AP)
880 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
881 sock[jj].sa_family = ARPHRD_ETHER;
882 qual[jj].level = pBSS->uRSSI;
883 qual[jj].qual = qual[jj].noise = 0;
884 qual[jj].updated = 2;
888 wrq->flags = 1; // Should be define'd
890 memcpy(extra, sock, sizeof(struct sockaddr)*jj);
891 memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
899 * Wireless Handler : set essid
902 int iwctl_siwessid(struct net_device *dev,
903 struct iw_request_info *info,
904 struct iw_point *wrq,
907 PSDevice pDevice = (PSDevice)netdev_priv(dev);
908 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
909 PWLAN_IE_SSID pItemSSID;
910 //2008-0409-05, <Add> by Einsn Liu
914 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID \n");
915 pDevice->fWPA_Authened = FALSE;
916 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
918 printk("SIOCSIWESSID(??)-->In scanning...\n");
921 // Check if we asked for `any'
922 if(wrq->flags == 0) {
923 // Just send an empty SSID list
924 // Just send an empty SSID list
925 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
926 memset(pMgmt->abyDesireBSSID, 0xFF,6);
927 printk("set essid to 'any' \n");
928 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
929 //Unknown desired AP,so here need not associate??
930 //if(pDevice->bWPASuppWextEnabled == TRUE) {
936 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
937 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
938 pItemSSID->byElementID = WLAN_EID_SSID;
939 memcpy(pItemSSID->abySSID, extra, wrq->length);
940 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
942 pItemSSID->len = wrq->length - 1;
945 pItemSSID->len = wrq->length;
946 printk("set essid to %s \n",pItemSSID->abySSID);
947 //2008-0409-05, <Add> by Einsn Liu
948 len=(pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)?pItemSSID->len:((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len;
949 if((pDevice->bLinkPass == TRUE) &&
950 (memcmp(pItemSSID->abySSID,((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,len)==0))
953 //mike:need clear desiredBSSID
954 if(pItemSSID->len==0) {
955 memset(pMgmt->abyDesireBSSID, 0xFF,6);
959 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
960 //Wext wil order another command of siwap to link with desired AP,
961 //so here need not associate??
962 if(pDevice->bWPASuppWextEnabled == TRUE) {
963 /*******search if in hidden ssid mode ****/
965 PKnownBSS pCurr = NULL;
966 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
967 UINT ii , uSameBssidNum=0;
969 memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID));
970 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
971 pCurr = BSSpSearchBSSList(pDevice,
974 pMgmt->eConfigPHYMode
978 printk("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
979 vResetCommandTimer((HANDLE) pDevice);
980 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
981 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
982 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
984 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
985 // by means of judging if there are two same BSSID exist in list ?
986 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
987 if (pMgmt->sBSSList[ii].bActive &&
988 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
992 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
993 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
994 vResetCommandTimer((HANDLE) pDevice);
995 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
996 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
997 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
1005 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
1007 #if WIRELESS_EXT < 21
1008 DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID1 \n");
1009 pItemSSID->len = wrq->length - 1;
1011 DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID2 \n");
1012 pItemSSID->len = wrq->length;
1017 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1018 pDevice->bCommit = TRUE;
1027 * Wireless Handler : get essid
1030 int iwctl_giwessid(struct net_device *dev,
1031 struct iw_request_info *info,
1032 struct iw_point *wrq,
1036 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1037 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1038 PWLAN_IE_SSID pItemSSID;
1040 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
1042 // Note : if wrq->u.data.flags != 0, we should
1043 // get the relevant SSID from the SSID list...
1045 // Get the current SSID
1046 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
1047 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
1048 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
1049 extra[pItemSSID->len] = '\0';
1050 wrq->length = pItemSSID->len + 1;
1051 //2008-0409-03, <Add> by Einsn Liu
1052 #if WIRELESS_EXT < 21
1053 wrq->length = pItemSSID->len + 1;
1055 wrq->length = pItemSSID->len;
1057 wrq->flags = 1; // active
1064 * Wireless Handler : set data rate
1067 int iwctl_siwrate(struct net_device *dev,
1068 struct iw_request_info *info,
1069 struct iw_param *wrq,
1072 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1076 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1079 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
1080 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1085 // First : get a valid bit rate value
1087 // Which type of value
1088 if((wrq->value < 13) &&
1089 (wrq->value >= 0)) {
1090 // Setting by rate index
1091 // Find value in the magic rate table
1094 // Setting by frequency value
1095 u8 normvalue = (u8) (wrq->value/500000);
1097 // Check if rate is valid
1098 for(i = 0 ; i < 13 ; i++) {
1099 if(normvalue == abySupportedRates[i]) {
1105 // -1 designed the max rate (mostly auto mode)
1106 if(wrq->value == -1) {
1107 // Get the highest available rate
1108 for(i = 0 ; i < 13 ; i++) {
1109 if(abySupportedRates[i] == 0)
1116 // Check that it is valid
1117 // brate is index of abySupportedRates[]
1123 // Now, check if we want a fixed or auto value
1124 if(wrq->fixed != 0) {
1127 printk("Rate Fix\n");
1128 pDevice->bFixRate = TRUE;
1129 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
1131 pDevice->uConnectionRate = 3;
1134 pDevice->uConnectionRate = brate;
1135 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
1140 pDevice->bFixRate = FALSE;
1141 pDevice->uConnectionRate = 13;
1142 printk("auto rate:connection_rate is 13\n");
1149 * Wireless Handler : get data rate
1152 int iwctl_giwrate(struct net_device *dev,
1153 struct iw_request_info *info,
1154 struct iw_param *wrq,
1157 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1158 //2007-0118-05,<Mark> by EinsnLiu
1159 //Mark the unnecessary sentences.
1160 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1162 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
1164 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1166 //2008-5-8 <modify> by chester
1167 if(pDevice->bLinkPass){
1168 if(pDevice->bFixRate == TRUE){
1169 if (pDevice->uConnectionRate < 13) {
1170 brate = abySupportedRates[pDevice->uConnectionRate];
1172 if (pDevice->byBBType == BB_TYPE_11B)
1174 if (pDevice->byBBType == BB_TYPE_11G)
1176 if (pDevice->byBBType == BB_TYPE_11A)
1183 brate = abySupportedRates[TxRate_iwconfig];
1187 //2007-0118-05,<Mark> by EinsnLiu
1188 //Mark the unnecessary sentences.
1190 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1191 if (pDevice->byBBType == BB_TYPE_11B)
1193 if (pDevice->byBBType == BB_TYPE_11G)
1195 if (pDevice->byBBType == BB_TYPE_11A)
1200 // if (pDevice->uConnectionRate == 13)
1201 // brate = abySupportedRates[pDevice->wCurrentRate];
1202 wrq->value = brate * 500000;
1203 // If more than one rate, set auto
1204 if (pDevice->bFixRate == TRUE)
1215 * Wireless Handler : set rts threshold
1218 int iwctl_siwrts(struct net_device *dev,
1219 struct iw_request_info *info,
1220 struct iw_param *wrq,
1223 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1226 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
1229 int rthr = wrq->value;
1232 if((rthr < 0) || (rthr > 2312)) {
1235 pDevice->wRTSThreshold = rthr;
1243 * Wireless Handler : get rts
1246 int iwctl_giwrts(struct net_device *dev,
1247 struct iw_request_info *info,
1248 struct iw_param *wrq,
1251 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1253 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
1254 wrq->value = pDevice->wRTSThreshold;
1255 wrq->disabled = (wrq->value >= 2312);
1262 * Wireless Handler : set fragment threshold
1265 int iwctl_siwfrag(struct net_device *dev,
1266 struct iw_request_info *info,
1267 struct iw_param *wrq,
1270 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1272 int fthr = wrq->value;
1275 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
1280 if((fthr < 256) || (fthr > 2312)) {
1283 fthr &= ~0x1; // Get an even value
1284 pDevice->wFragmentationThreshold = (u16)fthr;
1291 * Wireless Handler : get fragment threshold
1294 int iwctl_giwfrag(struct net_device *dev,
1295 struct iw_request_info *info,
1296 struct iw_param *wrq,
1299 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1301 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1302 wrq->value = pDevice->wFragmentationThreshold;
1303 wrq->disabled = (wrq->value >= 2312);
1312 * Wireless Handler : set retry threshold
1314 int iwctl_siwretry(struct net_device *dev,
1315 struct iw_request_info *info,
1316 struct iw_param *wrq,
1319 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1323 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1325 if (wrq->disabled) {
1330 if (wrq->flags & IW_RETRY_LIMIT) {
1331 if(wrq->flags & IW_RETRY_MAX)
1332 pDevice->byLongRetryLimit = wrq->value;
1333 else if (wrq->flags & IW_RETRY_MIN)
1334 pDevice->byShortRetryLimit = wrq->value;
1336 // No modifier : set both
1337 pDevice->byShortRetryLimit = wrq->value;
1338 pDevice->byLongRetryLimit = wrq->value;
1341 if (wrq->flags & IW_RETRY_LIFETIME) {
1342 pDevice->wMaxTransmitMSDULifetime = wrq->value;
1350 * Wireless Handler : get retry threshold
1352 int iwctl_giwretry(struct net_device *dev,
1353 struct iw_request_info *info,
1354 struct iw_param *wrq,
1357 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1358 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1359 wrq->disabled = 0; // Can't be disabled
1361 // Note : by default, display the min retry number
1362 if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1363 wrq->flags = IW_RETRY_LIFETIME;
1364 wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
1365 } else if((wrq->flags & IW_RETRY_MAX)) {
1366 wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1367 wrq->value = (int)pDevice->byLongRetryLimit;
1369 wrq->flags = IW_RETRY_LIMIT;
1370 wrq->value = (int)pDevice->byShortRetryLimit;
1371 if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
1372 wrq->flags |= IW_RETRY_MIN;
1381 * Wireless Handler : set encode mode
1383 int iwctl_siwencode(struct net_device *dev,
1384 struct iw_request_info *info,
1385 struct iw_point *wrq,
1388 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1389 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1390 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1392 int index = (wrq->flags & IW_ENCODE_INDEX);
1394 //2007-0207-07,<Modify> by EinsnLiu
1395 //There are some problems when using iwconfig encode/key command to set the WEP key.
1396 //I almost rewrite this function.
1397 //now it support:(assume the wireless interface's name is eth0)
1398 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1399 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1400 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1401 //iwconfig eth0 key restricted /*enable share key*/
1405 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1407 if((wrq->flags & IW_ENCODE_DISABLED)==0){
1408 //Not disable encryption
1410 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1415 if(dwKeyIndex<1&&((wrq->flags&IW_ENCODE_NOKEY)==0)){//set default key
1416 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1417 dwKeyIndex=pDevice->byKeyIndex;
1423 // Check the size of the key
1424 if (wrq->length > WLAN_WEP232_KEYLEN) {
1429 if(wrq->length>0){//have key
1431 if (wrq->length == WLAN_WEP232_KEYLEN) {
1432 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1434 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1435 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1437 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1438 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1439 }else {//no support length
1443 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1444 memcpy(pDevice->abyKey, extra, wrq->length);
1446 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1447 for (ii = 0; ii < wrq->length; ii++) {
1448 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1451 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1452 spin_lock_irq(&pDevice->lock);
1453 KeybSetDefaultKey(&(pDevice->sKey),
1454 (DWORD)(dwKeyIndex | (1 << 31)),
1459 pDevice->PortOffset,
1462 spin_unlock_irq(&pDevice->lock);
1464 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1465 pDevice->uKeyLength = wrq->length;
1466 pDevice->bTransmitKey = TRUE;
1467 pDevice->bEncryptionEnable = TRUE;
1468 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1471 //when the length is 0 the request only changes the default transmit key index
1472 //check the new key has a non zero lenget
1473 if(pDevice->bEncryptionEnable==FALSE)
1478 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Just set Default key Index:\n");
1479 pkeytab=&(pDevice->sKey.KeyTable[MAX_KEY_TABLE-1]);
1480 if(pkeytab->GroupKey[(BYTE)dwKeyIndex].uKeyLength==0){
1481 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Default key len is 0\n");
1485 pDevice->byKeyIndex =(BYTE)dwKeyIndex;
1486 pkeytab->dwGTKeyIndex =dwKeyIndex | (1 << 31);
1487 pkeytab->GroupKey[(BYTE)dwKeyIndex].dwKeyIndex=dwKeyIndex | (1 << 31);
1490 }else {//disable the key
1491 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1492 if(pDevice->bEncryptionEnable==FALSE)
1494 pMgmt->bShareKeyAlgorithm = FALSE;
1495 pDevice->bEncryptionEnable = FALSE;
1496 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1497 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1498 spin_lock_irq(&pDevice->lock);
1499 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1500 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1501 spin_unlock_irq(&pDevice->lock);
1507 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1509 // Check the size of the key
1510 if (wrq->length > WLAN_WEP232_KEYLEN) {
1515 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1523 // Send the key to the card
1524 if (wrq->length > 0) {
1526 if (wrq->length == WLAN_WEP232_KEYLEN) {
1527 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1529 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1530 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1532 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1533 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1535 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1536 memcpy(pDevice->abyKey, extra, wrq->length);
1538 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1539 for (ii = 0; ii < wrq->length; ii++) {
1540 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1543 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1544 spin_lock_irq(&pDevice->lock);
1545 KeybSetDefaultKey(&(pDevice->sKey),
1546 (DWORD)(pDevice->byKeyIndex | (1 << 31)),
1547 pDevice->uKeyLength,
1551 pDevice->PortOffset,
1554 spin_unlock_irq(&pDevice->lock);
1556 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1557 pDevice->uKeyLength = wrq->length;
1558 pDevice->bTransmitKey = TRUE;
1559 pDevice->bEncryptionEnable = TRUE;
1560 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1562 // Do we want to just set the transmit key index ?
1564 pDevice->byKeyIndex = index;
1566 else if(!wrq->flags & IW_ENCODE_MODE) {
1572 if(wrq->flags & IW_ENCODE_DISABLED){
1574 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1575 pMgmt->bShareKeyAlgorithm = FALSE;
1576 pDevice->bEncryptionEnable = FALSE;
1577 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1578 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1579 spin_lock_irq(&pDevice->lock);
1580 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1581 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1582 spin_unlock_irq(&pDevice->lock);
1587 if(wrq->flags & IW_ENCODE_RESTRICTED) {
1588 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1589 pMgmt->bShareKeyAlgorithm = TRUE;
1591 if(wrq->flags & IW_ENCODE_OPEN) {
1592 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1593 pMgmt->bShareKeyAlgorithm = FALSE;
1599 * Wireless Handler : get encode mode
1602 int iwctl_giwencode(struct net_device *dev,
1603 struct iw_request_info *info,
1604 struct iw_point *wrq,
1607 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1608 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1610 char abyKey[WLAN_WEP232_KEYLEN];
1611 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1612 PSKeyItem pKey = NULL;
1614 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1615 //2007-0207-06,<Add> by EinsnLiu
1616 //the key index in iwconfig is 1-4 when our driver is 0-3
1617 //so it can't be used directly.
1618 //if the index is 0,we should used the index set by driver.
1619 if (index > WLAN_WEP_NKEYS) {
1623 if(index<1){//set default key
1624 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1625 index=pDevice->byKeyIndex;
1631 memset(abyKey, 0, sizeof(abyKey));
1632 // Check encryption mode
1633 wrq->flags = IW_ENCODE_NOKEY;
1634 // Is WEP enabled ???
1635 if (pDevice->bEncryptionEnable)
1636 wrq->flags |= IW_ENCODE_ENABLED;
1638 wrq->flags |= IW_ENCODE_DISABLED;
1640 if (pMgmt->bShareKeyAlgorithm)
1641 wrq->flags |= IW_ENCODE_RESTRICTED;
1643 wrq->flags |= IW_ENCODE_OPEN;
1645 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1646 wrq->length = pKey->uKeyLength;
1647 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1648 //2007-0207-06,<Modify> by EinsnLiu
1649 //only get key success need to copy data
1651 //there is not necessary to return -EINVAL when get key failed
1652 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1653 wrq->flags |= index+1;
1654 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1669 //2008-0409-06, <Add> by Einsn Liu
1671 int iwctl_giwencode(struct net_device *dev,
1672 struct iw_request_info *info,
1673 struct iw_point *wrq,
1676 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1677 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1678 char abyKey[WLAN_WEP232_KEYLEN];
1680 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1681 PSKeyItem pKey = NULL;
1683 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1685 if (index > WLAN_WEP_NKEYS) {
1688 if(index<1){//get default key
1689 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1690 index=pDevice->byKeyIndex;
1696 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1697 // Check encryption mode
1698 wrq->flags = IW_ENCODE_NOKEY;
1699 // Is WEP enabled ???
1700 if (pDevice->bEncryptionEnable)
1701 wrq->flags |= IW_ENCODE_ENABLED;
1703 wrq->flags |= IW_ENCODE_DISABLED;
1705 if (pMgmt->bShareKeyAlgorithm)
1706 wrq->flags |= IW_ENCODE_RESTRICTED;
1708 wrq->flags |= IW_ENCODE_OPEN;
1711 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1712 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1713 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1714 wrq->length = pKey->uKeyLength;
1715 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1716 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1718 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1719 wrq->length = pKey->uKeyLength;
1720 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1721 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1724 wrq->flags |= index+1;
1730 * Wireless Handler : set power mode
1732 int iwctl_siwpower(struct net_device *dev,
1733 struct iw_request_info *info,
1734 struct iw_param *wrq,
1737 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1738 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1741 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1743 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1748 if (wrq->disabled) {
1749 pDevice->ePSMode = WMAC_POWER_CAM;
1750 PSvDisablePowerSaving(pDevice);
1753 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1754 pDevice->ePSMode = WMAC_POWER_FAST;
1755 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1757 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1758 pDevice->ePSMode = WMAC_POWER_FAST;
1759 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1761 switch (wrq->flags & IW_POWER_MODE) {
1762 case IW_POWER_UNICAST_R:
1763 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1766 case IW_POWER_ALL_R:
1767 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1770 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1780 * Wireless Handler : get power mode
1782 int iwctl_giwpower(struct net_device *dev,
1783 struct iw_request_info *info,
1784 struct iw_param *wrq,
1787 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1788 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1789 int mode = pDevice->ePSMode;
1792 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1795 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1798 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1799 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1800 wrq->flags = IW_POWER_TIMEOUT;
1802 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1803 wrq->flags = IW_POWER_PERIOD;
1805 wrq->flags |= IW_POWER_ALL_R;
1812 * Wireless Handler : get Sensitivity
1814 int iwctl_giwsens(struct net_device *dev,
1815 struct iw_request_info *info,
1816 struct iw_param *wrq,
1819 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1822 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1823 if (pDevice->bLinkPass == TRUE) {
1824 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1830 wrq->disabled = (wrq->value == 0);
1837 //2008-0409-07, <Add> by Einsn Liu
1838 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1840 int iwctl_siwauth(struct net_device *dev,
1841 struct iw_request_info *info,
1842 struct iw_param *wrq,
1845 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1846 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1848 static int wpa_version=0; //must be static to save the last value,einsn liu
1849 static int pairwise=0;
1851 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1852 switch (wrq->flags & IW_AUTH_INDEX) {
1853 case IW_AUTH_WPA_VERSION:
1854 wpa_version = wrq->value;
1855 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1856 printk("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1857 //pDevice->bWPADevEnable = FALSE;
1859 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1860 printk("iwctl_siwauth:set WPADEV to WPA1******\n");
1863 printk("iwctl_siwauth:set WPADEV to WPA2******\n");
1865 //pDevice->bWPASuppWextEnabled =TRUE;
1867 case IW_AUTH_CIPHER_PAIRWISE:
1868 pairwise = wrq->value;
1870 if(pairwise == IW_AUTH_CIPHER_CCMP){
1871 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1872 }else if(pairwise == IW_AUTH_CIPHER_TKIP){
1873 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1874 }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
1875 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1876 }else if(pairwise == IW_AUTH_CIPHER_NONE){
1877 //do nothing,einsn liu
1878 }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1881 case IW_AUTH_CIPHER_GROUP:
1882 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1884 if(pairwise == IW_AUTH_CIPHER_NONE){
1885 if(wrq->value == IW_AUTH_CIPHER_CCMP){
1886 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1888 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1892 case IW_AUTH_KEY_MGMT:
1894 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1895 if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1896 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
1897 else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
1898 }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
1899 if(wrq->value == 0){
1900 pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
1901 }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1902 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
1903 else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
1907 case IW_AUTH_TKIP_COUNTERMEASURES:
1909 case IW_AUTH_DROP_UNENCRYPTED:
1911 case IW_AUTH_80211_AUTH_ALG:
1912 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1913 pMgmt->bShareKeyAlgorithm=FALSE;
1914 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
1915 pMgmt->bShareKeyAlgorithm=TRUE;
1918 case IW_AUTH_WPA_ENABLED:
1919 //pDevice->bWPADevEnable = !! wrq->value;
1921 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1923 case IW_AUTH_ROAMING_CONTROL:
1926 case IW_AUTH_PRIVACY_INVOKED:
1927 pDevice->bEncryptionEnable = !!wrq->value;
1928 if(pDevice->bEncryptionEnable == FALSE){
1931 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1932 pMgmt->bShareKeyAlgorithm = FALSE;
1933 pMgmt->eAuthenMode = FALSE;
1934 //pDevice->bWPADevEnable = FALSE;
1943 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1944 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1945 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1946 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1947 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1948 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1949 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");
1955 int iwctl_giwauth(struct net_device *dev,
1956 struct iw_request_info *info,
1957 struct iw_param *wrq,
1965 int iwctl_siwgenie(struct net_device *dev,
1966 struct iw_request_info *info,
1967 struct iw_point *wrq,
1970 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1971 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1975 if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
1979 if(wrq->length > MAX_WPA_IE_LEN){
1983 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1984 if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
1988 pMgmt->wWPAIELen = wrq->length;
1990 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1991 pMgmt->wWPAIELen = 0;
1994 out://not completely ...not necessary in wpa_supplicant 0.5.8
1998 int iwctl_giwgenie(struct net_device *dev,
1999 struct iw_request_info *info,
2000 struct iw_point *wrq,
2003 PSDevice pDevice = (PSDevice)netdev_priv(dev);
2004 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
2006 int space = wrq->length;
2009 if(pMgmt->wWPAIELen > 0){
2010 wrq->length = pMgmt->wWPAIELen;
2011 if(pMgmt->wWPAIELen <= space){
2012 if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
2023 int iwctl_siwencodeext(struct net_device *dev,
2024 struct iw_request_info *info,
2025 struct iw_point *wrq,
2028 PSDevice pDevice = (PSDevice)netdev_priv(dev);
2029 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2030 struct viawget_wpa_param *param=NULL;
2034 int key_idx, set_tx;
2035 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
2037 size_t seq_len,key_len=0;
2045 printk("SIOCSIWENCODEEXT...... \n");
2047 blen = sizeof(*param);
2048 buf = kmalloc((int)blen, (int)GFP_KERNEL);
2051 memset(buf, 0, blen);
2052 param = (struct viawget_wpa_param *) buf;
2056 case IW_ENCODE_ALG_NONE:
2057 alg_name = WPA_ALG_NONE;
2059 case IW_ENCODE_ALG_WEP:
2060 alg_name = WPA_ALG_WEP;
2062 case IW_ENCODE_ALG_TKIP:
2063 alg_name = WPA_ALG_TKIP;
2065 case IW_ENCODE_ALG_CCMP:
2066 alg_name = WPA_ALG_CCMP;
2069 printk("Unknown alg = %d\n",ext->alg);
2074 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
2076 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
2078 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2080 //recover seq,seq_len
2081 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
2082 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
2083 memcpy(seq, ext->rx_seq, seq_len);
2085 //recover key,key_len
2087 key_len=ext->key_len;
2088 memcpy(key, &ext->key[0], key_len);
2091 memset(key_array, 0, 64);
2093 memcpy(key_array, key, key_len);
2094 if (key_len == 32) {
2095 // notice ! the oder
2096 memcpy(&key_array[16], &key[24], 8);
2097 memcpy(&key_array[24], &key[16], 8);
2101 /**************Translate iw_encode_ext to viawget_wpa_param****************/
2102 memcpy(param->addr, addr, ETH_ALEN);
2103 param->u.wpa_key.alg_name = (int)alg_name;
2104 param->u.wpa_key.set_tx = set_tx;
2105 param->u.wpa_key.key_index = key_idx;
2106 param->u.wpa_key.key_len = key_len;
2107 param->u.wpa_key.key = (u8 *)key_array;
2108 param->u.wpa_key.seq = (u8 *)seq;
2109 param->u.wpa_key.seq_len = seq_len;
2113 printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
2114 printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
2115 param->addr[0],param->addr[1],param->addr[2],
2116 param->addr[3],param->addr[4],param->addr[5]);
2117 printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
2118 printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
2119 printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
2120 printk("param->u.wpa_key.key =");
2121 for(ii=0;ii<param->u.wpa_key.key_len;ii++)
2122 printk("%02x:",param->u.wpa_key.key[ii]);
2124 printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
2125 printk("param->u.wpa_key.seq =");
2126 for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
2127 printk("%02x:",param->u.wpa_key.seq[ii]);
2130 printk("...........\n");
2132 //****set if current action is Network Manager count??
2133 //****this method is so foolish,but there is no other way???
2134 if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
2135 if(param->u.wpa_key.key_index ==0) {
2136 pDevice->bwextcount++;
2138 if((pDevice->bwextcount == 1)&&(param->u.wpa_key.key_index ==1)) {
2139 pDevice->bwextcount++;
2141 if((pDevice->bwextcount ==2)&&(param->u.wpa_key.key_index ==2)) {
2142 pDevice->bwextcount++;
2144 if((pDevice->bwextcount ==3)&&(param->u.wpa_key.key_index ==3)) {
2145 pDevice->bwextcount++;
2148 if( pDevice->bwextcount == 4) {
2149 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2150 pDevice->bwextcount=0;
2151 pDevice->bWPASuppWextEnabled = TRUE;
2155 spin_lock_irq(&pDevice->lock);
2156 ret = wpa_set_keys(pDevice, param, TRUE);
2157 spin_unlock_irq(&pDevice->lock);
2166 int iwctl_giwencodeext(struct net_device *dev,
2167 struct iw_request_info *info,
2168 struct iw_point *wrq,
2171 return -EOPNOTSUPP;;
2174 int iwctl_siwmlme(struct net_device *dev,
2175 struct iw_request_info * info,
2176 struct iw_point *wrq,
2179 PSDevice pDevice = (PSDevice)netdev_priv(dev);
2180 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
2181 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2182 //u16 reason = cpu_to_le16(mlme->reason_code);
2185 if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
2190 case IW_MLME_DEAUTH:
2191 //this command seems to be not complete,please test it --einsnliu
2192 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2194 case IW_MLME_DISASSOC:
2195 if(pDevice->bLinkPass == TRUE){
2196 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2197 //clear related flags
2198 memset(pMgmt->abyDesireBSSID, 0xFF,6);
2199 KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
2200 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
2214 /*------------------------------------------------------------------*/
2216 * Structures to export the Wireless Handlers
2220 #if WIRELESS_EXT > 12
2223 static const iw_handler iwctl_handler[] =
2225 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2226 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2227 (iw_handler) NULL, // SIOCSIWNWID
2228 (iw_handler) NULL, // SIOCGIWNWID
2229 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2230 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2231 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2232 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2233 (iw_handler) NULL, // SIOCSIWSENS
2234 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2235 (iw_handler) NULL, // SIOCSIWRANGE
2236 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2237 (iw_handler) NULL, // SIOCSIWPRIV
2238 (iw_handler) NULL, // SIOCGIWPRIV
2239 (iw_handler) NULL, // SIOCSIWSTATS
2240 (iw_handler) NULL, // SIOCGIWSTATS
2241 (iw_handler) NULL, // SIOCSIWSPY
2242 (iw_handler) NULL, // SIOCGIWSPY
2243 (iw_handler) NULL, // -- hole --
2244 (iw_handler) NULL, // -- hole --
2245 (iw_handler) iwctl_siwap, // SIOCSIWAP
2246 (iw_handler) iwctl_giwap, // SIOCGIWAP
2247 (iw_handler) NULL, // -- hole -- 0x16
2248 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2249 #if WIRELESS_EXT > 13
2250 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2251 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2256 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2257 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2258 (iw_handler) NULL, // SIOCSIWNICKN
2259 (iw_handler) NULL, // SIOCGIWNICKN
2260 (iw_handler) NULL, // -- hole --
2261 (iw_handler) NULL, // -- hole --
2262 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2263 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2264 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2265 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2266 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2267 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2268 (iw_handler) NULL, // SIOCSIWTXPOW
2269 (iw_handler) NULL, // SIOCGIWTXPOW
2270 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2271 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2272 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2273 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2274 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2275 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2276 #if WIRELESS_EXT > 17
2277 (iw_handler) NULL, // -- hole --
2278 (iw_handler) NULL, // -- hole --
2279 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2280 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2281 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2282 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2283 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2284 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2285 (iw_handler) NULL, // SIOCSIWPMKSA
2286 (iw_handler) NULL, // -- hole --
2287 #endif // WIRELESS_EXT > 17
2292 static const iw_handler iwctl_handler[] =
2294 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2295 (iw_handler) NULL, // SIOCGIWNAME
2296 (iw_handler) NULL, // SIOCSIWNWID
2297 (iw_handler) NULL, // SIOCGIWNWID
2298 (iw_handler) NULL, // SIOCSIWFREQ
2299 (iw_handler) NULL, // SIOCGIWFREQ
2300 (iw_handler) NULL, // SIOCSIWMODE
2301 (iw_handler) NULL, // SIOCGIWMODE
2302 (iw_handler) NULL, // SIOCSIWSENS
2303 (iw_handler) NULL, // SIOCGIWSENS
2304 (iw_handler) NULL, // SIOCSIWRANGE
2305 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2306 (iw_handler) NULL, // SIOCSIWPRIV
2307 (iw_handler) NULL, // SIOCGIWPRIV
2308 (iw_handler) NULL, // SIOCSIWSTATS
2309 (iw_handler) NULL, // SIOCGIWSTATS
2310 (iw_handler) NULL, // SIOCSIWSPY
2311 (iw_handler) NULL, // SIOCGIWSPY
2312 (iw_handler) NULL, // -- hole --
2313 (iw_handler) NULL, // -- hole --
2314 (iw_handler) NULL, // SIOCSIWAP
2315 (iw_handler) NULL, // SIOCGIWAP
2316 (iw_handler) NULL, // -- hole -- 0x16
2317 (iw_handler) NULL, // SIOCGIWAPLIST
2318 #if WIRELESS_EXT > 13
2319 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2320 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2325 (iw_handler) NULL, // SIOCSIWESSID
2326 (iw_handler) NULL, // SIOCGIWESSID
2327 (iw_handler) NULL, // SIOCSIWNICKN
2328 (iw_handler) NULL, // SIOCGIWNICKN
2329 (iw_handler) NULL, // -- hole --
2330 (iw_handler) NULL, // -- hole --
2331 (iw_handler) NULL, // SIOCSIWRATE 0x20
2332 (iw_handler) NULL, // SIOCGIWRATE
2333 (iw_handler) NULL, // SIOCSIWRTS
2334 (iw_handler) NULL, // SIOCGIWRTS
2335 (iw_handler) NULL, // SIOCSIWFRAG
2336 (iw_handler) NULL, // SIOCGIWFRAG
2337 (iw_handler) NULL, // SIOCSIWTXPOW
2338 (iw_handler) NULL, // SIOCGIWTXPOW
2339 (iw_handler) NULL, // SIOCSIWRETRY
2340 (iw_handler) NULL, // SIOCGIWRETRY
2341 (iw_handler) NULL, // SIOCSIWENCODE
2342 (iw_handler) NULL, // SIOCGIWENCODE
2343 (iw_handler) NULL, // SIOCSIWPOWER
2344 (iw_handler) NULL, // SIOCGIWPOWER
2346 //2008-0409-07, <Add> by Einsn Liu
2347 #if WIRELESS_EXT > 17
2348 (iw_handler) NULL, // -- hole --
2349 (iw_handler) NULL, // -- hole --
2350 (iw_handler) NULL, // SIOCSIWGENIE
2351 (iw_handler) NULL, // SIOCGIWGENIE
2352 (iw_handler) NULL, // SIOCSIWAUTH
2353 (iw_handler) NULL, // SIOCGIWAUTH
2354 (iw_handler) NULL, // SIOCSIWENCODEEXT
2355 (iw_handler) NULL, // SIOCGIWENCODEEXT
2356 (iw_handler) NULL, // SIOCSIWPMKSA
2357 (iw_handler) NULL, // -- hole --
2358 #endif // WIRELESS_EXT > 17
2362 static const iw_handler iwctl_private_handler[] =
2364 NULL, // SIOCIWFIRSTPRIV
2368 struct iw_priv_args iwctl_private_args[] = {
2370 IW_PRIV_TYPE_CHAR | 1024, 0,
2376 const struct iw_handler_def iwctl_handler_def =
2378 #if WIRELESS_EXT > 16
2379 .get_wireless_stats = &iwctl_get_wireless_stats,
2381 .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
2382 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2383 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2385 .num_private_args = 0,
2386 .standard = (iw_handler *) iwctl_handler,
2387 // .private = (iw_handler *) iwctl_private_handler,
2388 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2390 .private_args = NULL,
2394 #endif // WIRELESS_EXT > 12
2397 #endif // WIRELESS_EXT