[netif] check address type when adding addresses (#5297)

This commit is contained in:
Simon Lin
2020-07-31 09:33:48 -07:00
committed by GitHub
parent 82e7e32bb5
commit 6488b25484
+3
View File
@@ -321,6 +321,7 @@ otError Netif::SubscribeExternalMulticast(const Address &aAddress)
const_cast<otNetifMulticastAddress &>(kLinkLocalAllRoutersMulticastAddress));
ExternalNetifMulticastAddress *entry;
VerifyOrExit(aAddress.IsMulticast(), error = OT_ERROR_INVALID_ARGS);
VerifyOrExit(!IsMulticastSubscribed(aAddress), error = OT_ERROR_ALREADY);
// Check that the address is not one of the fixed addresses:
@@ -420,6 +421,8 @@ otError Netif::AddExternalUnicastAddress(const NetifUnicastAddress &aAddress)
NetifUnicastAddress *entry;
NetifUnicastAddress *prev;
VerifyOrExit(!aAddress.GetAddress().IsMulticast(), error = OT_ERROR_INVALID_ARGS);
entry = mUnicastAddresses.FindMatching(aAddress.GetAddress(), prev);
if (entry != nullptr)