File tree 4 files changed +56
-5
lines changed
4 files changed +56
-5
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include < lib/support/logging/CHIPLogging.h>
21
21
22
- #include < algorithm>
23
-
24
22
using namespace chip ;
25
23
26
24
namespace mdns {
@@ -284,6 +282,32 @@ Optional<ActiveResolveAttempts::ScheduledAttempt> ActiveResolveAttempts::NextSch
284
282
return Optional<ScheduledAttempt>::Missing ();
285
283
}
286
284
285
+ bool ActiveResolveAttempts::ShouldResolveIpAddress (PeerId peerId) const
286
+ {
287
+ for (auto & item : mRetryQueue )
288
+ {
289
+ if (item.attempt .IsEmpty ())
290
+ {
291
+ continue ;
292
+ }
293
+ if (item.attempt .IsBrowse ())
294
+ {
295
+ return true ;
296
+ }
297
+
298
+ if (item.attempt .IsResolve ())
299
+ {
300
+ auto & data = item.attempt .ResolveData ();
301
+ if (data.peerId == peerId)
302
+ {
303
+ return true ;
304
+ }
305
+ }
306
+ }
307
+
308
+ return false ;
309
+ }
310
+
287
311
bool ActiveResolveAttempts::IsWaitingForIpResolutionFor (SerializedQNameIterator hostName) const
288
312
{
289
313
for (auto & entry : mRetryQueue )
Original file line number Diff line number Diff line change @@ -288,6 +288,12 @@ class ActiveResolveAttempts
288
288
// / IP resolution.
289
289
bool IsWaitingForIpResolutionFor (SerializedQNameIterator hostName) const ;
290
290
291
+ // / Determines if address resolution for the given peer ID is required
292
+ // /
293
+ // / IP Addresses are required for active operational discovery of specific peers
294
+ // / or if an active browse is being performed.
295
+ bool ShouldResolveIpAddress (chip::PeerId peerId) const ;
296
+
291
297
// / Check if a browse operation is active for the given discovery type
292
298
bool HasBrowseFor (chip::Dnssd::DiscoveryType type) const ;
293
299
Original file line number Diff line number Diff line change 17
17
#pragma once
18
18
19
19
#include < lib/dnssd/Resolver.h>
20
+ #include < lib/dnssd/Types.h>
20
21
#include < lib/dnssd/minimal_mdns/Parser.h>
21
22
#include < lib/dnssd/minimal_mdns/RecordData.h>
22
23
#include < lib/dnssd/minimal_mdns/core/QName.h>
@@ -104,6 +105,12 @@ class IncrementalResolver
104
105
105
106
ServiceNameType GetCurrentType () const { return mServiceNameType ; }
106
107
108
+ PeerId OperationalParsePeerId () const
109
+ {
110
+ VerifyOrReturnValue (IsActiveOperationalParse (), PeerId ());
111
+ return mSpecificResolutionData .Get <OperationalNodeData>().peerId ;
112
+ }
113
+
107
114
// / Start parsing a new record. SRV records are the records we are mainly
108
115
// / interested on, after which TXT and A/AAAA are looked for.
109
116
// /
Original file line number Diff line number Diff line change 17
17
18
18
#include " Resolver.h"
19
19
20
- #include < limits>
21
-
22
20
#include < lib/core/CHIPConfig.h>
23
21
#include < lib/dnssd/ActiveResolveAttempts.h>
24
22
#include < lib/dnssd/IncrementalResolve.h>
@@ -372,7 +370,23 @@ void MinMdnsResolver::AdvancePendingResolverStates()
372
370
373
371
if (missing.Has (IncrementalResolver::RequiredInformationBitFlags::kIpAddress ))
374
372
{
375
- ScheduleIpAddressResolve (resolver->GetTargetHostName ());
373
+ if (resolver->IsActiveBrowseParse ())
374
+ {
375
+ // Browse wants IP addresses
376
+ ScheduleIpAddressResolve (resolver->GetTargetHostName ());
377
+ }
378
+ else if (mActiveResolves .ShouldResolveIpAddress (resolver->OperationalParsePeerId ()))
379
+ {
380
+ // Keep searching for IP addresses if an active resolve needs these IP addresses
381
+ // otherwise ignore the data (received a SRV record without IP address, however we do not
382
+ // seem interested in it. Probably just a device that came online).
383
+ ScheduleIpAddressResolve (resolver->GetTargetHostName ());
384
+ }
385
+ else
386
+ {
387
+ // This IP address is not interesting enough to run another discovery
388
+ resolver->ResetToInactive ();
389
+ }
376
390
continue ;
377
391
}
378
392
You can’t perform that action at this time.
0 commit comments