ULONG AutoChBssInsertEntry( IN PRTMP_ADAPTER pAd, IN PUCHAR pBssid, IN CHAR Ssid[], IN UCHAR SsidLen, IN UCHAR ChannelNo, IN UCHAR ExtChOffset, IN CHAR Rssi) { ULONG Idx; PBSSINFO pBssInfoTab = pAd->pBssInfoTab; if(pBssInfoTab == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("pAd->pBssInfoTab equal NULL.\n")); return BSS_NOT_FOUND; } Idx = AutoChBssSearchWithSSID(pAd, pBssid, (PUCHAR)Ssid, SsidLen, ChannelNo); if (Idx == BSS_NOT_FOUND) { if (pBssInfoTab->BssNr >= MAX_LEN_OF_BSS_TABLE) return BSS_NOT_FOUND; Idx = pBssInfoTab->BssNr; AutoChBssEntrySet(&pBssInfoTab->BssEntry[Idx], pBssid, Ssid, SsidLen, ChannelNo, ExtChOffset, Rssi); pBssInfoTab->BssNr++; } else { AutoChBssEntrySet(&pBssInfoTab->BssEntry[Idx], pBssid, Ssid, SsidLen, ChannelNo, ExtChOffset, Rssi); } return Idx; }
/* ========================================================================== Description: peer sends beacon back when scanning ========================================================================== */ VOID ApCliPeerProbeRspAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { PFRAME_802_11 pFrame; UCHAR *VarIE = NULL; USHORT LenVIE; NDIS_802_11_VARIABLE_IEs *pVIE = NULL; CHAR RealRssi = -127; BCN_IE_LIST *ie_list = NULL; /* allocate memory */ os_alloc_mem(NULL, (UCHAR **)&VarIE, MAX_VIE_LEN); if (VarIE == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("%s: Allocate memory fail!!!\n", __FUNCTION__)); goto LabelErr; } /* Init Variable IE structure */ pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE; pVIE->Length = 0; os_alloc_mem(NULL, (UCHAR **)&ie_list, sizeof(BCN_IE_LIST)); if (ie_list == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("%s: Allocate ie_list fail!!!\n", __FUNCTION__)); goto LabelErr; } NdisZeroMemory(ie_list, sizeof(BCN_IE_LIST)); pFrame = (PFRAME_802_11) Elem->Msg; if (PeerBeaconAndProbeRspSanity(pAd, Elem->Msg, Elem->MsgLen, Elem->Channel, ie_list, &LenVIE, pVIE)) { ULONG Idx; CHAR Rssi = -127; RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0, Elem->AntSel, BW_20), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1, Elem->AntSel, BW_20), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2, Elem->AntSel, BW_20)); #ifdef P2P_SUPPORT MlmeEnqueue(pAd, P2P_DISC_STATE_MACHINE, P2P_DISC_PEER_PROB_RSP, Elem->MsgLen, Elem->Msg, ie_list->Channel); #endif /* P2P_SUPPORT */ /* ignore BEACON not in this channel */ if (ie_list->Channel != pAd->MlmeAux.Channel #ifdef DOT11_N_SUPPORT #ifdef DOT11N_DRAFT3 && (pAd->CommonCfg.bOverlapScanning == FALSE) #endif /* DOT11N_DRAFT3 */ #endif /* DOT11_N_SUPPORT */ ) { goto __End_Of_APPeerBeaconAtScanAction; } #ifdef DOT11_N_SUPPORT if ((RealRssi > OBSS_BEACON_RSSI_THRESHOLD) && (ie_list->HtCapability.HtCapInfo.Forty_Mhz_Intolerant)) /* || (HtCapabilityLen == 0))) */ { Handle_BSS_Width_Trigger_Events(pAd); } #endif /* DOT11_N_SUPPORT */ #ifdef IDS_SUPPORT /* Conflict SSID detection */ if (ie_list->Channel == pAd->CommonCfg.Channel) RTMPConflictSsidDetection(pAd, ie_list->Ssid, ie_list->SsidLen, Elem->Rssi0, Elem->Rssi1, Elem->Rssi2, Elem->AntSel); #endif /* IDS_SUPPORT */ /* This correct im-proper RSSI indication during SITE SURVEY issue. Always report bigger RSSI during SCANNING when receiving multiple BEACONs from the same AP. This case happens because BEACONs come from adjacent channels, so RSSI become weaker as we switch to more far away channels. */ Idx = BssTableSearch(&pAd->ScanTab, ie_list->Bssid, ie_list->Channel); if (Idx != BSS_NOT_FOUND) Rssi = pAd->ScanTab.BssEntry[Idx].Rssi; /* TODO: 2005-03-04 dirty patch. we should change all RSSI related variables to SIGNED SHORT for easy/efficient reading and calaulation */ RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0, Elem->AntSel, BW_20), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1, Elem->AntSel, BW_20), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2, Elem->AntSel, BW_20)); if ((RealRssi + pAd->BbpRssiToDbmDelta) > Rssi) Rssi = RealRssi + pAd->BbpRssiToDbmDelta; Idx = BssTableSetEntry(pAd, &pAd->ScanTab, ie_list, -Rssi, LenVIE, pVIE); if (Idx != BSS_NOT_FOUND) { NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4); NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4); NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4); } } /* sanity check fail, ignored */ __End_Of_APPeerBeaconAtScanAction: /*scan beacon in pastive */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { if (ie_list->Channel == pAd->ApCfg.AutoChannel_Channel) { if (AutoChBssSearchWithSSID(pAd, ie_list->Bssid, (PUCHAR)ie_list->Ssid, ie_list->SsidLen, ie_list->Channel) == BSS_NOT_FOUND) pAd->pChannelInfo->ApCnt[pAd->ApCfg.current_channel_index]++; AutoChBssInsertEntry(pAd, ie_list->Bssid, (CHAR *)ie_list->Ssid, ie_list->SsidLen, ie_list->Channel, ie_list->NewExtChannelOffset, RealRssi); } } #endif /* CONFIG_AP_SUPPORT */ LabelErr: if (VarIE != NULL) os_free_mem(NULL, VarIE); if (ie_list != NULL) os_free_mem(NULL, ie_list); }