[network-data] added support for iterating over services from leader data (#2368)

This commit is contained in:
Kamil Burzynski
2017-11-27 22:20:55 +00:00
committed by Jonathan Hui
parent 9b4a9aced4
commit c9c203bbed
4 changed files with 35 additions and 0 deletions
+15
View File
@@ -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.
*
+5
View File
@@ -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.
*/
+14
View File
@@ -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);
+1
View File
@@ -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();