From 6c236b047e1b2508e8c12ae03dae5ca0f047bfb9 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 3 May 2017 16:42:30 +0200 Subject: [PATCH] ip_route() can be called with IP_ANY_TYPE in src parameter, so remove code associated to that --- src/core/raw.c | 7 +------ src/core/udp.c | 13 ++----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/core/raw.c b/src/core/raw.c index c630537f..17c664d8 100644 --- a/src/core/raw.c +++ b/src/core/raw.c @@ -369,12 +369,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr) if (netif == NULL) #endif /* LWIP_MULTICAST_TX_OPTIONS */ { - if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) { - /* Don't call ip_route() with IP_ANY_TYPE */ - netif = ip_route(IP46_ADDR_ANY(IP_GET_TYPE(ipaddr)), ipaddr); - } else { - netif = ip_route(&pcb->local_ip, ipaddr); - } + netif = ip_route(&pcb->local_ip, ipaddr); } } diff --git a/src/core/udp.c b/src/core/udp.c index 047e661b..9c067d6b 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -504,7 +504,6 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, { #endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ struct netif *netif; - const ip_addr_t *src_ip_route; if ((pcb == NULL) || (dst_ip == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { return ERR_VAL; @@ -515,14 +514,6 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, if (pcb->netif_idx != NETIF_NO_INDEX) { netif = netif_get_by_index(pcb->netif_idx); } else { - if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) { - /* Don't call ip_route() with IP_ANY_TYPE */ - src_ip_route = IP46_ADDR_ANY(IP_GET_TYPE(dst_ip)); - } else { - src_ip_route = &pcb->local_ip; - } - LWIP_UNUSED_ARG(src_ip_route); /* IPv4 only and no source based routing */ - #if LWIP_MULTICAST_TX_OPTIONS netif = NULL; if (ip_addr_ismulticast(dst_ip)) { @@ -548,7 +539,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, fails, we try regular routing as though no override was set. */ if (!ip4_addr_isany_val(pcb->mcast_ip4) && !ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) { - netif = ip4_route_src(ip_2_ip4(src_ip_route), &pcb->mcast_ip4); + netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4); } } #endif /* LWIP_IPV4 */ @@ -558,7 +549,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, #endif /* LWIP_MULTICAST_TX_OPTIONS */ { /* find the outgoing network interface for this packet */ - netif = ip_route(src_ip_route, dst_ip); + netif = ip_route(&pcb->local_ip, dst_ip); } }