mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-30 12:32:37 +00:00
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:
parent
90a3f88c08
commit
ca866c0d7d
@ -19,6 +19,13 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ 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
|
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
|
* 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
|
for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/snmp.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().
|
* 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 /* IP_FORWARD */
|
||||||
|
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
|
@ -144,10 +144,12 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
|||||||
/* send ICMP if TTL == 0 */
|
/* send ICMP if TTL == 0 */
|
||||||
if (IPH_TTL(iphdr) == 0) {
|
if (IPH_TTL(iphdr) == 0) {
|
||||||
snmp_inc_ipinhdrerrors();
|
snmp_inc_ipinhdrerrors();
|
||||||
|
#if LWIP_ICMP
|
||||||
/* Don't send ICMP messages in response to ICMP messages */
|
/* Don't send ICMP messages in response to ICMP messages */
|
||||||
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
|
if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
|
||||||
icmp_time_exceeded(p, ICMP_TE_TTL);
|
icmp_time_exceeded(p, ICMP_TE_TTL);
|
||||||
}
|
}
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
return (struct netif *)NULL;
|
return (struct netif *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,22 +386,26 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
tcp_input(p, inp);
|
tcp_input(p, inp);
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
|
#if LWIP_ICMP
|
||||||
case IP_PROTO_ICMP:
|
case IP_PROTO_ICMP:
|
||||||
snmp_inc_ipindelivers();
|
snmp_inc_ipindelivers();
|
||||||
icmp_input(p, inp);
|
icmp_input(p, inp);
|
||||||
break;
|
break;
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
#if LWIP_IGMP
|
#if LWIP_IGMP
|
||||||
case IP_PROTO_IGMP:
|
case IP_PROTO_IGMP:
|
||||||
igmp_input(p,inp,&(iphdr->dest));
|
igmp_input(p,inp,&(iphdr->dest));
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_IGMP */
|
#endif /* LWIP_IGMP */
|
||||||
default:
|
default:
|
||||||
|
#if LWIP_ICMP
|
||||||
/* send ICMP destination protocol unreachable unless is was a broadcast */
|
/* send ICMP destination protocol unreachable unless is was a broadcast */
|
||||||
if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
|
if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
|
||||||
!ip_addr_ismulticast(&(iphdr->dest))) {
|
!ip_addr_ismulticast(&(iphdr->dest))) {
|
||||||
p->payload = iphdr;
|
p->payload = iphdr;
|
||||||
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
||||||
}
|
}
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
|
||||||
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));
|
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
|
|
||||||
|
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
void
|
void
|
||||||
icmp_input(struct pbuf *p, struct netif *inp)
|
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);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,10 +111,12 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
|||||||
}
|
}
|
||||||
/* Decrement TTL and send ICMP if ttl == 0. */
|
/* Decrement TTL and send ICMP if ttl == 0. */
|
||||||
if (--iphdr->hoplim == 0) {
|
if (--iphdr->hoplim == 0) {
|
||||||
|
#if LWIP_ICMP
|
||||||
/* Don't send ICMP messages in response to ICMP messages */
|
/* Don't send ICMP messages in response to ICMP messages */
|
||||||
if (iphdr->nexthdr != IP_PROTO_ICMP) {
|
if (iphdr->nexthdr != IP_PROTO_ICMP) {
|
||||||
icmp_time_exceeded(p, ICMP_TE_TTL);
|
icmp_time_exceeded(p, ICMP_TE_TTL);
|
||||||
}
|
}
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -232,12 +234,16 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
case IP_PROTO_TCP:
|
case IP_PROTO_TCP:
|
||||||
tcp_input(p, inp);
|
tcp_input(p, inp);
|
||||||
break;
|
break;
|
||||||
|
#if LWIP_ICMP
|
||||||
case IP_PROTO_ICMP:
|
case IP_PROTO_ICMP:
|
||||||
icmp_input(p, inp);
|
icmp_input(p, inp);
|
||||||
break;
|
break;
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
default:
|
default:
|
||||||
|
#if LWIP_ICMP
|
||||||
/* send ICMP destination protocol unreachable */
|
/* send ICMP destination protocol unreachable */
|
||||||
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n",
|
LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n",
|
||||||
iphdr->nexthdr));
|
iphdr->nexthdr));
|
||||||
@ -382,4 +388,3 @@ ip_debug_print(struct pbuf *p)
|
|||||||
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
}
|
}
|
||||||
#endif /* IP_DEBUG */
|
#endif /* IP_DEBUG */
|
||||||
|
|
||||||
|
@ -256,6 +256,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
} else {
|
} else {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n"));
|
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
|
/* No match was found, send ICMP destination port unreachable unless
|
||||||
destination address was broadcast/multicast. */
|
destination address was broadcast/multicast. */
|
||||||
if (!ip_addr_isbroadcast(&iphdr->dest, inp) &&
|
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));
|
LWIP_ASSERT("p->payload == iphdr", (p->payload == iphdr));
|
||||||
icmp_dest_unreach(p, ICMP_DUR_PORT);
|
icmp_dest_unreach(p, ICMP_DUR_PORT);
|
||||||
}
|
}
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
UDP_STATS_INC(udp.proterr);
|
UDP_STATS_INC(udp.proterr);
|
||||||
UDP_STATS_INC(udp.drop);
|
UDP_STATS_INC(udp.drop);
|
||||||
snmp_inc_udpnoports();
|
snmp_inc_udpnoports();
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -116,5 +118,6 @@ PACK_STRUCT_END
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
|
|
||||||
#endif /* __LWIP_ICMP_H__ */
|
#endif /* __LWIP_ICMP_H__ */
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -94,5 +96,7 @@ struct icmp_te_hdr {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* LWIP_ICMP */
|
||||||
|
|
||||||
#endif /* __LWIP_ICMP_H__ */
|
#endif /* __LWIP_ICMP_H__ */
|
||||||
|
|
||||||
|
@ -403,6 +403,14 @@
|
|||||||
---------- ICMP options ----------
|
---------- 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.
|
* ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user