Index: udp.c =================================================================== RCS file: /sources/lwip/lwip/src/core/udp.c,v retrieving revision 1.108 diff -u -3 -p -r1.108 udp.c --- udp.c 15 Apr 2009 19:32:01 -0000 1.108 +++ udp.c 24 Apr 2009 08:26:13 -0000 @@ -90,6 +90,7 @@ udp_input(struct pbuf *p, struct netif * struct ip_hdr *iphdr; u16_t src, dest; u8_t local_match; + u8_t broadcast; PERF_START; @@ -112,6 +113,9 @@ udp_input(struct pbuf *p, struct netif * udphdr = (struct udp_hdr *)p->payload; + /* is broadcast packet ? */ + broadcast = ip_addr_isbroadcast(&(iphdr->dest), inp); + LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); /* convert src and dest ports to host byte order */ @@ -166,15 +170,14 @@ udp_input(struct pbuf *p, struct netif * ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port)); - /* compare PCB local addr+port to UDP destination addr+port */ if ((pcb->local_port == dest) && - (ip_addr_isany(&pcb->local_ip) || + ((!broadcast && ip_addr_isany(&pcb->local_ip)) || ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)) || #if LWIP_IGMP ip_addr_ismulticast(&(iphdr->dest)) || #endif /* LWIP_IGMP */ - ip_addr_isbroadcast(&(iphdr->dest), inp))) { + (broadcast && (pcb->so_options & SOF_BROADCAST)))) { local_match = 1; if ((uncon_pcb == NULL) && ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { @@ -286,7 +289,7 @@ udp_input(struct pbuf *p, struct netif * #if LWIP_ICMP /* No match was found, send ICMP destination port unreachable unless destination address was broadcast/multicast. */ - if (!ip_addr_isbroadcast(&iphdr->dest, inp) && + if (!broadcast && !ip_addr_ismulticast(&iphdr->dest)) { /* move payload pointer back to ip header */ pbuf_header(p, (IPH_HL(iphdr) * 4) + UDP_HLEN);