xref: /dpdk/lib/net/rte_icmp.h (revision fba9875559906e04eaeb74532f4cfd51194259a2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 1982, 1986, 1990, 1993
3  *      The Regents of the University of California.
4  * Copyright(c) 2013 6WIND S.A.
5  * All rights reserved.
6  */
7 
8 #ifndef _RTE_ICMP_H_
9 #define _RTE_ICMP_H_
10 
11 /**
12  * @file
13  *
14  * ICMP-related defines
15  */
16 
17 #include <stdint.h>
18 
19 #include <rte_byteorder.h>
20 
21 /**
22  * ICMP base header
23  */
24 struct __rte_packed_begin rte_icmp_base_hdr {
25 	uint8_t type;
26 	uint8_t code;
27 	rte_be16_t checksum;
28 } __rte_packed_end;
29 
30 /**
31  * ICMP echo header
32  */
33 struct __rte_packed_begin rte_icmp_echo_hdr {
34 	struct rte_icmp_base_hdr base;
35 	rte_be16_t identifier;
36 	rte_be16_t sequence;
37 } __rte_packed_end;
38 
39 /**
40  * ICMP Header
41  *
42  * @see rte_icmp_echo_hdr which is similar.
43  */
44 struct __rte_packed_begin rte_icmp_hdr {
45 	uint8_t  icmp_type;     /* ICMP packet type. */
46 	uint8_t  icmp_code;     /* ICMP packet code. */
47 	rte_be16_t icmp_cksum;  /* ICMP packet checksum. */
48 	rte_be16_t icmp_ident;  /* ICMP packet identifier. */
49 	rte_be16_t icmp_seq_nb; /* ICMP packet sequence number. */
50 } __rte_packed_end;
51 
52 /* ICMP packet types */
53 #define RTE_ICMP_TYPE_ECHO_REPLY 0
54 #define RTE_IP_ICMP_ECHO_REPLY \
55 	(RTE_DEPRECATED(RTE_IP_ICMP_ECHO_REPLY) RTE_ICMP_TYPE_ECHO_REPLY)
56 #define RTE_ICMP_TYPE_DEST_UNREACHABLE 3
57 #define RTE_ICMP_TYPE_REDIRECT 5
58 #define RTE_ICMP_TYPE_ECHO_REQUEST 8
59 #define RTE_IP_ICMP_ECHO_REQUEST \
60 	(RTE_DEPRECATED(RTE_IP_ICMP_ECHO_REQUEST) RTE_ICMP_TYPE_ECHO_REQUEST)
61 #define RTE_ICMP_TYPE_TTL_EXCEEDED 11
62 #define RTE_ICMP_TYPE_PARAM_PROBLEM 12
63 #define RTE_ICMP_TYPE_TIMESTAMP_REQUEST 13
64 #define RTE_ICMP_TYPE_TIMESTAMP_REPLY 14
65 
66 /* Destination Unreachable codes */
67 #define RTE_ICMP_CODE_UNREACH_NET 0
68 #define RTE_ICMP_CODE_UNREACH_HOST 1
69 #define RTE_ICMP_CODE_UNREACH_PROTO 2
70 #define RTE_ICMP_CODE_UNREACH_PORT 3
71 #define RTE_ICMP_CODE_UNREACH_FRAG 4
72 #define RTE_ICMP_CODE_UNREACH_SRC 5
73 
74 /* Time Exceeded codes */
75 #define RTE_ICMP_CODE_TTL_EXCEEDED 0
76 #define RTE_ICMP_CODE_TTL_FRAG 1
77 
78 /* Redirect codes */
79 #define RTE_ICMP_CODE_REDIRECT_NET 0
80 #define RTE_ICMP_CODE_REDIRECT_HOST 1
81 #define RTE_ICMP_CODE_REDIRECT_TOS_NET 2
82 #define RTE_ICMP_CODE_REDIRECT_TOS_HOST 3
83 
84 #define RTE_ICMP6_ECHO_REQUEST 128
85 #define RTE_ICMP6_ECHO_REPLY   129
86 
87 #endif /* RTE_ICMP_H_ */
88