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__)
71 #include <net/iw_handler.h>
72 extern WORD TxRate_iwconfig;//2008-5-8 <add> by chester
74 /*--------------------- Static Definitions -------------------------*/
76 //2008-0409-07, <Add> by Einsn Liu
77 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
78 #define SUPPORTED_WIRELESS_EXT 18
80 #define SUPPORTED_WIRELESS_EXT 17
83 static const long frequency_list[] = {
84 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
85 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
86 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
87 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
88 5700, 5745, 5765, 5785, 5805, 5825
92 /*--------------------- Static Classes ----------------------------*/
95 //static int msglevel =MSG_LEVEL_DEBUG;
96 static int msglevel =MSG_LEVEL_INFO;
99 /*--------------------- Static Variables --------------------------*/
100 /*--------------------- Static Functions --------------------------*/
102 /*--------------------- Export Variables --------------------------*/
104 struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
106 PSDevice pDevice = netdev_priv(dev);
108 pDevice->wstats.status = pDevice->eOPMode;
109 #ifdef Calcu_LinkQual
111 if(pDevice->byBBType == BB_TYPE_11B) {
112 if(pDevice->byCurrSQ > 120)
113 pDevice->scStatistic.LinkQuality = 100;
115 pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
117 else if(pDevice->byBBType == BB_TYPE_11G) {
118 if(pDevice->byCurrSQ < 20)
119 pDevice->scStatistic.LinkQuality = 100;
120 else if(pDevice->byCurrSQ >96)
121 pDevice->scStatistic.LinkQuality = 0;
123 pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
125 if(pDevice->bLinkPass !=TRUE)
126 pDevice->scStatistic.LinkQuality = 0;
128 if(pDevice->scStatistic.LinkQuality > 100)
129 pDevice->scStatistic.LinkQuality = 100;
130 pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
132 pDevice->wstats.qual.qual = pDevice->byCurrSQ;
134 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
135 pDevice->wstats.qual.level = ldBm;
136 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
137 pDevice->wstats.qual.noise = 0;
138 pDevice->wstats.qual.updated = 1;
139 pDevice->wstats.discard.nwid = 0;
140 pDevice->wstats.discard.code = 0;
141 pDevice->wstats.discard.fragment = 0;
142 pDevice->wstats.discard.retries = (U32)pDevice->scStatistic.dwTsrErr;
143 pDevice->wstats.discard.misc = 0;
144 pDevice->wstats.miss.beacon = 0;
146 return &pDevice->wstats;
151 /*------------------------------------------------------------------*/
154 static int iwctl_commit(struct net_device *dev,
155 struct iw_request_info *info,
159 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
166 * Wireless Handler : get protocol name
169 int iwctl_giwname(struct net_device *dev,
170 struct iw_request_info *info,
174 strcpy(wrq, "802.11-a/b/g");
178 int iwctl_giwnwid(struct net_device *dev,
179 struct iw_request_info *info,
180 struct iw_param *wrq,
183 //wrq->value = 0x100;
191 * Wireless Handler : set scan
194 int iwctl_siwscan(struct net_device *dev,
195 struct iw_request_info *info,
196 struct iw_point *wrq,
199 PSDevice pDevice = (PSDevice)netdev_priv(dev);
200 struct iw_scan_req *req = (struct iw_scan_req *)extra;
201 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
202 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
203 PWLAN_IE_SSID pItemSSID=NULL;
204 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSCAN \n");
207 if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
208 //send scan event to wpa_Supplicant
209 union iwreq_data wrqu;
210 printk("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
211 memset(&wrqu, 0, sizeof(wrqu));
212 wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
216 spin_lock_irq(&pDevice->lock);
217 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
219 //mike add: active scan OR passive scan OR desire_ssid scan
220 if(wrq->length == sizeof(struct iw_scan_req)) {
221 if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
222 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
223 pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
224 pItemSSID->byElementID = WLAN_EID_SSID;
225 memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
226 if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
228 pItemSSID->len = req->essid_len - 1;
231 pItemSSID->len = req->essid_len;
232 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
233 printk("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
234 ((PWLAN_IE_SSID)abyScanSSID)->len);
235 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
236 spin_unlock_irq(&pDevice->lock);
240 else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
241 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
245 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
248 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
249 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
250 spin_unlock_irq(&pDevice->lock);
257 * Wireless Handler : get scan results
260 int iwctl_giwscan(struct net_device *dev,
261 struct iw_request_info *info,
262 struct iw_point *wrq,
266 PSDevice pDevice = (PSDevice)netdev_priv(dev);
267 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
269 PWLAN_IE_SSID pItemSSID;
270 PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
271 char *current_ev = extra;
272 char *end_buf = extra + IW_SCAN_MAX_DATA;
273 char *current_val = NULL;
276 char buf[MAX_WPA_IE_LEN * 2 + 30];
279 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
281 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
285 pBSS = &(pMgmt->sBSSList[0]);
286 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
287 if (current_ev >= end_buf)
289 pBSS = &(pMgmt->sBSSList[jj]);
291 memset(&iwe, 0, sizeof(iwe));
293 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
294 memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
295 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
297 memset(&iwe, 0, sizeof(iwe));
298 iwe.cmd = SIOCGIWESSID;
299 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
300 iwe.u.data.length = pItemSSID->len;
301 iwe.u.data.flags = 1;
302 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
304 memset(&iwe, 0, sizeof(iwe));
305 iwe.cmd = SIOCGIWMODE;
306 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
307 iwe.u.mode = IW_MODE_INFRA;
310 iwe.u.mode = IW_MODE_ADHOC;
312 iwe.len = IW_EV_UINT_LEN;
313 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
315 pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
316 pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
317 memset(&iwe, 0, sizeof(iwe));
318 iwe.cmd = SIOCGIWFREQ;
319 iwe.u.freq.m = pBSS->uChannel;
322 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
325 //2008-0409-04, <Add> by Einsn Liu
327 int f = (int)pBSS->uChannel - 1;
329 iwe.u.freq.m = frequency_list[f] * 100000;
332 current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
334 memset(&iwe, 0, sizeof(iwe));
336 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
337 iwe.u.qual.level = ldBm;
338 iwe.u.qual.noise = 0;
339 //2008-0409-01, <Add> by Einsn Liu
341 iwe.u.qual.qual = 100;
342 }else if(-ldBm > 90) {
345 iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
347 iwe.u.qual.updated=7;
349 // iwe.u.qual.qual = 0;
350 current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
352 memset(&iwe, 0, sizeof(iwe));
353 iwe.cmd = SIOCGIWENCODE;
354 iwe.u.data.length = 0;
355 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
356 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
358 iwe.u.data.flags = IW_ENCODE_DISABLED;
360 current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
362 memset(&iwe, 0, sizeof(iwe));
363 iwe.cmd = SIOCGIWRATE;
364 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
365 current_val = current_ev + IW_EV_LCP_LEN;
367 for (kk = 0 ; kk < 12 ; kk++) {
368 if (pSuppRates->abyRates[kk] == 0)
370 // Bit rate given in 500 kb/s units (+ 0x80)
371 iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
372 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
374 for (kk = 0 ; kk < 8 ; kk++) {
375 if (pExtSuppRates->abyRates[kk] == 0)
377 // Bit rate given in 500 kb/s units (+ 0x80)
378 iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
379 current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
382 if((current_val - current_ev) > IW_EV_LCP_LEN)
383 current_ev = current_val;
385 memset(&iwe, 0, sizeof(iwe));
386 iwe.cmd = IWEVCUSTOM;
387 sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
388 iwe.u.data.length = strlen(buf);
389 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
391 if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
392 memset(&iwe, 0, sizeof(iwe));
394 iwe.u.data.length = pBSS->wWPALen;
395 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
398 if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
399 memset(&iwe, 0, sizeof(iwe));
401 iwe.u.data.length = pBSS->wRSNLen;
402 current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
408 wrq->length = current_ev - extra;
415 * Wireless Handler : set frequence or channel
418 int iwctl_siwfreq(struct net_device *dev,
419 struct iw_request_info *info,
423 PSDevice pDevice = (PSDevice)netdev_priv(dev);
426 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
428 // If setting by frequency, convert to a channel
430 (wrq->m >= (int) 2.412e8) &&
431 (wrq->m <= (int) 2.487e8)) {
432 int f = wrq->m / 100000;
434 while((c < 14) && (f != frequency_list[c]))
439 // Setting by channel number
440 if((wrq->m > 14) || (wrq->e > 0))
443 int channel = wrq->m;
444 if((channel < 1) || (channel > 14)) {
445 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
448 // Yes ! We can set it !!!
449 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
450 pDevice->uChannel = channel;
451 //2007-0207-04,<Add> by EinsnLiu
452 //Make change effect at once
453 pDevice->bCommit = TRUE;
461 * Wireless Handler : get frequence or channel
464 int iwctl_giwfreq(struct net_device *dev,
465 struct iw_request_info *info,
469 PSDevice pDevice = (PSDevice)netdev_priv(dev);
470 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
472 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
474 #ifdef WEXT_USECHANNELS
475 wrq->m = (int)pMgmt->uCurrChannel;
479 int f = (int)pMgmt->uCurrChannel - 1;
482 wrq->m = frequency_list[f] * 100000;
491 * Wireless Handler : set operation mode
494 int iwctl_siwmode(struct net_device *dev,
495 struct iw_request_info *info,
499 PSDevice pDevice = (PSDevice)netdev_priv(dev);
500 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
505 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
506 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
513 if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
514 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
515 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
516 pDevice->bCommit = TRUE;
519 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
523 if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
524 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
525 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
526 pDevice->bCommit = TRUE;
529 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
533 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
537 if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
538 pMgmt->eConfigMode = WMAC_CONFIG_AP;
539 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
540 pDevice->bCommit = TRUE;
543 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
547 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
558 * Wireless Handler : get operation mode
561 int iwctl_giwmode(struct net_device *dev,
562 struct iw_request_info *info,
566 PSDevice pDevice = (PSDevice)netdev_priv(dev);
567 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
571 // If not managed, assume it's ad-hoc
572 switch (pMgmt->eConfigMode) {
573 case WMAC_CONFIG_ESS_STA:
574 *wmode = IW_MODE_INFRA;
576 case WMAC_CONFIG_IBSS_STA:
577 *wmode = IW_MODE_ADHOC;
579 case WMAC_CONFIG_AUTO:
580 *wmode = IW_MODE_INFRA;
583 *wmode = IW_MODE_MASTER;
586 *wmode = IW_MODE_ADHOC;
594 * Wireless Handler : get capability range
597 int iwctl_giwrange(struct net_device *dev,
598 struct iw_request_info *info,
599 struct iw_point *wrq,
602 struct iw_range *range = (struct iw_range *) extra;
604 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
607 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
609 wrq->length = sizeof(struct iw_range);
610 memset(range, 0, sizeof(struct iw_range));
611 range->min_nwid = 0x0000;
612 range->max_nwid = 0x0000;
613 range->num_channels = 14;
614 // Should be based on cap_rid.country to give only
615 // what the current card support
617 for(i = 0; i < 14; i++) {
618 range->freq[k].i = i + 1; // List index
619 range->freq[k].m = frequency_list[i] * 100000;
620 range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
622 range->num_frequency = k;
623 // Hum... Should put the right values there
624 #ifdef Calcu_LinkQual
625 range->max_qual.qual = 100;
627 range->max_qual.qual = 255;
629 range->max_qual.level = 0;
630 range->max_qual.noise = 0;
631 range->sensitivity = 255;
633 for(i = 0 ; i < 13 ; i++) {
634 range->bitrate[i] = abySupportedRates[i] * 500000;
635 if(range->bitrate[i] == 0)
638 range->num_bitrates = i;
640 // Set an indication of the max TCP throughput
641 // in bit/s that we can expect using this interface.
642 // May be use for QoS stuff... Jean II
644 range->throughput = 5 * 1000 * 1000;
646 range->throughput = 1.5 * 1000 * 1000;
649 range->max_rts = 2312;
650 range->min_frag = 256;
651 range->max_frag = 2312;
654 // the encoding capabilities
655 range->num_encoding_sizes = 3;
657 range->encoding_size[0] = 5;
659 range->encoding_size[1] = 13;
660 // 256 bits for WPA-PSK
661 range->encoding_size[2] = 32;
662 // 4 keys are allowed
663 range->max_encoding_tokens = 4;
665 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
666 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
669 range->max_pmp = 1000000;// 1 secs
671 range->max_pmt = 1000000;// 1 secs
672 range->pmp_flags = IW_POWER_PERIOD;
673 range->pmt_flags = IW_POWER_TIMEOUT;
674 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
676 // Transmit Power - values are in mW
678 range->txpower[0] = 100;
679 range->num_txpower = 1;
680 range->txpower_capa = IW_TXPOW_MWATT;
681 range->we_version_source = SUPPORTED_WIRELESS_EXT;
682 range->we_version_compiled = WIRELESS_EXT;
683 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
684 range->retry_flags = IW_RETRY_LIMIT;
685 range->r_time_flags = IW_RETRY_LIFETIME;
686 range->min_retry = 1;
687 range->max_retry = 65535;
688 range->min_r_time = 1024;
689 range->max_r_time = 65535 * 1024;
690 // Experimental measurements - boundary 11/5.5 Mb/s
691 // Note : with or without the (local->rssi), results
692 // are somewhat different. - Jean II
693 range->avg_qual.qual = 6;
694 range->avg_qual.level = 176; // -80 dBm
695 range->avg_qual.noise = 0;
704 * Wireless Handler : set ap mac address
707 int iwctl_siwap(struct net_device *dev,
708 struct iw_request_info *info,
709 struct sockaddr *wrq,
712 PSDevice pDevice = (PSDevice)netdev_priv(dev);
713 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
715 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
717 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAP \n");
718 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
720 printk("SIOCSIWAP(??)-->In scanning...\n");
723 if (wrq->sa_family != ARPHRD_ETHER)
726 memset(pMgmt->abyDesireBSSID, 0xFF, 6);
727 memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
728 //2008-0409-05, <Add> by Einsn Liu
729 if((pDevice->bLinkPass == TRUE) &&
730 (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6)== 0)){
734 if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) ||
735 (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
736 printk("SIOCSIWAP:invalid desired BSSID return!\n");
739 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
740 // then ignore,because you don't known which one to be connect with??
742 UINT ii , uSameBssidNum=0;
743 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
744 if (pMgmt->sBSSList[ii].bActive &&
745 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) {
749 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
750 printk("SIOCSIWAP:ignore for desired AP in hidden mode\n");
754 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
755 pDevice->bCommit = TRUE;
762 * Wireless Handler : get ap mac address
765 int iwctl_giwap(struct net_device *dev,
766 struct iw_request_info *info,
767 struct sockaddr *wrq,
770 PSDevice pDevice = (PSDevice)netdev_priv(dev);
771 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
774 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
776 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
777 //2008-0410,<Modify> by Einsn Liu
778 if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
779 memset(wrq->sa_data, 0, 6);
781 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
782 memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
785 wrq->sa_family = ARPHRD_ETHER;
793 * Wireless Handler : get ap list
796 int iwctl_giwaplist(struct net_device *dev,
797 struct iw_request_info *info,
798 struct iw_point *wrq,
802 struct sockaddr sock[IW_MAX_AP];
803 struct iw_quality qual[IW_MAX_AP];
804 PSDevice pDevice = (PSDevice)netdev_priv(dev);
805 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
808 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
809 // Only super-user can see AP list
811 if (!capable(CAP_NET_ADMIN)) {
818 PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
820 for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
821 pBSS = &(pMgmt->sBSSList[ii]);
824 if ( jj >= IW_MAX_AP)
826 memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
827 sock[jj].sa_family = ARPHRD_ETHER;
828 qual[jj].level = pBSS->uRSSI;
829 qual[jj].qual = qual[jj].noise = 0;
830 qual[jj].updated = 2;
834 wrq->flags = 1; // Should be define'd
836 memcpy(extra, sock, sizeof(struct sockaddr)*jj);
837 memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
845 * Wireless Handler : set essid
848 int iwctl_siwessid(struct net_device *dev,
849 struct iw_request_info *info,
850 struct iw_point *wrq,
853 PSDevice pDevice = (PSDevice)netdev_priv(dev);
854 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
855 PWLAN_IE_SSID pItemSSID;
856 //2008-0409-05, <Add> by Einsn Liu
860 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID \n");
861 pDevice->fWPA_Authened = FALSE;
862 if (pMgmt->eScanState == WMAC_IS_SCANNING) {
864 printk("SIOCSIWESSID(??)-->In scanning...\n");
867 // Check if we asked for `any'
868 if(wrq->flags == 0) {
869 // Just send an empty SSID list
870 // Just send an empty SSID list
871 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
872 memset(pMgmt->abyDesireBSSID, 0xFF,6);
873 printk("set essid to 'any' \n");
874 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
875 //Unknown desired AP,so here need not associate??
876 //if(pDevice->bWPASuppWextEnabled == TRUE) {
882 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
883 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
884 pItemSSID->byElementID = WLAN_EID_SSID;
885 memcpy(pItemSSID->abySSID, extra, wrq->length);
886 if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
888 pItemSSID->len = wrq->length - 1;
891 pItemSSID->len = wrq->length;
892 printk("set essid to %s \n",pItemSSID->abySSID);
893 //2008-0409-05, <Add> by Einsn Liu
894 len=(pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)?pItemSSID->len:((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len;
895 if((pDevice->bLinkPass == TRUE) &&
896 (memcmp(pItemSSID->abySSID,((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,len)==0))
899 //mike:need clear desiredBSSID
900 if(pItemSSID->len==0) {
901 memset(pMgmt->abyDesireBSSID, 0xFF,6);
905 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
906 //Wext wil order another command of siwap to link with desired AP,
907 //so here need not associate??
908 if(pDevice->bWPASuppWextEnabled == TRUE) {
909 /*******search if in hidden ssid mode ****/
911 PKnownBSS pCurr = NULL;
912 BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
913 UINT ii , uSameBssidNum=0;
915 memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID));
916 memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
917 pCurr = BSSpSearchBSSList(pDevice,
920 pMgmt->eConfigPHYMode
924 printk("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
925 vResetCommandTimer((HANDLE) pDevice);
926 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
927 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
928 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
930 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
931 // by means of judging if there are two same BSSID exist in list ?
932 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
933 if (pMgmt->sBSSList[ii].bActive &&
934 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
938 if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
939 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
940 vResetCommandTimer((HANDLE) pDevice);
941 pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
942 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
943 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
951 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
953 DBG_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID2 \n");
954 pItemSSID->len = wrq->length;
958 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
959 pDevice->bCommit = TRUE;
968 * Wireless Handler : get essid
971 int iwctl_giwessid(struct net_device *dev,
972 struct iw_request_info *info,
973 struct iw_point *wrq,
977 PSDevice pDevice = (PSDevice)netdev_priv(dev);
978 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
979 PWLAN_IE_SSID pItemSSID;
981 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
983 // Note : if wrq->u.data.flags != 0, we should
984 // get the relevant SSID from the SSID list...
986 // Get the current SSID
987 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
988 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
989 memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
990 extra[pItemSSID->len] = '\0';
991 wrq->length = pItemSSID->len + 1;
992 //2008-0409-03, <Add> by Einsn Liu
993 wrq->length = pItemSSID->len;
994 wrq->flags = 1; // active
1001 * Wireless Handler : set data rate
1004 int iwctl_siwrate(struct net_device *dev,
1005 struct iw_request_info *info,
1006 struct iw_param *wrq,
1009 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1013 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1016 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
1017 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1022 // First : get a valid bit rate value
1024 // Which type of value
1025 if((wrq->value < 13) &&
1026 (wrq->value >= 0)) {
1027 // Setting by rate index
1028 // Find value in the magic rate table
1031 // Setting by frequency value
1032 u8 normvalue = (u8) (wrq->value/500000);
1034 // Check if rate is valid
1035 for(i = 0 ; i < 13 ; i++) {
1036 if(normvalue == abySupportedRates[i]) {
1042 // -1 designed the max rate (mostly auto mode)
1043 if(wrq->value == -1) {
1044 // Get the highest available rate
1045 for(i = 0 ; i < 13 ; i++) {
1046 if(abySupportedRates[i] == 0)
1053 // Check that it is valid
1054 // brate is index of abySupportedRates[]
1060 // Now, check if we want a fixed or auto value
1061 if(wrq->fixed != 0) {
1064 printk("Rate Fix\n");
1065 pDevice->bFixRate = TRUE;
1066 if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
1068 pDevice->uConnectionRate = 3;
1071 pDevice->uConnectionRate = brate;
1072 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
1077 pDevice->bFixRate = FALSE;
1078 pDevice->uConnectionRate = 13;
1079 printk("auto rate:connection_rate is 13\n");
1086 * Wireless Handler : get data rate
1089 int iwctl_giwrate(struct net_device *dev,
1090 struct iw_request_info *info,
1091 struct iw_param *wrq,
1094 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1095 //2007-0118-05,<Mark> by EinsnLiu
1096 //Mark the unnecessary sentences.
1097 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1099 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
1101 BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1103 //2008-5-8 <modify> by chester
1104 if(pDevice->bLinkPass){
1105 if(pDevice->bFixRate == TRUE){
1106 if (pDevice->uConnectionRate < 13) {
1107 brate = abySupportedRates[pDevice->uConnectionRate];
1109 if (pDevice->byBBType == BB_TYPE_11B)
1111 if (pDevice->byBBType == BB_TYPE_11G)
1113 if (pDevice->byBBType == BB_TYPE_11A)
1120 brate = abySupportedRates[TxRate_iwconfig];
1124 //2007-0118-05,<Mark> by EinsnLiu
1125 //Mark the unnecessary sentences.
1127 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1128 if (pDevice->byBBType == BB_TYPE_11B)
1130 if (pDevice->byBBType == BB_TYPE_11G)
1132 if (pDevice->byBBType == BB_TYPE_11A)
1137 // if (pDevice->uConnectionRate == 13)
1138 // brate = abySupportedRates[pDevice->wCurrentRate];
1139 wrq->value = brate * 500000;
1140 // If more than one rate, set auto
1141 if (pDevice->bFixRate == TRUE)
1152 * Wireless Handler : set rts threshold
1155 int iwctl_siwrts(struct net_device *dev,
1156 struct iw_request_info *info,
1157 struct iw_param *wrq,
1160 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1163 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
1166 int rthr = wrq->value;
1169 if((rthr < 0) || (rthr > 2312)) {
1172 pDevice->wRTSThreshold = rthr;
1180 * Wireless Handler : get rts
1183 int iwctl_giwrts(struct net_device *dev,
1184 struct iw_request_info *info,
1185 struct iw_param *wrq,
1188 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1190 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
1191 wrq->value = pDevice->wRTSThreshold;
1192 wrq->disabled = (wrq->value >= 2312);
1199 * Wireless Handler : set fragment threshold
1202 int iwctl_siwfrag(struct net_device *dev,
1203 struct iw_request_info *info,
1204 struct iw_param *wrq,
1207 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1209 int fthr = wrq->value;
1212 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
1217 if((fthr < 256) || (fthr > 2312)) {
1220 fthr &= ~0x1; // Get an even value
1221 pDevice->wFragmentationThreshold = (u16)fthr;
1228 * Wireless Handler : get fragment threshold
1231 int iwctl_giwfrag(struct net_device *dev,
1232 struct iw_request_info *info,
1233 struct iw_param *wrq,
1236 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1238 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
1239 wrq->value = pDevice->wFragmentationThreshold;
1240 wrq->disabled = (wrq->value >= 2312);
1249 * Wireless Handler : set retry threshold
1251 int iwctl_siwretry(struct net_device *dev,
1252 struct iw_request_info *info,
1253 struct iw_param *wrq,
1256 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1260 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
1262 if (wrq->disabled) {
1267 if (wrq->flags & IW_RETRY_LIMIT) {
1268 if(wrq->flags & IW_RETRY_MAX)
1269 pDevice->byLongRetryLimit = wrq->value;
1270 else if (wrq->flags & IW_RETRY_MIN)
1271 pDevice->byShortRetryLimit = wrq->value;
1273 // No modifier : set both
1274 pDevice->byShortRetryLimit = wrq->value;
1275 pDevice->byLongRetryLimit = wrq->value;
1278 if (wrq->flags & IW_RETRY_LIFETIME) {
1279 pDevice->wMaxTransmitMSDULifetime = wrq->value;
1287 * Wireless Handler : get retry threshold
1289 int iwctl_giwretry(struct net_device *dev,
1290 struct iw_request_info *info,
1291 struct iw_param *wrq,
1294 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1295 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
1296 wrq->disabled = 0; // Can't be disabled
1298 // Note : by default, display the min retry number
1299 if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1300 wrq->flags = IW_RETRY_LIFETIME;
1301 wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
1302 } else if((wrq->flags & IW_RETRY_MAX)) {
1303 wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1304 wrq->value = (int)pDevice->byLongRetryLimit;
1306 wrq->flags = IW_RETRY_LIMIT;
1307 wrq->value = (int)pDevice->byShortRetryLimit;
1308 if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
1309 wrq->flags |= IW_RETRY_MIN;
1318 * Wireless Handler : set encode mode
1320 int iwctl_siwencode(struct net_device *dev,
1321 struct iw_request_info *info,
1322 struct iw_point *wrq,
1325 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1326 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1327 DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
1329 int index = (wrq->flags & IW_ENCODE_INDEX);
1331 //2007-0207-07,<Modify> by EinsnLiu
1332 //There are some problems when using iwconfig encode/key command to set the WEP key.
1333 //I almost rewrite this function.
1334 //now it support:(assume the wireless interface's name is eth0)
1335 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1336 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1337 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1338 //iwconfig eth0 key restricted /*enable share key*/
1342 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1344 if((wrq->flags & IW_ENCODE_DISABLED)==0){
1345 //Not disable encryption
1347 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1352 if(dwKeyIndex<1&&((wrq->flags&IW_ENCODE_NOKEY)==0)){//set default key
1353 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1354 dwKeyIndex=pDevice->byKeyIndex;
1360 // Check the size of the key
1361 if (wrq->length > WLAN_WEP232_KEYLEN) {
1366 if(wrq->length>0){//have key
1368 if (wrq->length == WLAN_WEP232_KEYLEN) {
1369 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1371 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1372 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1374 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1375 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1376 }else {//no support length
1380 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1381 memcpy(pDevice->abyKey, extra, wrq->length);
1383 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1384 for (ii = 0; ii < wrq->length; ii++) {
1385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1388 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1389 spin_lock_irq(&pDevice->lock);
1390 KeybSetDefaultKey(&(pDevice->sKey),
1391 (DWORD)(dwKeyIndex | (1 << 31)),
1396 pDevice->PortOffset,
1399 spin_unlock_irq(&pDevice->lock);
1401 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1402 pDevice->uKeyLength = wrq->length;
1403 pDevice->bTransmitKey = TRUE;
1404 pDevice->bEncryptionEnable = TRUE;
1405 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1408 //when the length is 0 the request only changes the default transmit key index
1409 //check the new key has a non zero lenget
1410 if(pDevice->bEncryptionEnable==FALSE)
1415 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Just set Default key Index:\n");
1416 pkeytab=&(pDevice->sKey.KeyTable[MAX_KEY_TABLE-1]);
1417 if(pkeytab->GroupKey[(BYTE)dwKeyIndex].uKeyLength==0){
1418 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Default key len is 0\n");
1422 pDevice->byKeyIndex =(BYTE)dwKeyIndex;
1423 pkeytab->dwGTKeyIndex =dwKeyIndex | (1 << 31);
1424 pkeytab->GroupKey[(BYTE)dwKeyIndex].dwKeyIndex=dwKeyIndex | (1 << 31);
1427 }else {//disable the key
1428 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1429 if(pDevice->bEncryptionEnable==FALSE)
1431 pMgmt->bShareKeyAlgorithm = FALSE;
1432 pDevice->bEncryptionEnable = FALSE;
1433 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1434 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1435 spin_lock_irq(&pDevice->lock);
1436 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1437 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1438 spin_unlock_irq(&pDevice->lock);
1444 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1446 // Check the size of the key
1447 if (wrq->length > WLAN_WEP232_KEYLEN) {
1452 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1460 // Send the key to the card
1461 if (wrq->length > 0) {
1463 if (wrq->length == WLAN_WEP232_KEYLEN) {
1464 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1466 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1467 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1469 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1470 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1472 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1473 memcpy(pDevice->abyKey, extra, wrq->length);
1475 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1476 for (ii = 0; ii < wrq->length; ii++) {
1477 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1480 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1481 spin_lock_irq(&pDevice->lock);
1482 KeybSetDefaultKey(&(pDevice->sKey),
1483 (DWORD)(pDevice->byKeyIndex | (1 << 31)),
1484 pDevice->uKeyLength,
1488 pDevice->PortOffset,
1491 spin_unlock_irq(&pDevice->lock);
1493 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1494 pDevice->uKeyLength = wrq->length;
1495 pDevice->bTransmitKey = TRUE;
1496 pDevice->bEncryptionEnable = TRUE;
1497 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1499 // Do we want to just set the transmit key index ?
1501 pDevice->byKeyIndex = index;
1503 else if(!wrq->flags & IW_ENCODE_MODE) {
1509 if(wrq->flags & IW_ENCODE_DISABLED){
1511 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1512 pMgmt->bShareKeyAlgorithm = FALSE;
1513 pDevice->bEncryptionEnable = FALSE;
1514 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1515 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1516 spin_lock_irq(&pDevice->lock);
1517 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1518 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1519 spin_unlock_irq(&pDevice->lock);
1524 if(wrq->flags & IW_ENCODE_RESTRICTED) {
1525 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
1526 pMgmt->bShareKeyAlgorithm = TRUE;
1528 if(wrq->flags & IW_ENCODE_OPEN) {
1529 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
1530 pMgmt->bShareKeyAlgorithm = FALSE;
1536 * Wireless Handler : get encode mode
1539 int iwctl_giwencode(struct net_device *dev,
1540 struct iw_request_info *info,
1541 struct iw_point *wrq,
1544 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1545 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1547 char abyKey[WLAN_WEP232_KEYLEN];
1548 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1549 PSKeyItem pKey = NULL;
1551 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1552 //2007-0207-06,<Add> by EinsnLiu
1553 //the key index in iwconfig is 1-4 when our driver is 0-3
1554 //so it can't be used directly.
1555 //if the index is 0,we should used the index set by driver.
1556 if (index > WLAN_WEP_NKEYS) {
1560 if(index<1){//set default key
1561 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1562 index=pDevice->byKeyIndex;
1568 memset(abyKey, 0, sizeof(abyKey));
1569 // Check encryption mode
1570 wrq->flags = IW_ENCODE_NOKEY;
1571 // Is WEP enabled ???
1572 if (pDevice->bEncryptionEnable)
1573 wrq->flags |= IW_ENCODE_ENABLED;
1575 wrq->flags |= IW_ENCODE_DISABLED;
1577 if (pMgmt->bShareKeyAlgorithm)
1578 wrq->flags |= IW_ENCODE_RESTRICTED;
1580 wrq->flags |= IW_ENCODE_OPEN;
1582 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1583 wrq->length = pKey->uKeyLength;
1584 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1585 //2007-0207-06,<Modify> by EinsnLiu
1586 //only get key success need to copy data
1588 //there is not necessary to return -EINVAL when get key failed
1589 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1590 wrq->flags |= index+1;
1591 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1606 //2008-0409-06, <Add> by Einsn Liu
1608 int iwctl_giwencode(struct net_device *dev,
1609 struct iw_request_info *info,
1610 struct iw_point *wrq,
1613 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1614 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1615 char abyKey[WLAN_WEP232_KEYLEN];
1617 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1618 PSKeyItem pKey = NULL;
1620 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1622 if (index > WLAN_WEP_NKEYS) {
1625 if(index<1){//get default key
1626 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1627 index=pDevice->byKeyIndex;
1633 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1634 // Check encryption mode
1635 wrq->flags = IW_ENCODE_NOKEY;
1636 // Is WEP enabled ???
1637 if (pDevice->bEncryptionEnable)
1638 wrq->flags |= IW_ENCODE_ENABLED;
1640 wrq->flags |= IW_ENCODE_DISABLED;
1642 if (pMgmt->bShareKeyAlgorithm)
1643 wrq->flags |= IW_ENCODE_RESTRICTED;
1645 wrq->flags |= IW_ENCODE_OPEN;
1648 if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
1649 pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
1650 if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
1651 wrq->length = pKey->uKeyLength;
1652 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1653 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1655 }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1656 wrq->length = pKey->uKeyLength;
1657 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1658 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1661 wrq->flags |= index+1;
1667 * Wireless Handler : set power mode
1669 int iwctl_siwpower(struct net_device *dev,
1670 struct iw_request_info *info,
1671 struct iw_param *wrq,
1674 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1675 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1678 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
1680 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
1685 if (wrq->disabled) {
1686 pDevice->ePSMode = WMAC_POWER_CAM;
1687 PSvDisablePowerSaving(pDevice);
1690 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1691 pDevice->ePSMode = WMAC_POWER_FAST;
1692 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1694 } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
1695 pDevice->ePSMode = WMAC_POWER_FAST;
1696 PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);
1698 switch (wrq->flags & IW_POWER_MODE) {
1699 case IW_POWER_UNICAST_R:
1700 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1703 case IW_POWER_ALL_R:
1704 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
1707 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
1717 * Wireless Handler : get power mode
1719 int iwctl_giwpower(struct net_device *dev,
1720 struct iw_request_info *info,
1721 struct iw_param *wrq,
1724 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1725 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1726 int mode = pDevice->ePSMode;
1729 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
1732 if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
1735 if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1736 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1737 wrq->flags = IW_POWER_TIMEOUT;
1739 wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
1740 wrq->flags = IW_POWER_PERIOD;
1742 wrq->flags |= IW_POWER_ALL_R;
1749 * Wireless Handler : get Sensitivity
1751 int iwctl_giwsens(struct net_device *dev,
1752 struct iw_request_info *info,
1753 struct iw_param *wrq,
1756 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1759 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
1760 if (pDevice->bLinkPass == TRUE) {
1761 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1767 wrq->disabled = (wrq->value == 0);
1774 //2008-0409-07, <Add> by Einsn Liu
1775 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1777 int iwctl_siwauth(struct net_device *dev,
1778 struct iw_request_info *info,
1779 struct iw_param *wrq,
1782 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1783 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1785 static int wpa_version=0; //must be static to save the last value,einsn liu
1786 static int pairwise=0;
1788 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
1789 switch (wrq->flags & IW_AUTH_INDEX) {
1790 case IW_AUTH_WPA_VERSION:
1791 wpa_version = wrq->value;
1792 if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
1793 printk("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1794 //pDevice->bWPADevEnable = FALSE;
1796 else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
1797 printk("iwctl_siwauth:set WPADEV to WPA1******\n");
1800 printk("iwctl_siwauth:set WPADEV to WPA2******\n");
1802 //pDevice->bWPASuppWextEnabled =TRUE;
1804 case IW_AUTH_CIPHER_PAIRWISE:
1805 pairwise = wrq->value;
1807 if(pairwise == IW_AUTH_CIPHER_CCMP){
1808 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1809 }else if(pairwise == IW_AUTH_CIPHER_TKIP){
1810 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1811 }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
1812 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1813 }else if(pairwise == IW_AUTH_CIPHER_NONE){
1814 //do nothing,einsn liu
1815 }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1818 case IW_AUTH_CIPHER_GROUP:
1819 if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
1821 if(pairwise == IW_AUTH_CIPHER_NONE){
1822 if(wrq->value == IW_AUTH_CIPHER_CCMP){
1823 pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
1825 pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
1829 case IW_AUTH_KEY_MGMT:
1831 if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
1832 if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1833 pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
1834 else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
1835 }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
1836 if(wrq->value == 0){
1837 pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
1838 }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
1839 pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
1840 else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
1844 case IW_AUTH_TKIP_COUNTERMEASURES:
1846 case IW_AUTH_DROP_UNENCRYPTED:
1848 case IW_AUTH_80211_AUTH_ALG:
1849 if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
1850 pMgmt->bShareKeyAlgorithm=FALSE;
1851 }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
1852 pMgmt->bShareKeyAlgorithm=TRUE;
1855 case IW_AUTH_WPA_ENABLED:
1856 //pDevice->bWPADevEnable = !! wrq->value;
1858 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1860 case IW_AUTH_ROAMING_CONTROL:
1863 case IW_AUTH_PRIVACY_INVOKED:
1864 pDevice->bEncryptionEnable = !!wrq->value;
1865 if(pDevice->bEncryptionEnable == FALSE){
1868 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1869 pMgmt->bShareKeyAlgorithm = FALSE;
1870 pMgmt->eAuthenMode = FALSE;
1871 //pDevice->bWPADevEnable = FALSE;
1880 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1881 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1882 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1883 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1884 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1885 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1886 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");
1892 int iwctl_giwauth(struct net_device *dev,
1893 struct iw_request_info *info,
1894 struct iw_param *wrq,
1902 int iwctl_siwgenie(struct net_device *dev,
1903 struct iw_request_info *info,
1904 struct iw_point *wrq,
1907 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1908 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1912 if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
1916 if(wrq->length > MAX_WPA_IE_LEN){
1920 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1921 if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
1925 pMgmt->wWPAIELen = wrq->length;
1927 memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
1928 pMgmt->wWPAIELen = 0;
1931 out://not completely ...not necessary in wpa_supplicant 0.5.8
1935 int iwctl_giwgenie(struct net_device *dev,
1936 struct iw_request_info *info,
1937 struct iw_point *wrq,
1940 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1941 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1943 int space = wrq->length;
1946 if(pMgmt->wWPAIELen > 0){
1947 wrq->length = pMgmt->wWPAIELen;
1948 if(pMgmt->wWPAIELen <= space){
1949 if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
1960 int iwctl_siwencodeext(struct net_device *dev,
1961 struct iw_request_info *info,
1962 struct iw_point *wrq,
1965 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1966 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
1967 struct viawget_wpa_param *param=NULL;
1971 int key_idx, set_tx;
1972 u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
1974 size_t seq_len,key_len=0;
1982 printk("SIOCSIWENCODEEXT...... \n");
1984 blen = sizeof(*param);
1985 buf = kmalloc((int)blen, (int)GFP_KERNEL);
1988 memset(buf, 0, blen);
1989 param = (struct viawget_wpa_param *) buf;
1993 case IW_ENCODE_ALG_NONE:
1994 alg_name = WPA_ALG_NONE;
1996 case IW_ENCODE_ALG_WEP:
1997 alg_name = WPA_ALG_WEP;
1999 case IW_ENCODE_ALG_TKIP:
2000 alg_name = WPA_ALG_TKIP;
2002 case IW_ENCODE_ALG_CCMP:
2003 alg_name = WPA_ALG_CCMP;
2006 printk("Unknown alg = %d\n",ext->alg);
2011 memcpy(addr, ext->addr.sa_data, ETH_ALEN);
2013 key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
2015 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2017 //recover seq,seq_len
2018 if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
2019 seq_len=IW_ENCODE_SEQ_MAX_SIZE;
2020 memcpy(seq, ext->rx_seq, seq_len);
2022 //recover key,key_len
2024 key_len=ext->key_len;
2025 memcpy(key, &ext->key[0], key_len);
2028 memset(key_array, 0, 64);
2030 memcpy(key_array, key, key_len);
2031 if (key_len == 32) {
2032 // notice ! the oder
2033 memcpy(&key_array[16], &key[24], 8);
2034 memcpy(&key_array[24], &key[16], 8);
2038 /**************Translate iw_encode_ext to viawget_wpa_param****************/
2039 memcpy(param->addr, addr, ETH_ALEN);
2040 param->u.wpa_key.alg_name = (int)alg_name;
2041 param->u.wpa_key.set_tx = set_tx;
2042 param->u.wpa_key.key_index = key_idx;
2043 param->u.wpa_key.key_len = key_len;
2044 param->u.wpa_key.key = (u8 *)key_array;
2045 param->u.wpa_key.seq = (u8 *)seq;
2046 param->u.wpa_key.seq_len = seq_len;
2050 printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
2051 printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
2052 param->addr[0],param->addr[1],param->addr[2],
2053 param->addr[3],param->addr[4],param->addr[5]);
2054 printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
2055 printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
2056 printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
2057 printk("param->u.wpa_key.key =");
2058 for(ii=0;ii<param->u.wpa_key.key_len;ii++)
2059 printk("%02x:",param->u.wpa_key.key[ii]);
2061 printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
2062 printk("param->u.wpa_key.seq =");
2063 for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
2064 printk("%02x:",param->u.wpa_key.seq[ii]);
2067 printk("...........\n");
2069 //****set if current action is Network Manager count??
2070 //****this method is so foolish,but there is no other way???
2071 if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
2072 if(param->u.wpa_key.key_index ==0) {
2073 pDevice->bwextcount++;
2075 if((pDevice->bwextcount == 1)&&(param->u.wpa_key.key_index ==1)) {
2076 pDevice->bwextcount++;
2078 if((pDevice->bwextcount ==2)&&(param->u.wpa_key.key_index ==2)) {
2079 pDevice->bwextcount++;
2081 if((pDevice->bwextcount ==3)&&(param->u.wpa_key.key_index ==3)) {
2082 pDevice->bwextcount++;
2085 if( pDevice->bwextcount == 4) {
2086 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2087 pDevice->bwextcount=0;
2088 pDevice->bWPASuppWextEnabled = TRUE;
2092 spin_lock_irq(&pDevice->lock);
2093 ret = wpa_set_keys(pDevice, param, TRUE);
2094 spin_unlock_irq(&pDevice->lock);
2103 int iwctl_giwencodeext(struct net_device *dev,
2104 struct iw_request_info *info,
2105 struct iw_point *wrq,
2108 return -EOPNOTSUPP;;
2111 int iwctl_siwmlme(struct net_device *dev,
2112 struct iw_request_info * info,
2113 struct iw_point *wrq,
2116 PSDevice pDevice = (PSDevice)netdev_priv(dev);
2117 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
2118 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2119 //u16 reason = cpu_to_le16(mlme->reason_code);
2122 if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
2127 case IW_MLME_DEAUTH:
2128 //this command seems to be not complete,please test it --einsnliu
2129 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2131 case IW_MLME_DISASSOC:
2132 if(pDevice->bLinkPass == TRUE){
2133 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2134 //clear related flags
2135 memset(pMgmt->abyDesireBSSID, 0xFF,6);
2136 KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
2137 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
2151 /*------------------------------------------------------------------*/
2153 * Structures to export the Wireless Handlers
2158 static const iw_handler iwctl_handler[] =
2160 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2161 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2162 (iw_handler) NULL, // SIOCSIWNWID
2163 (iw_handler) NULL, // SIOCGIWNWID
2164 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2165 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2166 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2167 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2168 (iw_handler) NULL, // SIOCSIWSENS
2169 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2170 (iw_handler) NULL, // SIOCSIWRANGE
2171 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2172 (iw_handler) NULL, // SIOCSIWPRIV
2173 (iw_handler) NULL, // SIOCGIWPRIV
2174 (iw_handler) NULL, // SIOCSIWSTATS
2175 (iw_handler) NULL, // SIOCGIWSTATS
2176 (iw_handler) NULL, // SIOCSIWSPY
2177 (iw_handler) NULL, // SIOCGIWSPY
2178 (iw_handler) NULL, // -- hole --
2179 (iw_handler) NULL, // -- hole --
2180 (iw_handler) iwctl_siwap, // SIOCSIWAP
2181 (iw_handler) iwctl_giwap, // SIOCGIWAP
2182 (iw_handler) NULL, // -- hole -- 0x16
2183 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2184 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2185 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2186 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2187 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2188 (iw_handler) NULL, // SIOCSIWNICKN
2189 (iw_handler) NULL, // SIOCGIWNICKN
2190 (iw_handler) NULL, // -- hole --
2191 (iw_handler) NULL, // -- hole --
2192 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2193 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2194 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2195 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2196 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2197 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2198 (iw_handler) NULL, // SIOCSIWTXPOW
2199 (iw_handler) NULL, // SIOCGIWTXPOW
2200 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2201 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2202 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2203 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2204 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2205 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2206 (iw_handler) NULL, // -- hole --
2207 (iw_handler) NULL, // -- hole --
2208 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2209 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2210 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2211 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2212 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2213 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2214 (iw_handler) NULL, // SIOCSIWPMKSA
2215 (iw_handler) NULL, // -- hole --
2220 static const iw_handler iwctl_handler[] =
2222 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2223 (iw_handler) NULL, // SIOCGIWNAME
2224 (iw_handler) NULL, // SIOCSIWNWID
2225 (iw_handler) NULL, // SIOCGIWNWID
2226 (iw_handler) NULL, // SIOCSIWFREQ
2227 (iw_handler) NULL, // SIOCGIWFREQ
2228 (iw_handler) NULL, // SIOCSIWMODE
2229 (iw_handler) NULL, // SIOCGIWMODE
2230 (iw_handler) NULL, // SIOCSIWSENS
2231 (iw_handler) NULL, // SIOCGIWSENS
2232 (iw_handler) NULL, // SIOCSIWRANGE
2233 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2234 (iw_handler) NULL, // SIOCSIWPRIV
2235 (iw_handler) NULL, // SIOCGIWPRIV
2236 (iw_handler) NULL, // SIOCSIWSTATS
2237 (iw_handler) NULL, // SIOCGIWSTATS
2238 (iw_handler) NULL, // SIOCSIWSPY
2239 (iw_handler) NULL, // SIOCGIWSPY
2240 (iw_handler) NULL, // -- hole --
2241 (iw_handler) NULL, // -- hole --
2242 (iw_handler) NULL, // SIOCSIWAP
2243 (iw_handler) NULL, // SIOCGIWAP
2244 (iw_handler) NULL, // -- hole -- 0x16
2245 (iw_handler) NULL, // SIOCGIWAPLIST
2246 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2247 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2248 (iw_handler) NULL, // SIOCSIWESSID
2249 (iw_handler) NULL, // SIOCGIWESSID
2250 (iw_handler) NULL, // SIOCSIWNICKN
2251 (iw_handler) NULL, // SIOCGIWNICKN
2252 (iw_handler) NULL, // -- hole --
2253 (iw_handler) NULL, // -- hole --
2254 (iw_handler) NULL, // SIOCSIWRATE 0x20
2255 (iw_handler) NULL, // SIOCGIWRATE
2256 (iw_handler) NULL, // SIOCSIWRTS
2257 (iw_handler) NULL, // SIOCGIWRTS
2258 (iw_handler) NULL, // SIOCSIWFRAG
2259 (iw_handler) NULL, // SIOCGIWFRAG
2260 (iw_handler) NULL, // SIOCSIWTXPOW
2261 (iw_handler) NULL, // SIOCGIWTXPOW
2262 (iw_handler) NULL, // SIOCSIWRETRY
2263 (iw_handler) NULL, // SIOCGIWRETRY
2264 (iw_handler) NULL, // SIOCSIWENCODE
2265 (iw_handler) NULL, // SIOCGIWENCODE
2266 (iw_handler) NULL, // SIOCSIWPOWER
2267 (iw_handler) NULL, // SIOCGIWPOWER
2269 //2008-0409-07, <Add> by Einsn Liu
2270 (iw_handler) NULL, // -- hole --
2271 (iw_handler) NULL, // -- hole --
2272 (iw_handler) NULL, // SIOCSIWGENIE
2273 (iw_handler) NULL, // SIOCGIWGENIE
2274 (iw_handler) NULL, // SIOCSIWAUTH
2275 (iw_handler) NULL, // SIOCGIWAUTH
2276 (iw_handler) NULL, // SIOCSIWENCODEEXT
2277 (iw_handler) NULL, // SIOCGIWENCODEEXT
2278 (iw_handler) NULL, // SIOCSIWPMKSA
2279 (iw_handler) NULL, // -- hole --
2283 static const iw_handler iwctl_private_handler[] =
2285 NULL, // SIOCIWFIRSTPRIV
2289 struct iw_priv_args iwctl_private_args[] = {
2291 IW_PRIV_TYPE_CHAR | 1024, 0,
2297 const struct iw_handler_def iwctl_handler_def =
2299 .get_wireless_stats = &iwctl_get_wireless_stats,
2300 .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
2301 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2302 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2304 .num_private_args = 0,
2305 .standard = (iw_handler *) iwctl_handler,
2306 // .private = (iw_handler *) iwctl_private_handler,
2307 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2309 .private_args = NULL,