Skip to content

Commit

Permalink
Remove the address type argument from ResolveNodeId. (#24006)
Browse files Browse the repository at this point in the history
All consumers were passing kAny in practice, and some of the backends
(e.g. minimal mdns) had no capability to filter by type anyway.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 27, 2023
1 parent df63f94 commit 3d85217
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/controller/python/chip/discovery/NodeResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/TestCommissionableNodeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dnssd/Discovery_ImplPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/Discovery_ImplPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/Resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/ResolverProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dnssd/Resolver_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dnssd/Resolver_ImplNone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/shell/commands/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d85217

Please sign in to comment.