📄 cmm_profile.c
字号:
key Pointer to key string dest Pointer to destination destsize The datasize of the destination buffer Pointer to the buffer to start find the key Return Value: TRUE Success FALSE Fail Note: This routine get the value with the matched key (case case-sensitive) ========================================================================*/INT RTMPGetKeyParameterWithOffset( IN PSTRING key, OUT PSTRING dest, OUT USHORT *end_offset, IN INT destsize, IN PSTRING buffer, IN BOOLEAN bTrimSpace){ PSTRING temp_buf1 = NULL; PSTRING temp_buf2 = NULL; PSTRING start_ptr; PSTRING end_ptr; PSTRING ptr; PSTRING offset = 0; INT len; if (*end_offset >= MAX_INI_BUFFER_SIZE) return (FALSE); os_alloc_mem(NULL, (PUCHAR *)&temp_buf1, MAX_PARAM_BUFFER_SIZE); if(temp_buf1 == NULL) return (FALSE); os_alloc_mem(NULL, (PUCHAR *)&temp_buf2, MAX_PARAM_BUFFER_SIZE); if(temp_buf2 == NULL) { os_free_mem(NULL, (PUCHAR)temp_buf1); return (FALSE); } //find section if(*end_offset == 0) { if ((offset = RTMPFindSection(buffer)) == NULL) { os_free_mem(NULL, (PUCHAR)temp_buf1); os_free_mem(NULL, (PUCHAR)temp_buf2); return (FALSE); } } else offset = buffer + (*end_offset); strcpy(temp_buf1, "\n"); strcat(temp_buf1, key); strcat(temp_buf1, "="); //search key if((start_ptr=rtstrstr(offset, temp_buf1))==NULL) { os_free_mem(NULL, (PUCHAR)temp_buf1); os_free_mem(NULL, (PUCHAR)temp_buf2); return (FALSE); } start_ptr+=strlen("\n"); if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL) end_ptr=start_ptr+strlen(start_ptr); if (end_ptr<start_ptr) { os_free_mem(NULL, (PUCHAR)temp_buf1); os_free_mem(NULL, (PUCHAR)temp_buf2); return (FALSE); } *end_offset = end_ptr - buffer; NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr); temp_buf2[end_ptr-start_ptr]='\0'; len = strlen(temp_buf2); strcpy(temp_buf1, temp_buf2); if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL) { os_free_mem(NULL, (PUCHAR)temp_buf1); os_free_mem(NULL, (PUCHAR)temp_buf2); return (FALSE); } strcpy(temp_buf2, start_ptr+1); ptr = temp_buf2; //trim space or tab while(*ptr != 0x00) { if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') ) ptr++; else break; } len = strlen(ptr); memset(dest, 0x00, destsize); strncpy(dest, ptr, len >= destsize ? destsize: len); os_free_mem(NULL, (PUCHAR)temp_buf1); os_free_mem(NULL, (PUCHAR)temp_buf2); return TRUE;}static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN PSTRING buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx){ PSTRING keybuff; //INT i = BSSIdx, idx = KeyIdx, retVal; ULONG KeyLen; //UCHAR CipherAlg = CIPHER_WEP64; CIPHER_KEY *pSharedKey; keybuff = buffer; KeyLen = strlen(keybuff); pSharedKey = &pAd->SharedKey[BSSIdx][KeyIdx]; if(((KeyType != 0) && (KeyType != 1)) || ((KeyType == 0) && (KeyLen != 10) && (KeyLen != 26)) || ((KeyType== 1) && (KeyLen != 5) && (KeyLen != 13))) { DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length(%ld) or Type(%ld)\n", KeyIdx+1, KeyLen, KeyType)); return FALSE; } else { return RT_CfgSetWepKey(pAd, buffer, pSharedKey, KeyIdx); } }static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer){ STRING tok_str[16]; PSTRING macptr; INT i = 0, idx; ULONG KeyType[MAX_MBSSID_NUM]; ULONG KeyIdx; NdisZeroMemory(KeyType, sizeof(KeyType)); //DefaultKeyID if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer, TRUE)) {#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { KeyIdx = simple_strtol(tmpbuf, 0, 10); if((KeyIdx >= 1 ) && (KeyIdx <= 4)) pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1); else pAd->StaCfg.DefaultKeyId = 0; DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId)); }#endif // CONFIG_STA_SUPPORT // } for (idx = 0; idx < 4; idx++) { sprintf(tok_str, "Key%dType", idx + 1); //Key1Type if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++) { /* do sanity check for KeyType length; or in station mode, the KeyType length > 1, the code will overwrite the stack of caller (RTMPSetProfileParameters) and cause srcbuf = NULL */ if (i < MAX_MBSSID_NUM) KeyType[i] = simple_strtol(macptr, 0, 10); }#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { sprintf(tok_str, "Key%dStr", idx + 1); if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE)) { rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx); } }#endif // CONFIG_STA_SUPPORT // } }}#ifdef CONFIG_STA_SUPPORTstatic void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer){ PSTRING macptr; INT i=0; BOOLEAN bWmmEnable = FALSE; //WmmCapable if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer, TRUE)) { if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable { pAd->CommonCfg.bWmmCapable = TRUE; bWmmEnable = TRUE; } else //Disable { pAd->CommonCfg.bWmmCapable = FALSE; } DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable)); }#ifdef QOS_DLS_SUPPORT //DLSCapable if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer, TRUE)) { if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable { pAd->CommonCfg.bDLSCapable = TRUE; } else //Disable { pAd->CommonCfg.bDLSCapable = FALSE; } DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable)); }#endif // QOS_DLS_SUPPORT // //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++) { pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i])); } } if (bWmmEnable) { //APSDCapable if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer, TRUE)) { if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable pAd->CommonCfg.bAPSDCapable = TRUE; else pAd->CommonCfg.bAPSDCapable = FALSE; DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable)); } //MaxSPLength if(RTMPGetKeyParameter("MaxSPLength", tmpbuf, 10, buffer, TRUE)) { pAd->CommonCfg.MaxSPLength = simple_strtol(tmpbuf, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("MaxSPLength=%d\n", pAd->CommonCfg.MaxSPLength)); } //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer, TRUE)) { BOOLEAN apsd_ac[4]; for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++) { apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i])); } pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0]; pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1]; pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2]; pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3]; pAd->CommonCfg.bACMAPSDTr[0] = apsd_ac[0]; pAd->CommonCfg.bACMAPSDTr[1] = apsd_ac[1]; pAd->CommonCfg.bACMAPSDTr[2] = apsd_ac[2]; pAd->CommonCfg.bACMAPSDTr[3] = apsd_ac[3]; } }}#endif // CONFIG_STA_SUPPORT //#ifdef DOT11_N_SUPPORTstatic void HTParametersHook( IN PRTMP_ADAPTER pAd, IN PSTRING pValueStr, IN PSTRING pInput){ long Value; if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.bHTProtect = FALSE; } else { pAd->CommonCfg.bHTProtect = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable")); } if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.bMIMOPSEnable = FALSE; } else { pAd->CommonCfg.bMIMOPSEnable = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable")); } if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value > MMPS_ENABLE) { pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE; } else { //TODO: add mimo power saving mechanism pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE; //pAd->CommonCfg.BACapability.field.MMPSmode = Value; } DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", (INT) Value)); } if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.bBADecline = FALSE; } else { pAd->CommonCfg.bBADecline = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable")); } if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.bDisableReordering = FALSE; } else { pAd->CommonCfg.bDisableReordering = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable")); } if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.BACapability.field.AutoBA = FALSE; pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE; } else { pAd->CommonCfg.BACapability.field.AutoBA = TRUE; pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; } pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA; DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable")); } // Tx_+HTC frame if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->HTCEnable = FALSE; } else { pAd->HTCEnable = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable")); } // Enable HT Link Adaptation Control if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->bLinkAdapt = FALSE; } else { pAd->HTCEnable = TRUE; pAd->bLinkAdapt = TRUE; } DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)")); } // Reverse Direction Mechanism if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput, TRUE)) { Value = simple_strtol(pValueStr, 0, 10); if (Value == 0) { pAd->CommonCfg.bRdg = FALSE; } else { pAd->HTCEnable = TRUE; pAd->CommonCfg.bRdg = TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -