mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 15:47:46 +00:00
[netif] enhance return value of adding external addresses (#4693)
This commit changes the return value of subscribing a pre-defined address when it's already subscribed. Now returns OT_ERROR_ALREADY instead of OT_ERROR_INVALID_ARGS.
This commit is contained in:
@@ -363,6 +363,8 @@ otError Netif::SubscribeExternalMulticast(const Address &aAddress)
|
||||
NetifMulticastAddress &linkLocalAllRoutersAddress = static_cast<NetifMulticastAddress &>(
|
||||
const_cast<otNetifMulticastAddress &>(kLinkLocalAllRoutersMulticastAddress));
|
||||
|
||||
VerifyOrExit(!IsMulticastSubscribed(aAddress), error = OT_ERROR_ALREADY);
|
||||
|
||||
// Check that the address is not one of the fixed addresses:
|
||||
// LinkLocalAllRouters -> RealmLocalAllRouters -> LinkLocalAllNodes
|
||||
// -> RealmLocalAllNodes -> RealmLocalAllMpl.
|
||||
@@ -372,8 +374,6 @@ otError Netif::SubscribeExternalMulticast(const Address &aAddress)
|
||||
VerifyOrExit(cur->GetAddress() != aAddress, error = OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
|
||||
VerifyOrExit(!IsMulticastSubscribed(aAddress), error = OT_ERROR_ALREADY);
|
||||
|
||||
for (entry = &mExtMulticastAddresses[0]; entry < OT_ARRAY_END(mExtMulticastAddresses); entry++)
|
||||
{
|
||||
if (!entry->IsInUse())
|
||||
@@ -482,14 +482,12 @@ otError Netif::AddExternalUnicastAddress(const NetifUnicastAddress &aAddress)
|
||||
otError error = OT_ERROR_NONE;
|
||||
NetifUnicastAddress *entry;
|
||||
|
||||
VerifyOrExit(!aAddress.GetAddress().IsLinkLocal(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
for (entry = mUnicastAddresses.GetHead(); entry; entry = entry->GetNext())
|
||||
{
|
||||
if (entry->GetAddress() == aAddress.GetAddress())
|
||||
{
|
||||
VerifyOrExit((entry >= &mExtUnicastAddresses[0]) && (entry < OT_ARRAY_END(mExtUnicastAddresses)),
|
||||
error = OT_ERROR_INVALID_ARGS);
|
||||
error = OT_ERROR_ALREADY);
|
||||
|
||||
entry->mPrefixLength = aAddress.mPrefixLength;
|
||||
entry->mPreferred = aAddress.mPreferred;
|
||||
@@ -498,6 +496,8 @@ otError Netif::AddExternalUnicastAddress(const NetifUnicastAddress &aAddress)
|
||||
}
|
||||
}
|
||||
|
||||
VerifyOrExit(!aAddress.GetAddress().IsLinkLocal(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
for (entry = &mExtUnicastAddresses[0]; entry < OT_ARRAY_END(mExtUnicastAddresses); entry++)
|
||||
{
|
||||
if (!entry->IsInUse())
|
||||
|
||||
Reference in New Issue
Block a user