wifi: Fix address returned by StaWifiMac::DoGetLocalAddress()

Return the address of the link used to communicate with the single-link
AP if the remote address is the BSSID, or the MLD address otherwise.
This commit is contained in:
Stefano Avallone
2024-06-20 16:32:30 +02:00
committed by Stefano Avallone
parent ed053d33ac
commit b5e4e89b4c
2 changed files with 12 additions and 5 deletions

View File

@@ -960,10 +960,17 @@ StaWifiMac::GetSetupLinkIds() const
Mac48Address
StaWifiMac::DoGetLocalAddress(const Mac48Address& remoteAddr) const
{
auto linkIds = GetSetupLinkIds();
NS_ASSERT_MSG(!linkIds.empty(), "Not associated");
uint8_t linkId = *linkIds.begin();
return GetFrameExchangeManager(linkId)->GetAddress();
for (const auto& [id, link] : GetLinks())
{
if (GetStaLink(link).bssid == remoteAddr)
{
// the remote address is the address of the (single link) AP we are associated with;
return link->feManager->GetAddress();
}
}
// the remote address is unknown
return GetAddress();
}
bool

View File

@@ -1780,7 +1780,7 @@ WifiMac::GetLocalAddress(const Mac48Address& remoteAddr) const
// this is a single link device
return m_address;
}
// this is an MLD (hence the remote device is single link)
// this is an MLD (hence the remote device is single link or unknown)
return DoGetLocalAddress(remoteAddr);
}