diff --git a/src/apps/mdns/mdns_out.c b/src/apps/mdns/mdns_out.c index 10a61929..776af804 100644 --- a/src/apps/mdns/mdns_out.c +++ b/src/apps/mdns/mdns_out.c @@ -52,9 +52,6 @@ #if LWIP_MDNS_RESPONDER -/* Payload size allocated for each outgoing UDP packet */ -#define OUTPACKET_SIZE 500 - /* Function prototypes */ static void mdns_clear_outmsg(struct mdns_outmsg *outmsg); @@ -93,7 +90,7 @@ mdns_add_question(struct mdns_outpacket *outpkt, struct mdns_domain *domain, if (!outpkt->pbuf) { /* If no pbuf is active, allocate one */ - outpkt->pbuf = pbuf_alloc(PBUF_TRANSPORT, OUTPACKET_SIZE, PBUF_RAM); + outpkt->pbuf = pbuf_alloc(PBUF_TRANSPORT, MDNS_OUTPUT_PACKET_SIZE, PBUF_RAM); if (!outpkt->pbuf) { return ERR_MEM; } @@ -166,7 +163,7 @@ mdns_add_answer(struct mdns_outpacket *reply, struct mdns_domain *domain, if (!reply->pbuf) { /* If no pbuf is active, allocate one */ - reply->pbuf = pbuf_alloc(PBUF_TRANSPORT, OUTPACKET_SIZE, PBUF_RAM); + reply->pbuf = pbuf_alloc(PBUF_TRANSPORT, MDNS_OUTPUT_PACKET_SIZE, PBUF_RAM); if (!reply->pbuf) { return ERR_MEM; } diff --git a/src/include/lwip/apps/mdns_opts.h b/src/include/lwip/apps/mdns_opts.h index 684d631e..50a8e57f 100644 --- a/src/include/lwip/apps/mdns_opts.h +++ b/src/include/lwip/apps/mdns_opts.h @@ -60,6 +60,16 @@ #define MDNS_MAX_SERVICES 1 #endif +/** Payload size allocated for each outgoing UDP packet. Will be allocated with + * PBUF_RAM and freed after packet was sent. + * According to RFC 6762, there is no reason to retain the 512 bytes restriction + * for link-local multicast packet. + * 512 bytes isn't enough when 2 services need to be probed. + */ +#ifndef MDNS_OUTPUT_PACKET_SIZE +#define MDNS_OUTPUT_PACKET_SIZE ((MDNS_MAX_SERVICES == 1) ? 512 : 1450) +#endif + /** MDNS_RESP_USENETIF_EXTCALLBACK==1: register an ext_callback on the netif * to automatically restart probing/announcing on status or address change. */