Skip to content

Commit

Permalink
Enable DNSSD on ipv4 if broadcast is available
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Mar 18, 2022
1 parent 1bdfa49 commit c4d3f6c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
12 changes: 11 additions & 1 deletion examples/minimal-mdns/AllInterfaceListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,24 @@ class AllInterfaces : public mdns::Minimal::ListenIterator
}
}

template <typename T>
inline bool MulticastOk(T & iterator)
{
return iterator.SupportsMulticast()
#if INET_CONFIG_ENABLE_IPV4
|| iterator.HasBroadcastAddress()
#endif
;
}

bool SkipCurrentInterface()
{
if (!mIterator.HasCurrent())
{
return false; // nothing to try.
}

if (!mIterator.IsUp() || !mIterator.SupportsMulticast())
if (!mIterator.IsUp() || !MulticastOk(mIterator))
{
return true; // not a usable interface
}
Expand Down
12 changes: 11 additions & 1 deletion src/lib/dnssd/AllInterfacesListenIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@
namespace chip {
namespace Dnssd {

template <typename T>
inline bool MulticastOk(T & iterator)
{
return iterator.SupportsMulticast()
#if INET_CONFIG_ENABLE_IPV4
|| iterator.HasBroadcastAddress()
#endif
;
}

/// Checks if the current interface is powered on
/// and not local loopback.
template <typename T>
bool IsCurrentInterfaceUsable(T & iterator)
{
if (!iterator.IsUp() || !iterator.SupportsMulticast())
if (!iterator.IsUp() || !MulticastOk(iterator))
{
return false; // not a usable interface
}
Expand Down
13 changes: 12 additions & 1 deletion src/lib/dnssd/MinimalMdnsServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ namespace chip {
namespace Dnssd {

namespace Internal {

template <typename T>
inline bool MulticastOk(T & iterator)
{
return iterator.SupportsMulticast()
#if INET_CONFIG_ENABLE_IPV4
|| iterator.HasBroadcastAddress()
#endif
;
}

/// Checks if the current interface is powered on
/// and not local loopback.
template <typename T>
bool IsCurrentInterfaceUsable(T & iterator)
{
if (!iterator.IsUp() || !iterator.SupportsMulticast())
if (!iterator.IsUp() || !MulticastOk(iterator))
{
return false; // not a usable interface
}
Expand Down

0 comments on commit c4d3f6c

Please sign in to comment.