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
85 static const long frequency_list
[] = {
86 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
87 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
88 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
89 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
90 5700, 5745, 5765, 5785, 5805, 5825
96 /*--------------------- Static Classes ----------------------------*/
99 //static int msglevel =MSG_LEVEL_DEBUG;
100 static int msglevel
=MSG_LEVEL_INFO
;
103 /*--------------------- Static Variables --------------------------*/
104 /*--------------------- Static Functions --------------------------*/
106 /*--------------------- Export Variables --------------------------*/
110 struct iw_statistics
*iwctl_get_wireless_stats(struct net_device
*dev
)
112 PSDevice pDevice
= netdev_priv(dev
);
114 pDevice
->wstats
.status
= pDevice
->eOPMode
;
115 #ifdef Calcu_LinkQual
117 if(pDevice
->byBBType
== BB_TYPE_11B
) {
118 if(pDevice
->byCurrSQ
> 120)
119 pDevice
->scStatistic
.LinkQuality
= 100;
121 pDevice
->scStatistic
.LinkQuality
= pDevice
->byCurrSQ
*100/120;
123 else if(pDevice
->byBBType
== BB_TYPE_11G
) {
124 if(pDevice
->byCurrSQ
< 20)
125 pDevice
->scStatistic
.LinkQuality
= 100;
126 else if(pDevice
->byCurrSQ
>96)
127 pDevice
->scStatistic
.LinkQuality
= 0;
129 pDevice
->scStatistic
.LinkQuality
= (96-pDevice
->byCurrSQ
)*100/76;
131 if(pDevice
->bLinkPass
!=TRUE
)
132 pDevice
->scStatistic
.LinkQuality
= 0;
134 if(pDevice
->scStatistic
.LinkQuality
> 100)
135 pDevice
->scStatistic
.LinkQuality
= 100;
136 pDevice
->wstats
.qual
.qual
=(BYTE
) pDevice
->scStatistic
.LinkQuality
;
138 pDevice
->wstats
.qual
.qual
= pDevice
->byCurrSQ
;
140 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
141 pDevice
->wstats
.qual
.level
= ldBm
;
142 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
143 pDevice
->wstats
.qual
.noise
= 0;
144 pDevice
->wstats
.qual
.updated
= 1;
145 pDevice
->wstats
.discard
.nwid
= 0;
146 pDevice
->wstats
.discard
.code
= 0;
147 pDevice
->wstats
.discard
.fragment
= 0;
148 pDevice
->wstats
.discard
.retries
= (U32
)pDevice
->scStatistic
.dwTsrErr
;
149 pDevice
->wstats
.discard
.misc
= 0;
150 pDevice
->wstats
.miss
.beacon
= 0;
152 return &pDevice
->wstats
;
157 /*------------------------------------------------------------------*/
160 static int iwctl_commit(struct net_device
*dev
,
161 struct iw_request_info
*info
,
165 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWCOMMIT \n");
172 * Wireless Handler : get protocol name
175 int iwctl_giwname(struct net_device
*dev
,
176 struct iw_request_info
*info
,
180 strcpy(wrq
, "802.11-a/b/g");
184 int iwctl_giwnwid(struct net_device
*dev
,
185 struct iw_request_info
*info
,
186 struct iw_param
*wrq
,
189 //wrq->value = 0x100;
197 * Wireless Handler : set scan
200 int iwctl_siwscan(struct net_device
*dev
,
201 struct iw_request_info
*info
,
202 struct iw_point
*wrq
,
205 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
206 struct iw_scan_req
*req
= (struct iw_scan_req
*)extra
;
207 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
208 BYTE abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
209 PWLAN_IE_SSID pItemSSID
=NULL
;
210 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWSCAN \n");
213 if(pDevice
->byReAssocCount
> 0) { //reject scan when re-associating!
214 //send scan event to wpa_Supplicant
215 union iwreq_data wrqu
;
216 printk("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
217 memset(&wrqu
, 0, sizeof(wrqu
));
218 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
222 spin_lock_irq(&pDevice
->lock
);
223 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
225 //mike add: active scan OR passive scan OR desire_ssid scan
226 if(wrq
->length
== sizeof(struct iw_scan_req
)) {
227 if (wrq
->flags
& IW_SCAN_THIS_ESSID
) { //desire_ssid scan
228 memset(abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
229 pItemSSID
= (PWLAN_IE_SSID
)abyScanSSID
;
230 pItemSSID
->byElementID
= WLAN_EID_SSID
;
231 memcpy(pItemSSID
->abySSID
, req
->essid
, (int)req
->essid_len
);
232 if (pItemSSID
->abySSID
[req
->essid_len
- 1] == '\0') {
234 pItemSSID
->len
= req
->essid_len
- 1;
237 pItemSSID
->len
= req
->essid_len
;
238 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
239 printk("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID
)abyScanSSID
)->abySSID
,
240 ((PWLAN_IE_SSID
)abyScanSSID
)->len
);
241 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, abyScanSSID
);
242 spin_unlock_irq(&pDevice
->lock
);
246 else if(req
->scan_type
== IW_SCAN_TYPE_PASSIVE
) { //passive scan
247 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
251 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
254 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
255 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
256 spin_unlock_irq(&pDevice
->lock
);
263 * Wireless Handler : get scan results
266 int iwctl_giwscan(struct net_device
*dev
,
267 struct iw_request_info
*info
,
268 struct iw_point
*wrq
,
272 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
273 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
275 PWLAN_IE_SSID pItemSSID
;
276 PWLAN_IE_SUPP_RATES pSuppRates
, pExtSuppRates
;
277 char *current_ev
= extra
;
278 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
279 char *current_val
= NULL
;
282 char buf
[MAX_WPA_IE_LEN
* 2 + 30];
285 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSCAN \n");
287 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
291 pBSS
= &(pMgmt
->sBSSList
[0]);
292 for (ii
= 0, jj
= 0; jj
< MAX_BSS_NUM
; jj
++) {
293 if (current_ev
>= end_buf
)
295 pBSS
= &(pMgmt
->sBSSList
[jj
]);
297 memset(&iwe
, 0, sizeof(iwe
));
299 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
300 memcpy(iwe
.u
.ap_addr
.sa_data
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
301 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
303 memset(&iwe
, 0, sizeof(iwe
));
304 iwe
.cmd
= SIOCGIWESSID
;
305 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
306 iwe
.u
.data
.length
= pItemSSID
->len
;
307 iwe
.u
.data
.flags
= 1;
308 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
310 memset(&iwe
, 0, sizeof(iwe
));
311 iwe
.cmd
= SIOCGIWMODE
;
312 if (WLAN_GET_CAP_INFO_ESS(pBSS
->wCapInfo
)) {
313 iwe
.u
.mode
= IW_MODE_INFRA
;
316 iwe
.u
.mode
= IW_MODE_ADHOC
;
318 iwe
.len
= IW_EV_UINT_LEN
;
319 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
321 pSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abySuppRates
;
322 pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abyExtSuppRates
;
323 memset(&iwe
, 0, sizeof(iwe
));
324 iwe
.cmd
= SIOCGIWFREQ
;
325 iwe
.u
.freq
.m
= pBSS
->uChannel
;
328 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
331 //2008-0409-04, <Add> by Einsn Liu
333 int f
= (int)pBSS
->uChannel
- 1;
335 iwe
.u
.freq
.m
= frequency_list
[f
] * 100000;
338 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
340 memset(&iwe
, 0, sizeof(iwe
));
342 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
343 iwe
.u
.qual
.level
= ldBm
;
344 iwe
.u
.qual
.noise
= 0;
345 //2008-0409-01, <Add> by Einsn Liu
347 iwe
.u
.qual
.qual
= 100;
348 }else if(-ldBm
> 90) {
351 iwe
.u
.qual
.qual
=(40-(-ldBm
-50))*100/40;
353 iwe
.u
.qual
.updated
=7;
355 // iwe.u.qual.qual = 0;
356 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
358 memset(&iwe
, 0, sizeof(iwe
));
359 iwe
.cmd
= SIOCGIWENCODE
;
360 iwe
.u
.data
.length
= 0;
361 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS
->wCapInfo
)) {
362 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
364 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
366 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
368 memset(&iwe
, 0, sizeof(iwe
));
369 iwe
.cmd
= SIOCGIWRATE
;
370 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
371 current_val
= current_ev
+ IW_EV_LCP_LEN
;
373 for (kk
= 0 ; kk
< 12 ; kk
++) {
374 if (pSuppRates
->abyRates
[kk
] == 0)
376 // Bit rate given in 500 kb/s units (+ 0x80)
377 iwe
.u
.bitrate
.value
= ((pSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
378 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
380 for (kk
= 0 ; kk
< 8 ; kk
++) {
381 if (pExtSuppRates
->abyRates
[kk
] == 0)
383 // Bit rate given in 500 kb/s units (+ 0x80)
384 iwe
.u
.bitrate
.value
= ((pExtSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
385 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
388 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
389 current_ev
= current_val
;
391 memset(&iwe
, 0, sizeof(iwe
));
392 iwe
.cmd
= IWEVCUSTOM
;
393 sprintf(buf
, "bcn_int=%d", pBSS
->wBeaconInterval
);
394 iwe
.u
.data
.length
= strlen(buf
);
395 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, buf
);
397 if ((pBSS
->wWPALen
> 0) && (pBSS
->wWPALen
<= MAX_WPA_IE_LEN
)) {
398 memset(&iwe
, 0, sizeof(iwe
));
400 iwe
.u
.data
.length
= pBSS
->wWPALen
;
401 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byWPAIE
);
404 if ((pBSS
->wRSNLen
> 0) && (pBSS
->wRSNLen
<= MAX_WPA_IE_LEN
)) {
405 memset(&iwe
, 0, sizeof(iwe
));
407 iwe
.u
.data
.length
= pBSS
->wRSNLen
;
408 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byRSNIE
);
414 wrq
->length
= current_ev
- extra
;
421 * Wireless Handler : set frequence or channel
424 int iwctl_siwfreq(struct net_device
*dev
,
425 struct iw_request_info
*info
,
429 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
432 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFREQ \n");
434 // If setting by frequency, convert to a channel
436 (wrq
->m
>= (int) 2.412e8
) &&
437 (wrq
->m
<= (int) 2.487e8
)) {
438 int f
= wrq
->m
/ 100000;
440 while((c
< 14) && (f
!= frequency_list
[c
]))
445 // Setting by channel number
446 if((wrq
->m
> 14) || (wrq
->e
> 0))
449 int channel
= wrq
->m
;
450 if((channel
< 1) || (channel
> 14)) {
451 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: New channel value of %d is invalid!\n", dev
->name
, wrq
->m
);
454 // Yes ! We can set it !!!
455 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set to channel = %d\n", channel
);
456 pDevice
->uChannel
= channel
;
457 //2007-0207-04,<Add> by EinsnLiu
458 //Make change effect at once
459 pDevice
->bCommit
= TRUE
;
467 * Wireless Handler : get frequence or channel
470 int iwctl_giwfreq(struct net_device
*dev
,
471 struct iw_request_info
*info
,
475 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
476 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
478 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFREQ \n");
480 #ifdef WEXT_USECHANNELS
481 wrq
->m
= (int)pMgmt
->uCurrChannel
;
485 int f
= (int)pMgmt
->uCurrChannel
- 1;
488 wrq
->m
= frequency_list
[f
] * 100000;
497 * Wireless Handler : set operation mode
500 int iwctl_siwmode(struct net_device
*dev
,
501 struct iw_request_info
*info
,
505 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
506 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
509 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWMODE \n");
511 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
&& pDevice
->bEnableHostapd
) {
512 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Can't set operation mode, hostapd is running \n");
519 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_IBSS_STA
) {
520 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
521 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
522 pDevice
->bCommit
= TRUE
;
525 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to ad-hoc \n");
529 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_ESS_STA
) {
530 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
531 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
532 pDevice
->bCommit
= TRUE
;
535 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to infrastructure \n");
539 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
543 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_AP
) {
544 pMgmt
->eConfigMode
= WMAC_CONFIG_AP
;
545 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
546 pDevice
->bCommit
= TRUE
;
549 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to Access Point \n");
553 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
564 * Wireless Handler : get operation mode
567 int iwctl_giwmode(struct net_device
*dev
,
568 struct iw_request_info
*info
,
572 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
573 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
576 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWMODE \n");
577 // If not managed, assume it's ad-hoc
578 switch (pMgmt
->eConfigMode
) {
579 case WMAC_CONFIG_ESS_STA
:
580 *wmode
= IW_MODE_INFRA
;
582 case WMAC_CONFIG_IBSS_STA
:
583 *wmode
= IW_MODE_ADHOC
;
585 case WMAC_CONFIG_AUTO
:
586 *wmode
= IW_MODE_INFRA
;
589 *wmode
= IW_MODE_MASTER
;
592 *wmode
= IW_MODE_ADHOC
;
600 * Wireless Handler : get capability range
603 int iwctl_giwrange(struct net_device
*dev
,
604 struct iw_request_info
*info
,
605 struct iw_point
*wrq
,
608 struct iw_range
*range
= (struct iw_range
*) extra
;
610 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
613 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRANGE \n");
615 wrq
->length
= sizeof(struct iw_range
);
616 memset(range
, 0, sizeof(struct iw_range
));
617 range
->min_nwid
= 0x0000;
618 range
->max_nwid
= 0x0000;
619 range
->num_channels
= 14;
620 // Should be based on cap_rid.country to give only
621 // what the current card support
623 for(i
= 0; i
< 14; i
++) {
624 range
->freq
[k
].i
= i
+ 1; // List index
625 range
->freq
[k
].m
= frequency_list
[i
] * 100000;
626 range
->freq
[k
++].e
= 1; // Values in table in MHz -> * 10^5 * 10
628 range
->num_frequency
= k
;
629 // Hum... Should put the right values there
630 #ifdef Calcu_LinkQual
631 range
->max_qual
.qual
= 100;
633 range
->max_qual
.qual
= 255;
635 range
->max_qual
.level
= 0;
636 range
->max_qual
.noise
= 0;
637 range
->sensitivity
= 255;
639 for(i
= 0 ; i
< 13 ; i
++) {
640 range
->bitrate
[i
] = abySupportedRates
[i
] * 500000;
641 if(range
->bitrate
[i
] == 0)
644 range
->num_bitrates
= i
;
646 // Set an indication of the max TCP throughput
647 // in bit/s that we can expect using this interface.
648 // May be use for QoS stuff... Jean II
650 range
->throughput
= 5 * 1000 * 1000;
652 range
->throughput
= 1.5 * 1000 * 1000;
655 range
->max_rts
= 2312;
656 range
->min_frag
= 256;
657 range
->max_frag
= 2312;
660 // the encoding capabilities
661 range
->num_encoding_sizes
= 3;
663 range
->encoding_size
[0] = 5;
665 range
->encoding_size
[1] = 13;
666 // 256 bits for WPA-PSK
667 range
->encoding_size
[2] = 32;
668 // 4 keys are allowed
669 range
->max_encoding_tokens
= 4;
671 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
672 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
675 range
->max_pmp
= 1000000;// 1 secs
677 range
->max_pmt
= 1000000;// 1 secs
678 range
->pmp_flags
= IW_POWER_PERIOD
;
679 range
->pmt_flags
= IW_POWER_TIMEOUT
;
680 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
682 // Transmit Power - values are in mW
684 range
->txpower
[0] = 100;
685 range
->num_txpower
= 1;
686 range
->txpower_capa
= IW_TXPOW_MWATT
;
687 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
688 range
->we_version_compiled
= WIRELESS_EXT
;
689 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
690 range
->retry_flags
= IW_RETRY_LIMIT
;
691 range
->r_time_flags
= IW_RETRY_LIFETIME
;
692 range
->min_retry
= 1;
693 range
->max_retry
= 65535;
694 range
->min_r_time
= 1024;
695 range
->max_r_time
= 65535 * 1024;
696 // Experimental measurements - boundary 11/5.5 Mb/s
697 // Note : with or without the (local->rssi), results
698 // are somewhat different. - Jean II
699 range
->avg_qual
.qual
= 6;
700 range
->avg_qual
.level
= 176; // -80 dBm
701 range
->avg_qual
.noise
= 0;
710 * Wireless Handler : set ap mac address
713 int iwctl_siwap(struct net_device
*dev
,
714 struct iw_request_info
*info
,
715 struct sockaddr
*wrq
,
718 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
719 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
721 BYTE ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
723 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAP \n");
724 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
726 printk("SIOCSIWAP(??)-->In scanning...\n");
729 if (wrq
->sa_family
!= ARPHRD_ETHER
)
732 memset(pMgmt
->abyDesireBSSID
, 0xFF, 6);
733 memcpy(pMgmt
->abyDesireBSSID
, wrq
->sa_data
, 6);
734 //2008-0409-05, <Add> by Einsn Liu
735 if((pDevice
->bLinkPass
== TRUE
) &&
736 (memcmp(pMgmt
->abyDesireBSSID
, pMgmt
->abyCurrBSSID
, 6)== 0)){
740 if ((IS_BROADCAST_ADDRESS(pMgmt
->abyDesireBSSID
)) ||
741 (memcmp(pMgmt
->abyDesireBSSID
, ZeroBSSID
, 6) == 0)){
742 printk("SIOCSIWAP:invalid desired BSSID return!\n");
745 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
746 // then ignore,because you don't known which one to be connect with??
748 UINT ii
, uSameBssidNum
=0;
749 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
750 if (pMgmt
->sBSSList
[ii
].bActive
&&
751 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
,pMgmt
->abyDesireBSSID
)) {
755 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
756 printk("SIOCSIWAP:ignore for desired AP in hidden mode\n");
760 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
761 pDevice
->bCommit
= TRUE
;
768 * Wireless Handler : get ap mac address
771 int iwctl_giwap(struct net_device
*dev
,
772 struct iw_request_info
*info
,
773 struct sockaddr
*wrq
,
776 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
777 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
780 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAP \n");
782 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
783 //2008-0410,<Modify> by Einsn Liu
784 if ((pDevice
->bLinkPass
== FALSE
) && (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
))
785 memset(wrq
->sa_data
, 0, 6);
787 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
788 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
791 wrq
->sa_family
= ARPHRD_ETHER
;
799 * Wireless Handler : get ap list
802 int iwctl_giwaplist(struct net_device
*dev
,
803 struct iw_request_info
*info
,
804 struct iw_point
*wrq
,
808 struct sockaddr sock
[IW_MAX_AP
];
809 struct iw_quality qual
[IW_MAX_AP
];
810 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
811 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
814 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAPLIST \n");
815 // Only super-user can see AP list
817 if (!capable(CAP_NET_ADMIN
)) {
824 PKnownBSS pBSS
= &(pMgmt
->sBSSList
[0]);
826 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
827 pBSS
= &(pMgmt
->sBSSList
[ii
]);
830 if ( jj
>= IW_MAX_AP
)
832 memcpy(sock
[jj
].sa_data
, pBSS
->abyBSSID
, 6);
833 sock
[jj
].sa_family
= ARPHRD_ETHER
;
834 qual
[jj
].level
= pBSS
->uRSSI
;
835 qual
[jj
].qual
= qual
[jj
].noise
= 0;
836 qual
[jj
].updated
= 2;
840 wrq
->flags
= 1; // Should be define'd
842 memcpy(extra
, sock
, sizeof(struct sockaddr
)*jj
);
843 memcpy(extra
+ sizeof(struct sockaddr
)*jj
, qual
, sizeof(struct iw_quality
)*jj
);
851 * Wireless Handler : set essid
854 int iwctl_siwessid(struct net_device
*dev
,
855 struct iw_request_info
*info
,
856 struct iw_point
*wrq
,
859 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
860 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
861 PWLAN_IE_SSID pItemSSID
;
862 //2008-0409-05, <Add> by Einsn Liu
866 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWESSID \n");
867 pDevice
->fWPA_Authened
= FALSE
;
868 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
870 printk("SIOCSIWESSID(??)-->In scanning...\n");
873 // Check if we asked for `any'
874 if(wrq
->flags
== 0) {
875 // Just send an empty SSID list
876 // Just send an empty SSID list
877 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
878 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
879 printk("set essid to 'any' \n");
880 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
881 //Unknown desired AP,so here need not associate??
882 //if(pDevice->bWPASuppWextEnabled == TRUE) {
888 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
889 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
890 pItemSSID
->byElementID
= WLAN_EID_SSID
;
891 memcpy(pItemSSID
->abySSID
, extra
, wrq
->length
);
892 if (pItemSSID
->abySSID
[wrq
->length
- 1] == '\0') {
894 pItemSSID
->len
= wrq
->length
- 1;
897 pItemSSID
->len
= wrq
->length
;
898 printk("set essid to %s \n",pItemSSID
->abySSID
);
899 //2008-0409-05, <Add> by Einsn Liu
900 len
=(pItemSSID
->len
> ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)?pItemSSID
->len
:((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
;
901 if((pDevice
->bLinkPass
== TRUE
) &&
902 (memcmp(pItemSSID
->abySSID
,((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,len
)==0))
905 //mike:need clear desiredBSSID
906 if(pItemSSID
->len
==0) {
907 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
911 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
912 //Wext wil order another command of siwap to link with desired AP,
913 //so here need not associate??
914 if(pDevice
->bWPASuppWextEnabled
== TRUE
) {
915 /*******search if in hidden ssid mode ****/
917 PKnownBSS pCurr
= NULL
;
918 BYTE abyTmpDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
919 UINT ii
, uSameBssidNum
=0;
921 memset(abyTmpDesireSSID
,0,sizeof(abyTmpDesireSSID
));
922 memcpy(abyTmpDesireSSID
,pMgmt
->abyDesireSSID
,sizeof(abyTmpDesireSSID
));
923 pCurr
= BSSpSearchBSSList(pDevice
,
926 pMgmt
->eConfigPHYMode
930 printk("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
931 vResetCommandTimer((HANDLE
) pDevice
);
932 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
933 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
934 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
936 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
937 // by means of judging if there are two same BSSID exist in list ?
938 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
939 if (pMgmt
->sBSSList
[ii
].bActive
&&
940 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
, pCurr
->abyBSSID
)) {
944 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
945 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
946 vResetCommandTimer((HANDLE
) pDevice
);
947 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
; //this scan type,you'll submit scan result!
948 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
949 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
957 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set essid = %s \n", pItemSSID
->abySSID
);
959 DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO " SIOCSIWESSID2 \n");
960 pItemSSID->len = wrq->length;
964 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
965 pDevice
->bCommit
= TRUE
;
974 * Wireless Handler : get essid
977 int iwctl_giwessid(struct net_device
*dev
,
978 struct iw_request_info
*info
,
979 struct iw_point
*wrq
,
983 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
984 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
985 PWLAN_IE_SSID pItemSSID
;
987 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWESSID \n");
989 // Note : if wrq->u.data.flags != 0, we should
990 // get the relevant SSID from the SSID list...
992 // Get the current SSID
993 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
994 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
995 memcpy(extra
, pItemSSID
->abySSID
, pItemSSID
->len
);
996 extra
[pItemSSID
->len
] = '\0';
997 wrq
->length
= pItemSSID
->len
+ 1;
998 //2008-0409-03, <Add> by Einsn Liu
999 wrq
->length
= pItemSSID
->len
;
1000 wrq
->flags
= 1; // active
1007 * Wireless Handler : set data rate
1010 int iwctl_siwrate(struct net_device
*dev
,
1011 struct iw_request_info
*info
,
1012 struct iw_param
*wrq
,
1015 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1019 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1022 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRATE \n");
1023 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1028 // First : get a valid bit rate value
1030 // Which type of value
1031 if((wrq
->value
< 13) &&
1032 (wrq
->value
>= 0)) {
1033 // Setting by rate index
1034 // Find value in the magic rate table
1037 // Setting by frequency value
1038 u8 normvalue
= (u8
) (wrq
->value
/500000);
1040 // Check if rate is valid
1041 for(i
= 0 ; i
< 13 ; i
++) {
1042 if(normvalue
== abySupportedRates
[i
]) {
1048 // -1 designed the max rate (mostly auto mode)
1049 if(wrq
->value
== -1) {
1050 // Get the highest available rate
1051 for(i
= 0 ; i
< 13 ; i
++) {
1052 if(abySupportedRates
[i
] == 0)
1059 // Check that it is valid
1060 // brate is index of abySupportedRates[]
1066 // Now, check if we want a fixed or auto value
1067 if(wrq
->fixed
!= 0) {
1070 printk("Rate Fix\n");
1071 pDevice
->bFixRate
= TRUE
;
1072 if ((pDevice
->byBBType
== BB_TYPE_11B
)&& (brate
> 3)) {
1074 pDevice
->uConnectionRate
= 3;
1077 pDevice
->uConnectionRate
= brate
;
1078 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fixed to Rate %d \n", pDevice
->uConnectionRate
);
1083 pDevice
->bFixRate
= FALSE
;
1084 pDevice
->uConnectionRate
= 13;
1085 printk("auto rate:connection_rate is 13\n");
1092 * Wireless Handler : get data rate
1095 int iwctl_giwrate(struct net_device
*dev
,
1096 struct iw_request_info
*info
,
1097 struct iw_param
*wrq
,
1100 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1101 //2007-0118-05,<Mark> by EinsnLiu
1102 //Mark the unnecessary sentences.
1103 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1105 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRATE \n");
1107 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1109 //2008-5-8 <modify> by chester
1110 if(pDevice
->bLinkPass
){
1111 if(pDevice
->bFixRate
== TRUE
){
1112 if (pDevice
->uConnectionRate
< 13) {
1113 brate
= abySupportedRates
[pDevice
->uConnectionRate
];
1115 if (pDevice
->byBBType
== BB_TYPE_11B
)
1117 if (pDevice
->byBBType
== BB_TYPE_11G
)
1119 if (pDevice
->byBBType
== BB_TYPE_11A
)
1126 brate
= abySupportedRates
[TxRate_iwconfig
];
1130 //2007-0118-05,<Mark> by EinsnLiu
1131 //Mark the unnecessary sentences.
1133 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1134 if (pDevice->byBBType == BB_TYPE_11B)
1136 if (pDevice->byBBType == BB_TYPE_11G)
1138 if (pDevice->byBBType == BB_TYPE_11A)
1143 // if (pDevice->uConnectionRate == 13)
1144 // brate = abySupportedRates[pDevice->wCurrentRate];
1145 wrq
->value
= brate
* 500000;
1146 // If more than one rate, set auto
1147 if (pDevice
->bFixRate
== TRUE
)
1158 * Wireless Handler : set rts threshold
1161 int iwctl_siwrts(struct net_device
*dev
,
1162 struct iw_request_info
*info
,
1163 struct iw_param
*wrq
,
1166 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1169 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRTS \n");
1172 int rthr
= wrq
->value
;
1175 if((rthr
< 0) || (rthr
> 2312)) {
1178 pDevice
->wRTSThreshold
= rthr
;
1186 * Wireless Handler : get rts
1189 int iwctl_giwrts(struct net_device
*dev
,
1190 struct iw_request_info
*info
,
1191 struct iw_param
*wrq
,
1194 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1196 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRTS \n");
1197 wrq
->value
= pDevice
->wRTSThreshold
;
1198 wrq
->disabled
= (wrq
->value
>= 2312);
1205 * Wireless Handler : set fragment threshold
1208 int iwctl_siwfrag(struct net_device
*dev
,
1209 struct iw_request_info
*info
,
1210 struct iw_param
*wrq
,
1213 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1215 int fthr
= wrq
->value
;
1218 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFRAG \n");
1223 if((fthr
< 256) || (fthr
> 2312)) {
1226 fthr
&= ~0x1; // Get an even value
1227 pDevice
->wFragmentationThreshold
= (u16
)fthr
;
1234 * Wireless Handler : get fragment threshold
1237 int iwctl_giwfrag(struct net_device
*dev
,
1238 struct iw_request_info
*info
,
1239 struct iw_param
*wrq
,
1242 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1244 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFRAG \n");
1245 wrq
->value
= pDevice
->wFragmentationThreshold
;
1246 wrq
->disabled
= (wrq
->value
>= 2312);
1255 * Wireless Handler : set retry threshold
1257 int iwctl_siwretry(struct net_device
*dev
,
1258 struct iw_request_info
*info
,
1259 struct iw_param
*wrq
,
1262 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1266 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRETRY \n");
1268 if (wrq
->disabled
) {
1273 if (wrq
->flags
& IW_RETRY_LIMIT
) {
1274 if(wrq
->flags
& IW_RETRY_MAX
)
1275 pDevice
->byLongRetryLimit
= wrq
->value
;
1276 else if (wrq
->flags
& IW_RETRY_MIN
)
1277 pDevice
->byShortRetryLimit
= wrq
->value
;
1279 // No modifier : set both
1280 pDevice
->byShortRetryLimit
= wrq
->value
;
1281 pDevice
->byLongRetryLimit
= wrq
->value
;
1284 if (wrq
->flags
& IW_RETRY_LIFETIME
) {
1285 pDevice
->wMaxTransmitMSDULifetime
= wrq
->value
;
1293 * Wireless Handler : get retry threshold
1295 int iwctl_giwretry(struct net_device
*dev
,
1296 struct iw_request_info
*info
,
1297 struct iw_param
*wrq
,
1300 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1301 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRETRY \n");
1302 wrq
->disabled
= 0; // Can't be disabled
1304 // Note : by default, display the min retry number
1305 if((wrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1306 wrq
->flags
= IW_RETRY_LIFETIME
;
1307 wrq
->value
= (int)pDevice
->wMaxTransmitMSDULifetime
; //ms
1308 } else if((wrq
->flags
& IW_RETRY_MAX
)) {
1309 wrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
1310 wrq
->value
= (int)pDevice
->byLongRetryLimit
;
1312 wrq
->flags
= IW_RETRY_LIMIT
;
1313 wrq
->value
= (int)pDevice
->byShortRetryLimit
;
1314 if((int)pDevice
->byShortRetryLimit
!= (int)pDevice
->byLongRetryLimit
)
1315 wrq
->flags
|= IW_RETRY_MIN
;
1324 * Wireless Handler : set encode mode
1326 int iwctl_siwencode(struct net_device
*dev
,
1327 struct iw_request_info
*info
,
1328 struct iw_point
*wrq
,
1331 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1332 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1333 DWORD dwKeyIndex
= (DWORD
)(wrq
->flags
& IW_ENCODE_INDEX
);
1335 int index
= (wrq
->flags
& IW_ENCODE_INDEX
);
1337 //2007-0207-07,<Modify> by EinsnLiu
1338 //There are some problems when using iwconfig encode/key command to set the WEP key.
1339 //I almost rewrite this function.
1340 //now it support:(assume the wireless interface's name is eth0)
1341 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1342 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1343 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1344 //iwconfig eth0 key restricted /*enable share key*/
1348 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWENCODE \n");
1350 if((wrq
->flags
& IW_ENCODE_DISABLED
)==0){
1351 //Not disable encryption
1353 if (dwKeyIndex
> WLAN_WEP_NKEYS
) {
1358 if(dwKeyIndex
<1&&((wrq
->flags
&IW_ENCODE_NOKEY
)==0)){//set default key
1359 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1360 dwKeyIndex
=pDevice
->byKeyIndex
;
1366 // Check the size of the key
1367 if (wrq
->length
> WLAN_WEP232_KEYLEN
) {
1372 if(wrq
->length
>0){//have key
1374 if (wrq
->length
== WLAN_WEP232_KEYLEN
) {
1375 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 232 bit wep key\n");
1377 else if (wrq
->length
== WLAN_WEP104_KEYLEN
) {
1378 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 104 bit wep key\n");
1380 else if (wrq
->length
== WLAN_WEP40_KEYLEN
) {
1381 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 40 bit wep key, index= %d\n", (int)dwKeyIndex
);
1382 }else {//no support length
1386 memset(pDevice
->abyKey
, 0, WLAN_WEP232_KEYLEN
);
1387 memcpy(pDevice
->abyKey
, extra
, wrq
->length
);
1389 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyKey: ");
1390 for (ii
= 0; ii
< wrq
->length
; ii
++) {
1391 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02x ", pDevice
->abyKey
[ii
]);
1394 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1395 spin_lock_irq(&pDevice
->lock
);
1396 KeybSetDefaultKey(&(pDevice
->sKey
),
1397 (DWORD
)(dwKeyIndex
| (1 << 31)),
1402 pDevice
->PortOffset
,
1405 spin_unlock_irq(&pDevice
->lock
);
1407 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
1408 pDevice
->uKeyLength
= wrq
->length
;
1409 pDevice
->bTransmitKey
= TRUE
;
1410 pDevice
->bEncryptionEnable
= TRUE
;
1411 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1414 //when the length is 0 the request only changes the default transmit key index
1415 //check the new key has a non zero lenget
1416 if(pDevice
->bEncryptionEnable
==FALSE
)
1421 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Just set Default key Index:\n");
1422 pkeytab
=&(pDevice
->sKey
.KeyTable
[MAX_KEY_TABLE
-1]);
1423 if(pkeytab
->GroupKey
[(BYTE
)dwKeyIndex
].uKeyLength
==0){
1424 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Default key len is 0\n");
1428 pDevice
->byKeyIndex
=(BYTE
)dwKeyIndex
;
1429 pkeytab
->dwGTKeyIndex
=dwKeyIndex
| (1 << 31);
1430 pkeytab
->GroupKey
[(BYTE
)dwKeyIndex
].dwKeyIndex
=dwKeyIndex
| (1 << 31);
1433 }else {//disable the key
1434 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disable WEP function\n");
1435 if(pDevice
->bEncryptionEnable
==FALSE
)
1437 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1438 pDevice
->bEncryptionEnable
= FALSE
;
1439 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1440 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1441 spin_lock_irq(&pDevice
->lock
);
1442 for(uu
=0;uu
<MAX_KEY_TABLE
;uu
++)
1443 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
1444 spin_unlock_irq(&pDevice
->lock
);
1450 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1452 // Check the size of the key
1453 if (wrq->length > WLAN_WEP232_KEYLEN) {
1458 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1466 // Send the key to the card
1467 if (wrq->length > 0) {
1469 if (wrq->length == WLAN_WEP232_KEYLEN) {
1470 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1472 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1473 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1475 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1476 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1478 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1479 memcpy(pDevice->abyKey, extra, wrq->length);
1481 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1482 for (ii = 0; ii < wrq->length; ii++) {
1483 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1486 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1487 spin_lock_irq(&pDevice->lock);
1488 KeybSetDefaultKey(&(pDevice->sKey),
1489 (DWORD)(pDevice->byKeyIndex | (1 << 31)),
1490 pDevice->uKeyLength,
1494 pDevice->PortOffset,
1497 spin_unlock_irq(&pDevice->lock);
1499 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1500 pDevice->uKeyLength = wrq->length;
1501 pDevice->bTransmitKey = TRUE;
1502 pDevice->bEncryptionEnable = TRUE;
1503 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1505 // Do we want to just set the transmit key index ?
1507 pDevice->byKeyIndex = index;
1509 else if(!wrq->flags & IW_ENCODE_MODE) {
1515 if(wrq->flags & IW_ENCODE_DISABLED){
1517 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1518 pMgmt->bShareKeyAlgorithm = FALSE;
1519 pDevice->bEncryptionEnable = FALSE;
1520 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1521 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1522 spin_lock_irq(&pDevice->lock);
1523 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1524 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1525 spin_unlock_irq(&pDevice->lock);
1530 if(wrq
->flags
& IW_ENCODE_RESTRICTED
) {
1531 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & ShareKey System\n");
1532 pMgmt
->bShareKeyAlgorithm
= TRUE
;
1534 if(wrq
->flags
& IW_ENCODE_OPEN
) {
1535 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & Open System\n");
1536 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1542 * Wireless Handler : get encode mode
1545 int iwctl_giwencode(struct net_device *dev,
1546 struct iw_request_info *info,
1547 struct iw_point *wrq,
1550 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1551 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1553 char abyKey[WLAN_WEP232_KEYLEN];
1554 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1555 PSKeyItem pKey = NULL;
1557 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1558 //2007-0207-06,<Add> by EinsnLiu
1559 //the key index in iwconfig is 1-4 when our driver is 0-3
1560 //so it can't be used directly.
1561 //if the index is 0,we should used the index set by driver.
1562 if (index > WLAN_WEP_NKEYS) {
1566 if(index<1){//set default key
1567 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1568 index=pDevice->byKeyIndex;
1574 memset(abyKey, 0, sizeof(abyKey));
1575 // Check encryption mode
1576 wrq->flags = IW_ENCODE_NOKEY;
1577 // Is WEP enabled ???
1578 if (pDevice->bEncryptionEnable)
1579 wrq->flags |= IW_ENCODE_ENABLED;
1581 wrq->flags |= IW_ENCODE_DISABLED;
1583 if (pMgmt->bShareKeyAlgorithm)
1584 wrq->flags |= IW_ENCODE_RESTRICTED;
1586 wrq->flags |= IW_ENCODE_OPEN;
1588 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1589 wrq->length = pKey->uKeyLength;
1590 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1591 //2007-0207-06,<Modify> by EinsnLiu
1592 //only get key success need to copy data
1594 //there is not necessary to return -EINVAL when get key failed
1595 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1596 wrq->flags |= index+1;
1597 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1612 //2008-0409-06, <Add> by Einsn Liu
1614 int iwctl_giwencode(struct net_device
*dev
,
1615 struct iw_request_info
*info
,
1616 struct iw_point
*wrq
,
1619 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1620 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1621 char abyKey
[WLAN_WEP232_KEYLEN
];
1623 UINT index
= (UINT
)(wrq
->flags
& IW_ENCODE_INDEX
);
1624 PSKeyItem pKey
= NULL
;
1626 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWENCODE\n");
1628 if (index
> WLAN_WEP_NKEYS
) {
1631 if(index
<1){//get default key
1632 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1633 index
=pDevice
->byKeyIndex
;
1639 memset(abyKey
, 0, WLAN_WEP232_KEYLEN
);
1640 // Check encryption mode
1641 wrq
->flags
= IW_ENCODE_NOKEY
;
1642 // Is WEP enabled ???
1643 if (pDevice
->bEncryptionEnable
)
1644 wrq
->flags
|= IW_ENCODE_ENABLED
;
1646 wrq
->flags
|= IW_ENCODE_DISABLED
;
1648 if (pMgmt
->bShareKeyAlgorithm
)
1649 wrq
->flags
|= IW_ENCODE_RESTRICTED
;
1651 wrq
->flags
|= IW_ENCODE_OPEN
;
1654 if((index
==0)&&(pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
||
1655 pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)){//get wpa pairwise key
1656 if (KeybGetKey(&(pDevice
->sKey
),pMgmt
->abyCurrBSSID
, 0xffffffff, &pKey
)){
1657 wrq
->length
= pKey
->uKeyLength
;
1658 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1659 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1661 }else if (KeybGetKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, (BYTE
)index
, &pKey
)){
1662 wrq
->length
= pKey
->uKeyLength
;
1663 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1664 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1667 wrq
->flags
|= index
+1;
1673 * Wireless Handler : set power mode
1675 int iwctl_siwpower(struct net_device
*dev
,
1676 struct iw_request_info
*info
,
1677 struct iw_param
*wrq
,
1680 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1681 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1684 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER \n");
1686 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1691 if (wrq
->disabled
) {
1692 pDevice
->ePSMode
= WMAC_POWER_CAM
;
1693 PSvDisablePowerSaving(pDevice
);
1696 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1697 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1698 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1700 } else if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
1701 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1702 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1704 switch (wrq
->flags
& IW_POWER_MODE
) {
1705 case IW_POWER_UNICAST_R
:
1706 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1709 case IW_POWER_ALL_R
:
1710 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ALL_R \n");
1713 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ON \n");
1723 * Wireless Handler : get power mode
1725 int iwctl_giwpower(struct net_device
*dev
,
1726 struct iw_request_info
*info
,
1727 struct iw_param
*wrq
,
1730 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1731 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1732 int mode
= pDevice
->ePSMode
;
1735 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWPOWER \n");
1738 if ((wrq
->disabled
= (mode
== WMAC_POWER_CAM
)))
1741 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1742 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1743 wrq
->flags
= IW_POWER_TIMEOUT
;
1745 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1746 wrq
->flags
= IW_POWER_PERIOD
;
1748 wrq
->flags
|= IW_POWER_ALL_R
;
1755 * Wireless Handler : get Sensitivity
1757 int iwctl_giwsens(struct net_device
*dev
,
1758 struct iw_request_info
*info
,
1759 struct iw_param
*wrq
,
1762 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1765 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSENS \n");
1766 if (pDevice
->bLinkPass
== TRUE
) {
1767 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
1773 wrq
->disabled
= (wrq
->value
== 0);
1780 //2008-0409-07, <Add> by Einsn Liu
1781 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1783 int iwctl_siwauth(struct net_device
*dev
,
1784 struct iw_request_info
*info
,
1785 struct iw_param
*wrq
,
1788 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1789 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1791 static int wpa_version
=0; //must be static to save the last value,einsn liu
1792 static int pairwise
=0;
1794 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAUTH \n");
1795 switch (wrq
->flags
& IW_AUTH_INDEX
) {
1796 case IW_AUTH_WPA_VERSION
:
1797 wpa_version
= wrq
->value
;
1798 if(wrq
->value
== IW_AUTH_WPA_VERSION_DISABLED
) {
1799 printk("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1800 //pDevice->bWPADevEnable = FALSE;
1802 else if(wrq
->value
== IW_AUTH_WPA_VERSION_WPA
) {
1803 printk("iwctl_siwauth:set WPADEV to WPA1******\n");
1806 printk("iwctl_siwauth:set WPADEV to WPA2******\n");
1808 //pDevice->bWPASuppWextEnabled =TRUE;
1810 case IW_AUTH_CIPHER_PAIRWISE
:
1811 pairwise
= wrq
->value
;
1813 if(pairwise
== IW_AUTH_CIPHER_CCMP
){
1814 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1815 }else if(pairwise
== IW_AUTH_CIPHER_TKIP
){
1816 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1817 }else if(pairwise
== IW_AUTH_CIPHER_WEP40
||pairwise
== IW_AUTH_CIPHER_WEP104
){
1818 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1819 }else if(pairwise
== IW_AUTH_CIPHER_NONE
){
1820 //do nothing,einsn liu
1821 }else pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1824 case IW_AUTH_CIPHER_GROUP
:
1825 if(wpa_version
== IW_AUTH_WPA_VERSION_DISABLED
)
1827 if(pairwise
== IW_AUTH_CIPHER_NONE
){
1828 if(wrq
->value
== IW_AUTH_CIPHER_CCMP
){
1829 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1831 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1835 case IW_AUTH_KEY_MGMT
:
1837 if(wpa_version
== IW_AUTH_WPA_VERSION_WPA2
){
1838 if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1839 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
1840 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
1841 }else if(wpa_version
== IW_AUTH_WPA_VERSION_WPA
){
1842 if(wrq
->value
== 0){
1843 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
1844 }else if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1845 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
1846 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
1850 case IW_AUTH_TKIP_COUNTERMEASURES
:
1852 case IW_AUTH_DROP_UNENCRYPTED
:
1854 case IW_AUTH_80211_AUTH_ALG
:
1855 if(wrq
->value
==IW_AUTH_ALG_OPEN_SYSTEM
){
1856 pMgmt
->bShareKeyAlgorithm
=FALSE
;
1857 }else if(wrq
->value
==IW_AUTH_ALG_SHARED_KEY
){
1858 pMgmt
->bShareKeyAlgorithm
=TRUE
;
1861 case IW_AUTH_WPA_ENABLED
:
1862 //pDevice->bWPADevEnable = !! wrq->value;
1864 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1866 case IW_AUTH_ROAMING_CONTROL
:
1869 case IW_AUTH_PRIVACY_INVOKED
:
1870 pDevice
->bEncryptionEnable
= !!wrq
->value
;
1871 if(pDevice
->bEncryptionEnable
== FALSE
){
1874 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1875 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1876 pMgmt
->eAuthenMode
= FALSE
;
1877 //pDevice->bWPADevEnable = FALSE;
1886 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1887 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1888 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1889 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1890 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1891 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1892 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");
1898 int iwctl_giwauth(struct net_device
*dev
,
1899 struct iw_request_info
*info
,
1900 struct iw_param
*wrq
,
1908 int iwctl_siwgenie(struct net_device
*dev
,
1909 struct iw_request_info
*info
,
1910 struct iw_point
*wrq
,
1913 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1914 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1918 if ((wrq
->length
< 2) || (extra
[1]+2 != wrq
->length
)) {
1922 if(wrq
->length
> MAX_WPA_IE_LEN
){
1926 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1927 if(copy_from_user(pMgmt
->abyWPAIE
, extra
, wrq
->length
)){
1931 pMgmt
->wWPAIELen
= wrq
->length
;
1933 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1934 pMgmt
->wWPAIELen
= 0;
1937 out
://not completely ...not necessary in wpa_supplicant 0.5.8
1941 int iwctl_giwgenie(struct net_device
*dev
,
1942 struct iw_request_info
*info
,
1943 struct iw_point
*wrq
,
1946 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1947 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1949 int space
= wrq
->length
;
1952 if(pMgmt
->wWPAIELen
> 0){
1953 wrq
->length
= pMgmt
->wWPAIELen
;
1954 if(pMgmt
->wWPAIELen
<= space
){
1955 if(copy_to_user(extra
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
)){
1966 int iwctl_siwencodeext(struct net_device
*dev
,
1967 struct iw_request_info
*info
,
1968 struct iw_point
*wrq
,
1971 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1972 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1973 struct viawget_wpa_param
*param
=NULL
;
1977 int key_idx
, set_tx
;
1978 u8 seq
[IW_ENCODE_SEQ_MAX_SIZE
];
1980 size_t seq_len
,key_len
=0;
1988 printk("SIOCSIWENCODEEXT...... \n");
1990 blen
= sizeof(*param
);
1991 buf
= kmalloc((int)blen
, (int)GFP_KERNEL
);
1994 memset(buf
, 0, blen
);
1995 param
= (struct viawget_wpa_param
*) buf
;
1999 case IW_ENCODE_ALG_NONE
:
2000 alg_name
= WPA_ALG_NONE
;
2002 case IW_ENCODE_ALG_WEP
:
2003 alg_name
= WPA_ALG_WEP
;
2005 case IW_ENCODE_ALG_TKIP
:
2006 alg_name
= WPA_ALG_TKIP
;
2008 case IW_ENCODE_ALG_CCMP
:
2009 alg_name
= WPA_ALG_CCMP
;
2012 printk("Unknown alg = %d\n",ext
->alg
);
2017 memcpy(addr
, ext
->addr
.sa_data
, ETH_ALEN
);
2019 key_idx
= (wrq
->flags
&IW_ENCODE_INDEX
) - 1;
2021 if(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2023 //recover seq,seq_len
2024 if(ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
2025 seq_len
=IW_ENCODE_SEQ_MAX_SIZE
;
2026 memcpy(seq
, ext
->rx_seq
, seq_len
);
2028 //recover key,key_len
2030 key_len
=ext
->key_len
;
2031 memcpy(key
, &ext
->key
[0], key_len
);
2034 memset(key_array
, 0, 64);
2036 memcpy(key_array
, key
, key_len
);
2037 if (key_len
== 32) {
2038 // notice ! the oder
2039 memcpy(&key_array
[16], &key
[24], 8);
2040 memcpy(&key_array
[24], &key
[16], 8);
2044 /**************Translate iw_encode_ext to viawget_wpa_param****************/
2045 memcpy(param
->addr
, addr
, ETH_ALEN
);
2046 param
->u
.wpa_key
.alg_name
= (int)alg_name
;
2047 param
->u
.wpa_key
.set_tx
= set_tx
;
2048 param
->u
.wpa_key
.key_index
= key_idx
;
2049 param
->u
.wpa_key
.key_len
= key_len
;
2050 param
->u
.wpa_key
.key
= (u8
*)key_array
;
2051 param
->u
.wpa_key
.seq
= (u8
*)seq
;
2052 param
->u
.wpa_key
.seq_len
= seq_len
;
2056 printk("param->u.wpa_key.alg_name =%d\n",param
->u
.wpa_key
.alg_name
);
2057 printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
2058 param
->addr
[0],param
->addr
[1],param
->addr
[2],
2059 param
->addr
[3],param
->addr
[4],param
->addr
[5]);
2060 printk("param->u.wpa_key.set_tx =%d\n",param
->u
.wpa_key
.set_tx
);
2061 printk("param->u.wpa_key.key_index =%d\n",param
->u
.wpa_key
.key_index
);
2062 printk("param->u.wpa_key.key_len =%d\n",param
->u
.wpa_key
.key_len
);
2063 printk("param->u.wpa_key.key =");
2064 for(ii
=0;ii
<param
->u
.wpa_key
.key_len
;ii
++)
2065 printk("%02x:",param
->u
.wpa_key
.key
[ii
]);
2067 printk("param->u.wpa_key.seq_len =%d\n",param
->u
.wpa_key
.seq_len
);
2068 printk("param->u.wpa_key.seq =");
2069 for(ii
=0;ii
<param
->u
.wpa_key
.seq_len
;ii
++)
2070 printk("%02x:",param
->u
.wpa_key
.seq
[ii
]);
2073 printk("...........\n");
2075 //****set if current action is Network Manager count??
2076 //****this method is so foolish,but there is no other way???
2077 if(param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
2078 if(param
->u
.wpa_key
.key_index
==0) {
2079 pDevice
->bwextcount
++;
2081 if((pDevice
->bwextcount
== 1)&&(param
->u
.wpa_key
.key_index
==1)) {
2082 pDevice
->bwextcount
++;
2084 if((pDevice
->bwextcount
==2)&&(param
->u
.wpa_key
.key_index
==2)) {
2085 pDevice
->bwextcount
++;
2087 if((pDevice
->bwextcount
==3)&&(param
->u
.wpa_key
.key_index
==3)) {
2088 pDevice
->bwextcount
++;
2091 if( pDevice
->bwextcount
== 4) {
2092 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2093 pDevice
->bwextcount
=0;
2094 pDevice
->bWPASuppWextEnabled
= TRUE
;
2098 spin_lock_irq(&pDevice
->lock
);
2099 ret
= wpa_set_keys(pDevice
, param
, TRUE
);
2100 spin_unlock_irq(&pDevice
->lock
);
2109 int iwctl_giwencodeext(struct net_device
*dev
,
2110 struct iw_request_info
*info
,
2111 struct iw_point
*wrq
,
2114 return -EOPNOTSUPP
;;
2117 int iwctl_siwmlme(struct net_device
*dev
,
2118 struct iw_request_info
* info
,
2119 struct iw_point
*wrq
,
2122 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
2123 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2124 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2125 //u16 reason = cpu_to_le16(mlme->reason_code);
2128 if(memcmp(pMgmt
->abyCurrBSSID
, mlme
->addr
.sa_data
, ETH_ALEN
)){
2133 case IW_MLME_DEAUTH
:
2134 //this command seems to be not complete,please test it --einsnliu
2135 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2137 case IW_MLME_DISASSOC
:
2138 if(pDevice
->bLinkPass
== TRUE
){
2139 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2140 //clear related flags
2141 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
2142 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
2143 bScheduleCommand((HANDLE
)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
2157 /*------------------------------------------------------------------*/
2159 * Structures to export the Wireless Handlers
2164 static const iw_handler iwctl_handler[] =
2166 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2167 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2168 (iw_handler) NULL, // SIOCSIWNWID
2169 (iw_handler) NULL, // SIOCGIWNWID
2170 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2171 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2172 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2173 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2174 (iw_handler) NULL, // SIOCSIWSENS
2175 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2176 (iw_handler) NULL, // SIOCSIWRANGE
2177 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2178 (iw_handler) NULL, // SIOCSIWPRIV
2179 (iw_handler) NULL, // SIOCGIWPRIV
2180 (iw_handler) NULL, // SIOCSIWSTATS
2181 (iw_handler) NULL, // SIOCGIWSTATS
2182 (iw_handler) NULL, // SIOCSIWSPY
2183 (iw_handler) NULL, // SIOCGIWSPY
2184 (iw_handler) NULL, // -- hole --
2185 (iw_handler) NULL, // -- hole --
2186 (iw_handler) iwctl_siwap, // SIOCSIWAP
2187 (iw_handler) iwctl_giwap, // SIOCGIWAP
2188 (iw_handler) NULL, // -- hole -- 0x16
2189 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2190 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2191 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2192 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2193 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2194 (iw_handler) NULL, // SIOCSIWNICKN
2195 (iw_handler) NULL, // SIOCGIWNICKN
2196 (iw_handler) NULL, // -- hole --
2197 (iw_handler) NULL, // -- hole --
2198 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2199 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2200 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2201 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2202 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2203 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2204 (iw_handler) NULL, // SIOCSIWTXPOW
2205 (iw_handler) NULL, // SIOCGIWTXPOW
2206 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2207 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2208 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2209 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2210 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2211 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2212 (iw_handler) NULL, // -- hole --
2213 (iw_handler) NULL, // -- hole --
2214 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2215 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2216 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2217 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2218 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2219 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2220 (iw_handler) NULL, // SIOCSIWPMKSA
2221 (iw_handler) NULL, // -- hole --
2226 static const iw_handler iwctl_handler
[] =
2228 (iw_handler
) iwctl_commit
, // SIOCSIWCOMMIT
2229 (iw_handler
) NULL
, // SIOCGIWNAME
2230 (iw_handler
) NULL
, // SIOCSIWNWID
2231 (iw_handler
) NULL
, // SIOCGIWNWID
2232 (iw_handler
) NULL
, // SIOCSIWFREQ
2233 (iw_handler
) NULL
, // SIOCGIWFREQ
2234 (iw_handler
) NULL
, // SIOCSIWMODE
2235 (iw_handler
) NULL
, // SIOCGIWMODE
2236 (iw_handler
) NULL
, // SIOCSIWSENS
2237 (iw_handler
) NULL
, // SIOCGIWSENS
2238 (iw_handler
) NULL
, // SIOCSIWRANGE
2239 (iw_handler
) iwctl_giwrange
, // SIOCGIWRANGE
2240 (iw_handler
) NULL
, // SIOCSIWPRIV
2241 (iw_handler
) NULL
, // SIOCGIWPRIV
2242 (iw_handler
) NULL
, // SIOCSIWSTATS
2243 (iw_handler
) NULL
, // SIOCGIWSTATS
2244 (iw_handler
) NULL
, // SIOCSIWSPY
2245 (iw_handler
) NULL
, // SIOCGIWSPY
2246 (iw_handler
) NULL
, // -- hole --
2247 (iw_handler
) NULL
, // -- hole --
2248 (iw_handler
) NULL
, // SIOCSIWAP
2249 (iw_handler
) NULL
, // SIOCGIWAP
2250 (iw_handler
) NULL
, // -- hole -- 0x16
2251 (iw_handler
) NULL
, // SIOCGIWAPLIST
2252 (iw_handler
) iwctl_siwscan
, // SIOCSIWSCAN
2253 (iw_handler
) iwctl_giwscan
, // SIOCGIWSCAN
2254 (iw_handler
) NULL
, // SIOCSIWESSID
2255 (iw_handler
) NULL
, // SIOCGIWESSID
2256 (iw_handler
) NULL
, // SIOCSIWNICKN
2257 (iw_handler
) NULL
, // SIOCGIWNICKN
2258 (iw_handler
) NULL
, // -- hole --
2259 (iw_handler
) NULL
, // -- hole --
2260 (iw_handler
) NULL
, // SIOCSIWRATE 0x20
2261 (iw_handler
) NULL
, // SIOCGIWRATE
2262 (iw_handler
) NULL
, // SIOCSIWRTS
2263 (iw_handler
) NULL
, // SIOCGIWRTS
2264 (iw_handler
) NULL
, // SIOCSIWFRAG
2265 (iw_handler
) NULL
, // SIOCGIWFRAG
2266 (iw_handler
) NULL
, // SIOCSIWTXPOW
2267 (iw_handler
) NULL
, // SIOCGIWTXPOW
2268 (iw_handler
) NULL
, // SIOCSIWRETRY
2269 (iw_handler
) NULL
, // SIOCGIWRETRY
2270 (iw_handler
) NULL
, // SIOCSIWENCODE
2271 (iw_handler
) NULL
, // SIOCGIWENCODE
2272 (iw_handler
) NULL
, // SIOCSIWPOWER
2273 (iw_handler
) NULL
, // SIOCGIWPOWER
2275 //2008-0409-07, <Add> by Einsn Liu
2276 (iw_handler
) NULL
, // -- hole --
2277 (iw_handler
) NULL
, // -- hole --
2278 (iw_handler
) NULL
, // SIOCSIWGENIE
2279 (iw_handler
) NULL
, // SIOCGIWGENIE
2280 (iw_handler
) NULL
, // SIOCSIWAUTH
2281 (iw_handler
) NULL
, // SIOCGIWAUTH
2282 (iw_handler
) NULL
, // SIOCSIWENCODEEXT
2283 (iw_handler
) NULL
, // SIOCGIWENCODEEXT
2284 (iw_handler
) NULL
, // SIOCSIWPMKSA
2285 (iw_handler
) NULL
, // -- hole --
2289 static const iw_handler iwctl_private_handler
[] =
2291 NULL
, // SIOCIWFIRSTPRIV
2295 struct iw_priv_args iwctl_private_args
[] = {
2297 IW_PRIV_TYPE_CHAR
| 1024, 0,
2303 const struct iw_handler_def iwctl_handler_def
=
2305 .get_wireless_stats
= &iwctl_get_wireless_stats
,
2306 .num_standard
= sizeof(iwctl_handler
)/sizeof(iw_handler
),
2307 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2308 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2310 .num_private_args
= 0,
2311 .standard
= (iw_handler
*) iwctl_handler
,
2312 // .private = (iw_handler *) iwctl_private_handler,
2313 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2315 .private_args
= NULL
,
2320 #endif // WIRELESS_EXT