Merge branch 'bugfix/rebind_pcb_when_ip_changed' into 'master'
lwip: rebind UDP/TCP pcb to valid ip address when ip is changed See merge request !1535
This commit is contained in:
commit
af367452b0
2 changed files with 13 additions and 2 deletions
|
@ -453,14 +453,20 @@ void
|
||||||
netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||||
{
|
{
|
||||||
ip4_addr_t new_addr = (ipaddr ? *ipaddr : *IP4_ADDR_ANY);
|
ip4_addr_t new_addr = (ipaddr ? *ipaddr : *IP4_ADDR_ANY);
|
||||||
|
#if ESP_LWIP
|
||||||
|
ip4_addr_t *last_addr = ip_2_ip4(&netif->last_ip_addr);
|
||||||
|
#else
|
||||||
|
ip4_addr_t *last_addr = netif_ip4_addr(netif);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* address is actually being changed? */
|
/* address is actually being changed? */
|
||||||
if (ip4_addr_cmp(&new_addr, netif_ip4_addr(netif)) == 0) {
|
if (ip4_addr_cmp(&new_addr, netif_ip4_addr(netif)) == 0) {
|
||||||
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
|
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
tcp_netif_ipv4_addr_changed(netif_ip4_addr(netif), ipaddr);
|
tcp_netif_ipv4_addr_changed(last_addr, ipaddr);
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
udp_netif_ipv4_addr_changed(netif_ip4_addr(netif), ipaddr);
|
udp_netif_ipv4_addr_changed(last_addr, ipaddr);
|
||||||
#endif /* LWIP_UDP */
|
#endif /* LWIP_UDP */
|
||||||
|
|
||||||
mib2_remove_ip4(netif);
|
mib2_remove_ip4(netif);
|
||||||
|
@ -482,6 +488,10 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||||
ip4_addr2_16(netif_ip4_addr(netif)),
|
ip4_addr2_16(netif_ip4_addr(netif)),
|
||||||
ip4_addr3_16(netif_ip4_addr(netif)),
|
ip4_addr3_16(netif_ip4_addr(netif)),
|
||||||
ip4_addr4_16(netif_ip4_addr(netif))));
|
ip4_addr4_16(netif_ip4_addr(netif))));
|
||||||
|
|
||||||
|
if (ipaddr && !ip4_addr_isany(ipaddr)) {
|
||||||
|
ip4_addr_set(ip_2_ip4(&netif->last_ip_addr), ipaddr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -333,6 +333,7 @@ struct netif {
|
||||||
|
|
||||||
#if ESP_LWIP
|
#if ESP_LWIP
|
||||||
void (*l2_buffer_free_notify)(void *user_buf); /* Allows LWIP to notify driver when a L2-supplied pbuf can be freed */
|
void (*l2_buffer_free_notify)(void *user_buf); /* Allows LWIP to notify driver when a L2-supplied pbuf can be freed */
|
||||||
|
ip_addr_t last_ip_addr; /* Store last non-zero ip address */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue