Skip to content

Commit

Permalink
Add domain names matching the DnssdServices stored in Browse Context (#…
Browse files Browse the repository at this point in the history
…32740)

* 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.

* Restyled by clang-format

* Add the domain names to the services vector

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Apr 16, 2024
1 parent afe3b63 commit 1627714
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ void BrowseContext::DispatchSuccess()
void BrowseContext::DispatchPartialSuccess()
{
sContextDispatchingSuccess = this;
callback(context, services.data(), services.size(), false, CHIP_NO_ERROR);
std::vector<DnssdService> dnsServices;
for (auto iter : services)
{
dnsServices.push_back(std::move(iter.first));
}
callback(context, dnsServices.data(), dnsServices.size(), false, CHIP_NO_ERROR);
sContextDispatchingSuccess = nullptr;
services.clear();
}
Expand All @@ -390,7 +395,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);
services.push_back(std::make_pair(std::move(service), std::string(domain)));
}

void BrowseContext::OnBrowseRemove(const char * name, const char * type, const char * domain, uint32_t interfaceId)
Expand All @@ -402,9 +407,10 @@ void BrowseContext::OnBrowseRemove(const char * name, const char * type, const c
VerifyOrReturn(IsLocalDomain(domain));

services.erase(std::remove_if(services.begin(), services.end(),
[name, type, interfaceId](const DnssdService & service) {
return strcmp(name, service.mName) == 0 && type == GetFullType(&service) &&
service.mInterface == chip::Inet::InterfaceId(interfaceId);
[name, type, interfaceId, domain](const auto & service) {
return strcmp(name, service.first.mName) == 0 && type == GetFullType(&service.first) &&
service.first.mInterface == chip::Inet::InterfaceId(interfaceId) &&
strcmp(domain, service.second.c_str()) == 0;
}),
services.end());
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct BrowseHandler : public GenericContext
struct BrowseContext : public BrowseHandler
{
DnssdBrowseCallback callback;
std::vector<DnssdService> services;
std::vector<std::pair<DnssdService, std::string>> services;

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

Expand Down

0 comments on commit 1627714

Please sign in to comment.