wifi: Add a method to get the link on which a PHY is operating
This commit is contained in:
committed by
Stefano Avallone
parent
990fcc72f0
commit
1ab959a512
@@ -963,6 +963,27 @@ WifiMac::GetLinkIdByAddress(const Mac48Address& address) const
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<uint8_t>
|
||||
WifiMac::GetLinkForPhy(Ptr<const WifiPhy> phy) const
|
||||
{
|
||||
for (const auto& [id, link] : m_links)
|
||||
{
|
||||
if (link->phy == phy)
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<uint8_t>
|
||||
WifiMac::GetLinkForPhy(std::size_t phyId) const
|
||||
{
|
||||
NS_ABORT_UNLESS(phyId < m_device->GetNPhys());
|
||||
auto phy = m_device->GetPhy(phyId);
|
||||
return GetLinkForPhy(phy);
|
||||
}
|
||||
|
||||
void
|
||||
WifiMac::SwapLinks(std::map<uint8_t, uint8_t> links)
|
||||
{
|
||||
|
||||
@@ -150,6 +150,22 @@ class WifiMac : public Object
|
||||
*/
|
||||
virtual std::optional<uint8_t> GetLinkIdByAddress(const Mac48Address& address) const;
|
||||
|
||||
/**
|
||||
* Get the ID of the link (if any) on which the given PHY is operating.
|
||||
*
|
||||
* \param phy the given PHY
|
||||
* \return the ID of the link (if any) on which the given PHY is operating
|
||||
*/
|
||||
std::optional<uint8_t> GetLinkForPhy(Ptr<const WifiPhy> phy) const;
|
||||
|
||||
/**
|
||||
* Get the ID of the link (if any) on which the given PHY is operating.
|
||||
*
|
||||
* \param phyId the index of the given PHY in the vector of PHYs held by WifiNetDevice
|
||||
* \return the ID of the link (if any) on which the given PHY is operating
|
||||
*/
|
||||
std::optional<uint8_t> GetLinkForPhy(std::size_t phyId) const;
|
||||
|
||||
/**
|
||||
* \param remoteAddr the (MLD or link) address of a remote device
|
||||
* \return the MLD address of the remote device having the given (MLD or link) address, if
|
||||
|
||||
Reference in New Issue
Block a user