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
43 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
48 #include <net/iw_handler.h>
49 extern WORD TxRate_iwconfig
;//2008-5-8 <add> by chester
51 /*--------------------- Static Definitions -------------------------*/
53 //2008-0409-07, <Add> by Einsn Liu
54 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
55 #define SUPPORTED_WIRELESS_EXT 18
57 #define SUPPORTED_WIRELESS_EXT 17
60 static const long frequency_list
[] = {
61 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
62 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
63 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
64 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
65 5700, 5745, 5765, 5785, 5805, 5825
69 /*--------------------- Static Classes ----------------------------*/
72 //static int msglevel =MSG_LEVEL_DEBUG;
73 static int msglevel
=MSG_LEVEL_INFO
;
76 /*--------------------- Static Variables --------------------------*/
77 /*--------------------- Static Functions --------------------------*/
79 /*--------------------- Export Variables --------------------------*/
81 struct iw_statistics
*iwctl_get_wireless_stats(struct net_device
*dev
)
83 PSDevice pDevice
= netdev_priv(dev
);
86 pDevice
->wstats
.status
= pDevice
->eOPMode
;
89 if(pDevice
->byBBType
== BB_TYPE_11B
) {
90 if(pDevice
->byCurrSQ
> 120)
91 pDevice
->scStatistic
.LinkQuality
= 100;
93 pDevice
->scStatistic
.LinkQuality
= pDevice
->byCurrSQ
*100/120;
95 else if(pDevice
->byBBType
== BB_TYPE_11G
) {
96 if(pDevice
->byCurrSQ
< 20)
97 pDevice
->scStatistic
.LinkQuality
= 100;
98 else if(pDevice
->byCurrSQ
>96)
99 pDevice
->scStatistic
.LinkQuality
= 0;
101 pDevice
->scStatistic
.LinkQuality
= (96-pDevice
->byCurrSQ
)*100/76;
103 if(pDevice
->bLinkPass
!=TRUE
)
104 pDevice
->scStatistic
.LinkQuality
= 0;
106 if(pDevice
->scStatistic
.LinkQuality
> 100)
107 pDevice
->scStatistic
.LinkQuality
= 100;
108 pDevice
->wstats
.qual
.qual
=(BYTE
) pDevice
->scStatistic
.LinkQuality
;
110 pDevice
->wstats
.qual
.qual
= pDevice
->byCurrSQ
;
112 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
113 pDevice
->wstats
.qual
.level
= ldBm
;
114 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
115 pDevice
->wstats
.qual
.noise
= 0;
116 pDevice
->wstats
.qual
.updated
= 1;
117 pDevice
->wstats
.discard
.nwid
= 0;
118 pDevice
->wstats
.discard
.code
= 0;
119 pDevice
->wstats
.discard
.fragment
= 0;
120 pDevice
->wstats
.discard
.retries
= (U32
)pDevice
->scStatistic
.dwTsrErr
;
121 pDevice
->wstats
.discard
.misc
= 0;
122 pDevice
->wstats
.miss
.beacon
= 0;
124 return &pDevice
->wstats
;
129 /*------------------------------------------------------------------*/
132 static int iwctl_commit(struct net_device
*dev
,
133 struct iw_request_info
*info
,
137 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWCOMMIT \n");
143 * Wireless Handler : get protocol name
146 int iwctl_giwname(struct net_device
*dev
,
147 struct iw_request_info
*info
,
151 strcpy(wrq
, "802.11-a/b/g");
155 int iwctl_giwnwid(struct net_device
*dev
,
156 struct iw_request_info
*info
,
157 struct iw_param
*wrq
,
160 //wrq->value = 0x100;
168 * Wireless Handler : set scan
171 int iwctl_siwscan(struct net_device
*dev
,
172 struct iw_request_info
*info
,
173 struct iw_point
*wrq
,
176 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
177 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
178 struct iw_scan_req
*req
= (struct iw_scan_req
*)extra
;
179 BYTE abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
180 PWLAN_IE_SSID pItemSSID
=NULL
;
181 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWSCAN \n");
184 if(pDevice
->byReAssocCount
> 0) { //reject scan when re-associating!
185 //send scan event to wpa_Supplicant
186 union iwreq_data wrqu
;
187 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
188 memset(&wrqu
, 0, sizeof(wrqu
));
189 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
193 spin_lock_irq(&pDevice
->lock
);
194 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
196 //mike add: active scan OR passive scan OR desire_ssid scan
197 if(wrq
->length
== sizeof(struct iw_scan_req
)) {
198 if (wrq
->flags
& IW_SCAN_THIS_ESSID
) { //desire_ssid scan
199 memset(abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
200 pItemSSID
= (PWLAN_IE_SSID
)abyScanSSID
;
201 pItemSSID
->byElementID
= WLAN_EID_SSID
;
202 memcpy(pItemSSID
->abySSID
, req
->essid
, (int)req
->essid_len
);
203 if (pItemSSID
->abySSID
[req
->essid_len
- 1] == '\0') {
205 pItemSSID
->len
= req
->essid_len
- 1;
208 pItemSSID
->len
= req
->essid_len
;
209 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
210 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID
)abyScanSSID
)->abySSID
,
211 ((PWLAN_IE_SSID
)abyScanSSID
)->len
);
212 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, abyScanSSID
);
213 spin_unlock_irq(&pDevice
->lock
);
217 else if(req
->scan_type
== IW_SCAN_TYPE_PASSIVE
) { //passive scan
218 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
222 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
225 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
226 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
227 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
228 spin_unlock_irq(&pDevice
->lock
);
235 * Wireless Handler : get scan results
238 int iwctl_giwscan(struct net_device
*dev
,
239 struct iw_request_info
*info
,
240 struct iw_point
*wrq
,
244 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
245 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
247 PWLAN_IE_SSID pItemSSID
;
248 PWLAN_IE_SUPP_RATES pSuppRates
, pExtSuppRates
;
249 char *current_ev
= extra
;
250 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
251 char *current_val
= NULL
;
254 char buf
[MAX_WPA_IE_LEN
* 2 + 30];
257 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSCAN \n");
259 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
263 pBSS
= &(pMgmt
->sBSSList
[0]);
264 for (ii
= 0, jj
= 0; jj
< MAX_BSS_NUM
; jj
++) {
265 if (current_ev
>= end_buf
)
267 pBSS
= &(pMgmt
->sBSSList
[jj
]);
270 memset(&iwe
, 0, sizeof(iwe
));
272 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
273 memcpy(iwe
.u
.ap_addr
.sa_data
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
274 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
276 memset(&iwe
, 0, sizeof(iwe
));
277 iwe
.cmd
= SIOCGIWESSID
;
278 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
279 iwe
.u
.data
.length
= pItemSSID
->len
;
280 iwe
.u
.data
.flags
= 1;
281 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
283 memset(&iwe
, 0, sizeof(iwe
));
284 iwe
.cmd
= SIOCGIWMODE
;
285 if (WLAN_GET_CAP_INFO_ESS(pBSS
->wCapInfo
)) {
286 iwe
.u
.mode
= IW_MODE_INFRA
;
289 iwe
.u
.mode
= IW_MODE_ADHOC
;
291 iwe
.len
= IW_EV_UINT_LEN
;
292 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
294 pSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abySuppRates
;
295 pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abyExtSuppRates
;
296 memset(&iwe
, 0, sizeof(iwe
));
297 iwe
.cmd
= SIOCGIWFREQ
;
298 iwe
.u
.freq
.m
= pBSS
->uChannel
;
301 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
302 //2008-0409-04, <Add> by Einsn Liu
304 int f
= (int)pBSS
->uChannel
- 1;
306 iwe
.u
.freq
.m
= frequency_list
[f
] * 100000;
309 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
311 memset(&iwe
, 0, sizeof(iwe
));
313 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
314 iwe
.u
.qual
.level
= ldBm
;
315 iwe
.u
.qual
.noise
= 0;
316 //2008-0409-01, <Add> by Einsn Liu
318 iwe
.u
.qual
.qual
= 100;
319 }else if(-ldBm
> 90) {
322 iwe
.u
.qual
.qual
=(40-(-ldBm
-50))*100/40;
324 iwe
.u
.qual
.updated
=7;
326 // iwe.u.qual.qual = 0;
327 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
329 memset(&iwe
, 0, sizeof(iwe
));
330 iwe
.cmd
= SIOCGIWENCODE
;
331 iwe
.u
.data
.length
= 0;
332 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS
->wCapInfo
)) {
333 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
335 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
337 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
339 memset(&iwe
, 0, sizeof(iwe
));
340 iwe
.cmd
= SIOCGIWRATE
;
341 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
342 current_val
= current_ev
+ IW_EV_LCP_LEN
;
344 for (kk
= 0 ; kk
< 12 ; kk
++) {
345 if (pSuppRates
->abyRates
[kk
] == 0)
347 // Bit rate given in 500 kb/s units (+ 0x80)
348 iwe
.u
.bitrate
.value
= ((pSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
349 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
351 for (kk
= 0 ; kk
< 8 ; kk
++) {
352 if (pExtSuppRates
->abyRates
[kk
] == 0)
354 // Bit rate given in 500 kb/s units (+ 0x80)
355 iwe
.u
.bitrate
.value
= ((pExtSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
356 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
359 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
360 current_ev
= current_val
;
362 memset(&iwe
, 0, sizeof(iwe
));
363 iwe
.cmd
= IWEVCUSTOM
;
364 sprintf(buf
, "bcn_int=%d", pBSS
->wBeaconInterval
);
365 iwe
.u
.data
.length
= strlen(buf
);
366 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, buf
);
368 if ((pBSS
->wWPALen
> 0) && (pBSS
->wWPALen
<= MAX_WPA_IE_LEN
)) {
369 memset(&iwe
, 0, sizeof(iwe
));
371 iwe
.u
.data
.length
= pBSS
->wWPALen
;
372 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byWPAIE
);
375 if ((pBSS
->wRSNLen
> 0) && (pBSS
->wRSNLen
<= MAX_WPA_IE_LEN
)) {
376 memset(&iwe
, 0, sizeof(iwe
));
378 iwe
.u
.data
.length
= pBSS
->wRSNLen
;
379 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byRSNIE
);
385 wrq
->length
= current_ev
- extra
;
392 * Wireless Handler : set frequence or channel
395 int iwctl_siwfreq(struct net_device
*dev
,
396 struct iw_request_info
*info
,
400 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
403 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFREQ \n");
405 // If setting by frequency, convert to a channel
407 (wrq
->m
>= (int) 2.412e8
) &&
408 (wrq
->m
<= (int) 2.487e8
)) {
409 int f
= wrq
->m
/ 100000;
411 while((c
< 14) && (f
!= frequency_list
[c
]))
416 // Setting by channel number
417 if((wrq
->m
> 14) || (wrq
->e
> 0))
420 int channel
= wrq
->m
;
421 if((channel
< 1) || (channel
> 14)) {
422 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: New channel value of %d is invalid!\n", dev
->name
, wrq
->m
);
425 // Yes ! We can set it !!!
426 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set to channel = %d\n", channel
);
427 pDevice
->uChannel
= channel
;
428 //2007-0207-04,<Add> by EinsnLiu
429 //Make change effect at once
430 pDevice
->bCommit
= TRUE
;
438 * Wireless Handler : get frequence or channel
441 int iwctl_giwfreq(struct net_device
*dev
,
442 struct iw_request_info
*info
,
446 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
447 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
449 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFREQ \n");
451 #ifdef WEXT_USECHANNELS
452 wrq
->m
= (int)pMgmt
->uCurrChannel
;
456 int f
= (int)pMgmt
->uCurrChannel
- 1;
459 wrq
->m
= frequency_list
[f
] * 100000;
468 * Wireless Handler : set operation mode
471 int iwctl_siwmode(struct net_device
*dev
,
472 struct iw_request_info
*info
,
476 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
477 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
480 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWMODE \n");
482 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
&& pDevice
->bEnableHostapd
) {
483 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Can't set operation mode, hostapd is running \n");
490 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_IBSS_STA
) {
491 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
492 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
493 pDevice
->bCommit
= TRUE
;
496 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to ad-hoc \n");
500 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_ESS_STA
) {
501 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
502 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
503 pDevice
->bCommit
= TRUE
;
506 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to infrastructure \n");
510 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
514 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_AP
) {
515 pMgmt
->eConfigMode
= WMAC_CONFIG_AP
;
516 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
517 pDevice
->bCommit
= TRUE
;
520 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to Access Point \n");
524 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
535 * Wireless Handler : get operation mode
538 int iwctl_giwmode(struct net_device
*dev
,
539 struct iw_request_info
*info
,
543 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
544 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
547 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWMODE \n");
548 // If not managed, assume it's ad-hoc
549 switch (pMgmt
->eConfigMode
) {
550 case WMAC_CONFIG_ESS_STA
:
551 *wmode
= IW_MODE_INFRA
;
553 case WMAC_CONFIG_IBSS_STA
:
554 *wmode
= IW_MODE_ADHOC
;
556 case WMAC_CONFIG_AUTO
:
557 *wmode
= IW_MODE_INFRA
;
560 *wmode
= IW_MODE_MASTER
;
563 *wmode
= IW_MODE_ADHOC
;
571 * Wireless Handler : get capability range
574 int iwctl_giwrange(struct net_device
*dev
,
575 struct iw_request_info
*info
,
576 struct iw_point
*wrq
,
579 struct iw_range
*range
= (struct iw_range
*) extra
;
581 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
584 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRANGE \n");
586 wrq
->length
= sizeof(struct iw_range
);
587 memset(range
, 0, sizeof(struct iw_range
));
588 range
->min_nwid
= 0x0000;
589 range
->max_nwid
= 0x0000;
590 range
->num_channels
= 14;
591 // Should be based on cap_rid.country to give only
592 // what the current card support
594 for(i
= 0; i
< 14; i
++) {
595 range
->freq
[k
].i
= i
+ 1; // List index
596 range
->freq
[k
].m
= frequency_list
[i
] * 100000;
597 range
->freq
[k
++].e
= 1; // Values in table in MHz -> * 10^5 * 10
599 range
->num_frequency
= k
;
600 // Hum... Should put the right values there
601 #ifdef Calcu_LinkQual
602 range
->max_qual
.qual
= 100;
604 range
->max_qual
.qual
= 255;
606 range
->max_qual
.level
= 0;
607 range
->max_qual
.noise
= 0;
608 range
->sensitivity
= 255;
610 for(i
= 0 ; i
< 13 ; i
++) {
611 range
->bitrate
[i
] = abySupportedRates
[i
] * 500000;
612 if(range
->bitrate
[i
] == 0)
615 range
->num_bitrates
= i
;
617 // Set an indication of the max TCP throughput
618 // in bit/s that we can expect using this interface.
619 // May be use for QoS stuff... Jean II
621 range
->throughput
= 5 * 1000 * 1000;
623 range
->throughput
= 1.5 * 1000 * 1000;
626 range
->max_rts
= 2312;
627 range
->min_frag
= 256;
628 range
->max_frag
= 2312;
631 // the encoding capabilities
632 range
->num_encoding_sizes
= 3;
634 range
->encoding_size
[0] = 5;
636 range
->encoding_size
[1] = 13;
637 // 256 bits for WPA-PSK
638 range
->encoding_size
[2] = 32;
639 // 4 keys are allowed
640 range
->max_encoding_tokens
= 4;
642 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
643 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
646 range
->max_pmp
= 1000000;// 1 secs
648 range
->max_pmt
= 1000000;// 1 secs
649 range
->pmp_flags
= IW_POWER_PERIOD
;
650 range
->pmt_flags
= IW_POWER_TIMEOUT
;
651 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
653 // Transmit Power - values are in mW
655 range
->txpower
[0] = 100;
656 range
->num_txpower
= 1;
657 range
->txpower_capa
= IW_TXPOW_MWATT
;
658 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
659 range
->we_version_compiled
= WIRELESS_EXT
;
660 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
661 range
->retry_flags
= IW_RETRY_LIMIT
;
662 range
->r_time_flags
= IW_RETRY_LIFETIME
;
663 range
->min_retry
= 1;
664 range
->max_retry
= 65535;
665 range
->min_r_time
= 1024;
666 range
->max_r_time
= 65535 * 1024;
667 // Experimental measurements - boundary 11/5.5 Mb/s
668 // Note : with or without the (local->rssi), results
669 // are somewhat different. - Jean II
670 range
->avg_qual
.qual
= 6;
671 range
->avg_qual
.level
= 176; // -80 dBm
672 range
->avg_qual
.noise
= 0;
681 * Wireless Handler : set ap mac address
684 int iwctl_siwap(struct net_device
*dev
,
685 struct iw_request_info
*info
,
686 struct sockaddr
*wrq
,
689 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
690 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
692 BYTE ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
694 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAP \n");
695 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
697 printk("SIOCSIWAP(??)-->In scanning...\n");
700 if (wrq
->sa_family
!= ARPHRD_ETHER
)
703 memset(pMgmt
->abyDesireBSSID
, 0xFF, 6);
704 memcpy(pMgmt
->abyDesireBSSID
, wrq
->sa_data
, 6);
705 //2008-0409-05, <Add> by Einsn Liu
706 if((pDevice
->bLinkPass
== TRUE
) &&
707 (memcmp(pMgmt
->abyDesireBSSID
, pMgmt
->abyCurrBSSID
, 6)== 0)){
711 if ((IS_BROADCAST_ADDRESS(pMgmt
->abyDesireBSSID
)) ||
712 (memcmp(pMgmt
->abyDesireBSSID
, ZeroBSSID
, 6) == 0)){
713 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
716 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
717 // then ignore,because you don't known which one to be connect with??
719 UINT ii
, uSameBssidNum
=0;
720 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
721 if (pMgmt
->sBSSList
[ii
].bActive
&&
722 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
,pMgmt
->abyDesireBSSID
)) {
726 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
727 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
732 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
733 pDevice
->bCommit
= TRUE
;
740 * Wireless Handler : get ap mac address
743 int iwctl_giwap(struct net_device
*dev
,
744 struct iw_request_info
*info
,
745 struct sockaddr
*wrq
,
748 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
749 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
752 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAP \n");
754 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
755 //2008-0410,<Modify> by Einsn Liu
756 if ((pDevice
->bLinkPass
== FALSE
) && (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
))
757 memset(wrq
->sa_data
, 0, 6);
759 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
760 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
763 wrq
->sa_family
= ARPHRD_ETHER
;
771 * Wireless Handler : get ap list
774 int iwctl_giwaplist(struct net_device
*dev
,
775 struct iw_request_info
*info
,
776 struct iw_point
*wrq
,
780 struct sockaddr sock
[IW_MAX_AP
];
781 struct iw_quality qual
[IW_MAX_AP
];
782 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
783 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
786 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAPLIST \n");
787 // Only super-user can see AP list
789 if (!capable(CAP_NET_ADMIN
)) {
796 PKnownBSS pBSS
= &(pMgmt
->sBSSList
[0]);
798 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
799 pBSS
= &(pMgmt
->sBSSList
[ii
]);
802 if ( jj
>= IW_MAX_AP
)
804 memcpy(sock
[jj
].sa_data
, pBSS
->abyBSSID
, 6);
805 sock
[jj
].sa_family
= ARPHRD_ETHER
;
806 qual
[jj
].level
= pBSS
->uRSSI
;
807 qual
[jj
].qual
= qual
[jj
].noise
= 0;
808 qual
[jj
].updated
= 2;
812 wrq
->flags
= 1; // Should be define'd
814 memcpy(extra
, sock
, sizeof(struct sockaddr
)*jj
);
815 memcpy(extra
+ sizeof(struct sockaddr
)*jj
, qual
, sizeof(struct iw_quality
)*jj
);
823 * Wireless Handler : set essid
826 int iwctl_siwessid(struct net_device
*dev
,
827 struct iw_request_info
*info
,
828 struct iw_point
*wrq
,
831 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
832 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
833 PWLAN_IE_SSID pItemSSID
;
834 //2008-0409-05, <Add> by Einsn Liu
838 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWESSID \n");
839 pDevice
->fWPA_Authened
= FALSE
;
840 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
842 printk("SIOCSIWESSID(??)-->In scanning...\n");
845 // Check if we asked for `any'
846 if(wrq
->flags
== 0) {
847 // Just send an empty SSID list
848 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
849 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
850 PRINT_K("set essid to 'any' \n");
851 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
852 //Unknown desired AP,so here need not associate??
853 //if(pDevice->bWPASuppWextEnabled == TRUE) {
859 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
860 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
861 pItemSSID
->byElementID
= WLAN_EID_SSID
;
863 memcpy(pItemSSID
->abySSID
, extra
, wrq
->length
);
864 if (pItemSSID
->abySSID
[wrq
->length
- 1] == '\0') {
866 pItemSSID
->len
= wrq
->length
- 1;
869 pItemSSID
->len
= wrq
->length
;
870 printk("set essid to %s \n",pItemSSID
->abySSID
);
871 //2008-0409-05, <Add> by Einsn Liu
872 len
=(pItemSSID
->len
> ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)?pItemSSID
->len
:((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
;
873 if((pDevice
->bLinkPass
== TRUE
) &&
874 (memcmp(pItemSSID
->abySSID
,((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,len
)==0))
877 //mike:need clear desiredBSSID
878 if(pItemSSID
->len
==0) {
879 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
883 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
884 //Wext wil order another command of siwap to link with desired AP,
885 //so here need not associate??
886 if(pDevice
->bWPASuppWextEnabled
== TRUE
) {
887 /*******search if in hidden ssid mode ****/
889 PKnownBSS pCurr
= NULL
;
890 BYTE abyTmpDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
891 UINT ii
, uSameBssidNum
=0;
893 memset(abyTmpDesireSSID
,0,sizeof(abyTmpDesireSSID
));
894 memcpy(abyTmpDesireSSID
,pMgmt
->abyDesireSSID
,sizeof(abyTmpDesireSSID
));
895 pCurr
= BSSpSearchBSSList(pDevice
,
898 pMgmt
->eConfigPHYMode
902 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
903 vResetCommandTimer((HANDLE
) pDevice
);
904 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
905 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
906 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
908 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
909 // by means of judging if there are two same BSSID exist in list ?
910 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
911 if (pMgmt
->sBSSList
[ii
].bActive
&&
912 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
, pCurr
->abyBSSID
)) {
916 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
917 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
918 vResetCommandTimer((HANDLE
) pDevice
);
919 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
; //this scan type,you'll submit scan result!
920 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
921 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
929 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set essid = %s \n", pItemSSID
->abySSID
);
932 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
933 pDevice
->bCommit
= TRUE
;
942 * Wireless Handler : get essid
945 int iwctl_giwessid(struct net_device
*dev
,
946 struct iw_request_info
*info
,
947 struct iw_point
*wrq
,
951 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
952 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
953 PWLAN_IE_SSID pItemSSID
;
955 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWESSID \n");
957 // Note : if wrq->u.data.flags != 0, we should
958 // get the relevant SSID from the SSID list...
960 // Get the current SSID
961 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
962 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
963 memcpy(extra
, pItemSSID
->abySSID
, pItemSSID
->len
);
964 extra
[pItemSSID
->len
] = '\0';
965 wrq
->length
= pItemSSID
->len
+ 1;
966 //2008-0409-03, <Add> by Einsn Liu
967 wrq
->length
= pItemSSID
->len
;
968 wrq
->flags
= 1; // active
975 * Wireless Handler : set data rate
978 int iwctl_siwrate(struct net_device
*dev
,
979 struct iw_request_info
*info
,
980 struct iw_param
*wrq
,
983 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
987 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
990 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRATE \n");
991 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
996 // First : get a valid bit rate value
998 // Which type of value
999 if((wrq
->value
< 13) &&
1000 (wrq
->value
>= 0)) {
1001 // Setting by rate index
1002 // Find value in the magic rate table
1005 // Setting by frequency value
1006 u8 normvalue
= (u8
) (wrq
->value
/500000);
1008 // Check if rate is valid
1009 for(i
= 0 ; i
< 13 ; i
++) {
1010 if(normvalue
== abySupportedRates
[i
]) {
1016 // -1 designed the max rate (mostly auto mode)
1017 if(wrq
->value
== -1) {
1018 // Get the highest available rate
1019 for(i
= 0 ; i
< 13 ; i
++) {
1020 if(abySupportedRates
[i
] == 0)
1027 // Check that it is valid
1028 // brate is index of abySupportedRates[]
1034 // Now, check if we want a fixed or auto value
1035 if(wrq
->fixed
!= 0) {
1038 printk("Rate Fix\n");
1039 pDevice
->bFixRate
= TRUE
;
1040 if ((pDevice
->byBBType
== BB_TYPE_11B
)&& (brate
> 3)) {
1041 pDevice
->uConnectionRate
= 3;
1044 pDevice
->uConnectionRate
= brate
;
1045 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fixed to Rate %d \n", pDevice
->uConnectionRate
);
1050 pDevice
->bFixRate
= FALSE
;
1051 pDevice
->uConnectionRate
= 13;
1052 printk("auto rate:connection_rate is 13\n");
1059 * Wireless Handler : get data rate
1062 int iwctl_giwrate(struct net_device
*dev
,
1063 struct iw_request_info
*info
,
1064 struct iw_param
*wrq
,
1067 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1068 //2007-0118-05,<Mark> by EinsnLiu
1069 //Mark the unnecessary sentences.
1070 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1072 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRATE \n");
1074 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1076 //2008-5-8 <modify> by chester
1077 if(pDevice
->bLinkPass
){
1078 if(pDevice
->bFixRate
== TRUE
){
1079 if (pDevice
->uConnectionRate
< 13) {
1080 brate
= abySupportedRates
[pDevice
->uConnectionRate
];
1082 if (pDevice
->byBBType
== BB_TYPE_11B
)
1084 if (pDevice
->byBBType
== BB_TYPE_11G
)
1086 if (pDevice
->byBBType
== BB_TYPE_11A
)
1093 brate
= abySupportedRates
[TxRate_iwconfig
];
1097 //2007-0118-05,<Mark> by EinsnLiu
1098 //Mark the unnecessary sentences.
1100 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1101 if (pDevice->byBBType == BB_TYPE_11B)
1103 if (pDevice->byBBType == BB_TYPE_11G)
1105 if (pDevice->byBBType == BB_TYPE_11A)
1110 // if (pDevice->uConnectionRate == 13)
1111 // brate = abySupportedRates[pDevice->wCurrentRate];
1112 wrq
->value
= brate
* 500000;
1113 // If more than one rate, set auto
1114 if (pDevice
->bFixRate
== TRUE
)
1125 * Wireless Handler : set rts threshold
1128 int iwctl_siwrts(struct net_device
*dev
,
1129 struct iw_request_info
*info
,
1130 struct iw_param
*wrq
,
1133 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1136 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRTS \n");
1139 int rthr
= wrq
->value
;
1142 if((rthr
< 0) || (rthr
> 2312)) {
1145 pDevice
->wRTSThreshold
= rthr
;
1153 * Wireless Handler : get rts
1156 int iwctl_giwrts(struct net_device
*dev
,
1157 struct iw_request_info
*info
,
1158 struct iw_param
*wrq
,
1161 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1163 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRTS \n");
1164 wrq
->value
= pDevice
->wRTSThreshold
;
1165 wrq
->disabled
= (wrq
->value
>= 2312);
1172 * Wireless Handler : set fragment threshold
1175 int iwctl_siwfrag(struct net_device
*dev
,
1176 struct iw_request_info
*info
,
1177 struct iw_param
*wrq
,
1180 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1182 int fthr
= wrq
->value
;
1185 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFRAG \n");
1190 if((fthr
< 256) || (fthr
> 2312)) {
1193 fthr
&= ~0x1; // Get an even value
1194 pDevice
->wFragmentationThreshold
= (u16
)fthr
;
1201 * Wireless Handler : get fragment threshold
1204 int iwctl_giwfrag(struct net_device
*dev
,
1205 struct iw_request_info
*info
,
1206 struct iw_param
*wrq
,
1209 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1211 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFRAG \n");
1212 wrq
->value
= pDevice
->wFragmentationThreshold
;
1213 wrq
->disabled
= (wrq
->value
>= 2312);
1222 * Wireless Handler : set retry threshold
1224 int iwctl_siwretry(struct net_device
*dev
,
1225 struct iw_request_info
*info
,
1226 struct iw_param
*wrq
,
1229 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1233 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRETRY \n");
1235 if (wrq
->disabled
) {
1240 if (wrq
->flags
& IW_RETRY_LIMIT
) {
1241 if(wrq
->flags
& IW_RETRY_MAX
)
1242 pDevice
->byLongRetryLimit
= wrq
->value
;
1243 else if (wrq
->flags
& IW_RETRY_MIN
)
1244 pDevice
->byShortRetryLimit
= wrq
->value
;
1246 // No modifier : set both
1247 pDevice
->byShortRetryLimit
= wrq
->value
;
1248 pDevice
->byLongRetryLimit
= wrq
->value
;
1251 if (wrq
->flags
& IW_RETRY_LIFETIME
) {
1252 pDevice
->wMaxTransmitMSDULifetime
= wrq
->value
;
1260 * Wireless Handler : get retry threshold
1262 int iwctl_giwretry(struct net_device
*dev
,
1263 struct iw_request_info
*info
,
1264 struct iw_param
*wrq
,
1267 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1268 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRETRY \n");
1269 wrq
->disabled
= 0; // Can't be disabled
1271 // Note : by default, display the min retry number
1272 if((wrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1273 wrq
->flags
= IW_RETRY_LIFETIME
;
1274 wrq
->value
= (int)pDevice
->wMaxTransmitMSDULifetime
; //ms
1275 } else if((wrq
->flags
& IW_RETRY_MAX
)) {
1276 wrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
1277 wrq
->value
= (int)pDevice
->byLongRetryLimit
;
1279 wrq
->flags
= IW_RETRY_LIMIT
;
1280 wrq
->value
= (int)pDevice
->byShortRetryLimit
;
1281 if((int)pDevice
->byShortRetryLimit
!= (int)pDevice
->byLongRetryLimit
)
1282 wrq
->flags
|= IW_RETRY_MIN
;
1291 * Wireless Handler : set encode mode
1293 int iwctl_siwencode(struct net_device
*dev
,
1294 struct iw_request_info
*info
,
1295 struct iw_point
*wrq
,
1298 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1299 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1300 DWORD dwKeyIndex
= (DWORD
)(wrq
->flags
& IW_ENCODE_INDEX
);
1302 int index
= (wrq
->flags
& IW_ENCODE_INDEX
);
1304 //2007-0207-07,<Modify> by EinsnLiu
1305 //There are some problems when using iwconfig encode/key command to set the WEP key.
1306 //I almost rewrite this function.
1307 //now it support:(assume the wireless interface's name is eth0)
1308 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1309 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1310 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1311 //iwconfig eth0 key restricted /*enable share key*/
1315 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWENCODE \n");
1317 if((wrq
->flags
& IW_ENCODE_DISABLED
)==0){
1318 //Not disable encryption
1320 if (dwKeyIndex
> WLAN_WEP_NKEYS
) {
1325 if(dwKeyIndex
<1&&((wrq
->flags
&IW_ENCODE_NOKEY
)==0)){//set default key
1326 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1327 dwKeyIndex
=pDevice
->byKeyIndex
;
1333 // Check the size of the key
1334 if (wrq
->length
> WLAN_WEP232_KEYLEN
) {
1339 if(wrq
->length
>0){//have key
1341 if (wrq
->length
== WLAN_WEP232_KEYLEN
) {
1342 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 232 bit wep key\n");
1344 else if (wrq
->length
== WLAN_WEP104_KEYLEN
) {
1345 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 104 bit wep key\n");
1347 else if (wrq
->length
== WLAN_WEP40_KEYLEN
) {
1348 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 40 bit wep key, index= %d\n", (int)dwKeyIndex
);
1349 }else {//no support length
1353 memset(pDevice
->abyKey
, 0, WLAN_WEP232_KEYLEN
);
1354 memcpy(pDevice
->abyKey
, extra
, wrq
->length
);
1356 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyKey: ");
1357 for (ii
= 0; ii
< wrq
->length
; ii
++) {
1358 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02x ", pDevice
->abyKey
[ii
]);
1361 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1362 spin_lock_irq(&pDevice
->lock
);
1363 KeybSetDefaultKey(&(pDevice
->sKey
),
1364 (DWORD
)(dwKeyIndex
| (1 << 31)),
1369 pDevice
->PortOffset
,
1372 spin_unlock_irq(&pDevice
->lock
);
1374 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
1375 pDevice
->uKeyLength
= wrq
->length
;
1376 pDevice
->bTransmitKey
= TRUE
;
1377 pDevice
->bEncryptionEnable
= TRUE
;
1378 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1381 //when the length is 0 the request only changes the default transmit key index
1382 //check the new key has a non zero lenget
1383 if(pDevice
->bEncryptionEnable
==FALSE
)
1388 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Just set Default key Index:\n");
1389 pkeytab
=&(pDevice
->sKey
.KeyTable
[MAX_KEY_TABLE
-1]);
1390 if(pkeytab
->GroupKey
[(BYTE
)dwKeyIndex
].uKeyLength
==0){
1391 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Default key len is 0\n");
1395 pDevice
->byKeyIndex
=(BYTE
)dwKeyIndex
;
1396 pkeytab
->dwGTKeyIndex
=dwKeyIndex
| (1 << 31);
1397 pkeytab
->GroupKey
[(BYTE
)dwKeyIndex
].dwKeyIndex
=dwKeyIndex
| (1 << 31);
1400 }else {//disable the key
1401 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disable WEP function\n");
1402 if(pDevice
->bEncryptionEnable
==FALSE
)
1404 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1405 pDevice
->bEncryptionEnable
= FALSE
;
1406 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1407 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1408 spin_lock_irq(&pDevice
->lock
);
1409 for(uu
=0;uu
<MAX_KEY_TABLE
;uu
++)
1410 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
1411 spin_unlock_irq(&pDevice
->lock
);
1417 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1419 // Check the size of the key
1420 if (wrq->length > WLAN_WEP232_KEYLEN) {
1425 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1433 // Send the key to the card
1434 if (wrq->length > 0) {
1436 if (wrq->length == WLAN_WEP232_KEYLEN) {
1437 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1439 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1440 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1442 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1443 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1445 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1446 memcpy(pDevice->abyKey, extra, wrq->length);
1448 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1449 for (ii = 0; ii < wrq->length; ii++) {
1450 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1453 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1454 spin_lock_irq(&pDevice->lock);
1455 KeybSetDefaultKey(&(pDevice->sKey),
1456 (DWORD)(pDevice->byKeyIndex | (1 << 31)),
1457 pDevice->uKeyLength,
1461 pDevice->PortOffset,
1464 spin_unlock_irq(&pDevice->lock);
1466 pDevice->byKeyIndex = (BYTE)dwKeyIndex;
1467 pDevice->uKeyLength = wrq->length;
1468 pDevice->bTransmitKey = TRUE;
1469 pDevice->bEncryptionEnable = TRUE;
1470 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1472 // Do we want to just set the transmit key index ?
1474 pDevice->byKeyIndex = index;
1476 else if(!wrq->flags & IW_ENCODE_MODE) {
1482 if(wrq->flags & IW_ENCODE_DISABLED){
1484 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1485 pMgmt->bShareKeyAlgorithm = FALSE;
1486 pDevice->bEncryptionEnable = FALSE;
1487 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1488 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1489 spin_lock_irq(&pDevice->lock);
1490 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1491 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1492 spin_unlock_irq(&pDevice->lock);
1497 if(wrq
->flags
& IW_ENCODE_RESTRICTED
) {
1498 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & ShareKey System\n");
1499 pMgmt
->bShareKeyAlgorithm
= TRUE
;
1501 if(wrq
->flags
& IW_ENCODE_OPEN
) {
1502 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & Open System\n");
1503 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1509 * Wireless Handler : get encode mode
1512 int iwctl_giwencode(struct net_device *dev,
1513 struct iw_request_info *info,
1514 struct iw_point *wrq,
1517 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1518 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1520 char abyKey[WLAN_WEP232_KEYLEN];
1521 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1522 PSKeyItem pKey = NULL;
1524 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1525 //2007-0207-06,<Add> by EinsnLiu
1526 //the key index in iwconfig is 1-4 when our driver is 0-3
1527 //so it can't be used directly.
1528 //if the index is 0,we should used the index set by driver.
1529 if (index > WLAN_WEP_NKEYS) {
1533 if(index<1){//set default key
1534 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1535 index=pDevice->byKeyIndex;
1541 memset(abyKey, 0, sizeof(abyKey));
1542 // Check encryption mode
1543 wrq->flags = IW_ENCODE_NOKEY;
1544 // Is WEP enabled ???
1545 if (pDevice->bEncryptionEnable)
1546 wrq->flags |= IW_ENCODE_ENABLED;
1548 wrq->flags |= IW_ENCODE_DISABLED;
1550 if (pMgmt->bShareKeyAlgorithm)
1551 wrq->flags |= IW_ENCODE_RESTRICTED;
1553 wrq->flags |= IW_ENCODE_OPEN;
1555 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1556 wrq->length = pKey->uKeyLength;
1557 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1558 //2007-0207-06,<Modify> by EinsnLiu
1559 //only get key success need to copy data
1561 //there is not necessary to return -EINVAL when get key failed
1562 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1563 wrq->flags |= index+1;
1564 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1579 //2008-0409-06, <Add> by Einsn Liu
1581 int iwctl_giwencode(struct net_device
*dev
,
1582 struct iw_request_info
*info
,
1583 struct iw_point
*wrq
,
1586 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1587 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1588 char abyKey
[WLAN_WEP232_KEYLEN
];
1590 UINT index
= (UINT
)(wrq
->flags
& IW_ENCODE_INDEX
);
1591 PSKeyItem pKey
= NULL
;
1593 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWENCODE\n");
1595 if (index
> WLAN_WEP_NKEYS
) {
1598 if(index
<1){//get default key
1599 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1600 index
=pDevice
->byKeyIndex
;
1606 memset(abyKey
, 0, WLAN_WEP232_KEYLEN
);
1607 // Check encryption mode
1608 wrq
->flags
= IW_ENCODE_NOKEY
;
1609 // Is WEP enabled ???
1610 if (pDevice
->bEncryptionEnable
)
1611 wrq
->flags
|= IW_ENCODE_ENABLED
;
1613 wrq
->flags
|= IW_ENCODE_DISABLED
;
1615 if (pMgmt
->bShareKeyAlgorithm
)
1616 wrq
->flags
|= IW_ENCODE_RESTRICTED
;
1618 wrq
->flags
|= IW_ENCODE_OPEN
;
1621 if((index
==0)&&(pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
||
1622 pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)){//get wpa pairwise key
1623 if (KeybGetKey(&(pDevice
->sKey
),pMgmt
->abyCurrBSSID
, 0xffffffff, &pKey
)){
1624 wrq
->length
= pKey
->uKeyLength
;
1625 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1626 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1628 }else if (KeybGetKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, (BYTE
)index
, &pKey
)){
1629 wrq
->length
= pKey
->uKeyLength
;
1630 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1631 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1634 wrq
->flags
|= index
+1;
1641 * Wireless Handler : set power mode
1643 int iwctl_siwpower(struct net_device
*dev
,
1644 struct iw_request_info
*info
,
1645 struct iw_param
*wrq
,
1648 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1649 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1652 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER \n");
1654 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1659 if (wrq
->disabled
) {
1660 pDevice
->ePSMode
= WMAC_POWER_CAM
;
1661 PSvDisablePowerSaving(pDevice
);
1664 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1665 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1666 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1668 } else if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
1669 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1670 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1672 switch (wrq
->flags
& IW_POWER_MODE
) {
1673 case IW_POWER_UNICAST_R
:
1674 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1677 case IW_POWER_ALL_R
:
1678 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ALL_R \n");
1681 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ON \n");
1691 * Wireless Handler : get power mode
1693 int iwctl_giwpower(struct net_device
*dev
,
1694 struct iw_request_info
*info
,
1695 struct iw_param
*wrq
,
1698 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1699 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1700 int mode
= pDevice
->ePSMode
;
1703 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWPOWER \n");
1706 if ((wrq
->disabled
= (mode
== WMAC_POWER_CAM
)))
1709 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1710 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1711 wrq
->flags
= IW_POWER_TIMEOUT
;
1713 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1714 wrq
->flags
= IW_POWER_PERIOD
;
1716 wrq
->flags
|= IW_POWER_ALL_R
;
1723 * Wireless Handler : get Sensitivity
1725 int iwctl_giwsens(struct net_device
*dev
,
1726 struct iw_request_info
*info
,
1727 struct iw_param
*wrq
,
1730 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1733 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSENS \n");
1734 if (pDevice
->bLinkPass
== TRUE
) {
1735 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
1741 wrq
->disabled
= (wrq
->value
== 0);
1748 //2008-0409-07, <Add> by Einsn Liu
1749 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1751 int iwctl_siwauth(struct net_device
*dev
,
1752 struct iw_request_info
*info
,
1753 struct iw_param
*wrq
,
1756 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1757 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1759 static int wpa_version
=0; //must be static to save the last value,einsn liu
1760 static int pairwise
=0;
1762 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAUTH \n");
1763 switch (wrq
->flags
& IW_AUTH_INDEX
) {
1764 case IW_AUTH_WPA_VERSION
:
1765 wpa_version
= wrq
->value
;
1766 if(wrq
->value
== IW_AUTH_WPA_VERSION_DISABLED
) {
1767 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1768 //pDevice->bWPADevEnable = FALSE;
1770 else if(wrq
->value
== IW_AUTH_WPA_VERSION_WPA
) {
1771 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1774 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1776 //pDevice->bWPASuppWextEnabled =TRUE;
1778 case IW_AUTH_CIPHER_PAIRWISE
:
1779 pairwise
= wrq
->value
;
1780 if(pairwise
== IW_AUTH_CIPHER_CCMP
){
1781 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1782 }else if(pairwise
== IW_AUTH_CIPHER_TKIP
){
1783 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1784 }else if(pairwise
== IW_AUTH_CIPHER_WEP40
||pairwise
== IW_AUTH_CIPHER_WEP104
){
1785 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1786 }else if(pairwise
== IW_AUTH_CIPHER_NONE
){
1787 //do nothing,einsn liu
1788 }else pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1791 case IW_AUTH_CIPHER_GROUP
:
1792 if(wpa_version
== IW_AUTH_WPA_VERSION_DISABLED
)
1794 if(pairwise
== IW_AUTH_CIPHER_NONE
){
1795 if(wrq
->value
== IW_AUTH_CIPHER_CCMP
){
1796 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1798 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1802 case IW_AUTH_KEY_MGMT
:
1804 if(wpa_version
== IW_AUTH_WPA_VERSION_WPA2
){
1805 if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1806 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
1807 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
1808 }else if(wpa_version
== IW_AUTH_WPA_VERSION_WPA
){
1809 if(wrq
->value
== 0){
1810 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
1811 }else if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1812 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
1813 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
1817 case IW_AUTH_TKIP_COUNTERMEASURES
:
1819 case IW_AUTH_DROP_UNENCRYPTED
:
1821 case IW_AUTH_80211_AUTH_ALG
:
1822 if(wrq
->value
==IW_AUTH_ALG_OPEN_SYSTEM
){
1823 pMgmt
->bShareKeyAlgorithm
=FALSE
;
1824 }else if(wrq
->value
==IW_AUTH_ALG_SHARED_KEY
){
1825 pMgmt
->bShareKeyAlgorithm
=TRUE
;
1828 case IW_AUTH_WPA_ENABLED
:
1829 //pDevice->bWPADevEnable = !! wrq->value;
1831 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1833 case IW_AUTH_ROAMING_CONTROL
:
1836 case IW_AUTH_PRIVACY_INVOKED
:
1837 pDevice
->bEncryptionEnable
= !!wrq
->value
;
1838 if(pDevice
->bEncryptionEnable
== FALSE
){
1841 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1842 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1843 pMgmt
->eAuthenMode
= FALSE
;
1844 //pDevice->bWPADevEnable = FALSE;
1853 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1854 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1855 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1856 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1857 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1858 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1859 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");
1865 int iwctl_giwauth(struct net_device
*dev
,
1866 struct iw_request_info
*info
,
1867 struct iw_param
*wrq
,
1875 int iwctl_siwgenie(struct net_device
*dev
,
1876 struct iw_request_info
*info
,
1877 struct iw_point
*wrq
,
1880 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1881 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1885 if ((wrq
->length
< 2) || (extra
[1]+2 != wrq
->length
)) {
1889 if(wrq
->length
> MAX_WPA_IE_LEN
){
1893 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1894 if(copy_from_user(pMgmt
->abyWPAIE
, extra
, wrq
->length
)){
1898 pMgmt
->wWPAIELen
= wrq
->length
;
1900 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1901 pMgmt
->wWPAIELen
= 0;
1904 out
://not completely ...not necessary in wpa_supplicant 0.5.8
1908 int iwctl_giwgenie(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
);
1916 int space
= wrq
->length
;
1919 if(pMgmt
->wWPAIELen
> 0){
1920 wrq
->length
= pMgmt
->wWPAIELen
;
1921 if(pMgmt
->wWPAIELen
<= space
){
1922 if(copy_to_user(extra
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
)){
1933 int iwctl_siwencodeext(struct net_device
*dev
,
1934 struct iw_request_info
*info
,
1935 struct iw_point
*wrq
,
1938 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1939 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1940 struct viawget_wpa_param
*param
=NULL
;
1944 int key_idx
, set_tx
=0;
1945 u8 seq
[IW_ENCODE_SEQ_MAX_SIZE
];
1947 size_t seq_len
=0,key_len
=0;
1955 PRINT_K("SIOCSIWENCODEEXT...... \n");
1957 blen
= sizeof(*param
);
1958 buf
= kmalloc((int)blen
, (int)GFP_KERNEL
);
1961 memset(buf
, 0, blen
);
1962 param
= (struct viawget_wpa_param
*) buf
;
1966 case IW_ENCODE_ALG_NONE
:
1967 alg_name
= WPA_ALG_NONE
;
1969 case IW_ENCODE_ALG_WEP
:
1970 alg_name
= WPA_ALG_WEP
;
1972 case IW_ENCODE_ALG_TKIP
:
1973 alg_name
= WPA_ALG_TKIP
;
1975 case IW_ENCODE_ALG_CCMP
:
1976 alg_name
= WPA_ALG_CCMP
;
1979 PRINT_K("Unknown alg = %d\n",ext
->alg
);
1984 memcpy(addr
, ext
->addr
.sa_data
, ETH_ALEN
);
1986 key_idx
= (wrq
->flags
&IW_ENCODE_INDEX
) - 1;
1988 if(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1990 //recover seq,seq_len
1991 if(ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
1992 seq_len
=IW_ENCODE_SEQ_MAX_SIZE
;
1993 memcpy(seq
, ext
->rx_seq
, seq_len
);
1995 //recover key,key_len
1997 key_len
=ext
->key_len
;
1998 memcpy(key
, &ext
->key
[0], key_len
);
2001 memset(key_array
, 0, 64);
2003 memcpy(key_array
, key
, key_len
);
2004 if (key_len
== 32) {
2005 // notice ! the oder
2006 memcpy(&key_array
[16], &key
[24], 8);
2007 memcpy(&key_array
[24], &key
[16], 8);
2011 /**************Translate iw_encode_ext to viawget_wpa_param****************/
2012 memcpy(param
->addr
, addr
, ETH_ALEN
);
2013 param
->u
.wpa_key
.alg_name
= (int)alg_name
;
2014 param
->u
.wpa_key
.set_tx
= set_tx
;
2015 param
->u
.wpa_key
.key_index
= key_idx
;
2016 param
->u
.wpa_key
.key_len
= key_len
;
2017 param
->u
.wpa_key
.key
= (u8
*)key_array
;
2018 param
->u
.wpa_key
.seq
= (u8
*)seq
;
2019 param
->u
.wpa_key
.seq_len
= seq_len
;
2022 printk("param->u.wpa_key.alg_name =%d\n",param
->u
.wpa_key
.alg_name
);
2023 printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
2024 param
->addr
[0],param
->addr
[1],param
->addr
[2],
2025 param
->addr
[3],param
->addr
[4],param
->addr
[5]);
2026 printk("param->u.wpa_key.set_tx =%d\n",param
->u
.wpa_key
.set_tx
);
2027 printk("param->u.wpa_key.key_index =%d\n",param
->u
.wpa_key
.key_index
);
2028 printk("param->u.wpa_key.key_len =%d\n",param
->u
.wpa_key
.key_len
);
2029 printk("param->u.wpa_key.key =");
2030 for(ii
=0;ii
<param
->u
.wpa_key
.key_len
;ii
++)
2031 printk("%02x:",param
->u
.wpa_key
.key
[ii
]);
2033 printk("param->u.wpa_key.seq_len =%d\n",param
->u
.wpa_key
.seq_len
);
2034 printk("param->u.wpa_key.seq =");
2035 for(ii
=0;ii
<param
->u
.wpa_key
.seq_len
;ii
++)
2036 printk("%02x:",param
->u
.wpa_key
.seq
[ii
]);
2039 printk("...........\n");
2041 //****set if current action is Network Manager count??
2042 //****this method is so foolish,but there is no other way???
2043 if(param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
2044 if(param
->u
.wpa_key
.key_index
==0) {
2045 pDevice
->bwextcount
++;
2047 if((pDevice
->bwextcount
== 1)&&(param
->u
.wpa_key
.key_index
==1)) {
2048 pDevice
->bwextcount
++;
2050 if((pDevice
->bwextcount
==2)&&(param
->u
.wpa_key
.key_index
==2)) {
2051 pDevice
->bwextcount
++;
2053 if((pDevice
->bwextcount
==3)&&(param
->u
.wpa_key
.key_index
==3)) {
2054 pDevice
->bwextcount
++;
2057 if( pDevice
->bwextcount
== 4) {
2058 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2059 pDevice
->bwextcount
=0;
2060 pDevice
->bWPASuppWextEnabled
= TRUE
;
2064 spin_lock_irq(&pDevice
->lock
);
2065 ret
= wpa_set_keys(pDevice
, param
, TRUE
);
2066 spin_unlock_irq(&pDevice
->lock
);
2075 int iwctl_giwencodeext(struct net_device
*dev
,
2076 struct iw_request_info
*info
,
2077 struct iw_point
*wrq
,
2080 return -EOPNOTSUPP
;;
2083 int iwctl_siwmlme(struct net_device
*dev
,
2084 struct iw_request_info
* info
,
2085 struct iw_point
*wrq
,
2088 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
2089 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2090 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2091 //u16 reason = cpu_to_le16(mlme->reason_code);
2094 if(memcmp(pMgmt
->abyCurrBSSID
, mlme
->addr
.sa_data
, ETH_ALEN
)){
2099 case IW_MLME_DEAUTH
:
2100 //this command seems to be not complete,please test it --einsnliu
2101 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2103 case IW_MLME_DISASSOC
:
2104 if(pDevice
->bLinkPass
== TRUE
){
2105 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2106 //clear related flags
2107 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
2108 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
2109 bScheduleCommand((HANDLE
)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
2123 /*------------------------------------------------------------------*/
2125 * Structures to export the Wireless Handlers
2130 static const iw_handler iwctl_handler[] =
2132 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2133 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2134 (iw_handler) NULL, // SIOCSIWNWID
2135 (iw_handler) NULL, // SIOCGIWNWID
2136 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2137 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2138 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2139 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2140 (iw_handler) NULL, // SIOCSIWSENS
2141 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2142 (iw_handler) NULL, // SIOCSIWRANGE
2143 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2144 (iw_handler) NULL, // SIOCSIWPRIV
2145 (iw_handler) NULL, // SIOCGIWPRIV
2146 (iw_handler) NULL, // SIOCSIWSTATS
2147 (iw_handler) NULL, // SIOCGIWSTATS
2148 (iw_handler) NULL, // SIOCSIWSPY
2149 (iw_handler) NULL, // SIOCGIWSPY
2150 (iw_handler) NULL, // -- hole --
2151 (iw_handler) NULL, // -- hole --
2152 (iw_handler) iwctl_siwap, // SIOCSIWAP
2153 (iw_handler) iwctl_giwap, // SIOCGIWAP
2154 (iw_handler) NULL, // -- hole -- 0x16
2155 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2156 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2157 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2158 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2159 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2160 (iw_handler) NULL, // SIOCSIWNICKN
2161 (iw_handler) NULL, // SIOCGIWNICKN
2162 (iw_handler) NULL, // -- hole --
2163 (iw_handler) NULL, // -- hole --
2164 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2165 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2166 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2167 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2168 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2169 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2170 (iw_handler) NULL, // SIOCSIWTXPOW
2171 (iw_handler) NULL, // SIOCGIWTXPOW
2172 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2173 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2174 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2175 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2176 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2177 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2178 (iw_handler) NULL, // -- hole --
2179 (iw_handler) NULL, // -- hole --
2180 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2181 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2182 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2183 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2184 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2185 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2186 (iw_handler) NULL, // SIOCSIWPMKSA
2187 (iw_handler) NULL, // -- hole --
2192 static const iw_handler iwctl_handler
[] =
2194 (iw_handler
) iwctl_commit
, // SIOCSIWCOMMIT
2195 (iw_handler
) NULL
, // SIOCGIWNAME
2196 (iw_handler
) NULL
, // SIOCSIWNWID
2197 (iw_handler
) NULL
, // SIOCGIWNWID
2198 (iw_handler
) NULL
, // SIOCSIWFREQ
2199 (iw_handler
) NULL
, // SIOCGIWFREQ
2200 (iw_handler
) NULL
, // SIOCSIWMODE
2201 (iw_handler
) NULL
, // SIOCGIWMODE
2202 (iw_handler
) NULL
, // SIOCSIWSENS
2203 (iw_handler
) NULL
, // SIOCGIWSENS
2204 (iw_handler
) NULL
, // SIOCSIWRANGE
2205 (iw_handler
) iwctl_giwrange
, // SIOCGIWRANGE
2206 (iw_handler
) NULL
, // SIOCSIWPRIV
2207 (iw_handler
) NULL
, // SIOCGIWPRIV
2208 (iw_handler
) NULL
, // SIOCSIWSTATS
2209 (iw_handler
) NULL
, // SIOCGIWSTATS
2210 (iw_handler
) NULL
, // SIOCSIWSPY
2211 (iw_handler
) NULL
, // SIOCGIWSPY
2212 (iw_handler
) NULL
, // -- hole --
2213 (iw_handler
) NULL
, // -- hole --
2214 (iw_handler
) NULL
, // SIOCSIWAP
2215 (iw_handler
) NULL
, // SIOCGIWAP
2216 (iw_handler
) NULL
, // -- hole -- 0x16
2217 (iw_handler
) NULL
, // SIOCGIWAPLIST
2218 (iw_handler
) iwctl_siwscan
, // SIOCSIWSCAN
2219 (iw_handler
) iwctl_giwscan
, // SIOCGIWSCAN
2220 (iw_handler
) NULL
, // SIOCSIWESSID
2221 (iw_handler
) NULL
, // SIOCGIWESSID
2222 (iw_handler
) NULL
, // SIOCSIWNICKN
2223 (iw_handler
) NULL
, // SIOCGIWNICKN
2224 (iw_handler
) NULL
, // -- hole --
2225 (iw_handler
) NULL
, // -- hole --
2226 (iw_handler
) NULL
, // SIOCSIWRATE 0x20
2227 (iw_handler
) NULL
, // SIOCGIWRATE
2228 (iw_handler
) NULL
, // SIOCSIWRTS
2229 (iw_handler
) NULL
, // SIOCGIWRTS
2230 (iw_handler
) NULL
, // SIOCSIWFRAG
2231 (iw_handler
) NULL
, // SIOCGIWFRAG
2232 (iw_handler
) NULL
, // SIOCSIWTXPOW
2233 (iw_handler
) NULL
, // SIOCGIWTXPOW
2234 (iw_handler
) NULL
, // SIOCSIWRETRY
2235 (iw_handler
) NULL
, // SIOCGIWRETRY
2236 (iw_handler
) NULL
, // SIOCSIWENCODE
2237 (iw_handler
) NULL
, // SIOCGIWENCODE
2238 (iw_handler
) NULL
, // SIOCSIWPOWER
2239 (iw_handler
) NULL
, // SIOCGIWPOWER
2241 //2008-0409-07, <Add> by Einsn Liu
2242 (iw_handler
) NULL
, // -- hole --
2243 (iw_handler
) NULL
, // -- hole --
2244 (iw_handler
) NULL
, // SIOCSIWGENIE
2245 (iw_handler
) NULL
, // SIOCGIWGENIE
2246 (iw_handler
) NULL
, // SIOCSIWAUTH
2247 (iw_handler
) NULL
, // SIOCGIWAUTH
2248 (iw_handler
) NULL
, // SIOCSIWENCODEEXT
2249 (iw_handler
) NULL
, // SIOCGIWENCODEEXT
2250 (iw_handler
) NULL
, // SIOCSIWPMKSA
2251 (iw_handler
) NULL
, // -- hole --
2255 static const iw_handler iwctl_private_handler
[] =
2257 NULL
, // SIOCIWFIRSTPRIV
2261 struct iw_priv_args iwctl_private_args
[] = {
2263 IW_PRIV_TYPE_CHAR
| 1024, 0,
2269 const struct iw_handler_def iwctl_handler_def
=
2271 .get_wireless_stats
= &iwctl_get_wireless_stats
,
2272 .num_standard
= sizeof(iwctl_handler
)/sizeof(iw_handler
),
2273 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2274 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2276 .num_private_args
= 0,
2277 .standard
= (iw_handler
*) iwctl_handler
,
2278 // .private = (iw_handler *) iwctl_private_handler,
2279 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2281 .private_args
= NULL
,