[netif] change SubscribeMulticast() to return void (#4942)

This commit is contained in:
Jonathan Hui
2020-05-11 14:07:25 -07:00
parent 3bc11b88bf
commit e8d6705fdd
5 changed files with 12 additions and 17 deletions
+3 -3
View File
@@ -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:
+3 -5
View File
@@ -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)
+1 -4
View File
@@ -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.
+2 -2
View File
@@ -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())
{
+3 -3
View File
@@ -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);