You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/26 14:48:00 UTC
[incubator-nuttx] 01/02: net/icmp/v6: add ICMP Destination Unreachable code definitions
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 6cd850b0e68f87fa99946ad2e006e4397e1b26ba
Author: chao.an <an...@xiaomi.com>
AuthorDate: Thu Nov 25 22:02:07 2021 +0800
net/icmp/v6: add ICMP Destination Unreachable code definitions
Signed-off-by: chao.an <an...@xiaomi.com>
---
include/nuttx/net/icmp.h | 32 ++++++++++++++++++++++++++++++--
include/nuttx/net/icmpv6.h | 12 ++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/include/nuttx/net/icmp.h b/include/nuttx/net/icmp.h
index d949c25..eeb52a3 100644
--- a/include/nuttx/net/icmp.h
+++ b/include/nuttx/net/icmp.h
@@ -94,6 +94,26 @@
#define ICMP_HDRLEN 8 /* Size of ICMP header */
#define IPICMP_HDRLEN (ICMP_HDRLEN + IPv4_HDRLEN) /* Size of IPv4 + ICMP header */
+/* Codes for UNREACH. */
+
+#define ICMP_NET_UNREACH 0 /* Network Unreachable */
+#define ICMP_HOST_UNREACH 1 /* Host Unreachable */
+#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */
+#define ICMP_PORT_UNREACH 3 /* Port Unreachable */
+#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */
+#define ICMP_SR_FAILED 5 /* Source Route failed */
+#define ICMP_NET_UNKNOWN 6
+#define ICMP_HOST_UNKNOWN 7
+#define ICMP_HOST_ISOLATED 8
+#define ICMP_NET_ANO 9
+#define ICMP_HOST_ANO 10
+#define ICMP_NET_UNR_TOS 11
+#define ICMP_HOST_UNR_TOS 12
+#define ICMP_PKT_FILTERED 13 /* Packet filtered */
+#define ICMP_PREC_VIOLATION 14 /* Precedence violation */
+#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */
+#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */
+
/****************************************************************************
* Public Type Definitions
****************************************************************************/
@@ -113,8 +133,16 @@ struct icmp_hdr_s
/* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */
- uint16_t id; /* Used to match requests with replies */
- uint16_t seqno; /* " " "" " " " " " " " " */
+ union
+ {
+ struct
+ {
+ uint16_t id; /* Used to match requests with replies */
+ uint16_t seqno; /* " " "" " " " " " " " " */
+ };
+
+ uint32_t data;
+ };
};
/* The structure holding the ICMP statistics that are gathered if
diff --git a/include/nuttx/net/icmpv6.h b/include/nuttx/net/icmpv6.h
index e520fc1..457619d 100644
--- a/include/nuttx/net/icmpv6.h
+++ b/include/nuttx/net/icmpv6.h
@@ -131,6 +131,16 @@
#define ICMPv6_OPT_SIZE(a) ((a) > 0 ? ((a) + 2 + 7) & ~7 : 0)
#define ICMPv6_OPT_OCTECTS(a) ((a) > 0 ? ((a) + 2 + 7) >> 3 : 0)
+/* Codes for Destination Unreachable */
+
+#define ICMPv6_NOROUTE 0
+#define ICMPv6_ADM_PROHIBITED 1
+#define ICMPv6_NOT_NEIGHBOUR 2
+#define ICMPv6_ADDR_UNREACH 3
+#define ICMPv6_PORT_UNREACH 4
+#define ICMPv6_POLICY_FAIL 5
+#define ICMPv6_REJECT_ROUTE 6
+
/****************************************************************************
* Public Type Definitions
****************************************************************************/
@@ -146,6 +156,8 @@ struct icmpv6_hdr_s
/* Data following the ICMP header contains the data specific to the
* message type indicated by the Type and Code fields.
*/
+
+ uint32_t data;
};
/* The ICMPv6 and IPv6 headers */