diff --git a/examples/minimal-mdns/AllInterfaceListener.h b/examples/minimal-mdns/AllInterfaceListener.h index 4744583a7f0762..39f137d91b07e4 100644 --- a/examples/minimal-mdns/AllInterfaceListener.h +++ b/examples/minimal-mdns/AllInterfaceListener.h @@ -88,6 +88,16 @@ class AllInterfaces : public mdns::Minimal::ListenIterator } } + template + inline bool MulticastOk(T & iterator) + { + return iterator.SupportsMulticast() +#if INET_CONFIG_ENABLE_IPV4 + || iterator.HasBroadcastAddress() +#endif + ; + } + bool SkipCurrentInterface() { if (!mIterator.HasCurrent()) @@ -95,7 +105,7 @@ class AllInterfaces : public mdns::Minimal::ListenIterator return false; // nothing to try. } - if (!mIterator.IsUp() || !mIterator.SupportsMulticast()) + if (!mIterator.IsUp() || !MulticastOk(mIterator)) { return true; // not a usable interface } diff --git a/src/lib/dnssd/AllInterfacesListenIterator.h b/src/lib/dnssd/AllInterfacesListenIterator.h index 7366a3ca037605..d6c482b404eded 100644 --- a/src/lib/dnssd/AllInterfacesListenIterator.h +++ b/src/lib/dnssd/AllInterfacesListenIterator.h @@ -24,12 +24,22 @@ namespace chip { namespace Dnssd { +template +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 bool IsCurrentInterfaceUsable(T & iterator) { - if (!iterator.IsUp() || !iterator.SupportsMulticast()) + if (!iterator.IsUp() || !MulticastOk(iterator)) { return false; // not a usable interface } diff --git a/src/lib/dnssd/MinimalMdnsServer.h b/src/lib/dnssd/MinimalMdnsServer.h index 9b1507002f748a..1e3f1160437391 100644 --- a/src/lib/dnssd/MinimalMdnsServer.h +++ b/src/lib/dnssd/MinimalMdnsServer.h @@ -23,12 +23,23 @@ namespace chip { namespace Dnssd { namespace Internal { + +template +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 bool IsCurrentInterfaceUsable(T & iterator) { - if (!iterator.IsUp() || !iterator.SupportsMulticast()) + if (!iterator.IsUp() || !MulticastOk(iterator)) { return false; // not a usable interface }