From 264283c5a29fc6f4f18c43850e0e2cd9de4065d3 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Thu, 10 Aug 2023 11:27:20 +0800 Subject: [PATCH] net/icmpv6: Fix value of `SIZEOF_ICMPV6_ECHO_xxx_S` The `SIZEOF_ICMPV6_ECHO_REQUEST_S` and `SIZEOF_ICMPV6_ECHO_REPLY_S` macro are intended to be `8+n`, but actually becomes `10-1+n` and causes the packet sent by `ping6` one byte more than expected. Signed-off-by: Zhe Weng --- include/nuttx/net/icmpv6.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nuttx/net/icmpv6.h b/include/nuttx/net/icmpv6.h index d9872a3fbd..acd32ea8d8 100644 --- a/include/nuttx/net/icmpv6.h +++ b/include/nuttx/net/icmpv6.h @@ -269,7 +269,7 @@ struct icmpv6_router_advertise_s /* This the message format for the ICMPv6 Echo Request message */ -struct icmpv6_echo_request_s +begin_packed_struct struct icmpv6_echo_request_s { uint8_t type; /* Message Type: ICMPv6_ECHO_REQUEST */ uint8_t code; /* Further qualifies the ICMP messages */ @@ -277,14 +277,14 @@ struct icmpv6_echo_request_s uint16_t id; /* Identifier */ uint16_t seqno; /* Sequence Number */ uint8_t data[1]; /* Data follows */ -}; +} end_packed_struct; #define SIZEOF_ICMPV6_ECHO_REQUEST_S(n) \ (sizeof(struct icmpv6_echo_request_s) - 1 + (n)) /* This the message format for the ICMPv6 Echo Reply message */ -struct icmpv6_echo_reply_s +begin_packed_struct struct icmpv6_echo_reply_s { uint8_t type; /* Message Type: ICMPv6_ECHO_REQUEST */ uint8_t code; /* Further qualifies the ICMP messages */ @@ -292,7 +292,7 @@ struct icmpv6_echo_reply_s uint16_t id; /* Identifier */ uint16_t seqno; /* Sequence Number */ uint8_t data[1]; /* Data follows */ -}; +} end_packed_struct; #define SIZEOF_ICMPV6_ECHO_REPLY_S(n) \ (sizeof(struct icmpv6_echo_reply_s) - 1 + (n))