mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
icmp6: keep to the RFC and send as much as possible with icmp6 error messages
See bug 56013 Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
ba3b04e7fe
commit
8f5a0aaacb
@ -57,9 +57,9 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if LWIP_ICMP6_DATASIZE == 0
|
||||
#if !LWIP_ICMP6_DATASIZE || (LWIP_ICMP6_DATASIZE > (IP6_MIN_MTU_LENGTH - IP6_HLEN - ICMP6_HLEN))
|
||||
#undef LWIP_ICMP6_DATASIZE
|
||||
#define LWIP_ICMP6_DATASIZE 8
|
||||
#define LWIP_ICMP6_DATASIZE (IP6_MIN_MTU_LENGTH - IP6_HLEN - ICMP6_HLEN)
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
@ -387,17 +387,18 @@ icmp6_send_response_with_addrs_and_netif(struct pbuf *p, u8_t code, u32_t data,
|
||||
{
|
||||
struct pbuf *q;
|
||||
struct icmp6_hdr *icmp6hdr;
|
||||
u16_t datalen = LWIP_MIN(p->tot_len, LWIP_ICMP6_DATASIZE);
|
||||
|
||||
/* ICMPv6 header + IPv6 header + data */
|
||||
q = pbuf_alloc(PBUF_IP, sizeof(struct icmp6_hdr) + IP6_HLEN + LWIP_ICMP6_DATASIZE,
|
||||
/* ICMPv6 header + datalen (as much of the offending packet as possible) */
|
||||
q = pbuf_alloc(PBUF_IP, sizeof(struct icmp6_hdr) + datalen,
|
||||
PBUF_RAM);
|
||||
if (q == NULL) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMPv6 packet.\n"));
|
||||
ICMP6_STATS_INC(icmp6.memerr);
|
||||
return;
|
||||
}
|
||||
LWIP_ASSERT("check that first pbuf can hold icmp 6message",
|
||||
(q->len >= (sizeof(struct icmp6_hdr) + IP6_HLEN + LWIP_ICMP6_DATASIZE)));
|
||||
LWIP_ASSERT("check that first pbuf can hold icmp6 header",
|
||||
(q->len >= (sizeof(struct icmp6_hdr))));
|
||||
|
||||
icmp6hdr = (struct icmp6_hdr *)q->payload;
|
||||
icmp6hdr->type = type;
|
||||
@ -405,8 +406,7 @@ icmp6_send_response_with_addrs_and_netif(struct pbuf *p, u8_t code, u32_t data,
|
||||
icmp6hdr->data = lwip_htonl(data);
|
||||
|
||||
/* copy fields from original packet */
|
||||
SMEMCPY((u8_t *)q->payload + sizeof(struct icmp6_hdr), (u8_t *)p->payload,
|
||||
IP6_HLEN + LWIP_ICMP6_DATASIZE);
|
||||
pbuf_take_at(q, p->payload, datalen, sizeof(struct icmp6_hdr));
|
||||
|
||||
/* calculate checksum */
|
||||
icmp6hdr->chksum = 0;
|
||||
|
@ -2496,10 +2496,12 @@
|
||||
|
||||
/**
|
||||
* LWIP_ICMP6_DATASIZE: bytes from original packet to send back in
|
||||
* ICMPv6 error messages.
|
||||
* ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH)
|
||||
* ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST,
|
||||
* so override this only if you absolutely have to!
|
||||
*/
|
||||
#if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__
|
||||
#define LWIP_ICMP6_DATASIZE 8
|
||||
#define LWIP_ICMP6_DATASIZE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -146,6 +146,8 @@ PACK_STRUCT_END
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define ICMP6_HLEN 8
|
||||
|
||||
/** This is the ICMP6 header adapted for echo req/resp. */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
|
Loading…
Reference in New Issue
Block a user