From 37854354682be59d71a5c2aecb684e9d0e6fea72 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Thu, 9 Jun 2022 10:26:30 +0200 Subject: [PATCH] Provide DnssdTizen functions for browse and resolve --- src/platform/Tizen/DnssdImpl.cpp | 30 ++++++++++++++++++++---------- src/platform/Tizen/DnssdImpl.h | 6 ++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/platform/Tizen/DnssdImpl.cpp b/src/platform/Tizen/DnssdImpl.cpp index d0233f64a8a983..9800a7080ef98a 100644 --- a/src/platform/Tizen/DnssdImpl.cpp +++ b/src/platform/Tizen/DnssdImpl.cpp @@ -626,6 +626,20 @@ CHIP_ERROR DnssdTizen::UnregisterAllServices() return CHIP_NO_ERROR; } +CHIP_ERROR DnssdTizen::Browse(const char * type, DnssdServiceProtocol protocol, chip::Inet::IPAddressType addressType, + chip::Inet::InterfaceId interface, DnssdBrowseCallback callback, void * context) +{ + std::string regtype = GetFullType(type, protocol); + return ::Browse(interface.GetPlatformInterface(), regtype.c_str(), protocol, callback, context); +} + +CHIP_ERROR DnssdTizen::Resolve(const DnssdService & browseResult, chip::Inet::InterfaceId interface, DnssdResolveCallback callback, + void * context) +{ + std::string regtype = GetFullType(browseResult.mType, browseResult.mProtocol); + return ::Resolve(interface.GetPlatformInterface(), regtype.c_str(), browseResult.mName, callback, context); +} + void DnssdTizen::Delete(GenericContext * context) { switch (context->contextType) @@ -746,27 +760,23 @@ CHIP_ERROR ChipDnssdFinalizeServiceUpdate() } CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, chip::Inet::IPAddressType addressType, - chip::Inet::InterfaceId interfaceId, DnssdBrowseCallback callback, void * context) + chip::Inet::InterfaceId interface, DnssdBrowseCallback callback, void * context) { VerifyOrReturnError(type != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(IsSupportedProtocol(protocol), CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(callback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - std::string regtype = GetFullType(type, protocol); - - return Browse(interfaceId.GetPlatformInterface(), regtype.c_str(), protocol, callback, context); + return DnssdTizen::GetInstance().Browse(type, protocol, addressType, interface, callback, context); } -CHIP_ERROR ChipDnssdResolve(DnssdService * service, chip::Inet::InterfaceId interfaceId, DnssdResolveCallback callback, +CHIP_ERROR ChipDnssdResolve(DnssdService * browseResult, chip::Inet::InterfaceId interface, DnssdResolveCallback callback, void * context) { - VerifyOrReturnError(service != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(IsSupportedProtocol(service->mProtocol), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(browseResult != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSupportedProtocol(browseResult->mProtocol), CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(callback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - std::string regtype = GetFullType(service->mType, service->mProtocol); - - return Resolve(interfaceId.GetPlatformInterface(), regtype.c_str(), service->mName, callback, context); + return DnssdTizen::GetInstance().Resolve(*browseResult, interface, callback, context); } } // namespace Dnssd diff --git a/src/platform/Tizen/DnssdImpl.h b/src/platform/Tizen/DnssdImpl.h index 1dcd8478f9ba7b..1501e8ffd5b09c 100755 --- a/src/platform/Tizen/DnssdImpl.h +++ b/src/platform/Tizen/DnssdImpl.h @@ -126,6 +126,12 @@ class DnssdTizen CHIP_ERROR UnregisterService(dnssd_service_h serviceHandle); CHIP_ERROR UnregisterAllServices(); + CHIP_ERROR Browse(const char * type, DnssdServiceProtocol protocol, chip::Inet::IPAddressType addressType, + chip::Inet::InterfaceId interface, DnssdBrowseCallback callback, void * context); + + CHIP_ERROR Resolve(const DnssdService & browseResult, chip::Inet::InterfaceId interface, DnssdResolveCallback callback, + void * context); + CHIP_ERROR Add(BrowseContext * context, dnssd_browser_h browser); CHIP_ERROR Add(ResolveContext * context, dnssd_service_h service); CHIP_ERROR Remove(GenericContext * context);