mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-01 12:00:53 +00:00
Fix bug #48886: raw pcbs are not handled on netif address change
This commit is contained in:
parent
d7f8d33506
commit
df5a79966d
@ -58,6 +58,7 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/etharp.h"
|
||||
@ -391,6 +392,9 @@ netif_remove(struct netif *netif)
|
||||
#if LWIP_UDP
|
||||
udp_netif_ip_addr_changed(netif_ip_addr4(netif), NULL);
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_RAW
|
||||
raw_netif_ip_addr_changed(netif_ip_addr4(netif), NULL);
|
||||
#endif /* LWIP_RAW */
|
||||
}
|
||||
|
||||
#if LWIP_IGMP
|
||||
@ -410,6 +414,9 @@ netif_remove(struct netif *netif)
|
||||
#if LWIP_UDP
|
||||
udp_netif_ip_addr_changed(netif_ip_addr6(netif, i), NULL);
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_RAW
|
||||
raw_netif_ip_addr_changed(netif_ip_addr6(netif, i), NULL);
|
||||
#endif /* LWIP_RAW */
|
||||
}
|
||||
}
|
||||
#if LWIP_IPV6_MLD
|
||||
@ -512,6 +519,9 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||
#if LWIP_UDP
|
||||
udp_netif_ip_addr_changed(netif_ip_addr4(netif), &new_addr);
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_RAW
|
||||
raw_netif_ip_addr_changed(netif_ip_addr4(netif), &new_addr);
|
||||
#endif /* LWIP_RAW */
|
||||
|
||||
mib2_remove_ip4(netif);
|
||||
mib2_remove_route_ip4(0, netif);
|
||||
@ -1047,6 +1057,9 @@ netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1,
|
||||
#if LWIP_UDP
|
||||
udp_netif_ip_addr_changed(netif_ip_addr6(netif, addr_idx), &new_ipaddr);
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_RAW
|
||||
raw_netif_ip_addr_changed(netif_ip_addr6(netif, addr_idx), &new_ipaddr);
|
||||
#endif /* LWIP_RAW */
|
||||
}
|
||||
/* @todo: remove/readd mib2 ip6 entries? */
|
||||
|
||||
@ -1096,6 +1109,9 @@ netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state)
|
||||
#if LWIP_UDP
|
||||
udp_netif_ip_addr_changed(netif_ip_addr6(netif, addr_idx), NULL);
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_RAW
|
||||
raw_netif_ip_addr_changed(netif_ip_addr6(netif, addr_idx), NULL);
|
||||
#endif /* LWIP_RAW */
|
||||
/* @todo: remove mib2 ip6 entries? */
|
||||
}
|
||||
netif->ip6_addr_state[addr_idx] = state;
|
||||
|
@ -495,4 +495,25 @@ raw_new_ip_type(u8_t type, u8_t proto)
|
||||
return pcb;
|
||||
}
|
||||
|
||||
/** This function is called from netif.c when address is changed
|
||||
*
|
||||
* @param old_addr IP address of the netif before change
|
||||
* @param new_addr IP address of the netif after change
|
||||
*/
|
||||
void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr)
|
||||
{
|
||||
struct raw_pcb* rpcb;
|
||||
|
||||
if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
|
||||
for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) {
|
||||
/* PCB bound to current local interface address? */
|
||||
if (ip_addr_cmp(&rpcb->local_ip, old_addr)) {
|
||||
/* The PCB is bound to the old ipaddr and
|
||||
* is set to bound to the new one instead */
|
||||
ip_addr_copy(rpcb->local_ip, *new_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_RAW */
|
||||
|
@ -104,6 +104,8 @@ void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *re
|
||||
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
||||
#define raw_init() /* Compatibility define, no init needed. */
|
||||
|
||||
void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
|
||||
|
||||
/* for compatibility with older implementation */
|
||||
#define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user