icmpv6.h
7.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_icmpv6 ICMPV6
* @ingroup net_ipv6
* @brief Provides types related to ICMPv6
* @see <a href="https://tools.ietf.org/html/rfc4443">
* RFC 4443
* </a>
* @{
*
* @file
* @brief ICMPv6 type and function definitions
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef ICMPV6_H_
#define ICMPV6_H_
#include <stdint.h>
#include "byteorder.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @{
* @name Error message types
* @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2">
* IANA, ICMPv6 "type" Numbers
* </a>
*/
#define ICMPV6_DST_UNR (1) /**< Destination unreachable message */
#define ICMPV6_PKT_TOO_BIG (2) /**< Packet Too Big message */
#define ICMPV6_TIME_EXC (3) /**< Time Exceeded message */
#define ICMPV6_PARAM_PROB (4) /**< Parameter Problem message */
#define ICMPV6_ERR_EXP1 (100) /**< message type for private experimentation */
#define ICMPV6_ERR_EXP2 (101) /**< message type for private experimentation */
/**
* @}
*/
/**
* @{
* @name Informational message types
* @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-2">
* IANA, ICMPv6 "type" Numbers
* </a>
*/
#define ICMPV6_ECHO_REQ (128) /**< Echo request message (ping) */
#define ICMPV6_ECHO_REP (129) /**< Echo reply message (pong) */
#define ICMPV6_RTR_SOL (133) /**< NDP router solicitation message */
#define ICMPV6_RTR_ADV (134) /**< NDP router advertisement message */
#define ICMPV6_NBR_SOL (135) /**< NDP neighbor solicitation message */
#define ICMPV6_NBR_ADV (136) /**< NDP neighbor advertisement message */
#define ICMPV6_REDIRECT (137) /**< NDP redirect message */
#define ICMPV6_RPL_CTRL (155) /**< RPL control message */
#define ICMPV6_DAR (157) /**< Duplicate address request */
#define ICMPV6_DAC (158) /**< Duplicate address confirmation */
#define ICMPV6_INF_EXP1 (200) /**< message type for private experimentation */
#define ICMPV6_INF_EXP2 (201) /**< message type for private experimentation */
/**
* @}
*/
/**
* @{
* @name Codes for destination unreachable messages
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1">
* RFC 4443, section 3.1
* </a>
*/
#define ICMPV6_ERROR_DST_UNR_NO_ROUTE (0) /**< no route to destination */
#define ICMPV6_ERROR_DST_UNR_PROHIB (1) /**< communictation with
* destination administratively
* prohibited */
#define ICMPV6_ERROR_DST_UNR_SCOPE (2) /**< beyond scope of source address */
#define ICMPV6_ERROR_DST_UNR_ADDR (3) /**< address unreachable */
#define ICMPV6_ERROR_DST_UNR_PORT (4) /**< port unreachable */
#define ICMPV6_ERROR_DST_UNR_POLICY (5) /**< source address failed ingress/egress
* policy */
#define ICMPV6_ERROR_DST_UNR_REJECT (6) /**< reject route to destination */
/**
* @}
*/
/**
* @{
* @name Codes for time exceeded messages
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3">
* RFC 4443, section 3.3
* </a>
*/
#define ICMPV6_ERROR_TIME_EXC_HL (0) /**< hop limit exceeded in transit */
#define ICMPV6_ERROR_TIME_EXC_FRAG (1) /**< fragment reassembly time exceeded */
/**
* @}
*/
/**
* @{
* @name Codes for parameter problem messages
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4">
* RFC 4443, section 3.4
* </a>
*/
#define ICMPV6_ERROR_PARAM_PROB_HDR_FIELD (0) /**< errorneous header field
* encountered */
#define ICMPV6_ERROR_PARAM_PROB_NH (1) /**< unrecognized next header
* field encountered */
#define ICMPV6_ERROR_PARAM_PROB_OPT (2) /**< unrecognized IPv6 option
* field encountered */
/**
* @}
*/
/**
* @brief General ICMPv6 message format.
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-2.1">
* RFC 4443, section 2.1
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
} icmpv6_hdr_t;
/**
* @brief Destination unreachable message format.
* @extends icmpv6_hdr_t
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.1">
* RFC 4443, section 3.1
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint32_t unused; /**< unused field */
} icmpv6_error_dst_unr_t;
/**
* @brief Packet too big message format.
* @extends icmpv6_hdr_t
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.2">
* RFC 4443, section 3.2
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint32_t mtu; /**< MTU */
} icmpv6_error_pkt_too_big_t;
/**
* @brief Time exceeded message format.
* @extends icmpv6_hdr_t
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.3">
* RFC 4443, section 3.3
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint32_t unused; /**< unused field */
} icmpv6_error_time_exc_t;
/**
* @brief Parameter problem message format.
* @extends icmpv6_hdr_t
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-3.4">
* RFC 4443, section 3.3
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint32_t ptr; /**< pointer */
} icmpv6_error_param_prob_t;
/**
* @brief Echo request and response message format.
* @extends icmpv6_hdr_t
*
* @see <a href="https://tools.ietf.org/html/rfc4443#section-4.1">
* RFC 4443, section 4.1
* </a>
* @see <a href="https://tools.ietf.org/html/rfc4443#section-4.2">
* RFC 4443, section 4.2
* </a>
*/
typedef struct __attribute__((packed)) {
uint8_t type; /**< message type */
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint16_t id; /**< identifier */
network_uint16_t seq; /**< Sequence number */
} icmpv6_echo_t;
#ifdef __cplusplus
}
#endif
#endif /* ICMPV6_H_ */
/** @} */