From 8ac1b4825af1439601962d277c65e61bdc3929d4 Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Thu, 17 Mar 2016 14:38:14 -0500 Subject: [PATCH] udp: use netif addr as src for multicast sockets Sockets bound to a multicast address could not transmit multicast packets because the pcb local address did not match the netif address even if the outgoing netif was resolved correctly. To correct the issue, pcbs with a multicast local address will use the outgoing netif address as the source address in IPv4. --- src/core/udp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/udp.c b/src/core/udp.c index 7550c64b..2d345437 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -649,8 +649,10 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i else #endif /* LWIP_IPV4 && LWIP_IPV6 */ #if LWIP_IPV4 - if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) { - /* use outgoing network interface IP address as source address */ + if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) || + ip4_addr_ismulticast(ip_2_ip4(&pcb->local_ip))) { + /* if the local_ip is any or multicast + * use the outgoing network interface IP address as source address */ src_ip = netif_ip_addr4(netif); } else { /* check if UDP PCB local IP address is correct