mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[mle] fix handling of MLE Orphan Announce messages (#7786)
MLE Orphan Announce messages include a timestamp value that has both seconds and ticks set to zero, but authoritative bit set. However, the default Active Timestamp value is all zeros. As a result, an MLE Orphan Announce timestamp can appear to be greater than the default Active Timestamp value and cause a device to detach. This commit adds a special case to check for the Orphan Announce timestamp.
This commit is contained in:
@@ -140,6 +140,15 @@ public:
|
||||
*/
|
||||
void AdvanceRandomTicks(void);
|
||||
|
||||
/**
|
||||
* This method indicates whether the timestamp indicates an MLE Orphan Announce message.
|
||||
*
|
||||
* @retval TRUE The timestamp indicates an Orphan Announce message.
|
||||
* @retval FALSE If the timestamp does not indicate an Orphan Announce message.
|
||||
*
|
||||
*/
|
||||
bool IsOrphanTimestamp(void) const { return GetSeconds() == 0 && GetTicks() == 0 && GetAuthoritative(); }
|
||||
|
||||
/**
|
||||
* This static method compares two timestamps.
|
||||
*
|
||||
|
||||
@@ -4113,7 +4113,15 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo)
|
||||
|
||||
localTimestamp = Get<MeshCoP::ActiveDatasetManager>().GetTimestamp();
|
||||
|
||||
if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) > 0)
|
||||
if (timestamp.IsOrphanTimestamp() || MeshCoP::Timestamp::Compare(×tamp, localTimestamp) < 0)
|
||||
{
|
||||
SendAnnounce(channel);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE
|
||||
SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
#endif
|
||||
}
|
||||
else if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) > 0)
|
||||
{
|
||||
// No action is required if device is detached, and current
|
||||
// channel and pan-id match the values from the received MLE
|
||||
@@ -4136,14 +4144,6 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo)
|
||||
|
||||
LogNote("Delay processing Announce - channel %d, panid 0x%02x", channel, panId);
|
||||
}
|
||||
else if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) < 0)
|
||||
{
|
||||
SendAnnounce(channel);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE
|
||||
SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Timestamps are equal.
|
||||
|
||||
Reference in New Issue
Block a user