Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain names matching the DnssdServices stored in Browse Context #32740

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ void BrowseContext::DispatchPartialSuccess()
callback(context, services.data(), services.size(), false, CHIP_NO_ERROR);
sContextDispatchingSuccess = nullptr;
services.clear();
domainNames.clear();
}

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

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

domainNames.erase(std::remove_if(domainNames.begin(), domainNames.end(),
[name, type, interfaceId](const auto & domainName) {
return strcmp(domainName.first.mName, name) == 0 && domainName.first.mType == type &&
domainName.first.mInterface == chip::Inet::InterfaceId(interfaceId);
}),
domainNames.end());

services.erase(std::remove_if(services.begin(), services.end(),
[name, type, interfaceId](const DnssdService & service) {
return strcmp(name, service.mName) == 0 && type == GetFullType(&service) &&
Expand Down
1 change: 1 addition & 0 deletions src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct BrowseContext : public BrowseHandler
{
DnssdBrowseCallback callback;
std::vector<DnssdService> services;
std::vector<std::pair<DnssdService, std::string>> domainNames;

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

Expand Down
Loading