[netdata] unify GetNext...() methods into a single template (#11812)

This change updates the `NetworkData` iteration methods to reduce
redundant code and simplify their use.

Previously, separate methods were defined to iterate over different
types of network data entries (e.g., `GetNextOnMeshPrefix()`,
`GetNextExternalRoute()`). This change unifies these into a single
template method, `NetworkData::GetNext<EntryType>()`. A similar
change is applied to unify the corresponding `Contains...()`
methods into a single template.
This commit is contained in:
Abtin Keshavarzian
2025-08-13 10:15:24 -07:00
committed by GitHub
parent 19b5bfedbf
commit b89d05c5fc
16 changed files with 186 additions and 272 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ otError otBorderRouterGetNextOnMeshPrefix(otInstance *aInstance,
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Local>().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig)); return AsCoreType(aInstance).Get<NetworkData::Local>().GetNext(*aIterator, AsCoreType(aConfig));
} }
otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig) otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig)
@@ -106,7 +106,7 @@ otError otBorderRouterGetNextRoute(otInstance *aInstance,
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Local>().GetNextExternalRoute(*aIterator, AsCoreType(aConfig)); return AsCoreType(aInstance).Get<NetworkData::Local>().GetNext(*aIterator, AsCoreType(aConfig));
} }
otError otBorderRouterRegister(otInstance *aInstance) otError otBorderRouterRegister(otInstance *aInstance)
+4 -5
View File
@@ -67,7 +67,7 @@ otError otNetDataGetNextOnMeshPrefix(otInstance *aInstance,
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig)); return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNext(*aIterator, AsCoreType(aConfig));
} }
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
@@ -81,14 +81,14 @@ otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIte
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextExternalRoute(*aIterator, AsCoreType(aConfig)); return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNext(*aIterator, AsCoreType(aConfig));
} }
otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig) otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig)
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextService(*aIterator, AsCoreType(aConfig)); return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNext(*aIterator, AsCoreType(aConfig));
} }
otError otNetDataGetNextLowpanContextInfo(otInstance *aInstance, otError otNetDataGetNextLowpanContextInfo(otInstance *aInstance,
@@ -97,8 +97,7 @@ otError otNetDataGetNextLowpanContextInfo(otInstance *aInstance,
{ {
AssertPointerIsNotNull(aIterator); AssertPointerIsNotNull(aIterator);
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextLowpanContextInfo(*aIterator, return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNext(*aIterator, AsCoreType(aContextInfo));
AsCoreType(aContextInfo));
} }
void otNetDataGetCommissioningDataset(otInstance *aInstance, otCommissioningDataset *aDataset) void otNetDataGetCommissioningDataset(otInstance *aInstance, otCommissioningDataset *aDataset)
+1 -1
View File
@@ -75,7 +75,7 @@ otError otServerGetNextService(otInstance *aInstance, otNetworkDataIterator *aIt
VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs); VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs);
error = AsCoreType(aInstance).Get<NetworkData::Local>().GetNextService(*aIterator, AsCoreType(aConfig)); error = AsCoreType(aInstance).Get<NetworkData::Local>().GetNext(*aIterator, AsCoreType(aConfig));
exit: exit:
return error; return error;
+5 -5
View File
@@ -226,13 +226,13 @@ void Leader::UpdateBackboneRouterPrimary(void)
void Leader::UpdateDomainPrefixConfig(void) void Leader::UpdateDomainPrefixConfig(void)
{ {
NetworkData::Iterator iterator = NetworkData::kIteratorInit; NetworkData::Iterator iterator = NetworkData::kIteratorInit;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
DomainPrefixEvent event; DomainPrefixEvent event;
bool found = false; bool found = false;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (config.mDp) if (prefixConfig.mDp)
{ {
found = true; found = true;
break; break;
@@ -247,14 +247,14 @@ void Leader::UpdateDomainPrefixConfig(void)
mDomainPrefix.Clear(); mDomainPrefix.Clear();
event = kDomainPrefixRemoved; event = kDomainPrefixRemoved;
} }
else if (config.GetPrefix() == mDomainPrefix) else if (prefixConfig.GetPrefix() == mDomainPrefix)
{ {
event = kDomainPrefixUnchanged; event = kDomainPrefixUnchanged;
} }
else else
{ {
event = HasDomainPrefix() ? kDomainPrefixRefreshed : kDomainPrefixAdded; event = HasDomainPrefix() ? kDomainPrefixRefreshed : kDomainPrefixAdded;
mDomainPrefix = config.GetPrefix(); mDomainPrefix = prefixConfig.GetPrefix();
} }
LogInfo("%s domain Prefix: %s", DomainPrefixEventToString(event), mDomainPrefix.ToString().AsCString()); LogInfo("%s domain Prefix: %s", DomainPrefixEventToString(event), mDomainPrefix.ToString().AsCString());
+6 -6
View File
@@ -812,7 +812,7 @@ bool RoutingManager::NetworkDataContainsUlaRoute(void) const
NetworkData::ExternalRouteConfig routeConfig; NetworkData::ExternalRouteConfig routeConfig;
bool contains = false; bool contains = false;
while (Get<NetworkData::Leader>().GetNextExternalRoute(iterator, routeConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, routeConfig) == kErrorNone)
{ {
if (routeConfig.mStable && RoutePublisher::GetUlaPrefix().ContainsPrefix(routeConfig.GetPrefix())) if (routeConfig.mStable && RoutePublisher::GetUlaPrefix().ContainsPrefix(routeConfig.GetPrefix()))
{ {
@@ -840,7 +840,7 @@ void RoutingManager::CheckReachabilityToSendIcmpError(const Message &aMessage, c
// Validate that source matches a ULA OMR prefix with low preference // Validate that source matches a ULA OMR prefix with low preference
// (indicating it is not infrastructure-derived). // (indicating it is not infrastructure-derived).
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (IsValidOmrPrefix(prefixConfig) && prefixConfig.GetPrefix().IsUniqueLocal() && if (IsValidOmrPrefix(prefixConfig) && prefixConfig.GetPrefix().IsUniqueLocal() &&
aIp6Header.GetSource().MatchesPrefix(prefixConfig.GetPrefix())) aIp6Header.GetSource().MatchesPrefix(prefixConfig.GetPrefix()))
@@ -1690,7 +1690,7 @@ void RoutingManager::RxRaTracker::HandleNetDataChange(void)
NetworkData::OnMeshPrefixConfig prefixConfig; NetworkData::OnMeshPrefixConfig prefixConfig;
bool didChange = false; bool didChange = false;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (!IsValidOmrPrefix(prefixConfig)) if (!IsValidOmrPrefix(prefixConfig))
{ {
@@ -2666,7 +2666,7 @@ void RoutingManager::OmrPrefixManager::DetermineFavoredPrefixInNetData(FavoredOm
aFavoredPrefix.Clear(); aFavoredPrefix.Clear();
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (!IsValidOmrPrefix(prefixConfig) || !prefixConfig.mPreferred) if (!IsValidOmrPrefix(prefixConfig) || !prefixConfig.mPreferred)
{ {
@@ -3636,7 +3636,7 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
// The decision to include the local OMR prefix as a RIO is // The decision to include the local OMR prefix as a RIO is
// delegated to `OmrPrefixManager.ShouldAdvertiseLocalAsRio()` // delegated to `OmrPrefixManager.ShouldAdvertiseLocalAsRio()`
@@ -3662,7 +3662,7 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (prefixConfig.mOnMesh && !prefixConfig.mDp && !IsValidOmrPrefix(prefixConfig)) if (prefixConfig.mOnMesh && !prefixConfig.mDp && !IsValidOmrPrefix(prefixConfig))
{ {
+10 -10
View File
@@ -65,7 +65,7 @@ void Client::UpdateAddresses(void)
bool found = false; bool found = false;
bool doesAgentExist = false; bool doesAgentExist = false;
NetworkData::Iterator iterator; NetworkData::Iterator iterator;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
// remove addresses directly if prefix not valid in network data // remove addresses directly if prefix not valid in network data
for (IdentityAssociation &idAssociation : mIdentityAssociations) for (IdentityAssociation &idAssociation : mIdentityAssociations)
@@ -78,14 +78,14 @@ void Client::UpdateAddresses(void)
found = false; found = false;
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (!config.mDhcp) if (!prefixConfig.mDhcp)
{ {
continue; continue;
} }
if (idAssociation.mNetifAddress.HasPrefix(config.GetPrefix())) if (idAssociation.mNetifAddress.HasPrefix(prefixConfig.GetPrefix()))
{ {
found = true; found = true;
break; break;
@@ -102,11 +102,11 @@ void Client::UpdateAddresses(void)
// add IdentityAssociation for new configured prefix // add IdentityAssociation for new configured prefix
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
IdentityAssociation *idAssociation = nullptr; IdentityAssociation *idAssociation = nullptr;
if (!config.mDhcp) if (!prefixConfig.mDhcp)
{ {
continue; continue;
} }
@@ -124,7 +124,7 @@ void Client::UpdateAddresses(void)
idAssociation = &ia; idAssociation = &ia;
} }
} }
else if (ia.mNetifAddress.HasPrefix(config.GetPrefix())) else if (ia.mNetifAddress.HasPrefix(prefixConfig.GetPrefix()))
{ {
found = true; found = true;
idAssociation = &ia; idAssociation = &ia;
@@ -136,8 +136,8 @@ void Client::UpdateAddresses(void)
{ {
if (idAssociation != nullptr) if (idAssociation != nullptr)
{ {
idAssociation->mNetifAddress.mAddress = config.mPrefix.mPrefix; idAssociation->mNetifAddress.mAddress = prefixConfig.mPrefix.mPrefix;
idAssociation->mNetifAddress.mPrefixLength = config.mPrefix.mLength; idAssociation->mNetifAddress.mPrefixLength = prefixConfig.mPrefix.mLength;
idAssociation->mStatus = kIaStatusSolicit; idAssociation->mStatus = kIaStatusSolicit;
idAssociation->mValidLifetime = 0; idAssociation->mValidLifetime = 0;
} }
@@ -148,7 +148,7 @@ void Client::UpdateAddresses(void)
} }
} }
idAssociation->mPrefixAgentRloc = config.mRloc16; idAssociation->mPrefixAgentRloc = prefixConfig.mRloc16;
} }
if (doesAgentExist) if (doesAgentExist)
+7 -7
View File
@@ -64,7 +64,7 @@ void Server::UpdateService(void)
Error error = kErrorNone; Error error = kErrorNone;
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16(); uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
NetworkData::Iterator iterator; NetworkData::Iterator iterator;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
Lowpan::Context lowpanContext; Lowpan::Context lowpanContext;
// remove dhcp agent aloc and prefix delegation // remove dhcp agent aloc and prefix delegation
@@ -79,9 +79,9 @@ void Server::UpdateService(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, rloc16, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, rloc16, prefixConfig) == kErrorNone)
{ {
if (!(config.mDhcp || config.mConfigure)) if (!(prefixConfig.mDhcp || prefixConfig.mConfigure))
{ {
continue; continue;
} }
@@ -107,18 +107,18 @@ void Server::UpdateService(void)
// add dhcp agent aloc and prefix delegation // add dhcp agent aloc and prefix delegation
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, rloc16, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, rloc16, prefixConfig) == kErrorNone)
{ {
if (!(config.mDhcp || config.mConfigure)) if (!(prefixConfig.mDhcp || prefixConfig.mConfigure))
{ {
continue; continue;
} }
error = Get<NetworkData::Leader>().GetContext(AsCoreType(&config.mPrefix.mPrefix), lowpanContext); error = Get<NetworkData::Leader>().GetContext(AsCoreType(&prefixConfig.mPrefix.mPrefix), lowpanContext);
if (error == kErrorNone) if (error == kErrorNone)
{ {
AddPrefixAgent(config.GetPrefix(), lowpanContext); AddPrefixAgent(prefixConfig.GetPrefix(), lowpanContext);
} }
} }
+7 -7
View File
@@ -53,7 +53,7 @@ void Agent::UpdateService(void)
Error error; Error error;
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16(); uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
NetworkData::Iterator iterator; NetworkData::Iterator iterator;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
Lowpan::Context lowpanContext; Lowpan::Context lowpanContext;
if (IsAlocInUse()) if (IsAlocInUse())
@@ -64,14 +64,14 @@ void Agent::UpdateService(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, rloc16, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, rloc16, prefixConfig) == kErrorNone)
{ {
if (!config.mNdDns) if (!prefixConfig.mNdDns)
{ {
continue; continue;
} }
error = Get<NetworkData::Leader>().GetContext(AsCoreType(&config.mPrefix.mPrefix), lowpanContext); error = Get<NetworkData::Leader>().GetContext(AsCoreType(&prefixConfig.mPrefix.mPrefix), lowpanContext);
if ((error != kErrorNone) || (lowpanContext.mContextId != contextId)) if ((error != kErrorNone) || (lowpanContext.mContextId != contextId))
{ {
@@ -93,14 +93,14 @@ void Agent::UpdateService(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, rloc16, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, rloc16, prefixConfig) == kErrorNone)
{ {
if (!config.mNdDns) if (!prefixConfig.mNdDns)
{ {
continue; continue;
} }
error = Get<NetworkData::Leader>().GetContext(AsCoreType(&config.mPrefix.mPrefix), lowpanContext); error = Get<NetworkData::Leader>().GetContext(AsCoreType(&prefixConfig.mPrefix.mPrefix), lowpanContext);
if (error == kErrorNone) if (error == kErrorNone)
{ {
+2 -2
View File
@@ -1271,7 +1271,7 @@ void Mle::UpdateServiceAlocs(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextService(iterator, GetRloc16(), service) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, GetRloc16(), service) == kErrorNone)
{ {
if (service.mServiceId == ServiceIdFromAloc(serviceAloc.GetAloc16())) if (service.mServiceId == ServiceIdFromAloc(serviceAloc.GetAloc16()))
{ {
@@ -1291,7 +1291,7 @@ void Mle::UpdateServiceAlocs(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextService(iterator, GetRloc16(), service) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, GetRloc16(), service) == kErrorNone)
{ {
uint16_t aloc16 = ServiceAlocFromId(service.mServiceId); uint16_t aloc16 = ServiceAlocFromId(service.mServiceId);
+27 -96
View File
@@ -73,68 +73,30 @@ exit:
return error; return error;
} }
Error NetworkData::GetNextOnMeshPrefix(Iterator &aIterator, OnMeshPrefixConfig &aConfig) const template <typename EntryType> Error NetworkData::GetNext(Iterator &aIterator, EntryType &aEntry) const
{ {
return GetNextOnMeshPrefix(aIterator, Mac::kShortAddrBroadcast, aConfig); return GetNext<EntryType>(aIterator, Mac::kShortAddrBroadcast, aEntry);
} }
Error NetworkData::GetNextOnMeshPrefix(Iterator &aIterator, uint16_t aRloc16, OnMeshPrefixConfig &aConfig) const template <typename EntryType> Error NetworkData::GetNext(Iterator &aIterator, uint16_t aRloc16, EntryType &aEntry) const
{ {
Config config; Config config;
config.mOnMeshPrefix = &aConfig; config.Clear();
config.mExternalRoute = nullptr; config.Set(aEntry);
config.mService = nullptr;
config.mLowpanContext = nullptr;
return Iterate(aIterator, aRloc16, config); return Iterate(aIterator, aRloc16, config);
} }
Error NetworkData::GetNextExternalRoute(Iterator &aIterator, ExternalRouteConfig &aConfig) const // Explicit template instantiations
{ template Error NetworkData::GetNext<OnMeshPrefixConfig>(Iterator &, OnMeshPrefixConfig &) const;
return GetNextExternalRoute(aIterator, Mac::kShortAddrBroadcast, aConfig); template Error NetworkData::GetNext<ExternalRouteConfig>(Iterator &, ExternalRouteConfig &) const;
} template Error NetworkData::GetNext<ServiceConfig>(Iterator &, ServiceConfig &) const;
template Error NetworkData::GetNext<LowpanContextInfo>(Iterator &, LowpanContextInfo &) const;
Error NetworkData::GetNextExternalRoute(Iterator &aIterator, uint16_t aRloc16, ExternalRouteConfig &aConfig) const template Error NetworkData::GetNext<OnMeshPrefixConfig>(Iterator &, uint16_t, OnMeshPrefixConfig &) const;
{ template Error NetworkData::GetNext<ExternalRouteConfig>(Iterator &, uint16_t, ExternalRouteConfig &) const;
Config config; template Error NetworkData::GetNext<ServiceConfig>(Iterator &, uint16_t, ServiceConfig &) const;
template Error NetworkData::GetNext<LowpanContextInfo>(Iterator &, uint16_t, LowpanContextInfo &) const;
config.mOnMeshPrefix = nullptr;
config.mExternalRoute = &aConfig;
config.mService = nullptr;
config.mLowpanContext = nullptr;
return Iterate(aIterator, aRloc16, config);
}
Error NetworkData::GetNextService(Iterator &aIterator, ServiceConfig &aConfig) const
{
return GetNextService(aIterator, Mac::kShortAddrBroadcast, aConfig);
}
Error NetworkData::GetNextService(Iterator &aIterator, uint16_t aRloc16, ServiceConfig &aConfig) const
{
Config config;
config.mOnMeshPrefix = nullptr;
config.mExternalRoute = nullptr;
config.mService = &aConfig;
config.mLowpanContext = nullptr;
return Iterate(aIterator, aRloc16, config);
}
Error NetworkData::GetNextLowpanContextInfo(Iterator &aIterator, LowpanContextInfo &aContextInfo) const
{
Config config;
config.mOnMeshPrefix = nullptr;
config.mExternalRoute = nullptr;
config.mService = nullptr;
config.mLowpanContext = &aContextInfo;
return Iterate(aIterator, Mac::kShortAddrBroadcast, config);
}
Error NetworkData::Iterate(Iterator &aIterator, uint16_t aRloc16, Config &aConfig) const Error NetworkData::Iterate(Iterator &aIterator, uint16_t aRloc16, Config &aConfig) const
{ {
@@ -313,15 +275,15 @@ exit:
return error; return error;
} }
bool NetworkData::ContainsOnMeshPrefix(const OnMeshPrefixConfig &aPrefix) const template <typename EntryType> bool NetworkData::Contains(const EntryType &aEntry) const
{ {
bool contains = false; bool contains = false;
Iterator iterator = kIteratorInit; Iterator iterator = kIteratorInit;
OnMeshPrefixConfig prefix; EntryType entry;
while (GetNextOnMeshPrefix(iterator, aPrefix.mRloc16, prefix) == kErrorNone) while (GetNext(iterator, aEntry.GetRloc16(), entry) == kErrorNone)
{ {
if (prefix == aPrefix) if (entry == aEntry)
{ {
contains = true; contains = true;
break; break;
@@ -331,41 +293,10 @@ bool NetworkData::ContainsOnMeshPrefix(const OnMeshPrefixConfig &aPrefix) const
return contains; return contains;
} }
bool NetworkData::ContainsExternalRoute(const ExternalRouteConfig &aRoute) const // Explicit template instantiations
{ template bool NetworkData::Contains<OnMeshPrefixConfig>(const OnMeshPrefixConfig &) const;
bool contains = false; template bool NetworkData::Contains<ExternalRouteConfig>(const ExternalRouteConfig &) const;
Iterator iterator = kIteratorInit; template bool NetworkData::Contains<ServiceConfig>(const ServiceConfig &) const;
ExternalRouteConfig route;
while (GetNextExternalRoute(iterator, aRoute.mRloc16, route) == kErrorNone)
{
if (route == aRoute)
{
contains = true;
break;
}
}
return contains;
}
bool NetworkData::ContainsService(const ServiceConfig &aService) const
{
bool contains = false;
Iterator iterator = kIteratorInit;
ServiceConfig service;
while (GetNextService(iterator, aService.GetServerConfig().mRloc16, service) == kErrorNone)
{
if (service == aService)
{
contains = true;
break;
}
}
return contains;
}
bool NetworkData::ContainsEntriesFrom(const NetworkData &aCompare, uint16_t aRloc16) const bool NetworkData::ContainsEntriesFrom(const NetworkData &aCompare, uint16_t aRloc16) const
{ {
@@ -386,9 +317,9 @@ bool NetworkData::ContainsEntriesFrom(const NetworkData &aCompare, uint16_t aRlo
SuccessOrExit(aCompare.Iterate(iterator, aRloc16, config)); SuccessOrExit(aCompare.Iterate(iterator, aRloc16, config));
if (((config.mOnMeshPrefix != nullptr) && !ContainsOnMeshPrefix(*config.mOnMeshPrefix)) || if (((config.mOnMeshPrefix != nullptr) && !Contains(*config.mOnMeshPrefix)) ||
((config.mExternalRoute != nullptr) && !ContainsExternalRoute(*config.mExternalRoute)) || ((config.mExternalRoute != nullptr) && !Contains(*config.mExternalRoute)) ||
((config.mService != nullptr) && !ContainsService(*config.mService))) ((config.mService != nullptr) && !Contains(*config.mService)))
{ {
ExitNow(contains = false); ExitNow(contains = false);
} }
+52 -97
View File
@@ -96,7 +96,7 @@ class Publisher;
class MutableNetworkData; class MutableNetworkData;
/** /**
* Represents a Iterator used to iterate through Network Data info (e.g., see `GetNextOnMeshPrefix()`) * Represents a Iterator used to iterate through Network Data info (e.g., see `GetNext<EntryType>()`)
*/ */
typedef otNetworkDataIterator Iterator; typedef otNetworkDataIterator Iterator;
@@ -184,114 +184,51 @@ public:
Error CopyNetworkData(Type aType, MutableNetworkData &aNetworkData) const; Error CopyNetworkData(Type aType, MutableNetworkData &aNetworkData) const;
/** /**
* Provides the next On Mesh prefix in the Thread Network Data. * Gets the next Network Data entry of a specific type (e.g., on-mesh prefix, external route, service).
* *
* @param[in,out] aIterator A reference to the Network Data iterator. * @tparam EntryType The type of Network Data entry to find. It MUST be `OnMeshPrefixConfig`,
* @param[out] aConfig A reference to a config variable where the On Mesh Prefix information will be placed. * `ExternalRouteConfig`, `ServiceConfig`, or `LowpanContextInfo`.
* *
* @retval kErrorNone Successfully found the next On Mesh prefix. * To start iterating from the first entry, `aIterator` must be set to `kIteratorInit` before the first call.
* @retval kErrorNotFound No subsequent On Mesh prefix exists in the Thread Network Data. *
* @param[in,out] aIterator A reference to an iterator to track the current position in the Network Data.
* @param[out] aEntry A reference to an object to populate with the retrieved entry's information.
*
* @retval kErrorNone Successfully found the next entry and populated @p aEntry.
* @retval kErrorNotFound No subsequent entry of the requested type exists in the Thread Network Data.
*/ */
Error GetNextOnMeshPrefix(Iterator &aIterator, OnMeshPrefixConfig &aConfig) const; template <typename EntryType> Error GetNext(Iterator &aIterator, EntryType &aEntry) const;
/** /**
* Provides the next On Mesh prefix in the Thread Network Data for a given RLOC16. * Gets the next Network Data entry of a specific type (e.g., on-mesh prefix, external route, service) associated
* with a given RLOC16.
* *
* @param[in,out] aIterator A reference to the Network Data iterator. * @tparam EntryType The type of Network Data entry to find. It MUST be `OnMeshPrefixConfig`,
* @param[in] aRloc16 The RLOC16 value. * `ExternalRouteConfig`, `ServiceConfig`, or `LowpanContextInfo`.
* @param[out] aConfig A reference to a config variable where the On Mesh Prefix information will be placed.
* *
* @retval kErrorNone Successfully found the next On Mesh prefix. * To start iterating from the first entry, `aIterator` must be set to `kIteratorInit` before the first call.
* @retval kErrorNotFound No subsequent On Mesh prefix exists in the Thread Network Data. *
* @param[in,out] aIterator An iterator to track the current position in the Network Data.
* @param[in] aRloc16 The RLOC16 to filter entries by.
* @param[out] aEntry An object to populate with the retrieved entry's information.
*
* @retval kErrorNone Successfully found the next entry and populated @p aEntry.
* @retval kErrorNotFound No subsequent entry of the requested type exists in the Thread Network Data.
*/ */
Error GetNextOnMeshPrefix(Iterator &aIterator, uint16_t aRloc16, OnMeshPrefixConfig &aConfig) const; template <typename EntryType> Error GetNext(Iterator &aIterator, uint16_t aRloc16, EntryType &aEntry) const;
/** /**
* Provides the next external route in the Thread Network Data. * Indicates whether or not the Network Data contains a given entry of specific type.
* *
* @param[in,out] aIterator A reference to the Network Data iterator. * @tparam EntryType The type of Network Data entry to find. It MUST be `OnMeshPrefixConfig`,
* @param[out] aConfig A reference to a config variable where the external route information will be placed. * `ExternalRouteConfig`, or `ServiceConfig`.
* *
* @retval kErrorNone Successfully found the next external route. * @param[in] aEntry The entry to check
* @retval kErrorNotFound No subsequent external route exists in the Thread Network Data. *
* @retval TRUE if Network Data contains an entry matching @p aEntry.
* @retval FALSE if Network Data does not contain any entry matching @p aEntry.
*/ */
Error GetNextExternalRoute(Iterator &aIterator, ExternalRouteConfig &aConfig) const; template <typename EntryType> bool Contains(const EntryType &aEntry) const;
/**
* Provides the next external route in the Thread Network Data for a given RLOC16.
*
* @param[in,out] aIterator A reference to the Network Data iterator.
* @param[in] aRloc16 The RLOC16 value.
* @param[out] aConfig A reference to a config variable where the external route information will be placed.
*
* @retval kErrorNone Successfully found the next external route.
* @retval kErrorNotFound No subsequent external route exists in the Thread Network Data.
*/
Error GetNextExternalRoute(Iterator &aIterator, uint16_t aRloc16, ExternalRouteConfig &aConfig) const;
/**
* Provides the next service in the Thread Network Data.
*
* @param[in,out] aIterator A reference to the Network Data iterator.
* @param[out] aConfig A reference to a config variable where the service information will be placed.
*
* @retval kErrorNone Successfully found the next service.
* @retval kErrorNotFound No subsequent service exists in the Thread Network Data.
*/
Error GetNextService(Iterator &aIterator, ServiceConfig &aConfig) const;
/**
* Provides the next service in the Thread Network Data for a given RLOC16.
*
* @param[in,out] aIterator A reference to the Network Data iterator.
* @param[in] aRloc16 The RLOC16 value.
* @param[out] aConfig A reference to a config variable where the service information will be placed.
*
* @retval kErrorNone Successfully found the next service.
* @retval kErrorNotFound No subsequent service exists in the Thread Network Data.
*/
Error GetNextService(Iterator &aIterator, uint16_t aRloc16, ServiceConfig &aConfig) const;
/**
* Gets the next 6LoWPAN Context ID info in the Thread Network Data.
*
* @param[in,out] aIterator A reference to the Network Data iterator.
* @param[out] aContextInfo A reference to where the retrieved 6LoWPAN Context ID information will be placed.
*
* @retval kErrorNone Successfully found the next 6LoWPAN Context ID info.
* @retval kErrorNotFound No subsequent 6LoWPAN Context info exists in the partition's Network Data.
*/
Error GetNextLowpanContextInfo(Iterator &aIterator, LowpanContextInfo &aContextInfo) const;
/**
* Indicates whether or not the Thread Network Data contains a given on mesh prefix entry.
*
* @param[in] aPrefix The on mesh prefix config to check.
*
* @retval TRUE if Network Data contains an on mesh prefix matching @p aPrefix.
* @retval FALSE if Network Data does not contain an on mesh prefix matching @p aPrefix.
*/
bool ContainsOnMeshPrefix(const OnMeshPrefixConfig &aPrefix) const;
/**
* Indicates whether or not the Thread Network Data contains a given external route entry.
*
* @param[in] aRoute The external route config to check.
*
* @retval TRUE if Network Data contains an external route matching @p aRoute.
* @retval FALSE if Network Data does not contain an external route matching @p aRoute.
*/
bool ContainsExternalRoute(const ExternalRouteConfig &aRoute) const;
/**
* Indicates whether or not the Thread Network Data contains a given service entry.
*
* @param[in] aService The service config to check.
*
* @retval TRUE if Network Data contains a service matching @p aService.
* @retval FALSE if Network Data does not contain a service matching @p aService.
*/
bool ContainsService(const ServiceConfig &aService) const;
/** /**
* Indicates whether or not the Thread Network Data contains all the on mesh prefixes, external * Indicates whether or not the Thread Network Data contains all the on mesh prefixes, external
@@ -533,8 +470,13 @@ private:
uint8_t *mIteratorBuffer; uint8_t *mIteratorBuffer;
}; };
struct Config struct Config : Clearable<Config>
{ {
void Set(OnMeshPrefixConfig &aConfig) { mOnMeshPrefix = &aConfig; }
void Set(ExternalRouteConfig &aConfig) { mExternalRoute = &aConfig; }
void Set(ServiceConfig &aConfig) { mService = &aConfig; }
void Set(LowpanContextInfo &aInfo) { mLowpanContext = &aInfo; }
OnMeshPrefixConfig *mOnMeshPrefix; OnMeshPrefixConfig *mOnMeshPrefix;
ExternalRouteConfig *mExternalRoute; ExternalRouteConfig *mExternalRoute;
ServiceConfig *mService; ServiceConfig *mService;
@@ -554,6 +496,19 @@ private:
uint8_t mLength; uint8_t mLength;
}; };
// Explicit instantiation declarations
extern template Error NetworkData::GetNext<OnMeshPrefixConfig>(Iterator &, OnMeshPrefixConfig &) const;
extern template Error NetworkData::GetNext<ExternalRouteConfig>(Iterator &, ExternalRouteConfig &) const;
extern template Error NetworkData::GetNext<ServiceConfig>(Iterator &, ServiceConfig &) const;
extern template Error NetworkData::GetNext<LowpanContextInfo>(Iterator &, LowpanContextInfo &) const;
extern template Error NetworkData::GetNext<OnMeshPrefixConfig>(Iterator &, uint16_t, OnMeshPrefixConfig &) const;
extern template Error NetworkData::GetNext<ExternalRouteConfig>(Iterator &, uint16_t, ExternalRouteConfig &) const;
extern template Error NetworkData::GetNext<ServiceConfig>(Iterator &, uint16_t, ServiceConfig &) const;
extern template Error NetworkData::GetNext<LowpanContextInfo>(Iterator &, uint16_t, LowpanContextInfo &) const;
extern template bool NetworkData::Contains<OnMeshPrefixConfig>(const OnMeshPrefixConfig &) const;
extern template bool NetworkData::Contains<ExternalRouteConfig>(const ExternalRouteConfig &) const;
extern template bool NetworkData::Contains<ServiceConfig>(const ServiceConfig &) const;
/** /**
* Represents mutable Network Data. * Represents mutable Network Data.
*/ */
+11 -10
View File
@@ -77,7 +77,7 @@ Error Leader::GetServiceId(uint32_t aEnterpriseNumber,
ServiceConfig serviceConfig; ServiceConfig serviceConfig;
ServiceData serviceData; ServiceData serviceData;
while (GetNextService(iterator, serviceConfig) == kErrorNone) while (GetNext(iterator, serviceConfig) == kErrorNone)
{ {
serviceConfig.GetServiceData(serviceData); serviceConfig.GetServiceData(serviceData);
@@ -97,19 +97,19 @@ Error Leader::GetPreferredNat64Prefix(ExternalRouteConfig &aConfig) const
{ {
Error error = kErrorNotFound; Error error = kErrorNotFound;
Iterator iterator = kIteratorInit; Iterator iterator = kIteratorInit;
ExternalRouteConfig config; ExternalRouteConfig routeConfig;
while (GetNextExternalRoute(iterator, config) == kErrorNone) while (GetNext(iterator, routeConfig) == kErrorNone)
{ {
if (!config.mNat64 || !config.GetPrefix().IsValidNat64()) if (!routeConfig.mNat64 || !routeConfig.GetPrefix().IsValidNat64())
{ {
continue; continue;
} }
if ((error == kErrorNotFound) || (config.mPreference > aConfig.mPreference) || if ((error == kErrorNotFound) || (routeConfig.mPreference > aConfig.mPreference) ||
(config.mPreference == aConfig.mPreference && config.GetPrefix() < aConfig.GetPrefix())) (routeConfig.mPreference == aConfig.mPreference && routeConfig.GetPrefix() < aConfig.GetPrefix()))
{ {
aConfig = config; aConfig = routeConfig;
error = kErrorNone; error = kErrorNone;
} }
} }
@@ -121,11 +121,12 @@ bool Leader::IsNat64(const Ip6::Address &aAddress) const
{ {
bool isNat64 = false; bool isNat64 = false;
Iterator iterator = kIteratorInit; Iterator iterator = kIteratorInit;
ExternalRouteConfig config; ExternalRouteConfig routeConfig;
while (GetNextExternalRoute(iterator, config) == kErrorNone) while (GetNext(iterator, routeConfig) == kErrorNone)
{ {
if (config.mNat64 && config.GetPrefix().IsValidNat64() && aAddress.MatchesPrefix(config.GetPrefix())) if (routeConfig.mNat64 && routeConfig.GetPrefix().IsValidNat64() &&
aAddress.MatchesPrefix(routeConfig.GetPrefix()))
{ {
isNat64 = true; isNat64 = true;
break; break;
+28
View File
@@ -204,6 +204,13 @@ public:
*/ */
Ip6::Prefix &GetPrefix(void) { return AsCoreType(&mPrefix); } Ip6::Prefix &GetPrefix(void) { return AsCoreType(&mPrefix); }
/**
* Gets the RLOC16.
*
* @returns The RLOC16.
*/
uint16_t GetRloc16(void) const { return mRloc16; }
/** /**
* Gets the preference. * Gets the preference.
* *
@@ -266,6 +273,13 @@ public:
*/ */
void SetPrefix(const Ip6::Prefix &aPrefix) { mPrefix = aPrefix; } void SetPrefix(const Ip6::Prefix &aPrefix) { mPrefix = aPrefix; }
/**
* Gets the RLOC16.
*
* @returns The RLOC16.
*/
uint16_t GetRloc16(void) const { return mRloc16; }
#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE
/** /**
* Indicates whether or not the external route configuration is valid. * Indicates whether or not the external route configuration is valid.
@@ -346,6 +360,13 @@ public:
*/ */
void GetServerData(ServerData &aServerData) const { aServerData.Init(mServerData, mServerDataLength); } void GetServerData(ServerData &aServerData) const { aServerData.Init(mServerData, mServerDataLength); }
/**
* Gets the server RLOC16.
*
* @returns The server RLOC16.
*/
uint16_t GetRloc16(void) const { return mRloc16; }
/** /**
* Overloads operator `==` to evaluate whether or not two `ServerConfig` instances are equal. * Overloads operator `==` to evaluate whether or not two `ServerConfig` instances are equal.
* *
@@ -381,6 +402,13 @@ public:
*/ */
ServerConfig &GetServerConfig(void) { return static_cast<ServerConfig &>(mServerConfig); } ServerConfig &GetServerConfig(void) { return static_cast<ServerConfig &>(mServerConfig); }
/**
* Gets the RLOC16.
*
* @returns The RLOC16.
*/
uint16_t GetRloc16(void) const { return GetServerConfig().GetRloc16(); }
/** /**
* Overloads operator `==` to evaluate whether or not two `ServiceConfig` instances are equal. * Overloads operator `==` to evaluate whether or not two `ServiceConfig` instances are equal.
* *
+8 -8
View File
@@ -364,9 +364,9 @@ void Local::RecordNetworkDataChange(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (mPreviousNetworkData.GetNextOnMeshPrefix(iterator, prefix) == kErrorNone) while (mPreviousNetworkData.GetNext(iterator, prefix) == kErrorNone)
{ {
if (!Get<NetworkData::Leader>().ContainsOnMeshPrefix(prefix)) if (!Get<NetworkData::Leader>().Contains(prefix))
{ {
RecordOnMeshPrefixEvent(kNetDataEntryRemoved, prefix); RecordOnMeshPrefixEvent(kNetDataEntryRemoved, prefix);
} }
@@ -374,9 +374,9 @@ void Local::RecordNetworkDataChange(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, prefix) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefix) == kErrorNone)
{ {
if (!mPreviousNetworkData.ContainsOnMeshPrefix(prefix)) if (!mPreviousNetworkData.Contains(prefix))
{ {
RecordOnMeshPrefixEvent(kNetDataEntryAdded, prefix); RecordOnMeshPrefixEvent(kNetDataEntryAdded, prefix);
} }
@@ -386,9 +386,9 @@ void Local::RecordNetworkDataChange(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (mPreviousNetworkData.GetNextExternalRoute(iterator, route) == kErrorNone) while (mPreviousNetworkData.GetNext(iterator, route) == kErrorNone)
{ {
if (!Get<NetworkData::Leader>().ContainsExternalRoute(route)) if (!Get<NetworkData::Leader>().Contains(route))
{ {
RecordExternalRouteEvent(kNetDataEntryRemoved, route); RecordExternalRouteEvent(kNetDataEntryRemoved, route);
} }
@@ -396,9 +396,9 @@ void Local::RecordNetworkDataChange(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextExternalRoute(iterator, route) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, route) == kErrorNone)
{ {
if (!mPreviousNetworkData.ContainsExternalRoute(route)) if (!mPreviousNetworkData.Contains(route))
{ {
RecordExternalRouteEvent(kNetDataEntryAdded, route); RecordExternalRouteEvent(kNetDataEntryAdded, route);
} }
+11 -11
View File
@@ -171,7 +171,7 @@ void Slaac::RemoveOrDeprecateAddresses(void)
for (SlaacAddress &slaacAddr : mSlaacAddresses) for (SlaacAddress &slaacAddr : mSlaacAddresses)
{ {
NetworkData::Iterator iterator; NetworkData::Iterator iterator;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
bool found = false; bool found = false;
if (!slaacAddr.IsInUse()) if (!slaacAddr.IsInUse())
@@ -181,9 +181,9 @@ void Slaac::RemoveOrDeprecateAddresses(void)
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
if (IsSlaac(config) && DoesConfigMatchNetifAddr(config, slaacAddr)) if (IsSlaac(prefixConfig) && DoesConfigMatchNetifAddr(prefixConfig, slaacAddr))
{ {
found = true; found = true;
break; break;
@@ -192,7 +192,7 @@ void Slaac::RemoveOrDeprecateAddresses(void)
if (found) if (found)
{ {
if (IsFiltered(config)) if (IsFiltered(prefixConfig))
{ {
RemoveAddress(slaacAddr); RemoveAddress(slaacAddr);
} }
@@ -252,26 +252,26 @@ void Slaac::RemoveAddress(SlaacAddress &aAddress)
void Slaac::AddAddresses(void) void Slaac::AddAddresses(void)
{ {
NetworkData::Iterator iterator; NetworkData::Iterator iterator;
NetworkData::OnMeshPrefixConfig config; NetworkData::OnMeshPrefixConfig prefixConfig;
// Generate and add SLAAC addresses for any newly added on-mesh prefixes. // Generate and add SLAAC addresses for any newly added on-mesh prefixes.
iterator = NetworkData::kIteratorInit; iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNextOnMeshPrefix(iterator, config) == kErrorNone) while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{ {
bool found = false; bool found = false;
if (!IsSlaac(config) || IsFiltered(config)) if (!IsSlaac(prefixConfig) || IsFiltered(prefixConfig))
{ {
continue; continue;
} }
for (SlaacAddress &slaacAddr : mSlaacAddresses) for (SlaacAddress &slaacAddr : mSlaacAddresses)
{ {
if (slaacAddr.IsInUse() && DoesConfigMatchNetifAddr(config, slaacAddr)) if (slaacAddr.IsInUse() && DoesConfigMatchNetifAddr(prefixConfig, slaacAddr))
{ {
if (slaacAddr.IsDeprecating() && config.mPreferred) if (slaacAddr.IsDeprecating() && prefixConfig.mPreferred)
{ {
slaacAddr.MarkAsNotDeprecating(); slaacAddr.MarkAsNotDeprecating();
Get<ThreadNetif>().UpdatePreferredFlagOn(slaacAddr, true); Get<ThreadNetif>().UpdatePreferredFlagOn(slaacAddr, true);
@@ -289,7 +289,7 @@ void Slaac::AddAddresses(void)
for (const Ip6::Netif::UnicastAddress &netifAddr : Get<ThreadNetif>().GetUnicastAddresses()) for (const Ip6::Netif::UnicastAddress &netifAddr : Get<ThreadNetif>().GetUnicastAddresses())
{ {
if (DoesConfigMatchNetifAddr(config, netifAddr)) if (DoesConfigMatchNetifAddr(prefixConfig, netifAddr))
{ {
found = true; found = true;
break; break;
@@ -298,7 +298,7 @@ void Slaac::AddAddresses(void)
if (!found) if (!found)
{ {
AddAddressFor(config); AddAddressFor(prefixConfig);
} }
} }
} }
+5 -5
View File
@@ -179,12 +179,12 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes) for (const auto &route : routes)
{ {
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig)); SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig); PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route)); VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
} }
VerifyOrQuit(netData.GetNextExternalRoute(iter, rconfig) == kErrorNotFound); VerifyOrQuit(netData.GetNext(iter, rconfig) == kErrorNotFound);
netData.FindRlocs(kAnyBrOrServer, kAnyRole, rlocs); netData.FindRlocs(kAnyBrOrServer, kAnyRole, rlocs);
VerifyRlocsArray(rlocs, kRlocs); VerifyRlocsArray(rlocs, kRlocs);
@@ -303,7 +303,7 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes) for (const auto &route : routes)
{ {
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig)); SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig); PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route)); VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
} }
@@ -471,7 +471,7 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes) for (const auto &route : routes)
{ {
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig)); SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig); PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route)); VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
} }
@@ -480,7 +480,7 @@ void TestNetworkDataIterator(void)
for (const auto &prefix : prefixes) for (const auto &prefix : prefixes)
{ {
SuccessOrQuit(netData.GetNextOnMeshPrefix(iter, pconfig)); SuccessOrQuit(netData.GetNext(iter, pconfig));
PrintOnMeshPrefixConfig(pconfig); PrintOnMeshPrefixConfig(pconfig);
VerifyOrQuit(CompareOnMeshPrefixConfig(pconfig, prefix)); VerifyOrQuit(CompareOnMeshPrefixConfig(pconfig, prefix));
} }