mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[netif] change SubscribeMulticast() to return void (#4942)
This commit is contained in:
@@ -224,7 +224,7 @@ void Local::SetState(BackboneRouterState aState)
|
||||
{
|
||||
// Subscribe All Network Backbone Routers Multicast Address for both Secondary and Primary state.
|
||||
mAllNetworkBackboneRouters.GetAddress().SetMulticastNetworkPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
IgnoreError(Get<ThreadNetif>().SubscribeMulticast(mAllNetworkBackboneRouters));
|
||||
Get<ThreadNetif>().SubscribeMulticast(mAllNetworkBackboneRouters);
|
||||
}
|
||||
else if (aState == OT_BACKBONE_ROUTER_STATE_DISABLED)
|
||||
{
|
||||
@@ -353,7 +353,7 @@ void Local::ApplyMeshLocalPrefix(void)
|
||||
|
||||
IgnoreError(Get<ThreadNetif>().UnsubscribeMulticast(mAllNetworkBackboneRouters));
|
||||
mAllNetworkBackboneRouters.GetAddress().SetMulticastNetworkPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
IgnoreError(Get<ThreadNetif>().SubscribeMulticast(mAllNetworkBackboneRouters));
|
||||
Get<ThreadNetif>().SubscribeMulticast(mAllNetworkBackboneRouters);
|
||||
|
||||
if (IsPrimary())
|
||||
{
|
||||
@@ -382,7 +382,7 @@ void Local::UpdateAllDomainBackboneRouters(Leader::DomainPrefixState aState)
|
||||
if (aState == Leader::kDomainPrefixAdded || aState == Leader::kDomainPrefixRefreshed)
|
||||
{
|
||||
mAllDomainBackboneRouters.GetAddress().SetMulticastNetworkPrefix(*Get<Leader>().GetDomainPrefix());
|
||||
IgnoreError(Get<ThreadNetif>().SubscribeMulticast(mAllDomainBackboneRouters));
|
||||
Get<ThreadNetif>().SubscribeMulticast(mAllDomainBackboneRouters);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
@@ -303,11 +303,9 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Netif::SubscribeMulticast(NetifMulticastAddress &aAddress)
|
||||
void Netif::SubscribeMulticast(NetifMulticastAddress &aAddress)
|
||||
{
|
||||
otError error;
|
||||
|
||||
SuccessOrExit(error = mMulticastAddresses.Add(aAddress));
|
||||
SuccessOrExit(mMulticastAddresses.Add(aAddress));
|
||||
|
||||
Get<Notifier>().Signal(OT_CHANGED_IP6_MULTICAST_SUBSCRIBED);
|
||||
|
||||
@@ -315,7 +313,7 @@ otError Netif::SubscribeMulticast(NetifMulticastAddress &aAddress)
|
||||
mAddressCallback(&aAddress.mAddress, kMulticastPrefixLength, /* IsAdded */ true, mAddressCallbackContext);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return;
|
||||
}
|
||||
|
||||
otError Netif::UnsubscribeMulticast(const NetifMulticastAddress &aAddress)
|
||||
|
||||
@@ -309,11 +309,8 @@ public:
|
||||
*
|
||||
* @param[in] aAddress A reference to the multicast address.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully subscribed to @p aAddress.
|
||||
* @retval OT_ERROR_ALREADY The multicast address is already subscribed.
|
||||
*
|
||||
*/
|
||||
otError SubscribeMulticast(NetifMulticastAddress &aAddress);
|
||||
void SubscribeMulticast(NetifMulticastAddress &aAddress);
|
||||
|
||||
/**
|
||||
* This method unsubscribes the network interface to a multicast address.
|
||||
|
||||
@@ -940,8 +940,8 @@ void Mle::ApplyMeshLocalPrefix(void)
|
||||
|
||||
// Add the addresses back into the table.
|
||||
Get<ThreadNetif>().AddUnicastAddress(mMeshLocal64);
|
||||
IgnoreError(Get<ThreadNetif>().SubscribeMulticast(mLinkLocalAllThreadNodes));
|
||||
IgnoreError(Get<ThreadNetif>().SubscribeMulticast(mRealmLocalAllThreadNodes));
|
||||
Get<ThreadNetif>().SubscribeMulticast(mLinkLocalAllThreadNodes);
|
||||
Get<ThreadNetif>().SubscribeMulticast(mRealmLocalAllThreadNodes);
|
||||
|
||||
if (IsAttached())
|
||||
{
|
||||
|
||||
@@ -136,11 +136,11 @@ void TestNetifMulticastAddresses(void)
|
||||
"UnsubscribeAllRoutersMulticast() did not fail when not subscribed");
|
||||
|
||||
IgnoreError(netifAddress.GetAddress().FromString(kTestAddress1));
|
||||
SuccessOrQuit(netif.SubscribeMulticast(netifAddress), "SubscribeMulticast() failed");
|
||||
netif.SubscribeMulticast(netifAddress);
|
||||
VerifyMulticastAddressList(netif, &addresses[2], 4);
|
||||
|
||||
VerifyOrQuit(netif.SubscribeMulticast(netifAddress) == OT_ERROR_ALREADY,
|
||||
"SubscribeMulticast() did not fail when address was already subscribed");
|
||||
netif.SubscribeMulticast(netifAddress);
|
||||
VerifyMulticastAddressList(netif, &addresses[2], 4);
|
||||
|
||||
SuccessOrQuit(netif.UnsubscribeAllNodesMulticast(), "UnsubscribeAllNodesMulticast() failed");
|
||||
VerifyMulticastAddressList(netif, &addresses[5], 1);
|
||||
|
||||
Reference in New Issue
Block a user