From 26701627962664f0993ca8803e62248f3a286e08 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 9 Dec 2022 19:44:18 -0500 Subject: [PATCH] Remove the address type argument from ResolveNodeId. (#24006) All consumers were passing kAny in practice, and some of the backends (e.g. minimal mdns) had no capability to filter by type anyway. --- src/controller/python/chip/discovery/NodeResolution.cpp | 3 +-- src/controller/tests/TestCommissionableNodeController.cpp | 2 +- src/lib/address_resolve/AddressResolve_DefaultImpl.cpp | 2 +- src/lib/dnssd/Discovery_ImplPlatform.cpp | 8 ++++---- src/lib/dnssd/Discovery_ImplPlatform.h | 2 +- src/lib/dnssd/Resolver.h | 2 +- src/lib/dnssd/ResolverProxy.h | 2 +- src/lib/dnssd/Resolver_ImplMinimalMdns.cpp | 8 ++++---- src/lib/dnssd/Resolver_ImplNone.cpp | 4 ++-- src/lib/shell/commands/Dns.cpp | 2 +- 10 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/controller/python/chip/discovery/NodeResolution.cpp b/src/controller/python/chip/discovery/NodeResolution.cpp index 8f92477f1c1ef0..153cc1ef438643 100644 --- a/src/controller/python/chip/discovery/NodeResolution.cpp +++ b/src/controller/python/chip/discovery/NodeResolution.cpp @@ -96,8 +96,7 @@ extern "C" PyChipError pychip_discovery_resolve(uint64_t fabricId, uint64_t node ReturnOnFailure(result); Resolver::Instance().SetOperationalDelegate(&gPythonResolverDelegate); - result = Resolver::Instance().ResolveNodeId(chip::PeerId().SetCompressedFabricId(fabricId).SetNodeId(nodeId), - chip::Inet::IPAddressType::kAny); + result = Resolver::Instance().ResolveNodeId(chip::PeerId().SetCompressedFabricId(fabricId).SetNodeId(nodeId)); }); return ToPyChipError(result); diff --git a/src/controller/tests/TestCommissionableNodeController.cpp b/src/controller/tests/TestCommissionableNodeController.cpp index dc841b4482e4c0..29893620c971f0 100644 --- a/src/controller/tests/TestCommissionableNodeController.cpp +++ b/src/controller/tests/TestCommissionableNodeController.cpp @@ -36,7 +36,7 @@ class MockResolver : public Resolver void Shutdown() override {} void SetOperationalDelegate(OperationalResolveDelegate * delegate) override {} void SetCommissioningDelegate(CommissioningResolveDelegate * delegate) override {} - CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) override { return ResolveNodeIdStatus; } + CHIP_ERROR ResolveNodeId(const PeerId & peerId) override { return ResolveNodeIdStatus; } CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter = DiscoveryFilter()) override { return DiscoverCommissionersStatus; } CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter = DiscoveryFilter()) override { diff --git a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp index 6a7d856aa6e3b7..17b6f623f43c9f 100644 --- a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp +++ b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp @@ -117,7 +117,7 @@ CHIP_ERROR Resolver::LookupNode(const NodeLookupRequest & request, Impl::NodeLoo VerifyOrReturnError(mSystemLayer != nullptr, CHIP_ERROR_INCORRECT_STATE); handle.ResetForLookup(mTimeSource.GetMonotonicTimestamp(), request); - ReturnErrorOnFailure(Dnssd::Resolver::Instance().ResolveNodeId(request.GetPeerId(), Inet::IPAddressType::kAny)); + ReturnErrorOnFailure(Dnssd::Resolver::Instance().ResolveNodeId(request.GetPeerId())); mActiveLookups.PushBack(&handle); ReArmTimer(); return CHIP_NO_ERROR; diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index d664275c54b005..8a6f1976c557ca 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -619,10 +619,10 @@ CHIP_ERROR DiscoveryImplPlatform::FinalizeServiceUpdate() return ChipDnssdFinalizeServiceUpdate(); } -CHIP_ERROR DiscoveryImplPlatform::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) +CHIP_ERROR DiscoveryImplPlatform::ResolveNodeId(const PeerId & peerId) { ReturnErrorOnFailure(InitImpl()); - return mResolverProxy.ResolveNodeId(peerId, type); + return mResolverProxy.ResolveNodeId(peerId); } CHIP_ERROR DiscoveryImplPlatform::DiscoverCommissionableNodes(DiscoveryFilter filter) @@ -664,7 +664,7 @@ Resolver & chip::Dnssd::Resolver::Instance() return DiscoveryImplPlatform::GetInstance(); } -CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) +CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId) { VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -678,7 +678,7 @@ CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId, Inet::IPAddressTy ReturnErrorOnFailure(MakeInstanceName(service.mName, sizeof(service.mName), peerId)); Platform::CopyString(service.mType, kOperationalServiceName); service.mProtocol = DnssdServiceProtocol::kDnssdProtocolTcp; - service.mAddressType = type; + service.mAddressType = Inet::IPAddressType::kAny; return ChipDnssdResolve(&service, Inet::InterfaceId::Null(), HandleNodeIdResolve, mDelegate); } diff --git a/src/lib/dnssd/Discovery_ImplPlatform.h b/src/lib/dnssd/Discovery_ImplPlatform.h index 0723dbf0fedf0c..bf044ecb962602 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.h +++ b/src/lib/dnssd/Discovery_ImplPlatform.h @@ -54,7 +54,7 @@ class DiscoveryImplPlatform : public ServiceAdvertiser, public Resolver { mResolverProxy.SetCommissioningDelegate(delegate); } - CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) override; + CHIP_ERROR ResolveNodeId(const PeerId & peerId) override; CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR StopDiscovery() override; diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index efba2ba931a2ff..115e7e219231ab 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -372,7 +372,7 @@ class Resolver * the result of the operation is passed to the delegate's `OnNodeIdResolved` or * `OnNodeIdResolutionFailed` method, respectively. */ - virtual CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) = 0; + virtual CHIP_ERROR ResolveNodeId(const PeerId & peerId) = 0; /** * Finds all commissionable nodes matching the given filter. diff --git a/src/lib/dnssd/ResolverProxy.h b/src/lib/dnssd/ResolverProxy.h index b8bf3fbacb7082..5b16cd2def1513 100644 --- a/src/lib/dnssd/ResolverProxy.h +++ b/src/lib/dnssd/ResolverProxy.h @@ -149,7 +149,7 @@ class ResolverProxy : public Resolver mDelegate = nullptr; } - CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) override; + CHIP_ERROR ResolveNodeId(const PeerId & peerId) override; CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR StopDiscovery() override; diff --git a/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp b/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp index 7e9c44e4d8072f..5534ab1cb64b11 100644 --- a/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp @@ -278,7 +278,7 @@ class MinMdnsResolver : public Resolver, public MdnsPacketDelegate void Shutdown() override; void SetOperationalDelegate(OperationalResolveDelegate * delegate) override { mOperationalDelegate = delegate; } void SetCommissioningDelegate(CommissioningResolveDelegate * delegate) override { mCommissioningDelegate = delegate; } - CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) override; + CHIP_ERROR ResolveNodeId(const PeerId & peerId) override; CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter = DiscoveryFilter()) override; CHIP_ERROR StopDiscovery() override; @@ -652,7 +652,7 @@ CHIP_ERROR MinMdnsResolver::BrowseNodes(DiscoveryType type, DiscoveryFilter filt return SendAllPendingQueries(); } -CHIP_ERROR MinMdnsResolver::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) +CHIP_ERROR MinMdnsResolver::ResolveNodeId(const PeerId & peerId) { mActiveResolves.MarkPending(peerId); @@ -700,14 +700,14 @@ ResolverProxy::~ResolverProxy() // updating the delegate that ends up being used by the server by calling 'SetOperationalDelegate'. // This effectively allow minimal to have multiple controllers issuing requests as long the requests are serialized, but // it won't work well if requests are issued in parallel. -CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) +CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId) { VerifyOrReturnError(mDelegate != nullptr, CHIP_ERROR_INCORRECT_STATE); ChipLogProgress(Discovery, "Resolving " ChipLogFormatX64 ":" ChipLogFormatX64 " ...", ChipLogValueX64(peerId.GetCompressedFabricId()), ChipLogValueX64(peerId.GetNodeId())); chip::Dnssd::Resolver::Instance().SetOperationalDelegate(mDelegate); - return chip::Dnssd::Resolver::Instance().ResolveNodeId(peerId, type); + return chip::Dnssd::Resolver::Instance().ResolveNodeId(peerId); } CHIP_ERROR ResolverProxy::DiscoverCommissionableNodes(DiscoveryFilter filter) diff --git a/src/lib/dnssd/Resolver_ImplNone.cpp b/src/lib/dnssd/Resolver_ImplNone.cpp index c4d4cc0f6dce84..89fce74c065548 100644 --- a/src/lib/dnssd/Resolver_ImplNone.cpp +++ b/src/lib/dnssd/Resolver_ImplNone.cpp @@ -32,7 +32,7 @@ class NoneResolver : public Resolver void SetOperationalDelegate(OperationalResolveDelegate * delegate) override {} void SetCommissioningDelegate(CommissioningResolveDelegate * delegate) override {} - CHIP_ERROR ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) override + CHIP_ERROR ResolveNodeId(const PeerId & peerId) override { ChipLogError(Discovery, "Failed to resolve node ID: dnssd resolving not available"); return CHIP_ERROR_NOT_IMPLEMENTED; @@ -63,7 +63,7 @@ ResolverProxy::~ResolverProxy() Shutdown(); } -CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId, Inet::IPAddressType type) +CHIP_ERROR ResolverProxy::ResolveNodeId(const PeerId & peerId) { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/lib/shell/commands/Dns.cpp b/src/lib/shell/commands/Dns.cpp index c2010d9bffbcaf..305e142050295e 100644 --- a/src/lib/shell/commands/Dns.cpp +++ b/src/lib/shell/commands/Dns.cpp @@ -128,7 +128,7 @@ CHIP_ERROR ResolveHandler(int argc, char ** argv) peerId.SetCompressedFabricId(strtoull(argv[0], nullptr, 10)); peerId.SetNodeId(strtoull(argv[1], nullptr, 10)); - return sResolverProxy.ResolveNodeId(peerId, Inet::IPAddressType::kAny); + return sResolverProxy.ResolveNodeId(peerId); } bool ParseSubType(int argc, char ** argv, Dnssd::DiscoveryFilter & filter)