mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 01:23:48 +08:00
fixed bug #45120: Broadcast & multiple interfaces handling
This commit is contained in:
@@ -116,7 +116,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
#endif /* LWIP_MULTICAST_PING */
|
||||
#if !LWIP_BROADCAST_PING
|
||||
/* broadcast destination address? */
|
||||
if (ip_addr_isbroadcast(ip_current_dest_addr(), inp)) {
|
||||
if (ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())) {
|
||||
accepted = 0;
|
||||
}
|
||||
#endif /* LWIP_BROADCAST_PING */
|
||||
@@ -190,8 +190,28 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
} else {
|
||||
err_t ret;
|
||||
ip4_addr_t* src;
|
||||
iphdr = (struct ip_hdr*)p->payload;
|
||||
ip4_addr_copy(iphdr->src, inp->ip_addr);
|
||||
|
||||
#if LWIP_MULTICAST_PING || LWIP_BROADCAST_PING
|
||||
if (0
|
||||
#if LWIP_MULTICAST_PING
|
||||
|| ip_addr_ismulticast(ip_current_dest_addr())
|
||||
#endif
|
||||
#if LWIP_BROADCAST_PING
|
||||
|| ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif())
|
||||
#endif
|
||||
) {
|
||||
/* For multicast and broadcast, use address of receiving interface
|
||||
* as source address */
|
||||
src = &inp->ip_addr;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
src = ip_current_dest_addr();
|
||||
}
|
||||
ip4_addr_copy(iphdr->src, *src);
|
||||
ip4_addr_copy(iphdr->dest, *ip4_current_src_addr());
|
||||
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
||||
#if CHECKSUM_GEN_ICMP
|
||||
@@ -218,8 +238,8 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* increase number of echo replies attempted to send */
|
||||
snmp_inc_icmpoutechoreps();
|
||||
|
||||
/* send an ICMP packet, src addr is the dest addr of the current packet */
|
||||
ret = ip4_output_if(p, ip4_current_dest_addr(), IP_HDRINCL,
|
||||
/* send an ICMP packet */
|
||||
ret = ip4_output_if(p, src, IP_HDRINCL,
|
||||
ICMP_TTL, 0, IP_PROTO_ICMP, inp);
|
||||
if (ret != ERR_OK) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret));
|
||||
|
||||
@@ -660,7 +660,7 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
default:
|
||||
#if LWIP_ICMP
|
||||
/* send ICMP destination protocol unreachable unless is was a broadcast */
|
||||
if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp) &&
|
||||
if (!ip_addr_isbroadcast(ip_current_dest_addr(), netif) &&
|
||||
!ip_addr_ismulticast(ip_current_dest_addr())) {
|
||||
pbuf_header_force(p, iphdr_hlen); /* Move to ip header, no check necessary. */
|
||||
p->payload = iphdr;
|
||||
|
||||
Reference in New Issue
Block a user