Skip to content

Commit

Permalink
[adv-proxy] use new otSrpServer API for service sub-types (#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Jul 11, 2023
1 parent bb565ca commit 1c43b4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
30 changes: 10 additions & 20 deletions src/sdp_proxy/advertising_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,16 @@ otbrError AdvertisingProxy::PublishHostAndItsServices(const otSrpServerHost *aHo
aUpdate->mCallbackCount++;
aUpdate->mHostName = hostName;
service = nullptr;
while ((service = otSrpServerHostFindNextService(aHost, service, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY,
/* aServiceName */ nullptr, /* aInstanceName */ nullptr)))
while ((service = otSrpServerHostGetNextService(aHost, service)) != nullptr)
{
aUpdate->mCallbackCount++;
}
}

service = nullptr;
while ((service = otSrpServerHostFindNextService(aHost, service, OT_SRP_SERVER_FLAGS_BASE_TYPE_SERVICE_ONLY,
/* aServiceName */ nullptr, /* aInstanceName */ nullptr)))
while ((service = otSrpServerHostGetNextService(aHost, service)) != nullptr)
{
std::string fullServiceName = otSrpServerServiceGetFullName(service);
std::string fullServiceName = otSrpServerServiceGetInstanceName(service);
std::string serviceName;
std::string serviceType;
std::string serviceDomain;
Expand Down Expand Up @@ -362,27 +360,19 @@ Mdns::Publisher::TxtList AdvertisingProxy::MakeTxtList(const otSrpServerService

Mdns::Publisher::SubTypeList AdvertisingProxy::MakeSubTypeList(const otSrpServerService *aSrpService)
{
const otSrpServerHost *host = otSrpServerServiceGetHost(aSrpService);
const char *instanceName = otSrpServerServiceGetInstanceName(aSrpService);
const otSrpServerService *subService = nullptr;
Mdns::Publisher::SubTypeList subTypeList;

while ((subService = otSrpServerHostFindNextService(
host, subService, (OT_SRP_SERVER_SERVICE_FLAG_SUB_TYPE | OT_SRP_SERVER_SERVICE_FLAG_ACTIVE),
/* aServiceName */ nullptr, instanceName)) != nullptr)
for (uint16_t index = 0;; index++)
{
char subLabel[OT_DNS_MAX_LABEL_SIZE];
const char *subTypeName = otSrpServerServiceGetSubTypeServiceNameAt(aSrpService, index);
char subLabel[OT_DNS_MAX_LABEL_SIZE];

if (otSrpServerServiceGetServiceSubTypeLabel(subService, subLabel, sizeof(subLabel)) == OT_ERROR_NONE)
{
subTypeList.emplace_back(subLabel);
}
else
{
otbrLogWarning("Failed to retrieve subtype of SRP service: %s", otSrpServerServiceGetFullName(aSrpService));
}
VerifyOrExit(subTypeName != nullptr);
SuccessOrExit(otSrpServerParseSubTypeServiceName(subTypeName, subLabel, sizeof(subLabel)));
subTypeList.emplace_back(subLabel);
}

exit:
return subTypeList;
}

Expand Down

0 comments on commit 1c43b4b

Please sign in to comment.