[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:
Abtin Keshavarzian
2025-10-06 13:14:48 -07:00
committed by GitHub
parent 6e6086e2dc
commit 23c3bd4323
2 changed files with 30 additions and 2 deletions
+29 -2
View File
@@ -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
+1
View File
@@ -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);