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

This commit is contained in:
Jonathan Hui
2020-05-11 14:07:25 -07:00
parent 2607671f33
commit 3bc11b88bf
11 changed files with 36 additions and 31 deletions
+2 -2
View File
@@ -233,7 +233,7 @@ void Local::SetState(BackboneRouterState aState)
if (mState == OT_BACKBONE_ROUTER_STATE_PRIMARY)
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mBackboneRouterPrimaryAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mBackboneRouterPrimaryAloc);
}
else if (aState == OT_BACKBONE_ROUTER_STATE_PRIMARY)
{
@@ -357,7 +357,7 @@ void Local::ApplyMeshLocalPrefix(void)
if (IsPrimary())
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mBackboneRouterPrimaryAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mBackboneRouterPrimaryAloc);
mBackboneRouterPrimaryAloc.GetAddress().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
Get<ThreadNetif>().AddUnicastAddress(mBackboneRouterPrimaryAloc);
}
+1 -1
View File
@@ -235,7 +235,7 @@ public:
* @retval FALSE The linked list does not contain @p aEntry.
*
*/
bool Contains(Type &aEntry) const
bool Contains(const Type &aEntry) const
{
bool contains = false;
+3 -2
View File
@@ -660,7 +660,7 @@ void BorderAgent::HandleConnected(bool aConnected)
else
{
otLogInfoMeshCoP("Commissioner disconnected");
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc);
SetState(OT_BORDER_AGENT_STATE_STARTED);
}
}
@@ -751,8 +751,9 @@ void BorderAgent::ApplyMeshLocalPrefix(void)
{
VerifyOrExit(mState == OT_BORDER_AGENT_STATE_ACTIVE, OT_NOOP);
if (Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc) == OT_ERROR_NONE)
if (Get<ThreadNetif>().HasUnicastAddress(mCommissionerAloc))
{
Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc);
mCommissionerAloc.GetAddress().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
Get<ThreadNetif>().AddUnicastAddress(mCommissionerAloc);
}
+2 -2
View File
@@ -193,7 +193,7 @@ otError Commissioner::Stop(bool aResign)
if (mState == OT_COMMISSIONER_STATE_ACTIVE)
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc);
RemoveCoapResources();
ClearJoiners();
needResign = true;
@@ -1110,7 +1110,7 @@ void Commissioner::ApplyMeshLocalPrefix(void)
{
VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, OT_NOOP);
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mCommissionerAloc);
mCommissionerAloc.GetAddress().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
Get<ThreadNetif>().AddUnicastAddress(mCommissionerAloc);
+1 -1
View File
@@ -104,7 +104,7 @@ void Dhcp6Client::UpdateAddresses(void)
if (!found)
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(ia.mNetifAddress));
Get<ThreadNetif>().RemoveUnicastAddress(ia.mNetifAddress);
mIdentityAssociations[i].mStatus = kIaStatusInvalid;
}
}
+2 -1
View File
@@ -493,7 +493,8 @@ void Dhcp6Server::ApplyMeshLocalPrefix(void)
if (mPrefixAgents[i].IsValid())
{
PrefixAgent *entry = &mPrefixAgents[i];
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(entry->GetAloc()));
Get<ThreadNetif>().RemoveUnicastAddress(entry->GetAloc());
entry->GetAloc().GetAddress().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
Get<ThreadNetif>().AddUnicastAddress(entry->GetAloc());
}
+3 -5
View File
@@ -452,11 +452,9 @@ exit:
return;
}
otError Netif::RemoveUnicastAddress(const NetifUnicastAddress &aAddress)
void Netif::RemoveUnicastAddress(const NetifUnicastAddress &aAddress)
{
otError error;
SuccessOrExit(error = mUnicastAddresses.Remove(aAddress));
SuccessOrExit(mUnicastAddresses.Remove(aAddress));
Get<Notifier>().Signal(aAddress.mRloc ? OT_CHANGED_THREAD_RLOC_REMOVED : OT_CHANGED_IP6_ADDRESS_REMOVED);
@@ -464,7 +462,7 @@ otError Netif::RemoveUnicastAddress(const NetifUnicastAddress &aAddress)
mAddressCallback(&aAddress.mAddress, aAddress.mPrefixLength, /* IsAdded */ false, mAddressCallbackContext);
exit:
return error;
return;
}
otError Netif::AddExternalUnicastAddress(const NetifUnicastAddress &aAddress)
+8 -3
View File
@@ -213,11 +213,16 @@ public:
*
* @param[in] aAddress A reference to the unicast address.
*
* @retval OT_ERROR_NONE Successfully removed the unicast address.
* @retval OT_ERROR_NOT_FOUND The unicast address wasn't found to be removed.
*/
void RemoveUnicastAddress(const NetifUnicastAddress &aAddress);
/**
* This method indicates whether a unicast address is added to the network interface.
*
* @param[in] aAddress A reference to the unicast address.
*
*/
otError RemoveUnicastAddress(const NetifUnicastAddress &aAddress);
bool HasUnicastAddress(const NetifUnicastAddress &aAddress) const { return mUnicastAddresses.Contains(aAddress); }
/**
* This method adds an external (to OpenThread) unicast address to the network interface.
+1 -1
View File
@@ -742,7 +742,7 @@ void AddressResolver::HandleAddressError(Coap::Message &aMessage, const Ip6::Mes
memcmp(Get<Mle::MleRouter>().GetMeshLocal64().GetIid(), meshLocalIid, sizeof(meshLocalIid)))
{
// Target EID matches address and Mesh Local EID differs
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(*address));
Get<ThreadNetif>().RemoveUnicastAddress(*address);
ExitNow();
}
}
+12 -12
View File
@@ -224,7 +224,7 @@ otError Mle::Disable(void)
Stop(false);
SuccessOrExit(error = mSocket.Close());
SuccessOrExit(error = Get<ThreadNetif>().RemoveUnicastAddress(mLinkLocal64));
Get<ThreadNetif>().RemoveUnicastAddress(mLinkLocal64);
exit:
return error;
@@ -303,8 +303,8 @@ void Mle::Stop(bool aClearNetworkDatasets)
SetStateDetached();
IgnoreError(Get<ThreadNetif>().UnsubscribeMulticast(mRealmLocalAllThreadNodes));
IgnoreError(Get<ThreadNetif>().UnsubscribeMulticast(mLinkLocalAllThreadNodes));
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16));
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal64));
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16);
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal64);
SetRole(kRoleDisabled);
@@ -747,7 +747,7 @@ void Mle::SetStateDetached(void)
if (IsLeader())
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc);
}
SetRole(kRoleDetached);
@@ -773,7 +773,7 @@ void Mle::SetStateChild(uint16_t aRloc16)
{
if (IsLeader())
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc);
}
SetRloc16(aRloc16);
@@ -896,7 +896,7 @@ exit:
void Mle::UpdateLinkLocalAddress(void)
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mLinkLocal64));
Get<ThreadNetif>().RemoveUnicastAddress(mLinkLocal64);
mLinkLocal64.GetAddress().SetIid(Get<Mac::Mac>().GetExtAddress());
Get<ThreadNetif>().AddUnicastAddress(mLinkLocal64);
@@ -909,11 +909,11 @@ void Mle::SetMeshLocalPrefix(const MeshLocalPrefix &aMeshLocalPrefix)
if (Get<ThreadNetif>().IsUp())
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc));
Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc);
// We must remove the old addresses before adding the new ones.
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal64));
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16));
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal64);
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16);
IgnoreError(Get<ThreadNetif>().UnsubscribeMulticast(mLinkLocalAllThreadNodes));
IgnoreError(Get<ThreadNetif>().UnsubscribeMulticast(mRealmLocalAllThreadNodes));
}
@@ -972,7 +972,7 @@ void Mle::ApplyMeshLocalPrefix(void)
{
if (mServiceAlocs[i].GetAddress().GetLocator() != Mac::kShortAddrInvalid)
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mServiceAlocs[i]));
Get<ThreadNetif>().RemoveUnicastAddress(mServiceAlocs[i]);
mServiceAlocs[i].GetAddress().SetPrefix(GetMeshLocalPrefix());
Get<ThreadNetif>().AddUnicastAddress(mServiceAlocs[i]);
}
@@ -1009,7 +1009,7 @@ void Mle::SetRloc16(uint16_t aRloc16)
}
}
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16));
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocal16);
Get<Mac::Mac>().SetShortAddress(aRloc16);
Get<Ip6::Mpl>().SetSeedId(aRloc16);
@@ -1641,7 +1641,7 @@ void Mle::UpdateServiceAlocs(void)
if ((serviceAloc != Mac::kShortAddrInvalid) &&
(!Get<NetworkData::Leader>().ContainsService(Mle::ServiceIdFromAloc(serviceAloc), rloc)))
{
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(mServiceAlocs[i]));
Get<ThreadNetif>().RemoveUnicastAddress(mServiceAlocs[i]);
mServiceAlocs[i].GetAddress().SetLocator(Mac::kShortAddrInvalid);
}
}
+1 -1
View File
@@ -186,7 +186,7 @@ void Slaac::Update(UpdateMode aMode)
{
otLogInfoUtil("SLAAC: Removing address %s", slaacAddr->GetAddress().ToString().AsCString());
IgnoreError(Get<ThreadNetif>().RemoveUnicastAddress(*slaacAddr));
Get<ThreadNetif>().RemoveUnicastAddress(*slaacAddr);
slaacAddr->mValid = false;
}
}