diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 950ab0cdd41..18e7731fe13 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2473,26 +2473,15 @@ bool Mac::IsCslSupported(void) const void Mac::ProcessCsl(const RxFrame &aFrame, const Address &aSrcAddr) { - CslNeighbor *neighbor = nullptr; + CslNeighbor *neighbor = Get().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().FindChild(aSrcAddr, Child::kInStateAnyExceptInvalid); -#endif - -#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE - neighbor = neighbor == nullptr ? Get().GetWakeupParent() : neighbor; -#endif - - VerifyOrExit(neighbor != nullptr); - #if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE VerifyOrExit(neighbor->GetExtAddress() == aSrcAddr.GetExtended()); #endif diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 6c1aae0632c..c7accdd39dc 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -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; + + OT_UNUSED_VARIABLE(aAddress); + +#if OPENTHREAD_FTD + neighbor = Get().FindChild(aAddress, Child::kInStateAnyExceptInvalid); +#endif + +#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE + if (neighbor == nullptr) + { + neighbor = GetWakeupParent(); + } +#endif + + return neighbor; +} +#endif // OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE + //--------------------------------------------------------------------------------------------------------------------- // ParentCandidate diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index d44b2a10193..d3b206f4d32 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -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. @@ -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