Skip to content

Commit

Permalink
Provide DnssdTizen functions for browse and resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jun 16, 2022
1 parent 437b15e commit 3785435
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/platform/Tizen/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/platform/Tizen/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3785435

Please sign in to comment.