Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[adv-proxy] use new otSrpServer API for service sub-types #1923

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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