Skip to content

Commit

Permalink
Remove the kDNSServiceInterfaceIndexLocalOnly special-case on Darwin.
Browse files Browse the repository at this point in the history
Interface kDNSServiceInterfaceIndexLocalOnly means the _registration_ is
local-only, not that the registered host is localhost and has a loopback
address.  There can be local-only registrations for other hosts, and we need to
do actual address resolution.
  • Loading branch information
bzbarsky-apple committed Apr 27, 2023
1 parent cc6c414 commit f2654f7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
12 changes: 0 additions & 12 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,18 +431,6 @@ CHIP_ERROR ResolveContext::OnNewAddress(uint32_t interfaceId, const struct socka
return CHIP_NO_ERROR;
}

CHIP_ERROR ResolveContext::OnNewLocalOnlyAddress()
{
sockaddr_in6 sockaddr;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sin6_len = sizeof(sockaddr);
sockaddr.sin6_family = AF_INET6;
sockaddr.sin6_addr = in6addr_loopback;
sockaddr.sin6_port = htons((unsigned short) interfaces[kDNSServiceInterfaceIndexLocalOnly].service.mPort);

return OnNewAddress(kDNSServiceInterfaceIndexLocalOnly, reinterpret_cast<struct sockaddr *>(&sockaddr));
}

bool ResolveContext::HasAddress()
{
for (auto & interface : interfaces)
Expand Down
6 changes: 0 additions & 6 deletions src/platform/Darwin/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,6 @@ static void OnResolve(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t inter
if (kDNSServiceErr_NoError == err)
{
sdCtx->OnNewInterface(interfaceId, fullname, hostname, port, txtLen, txtRecord);
if (kDNSServiceInterfaceIndexLocalOnly == interfaceId)
{
sdCtx->OnNewLocalOnlyAddress();
sdCtx->Finalize();
return;
}
}

if (!(flags & kDNSServiceFlagsMoreComing))
Expand Down
1 change: 0 additions & 1 deletion src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ struct ResolveContext : public GenericContext
void DispatchSuccess() override;

CHIP_ERROR OnNewAddress(uint32_t interfaceId, const struct sockaddr * address);
CHIP_ERROR OnNewLocalOnlyAddress();
bool HasAddress();

void OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostname, uint16_t port, uint16_t txtLen,
Expand Down

0 comments on commit f2654f7

Please sign in to comment.