Skip to content

Commit

Permalink
Add Mle::FindCslNeighbor
Browse files Browse the repository at this point in the history
  • Loading branch information
edmont committed Dec 9, 2024
1 parent 49fe8cb commit f5c93ad
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
15 changes: 2 additions & 13 deletions src/core/mac/mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2473,26 +2473,15 @@ bool Mac::IsCslSupported(void) const

void Mac::ProcessCsl(const RxFrame &aFrame, const Address &aSrcAddr)
{
CslNeighbor *neighbor = nullptr;
CslNeighbor *neighbor = Get<Mle::Mle>().FindCslNeighbor(aSrcAddr);
const CslIe *csl;

OT_UNUSED_VARIABLE(aSrcAddr);

VerifyOrExit(neighbor != nullptr);
VerifyOrExit(aFrame.IsVersion2015() && aFrame.GetSecurityEnabled());

csl = aFrame.GetCslIe();
VerifyOrExit(csl != nullptr);

#if OPENTHREAD_FTD
neighbor = Get<ChildTable>().FindChild(aSrcAddr, Child::kInStateAnyExceptInvalid);
#endif

#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
neighbor = neighbor == nullptr ? Get<Mle::Mle>().GetWakeupParent() : neighbor;
#endif

VerifyOrExit(neighbor != nullptr);

#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
VerifyOrExit(neighbor->GetExtAddress() == aSrcAddr.GetExtended());
#endif
Expand Down
22 changes: 22 additions & 0 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5654,6 +5654,28 @@ void Mle::AttachToWakeupParent()
}
#endif // OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE

#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
CslNeighbor *Mle::FindCslNeighbor(const Mac::Address &aAddress)
{
CslNeighbor *neighbor = nullptr;

#if OPENTHREAD_FTD
neighbor = Get<ChildTable>().FindChild(aAddress, Child::kInStateAnyExceptInvalid);
#endif

#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
OT_UNUSED_VARIABLE(aAddress);

if (neighbor == nullptr)
{
neighbor = GetWakeupParent();
}
#endif

return neighbor;
}
#endif

//---------------------------------------------------------------------------------------------------------------------
// ParentCandidate

Expand Down
14 changes: 11 additions & 3 deletions src/core/thread/mle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ class Mle : public InstanceLocator, private NonCopyable
friend class ot::LinkMetrics::Initiator;
#endif
friend class ot::UnitTester;
#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
friend class ot::Mac::Mac;
#endif

public:
typedef otDetachGracefullyCallback DetachCallback; ///< Callback to signal end of graceful detach.
Expand Down Expand Up @@ -786,6 +783,17 @@ class Mle : public InstanceLocator, private NonCopyable
void AttachToWakeupParent();
#endif

#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
/**
* Returns a CSL Neighbor by its address.
*
* @param[in] aAddress The address of the CSL Neighbor.
*
* @returns A pointer to the CSL Neighbor, or NULL if not found.
*/
CslNeighbor *FindCslNeighbor(const Mac::Address &aAddress);
#endif

private:
//------------------------------------------------------------------------------------------------------------------
// Constants
Expand Down

0 comments on commit f5c93ad

Please sign in to comment.