mirror of
https://github.com/espressif/openthread.git
synced 2026-09-03 07:40:10 +00:00
[mle] improve DelayedSender::Match() and logging (#11997)
This change enhances the `DelayedSender::Match()` method to support a wildcard destination address. When the unspecified address (`::`) is provided, the address check is skipped, allowing a match against any destination. A new private helper method, `LogRemove()`, is introduced to ensure accurate logging when removing a delayed message schedule. Previously, `RemoveMatchingSchedules()` would log the address passed to it, which could be the wildcard `::` address. The new `LogRemove()` method logs the actual destination from the scheduled message header before it is removed.
This commit is contained in:
+29
-2
@@ -3386,11 +3386,26 @@ void Mle::DelayedSender::Execute(const Schedule &aSchedule)
|
||||
|
||||
bool Mle::DelayedSender::Match(const Schedule &aSchedule, MessageType aMessageType, const Ip6::Address &aDestination)
|
||||
{
|
||||
// If `aDestination` is `::` (the unspecified address), the
|
||||
// address check is skipped, effectively accepting any
|
||||
// destination address.
|
||||
|
||||
bool matches = false;
|
||||
Header header;
|
||||
|
||||
header.ReadFrom(aSchedule);
|
||||
|
||||
return (header.mMessageType == aMessageType) && (header.mDestination == aDestination);
|
||||
VerifyOrExit(header.mMessageType == aMessageType);
|
||||
|
||||
if (!aDestination.IsUnspecified())
|
||||
{
|
||||
VerifyOrExit(header.mDestination == aDestination);
|
||||
}
|
||||
|
||||
matches = true;
|
||||
|
||||
exit:
|
||||
return matches;
|
||||
}
|
||||
|
||||
bool Mle::DelayedSender::HasMatchingSchedule(MessageType aMessageType, const Ip6::Address &aDestination) const
|
||||
@@ -3415,12 +3430,24 @@ void Mle::DelayedSender::RemoveMatchingSchedules(MessageType aMessageType, const
|
||||
{
|
||||
if (Match(schedule, aMessageType, aDestination))
|
||||
{
|
||||
LogRemove(schedule);
|
||||
mSchedules.DequeueAndFree(schedule);
|
||||
Log(kMessageRemoveDelayed, aMessageType, aDestination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
void Mle::DelayedSender::LogRemove(const Schedule &aSchedule)
|
||||
{
|
||||
Header header;
|
||||
|
||||
header.ReadFrom(aSchedule);
|
||||
Log(kMessageRemoveDelayed, header.mMessageType, header.mDestination);
|
||||
}
|
||||
#else
|
||||
void Mle::DelayedSender::LogRemove(const Schedule &) {}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// TxMessage
|
||||
|
||||
|
||||
@@ -1733,6 +1733,7 @@ private:
|
||||
void Execute(const Schedule &aSchedule);
|
||||
bool HasMatchingSchedule(MessageType aMessageType, const Ip6::Address &aDestination) const;
|
||||
void RemoveMatchingSchedules(MessageType aMessageType, const Ip6::Address &aDestination);
|
||||
void LogRemove(const Schedule &aSchedule);
|
||||
|
||||
static bool Match(const Schedule &aSchedule, MessageType aMessageType, const Ip6::Address &aDestination);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user