1 /* $NetBSD: icmp6.h,v 1.39 2008/07/11 07:35:05 cyber Exp $ */
2 /* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 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. 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.
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
62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
65 #ifndef _NETINET_ICMP6_H_
66 #define _NETINET_ICMP6_H_
68 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
69 - sizeof(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 */
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 */
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 */
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 */
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 */
103 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
104 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
105 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
108 /* the followings are for backward compatibility to old KAME apps. */
109 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
110 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
111 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
114 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
115 #define ND_ROUTER_ADVERT 134 /* router advertisement */
116 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
117 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
118 #define ND_REDIRECT 137 /* redirect */
120 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
122 #define ICMP6_WRUREQUEST 139 /* who are you request */
123 #define ICMP6_WRUREPLY 140 /* who are you reply */
124 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
125 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
126 #define ICMP6_NI_QUERY 139 /* node information request */
127 #define ICMP6_NI_REPLY 140 /* node information reply */
129 /* The definitions below are experimental. TBA */
130 #define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
131 #define MLD_MTRACE 201 /* mtrace messages */
134 /* the followings are for backward compatibility to old KAME apps. */
135 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
136 #define MLD6_MTRACE MLD_MTRACE
139 #define ICMP6_MAXTYPE 201
141 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
142 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
143 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
144 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
145 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
146 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
148 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
149 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
151 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
152 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
153 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
155 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
157 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
158 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
159 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
161 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
162 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
163 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
165 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
166 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
167 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
169 /* Used in kernel only */
170 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
171 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
174 * Multicast Listener Discovery
177 struct icmp6_hdr mld_icmp6_hdr
;
178 struct in6_addr mld_addr
; /* multicast address */
181 /* definitions to provide backward compatibility to old KAME applications */
183 #define mld6_hdr mld_hdr
184 #define mld6_type mld_type
185 #define mld6_code mld_code
186 #define mld6_cksum mld_cksum
187 #define mld6_maxdelay mld_maxdelay
188 #define mld6_reserved mld_reserved
189 #define mld6_addr mld_addr
192 /* shortcut macro definitions */
193 #define mld_type mld_icmp6_hdr.icmp6_type
194 #define mld_code mld_icmp6_hdr.icmp6_code
195 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
196 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
197 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
199 #define MLD_MINLEN 24
205 struct nd_router_solicit
{ /* router solicitation */
206 struct icmp6_hdr nd_rs_hdr
;
207 /* could be followed by options */
210 #define nd_rs_type nd_rs_hdr.icmp6_type
211 #define nd_rs_code nd_rs_hdr.icmp6_code
212 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
213 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
215 struct nd_router_advert
{ /* router advertisement */
216 struct icmp6_hdr nd_ra_hdr
;
217 u_int32_t nd_ra_reachable
; /* reachable time */
218 u_int32_t nd_ra_retransmit
; /* retransmit timer */
219 /* could be followed by options */
222 #define nd_ra_type nd_ra_hdr.icmp6_type
223 #define nd_ra_code nd_ra_hdr.icmp6_code
224 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
225 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
226 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
227 #define ND_RA_FLAG_MANAGED 0x80
228 #define ND_RA_FLAG_OTHER 0x40
229 #define ND_RA_FLAG_HOME_AGENT 0x20
232 * Router preference values based on RFC4199.
234 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
236 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
237 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
238 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
239 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
241 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
243 struct nd_neighbor_solicit
{ /* neighbor solicitation */
244 struct icmp6_hdr nd_ns_hdr
;
245 struct in6_addr nd_ns_target
; /*target address */
246 /* could be followed by options */
249 #define nd_ns_type nd_ns_hdr.icmp6_type
250 #define nd_ns_code nd_ns_hdr.icmp6_code
251 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
252 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
254 struct nd_neighbor_advert
{ /* neighbor advertisement */
255 struct icmp6_hdr nd_na_hdr
;
256 struct in6_addr nd_na_target
; /* target address */
257 /* could be followed by options */
260 #define nd_na_type nd_na_hdr.icmp6_type
261 #define nd_na_code nd_na_hdr.icmp6_code
262 #define nd_na_cksum nd_na_hdr.icmp6_cksum
263 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
264 #if BYTE_ORDER == BIG_ENDIAN
265 #define ND_NA_FLAG_ROUTER 0x80000000
266 #define ND_NA_FLAG_SOLICITED 0x40000000
267 #define ND_NA_FLAG_OVERRIDE 0x20000000
269 #if BYTE_ORDER == LITTLE_ENDIAN
270 #define ND_NA_FLAG_ROUTER 0x80
271 #define ND_NA_FLAG_SOLICITED 0x40
272 #define ND_NA_FLAG_OVERRIDE 0x20
276 struct nd_redirect
{ /* redirect */
277 struct icmp6_hdr nd_rd_hdr
;
278 struct in6_addr nd_rd_target
; /* target address */
279 struct in6_addr nd_rd_dst
; /* destination address */
280 /* could be followed by options */
283 #define nd_rd_type nd_rd_hdr.icmp6_type
284 #define nd_rd_code nd_rd_hdr.icmp6_code
285 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
286 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
288 struct nd_opt_hdr
{ /* Neighbor discovery option header */
289 u_int8_t nd_opt_type
;
291 /* followed by option specific data*/
294 #define ND_OPT_SOURCE_LINKADDR 1
295 #define ND_OPT_TARGET_LINKADDR 2
296 #define ND_OPT_PREFIX_INFORMATION 3
297 #define ND_OPT_REDIRECTED_HEADER 4
299 #define ND_OPT_ADVINTERVAL 7
300 #define ND_OPT_HOMEAGENT_INFO 8
301 #define ND_OPT_SOURCE_ADDRLIST 9
302 #define ND_OPT_TARGET_ADDRLIST 10
303 #define ND_OPT_RDNSS 25
304 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
305 #define ND_OPT_ROUTE_INFO 200
306 /* draft-ietf-mobileip-hmipv6, not officially assigned yet */
307 #define ND_OPT_MAP 201
309 struct nd_opt_route_info
{ /* route info */
310 u_int8_t nd_opt_rti_type
;
311 u_int8_t nd_opt_rti_len
;
312 u_int8_t nd_opt_rti_prefixlen
;
313 u_int8_t nd_opt_rti_flags
;
314 u_int32_t nd_opt_rti_lifetime
;
318 struct nd_opt_prefix_info
{ /* prefix information */
319 u_int8_t nd_opt_pi_type
;
320 u_int8_t nd_opt_pi_len
;
321 u_int8_t nd_opt_pi_prefix_len
;
322 u_int8_t nd_opt_pi_flags_reserved
;
323 u_int32_t nd_opt_pi_valid_time
;
324 u_int32_t nd_opt_pi_preferred_time
;
325 u_int32_t nd_opt_pi_reserved2
;
326 struct in6_addr nd_opt_pi_prefix
;
329 #define ND_OPT_PI_FLAG_ONLINK 0x80
330 #define ND_OPT_PI_FLAG_AUTO 0x40
332 struct nd_opt_rd_hdr
{ /* redirected header */
333 u_int8_t nd_opt_rh_type
;
334 u_int8_t nd_opt_rh_len
;
335 u_int16_t nd_opt_rh_reserved1
;
336 u_int32_t nd_opt_rh_reserved2
;
337 /* followed by IP header and data */
340 struct nd_opt_mtu
{ /* MTU option */
341 u_int8_t nd_opt_mtu_type
;
342 u_int8_t nd_opt_mtu_len
;
343 u_int16_t nd_opt_mtu_reserved
;
344 u_int32_t nd_opt_mtu_mtu
;
347 struct nd_opt_rdnss
{ /* RDNSS option RFC 5006 */
348 u_int8_t nd_opt_rdnss_type
;
349 u_int8_t nd_opt_rdnss_len
;
350 u_int16_t nd_opt_rdnss_reserved
;
351 u_int32_t nd_opt_rdnss_lifetime
;
352 /* followed by list of IP prefixes */
359 struct icmp6_namelookup
{
360 struct icmp6_hdr icmp6_nl_hdr
;
361 u_int8_t icmp6_nl_nonce
[8];
362 int32_t icmp6_nl_ttl
;
364 u_int8_t icmp6_nl_len
;
365 u_int8_t icmp6_nl_name
[3];
367 /* could be followed by options */
371 * icmp6 node information
373 struct icmp6_nodeinfo
{
374 struct icmp6_hdr icmp6_ni_hdr
;
375 u_int8_t icmp6_ni_nonce
[8];
376 /* could be followed by reply data */
379 #define ni_type icmp6_ni_hdr.icmp6_type
380 #define ni_code icmp6_ni_hdr.icmp6_code
381 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
382 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
383 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
385 #define NI_QTYPE_NOOP 0 /* NOOP */
386 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
387 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
388 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
389 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
390 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
392 #if BYTE_ORDER == BIG_ENDIAN
393 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
394 #define NI_FQDN_FLAG_VALIDTTL 0x1
395 #elif BYTE_ORDER == LITTLE_ENDIAN
396 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
397 #define NI_FQDN_FLAG_VALIDTTL 0x0100
400 #ifdef NAME_LOOKUPS_04
401 #if BYTE_ORDER == BIG_ENDIAN
402 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
403 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
404 #define NI_NODEADDR_FLAG_GLOBAL 0x4
405 #define NI_NODEADDR_FLAG_ALL 0x8
406 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
407 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
408 #elif BYTE_ORDER == LITTLE_ENDIAN
409 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
410 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
411 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
412 #define NI_NODEADDR_FLAG_ALL 0x0800
413 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
414 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
416 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
417 #if BYTE_ORDER == BIG_ENDIAN
418 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
419 #define NI_NODEADDR_FLAG_ALL 0x2
420 #define NI_NODEADDR_FLAG_COMPAT 0x4
421 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
422 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
423 #define NI_NODEADDR_FLAG_GLOBAL 0x20
424 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
425 #elif BYTE_ORDER == LITTLE_ENDIAN
426 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
427 #define NI_NODEADDR_FLAG_ALL 0x0200
428 #define NI_NODEADDR_FLAG_COMPAT 0x0400
429 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
430 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
431 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
432 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
436 struct ni_reply_fqdn
{
437 u_int32_t ni_fqdn_ttl
; /* TTL */
438 u_int8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
439 u_int8_t ni_fqdn_name
[3]; /* XXX: alignment */
443 * Router Renumbering. as router-renum-08.txt
445 struct icmp6_router_renum
{ /* router renumbering header */
446 struct icmp6_hdr rr_hdr
;
449 u_int16_t rr_maxdelay
;
450 u_int32_t rr_reserved
;
453 #define ICMP6_RR_FLAGS_TEST 0x80
454 #define ICMP6_RR_FLAGS_REQRESULT 0x40
455 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
456 #define ICMP6_RR_FLAGS_SPECSITE 0x10
457 #define ICMP6_RR_FLAGS_PREVDONE 0x08
459 #define rr_type rr_hdr.icmp6_type
460 #define rr_code rr_hdr.icmp6_code
461 #define rr_cksum rr_hdr.icmp6_cksum
462 #define rr_seqnum rr_hdr.icmp6_data32[0]
464 struct rr_pco_match
{ /* match prefix part */
467 u_int8_t rpm_ordinal
;
468 u_int8_t rpm_matchlen
;
471 u_int16_t rpm_reserved
;
472 struct in6_addr rpm_prefix
;
475 #define RPM_PCO_ADD 1
476 #define RPM_PCO_CHANGE 2
477 #define RPM_PCO_SETGLOBAL 3
478 #define RPM_PCO_MAX 4
480 struct rr_pco_use
{ /* use prefix part */
482 u_int8_t rpu_keeplen
;
484 u_int8_t rpu_raflags
;
485 u_int32_t rpu_vltime
;
486 u_int32_t rpu_pltime
;
488 struct in6_addr rpu_prefix
;
490 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
491 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
493 #if BYTE_ORDER == BIG_ENDIAN
494 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
495 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
496 #elif BYTE_ORDER == LITTLE_ENDIAN
497 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
498 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
501 struct rr_result
{ /* router renumbering result message */
503 u_int8_t rrr_ordinal
;
504 u_int8_t rrr_matchedlen
;
506 struct in6_addr rrr_prefix
;
508 #if BYTE_ORDER == BIG_ENDIAN
509 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
510 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
511 #elif BYTE_ORDER == LITTLE_ENDIAN
512 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
513 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
517 * icmp6 filter structures.
520 struct icmp6_filter
{
521 u_int32_t icmp6_filt
[8];
524 #define ICMP6_FILTER_SETPASSALL(filterp) \
525 (void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
526 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
527 (void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
528 #define ICMP6_FILTER_SETPASS(type, filterp) \
529 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
530 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
531 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
532 #define ICMP6_FILTER_WILLPASS(type, filterp) \
533 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
534 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
535 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
538 * Variables related to this implementation
539 * of the internet control message protocol version 6.
543 * IPv6 ICMP statistics.
544 * Each counter is an unsigned 64-bit value.
546 #define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */
547 #define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */
548 #define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */
549 #define ICMP6_STAT_OUTHIST 3 /* # of output messages */
550 /* space for 256 counters */
551 #define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */
552 #define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */
553 #define ICMP6_STAT_CHECKSUM 261 /* bad checksum */
554 #define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */
556 * number of responses; this member is inherited from the netinet code,
557 * but for netinet6 code, it is already available in outhist[].
559 #define ICMP6_STAT_REFLECT 263
560 #define ICMP6_STAT_INHIST 264 /* # of input messages */
561 /* space for 256 counters */
562 #define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */
563 #define ICMP6_STAT_OUTERRHIST 521
564 /* space for 13 counters */
565 #define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */
566 #define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */
567 #define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */
568 #define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */
569 #define ICMP6_STAT_BADRS 538 /* bad router solicitiation */
570 #define ICMP6_STAT_BADRA 539 /* bad router advertisement */
571 #define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */
573 #define ICMP6_NSTATS 541
575 #define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0
576 #define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1
577 #define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2
578 #define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3
579 #define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4
580 #define ICMP6_ERRSTAT_PACKET_TOO_BIG 5
581 #define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6
582 #define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7
583 #define ICMP6_ERRSTAT_PARAMPROB_HEADER 8
584 #define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9
585 #define ICMP6_ERRSTAT_PARAMPROB_OPTION 10
586 #define ICMP6_ERRSTAT_REDIRECT 11
587 #define ICMP6_ERRSTAT_UNKNOWN 12
590 * Names for ICMP sysctl objects
592 #define ICMPV6CTL_STATS 1
593 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
594 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
596 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
598 #define ICMPV6CTL_ND6_PRUNE 6
599 #define ICMPV6CTL_ND6_DELAY 8
600 #define ICMPV6CTL_ND6_UMAXTRIES 9
601 #define ICMPV6CTL_ND6_MMAXTRIES 10
602 #define ICMPV6CTL_ND6_USELOOPBACK 11
603 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
604 #define ICMPV6CTL_NODEINFO 13
605 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
606 #define ICMPV6CTL_ND6_MAXNUDHINT 15
607 #define ICMPV6CTL_MTUDISC_HIWAT 16
608 #define ICMPV6CTL_MTUDISC_LOWAT 17
609 #define ICMPV6CTL_ND6_DEBUG 18
610 #define ICMPV6CTL_ND6_DRLIST 19
611 #define ICMPV6CTL_ND6_PRLIST 20
612 #define ICMPV6CTL_ND6_MAXQLEN 24
613 #define ICMPV6CTL_MAXID 25
615 #define ICMPV6CTL_NAMES { \
618 { "rediraccept", CTLTYPE_INT }, \
619 { "redirtimeout", CTLTYPE_INT }, \
622 { "nd6_prune", CTLTYPE_INT }, \
624 { "nd6_delay", CTLTYPE_INT }, \
625 { "nd6_umaxtries", CTLTYPE_INT }, \
626 { "nd6_mmaxtries", CTLTYPE_INT }, \
627 { "nd6_useloopback", CTLTYPE_INT }, \
629 { "nodeinfo", CTLTYPE_INT }, \
630 { "errppslimit", CTLTYPE_INT }, \
631 { "nd6_maxnudhint", CTLTYPE_INT }, \
632 { "mtudisc_hiwat", CTLTYPE_INT }, \
633 { "mtudisc_lowat", CTLTYPE_INT }, \
634 { "nd6_debug", CTLTYPE_INT }, \
640 { "nd6_maxqueuelen", CTLTYPE_INT }, \
643 #define RTF_PROBEMTU RTF_PROTO1
650 void icmp6_init(void);
651 void icmp6_paramerror(struct mbuf
*, int);
652 void icmp6_error(struct mbuf
*, int, int, int);
653 void icmp6_error2(struct mbuf
*, int, int, int, struct ifnet
*);
654 int icmp6_input(struct mbuf
**, int *, int);
655 void icmp6_fasttimo(void);
656 void icmp6_reflect(struct mbuf
*, size_t);
657 void icmp6_prepare(struct mbuf
*);
658 void icmp6_redirect_input(struct mbuf
*, int);
659 void icmp6_redirect_output(struct mbuf
*, struct rtentry
*);
660 int icmp6_sysctl(int *, u_int
, void *, size_t *, void *, size_t);
662 void icmp6_statinc(u_int
);
665 void icmp6_mtudisc_update(struct ip6ctlparam
*, int);
666 void icmp6_mtudisc_callback_register(void (*)(struct in6_addr
*));
668 /* XXX: is this the right place for these macros? */
669 #define icmp6_ifstat_inc(ifp, tag) \
672 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
673 } while (/*CONSTCOND*/ 0)
675 #define icmp6_ifoutstat_inc(ifp, type, code) \
677 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
679 case ICMP6_DST_UNREACH: \
680 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
681 if (code == ICMP6_DST_UNREACH_ADMIN) \
682 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
684 case ICMP6_PACKET_TOO_BIG: \
685 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
687 case ICMP6_TIME_EXCEEDED: \
688 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
690 case ICMP6_PARAM_PROB: \
691 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
693 case ICMP6_ECHO_REQUEST: \
694 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
696 case ICMP6_ECHO_REPLY: \
697 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
699 case MLD_LISTENER_QUERY: \
700 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
702 case MLD_LISTENER_REPORT: \
703 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
705 case MLD_LISTENER_DONE: \
706 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
708 case ND_ROUTER_SOLICIT: \
709 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
711 case ND_ROUTER_ADVERT: \
712 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
714 case ND_NEIGHBOR_SOLICIT: \
715 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
717 case ND_NEIGHBOR_ADVERT: \
718 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
721 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
724 } while (/*CONSTCOND*/ 0)
726 extern int icmp6_rediraccept
; /* accept/process redirects */
727 extern int icmp6_redirtimeout
; /* cache time for redirect routes */
730 #endif /* !_NETINET_ICMP6_H_ */