mirror of
https://github.com/espressif/openthread.git
synced 2026-08-15 23:27:47 +00:00
[mle] simplify logic for multicast address registration (#11872)
This change introduces `ShouldRegisterMulticastAddrsWithParent()` to consolidate the logic for determining when a child should register its multicast addresses with its parent, thereby avoiding repeated code. The criteria for registration remain the same: a child registers its multicast addresses if it is a Sleepy End Device (SED), or if it is a Minimal End Device (MED) and its parent is running Thread 1.2 or a later version.
This commit is contained in:
+22
-21
@@ -1001,23 +1001,10 @@ void Mle::HandleNotifierEvents(Events aEvents)
|
||||
ScheduleChildUpdateRequestIfMtdChild();
|
||||
}
|
||||
|
||||
if (aEvents.ContainsAny(kEventIp6MulticastSubscribed | kEventIp6MulticastUnsubscribed))
|
||||
if (aEvents.ContainsAny(kEventIp6MulticastSubscribed | kEventIp6MulticastUnsubscribed) &&
|
||||
ShouldRegisterMulticastAddrsWithParent())
|
||||
{
|
||||
// When multicast subscription changes, SED always notifies
|
||||
// its parent as it depends on its parent for indirect
|
||||
// transmission. Since Thread 1.2, MED MAY also notify its
|
||||
// parent of 1.2 or higher version as it could depend on its
|
||||
// parent to perform Multicast Listener Report.
|
||||
|
||||
if (!IsRxOnWhenIdle()
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
|| !GetParent().IsThreadVersion1p1()
|
||||
#endif
|
||||
)
|
||||
|
||||
{
|
||||
ScheduleChildUpdateRequestIfMtdChild();
|
||||
}
|
||||
ScheduleChildUpdateRequestIfMtdChild();
|
||||
}
|
||||
|
||||
if (aEvents.Contains(kEventThreadNetdataChanged))
|
||||
@@ -1071,6 +1058,23 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
bool Mle::ShouldRegisterMulticastAddrsWithParent(void) const
|
||||
{
|
||||
// When multicast subscription changes, SED always notifies
|
||||
// its parent as it depends on its parent for indirect
|
||||
// transmission. Since Thread 1.2, MED MAY also notify its
|
||||
// parent of 1.2 or higher version as it could depend on its
|
||||
// parent to perform Multicast Listener Report.
|
||||
|
||||
bool shouldRegister = !IsRxOnWhenIdle();
|
||||
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
shouldRegister |= !IsFullThreadDevice() && GetParent().IsThreadVersion1p2OrHigher();
|
||||
#endif
|
||||
|
||||
return shouldRegister;
|
||||
}
|
||||
|
||||
Error Mle::SendDataRequestToParent(void)
|
||||
{
|
||||
Ip6::Address destination;
|
||||
@@ -3564,11 +3568,8 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode
|
||||
// indirect transmission. Since Thread 1.2, non-sleepy MED should
|
||||
// also register external multicast addresses of scope larger than
|
||||
// realm with a 1.2 or higher parent.
|
||||
if (!Get<Mle>().IsRxOnWhenIdle()
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
|| !Get<Mle>().GetParent().IsThreadVersion1p1()
|
||||
#endif
|
||||
)
|
||||
|
||||
if (Get<Mle>().ShouldRegisterMulticastAddrsWithParent())
|
||||
{
|
||||
for (const Ip6::Netif::MulticastAddress &addr : Get<ThreadNetif>().IterateExternalMulticastAddresses())
|
||||
{
|
||||
|
||||
@@ -2132,6 +2132,7 @@ private:
|
||||
void SendAnnounce(uint8_t aChannel, AnnounceMode aMode);
|
||||
void SendAnnounce(uint8_t aChannel, const Ip6::Address &aDestination, AnnounceMode aMode = kNormalAnnounce);
|
||||
bool IsNetworkDataNewer(const LeaderData &aLeaderData);
|
||||
bool ShouldRegisterMulticastAddrsWithParent(void) const;
|
||||
Error ProcessMessageSecurity(Crypto::AesCcm::Mode aMode,
|
||||
Message &aMessage,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
|
||||
Reference in New Issue
Block a user