mirror of
https://github.com/espressif/openthread.git
synced 2026-09-16 22:20:07 +00:00
[api] harmonize nullptr assert check of pointer input parameters (#8031)
This commit harmonizes and simplifies the code related to asserting that the OT API pointer parameters are valid and not `nullptr`. `OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL` is added which when used performs assert check on all pointer inputs to APIs. This is either done within `AsCoreType()` when the pointer is converted to its related core type, or by a direct call to newly added macro `AssertPointerIsNotNull()`. Since enabling assert checks on every API parameter can increase code size, this config is disabled by default and it is recommended to use it during debugging only.
This commit is contained in:
@@ -44,7 +44,7 @@ using namespace ot;
|
||||
|
||||
otError otBackboneRouterGetPrimary(otInstance *aInstance, otBackboneRouterConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
AssertPointerIsNotNull(aConfig);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::Leader>().GetConfig(*aConfig);
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ otBackboneRouterState otBackboneRouterGetState(otInstance *aInstance)
|
||||
|
||||
void otBackboneRouterGetConfig(otInstance *aInstance, otBackboneRouterConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
AssertPointerIsNotNull(aConfig);
|
||||
|
||||
AsCoreType(aInstance).Get<BackboneRouter::Local>().GetConfig(*aConfig);
|
||||
}
|
||||
|
||||
otError otBackboneRouterSetConfig(otInstance *aInstance, const otBackboneRouterConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
AssertPointerIsNotNull(aConfig);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::Local>().SetConfig(*aConfig);
|
||||
}
|
||||
@@ -84,8 +84,6 @@ void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitte
|
||||
|
||||
otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::Local>().GetDomainPrefix(AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
@@ -108,6 +106,8 @@ otError otBackboneRouterGetNdProxyInfo(otInstance * aInstance,
|
||||
const otIp6Address * aDua,
|
||||
otBackboneRouterNdProxyInfo *aNdProxyInfo)
|
||||
{
|
||||
AssertPointerIsNotNull(aNdProxyInfo);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::NdProxyTable>().GetInfo(
|
||||
reinterpret_cast<const Ip6::Address &>(*aDua), *aNdProxyInfo);
|
||||
}
|
||||
@@ -125,8 +125,8 @@ otError otBackboneRouterMulticastListenerGetNext(otInstance *
|
||||
otChildIp6AddressIterator * aIterator,
|
||||
otBackboneRouterMulticastListenerInfo *aListenerInfo)
|
||||
{
|
||||
OT_ASSERT(aIterator != nullptr);
|
||||
OT_ASSERT(aListenerInfo != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aListenerInfo);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::MulticastListenersTable>().GetNext(*aIterator, *aListenerInfo);
|
||||
}
|
||||
@@ -159,8 +159,6 @@ void otBackboneRouterMulticastListenerClear(otInstance *aInstance)
|
||||
|
||||
otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6Address *aAddress, uint32_t aTimeout)
|
||||
{
|
||||
OT_ASSERT(aAddress != nullptr);
|
||||
|
||||
if (aTimeout == 0)
|
||||
{
|
||||
BackboneRouter::BackboneRouterConfig config;
|
||||
|
||||
@@ -53,8 +53,6 @@ otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRoute
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
if (aConfig->mDp)
|
||||
{
|
||||
@@ -73,8 +71,6 @@ otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefi
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
OT_ASSERT(aPrefix != nullptr);
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
error = AsCoreType(aInstance).Get<BackboneRouter::Local>().RemoveDomainPrefix(AsCoreType(aPrefix));
|
||||
|
||||
@@ -91,22 +87,18 @@ otError otBorderRouterGetNextOnMeshPrefix(otInstance * aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otBorderRouterConfig * aConfig)
|
||||
{
|
||||
OT_ASSERT(aIterator != nullptr && aConfig != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
return AsCoreType(aInstance).Get<NetworkData::Local>().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aConfig != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<NetworkData::Local>().AddHasRoutePrefix(AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
otError otBorderRouterRemoveRoute(otInstance *aInstance, const otIp6Prefix *aPrefix)
|
||||
{
|
||||
OT_ASSERT(aPrefix != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<NetworkData::Local>().RemoveHasRoutePrefix(AsCoreType(aPrefix));
|
||||
}
|
||||
|
||||
@@ -114,7 +106,7 @@ otError otBorderRouterGetNextRoute(otInstance * aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otExternalRouteConfig *aConfig)
|
||||
{
|
||||
OT_ASSERT(aIterator != nullptr && aConfig != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
return AsCoreType(aInstance).Get<NetworkData::Local>().GetNextExternalRoute(*aIterator, AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ otError otBorderRoutingGetFavoredOmrPrefix(otInstance *aInstance, otIp6Prefix *a
|
||||
otError error;
|
||||
BorderRouter::RoutingManager::RoutePreference preference;
|
||||
|
||||
AssertPointerIsNotNull(aPreference);
|
||||
|
||||
SuccessOrExit(error = AsCoreType(aInstance).Get<BorderRouter::RoutingManager>().GetFavoredOmrPrefix(
|
||||
AsCoreType(aPrefix), preference));
|
||||
*aPreference = static_cast<otRoutePreference>(preference);
|
||||
@@ -100,6 +102,8 @@ otError otBorderRoutingGetFavoredNat64Prefix(otInstance * aInstance,
|
||||
otError error;
|
||||
BorderRouter::RoutingManager::RoutePreference preference;
|
||||
|
||||
AssertPointerIsNotNull(aPreference);
|
||||
|
||||
SuccessOrExit(error = AsCoreType(aInstance).Get<BorderRouter::RoutingManager>().GetFavoredNat64Prefix(
|
||||
AsCoreType(aPrefix), preference));
|
||||
*aPreference = static_cast<otRoutePreference>(preference);
|
||||
@@ -111,6 +115,8 @@ exit:
|
||||
|
||||
void otBorderRoutingPrefixTableInitIterator(otInstance *aInstance, otBorderRoutingPrefixTableIterator *aIterator)
|
||||
{
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
AsCoreType(aInstance).Get<BorderRouter::RoutingManager>().InitPrefixTableIterator(*aIterator);
|
||||
}
|
||||
|
||||
@@ -118,6 +124,9 @@ otError otBorderRoutingGetNextPrefixTableEntry(otInstance *
|
||||
otBorderRoutingPrefixTableIterator *aIterator,
|
||||
otBorderRoutingPrefixTableEntry * aEntry)
|
||||
{
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aEntry);
|
||||
|
||||
return AsCoreType(aInstance).Get<BorderRouter::RoutingManager>().GetNextPrefixTableEntry(*aIterator, *aEntry);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ void otCoapSecureSetCertificate(otInstance * aInstance,
|
||||
const uint8_t *aPrivateKey,
|
||||
uint32_t aPrivateKeyLength)
|
||||
{
|
||||
OT_ASSERT(aX509Cert != nullptr && aX509Length != 0 && aPrivateKey != nullptr && aPrivateKeyLength != 0);
|
||||
|
||||
AsCoreType(aInstance).GetApplicationCoapSecure().SetCertificate(aX509Cert, aX509Length, aPrivateKey,
|
||||
aPrivateKeyLength);
|
||||
}
|
||||
@@ -67,8 +65,6 @@ void otCoapSecureSetCaCertificateChain(otInstance * aInstance,
|
||||
const uint8_t *aX509CaCertificateChain,
|
||||
uint32_t aX509CaCertChainLength)
|
||||
{
|
||||
OT_ASSERT(aX509CaCertificateChain != nullptr && aX509CaCertChainLength != 0);
|
||||
|
||||
AsCoreType(aInstance).GetApplicationCoapSecure().SetCaCertificateChain(aX509CaCertificateChain,
|
||||
aX509CaCertChainLength);
|
||||
}
|
||||
@@ -81,7 +77,8 @@ void otCoapSecureSetPsk(otInstance * aInstance,
|
||||
const uint8_t *aPskIdentity,
|
||||
uint16_t aPskIdLength)
|
||||
{
|
||||
OT_ASSERT(aPsk != nullptr && aPskLength != 0 && aPskIdentity != nullptr && aPskIdLength != 0);
|
||||
AssertPointerIsNotNull(aPsk);
|
||||
AssertPointerIsNotNull(aPskIdentity);
|
||||
|
||||
AsCoreType(aInstance).GetApplicationCoapSecure().SetPreSharedKey(aPsk, aPskLength, aPskIdentity, aPskIdLength);
|
||||
}
|
||||
@@ -93,6 +90,8 @@ otError otCoapSecureGetPeerCertificateBase64(otInstance * aInstance,
|
||||
size_t * aCertLength,
|
||||
size_t aCertBufferSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aPeerCert);
|
||||
|
||||
return AsCoreType(aInstance).GetApplicationCoapSecure().GetPeerCertificateBase64(aPeerCert, aCertLength,
|
||||
aCertBufferSize);
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ void otCryptoHmacSha256(const otCryptoKey *aKey, const uint8_t *aBuf, uint16_t a
|
||||
{
|
||||
HmacSha256 hmac;
|
||||
|
||||
OT_ASSERT((aKey != nullptr) && (aBuf != nullptr) && (aHash != nullptr));
|
||||
AssertPointerIsNotNull(aBuf);
|
||||
|
||||
hmac.Start(AsCoreType(aKey));
|
||||
hmac.Update(aBuf, aBufLength);
|
||||
hmac.Finish(ot::AsCoreType(aHash));
|
||||
hmac.Finish(AsCoreType(aHash));
|
||||
}
|
||||
|
||||
void otCryptoAesCcm(const otCryptoKey *aKey,
|
||||
@@ -71,7 +71,11 @@ void otCryptoAesCcm(const otCryptoKey *aKey,
|
||||
void * aTag)
|
||||
{
|
||||
AesCcm aesCcm;
|
||||
OT_ASSERT((aNonce != nullptr) && (aPlainText != nullptr) && (aCipherText != nullptr) && (aTag != nullptr));
|
||||
|
||||
AssertPointerIsNotNull(aNonce);
|
||||
AssertPointerIsNotNull(aPlainText);
|
||||
AssertPointerIsNotNull(aCipherText);
|
||||
AssertPointerIsNotNull(aTag);
|
||||
|
||||
aesCcm.SetKey(AsCoreType(aKey));
|
||||
aesCcm.Init(aHeaderLength, aLength, aTagLength, aNonce, aNonceLength);
|
||||
@@ -95,6 +99,11 @@ otError otCryptoEcdsaSign(uint8_t * aOutput,
|
||||
const uint8_t *aPrivateKey,
|
||||
uint16_t aPrivateKeyLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aOutput);
|
||||
AssertPointerIsNotNull(aOutputLength);
|
||||
AssertPointerIsNotNull(aInputHash);
|
||||
AssertPointerIsNotNull(aPrivateKey);
|
||||
|
||||
return Ecdsa::Sign(aOutput, *aOutputLength, aInputHash, aInputHashLength, aPrivateKey, aPrivateKeyLength);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,56 +49,48 @@ bool otDatasetIsCommissioned(otInstance *aInstance)
|
||||
|
||||
otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Read(AsCoreType(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
AssertPointerIsNotNull(aDataset);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Read(*aDataset);
|
||||
}
|
||||
|
||||
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Save(AsCoreType(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
AssertPointerIsNotNull(aDataset);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Save(*aDataset);
|
||||
}
|
||||
|
||||
otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Read(AsCoreType(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
AssertPointerIsNotNull(aDataset);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Read(*aDataset);
|
||||
}
|
||||
|
||||
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Save(AsCoreType(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
|
||||
{
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
AssertPointerIsNotNull(aDataset);
|
||||
|
||||
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Save(*aDataset);
|
||||
}
|
||||
@@ -153,7 +145,7 @@ otError otDatasetGeneratePskc(const char * aPassPhrase,
|
||||
{
|
||||
return MeshCoP::GeneratePskc(aPassPhrase, AsCoreType(aNetworkName), AsCoreType(aExtPanId), AsCoreType(aPskc));
|
||||
}
|
||||
#endif // OPENTHREAD_FTD
|
||||
#endif
|
||||
|
||||
otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameString)
|
||||
{
|
||||
@@ -167,6 +159,8 @@ otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOpera
|
||||
Error error = kErrorNone;
|
||||
MeshCoP::Dataset dataset;
|
||||
|
||||
AssertPointerIsNotNull(aDatasetTlvs);
|
||||
|
||||
dataset.SetFrom(*aDatasetTlvs);
|
||||
VerifyOrExit(dataset.IsValid(), error = kErrorInvalidArgs);
|
||||
dataset.ConvertTo(AsCoreType(aDataset));
|
||||
|
||||
@@ -44,6 +44,8 @@ using namespace ot;
|
||||
|
||||
void otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
AssertPointerIsNotNull(aString);
|
||||
|
||||
AsCoreType(aInstance).Get<FactoryDiags::Diags>().ProcessLine(aString, aOutput, aOutputMaxLen);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ otError otDnsClientResolveAddress(otInstance * aInstance,
|
||||
void * aContext,
|
||||
const otDnsQueryConfig *aConfig)
|
||||
{
|
||||
AssertPointerIsNotNull(aHostName);
|
||||
|
||||
return AsCoreType(aInstance).Get<Dns::Client>().ResolveAddress(aHostName, aCallback, aContext,
|
||||
AsCoreTypePtr(aConfig));
|
||||
}
|
||||
@@ -98,6 +100,8 @@ otError otDnsClientResolveIp4Address(otInstance * aInstance,
|
||||
void * aContext,
|
||||
const otDnsQueryConfig *aConfig)
|
||||
{
|
||||
AssertPointerIsNotNull(aHostName);
|
||||
|
||||
return AsCoreType(aInstance).Get<Dns::Client>().ResolveIp4Address(aHostName, aCallback, aContext,
|
||||
AsCoreTypePtr(aConfig));
|
||||
}
|
||||
@@ -107,6 +111,8 @@ otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse,
|
||||
char * aNameBuffer,
|
||||
uint16_t aNameBufferSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aNameBuffer);
|
||||
|
||||
return AsCoreType(aResponse).GetHostName(aNameBuffer, aNameBufferSize);
|
||||
}
|
||||
|
||||
@@ -128,6 +134,8 @@ otError otDnsClientBrowse(otInstance * aInstance,
|
||||
void * aContext,
|
||||
const otDnsQueryConfig *aConfig)
|
||||
{
|
||||
AssertPointerIsNotNull(aServiceName);
|
||||
|
||||
return AsCoreType(aInstance).Get<Dns::Client>().Browse(aServiceName, aCallback, aContext, AsCoreTypePtr(aConfig));
|
||||
}
|
||||
|
||||
@@ -135,6 +143,8 @@ otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse,
|
||||
char * aNameBuffer,
|
||||
uint16_t aNameBufferSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aNameBuffer);
|
||||
|
||||
return AsCoreType(aResponse).GetServiceName(aNameBuffer, aNameBufferSize);
|
||||
}
|
||||
|
||||
@@ -143,6 +153,8 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon
|
||||
char * aLabelBuffer,
|
||||
uint8_t aLabelBufferSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aLabelBuffer);
|
||||
|
||||
return AsCoreType(aResponse).GetServiceInstance(aIndex, aLabelBuffer, aLabelBufferSize);
|
||||
}
|
||||
|
||||
@@ -150,6 +162,8 @@ otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse,
|
||||
const char * aInstanceLabel,
|
||||
otDnsServiceInfo * aServiceInfo)
|
||||
{
|
||||
AssertPointerIsNotNull(aInstanceLabel);
|
||||
|
||||
return AsCoreType(aResponse).GetServiceInfo(aInstanceLabel, AsCoreType(aServiceInfo));
|
||||
}
|
||||
|
||||
@@ -161,6 +175,8 @@ otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse,
|
||||
{
|
||||
uint32_t ttl;
|
||||
|
||||
AssertPointerIsNotNull(aHostName);
|
||||
|
||||
return AsCoreType(aResponse).GetHostAddress(aHostName, aIndex, AsCoreType(aAddress), aTtl != nullptr ? *aTtl : ttl);
|
||||
}
|
||||
|
||||
@@ -171,6 +187,9 @@ otError otDnsClientResolveService(otInstance * aInstance,
|
||||
void * aContext,
|
||||
const otDnsQueryConfig *aConfig)
|
||||
{
|
||||
AssertPointerIsNotNull(aInstanceLabel);
|
||||
AssertPointerIsNotNull(aServiceName);
|
||||
|
||||
return AsCoreType(aInstance).Get<Dns::Client>().ResolveService(aInstanceLabel, aServiceName, aCallback, aContext,
|
||||
AsCoreTypePtr(aConfig));
|
||||
}
|
||||
@@ -181,6 +200,9 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
|
||||
char * aNameBuffer,
|
||||
uint16_t aNameBufferSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aLabelBuffer);
|
||||
AssertPointerIsNotNull(aNameBuffer);
|
||||
|
||||
return AsCoreType(aResponse).GetServiceName(aLabelBuffer, aLabelBufferSize, aNameBuffer, aNameBufferSize);
|
||||
}
|
||||
|
||||
@@ -197,6 +219,8 @@ otError otDnsServiceResponseGetHostAddress(const otDnsServiceResponse *aResponse
|
||||
{
|
||||
uint32_t ttl;
|
||||
|
||||
AssertPointerIsNotNull(aHostName);
|
||||
|
||||
return AsCoreType(aResponse).GetHostAddress(aHostName, aIndex, AsCoreType(aAddress),
|
||||
(aTtl != nullptr) ? *aTtl : ttl);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance * aIn
|
||||
const char * aServiceFullName,
|
||||
otDnssdServiceInstanceInfo *aInstanceInfo)
|
||||
{
|
||||
OT_ASSERT(aServiceFullName != nullptr);
|
||||
OT_ASSERT(aInstanceInfo != nullptr);
|
||||
AssertPointerIsNotNull(aServiceFullName);
|
||||
AssertPointerIsNotNull(aInstanceInfo);
|
||||
|
||||
AsCoreType(aInstance).Get<Dns::ServiceDiscovery::Server>().HandleDiscoveredServiceInstance(aServiceFullName,
|
||||
*aInstanceInfo);
|
||||
@@ -62,8 +62,8 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance * aIn
|
||||
|
||||
void otDnssdQueryHandleDiscoveredHost(otInstance *aInstance, const char *aHostFullName, otDnssdHostInfo *aHostInfo)
|
||||
{
|
||||
OT_ASSERT(aHostFullName != nullptr);
|
||||
OT_ASSERT(aHostInfo != nullptr);
|
||||
AssertPointerIsNotNull(aHostFullName);
|
||||
AssertPointerIsNotNull(aHostInfo);
|
||||
|
||||
AsCoreType(aInstance).Get<Dns::ServiceDiscovery::Server>().HandleDiscoveredHost(aHostFullName, *aHostInfo);
|
||||
}
|
||||
@@ -75,8 +75,8 @@ const otDnssdQuery *otDnssdGetNextQuery(otInstance *aInstance, const otDnssdQuer
|
||||
|
||||
otDnssdQueryType otDnssdGetQueryTypeAndName(const otDnssdQuery *aQuery, char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE])
|
||||
{
|
||||
OT_ASSERT(aQuery != nullptr);
|
||||
OT_ASSERT(aNameOutput != nullptr);
|
||||
AssertPointerIsNotNull(aQuery);
|
||||
AssertPointerIsNotNull(aNameOutput);
|
||||
|
||||
return MapEnum(Dns::ServiceDiscovery::Server::GetQueryTypeAndName(aQuery, *aNameOutput));
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInsta
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateNetInfoHistory(AsCoreType(aIterator), *aEntryAge);
|
||||
}
|
||||
|
||||
@@ -60,6 +62,8 @@ const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressH
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateUnicastAddressHistory(AsCoreType(aIterator),
|
||||
*aEntryAge);
|
||||
}
|
||||
@@ -69,6 +73,8 @@ const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddr
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateMulticastAddressHistory(AsCoreType(aIterator),
|
||||
*aEntryAge);
|
||||
}
|
||||
@@ -77,6 +83,8 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance *
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateRxHistory(AsCoreType(aIterator), *aEntryAge);
|
||||
}
|
||||
|
||||
@@ -84,6 +92,8 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance *
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateTxHistory(AsCoreType(aIterator), *aEntryAge);
|
||||
}
|
||||
|
||||
@@ -91,6 +101,8 @@ const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otIns
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateNeighborHistory(AsCoreType(aIterator), *aEntryAge);
|
||||
}
|
||||
|
||||
@@ -98,6 +110,8 @@ const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHisto
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateOnMeshPrefixHistory(AsCoreType(aIterator),
|
||||
*aEntryAge);
|
||||
}
|
||||
@@ -107,6 +121,8 @@ const otHistoryTrackerExternalRouteInfo *otHistoryTrackerIterateExternalRouteHis
|
||||
otHistoryTrackerIterator *aIterator,
|
||||
uint32_t * aEntryAge)
|
||||
{
|
||||
AssertPointerIsNotNull(aEntryAge);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::HistoryTracker>().IterateExternalRouteHistory(AsCoreType(aIterator),
|
||||
*aEntryAge);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ uint64_t otInstanceGetUptime(otInstance *aInstance)
|
||||
|
||||
void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuffer);
|
||||
|
||||
AsCoreType(aInstance).Get<Uptime>().GetUptime(aBuffer, aSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -168,6 +168,8 @@ void otIp6RemoveAllUnsecurePorts(otInstance *aInstance)
|
||||
|
||||
const uint16_t *otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries)
|
||||
{
|
||||
AssertPointerIsNotNull(aNumEntries);
|
||||
|
||||
return AsCoreType(aInstance).Get<Ip6::Filter>().GetUnsecurePorts(*aNumEntries);
|
||||
}
|
||||
|
||||
@@ -188,23 +190,27 @@ otError otIp6AddressFromString(const char *aString, otIp6Address *aAddress)
|
||||
|
||||
void otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuffer);
|
||||
|
||||
AsCoreType(aAddress).ToString(aBuffer, aSize);
|
||||
}
|
||||
|
||||
void otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuffer);
|
||||
|
||||
AsCoreType(aSockAddr).ToString(aBuffer, aSize);
|
||||
}
|
||||
|
||||
void otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuffer);
|
||||
|
||||
AsCoreType(aPrefix).ToString(aBuffer, aSize);
|
||||
}
|
||||
|
||||
uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond)
|
||||
{
|
||||
OT_ASSERT(aFirst != nullptr && aSecond != nullptr);
|
||||
|
||||
return AsCoreType(aFirst).PrefixMatch(AsCoreType(aSecond));
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ otError otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExt
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
OT_ASSERT(aExtAddress != nullptr);
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<Mac::Mac>().SetExtAddress(AsCoreType(aExtAddress));
|
||||
@@ -206,15 +205,11 @@ void otLinkFilterSetAddressMode(otInstance *aInstance, otMacFilterAddressMode aM
|
||||
|
||||
otError otLinkFilterAddAddress(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_ASSERT(aExtAddress != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mac::Filter>().AddAddress(AsCoreType(aExtAddress));
|
||||
}
|
||||
|
||||
void otLinkFilterRemoveAddress(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_ASSERT(aExtAddress != nullptr);
|
||||
|
||||
AsCoreType(aInstance).Get<Mac::Filter>().RemoveAddress(AsCoreType(aExtAddress));
|
||||
}
|
||||
|
||||
@@ -225,22 +220,19 @@ void otLinkFilterClearAddresses(otInstance *aInstance)
|
||||
|
||||
otError otLinkFilterGetNextAddress(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry)
|
||||
{
|
||||
OT_ASSERT(aIterator != nullptr && aEntry != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aEntry);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mac::Filter>().GetNextAddress(*aIterator, *aEntry);
|
||||
}
|
||||
|
||||
otError otLinkFilterAddRssIn(otInstance *aInstance, const otExtAddress *aExtAddress, int8_t aRss)
|
||||
{
|
||||
OT_ASSERT(aExtAddress != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mac::Filter>().AddRssIn(AsCoreType(aExtAddress), aRss);
|
||||
}
|
||||
|
||||
void otLinkFilterRemoveRssIn(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_ASSERT(aExtAddress != nullptr);
|
||||
|
||||
AsCoreType(aInstance).Get<Mac::Filter>().RemoveRssIn(AsCoreType(aExtAddress));
|
||||
}
|
||||
|
||||
@@ -261,7 +253,8 @@ void otLinkFilterClearAllRssIn(otInstance *aInstance)
|
||||
|
||||
otError otLinkFilterGetNextRssIn(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry)
|
||||
{
|
||||
OT_ASSERT(aIterator != nullptr && aEntry != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aEntry);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mac::Filter>().GetNextRssIn(*aIterator, *aEntry);
|
||||
}
|
||||
@@ -294,6 +287,8 @@ int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries)
|
||||
{
|
||||
AssertPointerIsNotNull(aNumberOfEntries);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mac::Mac>().GetDirectRetrySuccessHistogram(*aNumberOfEntries);
|
||||
}
|
||||
|
||||
@@ -301,6 +296,8 @@ const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance,
|
||||
{
|
||||
const uint32_t *histogram = nullptr;
|
||||
|
||||
AssertPointerIsNotNull(aNumberOfEntries);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
histogram = AsCoreType(aInstance).Get<Mac::Mac>().GetIndirectRetrySuccessHistogram(*aNumberOfEntries);
|
||||
#else
|
||||
|
||||
@@ -49,8 +49,6 @@ otError otLinkMetricsQuery(otInstance * aInstance,
|
||||
otLinkMetricsReportCallback aCallback,
|
||||
void * aCallbackContext)
|
||||
{
|
||||
OT_ASSERT(aDestination != nullptr);
|
||||
|
||||
AsCoreType(aInstance).Get<LinkMetrics::LinkMetrics>().SetReportCallback(aCallback, aCallbackContext);
|
||||
|
||||
return AsCoreType(aInstance).Get<LinkMetrics::LinkMetrics>().Query(AsCoreType(aDestination), aSeriesId,
|
||||
@@ -65,8 +63,6 @@ otError otLinkMetricsConfigForwardTrackingSeries(otInstance *
|
||||
otLinkMetricsMgmtResponseCallback aCallback,
|
||||
void * aCallbackContext)
|
||||
{
|
||||
OT_ASSERT(aDestination != nullptr);
|
||||
|
||||
LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get<LinkMetrics::LinkMetrics>();
|
||||
|
||||
linkMetrics.SetMgmtResponseCallback(aCallback, aCallbackContext);
|
||||
@@ -85,8 +81,6 @@ otError otLinkMetricsConfigEnhAckProbing(otInstance *
|
||||
otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback,
|
||||
void * aEnhAckCallbackContext)
|
||||
{
|
||||
OT_ASSERT(aDestination != nullptr);
|
||||
|
||||
LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get<LinkMetrics::LinkMetrics>();
|
||||
|
||||
linkMetrics.SetMgmtResponseCallback(aCallback, aCallbackContext);
|
||||
@@ -101,7 +95,6 @@ otError otLinkMetricsSendLinkProbe(otInstance * aInstance,
|
||||
uint8_t aSeriesId,
|
||||
uint8_t aLength)
|
||||
{
|
||||
OT_ASSERT(aDestination != nullptr);
|
||||
LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get<LinkMetrics::LinkMetrics>();
|
||||
|
||||
return linkMetrics.SendLinkProbe(AsCoreType(aDestination), aSeriesId, aLength);
|
||||
|
||||
@@ -159,6 +159,8 @@ otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *
|
||||
Error error = kErrorNone;
|
||||
Instance & instance = AsCoreType(aInstance);
|
||||
|
||||
AssertPointerIsNotNull(aExtAddress);
|
||||
|
||||
VerifyOrExit(instance.Get<Mac::LinkRaw>().IsEnabled(), error = kErrorInvalidState);
|
||||
|
||||
address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
@@ -186,6 +188,8 @@ otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress
|
||||
Error error = kErrorNone;
|
||||
Instance & instance = AsCoreType(aInstance);
|
||||
|
||||
AssertPointerIsNotNull(aExtAddress);
|
||||
|
||||
VerifyOrExit(instance.Get<Mac::LinkRaw>().IsEnabled(), error = kErrorInvalidState);
|
||||
|
||||
address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
@@ -288,6 +292,8 @@ uint16_t otLinkGetShortAddress(otInstance *aInstance)
|
||||
|
||||
void otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui64)
|
||||
{
|
||||
AssertPointerIsNotNull(aEui64);
|
||||
|
||||
otPlatRadioGetIeeeEui64(aInstance, aEui64->m8);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,16 +89,22 @@ int8_t otMessageGetRss(const otMessage *aMessage)
|
||||
|
||||
otError otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuf);
|
||||
|
||||
return AsCoreType(aMessage).AppendBytes(aBuf, aLength);
|
||||
}
|
||||
|
||||
uint16_t otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuf);
|
||||
|
||||
return AsCoreType(aMessage).ReadBytes(aOffset, aBuf, aLength);
|
||||
}
|
||||
|
||||
int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aBuf);
|
||||
|
||||
AsCoreType(aMessage).WriteBytes(aOffset, aBuf, aLength);
|
||||
|
||||
return aLength;
|
||||
@@ -106,6 +112,8 @@ int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint
|
||||
|
||||
void otMessageQueueInit(otMessageQueue *aQueue)
|
||||
{
|
||||
AssertPointerIsNotNull(aQueue);
|
||||
|
||||
aQueue->mData = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ using namespace ot;
|
||||
|
||||
otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aData);
|
||||
AssertPointerIsNotNull(aDataLength);
|
||||
|
||||
return AsCoreType(aInstance).Get<NetworkData::Leader>().CopyNetworkData(
|
||||
aStable ? NetworkData::kStableSubset : NetworkData::kFullSet, aData, *aDataLength);
|
||||
}
|
||||
@@ -50,14 +53,9 @@ otError otNetDataGetNextOnMeshPrefix(otInstance * aInstance,
|
||||
otNetworkDataIterator *aIterator,
|
||||
otBorderRouterConfig * aConfig)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs);
|
||||
|
||||
error = AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
@@ -69,26 +67,16 @@ bool otNetDataContainsOmrPrefix(otInstance *aInstance, const otIp6Prefix *aPrefi
|
||||
|
||||
otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIterator, otExternalRouteConfig *aConfig)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs);
|
||||
|
||||
error = AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextExternalRoute(*aIterator, AsCoreType(aConfig));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextExternalRoute(*aIterator, AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs);
|
||||
|
||||
error = AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextService(*aIterator, AsCoreType(aConfig));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return AsCoreType(aInstance).Get<NetworkData::Leader>().GetNextService(*aIterator, AsCoreType(aConfig));
|
||||
}
|
||||
|
||||
uint8_t otNetDataGetVersion(otInstance *aInstance)
|
||||
|
||||
@@ -46,6 +46,9 @@ otError otThreadGetNextDiagnosticTlv(const otMessage * aMessage,
|
||||
otNetworkDiagIterator *aIterator,
|
||||
otNetworkDiagTlv * aNetworkDiagTlv)
|
||||
{
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aNetworkDiagTlv);
|
||||
|
||||
return NetworkDiagnostic::NetworkDiagnostic::GetNextDiagTlv(AsCoapMessage(aMessage), *aIterator, *aNetworkDiagTlv);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ using namespace ot;
|
||||
|
||||
otNetworkTimeStatus otNetworkTimeGet(otInstance *aInstance, uint64_t *aNetworkTime)
|
||||
{
|
||||
AssertPointerIsNotNull(aNetworkTime);
|
||||
|
||||
return AsCoreType(aInstance).Get<TimeSync>().GetTime(*aNetworkTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,15 @@ using namespace ot;
|
||||
|
||||
char *otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aSize);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::SrpClientBuffers>().GetHostNameString(*aSize);
|
||||
}
|
||||
|
||||
otIp6Address *otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aArrayLength);
|
||||
|
||||
return AsCoreType(aInstance).Get<Utils::SrpClientBuffers>().GetHostAddressesArray(*aArrayLength);
|
||||
}
|
||||
|
||||
@@ -69,21 +73,29 @@ void otSrpClientBuffersFreeAllServices(otInstance *aInstance)
|
||||
|
||||
char *otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aSize);
|
||||
|
||||
return AsCoreType(aEntry).GetServiceNameString(*aSize);
|
||||
}
|
||||
|
||||
char *otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aSize);
|
||||
|
||||
return AsCoreType(aEntry).GetInstanceNameString(*aSize);
|
||||
}
|
||||
|
||||
uint8_t *otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize)
|
||||
{
|
||||
AssertPointerIsNotNull(aSize);
|
||||
|
||||
return AsCoreType(aEntry).GetTxtBuffer(*aSize);
|
||||
}
|
||||
|
||||
const char **otSrpClientBuffersGetSubTypeLabelsArray(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength)
|
||||
{
|
||||
AssertPointerIsNotNull(aArrayLength);
|
||||
|
||||
return AsCoreType(aEntry).GetSubTypeLabelsArray(*aArrayLength);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@ exit:
|
||||
|
||||
otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc)
|
||||
{
|
||||
OT_ASSERT(aLeaderRloc != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderAddress(AsCoreType(aLeaderRloc));
|
||||
}
|
||||
|
||||
@@ -114,8 +112,6 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
OT_ASSERT(aKey != nullptr);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<KeyManager>().SetNetworkKey(AsCoreType(aKey));
|
||||
@@ -297,7 +293,7 @@ otError otThreadBecomeChild(otInstance *aInstance)
|
||||
|
||||
otError otThreadGetNextNeighborInfo(otInstance *aInstance, otNeighborInfoIterator *aIterator, otNeighborInfo *aInfo)
|
||||
{
|
||||
OT_ASSERT((aInfo != nullptr) && (aIterator != nullptr));
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
|
||||
return AsCoreType(aInstance).Get<NeighborTable>().GetNextNeighborInfo(*aIterator, AsCoreType(aInfo));
|
||||
}
|
||||
@@ -316,7 +312,7 @@ otError otThreadGetLeaderData(otInstance *aInstance, otLeaderData *aLeaderData)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
OT_ASSERT(aLeaderData != nullptr);
|
||||
AssertPointerIsNotNull(aLeaderData);
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsAttached(), error = kErrorDetached);
|
||||
*aLeaderData = AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData();
|
||||
@@ -354,7 +350,7 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
OT_ASSERT(aParentRssi != nullptr);
|
||||
AssertPointerIsNotNull(aParentRssi);
|
||||
|
||||
*aParentRssi = AsCoreType(aInstance).Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetAverageRss();
|
||||
|
||||
@@ -368,7 +364,7 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
OT_ASSERT(aLastRssi != nullptr);
|
||||
AssertPointerIsNotNull(aLastRssi);
|
||||
|
||||
*aLastRssi = AsCoreType(aInstance).Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetLastRss();
|
||||
|
||||
|
||||
@@ -205,15 +205,11 @@ void otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitt
|
||||
|
||||
otError otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo)
|
||||
{
|
||||
OT_ASSERT(aChildInfo != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<ChildTable>().GetChildInfoById(aChildId, AsCoreType(aChildInfo));
|
||||
}
|
||||
|
||||
otError otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo)
|
||||
{
|
||||
OT_ASSERT(aChildInfo != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<ChildTable>().GetChildInfoByIndex(aChildIndex, AsCoreType(aChildInfo));
|
||||
}
|
||||
|
||||
@@ -225,7 +221,8 @@ otError otThreadGetChildNextIp6Address(otInstance * aInstance,
|
||||
Error error = kErrorNone;
|
||||
const Child *child;
|
||||
|
||||
OT_ASSERT(aIterator != nullptr && aAddress != nullptr);
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aAddress);
|
||||
|
||||
child = AsCoreType(aInstance).Get<ChildTable>().GetChildAtIndex(aChildIndex);
|
||||
VerifyOrExit(child != nullptr, error = kErrorInvalidArgs);
|
||||
@@ -258,14 +255,13 @@ uint8_t otThreadGetMaxRouterId(otInstance *aInstance)
|
||||
|
||||
otError otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo)
|
||||
{
|
||||
OT_ASSERT(aRouterInfo != nullptr);
|
||||
|
||||
return AsCoreType(aInstance).Get<RouterTable>().GetRouterInfo(aRouterId, AsCoreType(aRouterInfo));
|
||||
}
|
||||
|
||||
otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntryInfo, otCacheEntryIterator *aIterator)
|
||||
{
|
||||
OT_ASSERT((aIterator != nullptr) && (aEntryInfo != nullptr));
|
||||
AssertPointerIsNotNull(aIterator);
|
||||
AssertPointerIsNotNull(aEntryInfo);
|
||||
|
||||
return AsCoreType(aInstance).Get<AddressResolver>().GetNextCacheEntry(*aEntryInfo, *aIterator);
|
||||
}
|
||||
|
||||
@@ -95,8 +95,6 @@ void otUdpForwardReceive(otInstance * aInstance,
|
||||
{
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
OT_ASSERT(aMessage != nullptr && aPeerAddr != nullptr);
|
||||
|
||||
messageInfo.SetSockAddr(AsCoreType(aInstance).Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
messageInfo.SetSockPort(aSockPort);
|
||||
messageInfo.SetPeerAddr(AsCoreType(aPeerAddr));
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include "common/debug.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
/**
|
||||
@@ -63,6 +65,8 @@ template <typename FromType> struct CoreType;
|
||||
*/
|
||||
template <typename Type> typename CoreType<Type>::Type &AsCoreType(Type *aObject)
|
||||
{
|
||||
AssertPointerIsNotNull(aObject);
|
||||
|
||||
return *static_cast<typename CoreType<Type>::Type *>(aObject);
|
||||
}
|
||||
|
||||
@@ -78,6 +82,8 @@ template <typename Type> typename CoreType<Type>::Type &AsCoreType(Type *aObject
|
||||
*/
|
||||
template <typename Type> const typename CoreType<Type>::Type &AsCoreType(const Type *aObject)
|
||||
{
|
||||
AssertPointerIsNotNull(aObject);
|
||||
|
||||
return *static_cast<const typename CoreType<Type>::Type *>(aObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,4 +108,19 @@
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
/**
|
||||
* @def AssertPointerIsNotNull
|
||||
*
|
||||
* This macro asserts that a given pointer (API input parameter) is not `nullptr`. This macro checks the pointer only
|
||||
* when `OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL` is enabled. Otherwise it is an empty macro.
|
||||
*
|
||||
* @param[in] aPointer The pointer variable (API input parameter) to check.
|
||||
*
|
||||
*/
|
||||
#if OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL
|
||||
#define AssertPointerIsNotNull(aPointer) OT_ASSERT((aPointer) != nullptr)
|
||||
#else
|
||||
#define AssertPointerIsNotNull(aPointer)
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_HPP_
|
||||
|
||||
@@ -346,6 +346,19 @@
|
||||
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL
|
||||
*
|
||||
* Define as 1 to enable assert check of pointer-type API input parameters against null.
|
||||
*
|
||||
* Enabling this feature can increase code-size significantly due to many assert checks added for all API pointer
|
||||
* parameters. It is recommended to enable and use this feature during debugging only.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL
|
||||
#define OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
*
|
||||
|
||||
@@ -299,4 +299,14 @@
|
||||
#define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL
|
||||
*
|
||||
* Define as 1 to enable assert check of pointer-type API input parameters against null.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL
|
||||
#define OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL 1
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CORE_POSIX_CONFIG_H_
|
||||
|
||||
Reference in New Issue
Block a user