patch #6539: (configurable) response to broadcast- and multicast pings

This commit is contained in:
goldsimon 2009-02-16 20:24:29 +00:00
parent 14cb4eb735
commit e001a021d5
3 changed files with 43 additions and 8 deletions

View File

@ -19,13 +19,17 @@ HISTORY
++ New features:
2009-02-16 Simon Goldschmidt (patch by Rishi Khan)
* icmp.c, opt.h: patch #6539: (configurable) response to broadcast- and multicast
pings
2009-02-12 Simon Goldschmidt
* init.h: Added LWIP_VERSION to get the current version of the stack
2009-02-11 Simon Goldschmidt (suggested by Gottfried Spitaler)
* opt.h, memp.h/.c: added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead
of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc
is otherwise used)
of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc
is otherwise used)
2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach)
* ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial()

View File

@ -94,13 +94,30 @@ icmp_input(struct pbuf *p, struct netif *inp)
#endif /* LWIP_DEBUG */
switch (type) {
case ICMP_ECHO:
/* broadcast or multicast destination address? */
if (ip_addr_isbroadcast(&iphdr->dest, inp) || ip_addr_ismulticast(&iphdr->dest)) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n"));
ICMP_STATS_INC(icmp.err);
pbuf_free(p);
return;
#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
{
int accepted = 1;
#if !LWIP_MULTICAST_PING
/* multicast destination address? */
if (ip_addr_ismulticast(&iphdr->dest)) {
accepted = 0;
}
#endif /* LWIP_MULTICAST_PING */
#if !LWIP_BROADCAST_PING
/* broadcast destination address? */
if (ip_addr_isbroadcast(&iphdr->dest, inp)) {
accepted = 0;
}
#endif /* LWIP_BROADCAST_PING */
/* broadcast or multicast destination address not acceptd? */
if (!accepted) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n"));
ICMP_STATS_INC(icmp.err);
pbuf_free(p);
return;
}
}
#endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));

View File

@ -461,6 +461,20 @@
#define ICMP_TTL (IP_DEFAULT_TTL)
#endif
/**
* LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only)
*/
#ifndef LWIP_BROADCAST_PING
#define LWIP_BROADCAST_PING 0
#endif
/**
* LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only)
*/
#ifndef LWIP_MULTICAST_PING
#define LWIP_MULTICAST_PING 0
#endif
/*
---------------------------------
---------- RAW options ----------