Integrate "task #7272 : LWIP_ICMP option". The new option LWIP_ICMP enable/disable ICMP module inside the IP stack (enable per default). Be careful, disabling ICMP make your product non-compliant to RFC1122, but help to reduce footprint, and to reduce "visibility" on the Internet.

This commit is contained in:
fbernon 2007-09-05 17:20:45 +00:00
parent 90a3f88c08
commit ca866c0d7d
9 changed files with 44 additions and 10 deletions

View File

@ -19,6 +19,13 @@ HISTORY
++ New features:
2007-09-05 Frédéric Bernon
* udp.c, ipv4/icmp.c, ipv4/ip.c, ipv6/icmp.c, ipv6/ip6.c, ipv4/icmp.h,
ipv6/icmp.h, opt.h: Integrate "task #7272 : LWIP_ICMP option". The new option
LWIP_ICMP enable/disable ICMP module inside the IP stack (enable per default).
Be careful, disabling ICMP make your product non-compliant to RFC1122, but
help to reduce footprint, and to reduce "visibility" on the Internet.
2007-09-05 Frédéric Bernon, Bill Florac
* opt.h, sys.h, tcpip.c, slipif.c, ppp.c, sys_arch.txt: Change parameters list
for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new

View File

@ -49,6 +49,8 @@
#include "lwip/stats.h"
#include "lwip/snmp.h"
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
/**
* Processes ICMP input packets, called from ip_input().
*
@ -298,3 +300,5 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
}
#endif /* IP_FORWARD */
#endif /* LWIP_ICMP */

View File

@ -144,10 +144,12 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
/* send ICMP if TTL == 0 */
if (IPH_TTL(iphdr) == 0) {
snmp_inc_ipinhdrerrors();
#if LWIP_ICMP
/* Don't send ICMP messages in response to ICMP messages */
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
icmp_time_exceeded(p, ICMP_TE_TTL);
}
#endif /* LWIP_ICMP */
return (struct netif *)NULL;
}
@ -384,22 +386,26 @@ ip_input(struct pbuf *p, struct netif *inp) {
tcp_input(p, inp);
break;
#endif /* LWIP_TCP */
#if LWIP_ICMP
case IP_PROTO_ICMP:
snmp_inc_ipindelivers();
icmp_input(p, inp);
break;
#endif /* LWIP_ICMP */
#if LWIP_IGMP
case IP_PROTO_IGMP:
igmp_input(p,inp,&(iphdr->dest));
break;
#endif /* LWIP_IGMP */
default:
#if LWIP_ICMP
/* send ICMP destination protocol unreachable unless is was a broadcast */
if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
!ip_addr_ismulticast(&(iphdr->dest))) {
p->payload = iphdr;
icmp_dest_unreach(p, ICMP_DUR_PROTO);
}
#endif /* LWIP_ICMP */
pbuf_free(p);
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));

View File

@ -42,6 +42,7 @@
#include "lwip/stats.h"
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
void
icmp_input(struct pbuf *p, struct netif *inp)
@ -192,10 +193,4 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
pbuf_free(q);
}
#endif /* LWIP_ICMP */

View File

@ -111,10 +111,12 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
}
/* Decrement TTL and send ICMP if ttl == 0. */
if (--iphdr->hoplim == 0) {
#if LWIP_ICMP
/* Don't send ICMP messages in response to ICMP messages */
if (iphdr->nexthdr != IP_PROTO_ICMP) {
icmp_time_exceeded(p, ICMP_TE_TTL);
}
#endif /* LWIP_ICMP */
pbuf_free(p);
return;
}
@ -232,12 +234,16 @@ ip_input(struct pbuf *p, struct netif *inp) {
case IP_PROTO_TCP:
tcp_input(p, inp);
break;
#if LWIP_ICMP
case IP_PROTO_ICMP:
icmp_input(p, inp);
break;
#endif /* LWIP_ICMP */
default:
#if LWIP_ICMP
/* send ICMP destination protocol unreachable */
icmp_dest_unreach(p, ICMP_DUR_PROTO);
#endif /* LWIP_ICMP */
pbuf_free(p);
LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n",
iphdr->nexthdr));
@ -382,4 +388,3 @@ ip_debug_print(struct pbuf *p)
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
#endif /* IP_DEBUG */

View File

@ -256,6 +256,7 @@ udp_input(struct pbuf *p, struct netif *inp)
} else {
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n"));
#if LWIP_ICMP
/* No match was found, send ICMP destination port unreachable unless
destination address was broadcast/multicast. */
if (!ip_addr_isbroadcast(&iphdr->dest, inp) &&
@ -265,6 +266,7 @@ udp_input(struct pbuf *p, struct netif *inp)
LWIP_ASSERT("p->payload == iphdr", (p->payload == iphdr));
icmp_dest_unreach(p, ICMP_DUR_PORT);
}
#endif /* LWIP_ICMP */
UDP_STATS_INC(udp.proterr);
UDP_STATS_INC(udp.drop);
snmp_inc_udpnoports();

View File

@ -40,6 +40,8 @@
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
#ifdef __cplusplus
extern "C" {
#endif
@ -116,5 +118,6 @@ PACK_STRUCT_END
}
#endif
#endif /* LWIP_ICMP */
#endif /* __LWIP_ICMP_H__ */

View File

@ -39,6 +39,8 @@
#include "lwip/netif.h"
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
#ifdef __cplusplus
extern "C" {
#endif
@ -94,5 +96,7 @@ struct icmp_te_hdr {
}
#endif
#endif /* LWIP_ICMP */
#endif /* __LWIP_ICMP_H__ */

View File

@ -403,6 +403,14 @@
---------- ICMP options ----------
----------------------------------
*/
/**
* LWIP_ICMP==1: Enable ICMP module inside the IP stack.
* Be careful, disable that make your product non-compliant to RFC1122
*/
#ifndef LWIP_ICMP
#define LWIP_ICMP 1
#endif
/**
* ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
*/