/* ======================================================================== Routine Description: Protection Management Frame Capable Protection Management Frame Required Arguments: Return Value: Note: RSNA policy selection in a ESS: IEEE P802.11w Table 8-1a RSNA policy selection in an IBSS: IEEE P802.11w Table 8-1b ======================================================================== */ void rtmp_read_pmf_parameters_from_file( IN PRTMP_ADAPTER pAd, IN PSTRING tmpbuf, IN PSTRING pBuffer) { PSTRING macptr; #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { INT apidx; POS_COOKIE pObj; pObj = (POS_COOKIE) pAd->OS_Cookie; for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) { pAd->ApCfg.MBSSID[apidx].PmfCfg.Desired_MFPC = FALSE; pAd->ApCfg.MBSSID[apidx].PmfCfg.Desired_MFPR = FALSE; pAd->ApCfg.MBSSID[apidx].PmfCfg.Desired_PMFSHA256 = FALSE; } /* Protection Management Frame Capable */ if (RTMPGetKeyParameter("PMFMFPC", tmpbuf, 32, pBuffer, TRUE)) { for (apidx = 0, macptr = rstrtok(tmpbuf,";"); (macptr && apidx < pAd->ApCfg.BssidNum); macptr = rstrtok(NULL,";"), apidx++) { pObj->ioctl_if = apidx; Set_PMFMFPC_Proc(pAd, macptr); } } /* Protection Management Frame Required */ if (RTMPGetKeyParameter("PMFMFPR", tmpbuf, 32, pBuffer, TRUE)) { for (apidx = 0, macptr = rstrtok(tmpbuf,";"); (macptr && apidx < pAd->ApCfg.BssidNum); macptr = rstrtok(NULL,";"), apidx++) { pObj->ioctl_if = apidx; Set_PMFMFPR_Proc(pAd, macptr); } } if (RTMPGetKeyParameter("PMFSHA256", tmpbuf, 32, pBuffer, TRUE)) { for (apidx = 0, macptr = rstrtok(tmpbuf,";"); (macptr && apidx < pAd->ApCfg.BssidNum); macptr = rstrtok(NULL,";"), apidx++) { pObj->ioctl_if = apidx; Set_PMFSHA256_Proc(pAd, macptr); } } } #endif /* CONFIG_AP_SUPPORT */ }
INT Set_MultiMacAddrExt_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { UCHAR tempMAC[6], idx; PSTRING token; STRING sepValue[] = ":", DASH = '-'; ULONG offset, Addr; INT i; if(strlen(arg) < 19) /*Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.*/ return FALSE; token = strchr(arg, DASH); if ((token != NULL) && (strlen(token)>1)) { idx = (UCHAR) simple_strtol((token+1), 0, 10); if (idx > 15) return FALSE; *token = '\0'; for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++) { if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1)))) return FALSE; AtoH(token, (&tempMAC[i]), 1); } if(i != 6) return FALSE; DBGPRINT(RT_DEBUG_OFF, ("\n%02x:%02x:%02x:%02x:%02x:%02x-%02x\n", tempMAC[0], tempMAC[1], tempMAC[2], tempMAC[3], tempMAC[4], tempMAC[5], idx)); offset = 0x1480 + (HW_WCID_ENTRY_SIZE * idx); Addr = tempMAC[0] + (tempMAC[1] << 8) +(tempMAC[2] << 16) +(tempMAC[3] << 24); RTMP_IO_WRITE32(pAd, offset, Addr); Addr = tempMAC[4] + (tempMAC[5] << 8); RTMP_IO_WRITE32(pAd, offset + 4, Addr); return TRUE; } return FALSE; }
void RRM_ReadParametersFromFile( IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer) { INT loop; PSTRING macptr; /* RRMEnable */ if (RTMPGetKeyParameter("RRMEnable", tmpbuf, 255, buffer, TRUE)) { for (loop=0, macptr = rstrtok(tmpbuf,";"); (macptr && loop < MAX_MBSSID_NUM(pAd)); macptr = rstrtok(NULL,";"), loop++) { LONG Enable; Enable = simple_strtol(macptr, 0, 10); pAd->ApCfg.MBSSID[loop].RrmCfg.bDot11kRRMEnable = (Enable > 0) ? TRUE : FALSE; DBGPRINT(RT_DEBUG_TRACE, ("%s::(bDot11kRRMEnable[%d]=%d)\n", __FUNCTION__, loop, pAd->ApCfg.MBSSID[loop].RrmCfg.bDot11kRRMEnable)); } } else { for (loop = 0; loop < MAX_MBSSID_NUM(pAd); loop++) pAd->ApCfg.MBSSID[loop].RrmCfg.bDot11kRRMEnable = FALSE; } /* Regulatory Class */ if (RTMPGetKeyParameter("RegulatoryClass", tmpbuf, 255, buffer, TRUE)) { LONG Value; for (loop=0, macptr = rstrtok(tmpbuf,";"); (macptr && loop < MAX_NUM_OF_REGULATORY_CLASS); macptr = rstrtok(NULL,";"), loop++) { Value = simple_strtol(macptr, 0, 10); pAd->CommonCfg.RegulatoryClass[loop] = Value; } } return; }
int Set_IgmpSn_DelEntry_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { int i, memberCnt = 0; BOOLEAN bGroupId = 1; PSTRING value; PSTRING thisChar; UCHAR IpAddr[4]; UCHAR Addr[ETH_LENGTH_OF_ADDRESS]; UCHAR GroupId[ETH_LENGTH_OF_ADDRESS]; PUCHAR *pAddr = (PUCHAR *)&Addr; PNET_DEV pDev; POS_COOKIE pObj; UCHAR ifIndex; pObj = (POS_COOKIE) pAd->OS_Cookie; ifIndex = pObj->ioctl_if; pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].MSSIDDev); while ((thisChar = strsep((char **)&arg, "-")) != NULL) { /* refuse the Member if it's not a MAC address. */ if((bGroupId == 0) && (strlen(thisChar) != 17)) continue; if(strlen(thisChar) == 17) /*Mac address acceptable format 01:02:03:04:05:06 length 17 */ { for (i=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":")) { if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) return FALSE; /*Invalid */ AtoH(value, &Addr[i++], 1); } if(i != 6) return FALSE; /*Invalid */ } else { for (i=0, value = rstrtok(thisChar,"."); value; value = rstrtok(NULL,".")) { if((strlen(value) > 0) && (strlen(value) <= 3)) { int ii; for(ii=0; ii<strlen(value); ii++) if (!isxdigit(*(value + ii))) return FALSE; } else return FALSE; /*Invalid */ IpAddr[i] = (UCHAR)simple_strtol(value, NULL, 10); i++; } if(i != 4) return FALSE; /*Invalid */ ConvertMulticastIP2MAC(IpAddr, (PUCHAR *)&pAddr, ETH_P_IP); } if(bGroupId == 1) COPY_MAC_ADDR(GroupId, Addr); else memberCnt++; if (memberCnt > 0 ) MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, Addr, pDev); bGroupId = 0; } if(memberCnt == 0) MulticastFilterTableDeleteEntry(pAd, (PUCHAR)GroupId, NULL, pDev); DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X)\n", __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5])); return TRUE; }
/* ======================================================================== Routine Description: In kernel mode read parameters from file Arguments: src the location of the file. dest put the parameters to the destination. Length size to read. Return Value: None Note: ======================================================================== */ void rtmp_read_wapi_parms_from_file( IN PRTMP_ADAPTER pAd, RTMP_STRING *tmpbuf, RTMP_STRING *buffer) { UINT32 ip_addr; #ifdef CONFIG_AP_SUPPORT INT apidx = 0; #endif /* CONFIG_AP_SUPPORT */ RTMP_STRING tok_str[32]; INT idx; PCOMMON_WAPI_INFO pInfo = &pAd->CommonCfg.comm_wapi_info; /* wapi interface name */ if (RTMPGetKeyParameter("Wapiifname", tmpbuf, 32, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->wapi_ifname, tmpbuf, strlen(tmpbuf)); pInfo->wapi_ifname_len = strlen(tmpbuf); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("Wapiifname=%s, len=%d\n", pInfo->wapi_ifname, pInfo->wapi_ifname_len)); } } /* WapiAsCertPath */ if (RTMPGetKeyParameter("WapiAsCertPath", tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->as_cert_path[0], tmpbuf, strlen(tmpbuf)); pInfo->as_cert_path_len[0] = strlen(tmpbuf); pInfo->as_cert_no = 1; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiAsCertPath=%s, len=%d\n", pInfo->as_cert_path[0], pInfo->as_cert_path_len[0])); } } /* WapiAsCertPath2 ~ WapiAsCertPath10 */ for (idx = 1; idx < MAX_ID_NO; idx++) { sprintf(tok_str, "WapiAsCertPath%d", idx + 1); if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->as_cert_path[idx], tmpbuf, strlen(tmpbuf)); pInfo->as_cert_path_len[idx] = strlen(tmpbuf); pInfo->as_cert_no++; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiAsCertPath%d=%s, len=%d\n", idx+1, pInfo->as_cert_path[idx], pInfo->as_cert_path_len[idx])); } } } /* WapiCaCertPath */ if (RTMPGetKeyParameter("WapiCaCertPath", tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->ca_cert_path, tmpbuf, strlen(tmpbuf)); pInfo->ca_cert_path_len = strlen(tmpbuf); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiCaCertPath=%s, len=%d\n", pInfo->ca_cert_path, pInfo->ca_cert_path_len)); } } /* WapiUserCertPath */ if (RTMPGetKeyParameter("WapiUserCertPath", tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->user_cert_path, tmpbuf, strlen(tmpbuf)); pInfo->user_cert_path_len = strlen(tmpbuf); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiUserCertPath=%s, len=%d\n", pInfo->user_cert_path, pInfo->user_cert_path_len)); } } /* WapiAsIpAddr */ if (RTMPGetKeyParameter("WapiAsIpAddr", tmpbuf, 32, buffer, TRUE)) { if (rtinet_aton(tmpbuf, &ip_addr)) { pInfo->wapi_as_ip = ip_addr; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiAsIpAddr=%s(%x)\n", tmpbuf, pInfo->wapi_as_ip)); } } /* WapiAsPort */ if (RTMPGetKeyParameter("WapiAsPort", tmpbuf, 32, buffer, TRUE)) { pInfo->wapi_as_port = simple_strtol(tmpbuf, 0, 10); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiAsPort=%d\n", pInfo->wapi_as_port)); } /* WapiUskRekeyMethod */ if (RTMPGetKeyParameter("WapiUskRekeyMethod", tmpbuf, 32, buffer, TRUE)) { if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0)) pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_TIME; else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0)) pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_PKT; else pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_DISABLE; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiUskRekeyMethod=%d\n", pAd->CommonCfg.wapi_usk_rekey_method)); } /* WapiUskRekeyThreshold */ if (RTMPGetKeyParameter("WapiUskRekeyThreshold", tmpbuf, 32, buffer, TRUE)) { pAd->CommonCfg.wapi_usk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiUskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_usk_rekey_threshold)); } /* WapiMskRekeyMethod */ if (RTMPGetKeyParameter("WapiMskRekeyMethod", tmpbuf, 32, buffer, TRUE)) { if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0)) pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_TIME; else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0)) pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_PKT; else pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_DISABLE; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiMskRekeyMethod=%d\n", pAd->CommonCfg.wapi_msk_rekey_method)); } /* WapiMskRekeyThreshold */ if (RTMPGetKeyParameter("WapiMskRekeyThreshold", tmpbuf, 32, buffer, TRUE)) { pAd->CommonCfg.wapi_msk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("WapiMskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_msk_rekey_threshold)); } #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { RTMP_STRING tok_str[16]; /* WapiPskX */ for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) { snprintf(tok_str, sizeof(tok_str), "WapiPsk%d", apidx + 1); NdisZeroMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, 64); pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = 0; if(RTMPGetKeyParameter(tok_str, tmpbuf, 65, buffer, FALSE)) { if (strlen(tmpbuf) >= 8 && strlen(tmpbuf) <= 64) { NdisMoveMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, tmpbuf, strlen(tmpbuf)); pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = strlen(tmpbuf); MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("IF(ra%d) WapiPsk=(%s), len=%d\n", apidx, tmpbuf, strlen(tmpbuf))); } else { if (pAd->ApCfg.MBSSID[apidx].wdev.AuthMode == Ndis802_11AuthModeWAIPSK) { pAd->ApCfg.MBSSID[apidx].wdev.AuthMode = Ndis802_11AuthModeOpen; pAd->ApCfg.MBSSID[apidx].wdev.WepStatus = Ndis802_11EncryptionDisabled; } MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR, ("IF(ra%d) The length of WAPI PSKPassPhrase is invalid(len=%d). \n", apidx, strlen(tmpbuf))); } } } } #endif /* CONFIG_AP_SUPPORT */ /* WapiPskType */ if (RTMPGetKeyParameter("WapiPskType", tmpbuf, 32, buffer, TRUE)) { INT err; #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { RTMP_STRING *macptr; for (apidx = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), apidx++) { err = 0; if (apidx >= pAd->ApCfg.BssidNum) break; /* HEX */ if(simple_strtol(macptr, 0, 10) == 0) { pAd->ApCfg.MBSSID[apidx].WapiPskType = HEX_MODE; if (pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen % 2 != 0) { err = 1; MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR, ("I/F(ra%d) The WAPI-PSK key length MUST be even in Hex mode\n", apidx)); } } /* ASCII */ else { pAd->ApCfg.MBSSID[apidx].WapiPskType = ASCII_MODE; } if (err) { pAd->ApCfg.MBSSID[apidx].wdev.AuthMode = Ndis802_11AuthModeOpen; pAd->ApCfg.MBSSID[apidx].wdev.WepStatus = Ndis802_11EncryptionDisabled; } else MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("I/F(ra%d) WapiPskType=%s\n", apidx, (pAd->ApCfg.MBSSID[apidx].WapiPskType == HEX_MODE) ? "HEX" : "ASCII")); } } #endif /* CONFIG_AP_SUPPORT */ }
VOID rtmp_read_wds_from_file( IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer) { PSTRING macptr; INT i=0, j; STRING tok_str[16]; BOOLEAN bUsePrevFormat = FALSE; UCHAR macAddress[MAC_ADDR_LEN]; UCHAR keyMaterial[40]; UCHAR KeyLen, CipherAlg = CIPHER_NONE, KeyIdx; PRT_802_11_WDS_ENTRY pWdsEntry; /*WdsPhyMode */ if (RTMPGetKeyParameter("WdsPhyMode", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE)) { for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { if ((strncmp(macptr, "CCK", 3) == 0) || (strncmp(macptr, "cck", 3) == 0)) pAd->WdsTab.WdsEntry[i].PhyMode = MODE_CCK; else if ((strncmp(macptr, "OFDM", 4) == 0) || (strncmp(macptr, "ofdm", 4) == 0)) pAd->WdsTab.WdsEntry[i].PhyMode = MODE_OFDM; #ifdef DOT11_N_SUPPORT else if ((strncmp(macptr, "HTMIX", 5) == 0) || (strncmp(macptr, "htmix", 5) == 0)) pAd->WdsTab.WdsEntry[i].PhyMode = MODE_HTMIX; else if ((strncmp(macptr, "GREENFIELD", 10) == 0) || (strncmp(macptr, "greenfield", 10) == 0)) pAd->WdsTab.WdsEntry[i].PhyMode = MODE_HTGREENFIELD; #endif /* DOT11_N_SUPPORT */ else pAd->WdsTab.WdsEntry[i].PhyMode = 0xff; DBGPRINT(RT_DEBUG_TRACE, ("If/wds%d - WdsPhyMode=%d\n", i, pAd->WdsTab.WdsEntry[i].PhyMode)); } } /*WdsList */ if (RTMPGetKeyParameter("WdsList", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE)) { if (pAd->WdsTab.Mode != WDS_LAZY_MODE) { for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { if(strlen(macptr) != 17) /*Mac address acceptable format 01:02:03:04:05:06 length 17 */ continue; if(strcmp(macptr,"00:00:00:00:00:00") == 0) continue; if(i >= MAX_WDS_ENTRY) break; for (j=0; j<ETH_LENGTH_OF_ADDRESS; j++) { AtoH(macptr, &macAddress[j], 1); macptr=macptr+3; } WdsEntryAlloc(pAd, macAddress); } } } /*WdsEncrypType */ if (RTMPGetKeyParameter("WdsEncrypType", tmpbuf, 128, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { if ((strncmp(macptr, "NONE", 4) == 0) || (strncmp(macptr, "none", 4) == 0)) pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPDisabled; else if ((strncmp(macptr, "WEP", 3) == 0) || (strncmp(macptr, "wep", 3) == 0)) pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPEnabled; else if ((strncmp(macptr, "TKIP", 4) == 0) || (strncmp(macptr, "tkip", 4) == 0)) pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11Encryption2Enabled; else if ((strncmp(macptr, "AES", 3) == 0) || (strncmp(macptr, "aes", 3) == 0)) pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11Encryption3Enabled; else pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11WEPDisabled; DBGPRINT(RT_DEBUG_TRACE, ("WdsEncrypType[%d]=%d(%s)\n", i, pAd->WdsTab.WdsEntry[i].WepStatus, GetEncryptType(pAd->WdsTab.WdsEntry[i].WepStatus))); } /* Previous WDS only supports single encryption type. */ /* For backward compatible, other wds link encryption type shall be the same with the first. */ if (i == 1) { for (j = 1; j < MAX_WDS_ENTRY; j++) { pAd->WdsTab.WdsEntry[j].WepStatus = pAd->WdsTab.WdsEntry[0].WepStatus; DBGPRINT(RT_DEBUG_TRACE, ("@WdsEncrypType[%d]=%d(%s)\n", j, pAd->WdsTab.WdsEntry[i].WepStatus, GetEncryptType(pAd->WdsTab.WdsEntry[i].WepStatus))); } } } /* WdsKey */ /* This is a previous parameter and it only stores WPA key material, not WEP key */ if (RTMPGetKeyParameter("WdsKey", tmpbuf, 255, buffer, FALSE)) { for (i = 0; i < MAX_WDS_ENTRY; i++) NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY)); if (strlen(tmpbuf) > 0) bUsePrevFormat = TRUE; /* check if the wds-0 link key material is valid */ if (((pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption2Enabled) || (pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption3Enabled)) && (strlen(tmpbuf) >= 8) && (strlen(tmpbuf) <= 64)) { RT_CfgSetWPAPSKKey(pAd, tmpbuf, strlen(tmpbuf), (PUCHAR)RALINK_PASSPHRASE, sizeof(RALINK_PASSPHRASE), keyMaterial); if (pAd->WdsTab.WdsEntry[0].WepStatus == Ndis802_11Encryption3Enabled) pAd->WdsTab.WdsEntry[0].WdsKey.CipherAlg = CIPHER_AES; else pAd->WdsTab.WdsEntry[0].WdsKey.CipherAlg = CIPHER_TKIP; NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.Key, keyMaterial, 16); pAd->WdsTab.WdsEntry[0].WdsKey.KeyLen = 16; NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.RxMic, keyMaterial+16, 8); NdisMoveMemory(&pAd->WdsTab.WdsEntry[0].WdsKey.TxMic, keyMaterial+16, 8); } /* Previous WDS only supports single key-material. */ /* For backward compatible, other wds link key-material shall be the same with the first. */ if (pAd->WdsTab.WdsEntry[0].WdsKey.KeyLen == 16) { for (j = 1; j < MAX_WDS_ENTRY; j++) { NdisMoveMemory(&pAd->WdsTab.WdsEntry[j].WdsKey, &pAd->WdsTab.WdsEntry[0].WdsKey, sizeof(CIPHER_KEY)); } } } /* The parameters can provide different key information for each WDS-Link */ /* no matter WEP or WPA */ if (!bUsePrevFormat) { for (i = 0; i < MAX_WDS_ENTRY; i++) { AP_WDS_KeyNameMakeUp(tok_str, sizeof(tok_str), i); /* WdsXKey (X=0~MAX_WDS_ENTRY-1) */ if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer, FALSE)) { if (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption1Enabled) { /* Ascii type */ if (strlen(tmpbuf) == 5 || strlen(tmpbuf) == 13) { KeyLen = strlen(tmpbuf); pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = KeyLen; NdisMoveMemory(pAd->WdsTab.WdsEntry[i].WdsKey.Key, tmpbuf, KeyLen); if (KeyLen == 5) CipherAlg = CIPHER_WEP64; else CipherAlg = CIPHER_WEP128; pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CipherAlg; DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s ,type=Ascii, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_WEP64 ? "wep64" : "wep128"))); } /* Hex type */ else if (strlen(tmpbuf) == 10 || strlen(tmpbuf) == 26) { KeyLen = strlen(tmpbuf); pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = KeyLen / 2; AtoH(tmpbuf, pAd->WdsTab.WdsEntry[i].WdsKey.Key, KeyLen / 2); if (KeyLen == 10) CipherAlg = CIPHER_WEP64; else CipherAlg = CIPHER_WEP128; pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CipherAlg; DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s ,type=Hex, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_WEP64 ? "wep64" : "wep128"))); } /* Invalid type */ else { pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled; NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY)); DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d has invalid key for WEP, reset encryption to OPEN\n", i)); } } else if ((pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption2Enabled) || (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled)) { if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) <= 64)) { RT_CfgSetWPAPSKKey(pAd, tmpbuf, strlen(tmpbuf), (PUCHAR) RALINK_PASSPHRASE, sizeof(RALINK_PASSPHRASE), keyMaterial); if (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled) pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CIPHER_AES; else pAd->WdsTab.WdsEntry[i].WdsKey.CipherAlg = CIPHER_TKIP; NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.Key, keyMaterial, 16); pAd->WdsTab.WdsEntry[i].WdsKey.KeyLen = 16; NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.RxMic, keyMaterial+16, 8); NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey.TxMic, keyMaterial+16, 8); DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d Key=%s, CipherAlg(%s)\n", i, tmpbuf, (CipherAlg == CIPHER_AES ? "AES" : "TKIP"))); } else { DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d has invalid key for WPA, reset encryption to OPEN\n", i)); pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled; NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY)); } } else { pAd->WdsTab.WdsEntry[i].WepStatus = Ndis802_11EncryptionDisabled; NdisZeroMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, sizeof(CIPHER_KEY)); } } } } /* WdsDefaultKeyID */ if(RTMPGetKeyParameter("WdsDefaultKeyID", tmpbuf, 10, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { KeyIdx = (UCHAR) simple_strtol(macptr, 0, 10); if((KeyIdx >= 1 ) && (KeyIdx <= 4)) pAd->WdsTab.WdsEntry[i].KeyIdx = (UCHAR) (KeyIdx - 1); else pAd->WdsTab.WdsEntry[i].KeyIdx = 0; if ((pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption2Enabled) || (pAd->WdsTab.WdsEntry[i].WepStatus == Ndis802_11Encryption3Enabled)) pAd->WdsTab.WdsEntry[i].KeyIdx = 0; DBGPRINT(RT_DEBUG_TRACE, ("IF/wds%d - WdsDefaultKeyID(0~3)=%d\n", i, pAd->WdsTab.WdsEntry[i].KeyIdx)); } } /* WdsTxMode */ if (RTMPGetKeyParameter("WdsTxMode", tmpbuf, 25, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { pWdsEntry = &pAd->WdsTab.WdsEntry[i]; pWdsEntry->DesiredTransmitSetting.field.FixedTxMode = RT_CfgSetFixedTxPhyMode(macptr); DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx Mode = %d\n", i, pWdsEntry->DesiredTransmitSetting.field.FixedTxMode)); } } /* WdsTxMcs */ if (RTMPGetKeyParameter("WdsTxMcs", tmpbuf, 50, buffer, TRUE)) { for (i = 0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { pWdsEntry = &pAd->WdsTab.WdsEntry[i]; pWdsEntry->DesiredTransmitSetting.field.MCS = RT_CfgSetTxMCSProc(macptr, &pWdsEntry->bAutoTxRateSwitch); if (pWdsEntry->DesiredTransmitSetting.field.MCS == MCS_AUTO) { DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx MCS = AUTO\n", i)); } else { DBGPRINT(RT_DEBUG_TRACE, ("I/F(wds%d) Tx MCS = %d\n", i, pWdsEntry->DesiredTransmitSetting.field.MCS)); } } } /*WdsEnable */ if(RTMPGetKeyParameter("WdsEnable", tmpbuf, 10, buffer, TRUE)) { RT_802_11_WDS_ENTRY *pWdsEntry; switch(simple_strtol(tmpbuf, 0, 10)) { case 2: /* Bridge mode, DisAllow association(stop Beacon generation and Probe Req. */ pAd->WdsTab.Mode = WDS_BRIDGE_MODE; break; case 1: case 3: /* Repeater mode */ pAd->WdsTab.Mode = WDS_REPEATER_MODE; break; case 4: /* Lazy mode, Auto learn wds entry by same SSID, channel, security policy */ for(i = 0; i < MAX_WDS_ENTRY; i++) { pWdsEntry = &pAd->WdsTab.WdsEntry[i]; if (pWdsEntry->Valid) WdsEntryDel(pAd, pWdsEntry->PeerWdsAddr); /* When Lazy mode is enabled, the all wds-link shall share the same encryption type and key material */ if (i > 0) { pAd->WdsTab.WdsEntry[i].WepStatus = pAd->WdsTab.WdsEntry[0].WepStatus; pAd->WdsTab.WdsEntry[i].KeyIdx = pAd->WdsTab.WdsEntry[0].KeyIdx; NdisMoveMemory(&pAd->WdsTab.WdsEntry[i].WdsKey, &pAd->WdsTab.WdsEntry[0].WdsKey, sizeof(CIPHER_KEY)); } } pAd->WdsTab.Mode = WDS_LAZY_MODE; break; case 0: /* Disable mode */ default: APWdsInitialize(pAd); pAd->WdsTab.Mode = WDS_DISABLE_MODE; break; } DBGPRINT(RT_DEBUG_TRACE, ("WDS-Enable mode=%d\n", pAd->WdsTab.Mode)); } #ifdef WDS_VLAN_SUPPORT /* WdsVlan */ if (RTMPGetKeyParameter("WDS_VLANID", tmpbuf, MAX_PARAM_BUFFER_SIZE, buffer, TRUE)) { for (i=0, macptr = rstrtok(tmpbuf,";"); (macptr && i < MAX_WDS_ENTRY); macptr = rstrtok(NULL,";"), i++) { pAd->WdsTab.WdsEntry[i].VLAN_VID = simple_strtol(macptr, 0, 10); pAd->WdsTab.WdsEntry[i].VLAN_Priority = 0; DBGPRINT(RT_DEBUG_TRACE, ("If/wds%d - WdsVlanId=%d\n", i, pAd->WdsTab.WdsEntry[i].VLAN_VID)); } } #endif /* WDS_VLAN_SUPPORT */ }
INT Set_IgmpSn_AddEntry_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg) { INT i; BOOLEAN bGroupId = 1; RTMP_STRING *value; RTMP_STRING *thisChar; UCHAR IpAddr[4]; UCHAR Addr[MAC_ADDR_LEN]; UCHAR GroupId[MAC_ADDR_LEN]; PUCHAR *pAddr = (PUCHAR *)&Addr; PNET_DEV pDev; POS_COOKIE pObj; UCHAR ifIndex; pObj = (POS_COOKIE) pAd->OS_Cookie; ifIndex = pObj->ioctl_if; pDev = (ifIndex == MAIN_MBSSID) ? (pAd->net_dev) : (pAd->ApCfg.MBSSID[ifIndex].wdev.if_dev); while ((thisChar = strsep((char **)&arg, "-")) != NULL) { /* refuse the Member if it's not a MAC address. */ if((bGroupId == 0) && (strlen(thisChar) != 17)) continue; if(strlen(thisChar) == 17) /*Mac address acceptable format 01:02:03:04:05:06 length 17 */ { for (i=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":")) { if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) return FALSE; /*Invalid */ AtoH(value, &Addr[i++], 1); } if(i != 6) return FALSE; /*Invalid */ } else { for (i=0, value = rstrtok(thisChar,"."); value; value = rstrtok(NULL,".")) { if((strlen(value) > 0) && (strlen(value) <= 3)) { int ii; for(ii=0; ii<strlen(value); ii++) if (!isxdigit(*(value + ii))) return FALSE; } else return FALSE; /*Invalid */ IpAddr[i] = (UCHAR)simple_strtol(value, NULL, 10); i++; } if(i != 4) return FALSE; /*Invalid */ ConvertMulticastIP2MAC(IpAddr, (PUCHAR *)&pAddr, ETH_P_IP); } if(bGroupId == 1) COPY_MAC_ADDR(GroupId, Addr); /* Group-Id must be a MCAST address. */ if((bGroupId == 1) && IS_MULTICAST_MAC_ADDR(Addr)) MulticastFilterTableInsertEntry(pAd, GroupId, NULL, pDev, MCAT_FILTER_STATIC); /* Group-Member must be a UCAST address. */ else if ((bGroupId == 0) && !IS_MULTICAST_MAC_ADDR(Addr)) MulticastFilterTableInsertEntry(pAd, GroupId, Addr, pDev, MCAT_FILTER_STATIC); else { DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X) is not a acceptable address.\n", __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5])); return FALSE; } bGroupId = 0; DBGPRINT(RT_DEBUG_TRACE, ("%s (%2X:%2X:%2X:%2X:%2X:%2X)\n", __FUNCTION__, Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5])); } return TRUE; }
/* ======================================================================== Routine Description: In kernel mode read parameters from file Arguments: src the location of the file. dest put the parameters to the destination. Length size to read. Return Value: None Note: ======================================================================== */ void rtmp_read_wapi_parms_from_file( IN PRTMP_ADAPTER pAd, PSTRING tmpbuf, PSTRING buffer) { UINT32 ip_addr; #ifdef CONFIG_AP_SUPPORT INT apidx = 0; #endif // CONFIG_AP_SUPPORT // PCOMMON_WAPI_INFO pInfo = &pAd->CommonCfg.comm_wapi_info; // wapi interface name if (RTMPGetKeyParameter("Wapiifname", tmpbuf, 32, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->wapi_ifname, tmpbuf, strlen(tmpbuf)); pInfo->wapi_ifname_len = strlen(tmpbuf); DBGPRINT(RT_DEBUG_TRACE, ("Wapiifname=%s, len=%d\n", pInfo->wapi_ifname, pInfo->wapi_ifname_len)); } } // WapiAsCertPath if (RTMPGetKeyParameter("WapiAsCertPath", tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->as_cert_path, tmpbuf, strlen(tmpbuf)); pInfo->as_cert_path_len = strlen(tmpbuf); DBGPRINT(RT_DEBUG_TRACE, ("WapiAsCertPath=%s, len=%d\n", pInfo->as_cert_path, pInfo->as_cert_path_len)); } } // WapiUserCertPath if (RTMPGetKeyParameter("WapiUserCertPath", tmpbuf, 128, buffer, TRUE)) { if (strlen(tmpbuf) > 0) { NdisMoveMemory(pInfo->user_cert_path, tmpbuf, strlen(tmpbuf)); pInfo->user_cert_path_len = strlen(tmpbuf); DBGPRINT(RT_DEBUG_TRACE, ("WapiUserCertPath=%s, len=%d\n", pInfo->user_cert_path, pInfo->user_cert_path_len)); } } // WapiAsIpAddr if (RTMPGetKeyParameter("WapiAsIpAddr", tmpbuf, 32, buffer, TRUE)) { if (rtinet_aton(tmpbuf, &ip_addr)) { pInfo->wapi_as_ip = ip_addr; DBGPRINT(RT_DEBUG_TRACE, ("WapiAsIpAddr=%s(%x)\n", tmpbuf, pInfo->wapi_as_ip)); } } // WapiAsPort if (RTMPGetKeyParameter("WapiAsPort", tmpbuf, 32, buffer, TRUE)) { pInfo->wapi_as_port = simple_strtol(tmpbuf, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("WapiAsPort=%d\n", pInfo->wapi_as_port)); } // WapiUskRekeyMethod if (RTMPGetKeyParameter("WapiUskRekeyMethod", tmpbuf, 32, buffer, TRUE)) { if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0)) pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_TIME; else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0)) pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_PKT; else pAd->CommonCfg.wapi_usk_rekey_method = REKEY_METHOD_DISABLE; DBGPRINT(RT_DEBUG_TRACE, ("WapiUskRekeyMethod=%d\n", pAd->CommonCfg.wapi_usk_rekey_method)); } // WapiUskRekeyThreshold if (RTMPGetKeyParameter("WapiUskRekeyThreshold", tmpbuf, 32, buffer, TRUE)) { pAd->CommonCfg.wapi_usk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("WapiUskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_usk_rekey_threshold)); } // WapiMskRekeyMethod if (RTMPGetKeyParameter("WapiMskRekeyMethod", tmpbuf, 32, buffer, TRUE)) { if ((strcmp(tmpbuf, "TIME") == 0) || (strcmp(tmpbuf, "time") == 0)) pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_TIME; else if ((strcmp(tmpbuf, "PKT") == 0) || (strcmp(tmpbuf, "pkt") == 0)) pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_PKT; else pAd->CommonCfg.wapi_msk_rekey_method = REKEY_METHOD_DISABLE; DBGPRINT(RT_DEBUG_TRACE, ("WapiMskRekeyMethod=%d\n", pAd->CommonCfg.wapi_msk_rekey_method)); } // WapiMskRekeyThreshold if (RTMPGetKeyParameter("WapiMskRekeyThreshold", tmpbuf, 32, buffer, TRUE)) { pAd->CommonCfg.wapi_msk_rekey_threshold = simple_strtol(tmpbuf, 0, 10); DBGPRINT(RT_DEBUG_TRACE, ("WapiMskRekeyThreshold=%d\n", pAd->CommonCfg.wapi_msk_rekey_threshold)); } #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { STRING tok_str[16]; // WapiPskX for (apidx = 0; apidx < pAd->ApCfg.BssidNum; apidx++) { sprintf(tok_str, "WapiPsk%d", apidx + 1); NdisZeroMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, 64); pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = 0; if(RTMPGetKeyParameter(tok_str, tmpbuf, 65, buffer, FALSE)) { if (strlen(tmpbuf) >= 8 && strlen(tmpbuf) <= 64) { NdisMoveMemory(pAd->ApCfg.MBSSID[apidx].WAPIPassPhrase, tmpbuf, strlen(tmpbuf)); pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen = strlen(tmpbuf); DBGPRINT(RT_DEBUG_TRACE, ("IF(ra%d) WapiPsk=(%s), len=%d\n", apidx, tmpbuf, strlen(tmpbuf))); } else { if (pAd->ApCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWAIPSK) { pAd->ApCfg.MBSSID[apidx].AuthMode = Ndis802_11AuthModeOpen; pAd->ApCfg.MBSSID[apidx].WepStatus = Ndis802_11EncryptionDisabled; } DBGPRINT(RT_DEBUG_ERROR, ("IF(ra%d) The length of WAPI PSKPassPhrase is invalid(len=%d). \n", apidx, strlen(tmpbuf))); } } } } #endif // CONFIG_AP_SUPPORT // // WapiPskType if (RTMPGetKeyParameter("WapiPskType", tmpbuf, 32, buffer, TRUE)) { INT err; #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { PSTRING macptr; for (apidx = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), apidx++) { err = 0; if (apidx >= pAd->ApCfg.BssidNum) break; // HEX if(simple_strtol(macptr, 0, 10) == 0) { pAd->ApCfg.MBSSID[apidx].WapiPskType = HEX_MODE; if (pAd->ApCfg.MBSSID[apidx].WAPIPassPhraseLen % 2 != 0) { err = 1; DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) The WAPI-PSK key length MUST be even in Hex mode\n", apidx)); } } // ASCII else { pAd->ApCfg.MBSSID[apidx].WapiPskType = ASCII_MODE; } if (err) { pAd->ApCfg.MBSSID[apidx].AuthMode = Ndis802_11AuthModeOpen; pAd->ApCfg.MBSSID[apidx].WepStatus = Ndis802_11EncryptionDisabled; } else DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) WapiPskType=%s\n", apidx, (pAd->ApCfg.MBSSID[apidx].WapiPskType == HEX_MODE) ? "HEX" : "ASCII")); } } #endif // CONFIG_AP_SUPPORT // }
INT Set_BeaconReq_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { INT Loop; POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; UCHAR ifIndex = pObj->ioctl_if; UINT Aid = 1; UINT ArgIdx; PSTRING thisChar; RRM_MLME_BCN_REQ_INFO BcnReq; ArgIdx = 0; NdisZeroMemory(&BcnReq, sizeof(RRM_MLME_BCN_REQ_INFO)); while ((thisChar = strsep((char **)&arg, "-")) != NULL) { switch(ArgIdx) { case 0: /* Aid. */ Aid = (UINT8) simple_strtol(thisChar, 0, 16); if (!VALID_WCID(Aid)) { DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid)); return TRUE; } break; case 1: /* Meausre Duration. */ BcnReq.MeasureDuration = (UINT8) simple_strtol(thisChar, 0, 10); case 2: /* Regulator Class */ BcnReq.RegulatoryClass = (UINT8) simple_strtol(thisChar, 0, 10); break; case 3: /* BSSID */ if(strlen(thisChar) != 17) { DBGPRINT(RT_DEBUG_ERROR, ("%s: invalid value BSSID.\n", __FUNCTION__)); return TRUE; } if(strlen(thisChar) == 17) /*Mac address acceptable format 01:02:03:04:05:06 length 17 */ { PSTRING value; for (Loop=0, value = rstrtok(thisChar,":"); value; value = rstrtok(NULL,":")) { if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) return FALSE; /*Invalid */ AtoH(value, &BcnReq.Bssid[Loop++], 1); } if(Loop != 6) return TRUE; } break; case 4: /* SSID */ BcnReq.pSsid = (PUINT8)thisChar; BcnReq.SsidLen = strlen(thisChar); break; case 5: /* measure channel */ BcnReq.MeasureCh = (UINT8) simple_strtol(thisChar, 0, 10); break; case 6: /* measure mode. */ BcnReq.MeasureMode = (UINT8) simple_strtol(thisChar, 0, 10); if (BcnReq.MeasureMode > RRM_BCN_REQ_MODE_BCNTAB) { DBGPRINT(RT_DEBUG_ERROR, ("%s: invalid Measure Mode. %d\n", __FUNCTION__, BcnReq.MeasureMode)); return TRUE; } case 7: /* regulatory class. */ { PSTRING RegClassString; int RegClassIdx; RegClassIdx = 0; while ((RegClassString = strsep((char **)&thisChar, "+")) != NULL) { BcnReq.ChRepRegulatoryClass[RegClassIdx] = (UINT8) simple_strtol(RegClassString, 0, 10); RegClassIdx++; } } break; } ArgIdx++; } if (ArgIdx < 7 || ArgIdx > 8) { DBGPRINT(RT_DEBUG_ERROR, ("%s: invalid args (%d).\n", __FUNCTION__, ArgIdx)); DBGPRINT(RT_DEBUG_ERROR, ("eg: iwpriv ra0 set BcnReq=<Aid>-<Duration>-<RegulatoryClass>-<BSSID>-<SSID>-<MeasureCh>-<MeasureMode>-<ChRegClass>\n")); return TRUE; } #ifdef RELEASE_EXCLUDE DBGPRINT(RT_DEBUG_ERROR, ("%s::Aid = %d\n", __FUNCTION__, Aid)); DBGPRINT(RT_DEBUG_ERROR, ("%s::Bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__, BcnReq.Bssid[0], BcnReq.Bssid[1], BcnReq.Bssid[2], BcnReq.Bssid[3], BcnReq.Bssid[4], BcnReq.Bssid[5])); DBGPRINT(RT_DEBUG_ERROR, ("%s::SsidLen = %d\n", __FUNCTION__, BcnReq.SsidLen)); DBGPRINT(RT_DEBUG_ERROR, ("%s::MeasureCh = %d\n", __FUNCTION__, BcnReq.MeasureCh)); DBGPRINT(RT_DEBUG_ERROR, ("%s::RegulatoryDuration=%d\n", __FUNCTION__, BcnReq.MeasureDuration)); DBGPRINT(RT_DEBUG_ERROR, ("%s::MeasureMode=%d\n", __FUNCTION__, BcnReq.MeasureMode)); DBGPRINT(RT_DEBUG_ERROR, ("RegulatoryClass=")); for (ArgIdx=0; ArgIdx<MAX_NUM_OF_REGULATORY_CLASS; ArgIdx++) { if (BcnReq.ChRepRegulatoryClass[ArgIdx] == 0) break; DBGPRINT(RT_DEBUG_ERROR, ("%d ", \ BcnReq.ChRepRegulatoryClass[ArgIdx])); } DBGPRINT(RT_DEBUG_ERROR, ("\n")); #endif /* RELEASE_EXCLUDE */ BcnReq.BcnReqCapFlag.field.ReportCondition = TRUE; if (BcnReq.MeasureCh == 255) BcnReq.BcnReqCapFlag.field.ChannelRep = TRUE; else BcnReq.BcnReqCapFlag.field.ChannelRep = FALSE; RRM_EnqueueBcnReq(pAd, Aid, ifIndex, &BcnReq); return TRUE; }