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 --------- ---------- ----------------------------------------------
38 #include "../rt_config.h"
51 #ifdef DOT11_N_SUPPORT
55 case MODE_HTGREENFIELD:
57 #endif // DOT11_N_SUPPORT //
74 #ifdef DOT11_N_SUPPORT
77 #endif // DOT11_N_SUPPORT //
85 ==========================================================================
87 Set Country Region to pAd->CommonCfg.CountryRegion.
88 This command will not work, if the field of CountryRegion in eeprom is programmed.
91 TRUE if all parameters are OK, FALSE otherwise
92 ==========================================================================
94 INT RT_CfgSetCountryRegion(
99 LONG region, regionMax;
100 UCHAR *pCountryRegion;
102 region = simple_strtol(arg, 0, 10);
104 if (band == BAND_24G)
106 pCountryRegion = &pAd->CommonCfg.CountryRegion;
107 regionMax = REGION_MAXIMUM_BG_BAND;
111 pCountryRegion = &pAd->CommonCfg.CountryRegionForABand;
112 regionMax = REGION_MAXIMUM_A_BAND;
115 // TODO: Is it neccesay for following check???
116 // Country can be set only when EEPROM not programmed
117 if (*pCountryRegion & 0x80)
119 DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
123 if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
125 *pCountryRegion= (UCHAR) region;
127 else if ((region == REGION_31_BG_BAND) && (band == BAND_24G))
129 *pCountryRegion = (UCHAR) region;
133 DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():region(%ld) out of range!\n", region));
143 ==========================================================================
147 TRUE if all parameters are OK, FALSE otherwise
148 ==========================================================================
150 INT RT_CfgSetWirelessMode(
151 IN PRTMP_ADAPTER pAd,
154 INT MaxPhyMode = PHY_11G;
157 #ifdef DOT11_N_SUPPORT
158 MaxPhyMode = PHY_11N_5G;
159 #endif // DOT11_N_SUPPORT //
161 WirelessMode = simple_strtol(arg, 0, 10);
162 if (WirelessMode <= MaxPhyMode)
164 pAd->CommonCfg.PhyMode = WirelessMode;
165 pAd->CommonCfg.DesiredPhyMode = WirelessMode;
174 INT RT_CfgSetShortSlot(
175 IN PRTMP_ADAPTER pAd,
180 ShortSlot = simple_strtol(arg, 0, 10);
183 pAd->CommonCfg.bUseShortSlotTime = TRUE;
184 else if (ShortSlot == 0)
185 pAd->CommonCfg.bUseShortSlotTime = FALSE;
187 return FALSE; //Invalid argument
194 ==========================================================================
196 Set WEP KEY base on KeyIdx
198 TRUE if all parameters are OK, FALSE otherwise
199 ==========================================================================
202 IN PRTMP_ADAPTER pAd,
203 IN PSTRING keyString,
204 IN CIPHER_KEY *pSharedKey,
209 UCHAR CipherAlg = CIPHER_NONE;
210 BOOLEAN bKeyIsHex = FALSE;
212 // TODO: Shall we do memset for the original key info??
213 memset(pSharedKey, 0, sizeof(CIPHER_KEY));
214 KeyLen = strlen(keyString);
217 case 5: //wep 40 Ascii type
218 case 13: //wep 104 Ascii type
220 pSharedKey->KeyLen = KeyLen;
221 NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
224 case 10: //wep 40 Hex type
225 case 26: //wep 104 Hex type
226 for(i=0; i < KeyLen; i++)
228 if( !isxdigit(*(keyString+i)) )
229 return FALSE; //Not Hex value;
232 pSharedKey->KeyLen = KeyLen/2 ;
233 AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
236 default: //Invalid argument
237 DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n", keyIdx, keyString));
241 pSharedKey->CipherAlg = ((KeyLen % 5) ? CIPHER_WEP128 : CIPHER_WEP64);
242 DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n",
243 keyIdx, (bKeyIsHex == FALSE ? "Ascii" : "Hex"), CipherName[CipherAlg]));
250 ==========================================================================
255 pAdapter Pointer to our adapter
256 keyString WPA pre-shared key string
257 pHashStr String used for password hash function
258 hashStrLen Lenght of the hash string
259 pPMKBuf Output buffer of WPAPSK key
262 TRUE if all parameters are OK, FALSE otherwise
263 ==========================================================================
265 INT RT_CfgSetWPAPSKKey(
266 IN RTMP_ADAPTER *pAd,
267 IN PSTRING keyString,
273 UCHAR keyMaterial[40];
275 keyLen = strlen(keyString);
276 if ((keyLen < 8) || (keyLen > 64))
278 DBGPRINT(RT_DEBUG_TRACE, ("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
283 memset(pPMKBuf, 0, 32);
286 AtoH(keyString, pPMKBuf, 32);
290 PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
291 NdisMoveMemory(pPMKBuf, keyMaterial, 32);