icmp6.h revision 1.61 1 /* $NetBSD: icmp6.h,v 1.61 2024/12/06 18:36:09 riastradh Exp $ */
2 /* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
3
4
5 /*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 /*
35 * Copyright (c) 1982, 1986, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
63 */
64
65 #ifndef _NETINET_ICMP6_H_
66 #define _NETINET_ICMP6_H_
67
68 #include <sys/types.h>
69
70 #include <netinet/in.h>
71
72 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
73 - sizeof(struct icmp6_hdr) */
74
75 struct icmp6_hdr {
76 u_int8_t icmp6_type; /* type field */
77 u_int8_t icmp6_code; /* code field */
78 u_int16_t icmp6_cksum; /* checksum field */
79 union {
80 u_int32_t icmp6_un_data32[1]; /* type-specific field */
81 u_int16_t icmp6_un_data16[2]; /* type-specific field */
82 u_int8_t icmp6_un_data8[4]; /* type-specific field */
83 } icmp6_dataun;
84 };
85
86 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
87 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
88 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
89 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
90 #define icmp6_mtu icmp6_data32[0] /* packet too big */
91 #define icmp6_id icmp6_data16[0] /* echo request/reply */
92 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
93 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
94
95 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
96 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
97 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
98 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
99
100 #define ICMP6_ECHO_REQUEST 128 /* echo service */
101 #define ICMP6_ECHO_REPLY 129 /* echo reply */
102 #define MLD_LISTENER_QUERY 130 /* multicast listener query */
103 #define MLD_LISTENER_REPORT 131 /* multicast listener report */
104 #define MLD_LISTENER_DONE 132 /* multicast listener done */
105 #define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
106
107 /* RFC2292 decls */
108 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
109 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
110 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
111
112 #ifndef _KERNEL
113 /* the followings are for backward compatibility to old KAME apps. */
114 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
115 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
116 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
117 #endif
118
119 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
120 #define ND_ROUTER_ADVERT 134 /* router advertisement */
121 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
122 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
123 #define ND_REDIRECT 137 /* redirect */
124
125 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
126
127 #define ICMP6_WRUREQUEST 139 /* who are you request */
128 #define ICMP6_WRUREPLY 140 /* who are you reply */
129 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
130 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
131 #define ICMP6_NI_QUERY 139 /* node information request */
132 #define ICMP6_NI_REPLY 140 /* node information reply */
133 #define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
134
135 /* The definitions below are experimental. TBA */
136 #define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
137 #define MLD_MTRACE 201 /* mtrace messages */
138
139 #ifndef _KERNEL
140 /* the followings are for backward compatibility to old KAME apps. */
141 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
142 #define MLD6_MTRACE MLD_MTRACE
143 #endif
144
145 #define ICMP6_MAXTYPE 201
146
147 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
148 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
149 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
150 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
151 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
152 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
153 #define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */
154 #define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */
155 #define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */
156
157 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
158 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
159
160 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
161 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
162 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
163 #define ICMP6_PARAMPROB_FRAGMENT 3 /* incomplete chain in frag */
164
165 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
166
167 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
168 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
169 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
170
171 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
172 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
173 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
174
175 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
176 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
177 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
178
179 /* Used in kernel only */
180 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
181 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
182
183 /*
184 * Multicast Listener Discovery
185 */
186 struct mld_hdr {
187 struct icmp6_hdr mld_icmp6_hdr;
188 struct in6_addr mld_addr; /* multicast address */
189 };
190
191 /* definitions to provide backward compatibility to old KAME applications */
192 #ifndef _KERNEL
193 #define mld6_hdr mld_hdr
194 #define mld6_type mld_type
195 #define mld6_code mld_code
196 #define mld6_cksum mld_cksum
197 #define mld6_maxdelay mld_maxdelay
198 #define mld6_reserved mld_reserved
199 #define mld6_addr mld_addr
200 #endif
201
202 /* shortcut macro definitions */
203 #define mld_type mld_icmp6_hdr.icmp6_type
204 #define mld_code mld_icmp6_hdr.icmp6_code
205 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
206 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
207 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
208
209 #define MLD_MINLEN 24
210
211 /*
212 * Neighbor Discovery
213 */
214
215 struct nd_router_solicit { /* router solicitation */
216 struct icmp6_hdr nd_rs_hdr;
217 /* could be followed by options */
218 };
219
220 #define nd_rs_type nd_rs_hdr.icmp6_type
221 #define nd_rs_code nd_rs_hdr.icmp6_code
222 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
223 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
224
225 struct nd_router_advert { /* router advertisement */
226 struct icmp6_hdr nd_ra_hdr;
227 u_int32_t nd_ra_reachable; /* reachable time */
228 u_int32_t nd_ra_retransmit; /* retransmit timer */
229 /* could be followed by options */
230 };
231
232 #define nd_ra_type nd_ra_hdr.icmp6_type
233 #define nd_ra_code nd_ra_hdr.icmp6_code
234 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
235 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
236 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
237 #define ND_RA_FLAG_MANAGED 0x80
238 #define ND_RA_FLAG_OTHER 0x40
239 #define ND_RA_FLAG_HOME_AGENT 0x20
240 #define ND_RA_FLAG_PROXY 0x04
241
242 /*
243 * Router preference values based on RFC4191.
244 */
245 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
246
247 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
248 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
249 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
250 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
251
252 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
253
254 struct nd_neighbor_solicit { /* neighbor solicitation */
255 struct icmp6_hdr nd_ns_hdr;
256 struct in6_addr nd_ns_target; /*target address */
257 /* could be followed by options */
258 };
259
260 #define nd_ns_type nd_ns_hdr.icmp6_type
261 #define nd_ns_code nd_ns_hdr.icmp6_code
262 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
263 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
264
265 struct nd_neighbor_advert { /* neighbor advertisement */
266 struct icmp6_hdr nd_na_hdr;
267 struct in6_addr nd_na_target; /* target address */
268 /* could be followed by options */
269 };
270
271 #define nd_na_type nd_na_hdr.icmp6_type
272 #define nd_na_code nd_na_hdr.icmp6_code
273 #define nd_na_cksum nd_na_hdr.icmp6_cksum
274 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
275 #if BYTE_ORDER == BIG_ENDIAN
276 #define ND_NA_FLAG_ROUTER 0x80000000
277 #define ND_NA_FLAG_SOLICITED 0x40000000
278 #define ND_NA_FLAG_OVERRIDE 0x20000000
279 #else
280 #if BYTE_ORDER == LITTLE_ENDIAN
281 #define ND_NA_FLAG_ROUTER 0x80
282 #define ND_NA_FLAG_SOLICITED 0x40
283 #define ND_NA_FLAG_OVERRIDE 0x20
284 #endif
285 #endif
286
287 struct nd_redirect { /* redirect */
288 struct icmp6_hdr nd_rd_hdr;
289 struct in6_addr nd_rd_target; /* target address */
290 struct in6_addr nd_rd_dst; /* destination address */
291 /* could be followed by options */
292 };
293
294 #define nd_rd_type nd_rd_hdr.icmp6_type
295 #define nd_rd_code nd_rd_hdr.icmp6_code
296 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
297 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
298
299 struct nd_opt_hdr { /* Neighbor discovery option header */
300 u_int8_t nd_opt_type;
301 u_int8_t nd_opt_len;
302 /* followed by option specific data*/
303 };
304
305 #define ND_OPT_SOURCE_LINKADDR 1
306 #define ND_OPT_TARGET_LINKADDR 2
307 #define ND_OPT_PREFIX_INFORMATION 3
308 #define ND_OPT_REDIRECTED_HEADER 4
309 #define ND_OPT_MTU 5
310 #define ND_OPT_ADVINTERVAL 7
311 #define ND_OPT_HOMEAGENT_INFO 8
312 #define ND_OPT_SOURCE_ADDRLIST 9
313 #define ND_OPT_TARGET_ADDRLIST 10
314 #define ND_OPT_NONCE 14 /* RFC 3971 */
315 #define ND_OPT_MAP 23 /* RFC 5380 */
316 #define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
317 #define ND_OPT_RDNSS 25 /* RFC 6016 */
318 #define ND_OPT_DNSSL 31 /* RFC 6016 */
319 #define ND_OPT_MAX 31
320
321 struct nd_opt_route_info { /* route info */
322 u_int8_t nd_opt_rti_type;
323 u_int8_t nd_opt_rti_len;
324 u_int8_t nd_opt_rti_prefixlen;
325 u_int8_t nd_opt_rti_flags;
326 u_int32_t nd_opt_rti_lifetime;
327 /* prefix follows */
328 };
329
330 struct nd_opt_prefix_info { /* prefix information */
331 u_int8_t nd_opt_pi_type;
332 u_int8_t nd_opt_pi_len;
333 u_int8_t nd_opt_pi_prefix_len;
334 u_int8_t nd_opt_pi_flags_reserved;
335 u_int32_t nd_opt_pi_valid_time;
336 u_int32_t nd_opt_pi_preferred_time;
337 u_int32_t nd_opt_pi_reserved2;
338 struct in6_addr nd_opt_pi_prefix;
339 };
340
341 #define ND_OPT_PI_FLAG_ONLINK 0x80
342 #define ND_OPT_PI_FLAG_AUTO 0x40
343 #define ND_OPT_PI_FLAG_ROUTER 0x20
344
345 struct nd_opt_rd_hdr { /* redirected header */
346 u_int8_t nd_opt_rh_type;
347 u_int8_t nd_opt_rh_len;
348 u_int16_t nd_opt_rh_reserved1;
349 u_int32_t nd_opt_rh_reserved2;
350 /* followed by IP header and data */
351 };
352
353 struct nd_opt_mtu { /* MTU option */
354 u_int8_t nd_opt_mtu_type;
355 u_int8_t nd_opt_mtu_len;
356 u_int16_t nd_opt_mtu_reserved;
357 u_int32_t nd_opt_mtu_mtu;
358 };
359
360 #define ND_OPT_NONCE_LEN ((1 * 8) - 2)
361 #if ((ND_OPT_NONCE_LEN + 2) % 8) != 0
362 #error "(ND_OPT_NONCE_LEN + 2) must be a multiple of 8."
363 #endif
364 struct nd_opt_nonce {
365 u_int8_t nd_opt_nonce_type;
366 u_int8_t nd_opt_nonce_len;
367 u_int8_t nd_opt_nonce[ND_OPT_NONCE_LEN];
368 };
369
370 struct nd_opt_rdnss { /* RDNSS option RFC 6106 */
371 u_int8_t nd_opt_rdnss_type;
372 u_int8_t nd_opt_rdnss_len;
373 u_int16_t nd_opt_rdnss_reserved;
374 u_int32_t nd_opt_rdnss_lifetime;
375 /* followed by list of IP prefixes */
376 };
377
378 struct nd_opt_dnssl { /* DNSSL option RFC 6106 */
379 u_int8_t nd_opt_dnssl_type;
380 u_int8_t nd_opt_dnssl_len;
381 u_int16_t nd_opt_dnssl_reserved;
382 u_int32_t nd_opt_dnssl_lifetime;
383 /* followed by list of IP prefixes */
384 };
385
386 /*
387 * icmp6 namelookup
388 */
389
390 struct icmp6_namelookup {
391 struct icmp6_hdr icmp6_nl_hdr;
392 u_int8_t icmp6_nl_nonce[8];
393 int32_t icmp6_nl_ttl;
394 #if 0
395 u_int8_t icmp6_nl_len;
396 u_int8_t icmp6_nl_name[3];
397 #endif
398 /* could be followed by options */
399 };
400
401 /*
402 * icmp6 node information
403 */
404 struct icmp6_nodeinfo {
405 struct icmp6_hdr icmp6_ni_hdr;
406 u_int8_t icmp6_ni_nonce[8];
407 /* could be followed by reply data */
408 };
409
410 #define ni_type icmp6_ni_hdr.icmp6_type
411 #define ni_code icmp6_ni_hdr.icmp6_code
412 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
413 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
414 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
415
416 #define NI_QTYPE_NOOP 0 /* NOOP */
417 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
418 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
419 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
420 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
421 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
422
423 #if BYTE_ORDER == BIG_ENDIAN
424 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
425 #define NI_FQDN_FLAG_VALIDTTL 0x1
426 #elif BYTE_ORDER == LITTLE_ENDIAN
427 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
428 #define NI_FQDN_FLAG_VALIDTTL 0x0100
429 #endif
430
431 #ifdef NAME_LOOKUPS_04
432 #if BYTE_ORDER == BIG_ENDIAN
433 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
434 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
435 #define NI_NODEADDR_FLAG_GLOBAL 0x4
436 #define NI_NODEADDR_FLAG_ALL 0x8
437 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
438 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
439 #elif BYTE_ORDER == LITTLE_ENDIAN
440 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
441 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
442 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
443 #define NI_NODEADDR_FLAG_ALL 0x0800
444 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
445 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
446 #endif
447 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
448 #if BYTE_ORDER == BIG_ENDIAN
449 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
450 #define NI_NODEADDR_FLAG_ALL 0x2
451 #define NI_NODEADDR_FLAG_COMPAT 0x4
452 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
453 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
454 #define NI_NODEADDR_FLAG_GLOBAL 0x20
455 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
456 #elif BYTE_ORDER == LITTLE_ENDIAN
457 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
458 #define NI_NODEADDR_FLAG_ALL 0x0200
459 #define NI_NODEADDR_FLAG_COMPAT 0x0400
460 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
461 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
462 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
463 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
464 #endif
465 #endif
466
467 struct ni_reply_fqdn {
468 u_int32_t ni_fqdn_ttl; /* TTL */
469 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
470 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
471 };
472
473 /*
474 * Router Renumbering. as router-renum-08.txt
475 */
476 struct icmp6_router_renum { /* router renumbering header */
477 struct icmp6_hdr rr_hdr;
478 u_int8_t rr_segnum;
479 u_int8_t rr_flags;
480 u_int16_t rr_maxdelay;
481 u_int32_t rr_reserved;
482 };
483
484 #define ICMP6_RR_FLAGS_TEST 0x80
485 #define ICMP6_RR_FLAGS_REQRESULT 0x40
486 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
487 #define ICMP6_RR_FLAGS_SPECSITE 0x10
488 #define ICMP6_RR_FLAGS_PREVDONE 0x08
489
490 #define rr_type rr_hdr.icmp6_type
491 #define rr_code rr_hdr.icmp6_code
492 #define rr_cksum rr_hdr.icmp6_cksum
493 #define rr_seqnum rr_hdr.icmp6_data32[0]
494
495 struct rr_pco_match { /* match prefix part */
496 u_int8_t rpm_code;
497 u_int8_t rpm_len;
498 u_int8_t rpm_ordinal;
499 u_int8_t rpm_matchlen;
500 u_int8_t rpm_minlen;
501 u_int8_t rpm_maxlen;
502 u_int16_t rpm_reserved;
503 struct in6_addr rpm_prefix;
504 };
505
506 #define RPM_PCO_ADD 1
507 #define RPM_PCO_CHANGE 2
508 #define RPM_PCO_SETGLOBAL 3
509 #define RPM_PCO_MAX 4
510
511 struct rr_pco_use { /* use prefix part */
512 u_int8_t rpu_uselen;
513 u_int8_t rpu_keeplen;
514 u_int8_t rpu_ramask;
515 u_int8_t rpu_raflags;
516 u_int32_t rpu_vltime;
517 u_int32_t rpu_pltime;
518 u_int32_t rpu_flags;
519 struct in6_addr rpu_prefix;
520 };
521 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
522 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
523
524 #if BYTE_ORDER == BIG_ENDIAN
525 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
526 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
527 #elif BYTE_ORDER == LITTLE_ENDIAN
528 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
529 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
530 #endif
531
532 struct rr_result { /* router renumbering result message */
533 u_int16_t rrr_flags;
534 u_int8_t rrr_ordinal;
535 u_int8_t rrr_matchedlen;
536 u_int32_t rrr_ifid;
537 struct in6_addr rrr_prefix;
538 };
539 #if BYTE_ORDER == BIG_ENDIAN
540 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
541 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
542 #elif BYTE_ORDER == LITTLE_ENDIAN
543 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
544 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
545 #endif
546
547 /*
548 * icmp6 filter structures.
549 */
550
551 struct icmp6_filter {
552 u_int32_t icmp6_filt[8];
553 };
554
555 #define ICMP6_FILTER_SETPASSALL(filterp) \
556 (void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
557 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
558 (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
559 #define ICMP6_FILTER_SETPASS(type, filterp) \
560 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
561 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
562 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
563 #define ICMP6_FILTER_WILLPASS(type, filterp) \
564 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
565 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
566 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
567
568 /*
569 * Variables related to this implementation
570 * of the internet control message protocol version 6.
571 */
572
573 /*
574 * IPv6 ICMP statistics.
575 * Each counter is an unsigned 64-bit value.
576 */
577 #define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */
578 #define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */
579 #define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */
580 #define ICMP6_STAT_OUTHIST 3 /* # of output messages */
581 /* space for 256 counters */
582 #define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */
583 #define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */
584 #define ICMP6_STAT_CHECKSUM 261 /* bad checksum */
585 #define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */
586 /*
587 * number of responses; this member is inherited from the netinet code,
588 * but for netinet6 code, it is already available in outhist[].
589 */
590 #define ICMP6_STAT_REFLECT 263
591 #define ICMP6_STAT_INHIST 264 /* # of input messages */
592 /* space for 256 counters */
593 #define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */
594 #define ICMP6_STAT_OUTERRHIST 521
595 /* space for 13 counters */
596 #define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */
597 #define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */
598 #define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */
599 #define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */
600 #define ICMP6_STAT_BADRS 538 /* bad router solicitiation */
601 #define ICMP6_STAT_BADRA 539 /* bad router advertisement */
602 #define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */
603 #define ICMP6_STAT_DROPPED_RAROUTE 541 /* discarded routes from router advertisement */
604
605 #define ICMP6_NSTATS 542
606
607 #define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0
608 #define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1
609 #define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2
610 #define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3
611 #define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4
612 #define ICMP6_ERRSTAT_PACKET_TOO_BIG 5
613 #define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6
614 #define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7
615 #define ICMP6_ERRSTAT_PARAMPROB_HEADER 8
616 #define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9
617 #define ICMP6_ERRSTAT_PARAMPROB_OPTION 10
618 #define ICMP6_ERRSTAT_REDIRECT 11
619 #define ICMP6_ERRSTAT_UNKNOWN 12
620
621 /*
622 * Names for ICMP sysctl objects
623 */
624 #define ICMPV6CTL_STATS 1
625 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
626 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
627 #if 0 /*obsoleted*/
628 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
629 #endif
630 #define ICMPV6CTL_ND6_PRUNE 6
631 #define ICMPV6CTL_ND6_DELAY 8
632 #define ICMPV6CTL_ND6_UMAXTRIES 9
633 #define ICMPV6CTL_ND6_MMAXTRIES 10
634 #define ICMPV6CTL_ND6_USELOOPBACK 11
635 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
636 #define ICMPV6CTL_NODEINFO 13
637 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
638 #define ICMPV6CTL_ND6_MAXNUDHINT 15
639 #define ICMPV6CTL_MTUDISC_HIWAT 16
640 #define ICMPV6CTL_MTUDISC_LOWAT 17
641 #define ICMPV6CTL_ND6_DEBUG 18
642 #ifdef _KERNEL
643 #define OICMPV6CTL_ND6_DRLIST 19
644 #define OICMPV6CTL_ND6_PRLIST 20
645 #endif
646 #define ICMPV6CTL_ND6_MAXQLEN 24
647 #define ICMPV6CTL_REFLECT_PMTU 25
648 #define ICMPV6CTL_DYNAMIC_RT_MSG 26
649
650 #ifdef _KERNEL
651 struct rtentry;
652
653 void icmp6_init(void);
654 void icmp6_paramerror(struct mbuf *, int);
655 void icmp6_error(struct mbuf *, int, int, int);
656 void icmp6_error2(struct mbuf *, int, int, int, struct ifnet *,
657 struct in6_addr *);
658 int icmp6_input(struct mbuf **, int *, int);
659 void icmp6_fasttimo(void);
660 void icmp6_prepare(struct mbuf *);
661 void icmp6_redirect_output(struct mbuf *, struct rtentry *);
662 int icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
663
664 void icmp6_statinc(u_int);
665
666 struct ip6ctlparam;
667 void icmp6_mtudisc_update(struct ip6ctlparam *, int);
668 void icmp6_mtudisc_callback_register(void (*)(struct in6_addr *));
669
670 /* XXX: is this the right place for these macros? */
671 #define icmp6_ifstat_inc(ifp, tag) \
672 do { \
673 if (ifp) \
674 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
675 } while (/*CONSTCOND*/ 0)
676
677 #define icmp6_ifoutstat_inc(ifp, type, code) \
678 do { \
679 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
680 switch(type) { \
681 case ICMP6_DST_UNREACH: \
682 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
683 if (code == ICMP6_DST_UNREACH_ADMIN) \
684 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
685 break; \
686 case ICMP6_PACKET_TOO_BIG: \
687 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
688 break; \
689 case ICMP6_TIME_EXCEEDED: \
690 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
691 break; \
692 case ICMP6_PARAM_PROB: \
693 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
694 break; \
695 case ICMP6_ECHO_REQUEST: \
696 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
697 break; \
698 case ICMP6_ECHO_REPLY: \
699 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
700 break; \
701 case MLD_LISTENER_QUERY: \
702 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
703 break; \
704 case MLD_LISTENER_REPORT: \
705 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
706 break; \
707 case MLD_LISTENER_DONE: \
708 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
709 break; \
710 case ND_ROUTER_SOLICIT: \
711 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
712 break; \
713 case ND_ROUTER_ADVERT: \
714 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
715 break; \
716 case ND_NEIGHBOR_SOLICIT: \
717 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
718 break; \
719 case ND_NEIGHBOR_ADVERT: \
720 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
721 break; \
722 case ND_REDIRECT: \
723 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
724 break; \
725 } \
726 } while (/*CONSTCOND*/ 0)
727
728 extern int icmp6_rediraccept; /* accept/process redirects */
729 extern int icmp6_redirtimeout; /* cache time for redirect routes */
730 #endif /* _KERNEL */
731
732 #ifdef ICMP6_STRINGS
733 /* Info: http://www.iana.org/assignments/icmpv6-parameters */
734
735 static const char * const icmp6_type_err[] = {
736 "reserved0", "unreach", "packet_too_big", "timxceed", "paramprob",
737 NULL
738 };
739
740 static const char * const icmp6_type_info[] = {
741 "echo", "echoreply",
742 "mcastlistenq", "mcastlistenrep", "mcastlistendone",
743 "rtsol", "rtadv", "neighsol", "neighadv", "redirect",
744 "routerrenum", "nodeinfoq", "nodeinfor", "invneighsol", "invneighrep",
745 "mcastlistenrep2", "haad_req", "haad_rep",
746 "mobile_psol", "mobile_padv", "cga_sol", "cga_adv",
747 "experimental150", "mcast_rtadv", "mcast_rtsol", "mcast_rtterm",
748 "fmipv6_msg", "rpl_control", NULL
749 };
750
751 static const char * const icmp6_code_none[] = { "none", NULL };
752
753 static const char * const icmp6_code_unreach[] = {
754 "noroute", "admin", "beyondscope", "addr", "port",
755 "srcaddr_policy", "reject_route", "source_route_err", NULL
756 };
757
758 static const char * const icmp6_code_timxceed[] = {
759 "intrans", "reass", NULL
760 };
761
762 static const char * const icmp6_code_paramprob[] = {
763 "hdr_field", "nxthdr_type", "option", NULL
764 };
765
766 /* not all informational icmps that have codes have a names array */
767 #endif
768
769 #endif /* !_NETINET_ICMP6_H_ */
770