]> The Tcpdump Group git mirrors - tcpdump/blob - icmp6.h
Patch sent to Debian by Roderick Schertler <[email protected]> to print
[tcpdump] / icmp6.h
1 /* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */
2 /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
3
4 /*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33 /*
34 * Copyright (c) 1982, 1986, 1993
35 * The Regents of the University of California. All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE.
64 *
65 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
66 */
67
68 #ifndef _NETINET_ICMP6_H_
69 #define _NETINET_ICMP6_H_
70
71 struct icmp6_hdr {
72 u_int8_t icmp6_type; /* type field */
73 u_int8_t icmp6_code; /* code field */
74 u_int16_t icmp6_cksum; /* checksum field */
75 union {
76 u_int32_t icmp6_un_data32[1]; /* type-specific field */
77 u_int16_t icmp6_un_data16[2]; /* type-specific field */
78 u_int8_t icmp6_un_data8[4]; /* type-specific field */
79 } icmp6_dataun;
80 };
81
82 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
83 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
84 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
85 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
86 #define icmp6_mtu icmp6_data32[0] /* packet too big */
87 #define icmp6_id icmp6_data16[0] /* echo request/reply */
88 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
89 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
90
91 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
92 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
93 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
94 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
95
96 #define ICMP6_ECHO_REQUEST 128 /* echo service */
97 #define ICMP6_ECHO_REPLY 129 /* echo reply */
98 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
99 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
100 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
101 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
102 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
103 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
104
105 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
106 #define ND_ROUTER_ADVERT 134 /* router advertisment */
107 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
108 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
109 #define ND_REDIRECT 137 /* redirect */
110
111 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
112
113 #define ICMP6_WRUREQUEST 139 /* who are you request */
114 #define ICMP6_WRUREPLY 140 /* who are you reply */
115 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
116 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
117 #define ICMP6_NI_QUERY 139 /* node information request */
118 #define ICMP6_NI_REPLY 140 /* node information reply */
119
120 /* The definitions below are experimental. TBA */
121 #define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */
122 #define MLD6_MTRACE 142 /* mtrace messages */
123
124 #define ICMP6_MAXTYPE 142
125
126 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
127 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
128 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
129 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
130 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
131 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
132
133 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
134 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
135
136 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
137 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
138 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
139
140 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
141
142 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
143 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
144 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
145
146 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
147 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
148 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
149
150 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
151 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
152 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
153
154 /* Used in kernel only */
155 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
156 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
157
158 /*
159 * Multicast Listener Discovery
160 */
161 struct mld6_hdr {
162 struct icmp6_hdr mld6_hdr;
163 struct in6_addr mld6_addr; /* multicast address */
164 };
165
166 #define mld6_type mld6_hdr.icmp6_type
167 #define mld6_code mld6_hdr.icmp6_code
168 #define mld6_cksum mld6_hdr.icmp6_cksum
169 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
170 #define mld6_reserved mld6_hdr.icmp6_data16[1]
171
172 /*
173 * Neighbor Discovery
174 */
175
176 struct nd_router_solicit { /* router solicitation */
177 struct icmp6_hdr nd_rs_hdr;
178 /* could be followed by options */
179 };
180
181 #define nd_rs_type nd_rs_hdr.icmp6_type
182 #define nd_rs_code nd_rs_hdr.icmp6_code
183 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
184 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
185
186 struct nd_router_advert { /* router advertisement */
187 struct icmp6_hdr nd_ra_hdr;
188 u_int32_t nd_ra_reachable; /* reachable time */
189 u_int32_t nd_ra_retransmit; /* retransmit timer */
190 /* could be followed by options */
191 };
192
193 #define nd_ra_type nd_ra_hdr.icmp6_type
194 #define nd_ra_code nd_ra_hdr.icmp6_code
195 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
196 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
197 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
198 #define ND_RA_FLAG_MANAGED 0x80
199 #define ND_RA_FLAG_OTHER 0x40
200 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
201
202 struct nd_neighbor_solicit { /* neighbor solicitation */
203 struct icmp6_hdr nd_ns_hdr;
204 struct in6_addr nd_ns_target; /*target address */
205 /* could be followed by options */
206 };
207
208 #define nd_ns_type nd_ns_hdr.icmp6_type
209 #define nd_ns_code nd_ns_hdr.icmp6_code
210 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
211 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
212
213 struct nd_neighbor_advert { /* neighbor advertisement */
214 struct icmp6_hdr nd_na_hdr;
215 struct in6_addr nd_na_target; /* target address */
216 /* could be followed by options */
217 };
218
219 #define nd_na_type nd_na_hdr.icmp6_type
220 #define nd_na_code nd_na_hdr.icmp6_code
221 #define nd_na_cksum nd_na_hdr.icmp6_cksum
222 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
223 /* netowkr endian */
224 #define ND_NA_FLAG_ROUTER ((u_int32_t)htonl(0x80000000))
225 #define ND_NA_FLAG_SOLICITED ((u_int32_t)htonl(0x40000000))
226 #define ND_NA_FLAG_OVERRIDE ((u_int32_t)htonl(0x20000000))
227
228 struct nd_redirect { /* redirect */
229 struct icmp6_hdr nd_rd_hdr;
230 struct in6_addr nd_rd_target; /* target address */
231 struct in6_addr nd_rd_dst; /* destination address */
232 /* could be followed by options */
233 };
234
235 #define nd_rd_type nd_rd_hdr.icmp6_type
236 #define nd_rd_code nd_rd_hdr.icmp6_code
237 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
238 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
239
240 struct nd_opt_hdr { /* Neighbor discovery option header */
241 u_int8_t nd_opt_type;
242 u_int8_t nd_opt_len;
243 /* followed by option specific data*/
244 };
245
246 #define ND_OPT_SOURCE_LINKADDR 1
247 #define ND_OPT_TARGET_LINKADDR 2
248 #define ND_OPT_PREFIX_INFORMATION 3
249 #define ND_OPT_REDIRECTED_HEADER 4
250 #define ND_OPT_MTU 5
251
252 struct nd_opt_prefix_info { /* prefix information */
253 u_int8_t nd_opt_pi_type;
254 u_int8_t nd_opt_pi_len;
255 u_int8_t nd_opt_pi_prefix_len;
256 u_int8_t nd_opt_pi_flags_reserved;
257 u_int32_t nd_opt_pi_valid_time;
258 u_int32_t nd_opt_pi_preferred_time;
259 u_int32_t nd_opt_pi_reserved2;
260 struct in6_addr nd_opt_pi_prefix;
261 };
262
263 #define ND_OPT_PI_FLAG_ONLINK 0x80
264 #define ND_OPT_PI_FLAG_AUTO 0x40
265
266 struct nd_opt_rd_hdr { /* redirected header */
267 u_int8_t nd_opt_rh_type;
268 u_int8_t nd_opt_rh_len;
269 u_int16_t nd_opt_rh_reserved1;
270 u_int32_t nd_opt_rh_reserved2;
271 /* followed by IP header and data */
272 };
273
274 struct nd_opt_mtu { /* MTU option */
275 u_int8_t nd_opt_mtu_type;
276 u_int8_t nd_opt_mtu_len;
277 u_int16_t nd_opt_mtu_reserved;
278 u_int32_t nd_opt_mtu_mtu;
279 };
280
281 /*
282 * icmp6 namelookup
283 */
284
285 struct icmp6_namelookup {
286 struct icmp6_hdr icmp6_nl_hdr;
287 u_int8_t icmp6_nl_nonce[8];
288 int32_t icmp6_nl_ttl;
289 #if 0
290 u_int8_t icmp6_nl_len;
291 u_int8_t icmp6_nl_name[3];
292 #endif
293 /* could be followed by options */
294 };
295
296 /*
297 * icmp6 node information
298 */
299 struct icmp6_nodeinfo {
300 struct icmp6_hdr icmp6_ni_hdr;
301 u_int8_t icmp6_ni_nonce[8];
302 /* could be followed by reply data */
303 };
304
305 #define ni_type icmp6_ni_hdr.icmp6_type
306 #define ni_code icmp6_ni_hdr.icmp6_code
307 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
308 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
309 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
310
311 #define NI_QTYPE_NOOP 0 /* NOOP */
312 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
313 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
314 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
315 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
316 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
317
318 /* network endian */
319 #define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
320 #define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
321
322 /* network endian */
323 #define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
324 #define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
325 #define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
326 #define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
327 #define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
328 #define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
329 #define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
330
331 struct ni_reply_fqdn {
332 u_int32_t ni_fqdn_ttl; /* TTL */
333 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
334 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
335 };
336
337 /*
338 * Router Renumbering. as router-renum-08.txt
339 */
340 struct icmp6_router_renum { /* router renumbering header */
341 struct icmp6_hdr rr_hdr;
342 u_int8_t rr_segnum;
343 u_int8_t rr_flags;
344 u_int16_t rr_maxdelay;
345 u_int32_t rr_reserved;
346 };
347 #define ICMP6_RR_FLAGS_SEGNUM 0x80
348 #define ICMP6_RR_FLAGS_TEST 0x40
349 #define ICMP6_RR_FLAGS_REQRESULT 0x20
350 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x10
351 #define ICMP6_RR_FLAGS_SPECSITE 0x08
352 #define ICMP6_RR_FLAGS_PREVDONE 0x04
353
354 #define rr_type rr_hdr.icmp6_type
355 #define rr_code rr_hdr.icmp6_code
356 #define rr_cksum rr_hdr.icmp6_cksum
357 #define rr_seqnum rr_hdr.icmp6_data32[0]
358
359 struct rr_pco_match { /* match prefix part */
360 u_int8_t rpm_code;
361 u_int8_t rpm_len;
362 u_int8_t rpm_ordinal;
363 u_int8_t rpm_matchlen;
364 u_int8_t rpm_minlen;
365 u_int8_t rpm_maxlen;
366 u_int16_t rpm_reserved;
367 struct in6_addr rpm_prefix;
368 };
369
370 #define RPM_PCO_ADD 1
371 #define RPM_PCO_CHANGE 2
372 #define RPM_PCO_SETGLOBAL 3
373 #define RPM_PCO_MAX 4
374
375 struct rr_pco_use { /* use prefix part */
376 u_int8_t rpu_uselen;
377 u_int8_t rpu_keeplen;
378 u_int8_t rpu_ramask;
379 u_int8_t rpu_raflags;
380 u_int32_t rpu_vltime;
381 u_int32_t rpu_pltime;
382 u_int32_t rpu_flags;
383 struct in6_addr rpu_prefix;
384 };
385 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
386 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
387
388 /* network endian */
389 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
390 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
391
392 struct rr_result { /* router renumbering result message */
393 u_int16_t rrr_flags;
394 u_int8_t rrr_ordinal;
395 u_int8_t rrr_matchedlen;
396 u_int32_t rrr_ifid;
397 struct in6_addr rrr_prefix;
398 };
399 /* network endian */
400 #define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
401 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
402
403 #endif /* not _NETINET_ICMP6_H_ */