From 553c4203abf911cb72a40e72d88e31419c051cba Mon Sep 17 00:00:00 2001 From: sg Date: Fri, 6 Mar 2015 20:25:51 +0100 Subject: [PATCH] tcp/udp_netif_ipv4_addr_changed(): don't change specific-address of local tcp_listen/udp_pcb to ANY on address change --- src/core/tcp.c | 14 +++++++------- src/core/udp.c | 16 +++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index a323a270..36afd457 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -1843,15 +1843,15 @@ void tcp_netif_ipv4_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new tcp_netif_ipv4_addr_changed_pcblist(old_addr, tcp_active_pcbs); tcp_netif_ipv4_addr_changed_pcblist(old_addr, tcp_bound_pcbs); - /* PCB bound to current local interface address? */ - for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) { - next = lpcb->next; + if (!ip_addr_isany(new_addr)) { /* PCB bound to current local interface address? */ - if ((!(ip_addr_isany(ipX_2_ip(&lpcb->local_ip)))) && - (ip_addr_cmp(ipX_2_ip(&lpcb->local_ip), old_addr))) { - if (new_addr != NULL) { + for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) { + next = lpcb->next; + /* PCB bound to current local interface address? */ + if ((!(ip_addr_isany(ipX_2_ip(&lpcb->local_ip)))) && + (ip_addr_cmp(ipX_2_ip(&lpcb->local_ip), old_addr))) { /* The PCB is listening to the old ipaddr and - * is set to listen to the new one instead */ + * is set to listen to the new one instead */ ip_addr_set(ipX_2_ip(&lpcb->local_ip), new_addr); } } diff --git a/src/core/udp.c b/src/core/udp.c index 01ff470d..e0ffd619 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -1160,13 +1160,15 @@ void udp_netif_ipv4_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new { struct udp_pcb* upcb; - for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) { - /* PCB bound to current local interface address? */ - if ((!(ip_addr_isany(ipX_2_ip(&upcb->local_ip)))) && - (ip_addr_cmp(ipX_2_ip(&upcb->local_ip), old_addr))) { - /* The PCB is bound to the old ipaddr and - * is set to bound to the new one instead */ - ip_addr_set(ipX_2_ip(&upcb->local_ip), new_addr); + if (!ip_addr_isany(new_addr)) { + for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) { + /* PCB bound to current local interface address? */ + if ((!(ip_addr_isany(ipX_2_ip(&upcb->local_ip)))) && + (ip_addr_cmp(ipX_2_ip(&upcb->local_ip), old_addr))) { + /* The PCB is bound to the old ipaddr and + * is set to bound to the new one instead */ + ip_addr_set(ipX_2_ip(&upcb->local_ip), new_addr); + } } } }