mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[network-data] added support for iterating over services from leader data (#2368)
This commit is contained in:
committed by
Jonathan Hui
parent
9b4a9aced4
commit
c9c203bbed
@@ -110,6 +110,21 @@ OTAPI otError OTCALL otServerRemoveService(otInstance *aInstance, uint32_t aEnte
|
||||
OTAPI otError OTCALL otServerGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator,
|
||||
otServiceConfig *aConfig);
|
||||
|
||||
/**
|
||||
* This function gets the next service in the leader Network Data.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[inout] aIterator A pointer to the Network Data iterator context. To get the first service entry
|
||||
it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
|
||||
* @param[out] aConfig A pointer to where the service information will be placed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the next service.
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent service exists in the leader Network Data.
|
||||
*
|
||||
*/
|
||||
OTAPI otError OTCALL otServerGetNextLeaderService(otInstance *aInstance, otNetworkDataIterator *aIterator,
|
||||
otServiceConfig *aConfig);
|
||||
|
||||
/**
|
||||
* Immediately register the local network data with the Leader.
|
||||
*
|
||||
|
||||
@@ -856,6 +856,11 @@ typedef struct otServerConfig
|
||||
*/
|
||||
typedef struct otServiceConfig
|
||||
{
|
||||
/**
|
||||
* Service ID. This field is used to return service ID when iterating over network data from leader.
|
||||
*/
|
||||
uint8_t mServiceID;
|
||||
|
||||
/**
|
||||
* IANA Enterprise Number.
|
||||
*/
|
||||
|
||||
@@ -87,6 +87,20 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otServerGetNextLeaderService(otInstance *aInstance, otNetworkDataIterator *aIterator,
|
||||
otServiceConfig *aConfig)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aIterator && aConfig, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = instance.GetThreadNetif().GetNetworkDataLeader().GetNextService(aIterator, aConfig);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otServerRegister(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
@@ -285,6 +285,7 @@ otError NetworkData::GetNextService(otNetworkDataIterator *aIterator, uint16_t a
|
||||
{
|
||||
memset(aConfig, 0, sizeof(*aConfig));
|
||||
|
||||
aConfig->mServiceID = service->GetServiceID();
|
||||
aConfig->mEnterpriseNumber = service->GetEnterpriseNumber();
|
||||
aConfig->mServiceDataLength = service->GetServiceDataLength();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user