2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 Ralink WiFi Driver configuration related subroutines
35 --------- ---------- ----------------------------------------------
40 #include "../rt_config.h"
56 case MODE_HTGREENFIELD
:
83 ==========================================================================
85 Set Country Region to pAd->CommonCfg.CountryRegion.
86 This command will not work, if the field of CountryRegion in eeprom is programmed.
89 TRUE if all parameters are OK, FALSE otherwise
90 ==========================================================================
92 INT
RT_CfgSetCountryRegion(
97 LONG region
, regionMax
;
98 UCHAR
*pCountryRegion
;
100 region
= simple_strtol(arg
, 0, 10);
102 if (band
== BAND_24G
)
104 pCountryRegion
= &pAd
->CommonCfg
.CountryRegion
;
105 regionMax
= REGION_MAXIMUM_BG_BAND
;
109 pCountryRegion
= &pAd
->CommonCfg
.CountryRegionForABand
;
110 regionMax
= REGION_MAXIMUM_A_BAND
;
113 // TODO: Is it neccesay for following check???
114 // Country can be set only when EEPROM not programmed
115 if (*pCountryRegion
& 0x80)
117 DBGPRINT(RT_DEBUG_ERROR
, ("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
121 if((region
>= 0) && (region
<= REGION_MAXIMUM_BG_BAND
))
123 *pCountryRegion
= (UCHAR
) region
;
125 else if ((region
== REGION_31_BG_BAND
) && (band
== BAND_24G
))
127 *pCountryRegion
= (UCHAR
) region
;
131 DBGPRINT(RT_DEBUG_ERROR
, ("CfgSetCountryRegion():region(%ld) out of range!\n", region
));
141 ==========================================================================
145 TRUE if all parameters are OK, FALSE otherwise
146 ==========================================================================
148 INT
RT_CfgSetWirelessMode(
149 IN PRTMP_ADAPTER pAd
,
152 INT MaxPhyMode
= PHY_11G
;
155 MaxPhyMode
= PHY_11N_5G
;
157 WirelessMode
= simple_strtol(arg
, 0, 10);
158 if (WirelessMode
<= MaxPhyMode
)
160 pAd
->CommonCfg
.PhyMode
= WirelessMode
;
169 INT
RT_CfgSetShortSlot(
170 IN PRTMP_ADAPTER pAd
,
175 ShortSlot
= simple_strtol(arg
, 0, 10);
178 pAd
->CommonCfg
.bUseShortSlotTime
= TRUE
;
179 else if (ShortSlot
== 0)
180 pAd
->CommonCfg
.bUseShortSlotTime
= FALSE
;
182 return FALSE
; //Invalid argument
189 ==========================================================================
191 Set WEP KEY base on KeyIdx
193 TRUE if all parameters are OK, FALSE otherwise
194 ==========================================================================
197 IN PRTMP_ADAPTER pAd
,
198 IN PSTRING keyString
,
199 IN CIPHER_KEY
*pSharedKey
,
204 UCHAR CipherAlg
= CIPHER_NONE
;
205 BOOLEAN bKeyIsHex
= FALSE
;
207 // TODO: Shall we do memset for the original key info??
208 memset(pSharedKey
, 0, sizeof(CIPHER_KEY
));
209 KeyLen
= strlen(keyString
);
212 case 5: //wep 40 Ascii type
213 case 13: //wep 104 Ascii type
215 pSharedKey
->KeyLen
= KeyLen
;
216 NdisMoveMemory(pSharedKey
->Key
, keyString
, KeyLen
);
219 case 10: //wep 40 Hex type
220 case 26: //wep 104 Hex type
221 for(i
=0; i
< KeyLen
; i
++)
223 if( !isxdigit(*(keyString
+i
)) )
224 return FALSE
; //Not Hex value;
227 pSharedKey
->KeyLen
= KeyLen
/2 ;
228 AtoH(keyString
, pSharedKey
->Key
, pSharedKey
->KeyLen
);
231 default: //Invalid argument
232 DBGPRINT(RT_DEBUG_TRACE
, ("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n", keyIdx
, keyString
));
236 pSharedKey
->CipherAlg
= ((KeyLen
% 5) ? CIPHER_WEP128
: CIPHER_WEP64
);
237 DBGPRINT(RT_DEBUG_TRACE
, ("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n",
238 keyIdx
, (bKeyIsHex
== FALSE
? "Ascii" : "Hex"), CipherName
[CipherAlg
]));
245 ==========================================================================
250 pAdapter Pointer to our adapter
251 keyString WPA pre-shared key string
252 pHashStr String used for password hash function
253 hashStrLen Lenght of the hash string
254 pPMKBuf Output buffer of WPAPSK key
257 TRUE if all parameters are OK, FALSE otherwise
258 ==========================================================================
260 INT
RT_CfgSetWPAPSKKey(
261 IN RTMP_ADAPTER
*pAd
,
262 IN PSTRING keyString
,
268 UCHAR keyMaterial
[40];
270 keyLen
= strlen(keyString
);
271 if ((keyLen
< 8) || (keyLen
> 64))
273 DBGPRINT(RT_DEBUG_TRACE
, ("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
278 memset(pPMKBuf
, 0, 32);
281 AtoH(keyString
, pPMKBuf
, 32);
285 PasswordHash(keyString
, pHashStr
, hashStrLen
, keyMaterial
);
286 NdisMoveMemory(pPMKBuf
, keyMaterial
, 32);
This page took 0.03848 seconds and 5 git commands to generate.