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
42 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
47 #include <net/iw_handler.h>
48 extern unsigned short TxRate_iwconfig
;//2008-5-8 <add> by chester
50 /*--------------------- Static Definitions -------------------------*/
52 //2008-0409-07, <Add> by Einsn Liu
53 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
54 #define SUPPORTED_WIRELESS_EXT 18
56 #define SUPPORTED_WIRELESS_EXT 17
59 static const long frequency_list
[] = {
60 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
61 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
62 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
63 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
64 5700, 5745, 5765, 5785, 5805, 5825
68 /*--------------------- Static Classes ----------------------------*/
71 //static int msglevel =MSG_LEVEL_DEBUG;
72 static int msglevel
=MSG_LEVEL_INFO
;
75 /*--------------------- Static Variables --------------------------*/
76 /*--------------------- Static Functions --------------------------*/
78 /*--------------------- Export Variables --------------------------*/
80 struct iw_statistics
*iwctl_get_wireless_stats(struct net_device
*dev
)
82 PSDevice pDevice
= netdev_priv(dev
);
85 pDevice
->wstats
.status
= pDevice
->eOPMode
;
87 if(pDevice
->scStatistic
.LinkQuality
> 100)
88 pDevice
->scStatistic
.LinkQuality
= 100;
89 pDevice
->wstats
.qual
.qual
=(unsigned char) pDevice
->scStatistic
.LinkQuality
;
91 pDevice
->wstats
.qual
.qual
= pDevice
->byCurrSQ
;
93 RFvRSSITodBm(pDevice
, (unsigned char)(pDevice
->uCurrRSSI
), &ldBm
);
94 pDevice
->wstats
.qual
.level
= ldBm
;
95 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
96 pDevice
->wstats
.qual
.noise
= 0;
97 pDevice
->wstats
.qual
.updated
= 1;
98 pDevice
->wstats
.discard
.nwid
= 0;
99 pDevice
->wstats
.discard
.code
= 0;
100 pDevice
->wstats
.discard
.fragment
= 0;
101 pDevice
->wstats
.discard
.retries
= (unsigned long)pDevice
->scStatistic
.dwTsrErr
;
102 pDevice
->wstats
.discard
.misc
= 0;
103 pDevice
->wstats
.miss
.beacon
= 0;
105 return &pDevice
->wstats
;
110 /*------------------------------------------------------------------*/
113 static int iwctl_commit(struct net_device
*dev
,
114 struct iw_request_info
*info
,
118 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWCOMMIT \n");
124 * Wireless Handler : get protocol name
127 int iwctl_giwname(struct net_device
*dev
,
128 struct iw_request_info
*info
,
132 strcpy(wrq
, "802.11-a/b/g");
137 * Wireless Handler : set scan
140 int iwctl_siwscan(struct net_device
*dev
,
141 struct iw_request_info
*info
,
142 struct iw_point
*wrq
,
145 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
146 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
147 struct iw_scan_req
*req
= (struct iw_scan_req
*)extra
;
148 unsigned char abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
149 PWLAN_IE_SSID pItemSSID
=NULL
;
150 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWSCAN \n");
153 if(pDevice
->byReAssocCount
> 0) { //reject scan when re-associating!
154 //send scan event to wpa_Supplicant
155 union iwreq_data wrqu
;
156 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
157 memset(&wrqu
, 0, sizeof(wrqu
));
158 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
162 spin_lock_irq(&pDevice
->lock
);
163 BSSvClearBSSList((void *)pDevice
, pDevice
->bLinkPass
);
165 //mike add: active scan OR passive scan OR desire_ssid scan
166 if(wrq
->length
== sizeof(struct iw_scan_req
)) {
167 if (wrq
->flags
& IW_SCAN_THIS_ESSID
) { //desire_ssid scan
168 memset(abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
169 pItemSSID
= (PWLAN_IE_SSID
)abyScanSSID
;
170 pItemSSID
->byElementID
= WLAN_EID_SSID
;
171 memcpy(pItemSSID
->abySSID
, req
->essid
, (int)req
->essid_len
);
172 if (pItemSSID
->abySSID
[req
->essid_len
- 1] == '\0') {
174 pItemSSID
->len
= req
->essid_len
- 1;
177 pItemSSID
->len
= req
->essid_len
;
178 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
179 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID
)abyScanSSID
)->abySSID
,
180 ((PWLAN_IE_SSID
)abyScanSSID
)->len
);
181 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, abyScanSSID
);
182 spin_unlock_irq(&pDevice
->lock
);
186 else if(req
->scan_type
== IW_SCAN_TYPE_PASSIVE
) { //passive scan
187 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
191 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
194 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
195 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
196 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
197 spin_unlock_irq(&pDevice
->lock
);
204 * Wireless Handler : get scan results
207 int iwctl_giwscan(struct net_device
*dev
,
208 struct iw_request_info
*info
,
209 struct iw_point
*wrq
,
213 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
214 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
216 PWLAN_IE_SSID pItemSSID
;
217 PWLAN_IE_SUPP_RATES pSuppRates
, pExtSuppRates
;
218 char *current_ev
= extra
;
219 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
220 char *current_val
= NULL
;
223 char buf
[MAX_WPA_IE_LEN
* 2 + 30];
226 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSCAN \n");
228 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
232 pBSS
= &(pMgmt
->sBSSList
[0]);
233 for (ii
= 0, jj
= 0; jj
< MAX_BSS_NUM
; jj
++) {
234 if (current_ev
>= end_buf
)
236 pBSS
= &(pMgmt
->sBSSList
[jj
]);
239 memset(&iwe
, 0, sizeof(iwe
));
241 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
242 memcpy(iwe
.u
.ap_addr
.sa_data
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
243 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
245 memset(&iwe
, 0, sizeof(iwe
));
246 iwe
.cmd
= SIOCGIWESSID
;
247 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
248 iwe
.u
.data
.length
= pItemSSID
->len
;
249 iwe
.u
.data
.flags
= 1;
250 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
252 memset(&iwe
, 0, sizeof(iwe
));
253 iwe
.cmd
= SIOCGIWMODE
;
254 if (WLAN_GET_CAP_INFO_ESS(pBSS
->wCapInfo
)) {
255 iwe
.u
.mode
= IW_MODE_INFRA
;
258 iwe
.u
.mode
= IW_MODE_ADHOC
;
260 iwe
.len
= IW_EV_UINT_LEN
;
261 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
263 pSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abySuppRates
;
264 pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abyExtSuppRates
;
265 memset(&iwe
, 0, sizeof(iwe
));
266 iwe
.cmd
= SIOCGIWFREQ
;
267 iwe
.u
.freq
.m
= pBSS
->uChannel
;
270 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
271 //2008-0409-04, <Add> by Einsn Liu
273 int f
= (int)pBSS
->uChannel
- 1;
275 iwe
.u
.freq
.m
= frequency_list
[f
] * 100000;
278 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
280 memset(&iwe
, 0, sizeof(iwe
));
282 RFvRSSITodBm(pDevice
, (unsigned char)(pBSS
->uRSSI
), &ldBm
);
283 iwe
.u
.qual
.level
= ldBm
;
284 iwe
.u
.qual
.noise
= 0;
285 //2008-0409-01, <Add> by Einsn Liu
287 iwe
.u
.qual
.qual
= 100;
288 }else if(-ldBm
> 90) {
291 iwe
.u
.qual
.qual
=(40-(-ldBm
-50))*100/40;
293 iwe
.u
.qual
.updated
=7;
295 // iwe.u.qual.qual = 0;
296 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
298 memset(&iwe
, 0, sizeof(iwe
));
299 iwe
.cmd
= SIOCGIWENCODE
;
300 iwe
.u
.data
.length
= 0;
301 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS
->wCapInfo
)) {
302 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
304 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
306 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
308 memset(&iwe
, 0, sizeof(iwe
));
309 iwe
.cmd
= SIOCGIWRATE
;
310 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
311 current_val
= current_ev
+ IW_EV_LCP_LEN
;
313 for (kk
= 0 ; kk
< 12 ; kk
++) {
314 if (pSuppRates
->abyRates
[kk
] == 0)
316 // Bit rate given in 500 kb/s units (+ 0x80)
317 iwe
.u
.bitrate
.value
= ((pSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
318 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
320 for (kk
= 0 ; kk
< 8 ; kk
++) {
321 if (pExtSuppRates
->abyRates
[kk
] == 0)
323 // Bit rate given in 500 kb/s units (+ 0x80)
324 iwe
.u
.bitrate
.value
= ((pExtSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
325 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
328 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
329 current_ev
= current_val
;
331 memset(&iwe
, 0, sizeof(iwe
));
332 iwe
.cmd
= IWEVCUSTOM
;
333 sprintf(buf
, "bcn_int=%d", pBSS
->wBeaconInterval
);
334 iwe
.u
.data
.length
= strlen(buf
);
335 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, buf
);
337 if ((pBSS
->wWPALen
> 0) && (pBSS
->wWPALen
<= MAX_WPA_IE_LEN
)) {
338 memset(&iwe
, 0, sizeof(iwe
));
340 iwe
.u
.data
.length
= pBSS
->wWPALen
;
341 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byWPAIE
);
344 if ((pBSS
->wRSNLen
> 0) && (pBSS
->wRSNLen
<= MAX_WPA_IE_LEN
)) {
345 memset(&iwe
, 0, sizeof(iwe
));
347 iwe
.u
.data
.length
= pBSS
->wRSNLen
;
348 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byRSNIE
);
354 wrq
->length
= current_ev
- extra
;
361 * Wireless Handler : set frequence or channel
364 int iwctl_siwfreq(struct net_device
*dev
,
365 struct iw_request_info
*info
,
369 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
372 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFREQ \n");
374 // If setting by frequency, convert to a channel
376 (wrq
->m
>= (int) 2.412e8
) &&
377 (wrq
->m
<= (int) 2.487e8
)) {
378 int f
= wrq
->m
/ 100000;
380 while((c
< 14) && (f
!= frequency_list
[c
]))
385 // Setting by channel number
386 if((wrq
->m
> 14) || (wrq
->e
> 0))
389 int channel
= wrq
->m
;
390 if((channel
< 1) || (channel
> 14)) {
391 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: New channel value of %d is invalid!\n", dev
->name
, wrq
->m
);
394 // Yes ! We can set it !!!
395 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set to channel = %d\n", channel
);
396 pDevice
->uChannel
= channel
;
397 //2007-0207-04,<Add> by EinsnLiu
398 //Make change effect at once
399 pDevice
->bCommit
= true;
407 * Wireless Handler : get frequence or channel
410 int iwctl_giwfreq(struct net_device
*dev
,
411 struct iw_request_info
*info
,
415 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
416 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
418 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFREQ \n");
420 #ifdef WEXT_USECHANNELS
421 wrq
->m
= (int)pMgmt
->uCurrChannel
;
425 int f
= (int)pMgmt
->uCurrChannel
- 1;
428 wrq
->m
= frequency_list
[f
] * 100000;
437 * Wireless Handler : set operation mode
440 int iwctl_siwmode(struct net_device
*dev
,
441 struct iw_request_info
*info
,
445 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
446 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
449 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWMODE \n");
451 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
&& pDevice
->bEnableHostapd
) {
452 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Can't set operation mode, hostapd is running \n");
459 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_IBSS_STA
) {
460 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
461 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
462 pDevice
->bCommit
= true;
465 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to ad-hoc \n");
469 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_ESS_STA
) {
470 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
471 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
472 pDevice
->bCommit
= true;
475 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to infrastructure \n");
479 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
483 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_AP
) {
484 pMgmt
->eConfigMode
= WMAC_CONFIG_AP
;
485 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
486 pDevice
->bCommit
= true;
489 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to Access Point \n");
493 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
504 * Wireless Handler : get operation mode
507 int iwctl_giwmode(struct net_device
*dev
,
508 struct iw_request_info
*info
,
512 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
513 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
516 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWMODE \n");
517 // If not managed, assume it's ad-hoc
518 switch (pMgmt
->eConfigMode
) {
519 case WMAC_CONFIG_ESS_STA
:
520 *wmode
= IW_MODE_INFRA
;
522 case WMAC_CONFIG_IBSS_STA
:
523 *wmode
= IW_MODE_ADHOC
;
525 case WMAC_CONFIG_AUTO
:
526 *wmode
= IW_MODE_INFRA
;
529 *wmode
= IW_MODE_MASTER
;
532 *wmode
= IW_MODE_ADHOC
;
540 * Wireless Handler : get capability range
543 int iwctl_giwrange(struct net_device
*dev
,
544 struct iw_request_info
*info
,
545 struct iw_point
*wrq
,
548 struct iw_range
*range
= (struct iw_range
*) extra
;
550 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
553 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRANGE \n");
555 wrq
->length
= sizeof(struct iw_range
);
556 memset(range
, 0, sizeof(struct iw_range
));
557 range
->min_nwid
= 0x0000;
558 range
->max_nwid
= 0x0000;
559 range
->num_channels
= 14;
560 // Should be based on cap_rid.country to give only
561 // what the current card support
563 for(i
= 0; i
< 14; i
++) {
564 range
->freq
[k
].i
= i
+ 1; // List index
565 range
->freq
[k
].m
= frequency_list
[i
] * 100000;
566 range
->freq
[k
++].e
= 1; // Values in table in MHz -> * 10^5 * 10
568 range
->num_frequency
= k
;
569 // Hum... Should put the right values there
570 #ifdef Calcu_LinkQual
571 range
->max_qual
.qual
= 100;
573 range
->max_qual
.qual
= 255;
575 range
->max_qual
.level
= 0;
576 range
->max_qual
.noise
= 0;
577 range
->sensitivity
= 255;
579 for(i
= 0 ; i
< 13 ; i
++) {
580 range
->bitrate
[i
] = abySupportedRates
[i
] * 500000;
581 if(range
->bitrate
[i
] == 0)
584 range
->num_bitrates
= i
;
586 // Set an indication of the max TCP throughput
587 // in bit/s that we can expect using this interface.
588 // May be use for QoS stuff... Jean II
590 range
->throughput
= 5 * 1000 * 1000;
592 range
->throughput
= 1.5 * 1000 * 1000;
595 range
->max_rts
= 2312;
596 range
->min_frag
= 256;
597 range
->max_frag
= 2312;
600 // the encoding capabilities
601 range
->num_encoding_sizes
= 3;
603 range
->encoding_size
[0] = 5;
605 range
->encoding_size
[1] = 13;
606 // 256 bits for WPA-PSK
607 range
->encoding_size
[2] = 32;
608 // 4 keys are allowed
609 range
->max_encoding_tokens
= 4;
611 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
612 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
615 range
->max_pmp
= 1000000;// 1 secs
617 range
->max_pmt
= 1000000;// 1 secs
618 range
->pmp_flags
= IW_POWER_PERIOD
;
619 range
->pmt_flags
= IW_POWER_TIMEOUT
;
620 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
622 // Transmit Power - values are in mW
624 range
->txpower
[0] = 100;
625 range
->num_txpower
= 1;
626 range
->txpower_capa
= IW_TXPOW_MWATT
;
627 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
628 range
->we_version_compiled
= WIRELESS_EXT
;
629 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
630 range
->retry_flags
= IW_RETRY_LIMIT
;
631 range
->r_time_flags
= IW_RETRY_LIFETIME
;
632 range
->min_retry
= 1;
633 range
->max_retry
= 65535;
634 range
->min_r_time
= 1024;
635 range
->max_r_time
= 65535 * 1024;
636 // Experimental measurements - boundary 11/5.5 Mb/s
637 // Note : with or without the (local->rssi), results
638 // are somewhat different. - Jean II
639 range
->avg_qual
.qual
= 6;
640 range
->avg_qual
.level
= 176; // -80 dBm
641 range
->avg_qual
.noise
= 0;
650 * Wireless Handler : set ap mac address
653 int iwctl_siwap(struct net_device
*dev
,
654 struct iw_request_info
*info
,
655 struct sockaddr
*wrq
,
658 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
659 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
661 unsigned char ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
663 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAP \n");
664 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
666 printk("SIOCSIWAP(??)-->In scanning...\n");
669 if (wrq
->sa_family
!= ARPHRD_ETHER
)
672 memcpy(pMgmt
->abyDesireBSSID
, wrq
->sa_data
, 6);
673 //2008-0409-05, <Add> by Einsn Liu
674 if((pDevice
->bLinkPass
== true) &&
675 (memcmp(pMgmt
->abyDesireBSSID
, pMgmt
->abyCurrBSSID
, 6)== 0)){
679 if ((is_broadcast_ether_addr(pMgmt
->abyDesireBSSID
)) ||
680 (memcmp(pMgmt
->abyDesireBSSID
, ZeroBSSID
, 6) == 0)){
681 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
684 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
685 // then ignore,because you don't known which one to be connect with??
687 unsigned int ii
, uSameBssidNum
=0;
688 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
689 if (pMgmt
->sBSSList
[ii
].bActive
&&
690 !compare_ether_addr(pMgmt
->sBSSList
[ii
].abyBSSID
, pMgmt
->abyDesireBSSID
)) {
694 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
695 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
700 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
701 pDevice
->bCommit
= true;
708 * Wireless Handler : get ap mac address
711 int iwctl_giwap(struct net_device
*dev
,
712 struct iw_request_info
*info
,
713 struct sockaddr
*wrq
,
716 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
717 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
720 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAP \n");
722 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
723 //2008-0410,<Modify> by Einsn Liu
724 if ((pDevice
->bLinkPass
== false) && (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
))
725 memset(wrq
->sa_data
, 0, 6);
727 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
728 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
731 wrq
->sa_family
= ARPHRD_ETHER
;
739 * Wireless Handler : get ap list
742 int iwctl_giwaplist(struct net_device
*dev
,
743 struct iw_request_info
*info
,
744 struct iw_point
*wrq
,
748 struct sockaddr sock
[IW_MAX_AP
];
749 struct iw_quality qual
[IW_MAX_AP
];
750 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
751 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
754 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAPLIST \n");
755 // Only super-user can see AP list
757 if (!capable(CAP_NET_ADMIN
)) {
764 PKnownBSS pBSS
= &(pMgmt
->sBSSList
[0]);
766 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
767 pBSS
= &(pMgmt
->sBSSList
[ii
]);
770 if ( jj
>= IW_MAX_AP
)
772 memcpy(sock
[jj
].sa_data
, pBSS
->abyBSSID
, 6);
773 sock
[jj
].sa_family
= ARPHRD_ETHER
;
774 qual
[jj
].level
= pBSS
->uRSSI
;
775 qual
[jj
].qual
= qual
[jj
].noise
= 0;
776 qual
[jj
].updated
= 2;
780 wrq
->flags
= 1; // Should be define'd
782 memcpy(extra
, sock
, sizeof(struct sockaddr
)*jj
);
783 memcpy(extra
+ sizeof(struct sockaddr
)*jj
, qual
, sizeof(struct iw_quality
)*jj
);
791 * Wireless Handler : set essid
794 int iwctl_siwessid(struct net_device
*dev
,
795 struct iw_request_info
*info
,
796 struct iw_point
*wrq
,
799 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
800 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
801 PWLAN_IE_SSID pItemSSID
;
802 //2008-0409-05, <Add> by Einsn Liu
806 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWESSID \n");
807 pDevice
->fWPA_Authened
= false;
808 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
810 printk("SIOCSIWESSID(??)-->In scanning...\n");
813 // Check if we asked for `any'
814 if(wrq
->flags
== 0) {
815 // Just send an empty SSID list
816 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
817 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
818 PRINT_K("set essid to 'any' \n");
819 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
820 //Unknown desired AP,so here need not associate??
821 //if(pDevice->bWPASuppWextEnabled == true) {
827 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
828 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
829 pItemSSID
->byElementID
= WLAN_EID_SSID
;
831 memcpy(pItemSSID
->abySSID
, extra
, wrq
->length
);
832 if (pItemSSID
->abySSID
[wrq
->length
- 1] == '\0') {
834 pItemSSID
->len
= wrq
->length
- 1;
837 pItemSSID
->len
= wrq
->length
;
838 printk("set essid to %s \n",pItemSSID
->abySSID
);
839 //2008-0409-05, <Add> by Einsn Liu
840 len
=(pItemSSID
->len
> ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)?pItemSSID
->len
:((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
;
841 if((pDevice
->bLinkPass
== true) &&
842 (memcmp(pItemSSID
->abySSID
,((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,len
)==0))
845 //mike:need clear desiredBSSID
846 if(pItemSSID
->len
==0) {
847 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
851 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
852 //Wext wil order another command of siwap to link with desired AP,
853 //so here need not associate??
854 if(pDevice
->bWPASuppWextEnabled
== true) {
855 /*******search if in hidden ssid mode ****/
857 PKnownBSS pCurr
= NULL
;
858 unsigned char abyTmpDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
859 unsigned int ii
, uSameBssidNum
=0;
861 memcpy(abyTmpDesireSSID
,pMgmt
->abyDesireSSID
,sizeof(abyTmpDesireSSID
));
862 pCurr
= BSSpSearchBSSList(pDevice
,
865 pMgmt
->eConfigPHYMode
869 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
870 vResetCommandTimer((void *) pDevice
);
871 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
872 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
873 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
875 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
876 // by means of judging if there are two same BSSID exist in list ?
877 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
878 if (pMgmt
->sBSSList
[ii
].bActive
&&
879 !compare_ether_addr(pMgmt
->sBSSList
[ii
].abyBSSID
, pCurr
->abyBSSID
)) {
883 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
884 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
885 vResetCommandTimer((void *) pDevice
);
886 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
; //this scan type,you'll submit scan result!
887 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
888 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
896 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set essid = %s \n", pItemSSID
->abySSID
);
899 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
900 pDevice
->bCommit
= true;
909 * Wireless Handler : get essid
912 int iwctl_giwessid(struct net_device
*dev
,
913 struct iw_request_info
*info
,
914 struct iw_point
*wrq
,
918 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
919 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
920 PWLAN_IE_SSID pItemSSID
;
922 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWESSID \n");
924 // Note : if wrq->u.data.flags != 0, we should
925 // get the relevant SSID from the SSID list...
927 // Get the current SSID
928 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
929 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
930 memcpy(extra
, pItemSSID
->abySSID
, pItemSSID
->len
);
931 extra
[pItemSSID
->len
] = '\0';
932 wrq
->length
= pItemSSID
->len
+ 1;
933 //2008-0409-03, <Add> by Einsn Liu
934 wrq
->length
= pItemSSID
->len
;
935 wrq
->flags
= 1; // active
942 * Wireless Handler : set data rate
945 int iwctl_siwrate(struct net_device
*dev
,
946 struct iw_request_info
*info
,
947 struct iw_param
*wrq
,
950 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
954 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
957 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRATE \n");
958 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
963 // First : get a valid bit rate value
965 // Which type of value
966 if((wrq
->value
< 13) &&
968 // Setting by rate index
969 // Find value in the magic rate table
972 // Setting by frequency value
973 u8 normvalue
= (u8
) (wrq
->value
/500000);
975 // Check if rate is valid
976 for(i
= 0 ; i
< 13 ; i
++) {
977 if(normvalue
== abySupportedRates
[i
]) {
983 // -1 designed the max rate (mostly auto mode)
984 if(wrq
->value
== -1) {
985 // Get the highest available rate
986 for(i
= 0 ; i
< 13 ; i
++) {
987 if(abySupportedRates
[i
] == 0)
994 // Check that it is valid
995 // brate is index of abySupportedRates[]
1001 // Now, check if we want a fixed or auto value
1002 if(wrq
->fixed
!= 0) {
1005 printk("Rate Fix\n");
1006 pDevice
->bFixRate
= true;
1007 if ((pDevice
->byBBType
== BB_TYPE_11B
)&& (brate
> 3)) {
1008 pDevice
->uConnectionRate
= 3;
1011 pDevice
->uConnectionRate
= brate
;
1012 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fixed to Rate %d \n", pDevice
->uConnectionRate
);
1017 pDevice
->bFixRate
= false;
1018 pDevice
->uConnectionRate
= 13;
1019 printk("auto rate:connection_rate is 13\n");
1026 * Wireless Handler : get data rate
1029 int iwctl_giwrate(struct net_device
*dev
,
1030 struct iw_request_info
*info
,
1031 struct iw_param
*wrq
,
1034 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1035 //2007-0118-05,<Mark> by EinsnLiu
1036 //Mark the unnecessary sentences.
1037 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1039 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRATE \n");
1041 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1043 //2008-5-8 <modify> by chester
1044 if(pDevice
->bLinkPass
){
1045 if(pDevice
->bFixRate
== true){
1046 if (pDevice
->uConnectionRate
< 13) {
1047 brate
= abySupportedRates
[pDevice
->uConnectionRate
];
1049 if (pDevice
->byBBType
== BB_TYPE_11B
)
1051 if (pDevice
->byBBType
== BB_TYPE_11G
)
1053 if (pDevice
->byBBType
== BB_TYPE_11A
)
1060 brate
= abySupportedRates
[TxRate_iwconfig
];
1064 //2007-0118-05,<Mark> by EinsnLiu
1065 //Mark the unnecessary sentences.
1067 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1068 if (pDevice->byBBType == BB_TYPE_11B)
1070 if (pDevice->byBBType == BB_TYPE_11G)
1072 if (pDevice->byBBType == BB_TYPE_11A)
1077 // if (pDevice->uConnectionRate == 13)
1078 // brate = abySupportedRates[pDevice->wCurrentRate];
1079 wrq
->value
= brate
* 500000;
1080 // If more than one rate, set auto
1081 if (pDevice
->bFixRate
== true)
1092 * Wireless Handler : set rts threshold
1095 int iwctl_siwrts(struct net_device
*dev
,
1096 struct iw_request_info
*info
,
1097 struct iw_param
*wrq
,
1100 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1103 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRTS \n");
1106 int rthr
= wrq
->value
;
1109 if((rthr
< 0) || (rthr
> 2312)) {
1112 pDevice
->wRTSThreshold
= rthr
;
1120 * Wireless Handler : get rts
1123 int iwctl_giwrts(struct net_device
*dev
,
1124 struct iw_request_info
*info
,
1125 struct iw_param
*wrq
,
1128 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1130 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRTS \n");
1131 wrq
->value
= pDevice
->wRTSThreshold
;
1132 wrq
->disabled
= (wrq
->value
>= 2312);
1139 * Wireless Handler : set fragment threshold
1142 int iwctl_siwfrag(struct net_device
*dev
,
1143 struct iw_request_info
*info
,
1144 struct iw_param
*wrq
,
1147 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1149 int fthr
= wrq
->value
;
1152 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFRAG \n");
1157 if((fthr
< 256) || (fthr
> 2312)) {
1160 fthr
&= ~0x1; // Get an even value
1161 pDevice
->wFragmentationThreshold
= (u16
)fthr
;
1168 * Wireless Handler : get fragment threshold
1171 int iwctl_giwfrag(struct net_device
*dev
,
1172 struct iw_request_info
*info
,
1173 struct iw_param
*wrq
,
1176 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1178 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFRAG \n");
1179 wrq
->value
= pDevice
->wFragmentationThreshold
;
1180 wrq
->disabled
= (wrq
->value
>= 2312);
1189 * Wireless Handler : set retry threshold
1191 int iwctl_siwretry(struct net_device
*dev
,
1192 struct iw_request_info
*info
,
1193 struct iw_param
*wrq
,
1196 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1200 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRETRY \n");
1202 if (wrq
->disabled
) {
1207 if (wrq
->flags
& IW_RETRY_LIMIT
) {
1208 if(wrq
->flags
& IW_RETRY_MAX
)
1209 pDevice
->byLongRetryLimit
= wrq
->value
;
1210 else if (wrq
->flags
& IW_RETRY_MIN
)
1211 pDevice
->byShortRetryLimit
= wrq
->value
;
1213 // No modifier : set both
1214 pDevice
->byShortRetryLimit
= wrq
->value
;
1215 pDevice
->byLongRetryLimit
= wrq
->value
;
1218 if (wrq
->flags
& IW_RETRY_LIFETIME
) {
1219 pDevice
->wMaxTransmitMSDULifetime
= wrq
->value
;
1227 * Wireless Handler : get retry threshold
1229 int iwctl_giwretry(struct net_device
*dev
,
1230 struct iw_request_info
*info
,
1231 struct iw_param
*wrq
,
1234 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1235 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRETRY \n");
1236 wrq
->disabled
= 0; // Can't be disabled
1238 // Note : by default, display the min retry number
1239 if((wrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1240 wrq
->flags
= IW_RETRY_LIFETIME
;
1241 wrq
->value
= (int)pDevice
->wMaxTransmitMSDULifetime
; //ms
1242 } else if((wrq
->flags
& IW_RETRY_MAX
)) {
1243 wrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
1244 wrq
->value
= (int)pDevice
->byLongRetryLimit
;
1246 wrq
->flags
= IW_RETRY_LIMIT
;
1247 wrq
->value
= (int)pDevice
->byShortRetryLimit
;
1248 if((int)pDevice
->byShortRetryLimit
!= (int)pDevice
->byLongRetryLimit
)
1249 wrq
->flags
|= IW_RETRY_MIN
;
1258 * Wireless Handler : set encode mode
1260 int iwctl_siwencode(struct net_device
*dev
,
1261 struct iw_request_info
*info
,
1262 struct iw_point
*wrq
,
1265 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1266 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1267 unsigned long dwKeyIndex
= (unsigned long)(wrq
->flags
& IW_ENCODE_INDEX
);
1269 int index
= (wrq
->flags
& IW_ENCODE_INDEX
);
1271 //2007-0207-07,<Modify> by EinsnLiu
1272 //There are some problems when using iwconfig encode/key command to set the WEP key.
1273 //I almost rewrite this function.
1274 //now it support:(assume the wireless interface's name is eth0)
1275 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1276 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1277 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1278 //iwconfig eth0 key restricted /*enable share key*/
1282 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWENCODE \n");
1284 if((wrq
->flags
& IW_ENCODE_DISABLED
)==0){
1285 //Not disable encryption
1287 if (dwKeyIndex
> WLAN_WEP_NKEYS
) {
1292 if(dwKeyIndex
<1&&((wrq
->flags
&IW_ENCODE_NOKEY
)==0)){//set default key
1293 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1294 dwKeyIndex
=pDevice
->byKeyIndex
;
1300 // Check the size of the key
1301 if (wrq
->length
> WLAN_WEP232_KEYLEN
) {
1306 if(wrq
->length
>0){//have key
1308 if (wrq
->length
== WLAN_WEP232_KEYLEN
) {
1309 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 232 bit wep key\n");
1311 else if (wrq
->length
== WLAN_WEP104_KEYLEN
) {
1312 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 104 bit wep key\n");
1314 else if (wrq
->length
== WLAN_WEP40_KEYLEN
) {
1315 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 40 bit wep key, index= %d\n", (int)dwKeyIndex
);
1316 }else {//no support length
1320 memset(pDevice
->abyKey
, 0, WLAN_WEP232_KEYLEN
);
1321 memcpy(pDevice
->abyKey
, extra
, wrq
->length
);
1323 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyKey: ");
1324 for (ii
= 0; ii
< wrq
->length
; ii
++) {
1325 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02x ", pDevice
->abyKey
[ii
]);
1328 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1329 spin_lock_irq(&pDevice
->lock
);
1330 KeybSetDefaultKey(&(pDevice
->sKey
),
1331 (unsigned long)(dwKeyIndex
| (1 << 31)),
1336 pDevice
->PortOffset
,
1339 spin_unlock_irq(&pDevice
->lock
);
1341 pDevice
->byKeyIndex
= (unsigned char)dwKeyIndex
;
1342 pDevice
->uKeyLength
= wrq
->length
;
1343 pDevice
->bTransmitKey
= true;
1344 pDevice
->bEncryptionEnable
= true;
1345 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1348 //when the length is 0 the request only changes the default transmit key index
1349 //check the new key has a non zero lenget
1350 if(pDevice
->bEncryptionEnable
==false)
1355 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Just set Default key Index:\n");
1356 pkeytab
=&(pDevice
->sKey
.KeyTable
[MAX_KEY_TABLE
-1]);
1357 if(pkeytab
->GroupKey
[(unsigned char)dwKeyIndex
].uKeyLength
==0){
1358 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Default key len is 0\n");
1362 pDevice
->byKeyIndex
=(unsigned char)dwKeyIndex
;
1363 pkeytab
->dwGTKeyIndex
=dwKeyIndex
| (1 << 31);
1364 pkeytab
->GroupKey
[(unsigned char)dwKeyIndex
].dwKeyIndex
=dwKeyIndex
| (1 << 31);
1367 }else {//disable the key
1368 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disable WEP function\n");
1369 if(pDevice
->bEncryptionEnable
==false)
1371 pMgmt
->bShareKeyAlgorithm
= false;
1372 pDevice
->bEncryptionEnable
= false;
1373 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1374 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1375 spin_lock_irq(&pDevice
->lock
);
1376 for(uu
=0;uu
<MAX_KEY_TABLE
;uu
++)
1377 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
1378 spin_unlock_irq(&pDevice
->lock
);
1384 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1386 // Check the size of the key
1387 if (wrq->length > WLAN_WEP232_KEYLEN) {
1392 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1400 // Send the key to the card
1401 if (wrq->length > 0) {
1403 if (wrq->length == WLAN_WEP232_KEYLEN) {
1404 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1406 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1407 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1409 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1410 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1412 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1413 memcpy(pDevice->abyKey, extra, wrq->length);
1415 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1416 for (ii = 0; ii < wrq->length; ii++) {
1417 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1420 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1421 spin_lock_irq(&pDevice->lock);
1422 KeybSetDefaultKey(&(pDevice->sKey),
1423 (unsigned long)(pDevice->byKeyIndex | (1 << 31)),
1424 pDevice->uKeyLength,
1428 pDevice->PortOffset,
1431 spin_unlock_irq(&pDevice->lock);
1433 pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
1434 pDevice->uKeyLength = wrq->length;
1435 pDevice->bTransmitKey = true;
1436 pDevice->bEncryptionEnable = true;
1437 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1439 // Do we want to just set the transmit key index ?
1441 pDevice->byKeyIndex = index;
1443 else if(!(wrq->flags & IW_ENCODE_MODE)) {
1449 if(wrq->flags & IW_ENCODE_DISABLED){
1451 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1452 pMgmt->bShareKeyAlgorithm = false;
1453 pDevice->bEncryptionEnable = false;
1454 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1455 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1456 spin_lock_irq(&pDevice->lock);
1457 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1458 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1459 spin_unlock_irq(&pDevice->lock);
1464 if(wrq
->flags
& IW_ENCODE_RESTRICTED
) {
1465 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & ShareKey System\n");
1466 pMgmt
->bShareKeyAlgorithm
= true;
1468 if(wrq
->flags
& IW_ENCODE_OPEN
) {
1469 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & Open System\n");
1470 pMgmt
->bShareKeyAlgorithm
= false;
1476 * Wireless Handler : get encode mode
1479 int iwctl_giwencode(struct net_device *dev,
1480 struct iw_request_info *info,
1481 struct iw_point *wrq,
1484 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1485 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1487 char abyKey[WLAN_WEP232_KEYLEN];
1488 unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
1489 PSKeyItem pKey = NULL;
1491 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1492 //2007-0207-06,<Add> by EinsnLiu
1493 //the key index in iwconfig is 1-4 when our driver is 0-3
1494 //so it can't be used directly.
1495 //if the index is 0,we should used the index set by driver.
1496 if (index > WLAN_WEP_NKEYS) {
1500 if(index<1){//set default key
1501 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1502 index=pDevice->byKeyIndex;
1508 memset(abyKey, 0, sizeof(abyKey));
1509 // Check encryption mode
1510 wrq->flags = IW_ENCODE_NOKEY;
1511 // Is WEP enabled ???
1512 if (pDevice->bEncryptionEnable)
1513 wrq->flags |= IW_ENCODE_ENABLED;
1515 wrq->flags |= IW_ENCODE_DISABLED;
1517 if (pMgmt->bShareKeyAlgorithm)
1518 wrq->flags |= IW_ENCODE_RESTRICTED;
1520 wrq->flags |= IW_ENCODE_OPEN;
1522 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)){
1523 wrq->length = pKey->uKeyLength;
1524 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1525 //2007-0207-06,<Modify> by EinsnLiu
1526 //only get key success need to copy data
1528 //there is not necessary to return -EINVAL when get key failed
1529 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1530 wrq->flags |= index+1;
1531 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1546 //2008-0409-06, <Add> by Einsn Liu
1548 int iwctl_giwencode(struct net_device
*dev
,
1549 struct iw_request_info
*info
,
1550 struct iw_point
*wrq
,
1553 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1554 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1555 char abyKey
[WLAN_WEP232_KEYLEN
];
1557 unsigned int index
= (unsigned int)(wrq
->flags
& IW_ENCODE_INDEX
);
1558 PSKeyItem pKey
= NULL
;
1560 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWENCODE\n");
1562 if (index
> WLAN_WEP_NKEYS
) {
1565 if(index
<1){//get default key
1566 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1567 index
=pDevice
->byKeyIndex
;
1573 memset(abyKey
, 0, WLAN_WEP232_KEYLEN
);
1574 // Check encryption mode
1575 wrq
->flags
= IW_ENCODE_NOKEY
;
1576 // Is WEP enabled ???
1577 if (pDevice
->bEncryptionEnable
)
1578 wrq
->flags
|= IW_ENCODE_ENABLED
;
1580 wrq
->flags
|= IW_ENCODE_DISABLED
;
1582 if (pMgmt
->bShareKeyAlgorithm
)
1583 wrq
->flags
|= IW_ENCODE_RESTRICTED
;
1585 wrq
->flags
|= IW_ENCODE_OPEN
;
1588 if((index
==0)&&(pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
||
1589 pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)){//get wpa pairwise key
1590 if (KeybGetKey(&(pDevice
->sKey
),pMgmt
->abyCurrBSSID
, 0xffffffff, &pKey
)){
1591 wrq
->length
= pKey
->uKeyLength
;
1592 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1593 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1595 }else if (KeybGetKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, (unsigned char)index
, &pKey
)){
1596 wrq
->length
= pKey
->uKeyLength
;
1597 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1598 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1601 wrq
->flags
|= index
+1;
1608 * Wireless Handler : set power mode
1610 int iwctl_siwpower(struct net_device
*dev
,
1611 struct iw_request_info
*info
,
1612 struct iw_param
*wrq
,
1615 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1616 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1619 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER \n");
1621 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1626 if (wrq
->disabled
) {
1627 pDevice
->ePSMode
= WMAC_POWER_CAM
;
1628 PSvDisablePowerSaving(pDevice
);
1631 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1632 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1633 PSvEnablePowerSaving((void *)pDevice
, pMgmt
->wListenInterval
);
1635 } else if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
1636 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1637 PSvEnablePowerSaving((void *)pDevice
, pMgmt
->wListenInterval
);
1639 switch (wrq
->flags
& IW_POWER_MODE
) {
1640 case IW_POWER_UNICAST_R
:
1641 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1644 case IW_POWER_ALL_R
:
1645 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ALL_R \n");
1648 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ON \n");
1658 * Wireless Handler : get power mode
1660 int iwctl_giwpower(struct net_device
*dev
,
1661 struct iw_request_info
*info
,
1662 struct iw_param
*wrq
,
1665 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1666 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1667 int mode
= pDevice
->ePSMode
;
1670 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWPOWER \n");
1673 wrq
->disabled
= (mode
== WMAC_POWER_CAM
);
1677 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1678 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1679 wrq
->flags
= IW_POWER_TIMEOUT
;
1681 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1682 wrq
->flags
= IW_POWER_PERIOD
;
1684 wrq
->flags
|= IW_POWER_ALL_R
;
1691 * Wireless Handler : get Sensitivity
1693 int iwctl_giwsens(struct net_device
*dev
,
1694 struct iw_request_info
*info
,
1695 struct iw_param
*wrq
,
1698 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1701 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSENS \n");
1702 if (pDevice
->bLinkPass
== true) {
1703 RFvRSSITodBm(pDevice
, (unsigned char)(pDevice
->uCurrRSSI
), &ldBm
);
1709 wrq
->disabled
= (wrq
->value
== 0);
1716 //2008-0409-07, <Add> by Einsn Liu
1717 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1719 int iwctl_siwauth(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
);
1727 static int wpa_version
=0; //must be static to save the last value,einsn liu
1728 static int pairwise
=0;
1730 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAUTH \n");
1731 switch (wrq
->flags
& IW_AUTH_INDEX
) {
1732 case IW_AUTH_WPA_VERSION
:
1733 wpa_version
= wrq
->value
;
1734 if(wrq
->value
== IW_AUTH_WPA_VERSION_DISABLED
) {
1735 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1736 //pDevice->bWPADevEnable = false;
1738 else if(wrq
->value
== IW_AUTH_WPA_VERSION_WPA
) {
1739 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1742 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1744 //pDevice->bWPASuppWextEnabled =true;
1746 case IW_AUTH_CIPHER_PAIRWISE
:
1747 pairwise
= wrq
->value
;
1748 if(pairwise
== IW_AUTH_CIPHER_CCMP
){
1749 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1750 }else if(pairwise
== IW_AUTH_CIPHER_TKIP
){
1751 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1752 }else if(pairwise
== IW_AUTH_CIPHER_WEP40
||pairwise
== IW_AUTH_CIPHER_WEP104
){
1753 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1754 }else if(pairwise
== IW_AUTH_CIPHER_NONE
){
1755 //do nothing,einsn liu
1756 }else pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1759 case IW_AUTH_CIPHER_GROUP
:
1760 if(wpa_version
== IW_AUTH_WPA_VERSION_DISABLED
)
1762 if(pairwise
== IW_AUTH_CIPHER_NONE
){
1763 if(wrq
->value
== IW_AUTH_CIPHER_CCMP
){
1764 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1766 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1770 case IW_AUTH_KEY_MGMT
:
1772 if(wpa_version
== IW_AUTH_WPA_VERSION_WPA2
){
1773 if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1774 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
1775 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
1776 }else if(wpa_version
== IW_AUTH_WPA_VERSION_WPA
){
1777 if(wrq
->value
== 0){
1778 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
1779 }else if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1780 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
1781 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
1785 case IW_AUTH_TKIP_COUNTERMEASURES
:
1787 case IW_AUTH_DROP_UNENCRYPTED
:
1789 case IW_AUTH_80211_AUTH_ALG
:
1790 if(wrq
->value
==IW_AUTH_ALG_OPEN_SYSTEM
){
1791 pMgmt
->bShareKeyAlgorithm
=false;
1792 }else if(wrq
->value
==IW_AUTH_ALG_SHARED_KEY
){
1793 pMgmt
->bShareKeyAlgorithm
=true;
1796 case IW_AUTH_WPA_ENABLED
:
1797 //pDevice->bWPADevEnable = !! wrq->value;
1799 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1801 case IW_AUTH_ROAMING_CONTROL
:
1804 case IW_AUTH_PRIVACY_INVOKED
:
1805 pDevice
->bEncryptionEnable
= !!wrq
->value
;
1806 if(pDevice
->bEncryptionEnable
== false){
1809 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1810 pMgmt
->bShareKeyAlgorithm
= false;
1811 pMgmt
->eAuthenMode
= false;
1812 //pDevice->bWPADevEnable = false;
1821 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1822 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1823 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1824 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1825 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"true":"false");
1826 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"true":"false");
1827 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"true":"false");
1833 int iwctl_giwauth(struct net_device
*dev
,
1834 struct iw_request_info
*info
,
1835 struct iw_param
*wrq
,
1843 int iwctl_siwgenie(struct net_device
*dev
,
1844 struct iw_request_info
*info
,
1845 struct iw_point
*wrq
,
1848 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1849 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1853 if ((wrq
->length
< 2) || (extra
[1]+2 != wrq
->length
)) {
1857 if(wrq
->length
> MAX_WPA_IE_LEN
){
1861 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1862 if(copy_from_user(pMgmt
->abyWPAIE
, extra
, wrq
->length
)){
1866 pMgmt
->wWPAIELen
= wrq
->length
;
1868 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1869 pMgmt
->wWPAIELen
= 0;
1872 out
://not completely ...not necessary in wpa_supplicant 0.5.8
1876 int iwctl_giwgenie(struct net_device
*dev
,
1877 struct iw_request_info
*info
,
1878 struct iw_point
*wrq
,
1881 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1882 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1884 int space
= wrq
->length
;
1887 if(pMgmt
->wWPAIELen
> 0){
1888 wrq
->length
= pMgmt
->wWPAIELen
;
1889 if(pMgmt
->wWPAIELen
<= space
){
1890 if(copy_to_user(extra
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
)){
1901 int iwctl_siwencodeext(struct net_device
*dev
,
1902 struct iw_request_info
*info
,
1903 struct iw_point
*wrq
,
1906 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1907 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1908 struct viawget_wpa_param
*param
=NULL
;
1912 int key_idx
, set_tx
=0;
1913 u8 seq
[IW_ENCODE_SEQ_MAX_SIZE
];
1915 size_t seq_len
=0,key_len
=0;
1923 PRINT_K("SIOCSIWENCODEEXT...... \n");
1925 blen
= sizeof(*param
);
1926 buf
= kmalloc((int)blen
, (int)GFP_KERNEL
);
1929 memset(buf
, 0, blen
);
1930 param
= (struct viawget_wpa_param
*) buf
;
1934 case IW_ENCODE_ALG_NONE
:
1935 alg_name
= WPA_ALG_NONE
;
1937 case IW_ENCODE_ALG_WEP
:
1938 alg_name
= WPA_ALG_WEP
;
1940 case IW_ENCODE_ALG_TKIP
:
1941 alg_name
= WPA_ALG_TKIP
;
1943 case IW_ENCODE_ALG_CCMP
:
1944 alg_name
= WPA_ALG_CCMP
;
1947 PRINT_K("Unknown alg = %d\n",ext
->alg
);
1952 memcpy(addr
, ext
->addr
.sa_data
, ETH_ALEN
);
1954 key_idx
= (wrq
->flags
&IW_ENCODE_INDEX
) - 1;
1956 if(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1958 //recover seq,seq_len
1959 if(ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
1960 seq_len
=IW_ENCODE_SEQ_MAX_SIZE
;
1961 memcpy(seq
, ext
->rx_seq
, seq_len
);
1963 //recover key,key_len
1965 key_len
=ext
->key_len
;
1966 memcpy(key
, &ext
->key
[0], key_len
);
1969 memset(key_array
, 0, 64);
1971 memcpy(key_array
, key
, key_len
);
1972 if (key_len
== 32) {
1973 // notice ! the oder
1974 memcpy(&key_array
[16], &key
[24], 8);
1975 memcpy(&key_array
[24], &key
[16], 8);
1979 /**************Translate iw_encode_ext to viawget_wpa_param****************/
1980 memcpy(param
->addr
, addr
, ETH_ALEN
);
1981 param
->u
.wpa_key
.alg_name
= (int)alg_name
;
1982 param
->u
.wpa_key
.set_tx
= set_tx
;
1983 param
->u
.wpa_key
.key_index
= key_idx
;
1984 param
->u
.wpa_key
.key_len
= key_len
;
1985 param
->u
.wpa_key
.key
= (u8
*)key_array
;
1986 param
->u
.wpa_key
.seq
= (u8
*)seq
;
1987 param
->u
.wpa_key
.seq_len
= seq_len
;
1989 //****set if current action is Network Manager count??
1990 //****this method is so foolish,but there is no other way???
1991 if(param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
1992 if(param
->u
.wpa_key
.key_index
==0) {
1993 pDevice
->bwextcount
++;
1995 if((pDevice
->bwextcount
== 1)&&(param
->u
.wpa_key
.key_index
==1)) {
1996 pDevice
->bwextcount
++;
1998 if((pDevice
->bwextcount
==2)&&(param
->u
.wpa_key
.key_index
==2)) {
1999 pDevice
->bwextcount
++;
2001 if((pDevice
->bwextcount
==3)&&(param
->u
.wpa_key
.key_index
==3)) {
2002 pDevice
->bwextcount
++;
2005 if( pDevice
->bwextcount
== 4) {
2006 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2007 pDevice
->bwextcount
=0;
2008 pDevice
->bWPASuppWextEnabled
= true;
2012 spin_lock_irq(&pDevice
->lock
);
2013 ret
= wpa_set_keys(pDevice
, param
, true);
2014 spin_unlock_irq(&pDevice
->lock
);
2023 int iwctl_giwencodeext(struct net_device
*dev
,
2024 struct iw_request_info
*info
,
2025 struct iw_point
*wrq
,
2031 int iwctl_siwmlme(struct net_device
*dev
,
2032 struct iw_request_info
* info
,
2033 struct iw_point
*wrq
,
2036 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
2037 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2038 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2039 //u16 reason = cpu_to_le16(mlme->reason_code);
2042 if(memcmp(pMgmt
->abyCurrBSSID
, mlme
->addr
.sa_data
, ETH_ALEN
)){
2047 case IW_MLME_DEAUTH
:
2048 //this command seems to be not complete,please test it --einsnliu
2049 //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason);
2051 case IW_MLME_DISASSOC
:
2052 if(pDevice
->bLinkPass
== true){
2053 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2054 //clear related flags
2055 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
2056 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
2057 bScheduleCommand((void *)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
2071 /*------------------------------------------------------------------*/
2073 * Structures to export the Wireless Handlers
2078 static const iw_handler iwctl_handler[] =
2080 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2081 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2082 (iw_handler) NULL, // SIOCSIWNWID
2083 (iw_handler) NULL, // SIOCGIWNWID
2084 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2085 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2086 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2087 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2088 (iw_handler) NULL, // SIOCSIWSENS
2089 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2090 (iw_handler) NULL, // SIOCSIWRANGE
2091 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2092 (iw_handler) NULL, // SIOCSIWPRIV
2093 (iw_handler) NULL, // SIOCGIWPRIV
2094 (iw_handler) NULL, // SIOCSIWSTATS
2095 (iw_handler) NULL, // SIOCGIWSTATS
2096 (iw_handler) NULL, // SIOCSIWSPY
2097 (iw_handler) NULL, // SIOCGIWSPY
2098 (iw_handler) NULL, // -- hole --
2099 (iw_handler) NULL, // -- hole --
2100 (iw_handler) iwctl_siwap, // SIOCSIWAP
2101 (iw_handler) iwctl_giwap, // SIOCGIWAP
2102 (iw_handler) NULL, // -- hole -- 0x16
2103 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2104 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2105 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2106 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2107 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2108 (iw_handler) NULL, // SIOCSIWNICKN
2109 (iw_handler) NULL, // SIOCGIWNICKN
2110 (iw_handler) NULL, // -- hole --
2111 (iw_handler) NULL, // -- hole --
2112 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2113 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2114 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2115 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2116 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2117 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2118 (iw_handler) NULL, // SIOCSIWTXPOW
2119 (iw_handler) NULL, // SIOCGIWTXPOW
2120 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2121 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2122 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2123 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2124 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2125 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2126 (iw_handler) NULL, // -- hole --
2127 (iw_handler) NULL, // -- hole --
2128 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2129 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2130 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2131 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2132 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2133 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2134 (iw_handler) NULL, // SIOCSIWPMKSA
2135 (iw_handler) NULL, // -- hole --
2140 static const iw_handler iwctl_handler
[] =
2142 (iw_handler
) iwctl_commit
, // SIOCSIWCOMMIT
2143 (iw_handler
) NULL
, // SIOCGIWNAME
2144 (iw_handler
) NULL
, // SIOCSIWNWID
2145 (iw_handler
) NULL
, // SIOCGIWNWID
2146 (iw_handler
) NULL
, // SIOCSIWFREQ
2147 (iw_handler
) NULL
, // SIOCGIWFREQ
2148 (iw_handler
) NULL
, // SIOCSIWMODE
2149 (iw_handler
) NULL
, // SIOCGIWMODE
2150 (iw_handler
) NULL
, // SIOCSIWSENS
2151 (iw_handler
) NULL
, // SIOCGIWSENS
2152 (iw_handler
) NULL
, // SIOCSIWRANGE
2153 (iw_handler
) iwctl_giwrange
, // SIOCGIWRANGE
2154 (iw_handler
) NULL
, // SIOCSIWPRIV
2155 (iw_handler
) NULL
, // SIOCGIWPRIV
2156 (iw_handler
) NULL
, // SIOCSIWSTATS
2157 (iw_handler
) NULL
, // SIOCGIWSTATS
2158 (iw_handler
) NULL
, // SIOCSIWSPY
2159 (iw_handler
) NULL
, // SIOCGIWSPY
2160 (iw_handler
) NULL
, // -- hole --
2161 (iw_handler
) NULL
, // -- hole --
2162 (iw_handler
) NULL
, // SIOCSIWAP
2163 (iw_handler
) NULL
, // SIOCGIWAP
2164 (iw_handler
) NULL
, // -- hole -- 0x16
2165 (iw_handler
) NULL
, // SIOCGIWAPLIST
2166 (iw_handler
) iwctl_siwscan
, // SIOCSIWSCAN
2167 (iw_handler
) iwctl_giwscan
, // SIOCGIWSCAN
2168 (iw_handler
) NULL
, // SIOCSIWESSID
2169 (iw_handler
) NULL
, // SIOCGIWESSID
2170 (iw_handler
) NULL
, // SIOCSIWNICKN
2171 (iw_handler
) NULL
, // SIOCGIWNICKN
2172 (iw_handler
) NULL
, // -- hole --
2173 (iw_handler
) NULL
, // -- hole --
2174 (iw_handler
) NULL
, // SIOCSIWRATE 0x20
2175 (iw_handler
) NULL
, // SIOCGIWRATE
2176 (iw_handler
) NULL
, // SIOCSIWRTS
2177 (iw_handler
) NULL
, // SIOCGIWRTS
2178 (iw_handler
) NULL
, // SIOCSIWFRAG
2179 (iw_handler
) NULL
, // SIOCGIWFRAG
2180 (iw_handler
) NULL
, // SIOCSIWTXPOW
2181 (iw_handler
) NULL
, // SIOCGIWTXPOW
2182 (iw_handler
) NULL
, // SIOCSIWRETRY
2183 (iw_handler
) NULL
, // SIOCGIWRETRY
2184 (iw_handler
) NULL
, // SIOCSIWENCODE
2185 (iw_handler
) NULL
, // SIOCGIWENCODE
2186 (iw_handler
) NULL
, // SIOCSIWPOWER
2187 (iw_handler
) NULL
, // SIOCGIWPOWER
2189 //2008-0409-07, <Add> by Einsn Liu
2190 (iw_handler
) NULL
, // -- hole --
2191 (iw_handler
) NULL
, // -- hole --
2192 (iw_handler
) NULL
, // SIOCSIWGENIE
2193 (iw_handler
) NULL
, // SIOCGIWGENIE
2194 (iw_handler
) NULL
, // SIOCSIWAUTH
2195 (iw_handler
) NULL
, // SIOCGIWAUTH
2196 (iw_handler
) NULL
, // SIOCSIWENCODEEXT
2197 (iw_handler
) NULL
, // SIOCGIWENCODEEXT
2198 (iw_handler
) NULL
, // SIOCSIWPMKSA
2199 (iw_handler
) NULL
, // -- hole --
2203 static const iw_handler iwctl_private_handler
[] =
2205 NULL
, // SIOCIWFIRSTPRIV
2209 struct iw_priv_args iwctl_private_args
[] = {
2211 IW_PRIV_TYPE_CHAR
| 1024, 0,
2217 const struct iw_handler_def iwctl_handler_def
=
2219 .get_wireless_stats
= &iwctl_get_wireless_stats
,
2220 .num_standard
= sizeof(iwctl_handler
)/sizeof(iw_handler
),
2221 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2222 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2224 .num_private_args
= 0,
2225 .standard
= (iw_handler
*) iwctl_handler
,
2226 // .private = (iw_handler *) iwctl_private_handler,
2227 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2229 .private_args
= NULL
,