From 83bd8d570392cb569492f291434fcf1e7fdf279d Mon Sep 17 00:00:00 2001 From: Carol Yang Date: Fri, 10 Dec 2021 14:27:55 -0800 Subject: [PATCH] Make CASESessionManager the resolver delegate if ResolverProxy is not passed in (#12864) --- src/app/CASESessionManager.h | 12 +++++++++--- src/lib/dnssd/Resolver_ImplNone.cpp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/app/CASESessionManager.h b/src/app/CASESessionManager.h index 9d5bf11424a887..b33e2d921fbe98 100644 --- a/src/app/CASESessionManager.h +++ b/src/app/CASESessionManager.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -58,11 +59,15 @@ class CASESessionManager : public SessionReleaseDelegate, public Dnssd::Resolver mConfig = params; - // TODO: Revisit who should be set as the resolver delegate - Dnssd::Resolver::Instance().SetResolverDelegate(this); + if (mConfig.dnsResolver == nullptr) + { + VerifyOrDie(mDNSResolver.Init(DeviceLayer::UDPEndPointManager()) == CHIP_NO_ERROR); + mDNSResolver.SetResolverDelegate(this); + mConfig.dnsResolver = &mDNSResolver; + } } - virtual ~CASESessionManager() {} + virtual ~CASESessionManager() { mDNSResolver.Shutdown(); } /** * Find an existing session for the given node ID, or trigger a new session request. @@ -109,6 +114,7 @@ class CASESessionManager : public SessionReleaseDelegate, public Dnssd::Resolver void ReleaseSession(OperationalDeviceProxy * device); CASESessionManagerConfig mConfig; + Dnssd::ResolverProxy mDNSResolver; }; } // namespace chip diff --git a/src/lib/dnssd/Resolver_ImplNone.cpp b/src/lib/dnssd/Resolver_ImplNone.cpp index ed6049540475d6..0f8e88b0c0f329 100644 --- a/src/lib/dnssd/Resolver_ImplNone.cpp +++ b/src/lib/dnssd/Resolver_ImplNone.cpp @@ -17,6 +17,7 @@ #include "Resolver.h" +#include #include namespace chip { @@ -47,5 +48,21 @@ Resolver & chip::Dnssd::Resolver::Instance() { return gResolver; } + +CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type, Resolver::CacheBypass dnssdCacheBypass) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ResolverProxy::FindCommissionableNodes(DiscoveryFilter filter) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ResolverProxy::FindCommissioners(DiscoveryFilter filter) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + } // namespace Dnssd } // namespace chip