diff --git a/src/core/udp.c b/src/core/udp.c index 948848a3..fcc8e32d 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -66,7 +66,6 @@ struct udp_pcb *udp_pcbs = NULL; static struct udp_pcb *pcb_cache = NULL; - void udp_init(void) { @@ -410,6 +409,14 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) return err; } } + /* find the outgoing network interface for this packet */ + netif = ip_route(&(pcb->remote_ip)); + /* no outgoing network interface could be found? */ + if (netif == NULL) { + LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); + UDP_STATS_INC(udp.rterr); + return ERR_RTE; + } /* not enough space to add an UDP header to first pbuf in given p chain? */ if (pbuf_header(p, UDP_HLEN)) { @@ -437,14 +444,6 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p) /* in UDP, 0 checksum means 'no checksum' */ udphdr->chksum = 0x0000; - /* find the outgoing network interface for this packet */ - netif = ip_route(&(pcb->remote_ip)); - /* no outgoing network interface could be found? */ - if (netif == NULL) { - LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); - UDP_STATS_INC(udp.rterr); - return ERR_RTE; - } /* PCB local address is IP_ANY_ADDR? */ if (ip_addr_isany(&pcb->local_ip)) { /* use outgoing network interface IP address as source address */