2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: wireless ext & ioctl functions
42 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
47 #include <net/iw_handler.h>
48 extern unsigned short TxRate_iwconfig
;//2008-5-8 <add> by chester
50 /*--------------------- Static Definitions -------------------------*/
52 //2008-0409-07, <Add> by Einsn Liu
53 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
54 #define SUPPORTED_WIRELESS_EXT 18
56 #define SUPPORTED_WIRELESS_EXT 17
59 static const long frequency_list
[] = {
60 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
61 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
62 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
63 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
64 5700, 5745, 5765, 5785, 5805, 5825
68 /*--------------------- Static Classes ----------------------------*/
71 //static int msglevel =MSG_LEVEL_DEBUG;
72 static int msglevel
=MSG_LEVEL_INFO
;
75 /*--------------------- Static Variables --------------------------*/
76 /*--------------------- Static Functions --------------------------*/
78 /*--------------------- Export Variables --------------------------*/
80 struct iw_statistics
*iwctl_get_wireless_stats(struct net_device
*dev
)
82 PSDevice pDevice
= netdev_priv(dev
);
85 pDevice
->wstats
.status
= pDevice
->eOPMode
;
88 if(pDevice
->byBBType
== BB_TYPE_11B
) {
89 if(pDevice
->byCurrSQ
> 120)
90 pDevice
->scStatistic
.LinkQuality
= 100;
92 pDevice
->scStatistic
.LinkQuality
= pDevice
->byCurrSQ
*100/120;
94 else if(pDevice
->byBBType
== BB_TYPE_11G
) {
95 if(pDevice
->byCurrSQ
< 20)
96 pDevice
->scStatistic
.LinkQuality
= 100;
97 else if(pDevice
->byCurrSQ
>96)
98 pDevice
->scStatistic
.LinkQuality
= 0;
100 pDevice
->scStatistic
.LinkQuality
= (96-pDevice
->byCurrSQ
)*100/76;
102 if(pDevice
->bLinkPass
!=true)
103 pDevice
->scStatistic
.LinkQuality
= 0;
105 if(pDevice
->scStatistic
.LinkQuality
> 100)
106 pDevice
->scStatistic
.LinkQuality
= 100;
107 pDevice
->wstats
.qual
.qual
=(unsigned char) pDevice
->scStatistic
.LinkQuality
;
109 pDevice
->wstats
.qual
.qual
= pDevice
->byCurrSQ
;
111 RFvRSSITodBm(pDevice
, (unsigned char)(pDevice
->uCurrRSSI
), &ldBm
);
112 pDevice
->wstats
.qual
.level
= ldBm
;
113 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
114 pDevice
->wstats
.qual
.noise
= 0;
115 pDevice
->wstats
.qual
.updated
= 1;
116 pDevice
->wstats
.discard
.nwid
= 0;
117 pDevice
->wstats
.discard
.code
= 0;
118 pDevice
->wstats
.discard
.fragment
= 0;
119 pDevice
->wstats
.discard
.retries
= (unsigned long)pDevice
->scStatistic
.dwTsrErr
;
120 pDevice
->wstats
.discard
.misc
= 0;
121 pDevice
->wstats
.miss
.beacon
= 0;
123 return &pDevice
->wstats
;
128 /*------------------------------------------------------------------*/
131 static int iwctl_commit(struct net_device
*dev
,
132 struct iw_request_info
*info
,
136 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWCOMMIT \n");
142 * Wireless Handler : get protocol name
145 int iwctl_giwname(struct net_device
*dev
,
146 struct iw_request_info
*info
,
150 strcpy(wrq
, "802.11-a/b/g");
155 * Wireless Handler : set scan
158 int iwctl_siwscan(struct net_device
*dev
,
159 struct iw_request_info
*info
,
160 struct iw_point
*wrq
,
163 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
164 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
165 struct iw_scan_req
*req
= (struct iw_scan_req
*)extra
;
166 unsigned char abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
167 PWLAN_IE_SSID pItemSSID
=NULL
;
168 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWSCAN \n");
171 if(pDevice
->byReAssocCount
> 0) { //reject scan when re-associating!
172 //send scan event to wpa_Supplicant
173 union iwreq_data wrqu
;
174 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
175 memset(&wrqu
, 0, sizeof(wrqu
));
176 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
180 spin_lock_irq(&pDevice
->lock
);
181 BSSvClearBSSList((void *)pDevice
, pDevice
->bLinkPass
);
183 //mike add: active scan OR passive scan OR desire_ssid scan
184 if(wrq
->length
== sizeof(struct iw_scan_req
)) {
185 if (wrq
->flags
& IW_SCAN_THIS_ESSID
) { //desire_ssid scan
186 memset(abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
187 pItemSSID
= (PWLAN_IE_SSID
)abyScanSSID
;
188 pItemSSID
->byElementID
= WLAN_EID_SSID
;
189 memcpy(pItemSSID
->abySSID
, req
->essid
, (int)req
->essid_len
);
190 if (pItemSSID
->abySSID
[req
->essid_len
- 1] == '\0') {
192 pItemSSID
->len
= req
->essid_len
- 1;
195 pItemSSID
->len
= req
->essid_len
;
196 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
197 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID
)abyScanSSID
)->abySSID
,
198 ((PWLAN_IE_SSID
)abyScanSSID
)->len
);
199 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, abyScanSSID
);
200 spin_unlock_irq(&pDevice
->lock
);
204 else if(req
->scan_type
== IW_SCAN_TYPE_PASSIVE
) { //passive scan
205 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
209 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
212 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
213 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
214 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
215 spin_unlock_irq(&pDevice
->lock
);
222 * Wireless Handler : get scan results
225 int iwctl_giwscan(struct net_device
*dev
,
226 struct iw_request_info
*info
,
227 struct iw_point
*wrq
,
231 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
232 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
234 PWLAN_IE_SSID pItemSSID
;
235 PWLAN_IE_SUPP_RATES pSuppRates
, pExtSuppRates
;
236 char *current_ev
= extra
;
237 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
238 char *current_val
= NULL
;
241 char buf
[MAX_WPA_IE_LEN
* 2 + 30];
244 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSCAN \n");
246 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
250 pBSS
= &(pMgmt
->sBSSList
[0]);
251 for (ii
= 0, jj
= 0; jj
< MAX_BSS_NUM
; jj
++) {
252 if (current_ev
>= end_buf
)
254 pBSS
= &(pMgmt
->sBSSList
[jj
]);
257 memset(&iwe
, 0, sizeof(iwe
));
259 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
260 memcpy(iwe
.u
.ap_addr
.sa_data
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
261 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
263 memset(&iwe
, 0, sizeof(iwe
));
264 iwe
.cmd
= SIOCGIWESSID
;
265 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
266 iwe
.u
.data
.length
= pItemSSID
->len
;
267 iwe
.u
.data
.flags
= 1;
268 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
270 memset(&iwe
, 0, sizeof(iwe
));
271 iwe
.cmd
= SIOCGIWMODE
;
272 if (WLAN_GET_CAP_INFO_ESS(pBSS
->wCapInfo
)) {
273 iwe
.u
.mode
= IW_MODE_INFRA
;
276 iwe
.u
.mode
= IW_MODE_ADHOC
;
278 iwe
.len
= IW_EV_UINT_LEN
;
279 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
281 pSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abySuppRates
;
282 pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abyExtSuppRates
;
283 memset(&iwe
, 0, sizeof(iwe
));
284 iwe
.cmd
= SIOCGIWFREQ
;
285 iwe
.u
.freq
.m
= pBSS
->uChannel
;
288 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
289 //2008-0409-04, <Add> by Einsn Liu
291 int f
= (int)pBSS
->uChannel
- 1;
293 iwe
.u
.freq
.m
= frequency_list
[f
] * 100000;
296 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
298 memset(&iwe
, 0, sizeof(iwe
));
300 RFvRSSITodBm(pDevice
, (unsigned char)(pBSS
->uRSSI
), &ldBm
);
301 iwe
.u
.qual
.level
= ldBm
;
302 iwe
.u
.qual
.noise
= 0;
303 //2008-0409-01, <Add> by Einsn Liu
305 iwe
.u
.qual
.qual
= 100;
306 }else if(-ldBm
> 90) {
309 iwe
.u
.qual
.qual
=(40-(-ldBm
-50))*100/40;
311 iwe
.u
.qual
.updated
=7;
313 // iwe.u.qual.qual = 0;
314 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
316 memset(&iwe
, 0, sizeof(iwe
));
317 iwe
.cmd
= SIOCGIWENCODE
;
318 iwe
.u
.data
.length
= 0;
319 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS
->wCapInfo
)) {
320 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
322 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
324 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
326 memset(&iwe
, 0, sizeof(iwe
));
327 iwe
.cmd
= SIOCGIWRATE
;
328 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
329 current_val
= current_ev
+ IW_EV_LCP_LEN
;
331 for (kk
= 0 ; kk
< 12 ; kk
++) {
332 if (pSuppRates
->abyRates
[kk
] == 0)
334 // Bit rate given in 500 kb/s units (+ 0x80)
335 iwe
.u
.bitrate
.value
= ((pSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
336 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
338 for (kk
= 0 ; kk
< 8 ; kk
++) {
339 if (pExtSuppRates
->abyRates
[kk
] == 0)
341 // Bit rate given in 500 kb/s units (+ 0x80)
342 iwe
.u
.bitrate
.value
= ((pExtSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
343 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
346 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
347 current_ev
= current_val
;
349 memset(&iwe
, 0, sizeof(iwe
));
350 iwe
.cmd
= IWEVCUSTOM
;
351 sprintf(buf
, "bcn_int=%d", pBSS
->wBeaconInterval
);
352 iwe
.u
.data
.length
= strlen(buf
);
353 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, buf
);
355 if ((pBSS
->wWPALen
> 0) && (pBSS
->wWPALen
<= MAX_WPA_IE_LEN
)) {
356 memset(&iwe
, 0, sizeof(iwe
));
358 iwe
.u
.data
.length
= pBSS
->wWPALen
;
359 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byWPAIE
);
362 if ((pBSS
->wRSNLen
> 0) && (pBSS
->wRSNLen
<= MAX_WPA_IE_LEN
)) {
363 memset(&iwe
, 0, sizeof(iwe
));
365 iwe
.u
.data
.length
= pBSS
->wRSNLen
;
366 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byRSNIE
);
372 wrq
->length
= current_ev
- extra
;
379 * Wireless Handler : set frequence or channel
382 int iwctl_siwfreq(struct net_device
*dev
,
383 struct iw_request_info
*info
,
387 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
390 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFREQ \n");
392 // If setting by frequency, convert to a channel
394 (wrq
->m
>= (int) 2.412e8
) &&
395 (wrq
->m
<= (int) 2.487e8
)) {
396 int f
= wrq
->m
/ 100000;
398 while((c
< 14) && (f
!= frequency_list
[c
]))
403 // Setting by channel number
404 if((wrq
->m
> 14) || (wrq
->e
> 0))
407 int channel
= wrq
->m
;
408 if((channel
< 1) || (channel
> 14)) {
409 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: New channel value of %d is invalid!\n", dev
->name
, wrq
->m
);
412 // Yes ! We can set it !!!
413 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set to channel = %d\n", channel
);
414 pDevice
->uChannel
= channel
;
415 //2007-0207-04,<Add> by EinsnLiu
416 //Make change effect at once
417 pDevice
->bCommit
= true;
425 * Wireless Handler : get frequence or channel
428 int iwctl_giwfreq(struct net_device
*dev
,
429 struct iw_request_info
*info
,
433 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
434 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
436 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFREQ \n");
438 #ifdef WEXT_USECHANNELS
439 wrq
->m
= (int)pMgmt
->uCurrChannel
;
443 int f
= (int)pMgmt
->uCurrChannel
- 1;
446 wrq
->m
= frequency_list
[f
] * 100000;
455 * Wireless Handler : set operation mode
458 int iwctl_siwmode(struct net_device
*dev
,
459 struct iw_request_info
*info
,
463 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
464 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
467 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWMODE \n");
469 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
&& pDevice
->bEnableHostapd
) {
470 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Can't set operation mode, hostapd is running \n");
477 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_IBSS_STA
) {
478 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
479 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
480 pDevice
->bCommit
= true;
483 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to ad-hoc \n");
487 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_ESS_STA
) {
488 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
489 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
490 pDevice
->bCommit
= true;
493 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to infrastructure \n");
497 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
501 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_AP
) {
502 pMgmt
->eConfigMode
= WMAC_CONFIG_AP
;
503 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
504 pDevice
->bCommit
= true;
507 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to Access Point \n");
511 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
522 * Wireless Handler : get operation mode
525 int iwctl_giwmode(struct net_device
*dev
,
526 struct iw_request_info
*info
,
530 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
531 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
534 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWMODE \n");
535 // If not managed, assume it's ad-hoc
536 switch (pMgmt
->eConfigMode
) {
537 case WMAC_CONFIG_ESS_STA
:
538 *wmode
= IW_MODE_INFRA
;
540 case WMAC_CONFIG_IBSS_STA
:
541 *wmode
= IW_MODE_ADHOC
;
543 case WMAC_CONFIG_AUTO
:
544 *wmode
= IW_MODE_INFRA
;
547 *wmode
= IW_MODE_MASTER
;
550 *wmode
= IW_MODE_ADHOC
;
558 * Wireless Handler : get capability range
561 int iwctl_giwrange(struct net_device
*dev
,
562 struct iw_request_info
*info
,
563 struct iw_point
*wrq
,
566 struct iw_range
*range
= (struct iw_range
*) extra
;
568 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
571 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRANGE \n");
573 wrq
->length
= sizeof(struct iw_range
);
574 memset(range
, 0, sizeof(struct iw_range
));
575 range
->min_nwid
= 0x0000;
576 range
->max_nwid
= 0x0000;
577 range
->num_channels
= 14;
578 // Should be based on cap_rid.country to give only
579 // what the current card support
581 for(i
= 0; i
< 14; i
++) {
582 range
->freq
[k
].i
= i
+ 1; // List index
583 range
->freq
[k
].m
= frequency_list
[i
] * 100000;
584 range
->freq
[k
++].e
= 1; // Values in table in MHz -> * 10^5 * 10
586 range
->num_frequency
= k
;
587 // Hum... Should put the right values there
588 #ifdef Calcu_LinkQual
589 range
->max_qual
.qual
= 100;
591 range
->max_qual
.qual
= 255;
593 range
->max_qual
.level
= 0;
594 range
->max_qual
.noise
= 0;
595 range
->sensitivity
= 255;
597 for(i
= 0 ; i
< 13 ; i
++) {
598 range
->bitrate
[i
] = abySupportedRates
[i
] * 500000;
599 if(range
->bitrate
[i
] == 0)
602 range
->num_bitrates
= i
;
604 // Set an indication of the max TCP throughput
605 // in bit/s that we can expect using this interface.
606 // May be use for QoS stuff... Jean II
608 range
->throughput
= 5 * 1000 * 1000;
610 range
->throughput
= 1.5 * 1000 * 1000;
613 range
->max_rts
= 2312;
614 range
->min_frag
= 256;
615 range
->max_frag
= 2312;
618 // the encoding capabilities
619 range
->num_encoding_sizes
= 3;
621 range
->encoding_size
[0] = 5;
623 range
->encoding_size
[1] = 13;
624 // 256 bits for WPA-PSK
625 range
->encoding_size
[2] = 32;
626 // 4 keys are allowed
627 range
->max_encoding_tokens
= 4;
629 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
630 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
633 range
->max_pmp
= 1000000;// 1 secs
635 range
->max_pmt
= 1000000;// 1 secs
636 range
->pmp_flags
= IW_POWER_PERIOD
;
637 range
->pmt_flags
= IW_POWER_TIMEOUT
;
638 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
640 // Transmit Power - values are in mW
642 range
->txpower
[0] = 100;
643 range
->num_txpower
= 1;
644 range
->txpower_capa
= IW_TXPOW_MWATT
;
645 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
646 range
->we_version_compiled
= WIRELESS_EXT
;
647 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
648 range
->retry_flags
= IW_RETRY_LIMIT
;
649 range
->r_time_flags
= IW_RETRY_LIFETIME
;
650 range
->min_retry
= 1;
651 range
->max_retry
= 65535;
652 range
->min_r_time
= 1024;
653 range
->max_r_time
= 65535 * 1024;
654 // Experimental measurements - boundary 11/5.5 Mb/s
655 // Note : with or without the (local->rssi), results
656 // are somewhat different. - Jean II
657 range
->avg_qual
.qual
= 6;
658 range
->avg_qual
.level
= 176; // -80 dBm
659 range
->avg_qual
.noise
= 0;
668 * Wireless Handler : set ap mac address
671 int iwctl_siwap(struct net_device
*dev
,
672 struct iw_request_info
*info
,
673 struct sockaddr
*wrq
,
676 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
677 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
679 unsigned char ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
681 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAP \n");
682 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
684 printk("SIOCSIWAP(??)-->In scanning...\n");
687 if (wrq
->sa_family
!= ARPHRD_ETHER
)
690 memcpy(pMgmt
->abyDesireBSSID
, wrq
->sa_data
, 6);
691 //2008-0409-05, <Add> by Einsn Liu
692 if((pDevice
->bLinkPass
== true) &&
693 (memcmp(pMgmt
->abyDesireBSSID
, pMgmt
->abyCurrBSSID
, 6)== 0)){
697 if ((is_broadcast_ether_addr(pMgmt
->abyDesireBSSID
)) ||
698 (memcmp(pMgmt
->abyDesireBSSID
, ZeroBSSID
, 6) == 0)){
699 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
702 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
703 // then ignore,because you don't known which one to be connect with??
705 unsigned int ii
, uSameBssidNum
=0;
706 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
707 if (pMgmt
->sBSSList
[ii
].bActive
&&
708 !compare_ether_addr(pMgmt
->sBSSList
[ii
].abyBSSID
, pMgmt
->abyDesireBSSID
)) {
712 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
713 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
718 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
719 pDevice
->bCommit
= true;
726 * Wireless Handler : get ap mac address
729 int iwctl_giwap(struct net_device
*dev
,
730 struct iw_request_info
*info
,
731 struct sockaddr
*wrq
,
734 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
735 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
738 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAP \n");
740 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
741 //2008-0410,<Modify> by Einsn Liu
742 if ((pDevice
->bLinkPass
== false) && (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
))
743 memset(wrq
->sa_data
, 0, 6);
745 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
746 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
749 wrq
->sa_family
= ARPHRD_ETHER
;
757 * Wireless Handler : get ap list
760 int iwctl_giwaplist(struct net_device
*dev
,
761 struct iw_request_info
*info
,
762 struct iw_point
*wrq
,
766 struct sockaddr sock
[IW_MAX_AP
];
767 struct iw_quality qual
[IW_MAX_AP
];
768 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
769 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
772 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAPLIST \n");
773 // Only super-user can see AP list
775 if (!capable(CAP_NET_ADMIN
)) {
782 PKnownBSS pBSS
= &(pMgmt
->sBSSList
[0]);
784 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
785 pBSS
= &(pMgmt
->sBSSList
[ii
]);
788 if ( jj
>= IW_MAX_AP
)
790 memcpy(sock
[jj
].sa_data
, pBSS
->abyBSSID
, 6);
791 sock
[jj
].sa_family
= ARPHRD_ETHER
;
792 qual
[jj
].level
= pBSS
->uRSSI
;
793 qual
[jj
].qual
= qual
[jj
].noise
= 0;
794 qual
[jj
].updated
= 2;
798 wrq
->flags
= 1; // Should be define'd
800 memcpy(extra
, sock
, sizeof(struct sockaddr
)*jj
);
801 memcpy(extra
+ sizeof(struct sockaddr
)*jj
, qual
, sizeof(struct iw_quality
)*jj
);
809 * Wireless Handler : set essid
812 int iwctl_siwessid(struct net_device
*dev
,
813 struct iw_request_info
*info
,
814 struct iw_point
*wrq
,
817 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
818 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
819 PWLAN_IE_SSID pItemSSID
;
820 //2008-0409-05, <Add> by Einsn Liu
824 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWESSID \n");
825 pDevice
->fWPA_Authened
= false;
826 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
828 printk("SIOCSIWESSID(??)-->In scanning...\n");
831 // Check if we asked for `any'
832 if(wrq
->flags
== 0) {
833 // Just send an empty SSID list
834 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
835 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
836 PRINT_K("set essid to 'any' \n");
837 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
838 //Unknown desired AP,so here need not associate??
839 //if(pDevice->bWPASuppWextEnabled == true) {
845 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
846 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
847 pItemSSID
->byElementID
= WLAN_EID_SSID
;
849 memcpy(pItemSSID
->abySSID
, extra
, wrq
->length
);
850 if (pItemSSID
->abySSID
[wrq
->length
- 1] == '\0') {
852 pItemSSID
->len
= wrq
->length
- 1;
855 pItemSSID
->len
= wrq
->length
;
856 printk("set essid to %s \n",pItemSSID
->abySSID
);
857 //2008-0409-05, <Add> by Einsn Liu
858 len
=(pItemSSID
->len
> ((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
)?pItemSSID
->len
:((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->len
;
859 if((pDevice
->bLinkPass
== true) &&
860 (memcmp(pItemSSID
->abySSID
,((PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
)->abySSID
,len
)==0))
863 //mike:need clear desiredBSSID
864 if(pItemSSID
->len
==0) {
865 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
869 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
870 //Wext wil order another command of siwap to link with desired AP,
871 //so here need not associate??
872 if(pDevice
->bWPASuppWextEnabled
== true) {
873 /*******search if in hidden ssid mode ****/
875 PKnownBSS pCurr
= NULL
;
876 unsigned char abyTmpDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
877 unsigned int ii
, uSameBssidNum
=0;
879 memcpy(abyTmpDesireSSID
,pMgmt
->abyDesireSSID
,sizeof(abyTmpDesireSSID
));
880 pCurr
= BSSpSearchBSSList(pDevice
,
883 pMgmt
->eConfigPHYMode
887 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
888 vResetCommandTimer((void *) pDevice
);
889 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
890 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
891 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
893 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
894 // by means of judging if there are two same BSSID exist in list ?
895 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
896 if (pMgmt
->sBSSList
[ii
].bActive
&&
897 !compare_ether_addr(pMgmt
->sBSSList
[ii
].abyBSSID
, pCurr
->abyBSSID
)) {
901 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
902 printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
903 vResetCommandTimer((void *) pDevice
);
904 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
; //this scan type,you'll submit scan result!
905 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
906 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
914 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set essid = %s \n", pItemSSID
->abySSID
);
917 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
918 pDevice
->bCommit
= true;
927 * Wireless Handler : get essid
930 int iwctl_giwessid(struct net_device
*dev
,
931 struct iw_request_info
*info
,
932 struct iw_point
*wrq
,
936 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
937 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
938 PWLAN_IE_SSID pItemSSID
;
940 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWESSID \n");
942 // Note : if wrq->u.data.flags != 0, we should
943 // get the relevant SSID from the SSID list...
945 // Get the current SSID
946 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
947 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
948 memcpy(extra
, pItemSSID
->abySSID
, pItemSSID
->len
);
949 extra
[pItemSSID
->len
] = '\0';
950 wrq
->length
= pItemSSID
->len
+ 1;
951 //2008-0409-03, <Add> by Einsn Liu
952 wrq
->length
= pItemSSID
->len
;
953 wrq
->flags
= 1; // active
960 * Wireless Handler : set data rate
963 int iwctl_siwrate(struct net_device
*dev
,
964 struct iw_request_info
*info
,
965 struct iw_param
*wrq
,
968 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
972 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
975 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRATE \n");
976 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
981 // First : get a valid bit rate value
983 // Which type of value
984 if((wrq
->value
< 13) &&
986 // Setting by rate index
987 // Find value in the magic rate table
990 // Setting by frequency value
991 u8 normvalue
= (u8
) (wrq
->value
/500000);
993 // Check if rate is valid
994 for(i
= 0 ; i
< 13 ; i
++) {
995 if(normvalue
== abySupportedRates
[i
]) {
1001 // -1 designed the max rate (mostly auto mode)
1002 if(wrq
->value
== -1) {
1003 // Get the highest available rate
1004 for(i
= 0 ; i
< 13 ; i
++) {
1005 if(abySupportedRates
[i
] == 0)
1012 // Check that it is valid
1013 // brate is index of abySupportedRates[]
1019 // Now, check if we want a fixed or auto value
1020 if(wrq
->fixed
!= 0) {
1023 printk("Rate Fix\n");
1024 pDevice
->bFixRate
= true;
1025 if ((pDevice
->byBBType
== BB_TYPE_11B
)&& (brate
> 3)) {
1026 pDevice
->uConnectionRate
= 3;
1029 pDevice
->uConnectionRate
= brate
;
1030 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fixed to Rate %d \n", pDevice
->uConnectionRate
);
1035 pDevice
->bFixRate
= false;
1036 pDevice
->uConnectionRate
= 13;
1037 printk("auto rate:connection_rate is 13\n");
1044 * Wireless Handler : get data rate
1047 int iwctl_giwrate(struct net_device
*dev
,
1048 struct iw_request_info
*info
,
1049 struct iw_param
*wrq
,
1052 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1053 //2007-0118-05,<Mark> by EinsnLiu
1054 //Mark the unnecessary sentences.
1055 // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1057 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRATE \n");
1059 unsigned char abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1061 //2008-5-8 <modify> by chester
1062 if(pDevice
->bLinkPass
){
1063 if(pDevice
->bFixRate
== true){
1064 if (pDevice
->uConnectionRate
< 13) {
1065 brate
= abySupportedRates
[pDevice
->uConnectionRate
];
1067 if (pDevice
->byBBType
== BB_TYPE_11B
)
1069 if (pDevice
->byBBType
== BB_TYPE_11G
)
1071 if (pDevice
->byBBType
== BB_TYPE_11A
)
1078 brate
= abySupportedRates
[TxRate_iwconfig
];
1082 //2007-0118-05,<Mark> by EinsnLiu
1083 //Mark the unnecessary sentences.
1085 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1086 if (pDevice->byBBType == BB_TYPE_11B)
1088 if (pDevice->byBBType == BB_TYPE_11G)
1090 if (pDevice->byBBType == BB_TYPE_11A)
1095 // if (pDevice->uConnectionRate == 13)
1096 // brate = abySupportedRates[pDevice->wCurrentRate];
1097 wrq
->value
= brate
* 500000;
1098 // If more than one rate, set auto
1099 if (pDevice
->bFixRate
== true)
1110 * Wireless Handler : set rts threshold
1113 int iwctl_siwrts(struct net_device
*dev
,
1114 struct iw_request_info
*info
,
1115 struct iw_param
*wrq
,
1118 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1121 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRTS \n");
1124 int rthr
= wrq
->value
;
1127 if((rthr
< 0) || (rthr
> 2312)) {
1130 pDevice
->wRTSThreshold
= rthr
;
1138 * Wireless Handler : get rts
1141 int iwctl_giwrts(struct net_device
*dev
,
1142 struct iw_request_info
*info
,
1143 struct iw_param
*wrq
,
1146 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1148 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRTS \n");
1149 wrq
->value
= pDevice
->wRTSThreshold
;
1150 wrq
->disabled
= (wrq
->value
>= 2312);
1157 * Wireless Handler : set fragment threshold
1160 int iwctl_siwfrag(struct net_device
*dev
,
1161 struct iw_request_info
*info
,
1162 struct iw_param
*wrq
,
1165 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1167 int fthr
= wrq
->value
;
1170 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFRAG \n");
1175 if((fthr
< 256) || (fthr
> 2312)) {
1178 fthr
&= ~0x1; // Get an even value
1179 pDevice
->wFragmentationThreshold
= (u16
)fthr
;
1186 * Wireless Handler : get fragment threshold
1189 int iwctl_giwfrag(struct net_device
*dev
,
1190 struct iw_request_info
*info
,
1191 struct iw_param
*wrq
,
1194 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1196 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFRAG \n");
1197 wrq
->value
= pDevice
->wFragmentationThreshold
;
1198 wrq
->disabled
= (wrq
->value
>= 2312);
1207 * Wireless Handler : set retry threshold
1209 int iwctl_siwretry(struct net_device
*dev
,
1210 struct iw_request_info
*info
,
1211 struct iw_param
*wrq
,
1214 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1218 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRETRY \n");
1220 if (wrq
->disabled
) {
1225 if (wrq
->flags
& IW_RETRY_LIMIT
) {
1226 if(wrq
->flags
& IW_RETRY_MAX
)
1227 pDevice
->byLongRetryLimit
= wrq
->value
;
1228 else if (wrq
->flags
& IW_RETRY_MIN
)
1229 pDevice
->byShortRetryLimit
= wrq
->value
;
1231 // No modifier : set both
1232 pDevice
->byShortRetryLimit
= wrq
->value
;
1233 pDevice
->byLongRetryLimit
= wrq
->value
;
1236 if (wrq
->flags
& IW_RETRY_LIFETIME
) {
1237 pDevice
->wMaxTransmitMSDULifetime
= wrq
->value
;
1245 * Wireless Handler : get retry threshold
1247 int iwctl_giwretry(struct net_device
*dev
,
1248 struct iw_request_info
*info
,
1249 struct iw_param
*wrq
,
1252 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1253 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRETRY \n");
1254 wrq
->disabled
= 0; // Can't be disabled
1256 // Note : by default, display the min retry number
1257 if((wrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1258 wrq
->flags
= IW_RETRY_LIFETIME
;
1259 wrq
->value
= (int)pDevice
->wMaxTransmitMSDULifetime
; //ms
1260 } else if((wrq
->flags
& IW_RETRY_MAX
)) {
1261 wrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
1262 wrq
->value
= (int)pDevice
->byLongRetryLimit
;
1264 wrq
->flags
= IW_RETRY_LIMIT
;
1265 wrq
->value
= (int)pDevice
->byShortRetryLimit
;
1266 if((int)pDevice
->byShortRetryLimit
!= (int)pDevice
->byLongRetryLimit
)
1267 wrq
->flags
|= IW_RETRY_MIN
;
1276 * Wireless Handler : set encode mode
1278 int iwctl_siwencode(struct net_device
*dev
,
1279 struct iw_request_info
*info
,
1280 struct iw_point
*wrq
,
1283 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1284 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1285 unsigned long dwKeyIndex
= (unsigned long)(wrq
->flags
& IW_ENCODE_INDEX
);
1287 int index
= (wrq
->flags
& IW_ENCODE_INDEX
);
1289 //2007-0207-07,<Modify> by EinsnLiu
1290 //There are some problems when using iwconfig encode/key command to set the WEP key.
1291 //I almost rewrite this function.
1292 //now it support:(assume the wireless interface's name is eth0)
1293 //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
1294 //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
1295 //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
1296 //iwconfig eth0 key restricted /*enable share key*/
1300 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWENCODE \n");
1302 if((wrq
->flags
& IW_ENCODE_DISABLED
)==0){
1303 //Not disable encryption
1305 if (dwKeyIndex
> WLAN_WEP_NKEYS
) {
1310 if(dwKeyIndex
<1&&((wrq
->flags
&IW_ENCODE_NOKEY
)==0)){//set default key
1311 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1312 dwKeyIndex
=pDevice
->byKeyIndex
;
1318 // Check the size of the key
1319 if (wrq
->length
> WLAN_WEP232_KEYLEN
) {
1324 if(wrq
->length
>0){//have key
1326 if (wrq
->length
== WLAN_WEP232_KEYLEN
) {
1327 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 232 bit wep key\n");
1329 else if (wrq
->length
== WLAN_WEP104_KEYLEN
) {
1330 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 104 bit wep key\n");
1332 else if (wrq
->length
== WLAN_WEP40_KEYLEN
) {
1333 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 40 bit wep key, index= %d\n", (int)dwKeyIndex
);
1334 }else {//no support length
1338 memset(pDevice
->abyKey
, 0, WLAN_WEP232_KEYLEN
);
1339 memcpy(pDevice
->abyKey
, extra
, wrq
->length
);
1341 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyKey: ");
1342 for (ii
= 0; ii
< wrq
->length
; ii
++) {
1343 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02x ", pDevice
->abyKey
[ii
]);
1346 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1347 spin_lock_irq(&pDevice
->lock
);
1348 KeybSetDefaultKey(&(pDevice
->sKey
),
1349 (unsigned long)(dwKeyIndex
| (1 << 31)),
1354 pDevice
->PortOffset
,
1357 spin_unlock_irq(&pDevice
->lock
);
1359 pDevice
->byKeyIndex
= (unsigned char)dwKeyIndex
;
1360 pDevice
->uKeyLength
= wrq
->length
;
1361 pDevice
->bTransmitKey
= true;
1362 pDevice
->bEncryptionEnable
= true;
1363 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1366 //when the length is 0 the request only changes the default transmit key index
1367 //check the new key has a non zero lenget
1368 if(pDevice
->bEncryptionEnable
==false)
1373 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Just set Default key Index:\n");
1374 pkeytab
=&(pDevice
->sKey
.KeyTable
[MAX_KEY_TABLE
-1]);
1375 if(pkeytab
->GroupKey
[(unsigned char)dwKeyIndex
].uKeyLength
==0){
1376 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Default key len is 0\n");
1380 pDevice
->byKeyIndex
=(unsigned char)dwKeyIndex
;
1381 pkeytab
->dwGTKeyIndex
=dwKeyIndex
| (1 << 31);
1382 pkeytab
->GroupKey
[(unsigned char)dwKeyIndex
].dwKeyIndex
=dwKeyIndex
| (1 << 31);
1385 }else {//disable the key
1386 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disable WEP function\n");
1387 if(pDevice
->bEncryptionEnable
==false)
1389 pMgmt
->bShareKeyAlgorithm
= false;
1390 pDevice
->bEncryptionEnable
= false;
1391 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1392 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1393 spin_lock_irq(&pDevice
->lock
);
1394 for(uu
=0;uu
<MAX_KEY_TABLE
;uu
++)
1395 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
1396 spin_unlock_irq(&pDevice
->lock
);
1402 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
1404 // Check the size of the key
1405 if (wrq->length > WLAN_WEP232_KEYLEN) {
1410 if (dwKeyIndex > WLAN_WEP_NKEYS) {
1418 // Send the key to the card
1419 if (wrq->length > 0) {
1421 if (wrq->length == WLAN_WEP232_KEYLEN) {
1422 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
1424 else if (wrq->length == WLAN_WEP104_KEYLEN) {
1425 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
1427 else if (wrq->length == WLAN_WEP40_KEYLEN) {
1428 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
1430 memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
1431 memcpy(pDevice->abyKey, extra, wrq->length);
1433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
1434 for (ii = 0; ii < wrq->length; ii++) {
1435 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
1438 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1439 spin_lock_irq(&pDevice->lock);
1440 KeybSetDefaultKey(&(pDevice->sKey),
1441 (unsigned long)(pDevice->byKeyIndex | (1 << 31)),
1442 pDevice->uKeyLength,
1446 pDevice->PortOffset,
1449 spin_unlock_irq(&pDevice->lock);
1451 pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
1452 pDevice->uKeyLength = wrq->length;
1453 pDevice->bTransmitKey = true;
1454 pDevice->bEncryptionEnable = true;
1455 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1457 // Do we want to just set the transmit key index ?
1459 pDevice->byKeyIndex = index;
1461 else if(!(wrq->flags & IW_ENCODE_MODE)) {
1467 if(wrq->flags & IW_ENCODE_DISABLED){
1469 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
1470 pMgmt->bShareKeyAlgorithm = false;
1471 pDevice->bEncryptionEnable = false;
1472 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1473 if (pDevice->flags & DEVICE_FLAGS_OPENED) {
1474 spin_lock_irq(&pDevice->lock);
1475 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1476 MACvDisableKeyEntry(pDevice->PortOffset, uu);
1477 spin_unlock_irq(&pDevice->lock);
1482 if(wrq
->flags
& IW_ENCODE_RESTRICTED
) {
1483 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & ShareKey System\n");
1484 pMgmt
->bShareKeyAlgorithm
= true;
1486 if(wrq
->flags
& IW_ENCODE_OPEN
) {
1487 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & Open System\n");
1488 pMgmt
->bShareKeyAlgorithm
= false;
1494 * Wireless Handler : get encode mode
1497 int iwctl_giwencode(struct net_device *dev,
1498 struct iw_request_info *info,
1499 struct iw_point *wrq,
1502 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1503 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1505 char abyKey[WLAN_WEP232_KEYLEN];
1506 unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
1507 PSKeyItem pKey = NULL;
1509 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1510 //2007-0207-06,<Add> by EinsnLiu
1511 //the key index in iwconfig is 1-4 when our driver is 0-3
1512 //so it can't be used directly.
1513 //if the index is 0,we should used the index set by driver.
1514 if (index > WLAN_WEP_NKEYS) {
1518 if(index<1){//set default key
1519 if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
1520 index=pDevice->byKeyIndex;
1526 memset(abyKey, 0, sizeof(abyKey));
1527 // Check encryption mode
1528 wrq->flags = IW_ENCODE_NOKEY;
1529 // Is WEP enabled ???
1530 if (pDevice->bEncryptionEnable)
1531 wrq->flags |= IW_ENCODE_ENABLED;
1533 wrq->flags |= IW_ENCODE_DISABLED;
1535 if (pMgmt->bShareKeyAlgorithm)
1536 wrq->flags |= IW_ENCODE_RESTRICTED;
1538 wrq->flags |= IW_ENCODE_OPEN;
1540 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)){
1541 wrq->length = pKey->uKeyLength;
1542 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1543 //2007-0207-06,<Modify> by EinsnLiu
1544 //only get key success need to copy data
1546 //there is not necessary to return -EINVAL when get key failed
1547 //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
1548 wrq->flags |= index+1;
1549 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1564 //2008-0409-06, <Add> by Einsn Liu
1566 int iwctl_giwencode(struct net_device
*dev
,
1567 struct iw_request_info
*info
,
1568 struct iw_point
*wrq
,
1571 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1572 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1573 char abyKey
[WLAN_WEP232_KEYLEN
];
1575 unsigned int index
= (unsigned int)(wrq
->flags
& IW_ENCODE_INDEX
);
1576 PSKeyItem pKey
= NULL
;
1578 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWENCODE\n");
1580 if (index
> WLAN_WEP_NKEYS
) {
1583 if(index
<1){//get default key
1584 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1585 index
=pDevice
->byKeyIndex
;
1591 memset(abyKey
, 0, WLAN_WEP232_KEYLEN
);
1592 // Check encryption mode
1593 wrq
->flags
= IW_ENCODE_NOKEY
;
1594 // Is WEP enabled ???
1595 if (pDevice
->bEncryptionEnable
)
1596 wrq
->flags
|= IW_ENCODE_ENABLED
;
1598 wrq
->flags
|= IW_ENCODE_DISABLED
;
1600 if (pMgmt
->bShareKeyAlgorithm
)
1601 wrq
->flags
|= IW_ENCODE_RESTRICTED
;
1603 wrq
->flags
|= IW_ENCODE_OPEN
;
1606 if((index
==0)&&(pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
||
1607 pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)){//get wpa pairwise key
1608 if (KeybGetKey(&(pDevice
->sKey
),pMgmt
->abyCurrBSSID
, 0xffffffff, &pKey
)){
1609 wrq
->length
= pKey
->uKeyLength
;
1610 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1611 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1613 }else if (KeybGetKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, (unsigned char)index
, &pKey
)){
1614 wrq
->length
= pKey
->uKeyLength
;
1615 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1616 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1619 wrq
->flags
|= index
+1;
1626 * Wireless Handler : set power mode
1628 int iwctl_siwpower(struct net_device
*dev
,
1629 struct iw_request_info
*info
,
1630 struct iw_param
*wrq
,
1633 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1634 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1637 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER \n");
1639 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1644 if (wrq
->disabled
) {
1645 pDevice
->ePSMode
= WMAC_POWER_CAM
;
1646 PSvDisablePowerSaving(pDevice
);
1649 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1650 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1651 PSvEnablePowerSaving((void *)pDevice
, pMgmt
->wListenInterval
);
1653 } else if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
1654 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1655 PSvEnablePowerSaving((void *)pDevice
, pMgmt
->wListenInterval
);
1657 switch (wrq
->flags
& IW_POWER_MODE
) {
1658 case IW_POWER_UNICAST_R
:
1659 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1662 case IW_POWER_ALL_R
:
1663 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ALL_R \n");
1666 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ON \n");
1676 * Wireless Handler : get power mode
1678 int iwctl_giwpower(struct net_device
*dev
,
1679 struct iw_request_info
*info
,
1680 struct iw_param
*wrq
,
1683 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1684 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1685 int mode
= pDevice
->ePSMode
;
1688 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWPOWER \n");
1691 wrq
->disabled
= (mode
== WMAC_POWER_CAM
);
1695 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1696 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1697 wrq
->flags
= IW_POWER_TIMEOUT
;
1699 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1700 wrq
->flags
= IW_POWER_PERIOD
;
1702 wrq
->flags
|= IW_POWER_ALL_R
;
1709 * Wireless Handler : get Sensitivity
1711 int iwctl_giwsens(struct net_device
*dev
,
1712 struct iw_request_info
*info
,
1713 struct iw_param
*wrq
,
1716 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1719 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSENS \n");
1720 if (pDevice
->bLinkPass
== true) {
1721 RFvRSSITodBm(pDevice
, (unsigned char)(pDevice
->uCurrRSSI
), &ldBm
);
1727 wrq
->disabled
= (wrq
->value
== 0);
1734 //2008-0409-07, <Add> by Einsn Liu
1735 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1737 int iwctl_siwauth(struct net_device
*dev
,
1738 struct iw_request_info
*info
,
1739 struct iw_param
*wrq
,
1742 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1743 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1745 static int wpa_version
=0; //must be static to save the last value,einsn liu
1746 static int pairwise
=0;
1748 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAUTH \n");
1749 switch (wrq
->flags
& IW_AUTH_INDEX
) {
1750 case IW_AUTH_WPA_VERSION
:
1751 wpa_version
= wrq
->value
;
1752 if(wrq
->value
== IW_AUTH_WPA_VERSION_DISABLED
) {
1753 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1754 //pDevice->bWPADevEnable = false;
1756 else if(wrq
->value
== IW_AUTH_WPA_VERSION_WPA
) {
1757 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1760 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1762 //pDevice->bWPASuppWextEnabled =true;
1764 case IW_AUTH_CIPHER_PAIRWISE
:
1765 pairwise
= wrq
->value
;
1766 if(pairwise
== IW_AUTH_CIPHER_CCMP
){
1767 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1768 }else if(pairwise
== IW_AUTH_CIPHER_TKIP
){
1769 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1770 }else if(pairwise
== IW_AUTH_CIPHER_WEP40
||pairwise
== IW_AUTH_CIPHER_WEP104
){
1771 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1772 }else if(pairwise
== IW_AUTH_CIPHER_NONE
){
1773 //do nothing,einsn liu
1774 }else pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1777 case IW_AUTH_CIPHER_GROUP
:
1778 if(wpa_version
== IW_AUTH_WPA_VERSION_DISABLED
)
1780 if(pairwise
== IW_AUTH_CIPHER_NONE
){
1781 if(wrq
->value
== IW_AUTH_CIPHER_CCMP
){
1782 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1784 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1788 case IW_AUTH_KEY_MGMT
:
1790 if(wpa_version
== IW_AUTH_WPA_VERSION_WPA2
){
1791 if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1792 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
1793 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
1794 }else if(wpa_version
== IW_AUTH_WPA_VERSION_WPA
){
1795 if(wrq
->value
== 0){
1796 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
1797 }else if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1798 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
1799 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
1803 case IW_AUTH_TKIP_COUNTERMEASURES
:
1805 case IW_AUTH_DROP_UNENCRYPTED
:
1807 case IW_AUTH_80211_AUTH_ALG
:
1808 if(wrq
->value
==IW_AUTH_ALG_OPEN_SYSTEM
){
1809 pMgmt
->bShareKeyAlgorithm
=false;
1810 }else if(wrq
->value
==IW_AUTH_ALG_SHARED_KEY
){
1811 pMgmt
->bShareKeyAlgorithm
=true;
1814 case IW_AUTH_WPA_ENABLED
:
1815 //pDevice->bWPADevEnable = !! wrq->value;
1817 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1819 case IW_AUTH_ROAMING_CONTROL
:
1822 case IW_AUTH_PRIVACY_INVOKED
:
1823 pDevice
->bEncryptionEnable
= !!wrq
->value
;
1824 if(pDevice
->bEncryptionEnable
== false){
1827 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1828 pMgmt
->bShareKeyAlgorithm
= false;
1829 pMgmt
->eAuthenMode
= false;
1830 //pDevice->bWPADevEnable = false;
1839 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1840 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1841 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1842 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1843 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"true":"false");
1844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"true":"false");
1845 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"true":"false");
1851 int iwctl_giwauth(struct net_device
*dev
,
1852 struct iw_request_info
*info
,
1853 struct iw_param
*wrq
,
1861 int iwctl_siwgenie(struct net_device
*dev
,
1862 struct iw_request_info
*info
,
1863 struct iw_point
*wrq
,
1866 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1867 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1871 if ((wrq
->length
< 2) || (extra
[1]+2 != wrq
->length
)) {
1875 if(wrq
->length
> MAX_WPA_IE_LEN
){
1879 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1880 if(copy_from_user(pMgmt
->abyWPAIE
, extra
, wrq
->length
)){
1884 pMgmt
->wWPAIELen
= wrq
->length
;
1886 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1887 pMgmt
->wWPAIELen
= 0;
1890 out
://not completely ...not necessary in wpa_supplicant 0.5.8
1894 int iwctl_giwgenie(struct net_device
*dev
,
1895 struct iw_request_info
*info
,
1896 struct iw_point
*wrq
,
1899 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1900 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1902 int space
= wrq
->length
;
1905 if(pMgmt
->wWPAIELen
> 0){
1906 wrq
->length
= pMgmt
->wWPAIELen
;
1907 if(pMgmt
->wWPAIELen
<= space
){
1908 if(copy_to_user(extra
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
)){
1919 int iwctl_siwencodeext(struct net_device
*dev
,
1920 struct iw_request_info
*info
,
1921 struct iw_point
*wrq
,
1924 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1925 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1926 struct viawget_wpa_param
*param
=NULL
;
1930 int key_idx
, set_tx
=0;
1931 u8 seq
[IW_ENCODE_SEQ_MAX_SIZE
];
1933 size_t seq_len
=0,key_len
=0;
1941 PRINT_K("SIOCSIWENCODEEXT...... \n");
1943 blen
= sizeof(*param
);
1944 buf
= kmalloc((int)blen
, (int)GFP_KERNEL
);
1947 memset(buf
, 0, blen
);
1948 param
= (struct viawget_wpa_param
*) buf
;
1952 case IW_ENCODE_ALG_NONE
:
1953 alg_name
= WPA_ALG_NONE
;
1955 case IW_ENCODE_ALG_WEP
:
1956 alg_name
= WPA_ALG_WEP
;
1958 case IW_ENCODE_ALG_TKIP
:
1959 alg_name
= WPA_ALG_TKIP
;
1961 case IW_ENCODE_ALG_CCMP
:
1962 alg_name
= WPA_ALG_CCMP
;
1965 PRINT_K("Unknown alg = %d\n",ext
->alg
);
1970 memcpy(addr
, ext
->addr
.sa_data
, ETH_ALEN
);
1972 key_idx
= (wrq
->flags
&IW_ENCODE_INDEX
) - 1;
1974 if(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1976 //recover seq,seq_len
1977 if(ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
1978 seq_len
=IW_ENCODE_SEQ_MAX_SIZE
;
1979 memcpy(seq
, ext
->rx_seq
, seq_len
);
1981 //recover key,key_len
1983 key_len
=ext
->key_len
;
1984 memcpy(key
, &ext
->key
[0], key_len
);
1987 memset(key_array
, 0, 64);
1989 memcpy(key_array
, key
, key_len
);
1990 if (key_len
== 32) {
1991 // notice ! the oder
1992 memcpy(&key_array
[16], &key
[24], 8);
1993 memcpy(&key_array
[24], &key
[16], 8);
1997 /**************Translate iw_encode_ext to viawget_wpa_param****************/
1998 memcpy(param
->addr
, addr
, ETH_ALEN
);
1999 param
->u
.wpa_key
.alg_name
= (int)alg_name
;
2000 param
->u
.wpa_key
.set_tx
= set_tx
;
2001 param
->u
.wpa_key
.key_index
= key_idx
;
2002 param
->u
.wpa_key
.key_len
= key_len
;
2003 param
->u
.wpa_key
.key
= (u8
*)key_array
;
2004 param
->u
.wpa_key
.seq
= (u8
*)seq
;
2005 param
->u
.wpa_key
.seq_len
= seq_len
;
2008 printk("param->u.wpa_key.alg_name =%d\n",param
->u
.wpa_key
.alg_name
);
2009 printk(KERN_DEBUG
"param->addr=%pM\n", param
->addr
);
2010 printk("param->u.wpa_key.set_tx =%d\n",param
->u
.wpa_key
.set_tx
);
2011 printk("param->u.wpa_key.key_index =%d\n",param
->u
.wpa_key
.key_index
);
2012 printk("param->u.wpa_key.key_len =%d\n",param
->u
.wpa_key
.key_len
);
2013 printk("param->u.wpa_key.key =");
2014 for(ii
=0;ii
<param
->u
.wpa_key
.key_len
;ii
++)
2015 printk("%02x:",param
->u
.wpa_key
.key
[ii
]);
2017 printk("param->u.wpa_key.seq_len =%d\n",param
->u
.wpa_key
.seq_len
);
2018 printk("param->u.wpa_key.seq =");
2019 for(ii
=0;ii
<param
->u
.wpa_key
.seq_len
;ii
++)
2020 printk("%02x:",param
->u
.wpa_key
.seq
[ii
]);
2023 printk("...........\n");
2025 //****set if current action is Network Manager count??
2026 //****this method is so foolish,but there is no other way???
2027 if(param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
2028 if(param
->u
.wpa_key
.key_index
==0) {
2029 pDevice
->bwextcount
++;
2031 if((pDevice
->bwextcount
== 1)&&(param
->u
.wpa_key
.key_index
==1)) {
2032 pDevice
->bwextcount
++;
2034 if((pDevice
->bwextcount
==2)&&(param
->u
.wpa_key
.key_index
==2)) {
2035 pDevice
->bwextcount
++;
2037 if((pDevice
->bwextcount
==3)&&(param
->u
.wpa_key
.key_index
==3)) {
2038 pDevice
->bwextcount
++;
2041 if( pDevice
->bwextcount
== 4) {
2042 printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
2043 pDevice
->bwextcount
=0;
2044 pDevice
->bWPASuppWextEnabled
= true;
2048 spin_lock_irq(&pDevice
->lock
);
2049 ret
= wpa_set_keys(pDevice
, param
, true);
2050 spin_unlock_irq(&pDevice
->lock
);
2059 int iwctl_giwencodeext(struct net_device
*dev
,
2060 struct iw_request_info
*info
,
2061 struct iw_point
*wrq
,
2067 int iwctl_siwmlme(struct net_device
*dev
,
2068 struct iw_request_info
* info
,
2069 struct iw_point
*wrq
,
2072 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
2073 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2074 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2075 //u16 reason = cpu_to_le16(mlme->reason_code);
2078 if(memcmp(pMgmt
->abyCurrBSSID
, mlme
->addr
.sa_data
, ETH_ALEN
)){
2083 case IW_MLME_DEAUTH
:
2084 //this command seems to be not complete,please test it --einsnliu
2085 //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason);
2087 case IW_MLME_DISASSOC
:
2088 if(pDevice
->bLinkPass
== true){
2089 printk("iwctl_siwmlme--->send DISASSOCIATE\n");
2090 //clear related flags
2091 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
2092 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
2093 bScheduleCommand((void *)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
2107 /*------------------------------------------------------------------*/
2109 * Structures to export the Wireless Handlers
2114 static const iw_handler iwctl_handler[] =
2116 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2117 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2118 (iw_handler) NULL, // SIOCSIWNWID
2119 (iw_handler) NULL, // SIOCGIWNWID
2120 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2121 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2122 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2123 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2124 (iw_handler) NULL, // SIOCSIWSENS
2125 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2126 (iw_handler) NULL, // SIOCSIWRANGE
2127 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2128 (iw_handler) NULL, // SIOCSIWPRIV
2129 (iw_handler) NULL, // SIOCGIWPRIV
2130 (iw_handler) NULL, // SIOCSIWSTATS
2131 (iw_handler) NULL, // SIOCGIWSTATS
2132 (iw_handler) NULL, // SIOCSIWSPY
2133 (iw_handler) NULL, // SIOCGIWSPY
2134 (iw_handler) NULL, // -- hole --
2135 (iw_handler) NULL, // -- hole --
2136 (iw_handler) iwctl_siwap, // SIOCSIWAP
2137 (iw_handler) iwctl_giwap, // SIOCGIWAP
2138 (iw_handler) NULL, // -- hole -- 0x16
2139 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2140 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2141 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2142 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2143 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2144 (iw_handler) NULL, // SIOCSIWNICKN
2145 (iw_handler) NULL, // SIOCGIWNICKN
2146 (iw_handler) NULL, // -- hole --
2147 (iw_handler) NULL, // -- hole --
2148 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2149 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2150 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2151 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2152 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2153 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2154 (iw_handler) NULL, // SIOCSIWTXPOW
2155 (iw_handler) NULL, // SIOCGIWTXPOW
2156 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2157 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2158 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2159 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2160 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2161 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2162 (iw_handler) NULL, // -- hole --
2163 (iw_handler) NULL, // -- hole --
2164 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2165 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2166 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2167 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2168 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2169 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2170 (iw_handler) NULL, // SIOCSIWPMKSA
2171 (iw_handler) NULL, // -- hole --
2176 static const iw_handler iwctl_handler
[] =
2178 (iw_handler
) iwctl_commit
, // SIOCSIWCOMMIT
2179 (iw_handler
) NULL
, // SIOCGIWNAME
2180 (iw_handler
) NULL
, // SIOCSIWNWID
2181 (iw_handler
) NULL
, // SIOCGIWNWID
2182 (iw_handler
) NULL
, // SIOCSIWFREQ
2183 (iw_handler
) NULL
, // SIOCGIWFREQ
2184 (iw_handler
) NULL
, // SIOCSIWMODE
2185 (iw_handler
) NULL
, // SIOCGIWMODE
2186 (iw_handler
) NULL
, // SIOCSIWSENS
2187 (iw_handler
) NULL
, // SIOCGIWSENS
2188 (iw_handler
) NULL
, // SIOCSIWRANGE
2189 (iw_handler
) iwctl_giwrange
, // SIOCGIWRANGE
2190 (iw_handler
) NULL
, // SIOCSIWPRIV
2191 (iw_handler
) NULL
, // SIOCGIWPRIV
2192 (iw_handler
) NULL
, // SIOCSIWSTATS
2193 (iw_handler
) NULL
, // SIOCGIWSTATS
2194 (iw_handler
) NULL
, // SIOCSIWSPY
2195 (iw_handler
) NULL
, // SIOCGIWSPY
2196 (iw_handler
) NULL
, // -- hole --
2197 (iw_handler
) NULL
, // -- hole --
2198 (iw_handler
) NULL
, // SIOCSIWAP
2199 (iw_handler
) NULL
, // SIOCGIWAP
2200 (iw_handler
) NULL
, // -- hole -- 0x16
2201 (iw_handler
) NULL
, // SIOCGIWAPLIST
2202 (iw_handler
) iwctl_siwscan
, // SIOCSIWSCAN
2203 (iw_handler
) iwctl_giwscan
, // SIOCGIWSCAN
2204 (iw_handler
) NULL
, // SIOCSIWESSID
2205 (iw_handler
) NULL
, // SIOCGIWESSID
2206 (iw_handler
) NULL
, // SIOCSIWNICKN
2207 (iw_handler
) NULL
, // SIOCGIWNICKN
2208 (iw_handler
) NULL
, // -- hole --
2209 (iw_handler
) NULL
, // -- hole --
2210 (iw_handler
) NULL
, // SIOCSIWRATE 0x20
2211 (iw_handler
) NULL
, // SIOCGIWRATE
2212 (iw_handler
) NULL
, // SIOCSIWRTS
2213 (iw_handler
) NULL
, // SIOCGIWRTS
2214 (iw_handler
) NULL
, // SIOCSIWFRAG
2215 (iw_handler
) NULL
, // SIOCGIWFRAG
2216 (iw_handler
) NULL
, // SIOCSIWTXPOW
2217 (iw_handler
) NULL
, // SIOCGIWTXPOW
2218 (iw_handler
) NULL
, // SIOCSIWRETRY
2219 (iw_handler
) NULL
, // SIOCGIWRETRY
2220 (iw_handler
) NULL
, // SIOCSIWENCODE
2221 (iw_handler
) NULL
, // SIOCGIWENCODE
2222 (iw_handler
) NULL
, // SIOCSIWPOWER
2223 (iw_handler
) NULL
, // SIOCGIWPOWER
2225 //2008-0409-07, <Add> by Einsn Liu
2226 (iw_handler
) NULL
, // -- hole --
2227 (iw_handler
) NULL
, // -- hole --
2228 (iw_handler
) NULL
, // SIOCSIWGENIE
2229 (iw_handler
) NULL
, // SIOCGIWGENIE
2230 (iw_handler
) NULL
, // SIOCSIWAUTH
2231 (iw_handler
) NULL
, // SIOCGIWAUTH
2232 (iw_handler
) NULL
, // SIOCSIWENCODEEXT
2233 (iw_handler
) NULL
, // SIOCGIWENCODEEXT
2234 (iw_handler
) NULL
, // SIOCSIWPMKSA
2235 (iw_handler
) NULL
, // -- hole --
2239 static const iw_handler iwctl_private_handler
[] =
2241 NULL
, // SIOCIWFIRSTPRIV
2245 struct iw_priv_args iwctl_private_args
[] = {
2247 IW_PRIV_TYPE_CHAR
| 1024, 0,
2253 const struct iw_handler_def iwctl_handler_def
=
2255 .get_wireless_stats
= &iwctl_get_wireless_stats
,
2256 .num_standard
= sizeof(iwctl_handler
)/sizeof(iw_handler
),
2257 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2258 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2260 .num_private_args
= 0,
2261 .standard
= (iw_handler
*) iwctl_handler
,
2262 // .private = (iw_handler *) iwctl_private_handler,
2263 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2265 .private_args
= NULL
,