1 /* $FreeBSD: src/sys/netinet/icmp6.h,v 1.2.2.5 2002/06/29 18:31:11 ume Exp $ */
2 /* $DragonFly: src/sys/netinet/icmp6.h,v 1.3 2003/08/23 11:18:00 rob Exp $ */
3 /* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
35 * Copyright (c) 1982, 1986, 1993
36 * The Regents of the University of California. All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
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. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
69 #ifndef _NETINET_ICMP6_H_
70 #define _NETINET_ICMP6_H_
72 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
73 - sizeof(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 */
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 */
84 } __attribute__((__packed__));
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 */
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 */
100 #define ICMP6_ECHO_REQUEST 128 /* echo service */
101 #define ICMP6_ECHO_REPLY 129 /* echo reply */
102 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
103 #define MLD_LISTENER_QUERY 130 /* multicast listener query */
104 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
105 #define MLD_LISTENER_REPORT 131 /* multicast listener report */
106 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
107 #define MLD_LISTENER_DONE 132 /* multicast listener done */
110 /* the followings are for backward compatibility to old KAME apps. */
111 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
112 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
113 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
116 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
117 #define ND_ROUTER_ADVERT 134 /* router advertisment */
118 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
119 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
120 #define ND_REDIRECT 137 /* redirect */
122 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
124 #define ICMP6_WRUREQUEST 139 /* who are you request */
125 #define ICMP6_WRUREPLY 140 /* who are you reply */
126 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
127 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
128 #define ICMP6_NI_QUERY 139 /* node information request */
129 #define ICMP6_NI_REPLY 140 /* node information reply */
131 /* The definitions below are experimental. TBA */
132 #define MLD_MTRACE_RESP 200 /* mtrace resp (to sender) */
133 #define MLD_MTRACE 201 /* mtrace messages */
135 #define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */
136 #define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */
139 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
140 #define MLD6_MTRACE MLD_MTRACE
143 #define ICMP6_MAXTYPE 203
145 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
146 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
147 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
148 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
149 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
150 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
152 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
153 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
155 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
156 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
157 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
159 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
161 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
162 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
163 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
165 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
166 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
167 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
169 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
170 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
171 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
173 /* Used in kernel only */
174 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
175 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
178 * Multicast Listener Discovery
181 struct icmp6_hdr mld_icmp6_hdr;
182 struct in6_addr mld_addr; /* multicast address */
183 } __attribute__((__packed__));
185 /* definitions to provide backward compatibility to old KAME applications */
187 #define mld6_hdr mld_hdr
188 #define mld6_type mld_type
189 #define mld6_code mld_code
190 #define mld6_cksum mld_cksum
191 #define mld6_maxdelay mld_maxdelay
192 #define mld6_reserved mld_reserved
193 #define mld6_addr mld_addr
196 /* shortcut macro definitions */
197 #define mld_type mld_icmp6_hdr.icmp6_type
198 #define mld_code mld_icmp6_hdr.icmp6_code
199 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
200 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
201 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
207 struct nd_router_solicit { /* router solicitation */
208 struct icmp6_hdr nd_rs_hdr;
209 /* could be followed by options */
210 } __attribute__((__packed__));
212 #define nd_rs_type nd_rs_hdr.icmp6_type
213 #define nd_rs_code nd_rs_hdr.icmp6_code
214 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
215 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
217 struct nd_router_advert { /* router advertisement */
218 struct icmp6_hdr nd_ra_hdr;
219 u_int32_t nd_ra_reachable; /* reachable time */
220 u_int32_t nd_ra_retransmit; /* retransmit timer */
221 /* could be followed by options */
222 } __attribute__((__packed__));
224 #define nd_ra_type nd_ra_hdr.icmp6_type
225 #define nd_ra_code nd_ra_hdr.icmp6_code
226 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
227 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
228 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
229 #define ND_RA_FLAG_MANAGED 0x80
230 #define ND_RA_FLAG_OTHER 0x40
231 #define ND_RA_FLAG_HA 0x20
234 * Router preference values based on draft-draves-ipngwg-router-selection-01.
235 * These are non-standard definitions.
237 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
239 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
240 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
241 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
242 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
244 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
246 struct nd_neighbor_solicit { /* neighbor solicitation */
247 struct icmp6_hdr nd_ns_hdr;
248 struct in6_addr nd_ns_target; /*target address */
249 /* could be followed by options */
250 } __attribute__((__packed__));
252 #define nd_ns_type nd_ns_hdr.icmp6_type
253 #define nd_ns_code nd_ns_hdr.icmp6_code
254 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
255 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
257 struct nd_neighbor_advert { /* neighbor advertisement */
258 struct icmp6_hdr nd_na_hdr;
259 struct in6_addr nd_na_target; /* target address */
260 /* could be followed by options */
261 } __attribute__((__packed__));
263 #define nd_na_type nd_na_hdr.icmp6_type
264 #define nd_na_code nd_na_hdr.icmp6_code
265 #define nd_na_cksum nd_na_hdr.icmp6_cksum
266 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
267 #if BYTE_ORDER == BIG_ENDIAN
268 #define ND_NA_FLAG_ROUTER 0x80000000
269 #define ND_NA_FLAG_SOLICITED 0x40000000
270 #define ND_NA_FLAG_OVERRIDE 0x20000000
272 #if BYTE_ORDER == LITTLE_ENDIAN
273 #define ND_NA_FLAG_ROUTER 0x80
274 #define ND_NA_FLAG_SOLICITED 0x40
275 #define ND_NA_FLAG_OVERRIDE 0x20
279 struct nd_redirect { /* redirect */
280 struct icmp6_hdr nd_rd_hdr;
281 struct in6_addr nd_rd_target; /* target address */
282 struct in6_addr nd_rd_dst; /* destination address */
283 /* could be followed by options */
284 } __attribute__((__packed__));
286 #define nd_rd_type nd_rd_hdr.icmp6_type
287 #define nd_rd_code nd_rd_hdr.icmp6_code
288 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
289 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
291 struct nd_opt_hdr { /* Neighbor discovery option header */
292 u_int8_t nd_opt_type;
294 /* followed by option specific data*/
295 } __attribute__((__packed__));
297 #define ND_OPT_SOURCE_LINKADDR 1
298 #define ND_OPT_TARGET_LINKADDR 2
299 #define ND_OPT_PREFIX_INFORMATION 3
300 #define ND_OPT_REDIRECTED_HEADER 4
303 #define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
305 struct nd_opt_prefix_info { /* prefix information */
306 u_int8_t nd_opt_pi_type;
307 u_int8_t nd_opt_pi_len;
308 u_int8_t nd_opt_pi_prefix_len;
309 u_int8_t nd_opt_pi_flags_reserved;
310 u_int32_t nd_opt_pi_valid_time;
311 u_int32_t nd_opt_pi_preferred_time;
312 u_int32_t nd_opt_pi_reserved2;
313 struct in6_addr nd_opt_pi_prefix;
314 } __attribute__((__packed__));
316 #define ND_OPT_PI_FLAG_ONLINK 0x80
317 #define ND_OPT_PI_FLAG_AUTO 0x40
319 struct nd_opt_rd_hdr { /* redirected header */
320 u_int8_t nd_opt_rh_type;
321 u_int8_t nd_opt_rh_len;
322 u_int16_t nd_opt_rh_reserved1;
323 u_int32_t nd_opt_rh_reserved2;
324 /* followed by IP header and data */
325 } __attribute__((__packed__));
327 struct nd_opt_mtu { /* MTU option */
328 u_int8_t nd_opt_mtu_type;
329 u_int8_t nd_opt_mtu_len;
330 u_int16_t nd_opt_mtu_reserved;
331 u_int32_t nd_opt_mtu_mtu;
332 } __attribute__((__packed__));
334 struct nd_opt_route_info { /* route info */
335 u_int8_t nd_opt_rti_type;
336 u_int8_t nd_opt_rti_len;
337 u_int8_t nd_opt_rti_prefixlen;
338 u_int8_t nd_opt_rti_flags;
339 u_int32_t nd_opt_rti_lifetime;
341 } __attribute__((__packed__));
347 struct icmp6_namelookup {
348 struct icmp6_hdr icmp6_nl_hdr;
349 u_int8_t icmp6_nl_nonce[8];
350 int32_t icmp6_nl_ttl;
352 u_int8_t icmp6_nl_len;
353 u_int8_t icmp6_nl_name[3];
355 /* could be followed by options */
356 } __attribute__((__packed__));
359 * icmp6 node information
361 struct icmp6_nodeinfo {
362 struct icmp6_hdr icmp6_ni_hdr;
363 u_int8_t icmp6_ni_nonce[8];
364 /* could be followed by reply data */
365 } __attribute__((__packed__));
367 #define ni_type icmp6_ni_hdr.icmp6_type
368 #define ni_code icmp6_ni_hdr.icmp6_code
369 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
370 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
371 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
373 #define NI_QTYPE_NOOP 0 /* NOOP */
374 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
375 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
376 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
377 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
378 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
380 #if BYTE_ORDER == BIG_ENDIAN
381 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
382 #define NI_FQDN_FLAG_VALIDTTL 0x1
383 #elif BYTE_ORDER == LITTLE_ENDIAN
384 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
385 #define NI_FQDN_FLAG_VALIDTTL 0x0100
388 #ifdef NAME_LOOKUPS_04
389 #if BYTE_ORDER == BIG_ENDIAN
390 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
391 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
392 #define NI_NODEADDR_FLAG_GLOBAL 0x4
393 #define NI_NODEADDR_FLAG_ALL 0x8
394 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
395 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
396 #elif BYTE_ORDER == LITTLE_ENDIAN
397 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
398 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
399 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
400 #define NI_NODEADDR_FLAG_ALL 0x0800
401 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
402 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
404 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
405 #if BYTE_ORDER == BIG_ENDIAN
406 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
407 #define NI_NODEADDR_FLAG_ALL 0x2
408 #define NI_NODEADDR_FLAG_COMPAT 0x4
409 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
410 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
411 #define NI_NODEADDR_FLAG_GLOBAL 0x20
412 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
413 #elif BYTE_ORDER == LITTLE_ENDIAN
414 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
415 #define NI_NODEADDR_FLAG_ALL 0x0200
416 #define NI_NODEADDR_FLAG_COMPAT 0x0400
417 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
418 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
419 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
420 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
424 struct ni_reply_fqdn {
425 u_int32_t ni_fqdn_ttl; /* TTL */
426 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
427 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
428 } __attribute__((__packed__));
431 * Router Renumbering. as router-renum-08.txt
433 struct icmp6_router_renum { /* router renumbering header */
434 struct icmp6_hdr rr_hdr;
437 u_int16_t rr_maxdelay;
438 u_int32_t rr_reserved;
439 } __attribute__((__packed__));
441 #define ICMP6_RR_FLAGS_TEST 0x80
442 #define ICMP6_RR_FLAGS_REQRESULT 0x40
443 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
444 #define ICMP6_RR_FLAGS_SPECSITE 0x10
445 #define ICMP6_RR_FLAGS_PREVDONE 0x08
447 #define rr_type rr_hdr.icmp6_type
448 #define rr_code rr_hdr.icmp6_code
449 #define rr_cksum rr_hdr.icmp6_cksum
450 #define rr_seqnum rr_hdr.icmp6_data32[0]
452 struct rr_pco_match { /* match prefix part */
455 u_int8_t rpm_ordinal;
456 u_int8_t rpm_matchlen;
459 u_int16_t rpm_reserved;
460 struct in6_addr rpm_prefix;
461 } __attribute__((__packed__));
463 #define RPM_PCO_ADD 1
464 #define RPM_PCO_CHANGE 2
465 #define RPM_PCO_SETGLOBAL 3
466 #define RPM_PCO_MAX 4
468 struct rr_pco_use { /* use prefix part */
470 u_int8_t rpu_keeplen;
472 u_int8_t rpu_raflags;
473 u_int32_t rpu_vltime;
474 u_int32_t rpu_pltime;
476 struct in6_addr rpu_prefix;
477 } __attribute__((__packed__));
478 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
479 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
481 #if BYTE_ORDER == BIG_ENDIAN
482 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
483 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
484 #elif BYTE_ORDER == LITTLE_ENDIAN
485 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
486 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
489 struct rr_result { /* router renumbering result message */
491 u_int8_t rrr_ordinal;
492 u_int8_t rrr_matchedlen;
494 struct in6_addr rrr_prefix;
495 } __attribute__((__packed__));
496 #if BYTE_ORDER == BIG_ENDIAN
497 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
498 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
499 #elif BYTE_ORDER == LITTLE_ENDIAN
500 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
501 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
505 * icmp6 filter structures.
508 struct icmp6_filter {
509 u_int32_t icmp6_filt[8];
513 #define ICMP6_FILTER_SETPASSALL(filterp) \
516 p = (u_char *)filterp; \
517 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
520 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
521 bzero(filterp, sizeof(struct icmp6_filter))
523 #define ICMP6_FILTER_SETPASSALL(filterp) \
524 memset(filterp, 0xff, sizeof(struct icmp6_filter))
525 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
526 memset(filterp, 0x00, sizeof(struct icmp6_filter))
529 #define ICMP6_FILTER_SETPASS(type, filterp) \
530 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
531 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
532 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
533 #define ICMP6_FILTER_WILLPASS(type, filterp) \
534 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
535 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
536 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
539 * Variables related to this implementation
540 * of the internet control message protocol version 6.
542 struct icmp6errstat {
543 u_quad_t icp6errs_dst_unreach_noroute;
544 u_quad_t icp6errs_dst_unreach_admin;
545 u_quad_t icp6errs_dst_unreach_beyondscope;
546 u_quad_t icp6errs_dst_unreach_addr;
547 u_quad_t icp6errs_dst_unreach_noport;
548 u_quad_t icp6errs_packet_too_big;
549 u_quad_t icp6errs_time_exceed_transit;
550 u_quad_t icp6errs_time_exceed_reassembly;
551 u_quad_t icp6errs_paramprob_header;
552 u_quad_t icp6errs_paramprob_nextheader;
553 u_quad_t icp6errs_paramprob_option;
554 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
555 u_quad_t icp6errs_unknown;
559 /* statistics related to icmp6 packets generated */
560 u_quad_t icp6s_error; /* # of calls to icmp6_error */
561 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
562 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
563 u_quad_t icp6s_outhist[256];
564 /* statistics related to input message processed */
565 u_quad_t icp6s_badcode; /* icmp6_code out of range */
566 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
567 u_quad_t icp6s_checksum; /* bad checksum */
568 u_quad_t icp6s_badlen; /* calculated bound mismatch */
570 * number of responses: this member is inherited from netinet code, but
571 * for netinet6 code, it is already available in icp6s_outhist[].
573 u_quad_t icp6s_reflect;
574 u_quad_t icp6s_inhist[256];
575 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
576 struct icmp6errstat icp6s_outerrhist;
577 #define icp6s_odst_unreach_noroute \
578 icp6s_outerrhist.icp6errs_dst_unreach_noroute
579 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
580 #define icp6s_odst_unreach_beyondscope \
581 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
582 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
583 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
584 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
585 #define icp6s_otime_exceed_transit \
586 icp6s_outerrhist.icp6errs_time_exceed_transit
587 #define icp6s_otime_exceed_reassembly \
588 icp6s_outerrhist.icp6errs_time_exceed_reassembly
589 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
590 #define icp6s_oparamprob_nextheader \
591 icp6s_outerrhist.icp6errs_paramprob_nextheader
592 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
593 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
594 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
595 u_quad_t icp6s_pmtuchg; /* path MTU changes */
596 u_quad_t icp6s_nd_badopt; /* bad ND options */
597 u_quad_t icp6s_badns; /* bad neighbor solicitation */
598 u_quad_t icp6s_badna; /* bad neighbor advertisement */
599 u_quad_t icp6s_badrs; /* bad router advertisement */
600 u_quad_t icp6s_badra; /* bad router advertisement */
601 u_quad_t icp6s_badredirect; /* bad redirect message */
605 * Names for ICMP sysctl objects
607 #define ICMPV6CTL_STATS 1
608 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
609 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
611 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
613 #define ICMPV6CTL_ND6_PRUNE 6
614 #define ICMPV6CTL_ND6_DELAY 8
615 #define ICMPV6CTL_ND6_UMAXTRIES 9
616 #define ICMPV6CTL_ND6_MMAXTRIES 10
617 #define ICMPV6CTL_ND6_USELOOPBACK 11
618 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
619 #define ICMPV6CTL_NODEINFO 13
620 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
621 #define ICMPV6CTL_ND6_MAXNUDHINT 15
622 #define ICMPV6CTL_MTUDISC_HIWAT 16
623 #define ICMPV6CTL_MTUDISC_LOWAT 17
624 #define ICMPV6CTL_ND6_DEBUG 18
625 #define ICMPV6CTL_ND6_DRLIST 19
626 #define ICMPV6CTL_ND6_PRLIST 20
627 #define ICMPV6CTL_MAXID 21
629 #define ICMPV6CTL_NAMES { \
632 { "rediraccept", CTLTYPE_INT }, \
633 { "redirtimeout", CTLTYPE_INT }, \
636 { "nd6_prune", CTLTYPE_INT }, \
638 { "nd6_delay", CTLTYPE_INT }, \
639 { "nd6_umaxtries", CTLTYPE_INT }, \
640 { "nd6_mmaxtries", CTLTYPE_INT }, \
641 { "nd6_useloopback", CTLTYPE_INT }, \
643 { "nodeinfo", CTLTYPE_INT }, \
644 { "errppslimit", CTLTYPE_INT }, \
645 { "nd6_maxnudhint", CTLTYPE_INT }, \
646 { "mtudisc_hiwat", CTLTYPE_INT }, \
647 { "mtudisc_lowat", CTLTYPE_INT }, \
648 { "nd6_debug", CTLTYPE_INT }, \
653 #define RTF_PROBEMTU RTF_PROTO1
661 void icmp6_init (void);
662 void icmp6_paramerror (struct mbuf *, int);
663 void icmp6_error (struct mbuf *, int, int, int);
664 int icmp6_input (struct mbuf **, int *, int);
665 void icmp6_fasttimo (void);
666 void icmp6_reflect (struct mbuf *, size_t);
667 void icmp6_prepare (struct mbuf *);
668 void icmp6_redirect_input (struct mbuf *, int);
669 void icmp6_redirect_output (struct mbuf *, struct rtentry *);
672 void icmp6_mtudisc_update (struct ip6ctlparam *, int);
674 /* XXX: is this the right place for these macros? */
675 #define icmp6_ifstat_inc(ifp, tag) \
677 if ((ifp) && (ifp)->if_index <= if_index \
678 && (ifp)->if_index < icmp6_ifstatmax \
679 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
680 icmp6_ifstat[(ifp)->if_index]->tag++; \
684 #define icmp6_ifoutstat_inc(ifp, type, code) \
686 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
687 if (type < ICMP6_INFOMSG_MASK) \
688 icmp6_ifstat_inc(ifp, ifs6_out_error); \
690 case ICMP6_DST_UNREACH: \
691 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
692 if (code == ICMP6_DST_UNREACH_ADMIN) \
693 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
695 case ICMP6_PACKET_TOO_BIG: \
696 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
698 case ICMP6_TIME_EXCEEDED: \
699 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
701 case ICMP6_PARAM_PROB: \
702 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
704 case ICMP6_ECHO_REQUEST: \
705 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
707 case ICMP6_ECHO_REPLY: \
708 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
710 case MLD_LISTENER_QUERY: \
711 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
713 case MLD_LISTENER_REPORT: \
714 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
716 case MLD_LISTENER_DONE: \
717 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
719 case ND_ROUTER_SOLICIT: \
720 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
722 case ND_ROUTER_ADVERT: \
723 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
725 case ND_NEIGHBOR_SOLICIT: \
726 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
728 case ND_NEIGHBOR_ADVERT: \
729 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
732 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
737 extern int icmp6_rediraccept; /* accept/process redirects */
738 extern int icmp6_redirtimeout; /* cache time for redirect routes */
741 #endif /* not _NETINET_ICMP6_H_ */