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