tcp/udp_netif_ipv4_addr_changed(): don't change specific-address of local tcp_listen/udp_pcb to ANY on address change

This commit is contained in:
sg 2015-03-06 20:25:51 +01:00
parent df16a7c4f3
commit 553c4203ab
2 changed files with 16 additions and 14 deletions

View File

@ -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_active_pcbs);
tcp_netif_ipv4_addr_changed_pcblist(old_addr, tcp_bound_pcbs); tcp_netif_ipv4_addr_changed_pcblist(old_addr, tcp_bound_pcbs);
/* PCB bound to current local interface address? */ if (!ip_addr_isany(new_addr)) {
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) {
next = lpcb->next;
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if ((!(ip_addr_isany(ipX_2_ip(&lpcb->local_ip)))) && for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) {
(ip_addr_cmp(ipX_2_ip(&lpcb->local_ip), old_addr))) { next = lpcb->next;
if (new_addr != NULL) { /* 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 /* 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); ip_addr_set(ipX_2_ip(&lpcb->local_ip), new_addr);
} }
} }

View File

@ -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; struct udp_pcb* upcb;
for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) { if (!ip_addr_isany(new_addr)) {
/* PCB bound to current local interface address? */ for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) {
if ((!(ip_addr_isany(ipX_2_ip(&upcb->local_ip)))) && /* PCB bound to current local interface address? */
(ip_addr_cmp(ipX_2_ip(&upcb->local_ip), old_addr))) { if ((!(ip_addr_isany(ipX_2_ip(&upcb->local_ip)))) &&
/* The PCB is bound to the old ipaddr and (ip_addr_cmp(ipX_2_ip(&upcb->local_ip), old_addr))) {
* is set to bound to the new one instead */ /* The PCB is bound to the old ipaddr and
ip_addr_set(ipX_2_ip(&upcb->local_ip), new_addr); * is set to bound to the new one instead */
ip_addr_set(ipX_2_ip(&upcb->local_ip), new_addr);
}
} }
} }
} }