2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: wireless ext & ioctl functions
34 #if !defined(__DEVICE_H__)
37 #if !defined(__IOCTL_H__)
40 #if !defined(__IOCMD_H__)
43 #if !defined(__MAC_H__)
46 #if !defined(__CARD_H__)
49 #if !defined(__HOSTAP_H__)
52 #if !defined(__UMEM_H__)
55 #if !defined(__POWER_H__)
58 #if !defined(__RF_H__)
62 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
63 #if !defined(__IOWPA_H__)
66 #if !defined(__WPACTL_H__)
71 #include <net/iw_handler.h>
74 /*--------------------- Static Definitions -------------------------*/
76 //2008-0409-07, <Add> by Einsn Liu
77 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
78 #define SUPPORTED_WIRELESS_EXT 18
80 #define SUPPORTED_WIRELESS_EXT 17
83 static const long frequency_list
[] = {
84 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
85 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
86 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
87 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
88 5700, 5745, 5765, 5785, 5805, 5825
92 /*--------------------- Static Classes ----------------------------*/
95 //static int msglevel =MSG_LEVEL_DEBUG;
96 static int msglevel
=MSG_LEVEL_INFO
;
99 /*--------------------- Static Variables --------------------------*/
100 /*--------------------- Static Functions --------------------------*/
102 /*--------------------- Export Variables --------------------------*/
104 struct iw_statistics
*iwctl_get_wireless_stats(struct net_device
*dev
)
106 PSDevice pDevice
= netdev_priv(dev
);
109 pDevice
->wstats
.status
= pDevice
->eOPMode
;
110 #ifdef Calcu_LinkQual
112 if(pDevice
->byBBType
== BB_TYPE_11B
) {
113 if(pDevice
->byCurrSQ
> 120)
114 pDevice
->scStatistic
.LinkQuality
= 100;
116 pDevice
->scStatistic
.LinkQuality
= pDevice
->byCurrSQ
*100/120;
118 else if(pDevice
->byBBType
== BB_TYPE_11G
) {
119 if(pDevice
->byCurrSQ
< 20)
120 pDevice
->scStatistic
.LinkQuality
= 100;
121 else if(pDevice
->byCurrSQ
>96)
122 pDevice
->scStatistic
.LinkQuality
= 0;
124 pDevice
->scStatistic
.LinkQuality
= (96-pDevice
->byCurrSQ
)*100/76;
126 if(pDevice
->bLinkPass
!=TRUE
)
127 pDevice
->scStatistic
.LinkQuality
= 0;
129 if(pDevice
->scStatistic
.LinkQuality
> 100)
130 pDevice
->scStatistic
.LinkQuality
= 100;
131 pDevice
->wstats
.qual
.qual
=(BYTE
) pDevice
->scStatistic
.LinkQuality
;
133 pDevice
->wstats
.qual
.qual
= pDevice
->byCurrSQ
;
135 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
136 pDevice
->wstats
.qual
.level
= ldBm
;
137 //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
138 pDevice
->wstats
.qual
.noise
= 0;
139 pDevice
->wstats
.qual
.updated
= 1;
140 pDevice
->wstats
.discard
.nwid
= 0;
141 pDevice
->wstats
.discard
.code
= 0;
142 pDevice
->wstats
.discard
.fragment
= 0;
143 pDevice
->wstats
.discard
.retries
= pDevice
->scStatistic
.dwTsrErr
;
144 pDevice
->wstats
.discard
.misc
= 0;
145 pDevice
->wstats
.miss
.beacon
= 0;
147 return &pDevice
->wstats
;
152 /*------------------------------------------------------------------*/
155 static int iwctl_commit(struct net_device
*dev
,
156 struct iw_request_info
*info
,
160 //2008-0409-02, <Mark> by Einsn Liu
163 PSDevice pDevice = (PSDevice)netdev_priv(dev);
164 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
168 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWCOMMIT \n");
175 * Wireless Handler : get protocol name
178 int iwctl_giwname(struct net_device
*dev
,
179 struct iw_request_info
*info
,
183 strcpy(wrq
, "802.11-a/b/g");
187 int iwctl_giwnwid(struct net_device
*dev
,
188 struct iw_request_info
*info
,
189 struct iw_param
*wrq
,
192 //wrq->value = 0x100;
199 * Wireless Handler : set scan
202 int iwctl_siwscan(struct net_device
*dev
,
203 struct iw_request_info
*info
,
204 struct iw_point
*wrq
,
207 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
208 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
209 struct iw_scan_req
*req
= (struct iw_scan_req
*)extra
;
210 BYTE abyScanSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
211 PWLAN_IE_SSID pItemSSID
=NULL
;
213 //2008-0920-01<Add>by MikeLiu
214 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
))
217 PRINT_K(" SIOCSIWSCAN \n");
219 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
221 PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
225 if(pDevice
->byReAssocCount
> 0) { //reject scan when re-associating!
226 //send scan event to wpa_Supplicant
227 union iwreq_data wrqu
;
228 PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
229 memset(&wrqu
, 0, sizeof(wrqu
));
230 wireless_send_event(pDevice
->dev
, SIOCGIWSCAN
, &wrqu
, NULL
);
234 spin_lock_irq(&pDevice
->lock
);
236 #ifdef update_BssList
237 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
240 //mike add: active scan OR passive scan OR desire_ssid scan
241 if(wrq
->length
== sizeof(struct iw_scan_req
)) {
242 if (wrq
->flags
& IW_SCAN_THIS_ESSID
) { //desire_ssid scan
243 memset(abyScanSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
244 pItemSSID
= (PWLAN_IE_SSID
)abyScanSSID
;
245 pItemSSID
->byElementID
= WLAN_EID_SSID
;
246 memcpy(pItemSSID
->abySSID
, req
->essid
, (int)req
->essid_len
);
247 if (pItemSSID
->abySSID
[req
->essid_len
- 1] == '\0') {
249 pItemSSID
->len
= req
->essid_len
- 1;
252 pItemSSID
->len
= req
->essid_len
;
253 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
254 PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID
)abyScanSSID
)->abySSID
,
255 ((PWLAN_IE_SSID
)abyScanSSID
)->len
);
256 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, abyScanSSID
);
257 spin_unlock_irq(&pDevice
->lock
);
261 else if(req
->scan_type
== IW_SCAN_TYPE_PASSIVE
) { //passive scan
262 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
266 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
269 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
;
270 //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
271 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
272 spin_unlock_irq(&pDevice
->lock
);
279 * Wireless Handler : get scan results
282 int iwctl_giwscan(struct net_device
*dev
,
283 struct iw_request_info
*info
,
284 struct iw_point
*wrq
,
288 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
289 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
291 PWLAN_IE_SSID pItemSSID
;
292 PWLAN_IE_SUPP_RATES pSuppRates
, pExtSuppRates
;
293 char *current_ev
= extra
;
294 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
295 char *current_val
= NULL
;
298 char buf
[MAX_WPA_IE_LEN
* 2 + 30];
300 //2008-0409-02, <Mark> by Einsn Liu
303 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
307 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSCAN \n");
309 if (pMgmt
->eScanState
== WMAC_IS_SCANNING
) {
313 pBSS
= &(pMgmt
->sBSSList
[0]);
314 for (ii
= 0, jj
= 0; jj
< MAX_BSS_NUM
; jj
++) {
315 if (current_ev
>= end_buf
)
317 pBSS
= &(pMgmt
->sBSSList
[jj
]);
320 memset(&iwe
, 0, sizeof(iwe
));
322 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
323 memcpy(iwe
.u
.ap_addr
.sa_data
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
324 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
326 memset(&iwe
, 0, sizeof(iwe
));
327 iwe
.cmd
= SIOCGIWESSID
;
328 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
329 iwe
.u
.data
.length
= pItemSSID
->len
;
330 iwe
.u
.data
.flags
= 1;
331 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
333 memset(&iwe
, 0, sizeof(iwe
));
334 iwe
.cmd
= SIOCGIWMODE
;
335 if (WLAN_GET_CAP_INFO_ESS(pBSS
->wCapInfo
)) {
336 iwe
.u
.mode
= IW_MODE_INFRA
;
339 iwe
.u
.mode
= IW_MODE_ADHOC
;
341 iwe
.len
= IW_EV_UINT_LEN
;
342 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
344 pSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abySuppRates
;
345 pExtSuppRates
= (PWLAN_IE_SUPP_RATES
)pBSS
->abyExtSuppRates
;
346 memset(&iwe
, 0, sizeof(iwe
));
347 iwe
.cmd
= SIOCGIWFREQ
;
348 iwe
.u
.freq
.m
= pBSS
->uChannel
;
351 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
352 //2008-0409-04, <Add> by Einsn Liu
354 int f
= (int)pBSS
->uChannel
- 1;
356 iwe
.u
.freq
.m
= frequency_list
[f
] * 100000;
359 current_ev
= iwe_stream_add_event(info
,current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
361 memset(&iwe
, 0, sizeof(iwe
));
363 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
364 iwe
.u
.qual
.level
= ldBm
;
365 iwe
.u
.qual
.noise
= 0;
366 //2008-0409-01, <Add> by Einsn Liu
368 iwe
.u
.qual
.qual
= 100;
369 }else if(-ldBm
> 90) {
372 iwe
.u
.qual
.qual
=(40-(-ldBm
-50))*100/40;
374 iwe
.u
.qual
.updated
=7;
376 //2008-0409-01, <Mark> by Einsn Liu
378 //2008-0220-03, <Modify> by Einsn Liu
379 if(pDevice->bLinkPass== TRUE && IS_ETH_ADDRESS_EQUAL(pBSS->abyBSSID, pMgmt->abyCurrBSSID)){
380 #ifdef Calcu_LinkQual
382 if(pDevice->byBBType == BB_TYPE_11B) {
383 if(pDevice->byCurrSQ > 120)
384 pDevice->scStatistic.LinkQuality = 100;
386 pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
388 else if(pDevice->byBBType == BB_TYPE_11G) {
389 if(pDevice->byCurrSQ < 20)
390 pDevice->scStatistic.LinkQuality = 100;
391 else if(pDevice->byCurrSQ >96)
392 pDevice->scStatistic.LinkQuality = 0;
394 pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
396 if(pDevice->bLinkPass !=TRUE)
397 pDevice->scStatistic.LinkQuality = 0;
399 if(pDevice->scStatistic.LinkQuality > 100)
400 pDevice->scStatistic.LinkQuality = 100;
401 iwe.u.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
403 iwe.u.qual.qual = pDevice->byCurrSQ;
409 current_ev
= iwe_stream_add_event(info
,current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
411 memset(&iwe
, 0, sizeof(iwe
));
412 iwe
.cmd
= SIOCGIWENCODE
;
413 iwe
.u
.data
.length
= 0;
414 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS
->wCapInfo
)) {
415 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
417 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
419 current_ev
= iwe_stream_add_point(info
,current_ev
,end_buf
, &iwe
, pItemSSID
->abySSID
);
421 memset(&iwe
, 0, sizeof(iwe
));
422 iwe
.cmd
= SIOCGIWRATE
;
423 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
424 current_val
= current_ev
+ IW_EV_LCP_LEN
;
426 for (kk
= 0 ; kk
< 12 ; kk
++) {
427 if (pSuppRates
->abyRates
[kk
] == 0)
429 // Bit rate given in 500 kb/s units (+ 0x80)
430 iwe
.u
.bitrate
.value
= ((pSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
431 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
433 for (kk
= 0 ; kk
< 8 ; kk
++) {
434 if (pExtSuppRates
->abyRates
[kk
] == 0)
436 // Bit rate given in 500 kb/s units (+ 0x80)
437 iwe
.u
.bitrate
.value
= ((pExtSuppRates
->abyRates
[kk
] & 0x7f) * 500000);
438 current_val
= iwe_stream_add_value(info
,current_ev
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
441 if((current_val
- current_ev
) > IW_EV_LCP_LEN
)
442 current_ev
= current_val
;
444 memset(&iwe
, 0, sizeof(iwe
));
445 iwe
.cmd
= IWEVCUSTOM
;
446 sprintf(buf
, "bcn_int=%d", pBSS
->wBeaconInterval
);
447 iwe
.u
.data
.length
= strlen(buf
);
448 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, buf
);
450 if ((pBSS
->wWPALen
> 0) && (pBSS
->wWPALen
<= MAX_WPA_IE_LEN
)) {
451 memset(&iwe
, 0, sizeof(iwe
));
453 iwe
.u
.data
.length
= pBSS
->wWPALen
;
454 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byWPAIE
);
457 if ((pBSS
->wRSNLen
> 0) && (pBSS
->wRSNLen
<= MAX_WPA_IE_LEN
)) {
458 memset(&iwe
, 0, sizeof(iwe
));
460 iwe
.u
.data
.length
= pBSS
->wRSNLen
;
461 current_ev
= iwe_stream_add_point(info
,current_ev
, end_buf
, &iwe
, pBSS
->byRSNIE
);
467 wrq
->length
= current_ev
- extra
;
474 * Wireless Handler : set frequence or channel
477 int iwctl_siwfreq(struct net_device
*dev
,
478 struct iw_request_info
*info
,
482 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
485 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFREQ \n");
487 // If setting by frequency, convert to a channel
489 (wrq
->m
>= (int) 2.412e8
) &&
490 (wrq
->m
<= (int) 2.487e8
)) {
491 int f
= wrq
->m
/ 100000;
493 while((c
< 14) && (f
!= frequency_list
[c
]))
498 // Setting by channel number
499 if((wrq
->m
> 14) || (wrq
->e
> 0))
502 int channel
= wrq
->m
;
503 if((channel
< 1) || (channel
> 14)) {
504 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: New channel value of %d is invalid!\n", dev
->name
, wrq
->m
);
507 // Yes ! We can set it !!!
508 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" Set to channel = %d\n", channel
);
509 pDevice
->uChannel
= channel
;
517 * Wireless Handler : get frequence or channel
520 int iwctl_giwfreq(struct net_device
*dev
,
521 struct iw_request_info
*info
,
525 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
526 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
528 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFREQ \n");
530 #ifdef WEXT_USECHANNELS
531 wrq
->m
= (int)pMgmt
->uCurrChannel
;
535 int f
= (int)pMgmt
->uCurrChannel
- 1;
538 wrq
->m
= frequency_list
[f
] * 100000;
547 * Wireless Handler : set operation mode
550 int iwctl_siwmode(struct net_device
*dev
,
551 struct iw_request_info
*info
,
555 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
556 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
559 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWMODE \n");
561 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
&& pDevice
->bEnableHostapd
) {
562 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Can't set operation mode, hostapd is running \n");
569 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_IBSS_STA
) {
570 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
571 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
572 pDevice
->bCommit
= TRUE
;
575 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to ad-hoc \n");
579 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_ESS_STA
) {
580 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
581 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
582 pDevice
->bCommit
= TRUE
;
585 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to infrastructure \n");
589 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
593 if (pMgmt
->eConfigMode
!= WMAC_CONFIG_AP
) {
594 pMgmt
->eConfigMode
= WMAC_CONFIG_AP
;
595 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
596 pDevice
->bCommit
= TRUE
;
599 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set mode to Access Point \n");
603 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
614 * Wireless Handler : get operation mode
617 int iwctl_giwmode(struct net_device
*dev
,
618 struct iw_request_info
*info
,
622 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
623 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
626 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWMODE \n");
627 // If not managed, assume it's ad-hoc
628 switch (pMgmt
->eConfigMode
) {
629 case WMAC_CONFIG_ESS_STA
:
630 *wmode
= IW_MODE_INFRA
;
632 case WMAC_CONFIG_IBSS_STA
:
633 *wmode
= IW_MODE_ADHOC
;
635 case WMAC_CONFIG_AUTO
:
636 *wmode
= IW_MODE_INFRA
;
639 *wmode
= IW_MODE_MASTER
;
642 *wmode
= IW_MODE_ADHOC
;
650 * Wireless Handler : get capability range
653 int iwctl_giwrange(struct net_device
*dev
,
654 struct iw_request_info
*info
,
655 struct iw_point
*wrq
,
658 struct iw_range
*range
= (struct iw_range
*) extra
;
660 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
661 //2008-0409-02, <Mark> by Einsn Liu
664 PSDevice pDevice = (PSDevice)netdev_priv(dev);
665 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
670 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRANGE \n");
672 wrq
->length
= sizeof(struct iw_range
);
673 memset(range
, 0, sizeof(struct iw_range
));
674 range
->min_nwid
= 0x0000;
675 range
->max_nwid
= 0x0000;
676 range
->num_channels
= 14;
677 // Should be based on cap_rid.country to give only
678 // what the current card support
680 for(i
= 0; i
< 14; i
++) {
681 range
->freq
[k
].i
= i
+ 1; // List index
682 range
->freq
[k
].m
= frequency_list
[i
] * 100000;
683 range
->freq
[k
++].e
= 1; // Values in table in MHz -> * 10^5 * 10
685 range
->num_frequency
= k
;
686 // Hum... Should put the right values there
687 #ifdef Calcu_LinkQual
688 range
->max_qual
.qual
= 100;
690 range
->max_qual
.qual
= 255;
692 range
->max_qual
.level
= 0;
693 range
->max_qual
.noise
= 0;
694 range
->sensitivity
= 255;
696 for(i
= 0 ; i
< 13 ; i
++) {
697 range
->bitrate
[i
] = abySupportedRates
[i
] * 500000;
698 if(range
->bitrate
[i
] == 0)
701 range
->num_bitrates
= i
;
703 // Set an indication of the max TCP throughput
704 // in bit/s that we can expect using this interface.
705 // May be use for QoS stuff... Jean II
707 range
->throughput
= 5 * 1000 * 1000;
709 range
->throughput
= 1.5 * 1000 * 1000;
712 range
->max_rts
= 2312;
713 range
->min_frag
= 256;
714 range
->max_frag
= 2312;
717 // the encoding capabilities
718 range
->num_encoding_sizes
= 3;
720 range
->encoding_size
[0] = 5;
722 range
->encoding_size
[1] = 13;
723 // 256 bits for WPA-PSK
724 range
->encoding_size
[2] = 32;
725 // 4 keys are allowed
726 range
->max_encoding_tokens
= 4;
728 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
729 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
732 range
->max_pmp
= 1000000;// 1 secs
734 range
->max_pmt
= 1000000;// 1 secs
735 range
->pmp_flags
= IW_POWER_PERIOD
;
736 range
->pmt_flags
= IW_POWER_TIMEOUT
;
737 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
| IW_POWER_ALL_R
;
739 // Transmit Power - values are in mW
741 range
->txpower
[0] = 100;
742 range
->num_txpower
= 1;
743 range
->txpower_capa
= IW_TXPOW_MWATT
;
744 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
745 range
->we_version_compiled
= WIRELESS_EXT
;
746 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
747 range
->retry_flags
= IW_RETRY_LIMIT
;
748 range
->r_time_flags
= IW_RETRY_LIFETIME
;
749 range
->min_retry
= 1;
750 range
->max_retry
= 65535;
751 range
->min_r_time
= 1024;
752 range
->max_r_time
= 65535 * 1024;
753 // Experimental measurements - boundary 11/5.5 Mb/s
754 // Note : with or without the (local->rssi), results
755 // are somewhat different. - Jean II
756 range
->avg_qual
.qual
= 6;
757 range
->avg_qual
.level
= 176; // -80 dBm
758 range
->avg_qual
.noise
= 0;
767 * Wireless Handler : set ap mac address
770 int iwctl_siwap(struct net_device
*dev
,
771 struct iw_request_info
*info
,
772 struct sockaddr
*wrq
,
775 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
776 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
778 BYTE ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
780 PRINT_K(" SIOCSIWAP \n");
782 if (wrq
->sa_family
!= ARPHRD_ETHER
)
785 memset(pMgmt
->abyDesireBSSID
, 0xFF, 6);
786 memcpy(pMgmt
->abyDesireBSSID
, wrq
->sa_data
, 6);
789 if ((IS_BROADCAST_ADDRESS(pMgmt
->abyDesireBSSID
)) ||
790 (memcmp(pMgmt
->abyDesireBSSID
, ZeroBSSID
, 6) == 0)){
791 PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
794 //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
795 // then ignore,because you don't known which one to be connect with??
797 UINT ii
, uSameBssidNum
=0;
798 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
799 if (pMgmt
->sBSSList
[ii
].bActive
&&
800 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
,pMgmt
->abyDesireBSSID
)) {
804 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
805 PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
810 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
811 pDevice
->bCommit
= TRUE
;
818 * Wireless Handler : get ap mac address
821 int iwctl_giwap(struct net_device
*dev
,
822 struct iw_request_info
*info
,
823 struct sockaddr
*wrq
,
826 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
827 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
830 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAP \n");
832 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
834 //20080123-02,<Modify> by Einsn Liu
835 if ((pDevice
->bLinkPass
== FALSE
) && (pMgmt
->eCurrMode
!= WMAC_MODE_ESS_AP
))
836 // if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode == WMAC_MODE_ESS_STA))
837 memset(wrq
->sa_data
, 0, 6);
839 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
840 memcpy(wrq
->sa_data
, pMgmt
->abyCurrBSSID
, 6);
843 wrq
->sa_family
= ARPHRD_ETHER
;
851 * Wireless Handler : get ap list
854 int iwctl_giwaplist(struct net_device
*dev
,
855 struct iw_request_info
*info
,
856 struct iw_point
*wrq
,
860 struct sockaddr sock
[IW_MAX_AP
];
861 struct iw_quality qual
[IW_MAX_AP
];
862 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
863 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
866 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWAPLIST \n");
867 // Only super-user can see AP list
869 if (!capable(CAP_NET_ADMIN
)) {
876 PKnownBSS pBSS
= &(pMgmt
->sBSSList
[0]);
878 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
879 pBSS
= &(pMgmt
->sBSSList
[ii
]);
882 if ( jj
>= IW_MAX_AP
)
884 memcpy(sock
[jj
].sa_data
, pBSS
->abyBSSID
, 6);
885 sock
[jj
].sa_family
= ARPHRD_ETHER
;
886 qual
[jj
].level
= pBSS
->uRSSI
;
887 qual
[jj
].qual
= qual
[jj
].noise
= 0;
888 qual
[jj
].updated
= 2;
892 wrq
->flags
= 1; // Should be define'd
894 memcpy(extra
, sock
, sizeof(struct sockaddr
)*jj
);
895 memcpy(extra
+ sizeof(struct sockaddr
)*jj
, qual
, sizeof(struct iw_quality
)*jj
);
903 * Wireless Handler : set essid
906 int iwctl_siwessid(struct net_device
*dev
,
907 struct iw_request_info
*info
,
908 struct iw_point
*wrq
,
911 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
912 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
913 PWLAN_IE_SSID pItemSSID
;
915 //2008-0920-01<Add>by MikeLiu
916 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
))
919 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWESSID :\n");
921 pDevice
->fWPA_Authened
= FALSE
;
922 // Check if we asked for `any'
923 if(wrq
->flags
== 0) {
924 // Just send an empty SSID list
925 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
926 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
927 PRINT_K("set essid to 'any' \n");
928 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
929 //Unknown desired AP,so here need not associate??
934 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
935 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
936 pItemSSID
->byElementID
= WLAN_EID_SSID
;
938 memcpy(pItemSSID
->abySSID
, extra
, wrq
->length
);
939 if (pItemSSID
->abySSID
[wrq
->length
- 1] == '\0') {
941 pItemSSID
->len
= wrq
->length
- 1;
944 pItemSSID
->len
= wrq
->length
;
945 PRINT_K("set essid to %s \n",pItemSSID
->abySSID
);
947 //mike:need clear desiredBSSID
948 if(pItemSSID
->len
==0) {
949 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
953 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
954 //Wext wil order another command of siwap to link with desired AP,
955 //so here need not associate??
956 if(pDevice
->bWPASuppWextEnabled
== TRUE
) {
957 /*******search if in hidden ssid mode ****/
959 PKnownBSS pCurr
= NULL
;
960 BYTE abyTmpDesireSSID
[WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1];
961 UINT ii
, uSameBssidNum
=0;
963 memset(abyTmpDesireSSID
,0,sizeof(abyTmpDesireSSID
));
964 memcpy(abyTmpDesireSSID
,pMgmt
->abyDesireSSID
,sizeof(abyTmpDesireSSID
));
965 pCurr
= BSSpSearchBSSList(pDevice
,
968 pDevice
->eConfigPHYMode
972 PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
973 vResetCommandTimer((HANDLE
) pDevice
);
974 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
975 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
976 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
978 else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
979 // by means of judging if there are two same BSSID exist in list ?
980 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
981 if (pMgmt
->sBSSList
[ii
].bActive
&&
982 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
, pCurr
->abyBSSID
)) {
986 if(uSameBssidNum
>= 2) { //hit: desired AP is in hidden ssid mode!!!
987 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
988 vResetCommandTimer((HANDLE
) pDevice
);
989 pMgmt
->eScanType
= WMAC_SCAN_PASSIVE
; //this scan type,you'll submit scan result!
990 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
991 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
999 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"set essid = %s \n", pItemSSID
->abySSID
);
1002 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1003 pDevice
->bCommit
= TRUE
;
1012 * Wireless Handler : get essid
1015 int iwctl_giwessid(struct net_device
*dev
,
1016 struct iw_request_info
*info
,
1017 struct iw_point
*wrq
,
1021 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1022 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1023 PWLAN_IE_SSID pItemSSID
;
1025 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWESSID \n");
1027 // Note : if wrq->u.data.flags != 0, we should
1028 // get the relevant SSID from the SSID list...
1030 // Get the current SSID
1031 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
1032 //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
1033 memcpy(extra
, pItemSSID
->abySSID
, pItemSSID
->len
);
1034 extra
[pItemSSID
->len
] = '\0';
1035 //2008-0409-03, <Add> by Einsn Liu
1036 wrq
->length
= pItemSSID
->len
;
1037 wrq
->flags
= 1; // active
1044 * Wireless Handler : set data rate
1047 int iwctl_siwrate(struct net_device
*dev
,
1048 struct iw_request_info
*info
,
1049 struct iw_param
*wrq
,
1052 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1056 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1059 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRATE \n");
1060 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1065 // First : get a valid bit rate value
1067 // Which type of value
1068 if((wrq
->value
< 13) &&
1069 (wrq
->value
>= 0)) {
1070 // Setting by rate index
1071 // Find value in the magic rate table
1074 // Setting by frequency value
1075 u8 normvalue
= (u8
) (wrq
->value
/500000);
1077 // Check if rate is valid
1078 for(i
= 0 ; i
< 13 ; i
++) {
1079 if(normvalue
== abySupportedRates
[i
]) {
1085 // -1 designed the max rate (mostly auto mode)
1086 if(wrq
->value
== -1) {
1087 // Get the highest available rate
1088 for(i
= 0 ; i
< 13 ; i
++) {
1089 if(abySupportedRates
[i
] == 0)
1096 // Check that it is valid
1097 // brate is index of abySupportedRates[]
1103 // Now, check if we want a fixed or auto value
1104 if(wrq
->fixed
!= 0) {
1107 pDevice
->bFixRate
= TRUE
;
1108 if ((pDevice
->byBBType
== BB_TYPE_11B
)&& (brate
> 3)) {
1109 pDevice
->uConnectionRate
= 3;
1112 pDevice
->uConnectionRate
= brate
;
1113 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fixed to Rate %d \n", pDevice
->uConnectionRate
);
1118 pDevice
->bFixRate
= FALSE
;
1119 pDevice
->uConnectionRate
= 13;
1126 * Wireless Handler : get data rate
1129 int iwctl_giwrate(struct net_device
*dev
,
1130 struct iw_request_info
*info
,
1131 struct iw_param
*wrq
,
1134 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1135 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1137 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRATE \n");
1139 BYTE abySupportedRates
[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
1141 if (pDevice
->uConnectionRate
< 13) {
1142 brate
= abySupportedRates
[pDevice
->uConnectionRate
];
1144 if (pDevice
->byBBType
== BB_TYPE_11B
)
1146 if (pDevice
->byBBType
== BB_TYPE_11G
)
1148 if (pDevice
->byBBType
== BB_TYPE_11A
)
1152 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
1153 if (pDevice
->byBBType
== BB_TYPE_11B
)
1155 if (pDevice
->byBBType
== BB_TYPE_11G
)
1157 if (pDevice
->byBBType
== BB_TYPE_11A
)
1160 if (pDevice
->uConnectionRate
== 13)
1161 brate
= abySupportedRates
[pDevice
->wCurrentRate
];
1162 wrq
->value
= brate
* 500000;
1163 // If more than one rate, set auto
1164 if (pDevice
->bFixRate
== TRUE
)
1175 * Wireless Handler : set rts threshold
1178 int iwctl_siwrts(struct net_device
*dev
,
1179 struct iw_request_info
*info
,
1180 struct iw_param
*wrq
,
1183 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1186 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRTS \n");
1189 int rthr
= wrq
->value
;
1192 if((rthr
< 0) || (rthr
> 2312)) {
1195 pDevice
->wRTSThreshold
= rthr
;
1203 * Wireless Handler : get rts
1206 int iwctl_giwrts(struct net_device
*dev
,
1207 struct iw_request_info
*info
,
1208 struct iw_param
*wrq
,
1211 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1213 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRTS \n");
1214 wrq
->value
= pDevice
->wRTSThreshold
;
1215 wrq
->disabled
= (wrq
->value
>= 2312);
1222 * Wireless Handler : set fragment threshold
1225 int iwctl_siwfrag(struct net_device
*dev
,
1226 struct iw_request_info
*info
,
1227 struct iw_param
*wrq
,
1230 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1232 int fthr
= wrq
->value
;
1235 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWFRAG \n");
1240 if((fthr
< 256) || (fthr
> 2312)) {
1243 fthr
&= ~0x1; // Get an even value
1244 pDevice
->wFragmentationThreshold
= (u16
)fthr
;
1251 * Wireless Handler : get fragment threshold
1254 int iwctl_giwfrag(struct net_device
*dev
,
1255 struct iw_request_info
*info
,
1256 struct iw_param
*wrq
,
1259 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1261 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWFRAG \n");
1262 wrq
->value
= pDevice
->wFragmentationThreshold
;
1263 wrq
->disabled
= (wrq
->value
>= 2312);
1272 * Wireless Handler : set retry threshold
1274 int iwctl_siwretry(struct net_device
*dev
,
1275 struct iw_request_info
*info
,
1276 struct iw_param
*wrq
,
1279 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1283 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWRETRY \n");
1285 if (wrq
->disabled
) {
1290 if (wrq
->flags
& IW_RETRY_LIMIT
) {
1291 if(wrq
->flags
& IW_RETRY_MAX
)
1292 pDevice
->byLongRetryLimit
= wrq
->value
;
1293 else if (wrq
->flags
& IW_RETRY_MIN
)
1294 pDevice
->byShortRetryLimit
= wrq
->value
;
1296 // No modifier : set both
1297 pDevice
->byShortRetryLimit
= wrq
->value
;
1298 pDevice
->byLongRetryLimit
= wrq
->value
;
1301 if (wrq
->flags
& IW_RETRY_LIFETIME
) {
1302 pDevice
->wMaxTransmitMSDULifetime
= wrq
->value
;
1310 * Wireless Handler : get retry threshold
1312 int iwctl_giwretry(struct net_device
*dev
,
1313 struct iw_request_info
*info
,
1314 struct iw_param
*wrq
,
1317 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1318 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWRETRY \n");
1319 wrq
->disabled
= 0; // Can't be disabled
1321 // Note : by default, display the min retry number
1322 if((wrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1323 wrq
->flags
= IW_RETRY_LIFETIME
;
1324 wrq
->value
= (int)pDevice
->wMaxTransmitMSDULifetime
; //ms
1325 } else if((wrq
->flags
& IW_RETRY_MAX
)) {
1326 wrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
1327 wrq
->value
= (int)pDevice
->byLongRetryLimit
;
1329 wrq
->flags
= IW_RETRY_LIMIT
;
1330 wrq
->value
= (int)pDevice
->byShortRetryLimit
;
1331 if((int)pDevice
->byShortRetryLimit
!= (int)pDevice
->byLongRetryLimit
)
1332 wrq
->flags
|= IW_RETRY_MIN
;
1341 * Wireless Handler : set encode mode
1343 int iwctl_siwencode(struct net_device
*dev
,
1344 struct iw_request_info
*info
,
1345 struct iw_point
*wrq
,
1348 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1349 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1350 DWORD dwKeyIndex
= (DWORD
)(wrq
->flags
& IW_ENCODE_INDEX
);
1352 int index
= (wrq
->flags
& IW_ENCODE_INDEX
);
1355 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWENCODE \n");
1357 // Check the size of the key
1358 if (wrq
->length
> WLAN_WEP232_KEYLEN
) {
1363 if (dwKeyIndex
> WLAN_WEP_NKEYS
) {
1371 // Send the key to the card
1372 if (wrq
->length
> 0) {
1374 if (wrq
->length
== WLAN_WEP232_KEYLEN
) {
1375 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 232 bit wep key\n");
1377 else if (wrq
->length
== WLAN_WEP104_KEYLEN
) {
1378 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 104 bit wep key\n");
1380 else if (wrq
->length
== WLAN_WEP40_KEYLEN
) {
1381 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set 40 bit wep key, index= %d\n", (int)dwKeyIndex
);
1383 memset(pDevice
->abyKey
, 0, WLAN_WEP232_KEYLEN
);
1384 memcpy(pDevice
->abyKey
, extra
, wrq
->length
);
1386 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyKey: ");
1387 for (ii
= 0; ii
< wrq
->length
; ii
++) {
1388 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02x ", pDevice
->abyKey
[ii
]);
1391 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1392 spin_lock_irq(&pDevice
->lock
);
1393 KeybSetDefaultKey( pDevice
,
1395 dwKeyIndex
| (1 << 31),
1401 spin_unlock_irq(&pDevice
->lock
);
1403 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
1404 pDevice
->uKeyLength
= wrq
->length
;
1405 pDevice
->bTransmitKey
= TRUE
;
1406 pDevice
->bEncryptionEnable
= TRUE
;
1407 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1409 // Do we want to just set the transmit key index ?
1411 pDevice
->byKeyIndex
= index
;
1413 else if(!wrq
->flags
& IW_ENCODE_MODE
) {
1419 if(wrq
->flags
& IW_ENCODE_DISABLED
){
1421 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Disable WEP function\n");
1422 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1423 pDevice
->bEncryptionEnable
= FALSE
;
1424 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1425 if (pDevice
->flags
& DEVICE_FLAGS_OPENED
) {
1426 spin_lock_irq(&pDevice
->lock
);
1427 for(uu
=0;uu
<MAX_KEY_TABLE
;uu
++)
1428 MACvDisableKeyEntry(pDevice
,uu
);
1429 spin_unlock_irq(&pDevice
->lock
);
1432 if(wrq
->flags
& IW_ENCODE_RESTRICTED
) {
1433 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & ShareKey System\n");
1434 pMgmt
->bShareKeyAlgorithm
= TRUE
;
1436 if(wrq
->flags
& IW_ENCODE_OPEN
) {
1437 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Enable WEP & Open System\n");
1438 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1441 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1442 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
1449 * Wireless Handler : get encode mode
1451 //2008-0409-06, <Mark> by Einsn Liu
1453 int iwctl_giwencode(struct net_device *dev,
1454 struct iw_request_info *info,
1455 struct iw_point *wrq,
1458 PSDevice pDevice = (PSDevice)netdev_priv(dev);
1459 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1461 char abyKey[WLAN_WEP232_KEYLEN];
1462 UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);
1463 PSKeyItem pKey = NULL;
1465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
1468 memset(abyKey, 0, sizeof(abyKey));
1469 // Check encryption mode
1470 wrq->flags = IW_ENCODE_NOKEY;
1471 // Is WEP enabled ???
1472 if (pDevice->bEncryptionEnable)
1473 wrq->flags |= IW_ENCODE_ENABLED;
1475 wrq->flags |= IW_ENCODE_DISABLED;
1477 if (pMgmt->bShareKeyAlgorithm)
1478 wrq->flags |= IW_ENCODE_RESTRICTED;
1480 wrq->flags |= IW_ENCODE_OPEN;
1482 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
1483 wrq->length = pKey->uKeyLength;
1484 memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
1490 wrq->flags |= index;
1491 // Copy the key to the user buffer
1492 memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
1497 //2008-0409-06, <Add> by Einsn Liu
1499 int iwctl_giwencode(struct net_device
*dev
,
1500 struct iw_request_info
*info
,
1501 struct iw_point
*wrq
,
1504 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1505 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1506 char abyKey
[WLAN_WEP232_KEYLEN
];
1508 UINT index
= (UINT
)(wrq
->flags
& IW_ENCODE_INDEX
);
1509 PSKeyItem pKey
= NULL
;
1511 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWENCODE\n");
1513 if (index
> WLAN_WEP_NKEYS
) {
1516 if(index
<1){//get default key
1517 if(pDevice
->byKeyIndex
<WLAN_WEP_NKEYS
){
1518 index
=pDevice
->byKeyIndex
;
1524 memset(abyKey
, 0, WLAN_WEP232_KEYLEN
);
1525 // Check encryption mode
1526 wrq
->flags
= IW_ENCODE_NOKEY
;
1527 // Is WEP enabled ???
1528 if (pDevice
->bEncryptionEnable
)
1529 wrq
->flags
|= IW_ENCODE_ENABLED
;
1531 wrq
->flags
|= IW_ENCODE_DISABLED
;
1533 if (pMgmt
->bShareKeyAlgorithm
)
1534 wrq
->flags
|= IW_ENCODE_RESTRICTED
;
1536 wrq
->flags
|= IW_ENCODE_OPEN
;
1539 if((index
==0)&&(pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
||
1540 pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)){//get wpa pairwise key
1541 if (KeybGetKey(&(pDevice
->sKey
),pMgmt
->abyCurrBSSID
, 0xffffffff, &pKey
)){
1542 wrq
->length
= pKey
->uKeyLength
;
1543 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1544 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1546 }else if (KeybGetKey(&(pDevice
->sKey
), pDevice
->abyBroadcastAddr
, (BYTE
)index
, &pKey
)){
1547 wrq
->length
= pKey
->uKeyLength
;
1548 memcpy(abyKey
, pKey
->abyKey
, pKey
->uKeyLength
);
1549 memcpy(extra
, abyKey
, WLAN_WEP232_KEYLEN
);
1552 wrq
->flags
|= index
+1;
1559 * Wireless Handler : set power mode
1561 int iwctl_siwpower(struct net_device
*dev
,
1562 struct iw_request_info
*info
,
1563 struct iw_param
*wrq
,
1566 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1567 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1570 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER \n");
1572 if (!(pDevice
->flags
& DEVICE_FLAGS_OPENED
)) {
1577 if (wrq
->disabled
) {
1578 pDevice
->ePSMode
= WMAC_POWER_CAM
;
1579 PSvDisablePowerSaving(pDevice
);
1582 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1583 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1584 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1586 } else if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
1587 pDevice
->ePSMode
= WMAC_POWER_FAST
;
1588 PSvEnablePowerSaving((HANDLE
)pDevice
, pMgmt
->wListenInterval
);
1590 switch (wrq
->flags
& IW_POWER_MODE
) {
1591 case IW_POWER_UNICAST_R
:
1592 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
1595 case IW_POWER_ALL_R
:
1596 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ALL_R \n");
1599 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWPOWER: IW_POWER_ON \n");
1609 * Wireless Handler : get power mode
1611 int iwctl_giwpower(struct net_device
*dev
,
1612 struct iw_request_info
*info
,
1613 struct iw_param
*wrq
,
1616 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1617 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1618 int mode
= pDevice
->ePSMode
;
1621 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWPOWER \n");
1624 if ((wrq
->disabled
= (mode
== WMAC_POWER_CAM
)))
1627 if ((wrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1628 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1629 wrq
->flags
= IW_POWER_TIMEOUT
;
1631 wrq
->value
= (int)((pMgmt
->wListenInterval
* pMgmt
->wCurrBeaconPeriod
) << 10);
1632 wrq
->flags
= IW_POWER_PERIOD
;
1634 wrq
->flags
|= IW_POWER_ALL_R
;
1641 * Wireless Handler : get Sensitivity
1643 int iwctl_giwsens(struct net_device
*dev
,
1644 struct iw_request_info
*info
,
1645 struct iw_param
*wrq
,
1648 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1651 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCGIWSENS \n");
1652 if (pDevice
->bLinkPass
== TRUE
) {
1653 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
1659 wrq
->disabled
= (wrq
->value
== 0);
1666 //2008-0409-07, <Add> by Einsn Liu
1667 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1669 int iwctl_siwauth(struct net_device
*dev
,
1670 struct iw_request_info
*info
,
1671 struct iw_param
*wrq
,
1674 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1675 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1677 static int wpa_version
=0; //must be static to save the last value,einsn liu
1678 static int pairwise
=0;
1680 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" SIOCSIWAUTH \n");
1681 switch (wrq
->flags
& IW_AUTH_INDEX
) {
1682 case IW_AUTH_WPA_VERSION
:
1683 wpa_version
= wrq
->value
;
1684 if(wrq
->value
== IW_AUTH_WPA_VERSION_DISABLED
) {
1685 PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
1686 //pDevice->bWPADEVUp = FALSE;
1688 else if(wrq
->value
== IW_AUTH_WPA_VERSION_WPA
) {
1689 PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
1692 PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
1694 //pDevice->bWPASuppWextEnabled =TRUE;
1696 case IW_AUTH_CIPHER_PAIRWISE
:
1697 pairwise
= wrq
->value
;
1698 PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise
);
1699 if(pairwise
== IW_AUTH_CIPHER_CCMP
){
1700 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1701 }else if(pairwise
== IW_AUTH_CIPHER_TKIP
){
1702 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1703 }else if(pairwise
== IW_AUTH_CIPHER_WEP40
||pairwise
== IW_AUTH_CIPHER_WEP104
){
1704 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
1705 }else if(pairwise
== IW_AUTH_CIPHER_NONE
){
1706 //do nothing,einsn liu
1707 }else pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1710 case IW_AUTH_CIPHER_GROUP
:
1711 PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq
->value
);
1712 if(wpa_version
== IW_AUTH_WPA_VERSION_DISABLED
)
1714 if(pairwise
== IW_AUTH_CIPHER_NONE
){
1715 if(wrq
->value
== IW_AUTH_CIPHER_CCMP
){
1716 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
1718 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
1722 case IW_AUTH_KEY_MGMT
:
1723 PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version
,wrq
->value
);
1724 if(wpa_version
== IW_AUTH_WPA_VERSION_WPA2
){
1725 if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1726 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
1727 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
1728 }else if(wpa_version
== IW_AUTH_WPA_VERSION_WPA
){
1729 if(wrq
->value
== 0){
1730 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
1731 }else if(wrq
->value
== IW_AUTH_KEY_MGMT_PSK
)
1732 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
1733 else pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
1737 case IW_AUTH_TKIP_COUNTERMEASURES
:
1739 case IW_AUTH_DROP_UNENCRYPTED
:
1741 case IW_AUTH_80211_AUTH_ALG
:
1742 PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq
->value
);
1743 if(wrq
->value
==IW_AUTH_ALG_OPEN_SYSTEM
){
1744 pMgmt
->bShareKeyAlgorithm
=FALSE
;
1745 }else if(wrq
->value
==IW_AUTH_ALG_SHARED_KEY
){
1746 pMgmt
->bShareKeyAlgorithm
=TRUE
;
1749 case IW_AUTH_WPA_ENABLED
:
1750 //pDevice->bWPADEVUp = !! wrq->value;
1751 //if(pDevice->bWPADEVUp==TRUE)
1752 // printk("iwctl_siwauth:set WPADEV to enable sucessful*******\n");
1754 // printk("iwctl_siwauth:set WPADEV to enable fail?????\n");
1756 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1758 case IW_AUTH_ROAMING_CONTROL
:
1761 case IW_AUTH_PRIVACY_INVOKED
:
1762 pDevice
->bEncryptionEnable
= !!wrq
->value
;
1763 if(pDevice
->bEncryptionEnable
== FALSE
){
1766 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
1767 pMgmt
->bShareKeyAlgorithm
= FALSE
;
1768 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
1769 //pDevice->bWPADEVUp = FALSE;
1770 PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
1779 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
1780 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
1781 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
1782 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
1783 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");
1784 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");
1785 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADEVUp = %s\n",pDevice->bWPADEVUp?"TRUE":"FALSE");
1791 int iwctl_giwauth(struct net_device
*dev
,
1792 struct iw_request_info
*info
,
1793 struct iw_param
*wrq
,
1801 int iwctl_siwgenie(struct net_device
*dev
,
1802 struct iw_request_info
*info
,
1803 struct iw_point
*wrq
,
1806 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1807 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1811 if ((wrq
->length
< 2) || (extra
[1]+2 != wrq
->length
)) {
1815 if(wrq
->length
> MAX_WPA_IE_LEN
){
1819 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1820 if(copy_from_user(pMgmt
->abyWPAIE
, extra
, wrq
->length
)){
1824 pMgmt
->wWPAIELen
= wrq
->length
;
1826 memset(pMgmt
->abyWPAIE
, 0, MAX_WPA_IE_LEN
);
1827 pMgmt
->wWPAIELen
= 0;
1830 out
://not completely ...not necessary in wpa_supplicant 0.5.8
1834 int iwctl_giwgenie(struct net_device
*dev
,
1835 struct iw_request_info
*info
,
1836 struct iw_point
*wrq
,
1839 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1840 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1842 int space
= wrq
->length
;
1845 if(pMgmt
->wWPAIELen
> 0){
1846 wrq
->length
= pMgmt
->wWPAIELen
;
1847 if(pMgmt
->wWPAIELen
<= space
){
1848 if(copy_to_user(extra
, pMgmt
->abyWPAIE
, pMgmt
->wWPAIELen
)){
1859 int iwctl_siwencodeext(struct net_device
*dev
,
1860 struct iw_request_info
*info
,
1861 struct iw_point
*wrq
,
1864 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
1865 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1866 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1867 struct viawget_wpa_param
*param
=NULL
;
1871 int key_idx
, set_tx
=0;
1872 u8 seq
[IW_ENCODE_SEQ_MAX_SIZE
];
1874 size_t seq_len
=0,key_len
=0;
1882 PRINT_K("SIOCSIWENCODEEXT...... \n");
1884 blen
= sizeof(*param
);
1885 buf
= kmalloc((int)blen
, (int)GFP_KERNEL
);
1888 memset(buf
, 0, blen
);
1889 param
= (struct viawget_wpa_param
*) buf
;
1893 case IW_ENCODE_ALG_NONE
:
1894 alg_name
= WPA_ALG_NONE
;
1896 case IW_ENCODE_ALG_WEP
:
1897 alg_name
= WPA_ALG_WEP
;
1899 case IW_ENCODE_ALG_TKIP
:
1900 alg_name
= WPA_ALG_TKIP
;
1902 case IW_ENCODE_ALG_CCMP
:
1903 alg_name
= WPA_ALG_CCMP
;
1906 PRINT_K("Unknown alg = %d\n",ext
->alg
);
1911 memcpy(addr
, ext
->addr
.sa_data
, ETH_ALEN
);
1913 key_idx
= (wrq
->flags
&IW_ENCODE_INDEX
) - 1;
1915 if(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1917 //recover seq,seq_len
1918 if(ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
1919 seq_len
=IW_ENCODE_SEQ_MAX_SIZE
;
1920 memcpy(seq
, ext
->rx_seq
, seq_len
);
1922 //recover key,key_len
1924 key_len
=ext
->key_len
;
1925 memcpy(key
, &ext
->key
[0], key_len
);
1928 memset(key_array
, 0, 64);
1930 memcpy(key_array
, key
, key_len
);
1931 if (key_len
== 32) {
1932 // notice ! the oder
1933 memcpy(&key_array
[16], &key
[24], 8);
1934 memcpy(&key_array
[24], &key
[16], 8);
1938 /**************Translate iw_encode_ext to viawget_wpa_param****************/
1939 memcpy(param
->addr
, addr
, ETH_ALEN
);
1940 param
->u
.wpa_key
.alg_name
= (int)alg_name
;
1941 param
->u
.wpa_key
.set_tx
= set_tx
;
1942 param
->u
.wpa_key
.key_index
= key_idx
;
1943 param
->u
.wpa_key
.key_len
= key_len
;
1944 param
->u
.wpa_key
.key
= (u8
*)key_array
;
1945 param
->u
.wpa_key
.seq
= (u8
*)seq
;
1946 param
->u
.wpa_key
.seq_len
= seq_len
;
1949 printk("param->u.wpa_key.alg_name =%d\n",param
->u
.wpa_key
.alg_name
);
1950 printk("param->addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
1951 param
->addr
[0],param
->addr
[1],param
->addr
[2],
1952 param
->addr
[3],param
->addr
[4],param
->addr
[5]);
1953 printk("param->u.wpa_key.set_tx =%d\n",param
->u
.wpa_key
.set_tx
);
1954 printk("param->u.wpa_key.key_index =%d\n",param
->u
.wpa_key
.key_index
);
1955 printk("param->u.wpa_key.key_len =%d\n",param
->u
.wpa_key
.key_len
);
1956 printk("param->u.wpa_key.key =");
1957 for(ii
=0;ii
<param
->u
.wpa_key
.key_len
;ii
++)
1958 printk("%02x:",param
->u
.wpa_key
.key
[ii
]);
1960 printk("param->u.wpa_key.seq_len =%d\n",param
->u
.wpa_key
.seq_len
);
1961 printk("param->u.wpa_key.seq =");
1962 for(ii
=0;ii
<param
->u
.wpa_key
.seq_len
;ii
++)
1963 printk("%02x:",param
->u
.wpa_key
.seq
[ii
]);
1966 printk("...........\n");
1968 //****set if current action is Network Manager count??
1969 //****this method is so foolish,but there is no other way???
1970 if(param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
1971 if(param
->u
.wpa_key
.key_index
==0) {
1972 pDevice
->bwextstep0
= TRUE
;
1974 if((pDevice
->bwextstep0
= TRUE
)&&(param
->u
.wpa_key
.key_index
==1)) {
1975 pDevice
->bwextstep0
= FALSE
;
1976 pDevice
->bwextstep1
= TRUE
;
1978 if((pDevice
->bwextstep1
= TRUE
)&&(param
->u
.wpa_key
.key_index
==2)) {
1979 pDevice
->bwextstep1
= FALSE
;
1980 pDevice
->bwextstep2
= TRUE
;
1982 if((pDevice
->bwextstep2
= TRUE
)&&(param
->u
.wpa_key
.key_index
==3)) {
1983 pDevice
->bwextstep2
= FALSE
;
1984 pDevice
->bwextstep3
= TRUE
;
1987 if(pDevice
->bwextstep3
== TRUE
) {
1988 PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
1989 pDevice
->bwextstep0
= FALSE
;
1990 pDevice
->bwextstep1
= FALSE
;
1991 pDevice
->bwextstep2
= FALSE
;
1992 pDevice
->bwextstep3
= FALSE
;
1993 pDevice
->bWPASuppWextEnabled
= TRUE
;
1994 memset(pMgmt
->abyDesireBSSID
, 0xFF,6);
1995 KeyvInitTable(pDevice
,&pDevice
->sKey
);
1999 spin_lock_irq(&pDevice
->lock
);
2000 ret
= wpa_set_keys(pDevice
, param
, TRUE
);
2001 spin_unlock_irq(&pDevice
->lock
);
2010 int iwctl_giwencodeext(struct net_device
*dev
,
2011 struct iw_request_info
*info
,
2012 struct iw_point
*wrq
,
2015 return -EOPNOTSUPP
;;
2018 int iwctl_siwmlme(struct net_device
*dev
,
2019 struct iw_request_info
* info
,
2020 struct iw_point
*wrq
,
2023 PSDevice pDevice
= (PSDevice
)netdev_priv(dev
);
2024 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
2025 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2026 //u16 reason = cpu_to_le16(mlme->reason_code);
2029 if(memcmp(pMgmt
->abyCurrBSSID
, mlme
->addr
.sa_data
, ETH_ALEN
)){
2034 case IW_MLME_DEAUTH
:
2035 //this command seems to be not complete,please test it --einsnliu
2036 //printk("iwctl_siwmlme--->send DEAUTH\n");
2037 //bScheduleCommand((HANDLE) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason);
2039 case IW_MLME_DISASSOC
:
2040 if(pDevice
->bLinkPass
== TRUE
){
2041 PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
2042 bScheduleCommand((HANDLE
)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
2054 //End Add --//2008-0409-07, <Add> by Einsn Liu
2058 /*------------------------------------------------------------------*/
2060 * Structures to export the Wireless Handlers
2065 static const iw_handler iwctl_handler[] =
2067 (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
2068 (iw_handler) iwctl_giwname, // SIOCGIWNAME
2069 (iw_handler) NULL, // SIOCSIWNWID
2070 (iw_handler) NULL, // SIOCGIWNWID
2071 (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
2072 (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
2073 (iw_handler) iwctl_siwmode, // SIOCSIWMODE
2074 (iw_handler) iwctl_giwmode, // SIOCGIWMODE
2075 (iw_handler) NULL, // SIOCSIWSENS
2076 (iw_handler) iwctl_giwsens, // SIOCGIWSENS
2077 (iw_handler) NULL, // SIOCSIWRANGE
2078 (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
2079 (iw_handler) NULL, // SIOCSIWPRIV
2080 (iw_handler) NULL, // SIOCGIWPRIV
2081 (iw_handler) NULL, // SIOCSIWSTATS
2082 (iw_handler) NULL, // SIOCGIWSTATS
2083 (iw_handler) NULL, // SIOCSIWSPY
2084 (iw_handler) NULL, // SIOCGIWSPY
2085 (iw_handler) NULL, // -- hole --
2086 (iw_handler) NULL, // -- hole --
2087 (iw_handler) iwctl_siwap, // SIOCSIWAP
2088 (iw_handler) iwctl_giwap, // SIOCGIWAP
2089 (iw_handler) NULL, // -- hole -- 0x16
2090 (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
2091 (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
2092 (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
2093 (iw_handler) iwctl_siwessid, // SIOCSIWESSID
2094 (iw_handler) iwctl_giwessid, // SIOCGIWESSID
2095 (iw_handler) NULL, // SIOCSIWNICKN
2096 (iw_handler) NULL, // SIOCGIWNICKN
2097 (iw_handler) NULL, // -- hole --
2098 (iw_handler) NULL, // -- hole --
2099 (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
2100 (iw_handler) iwctl_giwrate, // SIOCGIWRATE
2101 (iw_handler) iwctl_siwrts, // SIOCSIWRTS
2102 (iw_handler) iwctl_giwrts, // SIOCGIWRTS
2103 (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
2104 (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
2105 (iw_handler) NULL, // SIOCSIWTXPOW
2106 (iw_handler) NULL, // SIOCGIWTXPOW
2107 (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
2108 (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
2109 (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
2110 (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
2111 (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
2112 (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
2113 (iw_handler) NULL, // -- hole --
2114 (iw_handler) NULL, // -- hole --
2115 (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
2116 (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
2117 (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
2118 (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
2119 (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
2120 (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
2121 (iw_handler) NULL, // SIOCSIWPMKSA
2122 (iw_handler) NULL, // -- hole --
2127 static const iw_handler iwctl_handler
[] =
2129 (iw_handler
) iwctl_commit
, // SIOCSIWCOMMIT
2130 (iw_handler
) NULL
, // SIOCGIWNAME
2131 (iw_handler
) NULL
, // SIOCSIWNWID
2132 (iw_handler
) NULL
, // SIOCGIWNWID
2133 (iw_handler
) NULL
, // SIOCSIWFREQ
2134 (iw_handler
) NULL
, // SIOCGIWFREQ
2135 (iw_handler
) NULL
, // SIOCSIWMODE
2136 (iw_handler
) NULL
, // SIOCGIWMODE
2137 (iw_handler
) NULL
, // SIOCSIWSENS
2138 (iw_handler
) NULL
, // SIOCGIWSENS
2139 (iw_handler
) NULL
, // SIOCSIWRANGE
2140 (iw_handler
) iwctl_giwrange
, // SIOCGIWRANGE
2141 (iw_handler
) NULL
, // SIOCSIWPRIV
2142 (iw_handler
) NULL
, // SIOCGIWPRIV
2143 (iw_handler
) NULL
, // SIOCSIWSTATS
2144 (iw_handler
) NULL
, // SIOCGIWSTATS
2145 (iw_handler
) NULL
, // SIOCSIWSPY
2146 (iw_handler
) NULL
, // SIOCGIWSPY
2147 (iw_handler
) NULL
, // -- hole --
2148 (iw_handler
) NULL
, // -- hole --
2149 (iw_handler
) NULL
, // SIOCSIWAP
2150 (iw_handler
) NULL
, // SIOCGIWAP
2151 (iw_handler
) NULL
, // -- hole -- 0x16
2152 (iw_handler
) NULL
, // SIOCGIWAPLIST
2153 (iw_handler
) iwctl_siwscan
, // SIOCSIWSCAN
2154 (iw_handler
) iwctl_giwscan
, // SIOCGIWSCAN
2155 (iw_handler
) NULL
, // SIOCSIWESSID
2156 (iw_handler
) NULL
, // SIOCGIWESSID
2157 (iw_handler
) NULL
, // SIOCSIWNICKN
2158 (iw_handler
) NULL
, // SIOCGIWNICKN
2159 (iw_handler
) NULL
, // -- hole --
2160 (iw_handler
) NULL
, // -- hole --
2161 (iw_handler
) NULL
, // SIOCSIWRATE 0x20
2162 (iw_handler
) NULL
, // SIOCGIWRATE
2163 (iw_handler
) NULL
, // SIOCSIWRTS
2164 (iw_handler
) NULL
, // SIOCGIWRTS
2165 (iw_handler
) NULL
, // SIOCSIWFRAG
2166 (iw_handler
) NULL
, // SIOCGIWFRAG
2167 (iw_handler
) NULL
, // SIOCSIWTXPOW
2168 (iw_handler
) NULL
, // SIOCGIWTXPOW
2169 (iw_handler
) NULL
, // SIOCSIWRETRY
2170 (iw_handler
) NULL
, // SIOCGIWRETRY
2171 (iw_handler
) NULL
, // SIOCSIWENCODE
2172 (iw_handler
) NULL
, // SIOCGIWENCODE
2173 (iw_handler
) NULL
, // SIOCSIWPOWER
2174 (iw_handler
) NULL
, // SIOCGIWPOWER
2175 (iw_handler
) NULL
, // -- hole --
2176 (iw_handler
) NULL
, // -- hole --
2177 (iw_handler
) NULL
, // SIOCSIWGENIE
2178 (iw_handler
) NULL
, // SIOCGIWGENIE
2179 (iw_handler
) NULL
, // SIOCSIWAUTH
2180 (iw_handler
) NULL
, // SIOCGIWAUTH
2181 (iw_handler
) NULL
, // SIOCSIWENCODEEXT
2182 (iw_handler
) NULL
, // SIOCGIWENCODEEXT
2183 (iw_handler
) NULL
, // SIOCSIWPMKSA
2184 (iw_handler
) NULL
, // -- hole --
2188 static const iw_handler iwctl_private_handler
[] =
2190 NULL
, // SIOCIWFIRSTPRIV
2194 struct iw_priv_args iwctl_private_args
[] = {
2196 IW_PRIV_TYPE_CHAR
| 1024, 0,
2202 const struct iw_handler_def iwctl_handler_def
=
2204 .get_wireless_stats
= &iwctl_get_wireless_stats
,
2205 .num_standard
= sizeof(iwctl_handler
)/sizeof(iw_handler
),
2206 // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
2207 // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
2209 .num_private_args
= 0,
2210 .standard
= (iw_handler
*) iwctl_handler
,
2211 // .private = (iw_handler *) iwctl_private_handler,
2212 // .private_args = (struct iw_priv_args *)iwctl_private_args,
2214 .private_args
= NULL
,