From 1b57284bb49ac53d12d14fbb0454b0199eabb1fe Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Sat, 30 Dec 2017 13:06:53 +1100 Subject: [PATCH] mdns: guard against there being no ip4 address. * Avoid announcing to an interface with no ip4addr. * Avoid emitting A answers if there is no ip4 address. --- src/apps/mdns/mdns.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 920424b6..e67e9927 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -1421,7 +1421,8 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt) } #endif #if LWIP_IPV4 - if (!(outpkt->host_replies & REPLY_HOST_A)) { + if (!(outpkt->host_replies & REPLY_HOST_A) && + !ip4_addr_isany_val(*netif_ip4_addr(outpkt->netif))) { res = mdns_add_a_answer(outpkt, outpkt->cache_flush, outpkt->netif); if (res != ERR_OK) { goto cleanup; @@ -1858,7 +1859,9 @@ mdns_resp_netif_settings_changed(struct netif *netif) mdns_announce(netif, IP6_ADDR_ANY); #endif #if LWIP_IPV4 - mdns_announce(netif, IP4_ADDR_ANY); + if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) { + mdns_announce(netif, IP4_ADDR_ANY); + } #endif } @@ -2044,7 +2047,9 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service mdns_announce(netif, IP6_ADDR_ANY); #endif #if LWIP_IPV4 - mdns_announce(netif, IP4_ADDR_ANY); + if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) { + mdns_announce(netif, IP4_ADDR_ANY); + } #endif return slot; }