63#if LWIP_ICMP6 && LWIP_IPV6
79#ifndef LWIP_ICMP6_DATASIZE
80#define LWIP_ICMP6_DATASIZE 8
82#if LWIP_ICMP6_DATASIZE == 0
83#define LWIP_ICMP6_DATASIZE 8
87static void icmp6_send_response(
struct pbuf *p, u8_t code, u32_t data, u8_t type);
100icmp6_input(
struct pbuf *p,
struct netif *inp)
104 const ip6_addr_t *reply_src;
106 ICMP6_STATS_INC(icmp6.recv);
112 ICMP6_STATS_INC(icmp6.lenerr);
113 ICMP6_STATS_INC(icmp6.drop);
119#if CHECKSUM_CHECK_ICMP6
120 IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_CHECK_ICMP6) {
121 if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->
tot_len, ip6_current_src_addr(),
122 ip6_current_dest_addr()) != 0) {
125 ICMP6_STATS_INC(icmp6.chkerr);
126 ICMP6_STATS_INC(icmp6.drop);
132 switch (icmp6hdr->type) {
155#if !LWIP_MULTICAST_PING
157 if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
160 ICMP6_STATS_INC(icmp6.drop);
170 ICMP6_STATS_INC(icmp6.memerr);
179 ICMP6_STATS_INC(icmp6.err);
184#if LWIP_MULTICAST_PING
185 if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
186 reply_src = ip_2_ip6(ip6_select_source_address(inp, ip6_current_src_addr()));
187 if (reply_src == NULL) {
191 ICMP6_STATS_INC(icmp6.rterr);
198 reply_src = ip6_current_dest_addr();
204#if CHECKSUM_GEN_ICMP6
205 IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_GEN_ICMP6) {
207 IP6_NEXTH_ICMP6, r->
tot_len, reply_src, ip6_current_src_addr());
212 ICMP6_STATS_INC(icmp6.xmit);
213 ip6_output_if(r, reply_src, ip6_current_src_addr(),
219 ICMP6_STATS_INC(icmp6.proterr);
220 ICMP6_STATS_INC(icmp6.drop);
249icmp6_packet_too_big(
struct pbuf *p, u32_t mtu)
291icmp6_send_response(
struct pbuf *p, u8_t code, u32_t data, u8_t type)
295 const ip6_addr_t *reply_src;
296 ip6_addr_t *reply_dest;
297 ip6_addr_t reply_src_local, reply_dest_local;
306 ICMP6_STATS_INC(icmp6.memerr);
309 LWIP_ASSERT(
"check that first pbuf can hold icmp 6message",
313 icmp6hdr->type = type;
314 icmp6hdr->code = code;
315 icmp6hdr->data = data;
329 ip6_addr_copy(reply_dest_local, ip6hdr->src);
330 ip6_addr_copy(reply_src_local, ip6hdr->dest);
331 reply_dest = &reply_dest_local;
332 reply_src = &reply_src_local;
333 netif = ip6_route(reply_src, reply_dest);
337 ICMP6_STATS_INC(icmp6.rterr);
343 reply_dest = ip6_current_src_addr();
346 reply_src = ip_2_ip6(ip6_select_source_address(
netif, reply_dest));
347 if (reply_src == NULL) {
350 ICMP6_STATS_INC(icmp6.rterr);
356 icmp6hdr->chksum = 0;
357#if CHECKSUM_GEN_ICMP6
358 IF__NETIF_CHECKSUM_ENABLED(
netif, NETIF_CHECKSUM_GEN_ICMP6) {
359 icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->
tot_len,
360 reply_src, reply_dest);
364 ICMP6_STATS_INC(icmp6.xmit);
#define LWIP_DEBUGF(debug, message)
#define LWIP_ICMP6_DATASIZE
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)
#define ip_current_netif()