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