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.6 2005/02/01 16:09:37 hrs 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
271 #elif _BYTE_ORDER == _LITTLE_ENDIAN
272 #define ND_NA_FLAG_ROUTER 0x80
273 #define ND_NA_FLAG_SOLICITED 0x40
274 #define ND_NA_FLAG_OVERRIDE 0x20
276 #error "Byte order not implemented"
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
387 #error "Byte order not implemented"
390 #ifdef NAME_LOOKUPS_04
391 #if _BYTE_ORDER == _BIG_ENDIAN
392 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
393 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
394 #define NI_NODEADDR_FLAG_GLOBAL 0x4
395 #define NI_NODEADDR_FLAG_ALL 0x8
396 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
397 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
398 #elif _BYTE_ORDER == _LITTLE_ENDIAN
399 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
400 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
401 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
402 #define NI_NODEADDR_FLAG_ALL 0x0800
403 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
404 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
406 #error "Byte order not implemented"
408 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
409 #if _BYTE_ORDER == _BIG_ENDIAN
410 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
411 #define NI_NODEADDR_FLAG_ALL 0x2
412 #define NI_NODEADDR_FLAG_COMPAT 0x4
413 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
414 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
415 #define NI_NODEADDR_FLAG_GLOBAL 0x20
416 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
417 #elif _BYTE_ORDER == _LITTLE_ENDIAN
418 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
419 #define NI_NODEADDR_FLAG_ALL 0x0200
420 #define NI_NODEADDR_FLAG_COMPAT 0x0400
421 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
422 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
423 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
424 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
426 #error "Byte order not implemented"
430 struct ni_reply_fqdn {
431 u_int32_t ni_fqdn_ttl; /* TTL */
432 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
433 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
434 } __attribute__((__packed__));
437 * Router Renumbering. as router-renum-08.txt
439 struct icmp6_router_renum { /* router renumbering header */
440 struct icmp6_hdr rr_hdr;
443 u_int16_t rr_maxdelay;
444 u_int32_t rr_reserved;
445 } __attribute__((__packed__));
447 #define ICMP6_RR_FLAGS_TEST 0x80
448 #define ICMP6_RR_FLAGS_REQRESULT 0x40
449 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
450 #define ICMP6_RR_FLAGS_SPECSITE 0x10
451 #define ICMP6_RR_FLAGS_PREVDONE 0x08
453 #define rr_type rr_hdr.icmp6_type
454 #define rr_code rr_hdr.icmp6_code
455 #define rr_cksum rr_hdr.icmp6_cksum
456 #define rr_seqnum rr_hdr.icmp6_data32[0]
458 struct rr_pco_match { /* match prefix part */
461 u_int8_t rpm_ordinal;
462 u_int8_t rpm_matchlen;
465 u_int16_t rpm_reserved;
466 struct in6_addr rpm_prefix;
467 } __attribute__((__packed__));
469 #define RPM_PCO_ADD 1
470 #define RPM_PCO_CHANGE 2
471 #define RPM_PCO_SETGLOBAL 3
472 #define RPM_PCO_MAX 4
474 struct rr_pco_use { /* use prefix part */
476 u_int8_t rpu_keeplen;
478 u_int8_t rpu_raflags;
479 u_int32_t rpu_vltime;
480 u_int32_t rpu_pltime;
482 struct in6_addr rpu_prefix;
483 } __attribute__((__packed__));
484 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
485 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
487 #if _BYTE_ORDER == _BIG_ENDIAN
488 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
489 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
490 #elif _BYTE_ORDER == _LITTLE_ENDIAN
491 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
492 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
494 #error "Byte order not implemented"
497 struct rr_result { /* router renumbering result message */
499 u_int8_t rrr_ordinal;
500 u_int8_t rrr_matchedlen;
502 struct in6_addr rrr_prefix;
503 } __attribute__((__packed__));
504 #if _BYTE_ORDER == _BIG_ENDIAN
505 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
506 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
507 #elif _BYTE_ORDER == _LITTLE_ENDIAN
508 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
509 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
511 #error "Byte order not implemented"
515 * icmp6 filter structures.
518 struct icmp6_filter {
519 u_int32_t icmp6_filt[8];
523 #define ICMP6_FILTER_SETPASSALL(filterp) \
526 p = (u_char *)filterp; \
527 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
530 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
531 bzero(filterp, sizeof(struct icmp6_filter))
533 #define ICMP6_FILTER_SETPASSALL(filterp) \
534 memset(filterp, 0xff, sizeof(struct icmp6_filter))
535 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
536 memset(filterp, 0x00, sizeof(struct icmp6_filter))
539 #define ICMP6_FILTER_SETPASS(type, filterp) \
540 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
541 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
542 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
543 #define ICMP6_FILTER_WILLPASS(type, filterp) \
544 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
545 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
546 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
549 * Variables related to this implementation
550 * of the internet control message protocol version 6.
552 struct icmp6errstat {
553 u_quad_t icp6errs_dst_unreach_noroute;
554 u_quad_t icp6errs_dst_unreach_admin;
555 u_quad_t icp6errs_dst_unreach_beyondscope;
556 u_quad_t icp6errs_dst_unreach_addr;
557 u_quad_t icp6errs_dst_unreach_noport;
558 u_quad_t icp6errs_packet_too_big;
559 u_quad_t icp6errs_time_exceed_transit;
560 u_quad_t icp6errs_time_exceed_reassembly;
561 u_quad_t icp6errs_paramprob_header;
562 u_quad_t icp6errs_paramprob_nextheader;
563 u_quad_t icp6errs_paramprob_option;
564 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
565 u_quad_t icp6errs_unknown;
569 /* statistics related to icmp6 packets generated */
570 u_quad_t icp6s_error; /* # of calls to icmp6_error */
571 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
572 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
573 u_quad_t icp6s_outhist[256];
574 /* statistics related to input message processed */
575 u_quad_t icp6s_badcode; /* icmp6_code out of range */
576 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
577 u_quad_t icp6s_checksum; /* bad checksum */
578 u_quad_t icp6s_badlen; /* calculated bound mismatch */
580 * number of responses: this member is inherited from netinet code, but
581 * for netinet6 code, it is already available in icp6s_outhist[].
583 u_quad_t icp6s_reflect;
584 u_quad_t icp6s_inhist[256];
585 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
586 struct icmp6errstat icp6s_outerrhist;
587 #define icp6s_odst_unreach_noroute \
588 icp6s_outerrhist.icp6errs_dst_unreach_noroute
589 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
590 #define icp6s_odst_unreach_beyondscope \
591 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
592 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
593 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
594 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
595 #define icp6s_otime_exceed_transit \
596 icp6s_outerrhist.icp6errs_time_exceed_transit
597 #define icp6s_otime_exceed_reassembly \
598 icp6s_outerrhist.icp6errs_time_exceed_reassembly
599 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
600 #define icp6s_oparamprob_nextheader \
601 icp6s_outerrhist.icp6errs_paramprob_nextheader
602 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
603 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
604 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
605 u_quad_t icp6s_pmtuchg; /* path MTU changes */
606 u_quad_t icp6s_nd_badopt; /* bad ND options */
607 u_quad_t icp6s_badns; /* bad neighbor solicitation */
608 u_quad_t icp6s_badna; /* bad neighbor advertisement */
609 u_quad_t icp6s_badrs; /* bad router advertisement */
610 u_quad_t icp6s_badra; /* bad router advertisement */
611 u_quad_t icp6s_badredirect; /* bad redirect message */
615 * Names for ICMP sysctl objects
617 #define ICMPV6CTL_STATS 1
618 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
619 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
621 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
623 #define ICMPV6CTL_ND6_PRUNE 6
624 #define ICMPV6CTL_ND6_DELAY 8
625 #define ICMPV6CTL_ND6_UMAXTRIES 9
626 #define ICMPV6CTL_ND6_MMAXTRIES 10
627 #define ICMPV6CTL_ND6_USELOOPBACK 11
628 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
629 #define ICMPV6CTL_NODEINFO 13
630 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
631 #define ICMPV6CTL_ND6_MAXNUDHINT 15
632 #define ICMPV6CTL_MTUDISC_HIWAT 16
633 #define ICMPV6CTL_MTUDISC_LOWAT 17
634 #define ICMPV6CTL_ND6_DEBUG 18
635 #define ICMPV6CTL_ND6_DRLIST 19
636 #define ICMPV6CTL_ND6_PRLIST 20
637 #define ICMPV6CTL_MAXID 21
639 #define ICMPV6CTL_NAMES { \
642 { "rediraccept", CTLTYPE_INT }, \
643 { "redirtimeout", CTLTYPE_INT }, \
646 { "nd6_prune", CTLTYPE_INT }, \
648 { "nd6_delay", CTLTYPE_INT }, \
649 { "nd6_umaxtries", CTLTYPE_INT }, \
650 { "nd6_mmaxtries", CTLTYPE_INT }, \
651 { "nd6_useloopback", CTLTYPE_INT }, \
653 { "nodeinfo", CTLTYPE_INT }, \
654 { "errppslimit", CTLTYPE_INT }, \
655 { "nd6_maxnudhint", CTLTYPE_INT }, \
656 { "mtudisc_hiwat", CTLTYPE_INT }, \
657 { "mtudisc_lowat", CTLTYPE_INT }, \
658 { "nd6_debug", CTLTYPE_INT }, \
663 #define RTF_PROBEMTU RTF_PROTO1
671 void icmp6_init (void);
672 void icmp6_paramerror (struct mbuf *, int);
673 void icmp6_error (struct mbuf *, int, int, int);
674 int icmp6_input (struct mbuf **, int *, int);
675 void icmp6_fasttimo (void);
676 void icmp6_reflect (struct mbuf *, size_t);
677 void icmp6_prepare (struct mbuf *);
678 void icmp6_redirect_input (struct mbuf *, int);
679 void icmp6_redirect_output (struct mbuf *, struct rtentry *);
682 void icmp6_mtudisc_update (struct ip6ctlparam *, int);
684 /* XXX: is this the right place for these macros? */
685 #define icmp6_ifstat_inc(ifp, tag) \
688 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
691 #define icmp6_ifoutstat_inc(ifp, type, code) \
693 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
694 if (type < ICMP6_INFOMSG_MASK) \
695 icmp6_ifstat_inc(ifp, ifs6_out_error); \
697 case ICMP6_DST_UNREACH: \
698 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
699 if (code == ICMP6_DST_UNREACH_ADMIN) \
700 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
702 case ICMP6_PACKET_TOO_BIG: \
703 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
705 case ICMP6_TIME_EXCEEDED: \
706 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
708 case ICMP6_PARAM_PROB: \
709 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
711 case ICMP6_ECHO_REQUEST: \
712 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
714 case ICMP6_ECHO_REPLY: \
715 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
717 case MLD_LISTENER_QUERY: \
718 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
720 case MLD_LISTENER_REPORT: \
721 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
723 case MLD_LISTENER_DONE: \
724 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
726 case ND_ROUTER_SOLICIT: \
727 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
729 case ND_ROUTER_ADVERT: \
730 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
732 case ND_NEIGHBOR_SOLICIT: \
733 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
735 case ND_NEIGHBOR_ADVERT: \
736 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
739 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
744 extern int icmp6_rediraccept; /* accept/process redirects */
745 extern int icmp6_redirtimeout; /* cache time for redirect routes */
748 #endif /* not _NETINET_ICMP6_H_ */