44#if LWIP_IPV4 && LWIP_ICMP
54#ifdef LWIP_HOOK_FILENAME
55#include LWIP_HOOK_FILENAME
61#ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
62#define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1
66#define ICMP_DEST_UNREACH_DATASIZE 8
87 const struct ip_hdr *iphdr_in;
89 const ip4_addr_t *
src;
94 iphdr_in = ip4_current_header();
100 if (
p->len <
sizeof(
u16_t) * 2) {
119 src = ip4_current_dest_addr();
121 if (ip4_addr_ismulticast(ip4_current_dest_addr())) {
122#if LWIP_MULTICAST_PING
124 src = netif_ip4_addr(inp);
132#if LWIP_BROADCAST_PING
134 src = netif_ip4_addr(inp);
145#if CHECKSUM_CHECK_ICMP
156#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
179 MEMCPY(
r->payload, iphdr_in, hlen);
182 LWIP_ASSERT(
"icmp_input: moving r->payload to icmp header failed", 0);
199 LWIP_ASSERT(
"icmp_input: restoring original p->payload failed", 0);
213 ip4_addr_copy(iphdr->src, *
src);
214 ip4_addr_copy(iphdr->dest, *ip4_current_src_addr());
225#if LWIP_CHECKSUM_CTRL_PER_NETIF
289#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN || !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
314#if IP_FORWARD || IP_REASSEMBLY
345 ip4_addr_t iphdr_src;
347 u16_t response_pkt_len;
353 response_pkt_len =
IP_HLEN + ICMP_DEST_UNREACH_DATASIZE;
354 if (
p->tot_len < response_pkt_len) {
355 response_pkt_len =
p->tot_len;
365 LWIP_ASSERT(
"check that first pbuf can hold icmp message",
366 (
q->len >= (
sizeof(
struct icmp_hdr) + response_pkt_len)));
368 iphdr = (
struct ip_hdr *)
p->payload;
370 ip4_addr_debug_print_val(
ICMP_DEBUG, iphdr->src);
372 ip4_addr_debug_print_val(
ICMP_DEBUG, iphdr->dest);
376 icmphdr->type =
type;
377 icmphdr->code =
code;
383 ip4_addr_copy(iphdr_src, iphdr->src);
384#ifdef LWIP_HOOK_IP4_ROUTE_SRC
386 ip4_addr_t iphdr_dst;
387 ip4_addr_copy(iphdr_dst, iphdr->dest);
388 netif = ip4_route_src(&iphdr_dst, &iphdr_src);
391 netif = ip4_route(&iphdr_src);
#define LWIP_DEBUGF(debug, message)
#define LWIP_ASSERT(message, assertion)
#define ip_current_netif()
GLuint GLuint GLsizei GLenum type
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble GLdouble q
#define LWIP_UNUSED_ARG(x)
#define LWIP_DBG_LEVEL_SERIOUS
#define PBUF_LINK_ENCAPSULATION_HLEN
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_free(struct pbuf *p)
err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset)
u16_t inet_chksum(const void *dataptr, u16_t len)
u16_t inet_chksum_pbuf(struct pbuf *p)
#define ICMPH_TYPE_SET(hdr, t)
#define MEMCPY(DST, SRC, BYTES)
#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
#define IPH_HL_BYTES(hdr)
#define IPH_TTL_SET(hdr, ttl)
#define IPH_CHKSUM_SET(hdr, chksum)
#define MIB2_STATS_INC(x)
#define ICMP_STATS_INC(x)