diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index c907730e..aad27288 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -102,7 +102,9 @@ static const ip_addr_t v6group = DNS_MQUERY_IPV6_GROUP_INIT; static u8_t mdns_netif_client_id; static struct udp_pcb *mdns_pcb; +#if MDNS_RESP_USENETIF_EXTCALLBACK NETIF_DECLARE_EXT_CALLBACK(netif_callback) +#endif static mdns_name_result_cb_t mdns_name_result_cb; #define NETIF_TO_HOST(netif) (struct mdns_host*)(netif_get_client_data(netif, mdns_netif_client_id)) @@ -1912,7 +1914,7 @@ dealloc: pbuf_free(p); } -#if LWIP_NETIF_EXT_STATUS_CALLBACK +#if LWIP_NETIF_EXT_STATUS_CALLBACK && MDNS_RESP_USENETIF_EXTCALLBACK static void mdns_netif_ext_status_callback(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args) { @@ -1940,7 +1942,7 @@ mdns_netif_ext_status_callback(struct netif *netif, netif_nsc_reason_t reason, c mdns_resp_announce(netif); } } -#endif +#endif /* LWIP_NETIF_EXT_STATUS_CALLBACK && MDNS_RESP_USENETIF_EXTCALLBACK */ static err_t mdns_send_probe(struct netif* netif, const ip_addr_t *destination) @@ -2396,8 +2398,10 @@ mdns_resp_init(void) mdns_netif_client_id = netif_alloc_client_data_id(); +#if MDNS_RESP_USENETIF_EXTCALLBACK /* register for netif events when started on first netif */ netif_add_ext_callback(&netif_callback, mdns_netif_ext_status_callback); +#endif } #endif /* LWIP_MDNS_RESPONDER */ diff --git a/src/include/lwip/apps/mdns_opts.h b/src/include/lwip/apps/mdns_opts.h index bf186bcc..45f2c50c 100644 --- a/src/include/lwip/apps/mdns_opts.h +++ b/src/include/lwip/apps/mdns_opts.h @@ -59,6 +59,13 @@ #define MDNS_MAX_SERVICES 1 #endif +/** MDNS_RESP_USENETIF_EXTCALLBACK==1: register an ext_callback on the netif + * to automatically restart probing/announcing on status or address change. + */ +#ifndef MDNS_RESP_USENETIF_EXTCALLBACK +#define MDNS_RESP_USENETIF_EXTCALLBACK LWIP_NETIF_EXT_STATUS_CALLBACK +#endif + /** * MDNS_DEBUG: Enable debugging for multicast DNS. */