Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / sys / netinet / icmp6.h
blobe9ded24823345dfddd524c9adef3fbfa4cb6ae12
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.8 2008/09/04 09:08:22 hasso Exp $ */
3 /* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */
5 /*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
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
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. 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
64 * SUCH DAMAGE.
66 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
69 #ifndef _NETINET_ICMP6_H_
70 #define _NETINET_ICMP6_H_
72 #ifndef _SYS_TYPES_H_
73 #include <sys/types.h>
74 #endif
75 #ifndef _NETINET6_IN6_H_
76 #include <netinet/in.h>
77 #endif
78 #ifndef _MACHINE_ENDIAN_H_
79 #include <machine/endian.h>
80 #endif
82 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
83 - sizeof(struct icmp6_hdr) */
85 struct icmp6_hdr {
86 u_int8_t icmp6_type; /* type field */
87 u_int8_t icmp6_code; /* code field */
88 u_int16_t icmp6_cksum; /* checksum field */
89 union {
90 u_int32_t icmp6_un_data32[1]; /* type-specific field */
91 u_int16_t icmp6_un_data16[2]; /* type-specific field */
92 u_int8_t icmp6_un_data8[4]; /* type-specific field */
93 } icmp6_dataun;
94 } __attribute__((__packed__));
96 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
97 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
98 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
99 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
100 #define icmp6_mtu icmp6_data32[0] /* packet too big */
101 #define icmp6_id icmp6_data16[0] /* echo request/reply */
102 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
103 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
105 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
106 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
107 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
108 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
110 #define ICMP6_ECHO_REQUEST 128 /* echo service */
111 #define ICMP6_ECHO_REPLY 129 /* echo reply */
112 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
113 #define MLD_LISTENER_QUERY 130 /* multicast listener query */
114 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
115 #define MLD_LISTENER_REPORT 131 /* multicast listener report */
116 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
117 #define MLD_LISTENER_DONE 132 /* multicast listener done */
118 #define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* defined in RFC3542 */
120 #ifndef _KERNEL
121 /* the followings are for backward compatibility to old KAME apps. */
122 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
123 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
124 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
125 #endif
127 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
128 #define ND_ROUTER_ADVERT 134 /* router advertisment */
129 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
130 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
131 #define ND_REDIRECT 137 /* redirect */
133 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
135 #define ICMP6_WRUREQUEST 139 /* who are you request */
136 #define ICMP6_WRUREPLY 140 /* who are you reply */
137 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
138 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
139 #define ICMP6_NI_QUERY 139 /* node information request */
140 #define ICMP6_NI_REPLY 140 /* node information reply */
142 /* The definitions below are experimental. TBA */
143 #define MLD_MTRACE_RESP 200 /* mtrace resp (to sender) */
144 #define MLD_MTRACE 201 /* mtrace messages */
146 #define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */
147 #define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */
149 #ifndef _KERNEL
150 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
151 #define MLD6_MTRACE MLD_MTRACE
152 #endif
154 #define ICMP6_MAXTYPE 203
156 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
157 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
158 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
159 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
160 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
161 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
163 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
164 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
166 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
167 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
168 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
170 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
172 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
173 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
174 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
176 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
177 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
178 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
180 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
181 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
182 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
184 /* Used in kernel only */
185 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
186 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
189 * Multicast Listener Discovery
191 struct mld_hdr {
192 struct icmp6_hdr mld_icmp6_hdr;
193 struct in6_addr mld_addr; /* multicast address */
194 } __attribute__((__packed__));
196 /* definitions to provide backward compatibility to old KAME applications */
197 #ifndef _KERNEL
198 #define mld6_hdr mld_hdr
199 #define mld6_type mld_type
200 #define mld6_code mld_code
201 #define mld6_cksum mld_cksum
202 #define mld6_maxdelay mld_maxdelay
203 #define mld6_reserved mld_reserved
204 #define mld6_addr mld_addr
205 #endif
207 /* shortcut macro definitions */
208 #define mld_type mld_icmp6_hdr.icmp6_type
209 #define mld_code mld_icmp6_hdr.icmp6_code
210 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
211 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
212 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
215 * Neighbor Discovery
218 struct nd_router_solicit { /* router solicitation */
219 struct icmp6_hdr nd_rs_hdr;
220 /* could be followed by options */
221 } __attribute__((__packed__));
223 #define nd_rs_type nd_rs_hdr.icmp6_type
224 #define nd_rs_code nd_rs_hdr.icmp6_code
225 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
226 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
228 struct nd_router_advert { /* router advertisement */
229 struct icmp6_hdr nd_ra_hdr;
230 u_int32_t nd_ra_reachable; /* reachable time */
231 u_int32_t nd_ra_retransmit; /* retransmit timer */
232 /* could be followed by options */
233 } __attribute__((__packed__));
235 #define nd_ra_type nd_ra_hdr.icmp6_type
236 #define nd_ra_code nd_ra_hdr.icmp6_code
237 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
238 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
239 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
240 #define ND_RA_FLAG_MANAGED 0x80
241 #define ND_RA_FLAG_OTHER 0x40
242 #define ND_RA_FLAG_HA 0x20
245 * Router preference values based on draft-draves-ipngwg-router-selection-01.
246 * These are non-standard definitions.
248 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
250 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
251 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
252 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
253 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
255 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
257 struct nd_neighbor_solicit { /* neighbor solicitation */
258 struct icmp6_hdr nd_ns_hdr;
259 struct in6_addr nd_ns_target; /*target address */
260 /* could be followed by options */
261 } __attribute__((__packed__));
263 #define nd_ns_type nd_ns_hdr.icmp6_type
264 #define nd_ns_code nd_ns_hdr.icmp6_code
265 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
266 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
268 struct nd_neighbor_advert { /* neighbor advertisement */
269 struct icmp6_hdr nd_na_hdr;
270 struct in6_addr nd_na_target; /* target address */
271 /* could be followed by options */
272 } __attribute__((__packed__));
274 #define nd_na_type nd_na_hdr.icmp6_type
275 #define nd_na_code nd_na_hdr.icmp6_code
276 #define nd_na_cksum nd_na_hdr.icmp6_cksum
277 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
278 #if _BYTE_ORDER == _BIG_ENDIAN
279 #define ND_NA_FLAG_ROUTER 0x80000000
280 #define ND_NA_FLAG_SOLICITED 0x40000000
281 #define ND_NA_FLAG_OVERRIDE 0x20000000
282 #elif _BYTE_ORDER == _LITTLE_ENDIAN
283 #define ND_NA_FLAG_ROUTER 0x80
284 #define ND_NA_FLAG_SOLICITED 0x40
285 #define ND_NA_FLAG_OVERRIDE 0x20
286 #else
287 #error "Byte order not implemented"
288 #endif
290 struct nd_redirect { /* redirect */
291 struct icmp6_hdr nd_rd_hdr;
292 struct in6_addr nd_rd_target; /* target address */
293 struct in6_addr nd_rd_dst; /* destination address */
294 /* could be followed by options */
295 } __attribute__((__packed__));
297 #define nd_rd_type nd_rd_hdr.icmp6_type
298 #define nd_rd_code nd_rd_hdr.icmp6_code
299 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
300 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
302 struct nd_opt_hdr { /* Neighbor discovery option header */
303 u_int8_t nd_opt_type;
304 u_int8_t nd_opt_len;
305 /* followed by option specific data*/
306 } __attribute__((__packed__));
308 #define ND_OPT_SOURCE_LINKADDR 1
309 #define ND_OPT_TARGET_LINKADDR 2
310 #define ND_OPT_PREFIX_INFORMATION 3
311 #define ND_OPT_REDIRECTED_HEADER 4
312 #define ND_OPT_MTU 5
314 #define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
316 struct nd_opt_prefix_info { /* prefix information */
317 u_int8_t nd_opt_pi_type;
318 u_int8_t nd_opt_pi_len;
319 u_int8_t nd_opt_pi_prefix_len;
320 u_int8_t nd_opt_pi_flags_reserved;
321 u_int32_t nd_opt_pi_valid_time;
322 u_int32_t nd_opt_pi_preferred_time;
323 u_int32_t nd_opt_pi_reserved2;
324 struct in6_addr nd_opt_pi_prefix;
325 } __attribute__((__packed__));
327 #define ND_OPT_PI_FLAG_ONLINK 0x80
328 #define ND_OPT_PI_FLAG_AUTO 0x40
330 struct nd_opt_rd_hdr { /* redirected header */
331 u_int8_t nd_opt_rh_type;
332 u_int8_t nd_opt_rh_len;
333 u_int16_t nd_opt_rh_reserved1;
334 u_int32_t nd_opt_rh_reserved2;
335 /* followed by IP header and data */
336 } __attribute__((__packed__));
338 struct nd_opt_mtu { /* MTU option */
339 u_int8_t nd_opt_mtu_type;
340 u_int8_t nd_opt_mtu_len;
341 u_int16_t nd_opt_mtu_reserved;
342 u_int32_t nd_opt_mtu_mtu;
343 } __attribute__((__packed__));
345 struct nd_opt_route_info { /* route info */
346 u_int8_t nd_opt_rti_type;
347 u_int8_t nd_opt_rti_len;
348 u_int8_t nd_opt_rti_prefixlen;
349 u_int8_t nd_opt_rti_flags;
350 u_int32_t nd_opt_rti_lifetime;
351 /* prefix follows */
352 } __attribute__((__packed__));
355 * icmp6 namelookup
358 struct icmp6_namelookup {
359 struct icmp6_hdr icmp6_nl_hdr;
360 u_int8_t icmp6_nl_nonce[8];
361 int32_t icmp6_nl_ttl;
362 #if 0
363 u_int8_t icmp6_nl_len;
364 u_int8_t icmp6_nl_name[3];
365 #endif
366 /* could be followed by options */
367 } __attribute__((__packed__));
370 * icmp6 node information
372 struct icmp6_nodeinfo {
373 struct icmp6_hdr icmp6_ni_hdr;
374 u_int8_t icmp6_ni_nonce[8];
375 /* could be followed by reply data */
376 } __attribute__((__packed__));
378 #define ni_type icmp6_ni_hdr.icmp6_type
379 #define ni_code icmp6_ni_hdr.icmp6_code
380 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
381 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
382 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
384 #define NI_QTYPE_NOOP 0 /* NOOP */
385 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
386 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
387 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
388 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
389 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
391 #if _BYTE_ORDER == _BIG_ENDIAN
392 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
393 #define NI_FQDN_FLAG_VALIDTTL 0x1
394 #elif _BYTE_ORDER == _LITTLE_ENDIAN
395 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
396 #define NI_FQDN_FLAG_VALIDTTL 0x0100
397 #else
398 #error "Byte order not implemented"
399 #endif
401 #ifdef NAME_LOOKUPS_04
402 #if _BYTE_ORDER == _BIG_ENDIAN
403 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
404 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
405 #define NI_NODEADDR_FLAG_GLOBAL 0x4
406 #define NI_NODEADDR_FLAG_ALL 0x8
407 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
408 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
409 #elif _BYTE_ORDER == _LITTLE_ENDIAN
410 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
411 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
412 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
413 #define NI_NODEADDR_FLAG_ALL 0x0800
414 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
415 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
416 #else
417 #error "Byte order not implemented"
418 #endif
419 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
420 #if _BYTE_ORDER == _BIG_ENDIAN
421 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
422 #define NI_NODEADDR_FLAG_ALL 0x2
423 #define NI_NODEADDR_FLAG_COMPAT 0x4
424 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
425 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
426 #define NI_NODEADDR_FLAG_GLOBAL 0x20
427 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
428 #elif _BYTE_ORDER == _LITTLE_ENDIAN
429 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
430 #define NI_NODEADDR_FLAG_ALL 0x0200
431 #define NI_NODEADDR_FLAG_COMPAT 0x0400
432 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
433 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
434 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
435 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
436 #else
437 #error "Byte order not implemented"
438 #endif
439 #endif
441 struct ni_reply_fqdn {
442 u_int32_t ni_fqdn_ttl; /* TTL */
443 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
444 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
445 } __attribute__((__packed__));
448 * Router Renumbering. as router-renum-08.txt
450 struct icmp6_router_renum { /* router renumbering header */
451 struct icmp6_hdr rr_hdr;
452 u_int8_t rr_segnum;
453 u_int8_t rr_flags;
454 u_int16_t rr_maxdelay;
455 u_int32_t rr_reserved;
456 } __attribute__((__packed__));
458 #define ICMP6_RR_FLAGS_TEST 0x80
459 #define ICMP6_RR_FLAGS_REQRESULT 0x40
460 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
461 #define ICMP6_RR_FLAGS_SPECSITE 0x10
462 #define ICMP6_RR_FLAGS_PREVDONE 0x08
464 #define rr_type rr_hdr.icmp6_type
465 #define rr_code rr_hdr.icmp6_code
466 #define rr_cksum rr_hdr.icmp6_cksum
467 #define rr_seqnum rr_hdr.icmp6_data32[0]
469 struct rr_pco_match { /* match prefix part */
470 u_int8_t rpm_code;
471 u_int8_t rpm_len;
472 u_int8_t rpm_ordinal;
473 u_int8_t rpm_matchlen;
474 u_int8_t rpm_minlen;
475 u_int8_t rpm_maxlen;
476 u_int16_t rpm_reserved;
477 struct in6_addr rpm_prefix;
478 } __attribute__((__packed__));
480 #define RPM_PCO_ADD 1
481 #define RPM_PCO_CHANGE 2
482 #define RPM_PCO_SETGLOBAL 3
483 #define RPM_PCO_MAX 4
485 struct rr_pco_use { /* use prefix part */
486 u_int8_t rpu_uselen;
487 u_int8_t rpu_keeplen;
488 u_int8_t rpu_ramask;
489 u_int8_t rpu_raflags;
490 u_int32_t rpu_vltime;
491 u_int32_t rpu_pltime;
492 u_int32_t rpu_flags;
493 struct in6_addr rpu_prefix;
494 } __attribute__((__packed__));
495 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
496 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
498 #if _BYTE_ORDER == _BIG_ENDIAN
499 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
500 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
501 #elif _BYTE_ORDER == _LITTLE_ENDIAN
502 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
503 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
504 #else
505 #error "Byte order not implemented"
506 #endif
508 struct rr_result { /* router renumbering result message */
509 u_int16_t rrr_flags;
510 u_int8_t rrr_ordinal;
511 u_int8_t rrr_matchedlen;
512 u_int32_t rrr_ifid;
513 struct in6_addr rrr_prefix;
514 } __attribute__((__packed__));
515 #if _BYTE_ORDER == _BIG_ENDIAN
516 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
517 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
518 #elif _BYTE_ORDER == _LITTLE_ENDIAN
519 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
520 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
521 #else
522 #error "Byte order not implemented"
523 #endif
526 * icmp6 filter structures.
529 struct icmp6_filter {
530 u_int32_t icmp6_filt[8];
533 #ifdef _KERNEL
534 #define ICMP6_FILTER_SETPASSALL(filterp) \
535 do { \
536 int i; u_char *p; \
537 p = (u_char *)filterp; \
538 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
539 p[i] = 0xff; \
540 } while (0)
541 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
542 bzero(filterp, sizeof(struct icmp6_filter))
543 #else /* _KERNEL */
544 #define ICMP6_FILTER_SETPASSALL(filterp) \
545 memset(filterp, 0xff, sizeof(struct icmp6_filter))
546 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
547 memset(filterp, 0x00, sizeof(struct icmp6_filter))
548 #endif /* _KERNEL */
550 #define ICMP6_FILTER_SETPASS(type, filterp) \
551 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
552 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
553 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
554 #define ICMP6_FILTER_WILLPASS(type, filterp) \
555 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
556 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
557 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
560 * Variables related to this implementation
561 * of the internet control message protocol version 6.
563 struct icmp6errstat {
564 u_quad_t icp6errs_dst_unreach_noroute;
565 u_quad_t icp6errs_dst_unreach_admin;
566 u_quad_t icp6errs_dst_unreach_beyondscope;
567 u_quad_t icp6errs_dst_unreach_addr;
568 u_quad_t icp6errs_dst_unreach_noport;
569 u_quad_t icp6errs_packet_too_big;
570 u_quad_t icp6errs_time_exceed_transit;
571 u_quad_t icp6errs_time_exceed_reassembly;
572 u_quad_t icp6errs_paramprob_header;
573 u_quad_t icp6errs_paramprob_nextheader;
574 u_quad_t icp6errs_paramprob_option;
575 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
576 u_quad_t icp6errs_unknown;
579 struct icmp6stat {
580 /* statistics related to icmp6 packets generated */
581 u_quad_t icp6s_error; /* # of calls to icmp6_error */
582 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
583 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
584 u_quad_t icp6s_outhist[256];
585 /* statistics related to input message processed */
586 u_quad_t icp6s_badcode; /* icmp6_code out of range */
587 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
588 u_quad_t icp6s_checksum; /* bad checksum */
589 u_quad_t icp6s_badlen; /* calculated bound mismatch */
591 * number of responses: this member is inherited from netinet code, but
592 * for netinet6 code, it is already available in icp6s_outhist[].
594 u_quad_t icp6s_reflect;
595 u_quad_t icp6s_inhist[256];
596 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
597 struct icmp6errstat icp6s_outerrhist;
598 #define icp6s_odst_unreach_noroute \
599 icp6s_outerrhist.icp6errs_dst_unreach_noroute
600 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
601 #define icp6s_odst_unreach_beyondscope \
602 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
603 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
604 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
605 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
606 #define icp6s_otime_exceed_transit \
607 icp6s_outerrhist.icp6errs_time_exceed_transit
608 #define icp6s_otime_exceed_reassembly \
609 icp6s_outerrhist.icp6errs_time_exceed_reassembly
610 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
611 #define icp6s_oparamprob_nextheader \
612 icp6s_outerrhist.icp6errs_paramprob_nextheader
613 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
614 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
615 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
616 u_quad_t icp6s_pmtuchg; /* path MTU changes */
617 u_quad_t icp6s_nd_badopt; /* bad ND options */
618 u_quad_t icp6s_badns; /* bad neighbor solicitation */
619 u_quad_t icp6s_badna; /* bad neighbor advertisement */
620 u_quad_t icp6s_badrs; /* bad router advertisement */
621 u_quad_t icp6s_badra; /* bad router advertisement */
622 u_quad_t icp6s_badredirect; /* bad redirect message */
626 * Names for ICMP sysctl objects
628 #define ICMPV6CTL_STATS 1
629 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
630 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
631 #if 0 /*obsoleted*/
632 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
633 #endif
634 #define ICMPV6CTL_ND6_PRUNE 6
635 #define ICMPV6CTL_ND6_DELAY 8
636 #define ICMPV6CTL_ND6_UMAXTRIES 9
637 #define ICMPV6CTL_ND6_MMAXTRIES 10
638 #define ICMPV6CTL_ND6_USELOOPBACK 11
639 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
640 #define ICMPV6CTL_NODEINFO 13
641 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
642 #define ICMPV6CTL_ND6_MAXNUDHINT 15
643 #define ICMPV6CTL_MTUDISC_HIWAT 16
644 #define ICMPV6CTL_MTUDISC_LOWAT 17
645 #define ICMPV6CTL_ND6_DEBUG 18
646 #define ICMPV6CTL_ND6_DRLIST 19
647 #define ICMPV6CTL_ND6_PRLIST 20
648 #define ICMPV6CTL_MAXID 21
650 #define ICMPV6CTL_NAMES { \
651 { 0, 0 }, \
652 { 0, 0 }, \
653 { "rediraccept", CTLTYPE_INT }, \
654 { "redirtimeout", CTLTYPE_INT }, \
655 { 0, 0 }, \
656 { 0, 0 }, \
657 { "nd6_prune", CTLTYPE_INT }, \
658 { 0, 0 }, \
659 { "nd6_delay", CTLTYPE_INT }, \
660 { "nd6_umaxtries", CTLTYPE_INT }, \
661 { "nd6_mmaxtries", CTLTYPE_INT }, \
662 { "nd6_useloopback", CTLTYPE_INT }, \
663 { 0, 0 }, \
664 { "nodeinfo", CTLTYPE_INT }, \
665 { "errppslimit", CTLTYPE_INT }, \
666 { "nd6_maxnudhint", CTLTYPE_INT }, \
667 { "mtudisc_hiwat", CTLTYPE_INT }, \
668 { "mtudisc_lowat", CTLTYPE_INT }, \
669 { "nd6_debug", CTLTYPE_INT }, \
670 { 0, 0 }, \
671 { 0, 0 }, \
674 #define RTF_PROBEMTU RTF_PROTO1
676 #ifdef _KERNEL
677 # ifdef __STDC__
678 struct rtentry;
679 struct rttimer;
680 struct in6_multi;
681 # endif
682 void icmp6_init (void);
683 void icmp6_paramerror (struct mbuf *, int);
684 void icmp6_error (struct mbuf *, int, int, int);
685 int icmp6_input (struct mbuf **, int *, int);
686 void icmp6_fasttimo (void);
687 void icmp6_reflect (struct mbuf *, size_t);
688 void icmp6_prepare (struct mbuf *);
689 void icmp6_redirect_input (struct mbuf *, int);
690 void icmp6_redirect_output (struct mbuf *, struct rtentry *);
692 struct ip6ctlparam;
693 void icmp6_mtudisc_update (struct ip6ctlparam *, int);
695 /* XXX: is this the right place for these macros? */
696 #define icmp6_ifstat_inc(ifp, tag) \
697 do { \
698 if (ifp) \
699 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
700 } while (0)
702 #define icmp6_ifoutstat_inc(ifp, type, code) \
703 do { \
704 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
705 if (type < ICMP6_INFOMSG_MASK) \
706 icmp6_ifstat_inc(ifp, ifs6_out_error); \
707 switch (type) { \
708 case ICMP6_DST_UNREACH: \
709 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
710 if (code == ICMP6_DST_UNREACH_ADMIN) \
711 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
712 break; \
713 case ICMP6_PACKET_TOO_BIG: \
714 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
715 break; \
716 case ICMP6_TIME_EXCEEDED: \
717 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
718 break; \
719 case ICMP6_PARAM_PROB: \
720 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
721 break; \
722 case ICMP6_ECHO_REQUEST: \
723 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
724 break; \
725 case ICMP6_ECHO_REPLY: \
726 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
727 break; \
728 case MLD_LISTENER_QUERY: \
729 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
730 break; \
731 case MLD_LISTENER_REPORT: \
732 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
733 break; \
734 case MLD_LISTENER_DONE: \
735 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
736 break; \
737 case ND_ROUTER_SOLICIT: \
738 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
739 break; \
740 case ND_ROUTER_ADVERT: \
741 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
742 break; \
743 case ND_NEIGHBOR_SOLICIT: \
744 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
745 break; \
746 case ND_NEIGHBOR_ADVERT: \
747 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
748 break; \
749 case ND_REDIRECT: \
750 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
751 break; \
753 } while (0)
755 extern int icmp6_rediraccept; /* accept/process redirects */
756 extern int icmp6_redirtimeout; /* cache time for redirect routes */
757 #endif /* _KERNEL */
759 #endif /* not _NETINET_ICMP6_H_ */