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 *************************************************************************
28 #include "../rt_config.h"
31 #define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
33 // We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
34 BOOLEAN rtstrmactohex(PSTRING s1, PSTRING s2)
37 PSTRING ptokS = s1, ptokE = s1;
39 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
42 while((*ptokS) != '\0')
44 if((ptokE = strchr(ptokS, ':')) != NULL)
46 if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
48 AtoH(ptokS, (PUCHAR)&s2[i++], 1);
51 break; // parsing finished
54 return ( i == 6 ? TRUE : FALSE);
59 // we assume the s1 and s2 both are strings.
60 BOOLEAN rtstrcasecmp(PSTRING s1, PSTRING s2)
62 PSTRING p1 = s1, p2 = s2;
64 if (strlen(s1) != strlen(s2))
69 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
78 // we assume the s1 (buffer) and s2 (key) both are strings.
79 PSTRING rtstrstruncasecmp(PSTRING s1, PSTRING s2)
99 if (('a' <= temp1) && (temp1 <= 'z'))
100 temp1 = 'A'+(temp1-'a');
101 if (('a' <= temp2) && (temp2 <= 'z'))
102 temp2 = 'A'+(temp2-'a');
114 return NULL; // not found
120 * strstr - Find the first substring in a %NUL terminated string
121 * @s1: The string to be searched
122 * @s2: The string to search for
124 PSTRING rtstrstr(PSTRING s1,const PSTRING s2)
137 if (!memcmp(s1,s2,l2))
146 * rstrtok - Split a string into tokens
147 * @s: The string to be searched
148 * @ct: The characters to search for
149 * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
152 PSTRING rstrtok(PSTRING s,const PSTRING ct)
154 PSTRING sbegin, send;
156 sbegin = s ? s : __rstrtok;
162 sbegin += strspn(sbegin,ct);
169 send = strpbrk( sbegin, ct);
170 if (send && *send != '\0')
179 * delimitcnt - return the count of a given delimiter in a given string.
180 * @s: The string to be searched.
181 * @ct: The delimiter to search for.
182 * Notice : We suppose the delimiter is a single-char string(for example : ";").
184 INT delimitcnt(PSTRING s,PSTRING ct)
187 /* point to the beginning of the line */
192 token = strpbrk(token, ct); /* search for delimiters */
196 /* advanced to the terminating null character */
199 /* skip the delimiter */
203 * Print the found text: use len with %.*s to specify field width.
206 /* accumulate delimiter count */
213 * converts the Internet host address from the standard numbers-and-dots notation
215 * returns nonzero if the address is valid, zero if not.
217 int rtinet_aton(PSTRING cp, unsigned int *addr)
222 unsigned int parts[4];
223 unsigned int *pp = parts;
228 * Collect number up to ``.''.
229 * Values are specified as for C:
230 * 0x=hex, 0=octal, other=decimal.
236 if (*++cp == 'x' || *cp == 'X')
241 while ((c = *cp) != '\0')
243 if (isdigit((unsigned char) c))
245 val = (val * base) + (c - '0');
249 if (base == 16 && isxdigit((unsigned char) c))
252 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
261 * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
262 * a.b (with b treated as 24 bits)
264 if (pp >= parts + 3 || val > 0xff)
273 * Check for trailing junk.
276 if (!isspace((unsigned char) *cp++))
280 * Concoct the address according to the number of parts specified.
286 case 1: /* a -- 32 bits */
289 case 2: /* a.b -- 8.24 bits */
292 val |= parts[0] << 24;
295 case 3: /* a.b.c -- 8.8.16 bits */
298 val |= (parts[0] << 24) | (parts[1] << 16);
301 case 4: /* a.b.c.d -- 8.8.8.8 bits */
304 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
314 ========================================================================
317 Find key section for Get key parameter.
320 buffer Pointer to the buffer to start find the key section
321 section the key of the secion to be find
326 ========================================================================
328 PSTRING RTMPFindSection(
334 strcpy(temp_buf, "Default");
336 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
337 return (ptr+strlen("\n"));
343 ========================================================================
349 key Pointer to key string
350 dest Pointer to destination
351 destsize The datasize of the destination
352 buffer Pointer to the buffer to start find the key
353 bTrimSpace Set true if you want to strip the space character of the result pattern
360 This routine get the value with the matched key (case case-sensitive)
361 For SSID and security key related parameters, we SHALL NOT trim the space(' ') character.
362 ========================================================================
364 INT RTMPGetKeyParameter(
369 IN BOOLEAN bTrimSpace)
371 PSTRING pMemBuf, temp_buf1 = NULL, temp_buf2 = NULL;
372 PSTRING start_ptr, end_ptr;
374 PSTRING offset = NULL;
378 keyLen = strlen(key);
379 os_alloc_mem(NULL, (PUCHAR *)&pMemBuf, MAX_PARAM_BUFFER_SIZE * 2);
383 memset(pMemBuf, 0, MAX_PARAM_BUFFER_SIZE * 2);
385 temp_buf2 = (PSTRING)(pMemBuf + MAX_PARAM_BUFFER_SIZE);
389 if((offset = RTMPFindSection(buffer)) == NULL)
391 os_free_mem(NULL, (PUCHAR)pMemBuf);
395 strcpy(temp_buf1, "\n");
396 strcat(temp_buf1, key);
397 strcat(temp_buf1, "=");
400 if((start_ptr=rtstrstr(offset, temp_buf1)) == NULL)
402 os_free_mem(NULL, (PUCHAR)pMemBuf);
406 start_ptr += strlen("\n");
407 if((end_ptr = rtstrstr(start_ptr, "\n"))==NULL)
408 end_ptr = start_ptr+strlen(start_ptr);
410 if (end_ptr<start_ptr)
412 os_free_mem(NULL, (PUCHAR)pMemBuf);
416 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
417 temp_buf2[end_ptr-start_ptr]='\0';
418 if((start_ptr=rtstrstr(temp_buf2, "=")) == NULL)
420 os_free_mem(NULL, (PUCHAR)pMemBuf);
423 ptr = (start_ptr +1);
424 //trim special characters, i.e., TAB or space
425 while(*start_ptr != 0x00)
427 if( ((*ptr == ' ') && bTrimSpace) || (*ptr == '\t') )
432 len = strlen(start_ptr);
434 memset(dest, 0x00, destsize);
435 strncpy(dest, ptr, ((len >= destsize) ? destsize: len));
437 os_free_mem(NULL, (PUCHAR)pMemBuf);
444 ========================================================================
447 Get multiple key parameter.
450 key Pointer to key string
451 dest Pointer to destination
452 destsize The datasize of the destination
453 buffer Pointer to the buffer to start find the key
460 This routine get the value with the matched key (case case-sensitive)
461 ========================================================================
463 INT RTMPGetKeyParameterWithOffset(
466 OUT USHORT *end_offset,
469 IN BOOLEAN bTrimSpace)
471 PSTRING temp_buf1 = NULL;
472 PSTRING temp_buf2 = NULL;
479 if (*end_offset >= MAX_INI_BUFFER_SIZE)
482 os_alloc_mem(NULL, (PUCHAR *)&temp_buf1, MAX_PARAM_BUFFER_SIZE);
484 if(temp_buf1 == NULL)
487 os_alloc_mem(NULL, (PUCHAR *)&temp_buf2, MAX_PARAM_BUFFER_SIZE);
488 if(temp_buf2 == NULL)
490 os_free_mem(NULL, (PUCHAR)temp_buf1);
497 if ((offset = RTMPFindSection(buffer)) == NULL)
499 os_free_mem(NULL, (PUCHAR)temp_buf1);
500 os_free_mem(NULL, (PUCHAR)temp_buf2);
505 offset = buffer + (*end_offset);
507 strcpy(temp_buf1, "\n");
508 strcat(temp_buf1, key);
509 strcat(temp_buf1, "=");
512 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
514 os_free_mem(NULL, (PUCHAR)temp_buf1);
515 os_free_mem(NULL, (PUCHAR)temp_buf2);
519 start_ptr+=strlen("\n");
520 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
521 end_ptr=start_ptr+strlen(start_ptr);
523 if (end_ptr<start_ptr)
525 os_free_mem(NULL, (PUCHAR)temp_buf1);
526 os_free_mem(NULL, (PUCHAR)temp_buf2);
530 *end_offset = end_ptr - buffer;
532 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
533 temp_buf2[end_ptr-start_ptr]='\0';
534 len = strlen(temp_buf2);
535 strcpy(temp_buf1, temp_buf2);
536 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
538 os_free_mem(NULL, (PUCHAR)temp_buf1);
539 os_free_mem(NULL, (PUCHAR)temp_buf2);
543 strcpy(temp_buf2, start_ptr+1);
548 if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
555 memset(dest, 0x00, destsize);
556 strncpy(dest, ptr, len >= destsize ? destsize: len);
558 os_free_mem(NULL, (PUCHAR)temp_buf1);
559 os_free_mem(NULL, (PUCHAR)temp_buf2);
564 static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN PSTRING buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
567 //INT i = BSSIdx, idx = KeyIdx, retVal;
569 //UCHAR CipherAlg = CIPHER_WEP64;
570 CIPHER_KEY *pSharedKey;
573 KeyLen = strlen(keybuff);
574 pSharedKey = &pAd->SharedKey[BSSIdx][KeyIdx];
576 if(((KeyType != 0) && (KeyType != 1)) ||
577 ((KeyType == 0) && (KeyLen != 10) && (KeyLen != 26)) ||
578 ((KeyType== 1) && (KeyLen != 5) && (KeyLen != 13)))
580 DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length(%ld) or Type(%ld)\n",
581 KeyIdx+1, KeyLen, KeyType));
586 return RT_CfgSetWepKey(pAd, buffer, pSharedKey, KeyIdx);
592 static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer)
597 ULONG KeyType[MAX_MBSSID_NUM];
600 NdisZeroMemory(KeyType, sizeof(KeyType));
603 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer, TRUE))
606 KeyIdx = simple_strtol(tmpbuf, 0, 10);
607 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
608 pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
610 pAd->StaCfg.DefaultKeyId = 0;
612 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
617 for (idx = 0; idx < 4; idx++)
619 sprintf(tok_str, "Key%dType", idx + 1);
621 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, TRUE))
623 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
626 do sanity check for KeyType length;
627 or in station mode, the KeyType length > 1,
628 the code will overwrite the stack of caller
629 (RTMPSetProfileParameters) and cause srcbuf = NULL
631 if (i < MAX_MBSSID_NUM)
632 KeyType[i] = simple_strtol(macptr, 0, 10);
636 sprintf(tok_str, "Key%dStr", idx + 1);
637 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE))
639 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
648 static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
652 BOOLEAN bWmmEnable = FALSE;
655 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer, TRUE))
657 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
659 pAd->CommonCfg.bWmmCapable = TRUE;
664 pAd->CommonCfg.bWmmCapable = FALSE;
667 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
671 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
672 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer, TRUE))
674 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
676 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
678 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
685 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer, TRUE))
687 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
688 pAd->CommonCfg.bAPSDCapable = TRUE;
690 pAd->CommonCfg.bAPSDCapable = FALSE;
692 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
696 if(RTMPGetKeyParameter("MaxSPLength", tmpbuf, 10, buffer, TRUE))
698 pAd->CommonCfg.MaxSPLength = simple_strtol(tmpbuf, 0, 10);
700 DBGPRINT(RT_DEBUG_TRACE, ("MaxSPLength=%d\n", pAd->CommonCfg.MaxSPLength));
703 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
704 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer, TRUE))
708 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
710 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
712 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
715 pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
716 pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
717 pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
718 pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
720 pAd->CommonCfg.bACMAPSDTr[0] = apsd_ac[0];
721 pAd->CommonCfg.bACMAPSDTr[1] = apsd_ac[1];
722 pAd->CommonCfg.bACMAPSDTr[2] = apsd_ac[2];
723 pAd->CommonCfg.bACMAPSDTr[3] = apsd_ac[3];
730 static void HTParametersHook(
731 IN PRTMP_ADAPTER pAd,
732 IN PSTRING pValueStr,
738 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput, TRUE))
740 Value = simple_strtol(pValueStr, 0, 10);
743 pAd->CommonCfg.bHTProtect = FALSE;
747 pAd->CommonCfg.bHTProtect = TRUE;
749 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
752 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput, TRUE))
754 Value = simple_strtol(pValueStr, 0, 10);
757 pAd->CommonCfg.bMIMOPSEnable = FALSE;
761 pAd->CommonCfg.bMIMOPSEnable = TRUE;
763 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
767 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput, TRUE))
769 Value = simple_strtol(pValueStr, 0, 10);
770 if (Value > MMPS_ENABLE)
772 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
776 //TODO: add mimo power saving mechanism
777 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
778 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
780 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", (INT) Value));
783 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput, TRUE))
785 Value = simple_strtol(pValueStr, 0, 10);
788 pAd->CommonCfg.bBADecline = FALSE;
792 pAd->CommonCfg.bBADecline = TRUE;
794 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
798 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput, TRUE))
800 Value = simple_strtol(pValueStr, 0, 10);
803 pAd->CommonCfg.bDisableReordering = FALSE;
807 pAd->CommonCfg.bDisableReordering = TRUE;
809 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
812 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput, TRUE))
814 Value = simple_strtol(pValueStr, 0, 10);
817 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
818 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
822 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
823 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
825 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
826 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
830 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput, TRUE))
832 Value = simple_strtol(pValueStr, 0, 10);
835 pAd->HTCEnable = FALSE;
839 pAd->HTCEnable = TRUE;
841 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
844 // Enable HT Link Adaptation Control
845 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput, TRUE))
847 Value = simple_strtol(pValueStr, 0, 10);
850 pAd->bLinkAdapt = FALSE;
854 pAd->HTCEnable = TRUE;
855 pAd->bLinkAdapt = TRUE;
857 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
860 // Reverse Direction Mechanism
861 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput, TRUE))
863 Value = simple_strtol(pValueStr, 0, 10);
866 pAd->CommonCfg.bRdg = FALSE;
870 pAd->HTCEnable = TRUE;
871 pAd->CommonCfg.bRdg = TRUE;
873 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
880 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput, TRUE))
882 Value = simple_strtol(pValueStr, 0, 10);
885 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
889 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
891 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
895 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput, TRUE))
897 Value = simple_strtol(pValueStr, 0, 10);
898 if (Value <=7 && Value >= 0)
900 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
901 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", (INT) Value));
905 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
906 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
910 // Max Rx BA Window Size
911 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput, TRUE))
913 Value = simple_strtol(pValueStr, 0, 10);
915 if (Value >=1 && Value <= 64)
917 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
918 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
919 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", (INT) Value));
923 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
924 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
925 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
931 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput, TRUE))
933 Value = simple_strtol(pValueStr, 0, 10);
937 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
941 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
944 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
947 // HT Operation Mode : Mixed Mode , Green Field
948 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput, TRUE))
950 Value = simple_strtol(pValueStr, 0, 10);
952 if (Value == HTMODE_GF)
955 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
959 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
962 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
965 // Fixed Tx mode : CCK, OFDM
966 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput, TRUE))
971 fix_tx_mode = FIXED_TXMODE_HT;
973 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
975 fix_tx_mode = FIXED_TXMODE_OFDM;
977 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
979 fix_tx_mode = FIXED_TXMODE_CCK;
981 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
983 fix_tx_mode = FIXED_TXMODE_HT;
987 Value = simple_strtol(pValueStr, 0, 10);
991 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
994 fix_tx_mode = FIXED_TXMODE_HT;
997 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
998 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1005 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput, TRUE))
1007 Value = simple_strtol(pValueStr, 0, 10);
1011 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1015 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1018 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1021 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput, TRUE))
1023 Value = simple_strtol(pValueStr, 0, 10);
1028 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1032 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1035 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1039 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput, TRUE))
1042 Value = simple_strtol(pValueStr, 0, 10);
1044 // if ((Value >= 0 && Value <= 15) || (Value == 32))
1045 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1047 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1048 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1049 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1053 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1054 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1055 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1061 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput, TRUE))
1063 Value = simple_strtol(pValueStr, 0, 10);
1064 if (Value == STBC_USE)
1066 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1070 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1072 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1075 // 40_Mhz_Intolerant
1076 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput, TRUE))
1078 Value = simple_strtol(pValueStr, 0, 10);
1081 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1085 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1087 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1090 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput, TRUE))
1092 switch (simple_strtol(pValueStr, 0, 10))
1095 pAd->CommonCfg.TxStream = 1;
1098 pAd->CommonCfg.TxStream = 2;
1102 pAd->CommonCfg.TxStream = 3;
1104 if (pAd->MACVersion < RALINK_2883_VERSION)
1105 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1108 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1111 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput, TRUE))
1113 switch (simple_strtol(pValueStr, 0, 10))
1116 pAd->CommonCfg.RxStream = 1;
1119 pAd->CommonCfg.RxStream = 2;
1123 pAd->CommonCfg.RxStream = 3;
1125 if (pAd->MACVersion < RALINK_2883_VERSION)
1126 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
1129 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
1131 //2008/11/05: KH add to support Antenna power-saving of AP<--
1133 if(RTMPGetKeyParameter("GreenAP", pValueStr, 10, pInput, TRUE))
1135 Value = simple_strtol(pValueStr, 0, 10);
1138 pAd->CommonCfg.bGreenAPEnable = FALSE;
1142 pAd->CommonCfg.bGreenAPEnable = TRUE;
1144 DBGPRINT(RT_DEBUG_TRACE, ("HT: Green AP= %d\n", pAd->CommonCfg.bGreenAPEnable));
1148 if (RTMPGetKeyParameter("HT_DisallowTKIP", pValueStr, 25, pInput, TRUE))
1150 Value = simple_strtol(pValueStr, 0, 10);
1154 pAd->CommonCfg.HT_DisallowTKIP = TRUE;
1158 pAd->CommonCfg.HT_DisallowTKIP = FALSE;
1161 DBGPRINT(RT_DEBUG_TRACE, ("HT: Disallow TKIP mode = %s\n", (pAd->CommonCfg.HT_DisallowTKIP == TRUE) ? "ON" : "OFF" ));
1165 //2008/11/05:KH add to support Antenna power-saving of AP-->
1169 NDIS_STATUS RTMPSetProfileParameters(
1170 IN RTMP_ADAPTER *pAd,
1178 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
1180 return NDIS_STATUS_FAILURE;
1184 // set file parameter to portcfg
1186 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, pBuffer, TRUE))
1188 retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_24G);
1189 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
1191 //CountryRegionABand
1192 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, pBuffer, TRUE))
1194 retval = RT_CfgSetCountryRegion(pAd, tmpbuf, BAND_5G);
1195 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
1197 #ifdef RTMP_EFUSE_SUPPORT
1200 if(RTMPGetKeyParameter("EfuseBufferMode", tmpbuf, 25, pBuffer, TRUE))
1202 pAd->bEEPROMFile = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1203 DBGPRINT(RT_DEBUG_TRACE, ("EfuseBufferMode=%d\n", pAd->bUseEfuse));
1206 #endif // RTMP_EFUSE_SUPPORT //
1208 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, pBuffer, TRUE))
1210 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
1211 if (strlen((PSTRING) pAd->CommonCfg.CountryCode) != 0)
1213 pAd->CommonCfg.bCountryFlag = TRUE;
1215 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
1218 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, pBuffer, TRUE))
1220 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1221 if (Geography <= BOTH)
1223 pAd->CommonCfg.Geography = Geography;
1224 pAd->CommonCfg.CountryCode[2] =
1225 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
1226 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
1231 pAd->CommonCfg.Geography = BOTH;
1232 pAd->CommonCfg.CountryCode[2] = ' ';
1237 if (RTMPGetKeyParameter("SSID", tmpbuf, 256, pBuffer, FALSE))
1239 if (strlen(tmpbuf) <= 32)
1241 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
1242 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
1243 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
1244 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
1245 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
1246 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
1247 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1248 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1249 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1250 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
1257 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, pBuffer, TRUE))
1259 pAd->bConfigChanged = TRUE;
1260 if (strcmp(tmpbuf, "Adhoc") == 0)
1261 pAd->StaCfg.BssType = BSS_ADHOC;
1262 else //Default Infrastructure mode
1263 pAd->StaCfg.BssType = BSS_INFRA;
1264 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1265 pAd->StaCfg.WpaState = SS_NOTUSE;
1266 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
1270 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, pBuffer, TRUE))
1272 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1273 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1276 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, pBuffer, TRUE))
1278 RT_CfgSetWirelessMode(pAd, tmpbuf);
1279 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1282 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, pBuffer, TRUE))
1284 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1285 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1288 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, pBuffer, TRUE))
1290 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1291 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1294 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, pBuffer, TRUE))
1296 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1297 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1298 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1301 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, pBuffer, TRUE))
1303 //#if 0 //#ifndef WIFI_TEST
1304 // pAd->CommonCfg.UseBGProtection = 2;// disable b/g protection for throughput test
1306 switch (simple_strtol(tmpbuf, 0, 10))
1309 pAd->CommonCfg.UseBGProtection = 1;
1311 case 2: //Always OFF
1312 pAd->CommonCfg.UseBGProtection = 2;
1316 pAd->CommonCfg.UseBGProtection = 0;
1320 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1323 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, pBuffer, TRUE))
1325 switch (simple_strtol(tmpbuf, 0, 10))
1327 case 1: //disable OLBC Detection
1328 pAd->CommonCfg.DisableOLBCDetect = 1;
1330 case 0: //enable OLBC Detection
1331 pAd->CommonCfg.DisableOLBCDetect = 0;
1334 pAd->CommonCfg.DisableOLBCDetect= 0;
1337 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1340 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, pBuffer, TRUE))
1342 switch (simple_strtol(tmpbuf, 0, 10))
1344 case Rt802_11PreambleShort:
1345 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1347 case Rt802_11PreambleLong:
1349 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1352 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1355 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, pBuffer, TRUE))
1357 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1358 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1359 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1361 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1363 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1366 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, pBuffer, TRUE))
1368 FragThresh = simple_strtol(tmpbuf, 0, 10);
1369 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1371 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1372 { //illegal FragThresh so we set it to default
1373 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1374 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1376 else if (FragThresh % 2 == 1)
1378 // The length of each fragment shall always be an even number of octets, except for the last fragment
1379 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1380 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1384 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1386 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1387 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1390 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, pBuffer, TRUE))
1393 // pAd->CommonCfg.bEnableTxBurst = FALSE;
1395 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1396 pAd->CommonCfg.bEnableTxBurst = TRUE;
1398 pAd->CommonCfg.bEnableTxBurst = FALSE;
1400 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1403 #ifdef AGGREGATION_SUPPORT
1405 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, pBuffer, TRUE))
1407 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1408 pAd->CommonCfg.bAggregationCapable = TRUE;
1410 pAd->CommonCfg.bAggregationCapable = FALSE;
1411 #ifdef PIGGYBACK_SUPPORT
1412 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1413 #endif // PIGGYBACK_SUPPORT //
1414 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1417 pAd->CommonCfg.bAggregationCapable = FALSE;
1418 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1419 #endif // AGGREGATION_SUPPORT //
1423 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, pBuffer);
1426 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, pBuffer, TRUE))
1428 RT_CfgSetShortSlot(pAd, tmpbuf);
1429 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1432 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, pBuffer, TRUE))
1434 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1436 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1437 pAd->CommonCfg.bIEEE80211H = TRUE;
1439 pAd->CommonCfg.bIEEE80211H = FALSE;
1441 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1445 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, pBuffer, TRUE))
1447 if(simple_strtol(tmpbuf, 0, 10) != 0)
1448 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1450 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1452 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1456 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, pBuffer, TRUE))
1458 RADAR_DETECT_STRUCT *pRadarDetect = &pAd->CommonCfg.RadarDetect;
1459 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1461 pRadarDetect->RDDurRegion = JAP_W53;
1462 pRadarDetect->DfsSessionTime = 15;
1464 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1466 pRadarDetect->RDDurRegion = JAP_W56;
1467 pRadarDetect->DfsSessionTime = 13;
1469 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1471 pRadarDetect->RDDurRegion = JAP;
1472 pRadarDetect->DfsSessionTime = 5;
1474 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1476 pRadarDetect->RDDurRegion = FCC;
1477 pRadarDetect->DfsSessionTime = 5;
1479 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1481 pRadarDetect->RDDurRegion = CE;
1482 pRadarDetect->DfsSessionTime = 13;
1486 pRadarDetect->RDDurRegion = CE;
1487 pRadarDetect->DfsSessionTime = 13;
1490 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pRadarDetect->RDDurRegion));
1494 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1495 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1499 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, pBuffer, TRUE))
1501 if(simple_strtol(tmpbuf, 0, 10) != 0)
1502 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1504 pAd->CommonCfg.bWirelessEvent = 0; // disable
1505 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1507 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, pBuffer, TRUE))
1509 if(simple_strtol(tmpbuf, 0, 10) != 0)
1510 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1512 pAd->CommonCfg.bWiFiTest = 0; // disable
1514 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1517 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, pBuffer, TRUE))
1520 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1521 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1522 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1523 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1524 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1525 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1526 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1527 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1528 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1529 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1530 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1531 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1532 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1533 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1535 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1537 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1539 DBGPRINT(RT_DEBUG_TRACE, ("%s::(AuthMode=%d)\n", __func__, pAd->StaCfg.AuthMode));
1543 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, pBuffer, TRUE))
1546 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1547 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1548 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1549 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1550 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1551 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1553 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1555 // Update all wepstatus related
1556 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1557 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1558 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1559 pAd->StaCfg.bMixCipher = FALSE;
1561 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1562 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1567 if(RTMPGetKeyParameter("WPAPSK", tmpbuf, 512, pBuffer, FALSE))
1571 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1573 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1574 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1575 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1582 ret = RT_CfgSetWPAPSKKey(pAd, tmpbuf, (PUCHAR)pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, pAd->StaCfg.PMK);
1587 RTMPZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
1588 RTMPMoveMemory(pAd->StaCfg.WpaPassPhrase, tmpbuf, strlen(tmpbuf));
1589 pAd->StaCfg.WpaPassPhraseLen= strlen(tmpbuf);
1591 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1592 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1594 // Start STA supplicant state machine
1595 pAd->StaCfg.WpaState = SS_START;
1597 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1599 pAd->StaCfg.WpaState = SS_NOTUSE;
1601 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1606 //DefaultKeyID, KeyType, KeyStr
1607 rtmp_read_key_parms_from_file(pAd, tmpbuf, pBuffer);
1611 /*if(RTMPGetKeyParameter("HSCounter", tmpbuf, 10, pBuffer, TRUE))
1613 switch (simple_strtol(tmpbuf, 0, 10))
1616 pAd->CommonCfg.bEnableHSCounter = TRUE;
1620 pAd->CommonCfg.bEnableHSCounter = FALSE;
1623 DBGPRINT(RT_DEBUG_TRACE, "HSCounter=%d\n", pAd->CommonCfg.bEnableHSCounter);
1626 HTParametersHook(pAd, tmpbuf, pBuffer);
1630 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, pBuffer, TRUE))
1632 if (pAd->StaCfg.BssType == BSS_INFRA)
1634 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1636 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1637 // to exclude certain situations.
1638 // MlmeSetPsm(pAd, PWR_SAVE);
1639 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1640 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1641 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1642 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1643 pAd->StaCfg.DefaultListenCount = 5;
1645 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1646 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1648 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1649 // to exclude certain situations.
1650 // RTMP_SET_PSM_BIT(pAd, PWR_SAVE);
1651 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1652 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1653 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1654 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1655 pAd->StaCfg.DefaultListenCount = 3;
1657 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1658 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1660 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1661 // to exclude certain situations.
1662 // RTMP_SET_PSM_BIT(pAd, PWR_SAVE);
1663 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1664 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1665 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1666 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1667 pAd->StaCfg.DefaultListenCount = 3;
1670 { //Default Ndis802_11PowerModeCAM
1671 // clear PSM bit immediately
1672 RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
1673 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1674 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1675 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1676 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1678 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1681 // AutoRoaming by RSSI
1682 if (RTMPGetKeyParameter("AutoRoaming", tmpbuf, 32, pBuffer, TRUE))
1684 if (simple_strtol(tmpbuf, 0, 10) == 0)
1685 pAd->StaCfg.bAutoRoaming = FALSE;
1687 pAd->StaCfg.bAutoRoaming = TRUE;
1689 DBGPRINT(RT_DEBUG_TRACE, ("AutoRoaming=%d\n", pAd->StaCfg.bAutoRoaming));
1692 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, pBuffer, TRUE))
1694 long lInfo = simple_strtol(tmpbuf, 0, 10);
1696 if (lInfo > 90 || lInfo < 60)
1697 pAd->StaCfg.dBmToRoam = -70;
1699 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1701 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1704 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, pBuffer, TRUE))
1706 if(simple_strtol(tmpbuf, 0, 10) == 0)
1707 pAd->StaCfg.bTGnWifiTest = FALSE;
1709 pAd->StaCfg.bTGnWifiTest = TRUE;
1710 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1714 if (RTMPGetKeyParameter("BeaconLostTime", tmpbuf, 32, pBuffer, TRUE))
1716 ULONG lInfo = (ULONG)simple_strtol(tmpbuf, 0, 10);
1718 if ((lInfo != 0) && (lInfo <= 60))
1719 pAd->StaCfg.BeaconLostTime = (lInfo * OS_HZ);
1720 DBGPRINT(RT_DEBUG_TRACE, ("BeaconLostTime=%ld \n", pAd->StaCfg.BeaconLostTime));
1734 return NDIS_STATUS_SUCCESS;