From 1b3d054cc8be1bb601bb72342a8bd73999db694f Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 26 Jun 2023 17:48:54 -0700 Subject: [PATCH] [adv-proxy] use new `otSrpServer` API for service sub-types --- src/sdp_proxy/advertising_proxy.cpp | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/sdp_proxy/advertising_proxy.cpp b/src/sdp_proxy/advertising_proxy.cpp index d254ed0dbb6..817786c0ede 100644 --- a/src/sdp_proxy/advertising_proxy.cpp +++ b/src/sdp_proxy/advertising_proxy.cpp @@ -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; @@ -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; }