1 /* $FreeBSD: src/sys/netinet/icmp6.h,v 1.2.2.5 2002/06/29 18:31:11 ume Exp $ */
2 /* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * Copyright (c) 1982, 1986, 1993
35 * The Regents of the University of California. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
68 #ifndef _NETINET_ICMP6_H_
69 #define _NETINET_ICMP6_H_
72 #include <sys/types.h>
74 #ifndef _NETINET6_IN6_H_
75 #include <netinet/in.h>
77 #include <machine/endian.h>
79 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
80 - sizeof(struct icmp6_hdr) */
83 u_int8_t icmp6_type; /* type field */
84 u_int8_t icmp6_code; /* code field */
85 u_int16_t icmp6_cksum; /* checksum field */
87 u_int32_t icmp6_un_data32[1]; /* type-specific field */
88 u_int16_t icmp6_un_data16[2]; /* type-specific field */
89 u_int8_t icmp6_un_data8[4]; /* type-specific field */
91 } __attribute__((__packed__));
93 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
94 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
95 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
96 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
97 #define icmp6_mtu icmp6_data32[0] /* packet too big */
98 #define icmp6_id icmp6_data16[0] /* echo request/reply */
99 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
100 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
102 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
103 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
104 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
105 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
107 #define ICMP6_ECHO_REQUEST 128 /* echo service */
108 #define ICMP6_ECHO_REPLY 129 /* echo reply */
109 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
110 #define MLD_LISTENER_QUERY 130 /* multicast listener query */
111 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
112 #define MLD_LISTENER_REPORT 131 /* multicast listener report */
113 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
114 #define MLD_LISTENER_DONE 132 /* multicast listener done */
115 #define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* defined in RFC3542 */
118 /* the followings are for backward compatibility to old KAME apps. */
119 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
120 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
121 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
124 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
125 #define ND_ROUTER_ADVERT 134 /* router advertisment */
126 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
127 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
128 #define ND_REDIRECT 137 /* redirect */
130 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
132 #define ICMP6_WRUREQUEST 139 /* who are you request */
133 #define ICMP6_WRUREPLY 140 /* who are you reply */
134 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
135 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
136 #define ICMP6_NI_QUERY 139 /* node information request */
137 #define ICMP6_NI_REPLY 140 /* node information reply */
139 /* The definitions below are experimental. TBA */
140 #define MLD_MTRACE_RESP 200 /* mtrace resp (to sender) */
141 #define MLD_MTRACE 201 /* mtrace messages */
143 #define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */
144 #define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */
147 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
148 #define MLD6_MTRACE MLD_MTRACE
151 #define ICMP6_MAXTYPE 203
153 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
154 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
155 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
156 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
157 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
158 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
160 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
161 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
163 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
164 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
165 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
167 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
169 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
170 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
171 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
173 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
174 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
175 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
177 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
178 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
179 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
181 /* Used in kernel only */
182 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
183 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
186 * Multicast Listener Discovery
189 struct icmp6_hdr mld_icmp6_hdr;
190 struct in6_addr mld_addr; /* multicast address */
191 } __attribute__((__packed__));
193 /* definitions to provide backward compatibility to old KAME applications */
195 #define mld6_hdr mld_hdr
196 #define mld6_type mld_type
197 #define mld6_code mld_code
198 #define mld6_cksum mld_cksum
199 #define mld6_maxdelay mld_maxdelay
200 #define mld6_reserved mld_reserved
201 #define mld6_addr mld_addr
204 /* shortcut macro definitions */
205 #define mld_type mld_icmp6_hdr.icmp6_type
206 #define mld_code mld_icmp6_hdr.icmp6_code
207 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
208 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
209 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
215 struct nd_router_solicit { /* router solicitation */
216 struct icmp6_hdr nd_rs_hdr;
217 /* could be followed by options */
218 } __attribute__((__packed__));
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]
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 } __attribute__((__packed__));
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_HA 0x20
242 * Router preference values based on draft-draves-ipngwg-router-selection-01.
243 * These are non-standard definitions.
245 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
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 */
252 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
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 } __attribute__((__packed__));
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]
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 } __attribute__((__packed__));
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 #elif _BYTE_ORDER == _LITTLE_ENDIAN
280 #define ND_NA_FLAG_ROUTER 0x80
281 #define ND_NA_FLAG_SOLICITED 0x40
282 #define ND_NA_FLAG_OVERRIDE 0x20
284 #error "Byte order not implemented"
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 } __attribute__((__packed__));
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]
299 struct nd_opt_hdr { /* Neighbor discovery option header */
300 u_int8_t nd_opt_type;
302 /* followed by option specific data*/
303 } __attribute__((__packed__));
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
311 #define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
313 struct nd_opt_prefix_info { /* prefix information */
314 u_int8_t nd_opt_pi_type;
315 u_int8_t nd_opt_pi_len;
316 u_int8_t nd_opt_pi_prefix_len;
317 u_int8_t nd_opt_pi_flags_reserved;
318 u_int32_t nd_opt_pi_valid_time;
319 u_int32_t nd_opt_pi_preferred_time;
320 u_int32_t nd_opt_pi_reserved2;
321 struct in6_addr nd_opt_pi_prefix;
322 } __attribute__((__packed__));
324 #define ND_OPT_PI_FLAG_ONLINK 0x80
325 #define ND_OPT_PI_FLAG_AUTO 0x40
327 struct nd_opt_rd_hdr { /* redirected header */
328 u_int8_t nd_opt_rh_type;
329 u_int8_t nd_opt_rh_len;
330 u_int16_t nd_opt_rh_reserved1;
331 u_int32_t nd_opt_rh_reserved2;
332 /* followed by IP header and data */
333 } __attribute__((__packed__));
335 struct nd_opt_mtu { /* MTU option */
336 u_int8_t nd_opt_mtu_type;
337 u_int8_t nd_opt_mtu_len;
338 u_int16_t nd_opt_mtu_reserved;
339 u_int32_t nd_opt_mtu_mtu;
340 } __attribute__((__packed__));
342 struct nd_opt_route_info { /* route info */
343 u_int8_t nd_opt_rti_type;
344 u_int8_t nd_opt_rti_len;
345 u_int8_t nd_opt_rti_prefixlen;
346 u_int8_t nd_opt_rti_flags;
347 u_int32_t nd_opt_rti_lifetime;
349 } __attribute__((__packed__));
355 struct icmp6_namelookup {
356 struct icmp6_hdr icmp6_nl_hdr;
357 u_int8_t icmp6_nl_nonce[8];
358 int32_t icmp6_nl_ttl;
360 u_int8_t icmp6_nl_len;
361 u_int8_t icmp6_nl_name[3];
363 /* could be followed by options */
364 } __attribute__((__packed__));
367 * icmp6 node information
369 struct icmp6_nodeinfo {
370 struct icmp6_hdr icmp6_ni_hdr;
371 u_int8_t icmp6_ni_nonce[8];
372 /* could be followed by reply data */
373 } __attribute__((__packed__));
375 #define ni_type icmp6_ni_hdr.icmp6_type
376 #define ni_code icmp6_ni_hdr.icmp6_code
377 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
378 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
379 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
381 #define NI_QTYPE_NOOP 0 /* NOOP */
382 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
383 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
384 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
385 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
386 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
388 #if _BYTE_ORDER == _BIG_ENDIAN
389 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
390 #define NI_FQDN_FLAG_VALIDTTL 0x1
391 #elif _BYTE_ORDER == _LITTLE_ENDIAN
392 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
393 #define NI_FQDN_FLAG_VALIDTTL 0x0100
395 #error "Byte order not implemented"
398 #ifdef NAME_LOOKUPS_04
399 #if _BYTE_ORDER == _BIG_ENDIAN
400 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
401 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
402 #define NI_NODEADDR_FLAG_GLOBAL 0x4
403 #define NI_NODEADDR_FLAG_ALL 0x8
404 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
405 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
406 #elif _BYTE_ORDER == _LITTLE_ENDIAN
407 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
408 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
409 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
410 #define NI_NODEADDR_FLAG_ALL 0x0800
411 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
412 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
414 #error "Byte order not implemented"
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 */
434 #error "Byte order not implemented"
438 struct ni_reply_fqdn {
439 u_int32_t ni_fqdn_ttl; /* TTL */
440 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
441 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
442 } __attribute__((__packed__));
445 * Router Renumbering. as router-renum-08.txt
447 struct icmp6_router_renum { /* router renumbering header */
448 struct icmp6_hdr rr_hdr;
451 u_int16_t rr_maxdelay;
452 u_int32_t rr_reserved;
453 } __attribute__((__packed__));
455 #define ICMP6_RR_FLAGS_TEST 0x80
456 #define ICMP6_RR_FLAGS_REQRESULT 0x40
457 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
458 #define ICMP6_RR_FLAGS_SPECSITE 0x10
459 #define ICMP6_RR_FLAGS_PREVDONE 0x08
461 #define rr_type rr_hdr.icmp6_type
462 #define rr_code rr_hdr.icmp6_code
463 #define rr_cksum rr_hdr.icmp6_cksum
464 #define rr_seqnum rr_hdr.icmp6_data32[0]
466 struct rr_pco_match { /* match prefix part */
469 u_int8_t rpm_ordinal;
470 u_int8_t rpm_matchlen;
473 u_int16_t rpm_reserved;
474 struct in6_addr rpm_prefix;
475 } __attribute__((__packed__));
477 #define RPM_PCO_ADD 1
478 #define RPM_PCO_CHANGE 2
479 #define RPM_PCO_SETGLOBAL 3
480 #define RPM_PCO_MAX 4
482 struct rr_pco_use { /* use prefix part */
484 u_int8_t rpu_keeplen;
486 u_int8_t rpu_raflags;
487 u_int32_t rpu_vltime;
488 u_int32_t rpu_pltime;
490 struct in6_addr rpu_prefix;
491 } __attribute__((__packed__));
492 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
493 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
495 #if _BYTE_ORDER == _BIG_ENDIAN
496 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
497 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
498 #elif _BYTE_ORDER == _LITTLE_ENDIAN
499 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
500 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
502 #error "Byte order not implemented"
505 struct rr_result { /* router renumbering result message */
507 u_int8_t rrr_ordinal;
508 u_int8_t rrr_matchedlen;
510 struct in6_addr rrr_prefix;
511 } __attribute__((__packed__));
512 #if _BYTE_ORDER == _BIG_ENDIAN
513 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
514 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
515 #elif _BYTE_ORDER == _LITTLE_ENDIAN
516 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
517 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
519 #error "Byte order not implemented"
523 * icmp6 filter structures.
526 struct icmp6_filter {
527 u_int32_t icmp6_filt[8];
531 #define ICMP6_FILTER_SETPASSALL(filterp) \
534 p = (u_char *)filterp; \
535 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
538 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
539 bzero(filterp, sizeof(struct icmp6_filter))
541 #define ICMP6_FILTER_SETPASSALL(filterp) \
542 memset(filterp, 0xff, sizeof(struct icmp6_filter))
543 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
544 memset(filterp, 0x00, sizeof(struct icmp6_filter))
547 #define ICMP6_FILTER_SETPASS(type, filterp) \
548 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
549 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
550 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
551 #define ICMP6_FILTER_WILLPASS(type, filterp) \
552 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
553 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
554 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
557 * Variables related to this implementation
558 * of the internet control message protocol version 6.
560 struct icmp6errstat {
561 u_quad_t icp6errs_dst_unreach_noroute;
562 u_quad_t icp6errs_dst_unreach_admin;
563 u_quad_t icp6errs_dst_unreach_beyondscope;
564 u_quad_t icp6errs_dst_unreach_addr;
565 u_quad_t icp6errs_dst_unreach_noport;
566 u_quad_t icp6errs_packet_too_big;
567 u_quad_t icp6errs_time_exceed_transit;
568 u_quad_t icp6errs_time_exceed_reassembly;
569 u_quad_t icp6errs_paramprob_header;
570 u_quad_t icp6errs_paramprob_nextheader;
571 u_quad_t icp6errs_paramprob_option;
572 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
573 u_quad_t icp6errs_unknown;
577 /* statistics related to icmp6 packets generated */
578 u_quad_t icp6s_error; /* # of calls to icmp6_error */
579 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
580 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
581 u_quad_t icp6s_outhist[256];
582 /* statistics related to input message processed */
583 u_quad_t icp6s_badcode; /* icmp6_code out of range */
584 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
585 u_quad_t icp6s_checksum; /* bad checksum */
586 u_quad_t icp6s_badlen; /* calculated bound mismatch */
588 * number of responses: this member is inherited from netinet code, but
589 * for netinet6 code, it is already available in icp6s_outhist[].
591 u_quad_t icp6s_reflect;
592 u_quad_t icp6s_inhist[256];
593 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
594 struct icmp6errstat icp6s_outerrhist;
595 #define icp6s_odst_unreach_noroute \
596 icp6s_outerrhist.icp6errs_dst_unreach_noroute
597 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
598 #define icp6s_odst_unreach_beyondscope \
599 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
600 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
601 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
602 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
603 #define icp6s_otime_exceed_transit \
604 icp6s_outerrhist.icp6errs_time_exceed_transit
605 #define icp6s_otime_exceed_reassembly \
606 icp6s_outerrhist.icp6errs_time_exceed_reassembly
607 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
608 #define icp6s_oparamprob_nextheader \
609 icp6s_outerrhist.icp6errs_paramprob_nextheader
610 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
611 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
612 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
613 u_quad_t icp6s_pmtuchg; /* path MTU changes */
614 u_quad_t icp6s_nd_badopt; /* bad ND options */
615 u_quad_t icp6s_badns; /* bad neighbor solicitation */
616 u_quad_t icp6s_badna; /* bad neighbor advertisement */
617 u_quad_t icp6s_badrs; /* bad router advertisement */
618 u_quad_t icp6s_badra; /* bad router advertisement */
619 u_quad_t icp6s_badredirect; /* bad redirect message */
623 * Names for ICMP sysctl objects
625 #define ICMPV6CTL_STATS 1
626 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
627 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
629 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
631 #define ICMPV6CTL_ND6_PRUNE 6
632 #define ICMPV6CTL_ND6_DELAY 8
633 #define ICMPV6CTL_ND6_UMAXTRIES 9
634 #define ICMPV6CTL_ND6_MMAXTRIES 10
635 #define ICMPV6CTL_ND6_USELOOPBACK 11
636 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
637 #define ICMPV6CTL_NODEINFO 13
638 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
639 #define ICMPV6CTL_ND6_MAXNUDHINT 15
640 #define ICMPV6CTL_MTUDISC_HIWAT 16
641 #define ICMPV6CTL_MTUDISC_LOWAT 17
642 #define ICMPV6CTL_ND6_DEBUG 18
643 #define ICMPV6CTL_ND6_DRLIST 19
644 #define ICMPV6CTL_ND6_PRLIST 20
645 #define ICMPV6CTL_MAXID 21
647 #define ICMPV6CTL_NAMES { \
650 { "rediraccept", CTLTYPE_INT }, \
651 { "redirtimeout", CTLTYPE_INT }, \
654 { "nd6_prune", CTLTYPE_INT }, \
656 { "nd6_delay", CTLTYPE_INT }, \
657 { "nd6_umaxtries", CTLTYPE_INT }, \
658 { "nd6_mmaxtries", CTLTYPE_INT }, \
659 { "nd6_useloopback", CTLTYPE_INT }, \
661 { "nodeinfo", CTLTYPE_INT }, \
662 { "errppslimit", CTLTYPE_INT }, \
663 { "nd6_maxnudhint", CTLTYPE_INT }, \
664 { "mtudisc_hiwat", CTLTYPE_INT }, \
665 { "mtudisc_lowat", CTLTYPE_INT }, \
666 { "nd6_debug", CTLTYPE_INT }, \
671 #define RTF_PROBEMTU RTF_PROTO1
679 void icmp6_init (void);
680 void icmp6_paramerror (struct mbuf *, int);
681 void icmp6_error (struct mbuf *, int, int, int);
682 int icmp6_input (struct mbuf **, int *, int);
683 void icmp6_fasttimo (void);
684 void icmp6_reflect (struct mbuf *, size_t);
685 void icmp6_prepare (struct mbuf *);
686 void icmp6_redirect_input (struct mbuf *, int);
687 void icmp6_redirect_output (struct mbuf *, struct rtentry *);
690 void icmp6_mtudisc_update (struct ip6ctlparam *, int);
692 /* XXX: is this the right place for these macros? */
693 #define icmp6_ifstat_inc(ifp, tag) \
696 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
699 #define icmp6_ifoutstat_inc(ifp, type, code) \
701 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
702 if (type < ICMP6_INFOMSG_MASK) \
703 icmp6_ifstat_inc(ifp, ifs6_out_error); \
705 case ICMP6_DST_UNREACH: \
706 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
707 if (code == ICMP6_DST_UNREACH_ADMIN) \
708 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
710 case ICMP6_PACKET_TOO_BIG: \
711 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
713 case ICMP6_TIME_EXCEEDED: \
714 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
716 case ICMP6_PARAM_PROB: \
717 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
719 case ICMP6_ECHO_REQUEST: \
720 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
722 case ICMP6_ECHO_REPLY: \
723 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
725 case MLD_LISTENER_QUERY: \
726 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
728 case MLD_LISTENER_REPORT: \
729 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
731 case MLD_LISTENER_DONE: \
732 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
734 case ND_ROUTER_SOLICIT: \
735 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
737 case ND_ROUTER_ADVERT: \
738 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
740 case ND_NEIGHBOR_SOLICIT: \
741 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
743 case ND_NEIGHBOR_ADVERT: \
744 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
747 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
752 extern int icmp6_rediraccept; /* accept/process redirects */
753 extern int icmp6_redirtimeout; /* cache time for redirect routes */
756 #endif /* not _NETINET_ICMP6_H_ */