Skip to content

Commit 3ed535f

Browse files
committed
Add domain names matching the DnssdServices stored in Browse Context
This is needed to pass the domain returned from a call to Browse to the Resolve.
1 parent 5bb5c9e commit 3ed535f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/platform/Darwin/DnssdContexts.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ void BrowseContext::DispatchPartialSuccess()
371371
callback(context, services.data(), services.size(), false, CHIP_NO_ERROR);
372372
sContextDispatchingSuccess = nullptr;
373373
services.clear();
374+
domainNames.clear();
374375
}
375376

376377
void BrowseContext::OnBrowse(DNSServiceFlags flags, const char * name, const char * type, const char * domain, uint32_t interfaceId)
@@ -391,6 +392,7 @@ void BrowseContext::OnBrowseAdd(const char * name, const char * type, const char
391392
VerifyOrReturn(IsLocalDomain(domain));
392393
auto service = GetService(name, type, protocol, interfaceId);
393394
services.push_back(service);
395+
domainNames.push_back(std::make_pair(service, std::string(domain)));
394396
}
395397

396398
void BrowseContext::OnBrowseRemove(const char * name, const char * type, const char * domain, uint32_t interfaceId)
@@ -401,6 +403,13 @@ void BrowseContext::OnBrowseRemove(const char * name, const char * type, const c
401403
VerifyOrReturn(name != nullptr);
402404
VerifyOrReturn(IsLocalDomain(domain));
403405

406+
domainNames.erase(std::remove_if(domainNames.begin(), domainNames.end(),
407+
[name, type, interfaceId](const auto & domainName) {
408+
return strcmp(domainName.first.mName, name) == 0 && domainName.first.mType == type &&
409+
domainName.first.mInterface == chip::Inet::InterfaceId(interfaceId);
410+
}),
411+
domainNames.end());
412+
404413
services.erase(std::remove_if(services.begin(), services.end(),
405414
[name, type, interfaceId](const DnssdService & service) {
406415
return strcmp(name, service.mName) == 0 && type == GetFullType(&service) &&

src/platform/Darwin/DnssdImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct BrowseContext : public BrowseHandler
168168
{
169169
DnssdBrowseCallback callback;
170170
std::vector<DnssdService> services;
171+
std::vector<std::pair<DnssdService, std::string>> domainNames;
171172

172173
BrowseContext(void * cbContext, DnssdBrowseCallback cb, DnssdServiceProtocol cbContextProtocol);
173174

0 commit comments

Comments
 (0)