icmp6.h revision 1.8.2.1 1 /* $NetBSD: icmp6.h,v 1.8.2.1 2000/06/22 17:09:44 minoura Exp $ */
2 /* $KAME: icmp6.h,v 1.17 2000/06/11 17:23:40 jinmei Exp $ */
3
4 /*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
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.
19 *
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.
31 */
32
33 /*
34 * Copyright (c) 1982, 1986, 1993
35 * The Regents of the University of California. All rights reserved.
36 *
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. 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.
52 *
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
63 * SUCH DAMAGE.
64 *
65 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
66 */
67
68 #ifndef _NETINET_ICMP6_H_
69 #define _NETINET_ICMP6_H_
70
71 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
72 - sizeof(struct icmp6_hdr) */
73
74 struct icmp6_hdr {
75 u_int8_t icmp6_type; /* type field */
76 u_int8_t icmp6_code; /* code field */
77 u_int16_t icmp6_cksum; /* checksum field */
78 union {
79 u_int32_t icmp6_un_data32[1]; /* type-specific field */
80 u_int16_t icmp6_un_data16[2]; /* type-specific field */
81 u_int8_t icmp6_un_data8[4]; /* type-specific field */
82 } icmp6_dataun;
83 };
84
85 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
86 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
87 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
88 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
89 #define icmp6_mtu icmp6_data32[0] /* packet too big */
90 #define icmp6_id icmp6_data16[0] /* echo request/reply */
91 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
92 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
93
94 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
95 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
96 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
97 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
98
99 #define ICMP6_ECHO_REQUEST 128 /* echo service */
100 #define ICMP6_ECHO_REPLY 129 /* echo reply */
101 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
102 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
103 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
104 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
105 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
106 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
107
108 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
109 #define ND_ROUTER_ADVERT 134 /* router advertisment */
110 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
111 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
112 #define ND_REDIRECT 137 /* redirect */
113
114 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
115
116 #define ICMP6_WRUREQUEST 139 /* who are you request */
117 #define ICMP6_WRUREPLY 140 /* who are you reply */
118 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
119 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
120 #define ICMP6_NI_QUERY 139 /* node information request */
121 #define ICMP6_NI_REPLY 140 /* node information reply */
122
123 /* The definitions below are experimental. TBA */
124 #define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */
125 #define MLD6_MTRACE 142 /* mtrace messages */
126
127 #define ICMP6_MAXTYPE 142
128
129 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
130 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
131 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
132 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
133 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
134 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
135
136 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
137 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
138
139 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
140 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
141 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
142
143 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
144
145 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
146 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
147 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
148
149 #define ICMP6_NI_SUCESS 0 /* node information successful reply */
150 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
151 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
152
153 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
154 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
155 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
156
157 /* Used in kernel only */
158 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
159 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
160
161 /*
162 * Multicast Listener Discovery
163 */
164 struct mld6_hdr {
165 struct icmp6_hdr mld6_hdr;
166 struct in6_addr mld6_addr; /* multicast address */
167 };
168
169 #define mld6_type mld6_hdr.icmp6_type
170 #define mld6_code mld6_hdr.icmp6_code
171 #define mld6_cksum mld6_hdr.icmp6_cksum
172 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
173 #define mld6_reserved mld6_hdr.icmp6_data16[1]
174
175 /*
176 * Neighbor Discovery
177 */
178
179 struct nd_router_solicit { /* router solicitation */
180 struct icmp6_hdr nd_rs_hdr;
181 /* could be followed by options */
182 };
183
184 #define nd_rs_type nd_rs_hdr.icmp6_type
185 #define nd_rs_code nd_rs_hdr.icmp6_code
186 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
187 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
188
189 struct nd_router_advert { /* router advertisement */
190 struct icmp6_hdr nd_ra_hdr;
191 u_int32_t nd_ra_reachable; /* reachable time */
192 u_int32_t nd_ra_retransmit; /* retransmit timer */
193 /* could be followed by options */
194 };
195
196 #define nd_ra_type nd_ra_hdr.icmp6_type
197 #define nd_ra_code nd_ra_hdr.icmp6_code
198 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
199 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
200 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
201 #define ND_RA_FLAG_MANAGED 0x80
202 #define ND_RA_FLAG_OTHER 0x40
203 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
204
205 struct nd_neighbor_solicit { /* neighbor solicitation */
206 struct icmp6_hdr nd_ns_hdr;
207 struct in6_addr nd_ns_target; /*target address */
208 /* could be followed by options */
209 };
210
211 #define nd_ns_type nd_ns_hdr.icmp6_type
212 #define nd_ns_code nd_ns_hdr.icmp6_code
213 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
214 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
215
216 struct nd_neighbor_advert { /* neighbor advertisement */
217 struct icmp6_hdr nd_na_hdr;
218 struct in6_addr nd_na_target; /* target address */
219 /* could be followed by options */
220 };
221
222 #define nd_na_type nd_na_hdr.icmp6_type
223 #define nd_na_code nd_na_hdr.icmp6_code
224 #define nd_na_cksum nd_na_hdr.icmp6_cksum
225 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
226 #if BYTE_ORDER == BIG_ENDIAN
227 #define ND_NA_FLAG_ROUTER 0x80000000
228 #define ND_NA_FLAG_SOLICITED 0x40000000
229 #define ND_NA_FLAG_OVERRIDE 0x20000000
230 #else
231 #if BYTE_ORDER == LITTLE_ENDIAN
232 #define ND_NA_FLAG_ROUTER 0x80
233 #define ND_NA_FLAG_SOLICITED 0x40
234 #define ND_NA_FLAG_OVERRIDE 0x20
235 #endif
236 #endif
237
238 struct nd_redirect { /* redirect */
239 struct icmp6_hdr nd_rd_hdr;
240 struct in6_addr nd_rd_target; /* target address */
241 struct in6_addr nd_rd_dst; /* destination address */
242 /* could be followed by options */
243 };
244
245 #define nd_rd_type nd_rd_hdr.icmp6_type
246 #define nd_rd_code nd_rd_hdr.icmp6_code
247 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
248 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
249
250 struct nd_opt_hdr { /* Neighbor discovery option header */
251 u_int8_t nd_opt_type;
252 u_int8_t nd_opt_len;
253 /* followed by option specific data*/
254 };
255
256 #define ND_OPT_SOURCE_LINKADDR 1
257 #define ND_OPT_TARGET_LINKADDR 2
258 #define ND_OPT_PREFIX_INFORMATION 3
259 #define ND_OPT_REDIRECTED_HEADER 4
260 #define ND_OPT_MTU 5
261
262 struct nd_opt_prefix_info { /* prefix information */
263 u_int8_t nd_opt_pi_type;
264 u_int8_t nd_opt_pi_len;
265 u_int8_t nd_opt_pi_prefix_len;
266 u_int8_t nd_opt_pi_flags_reserved;
267 u_int32_t nd_opt_pi_valid_time;
268 u_int32_t nd_opt_pi_preferred_time;
269 u_int32_t nd_opt_pi_reserved2;
270 struct in6_addr nd_opt_pi_prefix;
271 };
272
273 #define ND_OPT_PI_FLAG_ONLINK 0x80
274 #define ND_OPT_PI_FLAG_AUTO 0x40
275
276 struct nd_opt_rd_hdr { /* redirected header */
277 u_int8_t nd_opt_rh_type;
278 u_int8_t nd_opt_rh_len;
279 u_int16_t nd_opt_rh_reserved1;
280 u_int32_t nd_opt_rh_reserved2;
281 /* followed by IP header and data */
282 };
283
284 struct nd_opt_mtu { /* MTU option */
285 u_int8_t nd_opt_mtu_type;
286 u_int8_t nd_opt_mtu_len;
287 u_int16_t nd_opt_mtu_reserved;
288 u_int32_t nd_opt_mtu_mtu;
289 };
290
291 /*
292 * icmp6 namelookup
293 */
294
295 struct icmp6_namelookup {
296 struct icmp6_hdr icmp6_nl_hdr;
297 u_int8_t icmp6_nl_nonce[8];
298 int32_t icmp6_nl_ttl;
299 #if 0
300 u_int8_t icmp6_nl_len;
301 u_int8_t icmp6_nl_name[3];
302 #endif
303 /* could be followed by options */
304 };
305
306 /*
307 * icmp6 node information
308 */
309 struct icmp6_nodeinfo {
310 struct icmp6_hdr icmp6_ni_hdr;
311 u_int8_t icmp6_ni_nonce[8];
312 /* could be followed by reply data */
313 };
314
315 #define ni_type icmp6_ni_hdr.icmp6_type
316 #define ni_code icmp6_ni_hdr.icmp6_code
317 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
318 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
319 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
320
321 #define NI_QTYPE_NOOP 0 /* NOOP */
322 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
323 #define NI_QTYPE_FQDN 2 /* FQDN */
324 #define NI_QTYPE_NODEADDR 3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */
325
326 #if BYTE_ORDER == BIG_ENDIAN
327 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
328 #define NI_FQDN_FLAG_VALIDTTL 0x1
329 #elif BYTE_ORDER == LITTLE_ENDIAN
330 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
331 #define NI_FQDN_FLAG_VALIDTTL 0x0100
332 #endif
333
334 #ifdef NAME_LOOKUPS_04
335 #if BYTE_ORDER == BIG_ENDIAN
336 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
337 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
338 #define NI_NODEADDR_FLAG_GLOBAL 0x4
339 #define NI_NODEADDR_FLAG_ALL 0x8
340 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
341 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
342 #elif BYTE_ORDER == LITTLE_ENDIAN
343 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
344 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
345 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
346 #define NI_NODEADDR_FLAG_ALL 0x0800
347 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
348 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
349 #endif
350 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
351 #if BYTE_ORDER == BIG_ENDIAN
352 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
353 #define NI_NODEADDR_FLAG_ALL 0x2
354 #define NI_NODEADDR_FLAG_COMPAT 0x4
355 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
356 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
357 #define NI_NODEADDR_FLAG_GLOBAL 0x20
358 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
359 #elif BYTE_ORDER == LITTLE_ENDIAN
360 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
361 #define NI_NODEADDR_FLAG_ALL 0x0200
362 #define NI_NODEADDR_FLAG_COMPAT 0x0400
363 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
364 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
365 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
366 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
367 #endif
368 #endif
369
370 struct ni_reply_fqdn {
371 u_int32_t ni_fqdn_ttl; /* TTL */
372 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
373 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
374 };
375
376 /*
377 * Router Renumbering. as router-renum-08.txt
378 */
379 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
380 struct icmp6_router_renum { /* router renumbering header */
381 struct icmp6_hdr rr_hdr;
382 u_int8_t rr_segnum;
383 u_int8_t rr_test : 1;
384 u_int8_t rr_reqresult : 1;
385 u_int8_t rr_forceapply : 1;
386 u_int8_t rr_specsite : 1;
387 u_int8_t rr_prevdone : 1;
388 u_int8_t rr_flags_reserved : 3;
389 u_int16_t rr_maxdelay;
390 u_int32_t rr_reserved;
391 };
392 #elif BYTE_ORDER == LITTLE_ENDIAN
393 struct icmp6_router_renum { /* router renumbering header */
394 struct icmp6_hdr rr_hdr;
395 u_int8_t rr_segnum;
396 u_int8_t rr_flags_reserved : 3;
397 u_int8_t rr_prevdone : 1;
398 u_int8_t rr_specsite : 1;
399 u_int8_t rr_forceapply : 1;
400 u_int8_t rr_reqresult : 1;
401 u_int8_t rr_test : 1;
402 u_int16_t rr_maxdelay;
403 u_int32_t rr_reserved;
404 };
405 #endif /* BYTE_ORDER */
406
407 #define rr_type rr_hdr.icmp6_type
408 #define rr_code rr_hdr.icmp6_code
409 #define rr_cksum rr_hdr.icmp6_cksum
410 #define rr_seqnum rr_hdr.icmp6_data32[0]
411
412 struct rr_pco_match { /* match prefix part */
413 u_int8_t rpm_code;
414 u_int8_t rpm_len;
415 u_int8_t rpm_ordinal;
416 u_int8_t rpm_matchlen;
417 u_int8_t rpm_minlen;
418 u_int8_t rpm_maxlen;
419 u_int16_t rpm_reserved;
420 struct in6_addr rpm_prefix;
421 };
422
423 #define RPM_PCO_ADD 1
424 #define RPM_PCO_CHANGE 2
425 #define RPM_PCO_SETGLOBAL 3
426 #define RPM_PCO_MAX 4
427
428 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
429 struct rr_pco_use { /* use prefix part */
430 u_int8_t rpu_uselen;
431 u_int8_t rpu_keeplen;
432 u_int8_t rpu_mask_onlink : 1;
433 u_int8_t rpu_mask_autonomous : 1;
434 u_int8_t rpu_mask_reserved : 6;
435 u_int8_t rpu_onlink : 1;
436 u_int8_t rpu_autonomous : 1;
437 u_int8_t rpu_raflags_reserved : 6;
438 u_int32_t rpu_vltime;
439 u_int32_t rpu_pltime;
440 u_int32_t rpu_decr_vltime : 1;
441 u_int32_t rpu_decr_pltime : 1;
442 u_int32_t rpu_flags_reserved : 6;
443 u_int32_t rpu_reserved : 24;
444 struct in6_addr rpu_prefix;
445 };
446 #elif BYTE_ORDER == LITTLE_ENDIAN
447 struct rr_pco_use { /* use prefix part */
448 u_int8_t rpu_uselen;
449 u_int8_t rpu_keeplen;
450 u_int8_t rpu_mask_reserved : 6;
451 u_int8_t rpu_mask_autonomous : 1;
452 u_int8_t rpu_mask_onlink : 1;
453 u_int8_t rpu_raflags_reserved : 6;
454 u_int8_t rpu_autonomous : 1;
455 u_int8_t rpu_onlink : 1;
456 u_int32_t rpu_vltime;
457 u_int32_t rpu_pltime;
458 u_int32_t rpu_flags_reserved : 6;
459 u_int32_t rpu_decr_pltime : 1;
460 u_int32_t rpu_decr_vltime : 1;
461 u_int32_t rpu_reserved : 24;
462 struct in6_addr rpu_prefix;
463 };
464 #endif /* BYTE_ORDER */
465
466 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
467 struct rr_result { /* router renumbering result message */
468 u_int8_t rrr_reserved;
469 u_int8_t rrr_flags_reserved : 6;
470 u_int8_t rrr_outofbound : 1;
471 u_int8_t rrr_forbidden : 1;
472 u_int8_t rrr_ordinal;
473 u_int8_t rrr_matchedlen;
474 u_int32_t rrr_ifid;
475 struct in6_addr rrr_prefix;
476 };
477 #elif BYTE_ORDER == LITTLE_ENDIAN
478 struct rr_result { /* router renumbering result message */
479 u_int8_t rrr_reserved;
480 u_int8_t rrr_forbidden : 1;
481 u_int8_t rrr_outofbound : 1;
482 u_int8_t rrr_flags_reserved : 6;
483 u_int8_t rrr_ordinal;
484 u_int8_t rrr_matchedlen;
485 u_int32_t rrr_ifid;
486 struct in6_addr rrr_prefix;
487 };
488 #endif /* BYTE_ORDER */
489
490 /*
491 * icmp6 filter structures.
492 */
493
494 struct icmp6_filter {
495 u_int32_t icmp6_filt[8];
496 };
497
498 #ifdef _KERNEL
499 #define ICMP6_FILTER_SETPASSALL(filterp) \
500 do { \
501 int i; u_char *p; \
502 p = (u_char *)filterp; \
503 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
504 p[i] = 0xff; \
505 } while (0)
506 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
507 bzero(filterp, sizeof(struct icmp6_filter))
508 #else /* _KERNEL */
509 #define ICMP6_FILTER_SETPASSALL(filterp) \
510 memset(filterp, 0xff, sizeof(struct icmp6_filter))
511 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
512 memset(filterp, 0x00, sizeof(struct icmp6_filter))
513 #endif /* _KERNEL */
514
515 #define ICMP6_FILTER_SETPASS(type, filterp) \
516 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
517 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
518 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
519 #define ICMP6_FILTER_WILLPASS(type, filterp) \
520 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
521 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
522 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
523
524 /*
525 * Variables related to this implementation
526 * of the internet control message protocol version 6.
527 */
528 struct icmp6stat {
529 /* statistics related to icmp6 packets generated */
530 u_quad_t icp6s_error; /* # of calls to icmp6_error */
531 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
532 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
533 u_quad_t icp6s_outhist[256];
534 /* statistics related to input message processed */
535 u_quad_t icp6s_badcode; /* icmp6_code out of range */
536 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
537 u_quad_t icp6s_checksum; /* bad checksum */
538 u_quad_t icp6s_badlen; /* calculated bound mismatch */
539 u_quad_t icp6s_reflect; /* number of responses */
540 u_quad_t icp6s_inhist[256];
541 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
542 };
543
544 /*
545 * Names for ICMP sysctl objects
546 */
547 #define ICMPV6CTL_STATS 1
548 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
549 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
550 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
551 #define ICMPV6CTL_ND6_PRUNE 6
552 #define ICMPV6CTL_ND6_DELAY 8
553 #define ICMPV6CTL_ND6_UMAXTRIES 9
554 #define ICMPV6CTL_ND6_MMAXTRIES 10
555 #define ICMPV6CTL_ND6_USELOOPBACK 11
556 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
557 #define ICMPV6CTL_NODEINFO 13
558 #define ICMPV6CTL_MAXID 14
559
560 #define ICMPV6CTL_NAMES { \
561 { 0, 0 }, \
562 { 0, 0 }, \
563 { "rediraccept", CTLTYPE_INT }, \
564 { "redirtimeout", CTLTYPE_INT }, \
565 { 0, 0 }, \
566 { "errratelimit", CTLTYPE_INT }, \
567 { "nd6_prune", CTLTYPE_INT }, \
568 { 0, 0 }, \
569 { "nd6_delay", CTLTYPE_INT }, \
570 { "nd6_umaxtries", CTLTYPE_INT }, \
571 { "nd6_mmaxtries", CTLTYPE_INT }, \
572 { "nd6_useloopback", CTLTYPE_INT }, \
573 { 0, 0 }, \
574 { "nodeinfo", CTLTYPE_INT }, \
575 }
576
577 #define RTF_PROBEMTU RTF_PROTO1
578
579 #ifdef _KERNEL
580 # ifdef __STDC__
581 struct rtentry;
582 struct rttimer;
583 struct in6_multi;
584 # endif
585 void icmp6_init __P((void));
586 void icmp6_paramerror __P((struct mbuf *, int));
587 void icmp6_error __P((struct mbuf *, int, int, int));
588 int icmp6_input __P((struct mbuf **, int *, int));
589 void icmp6_fasttimo __P((void));
590 void icmp6_reflect __P((struct mbuf *, size_t));
591 void icmp6_prepare __P((struct mbuf *));
592 void icmp6_redirect_input __P((struct mbuf *, int));
593 void icmp6_redirect_output __P((struct mbuf *, struct rtentry *));
594 int icmp6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
595
596 /* XXX: is this the right place for these macros? */
597 #define icmp6_ifstat_inc(ifp, tag) \
598 do { \
599 if ((ifp) && (ifp)->if_index <= if_index \
600 && (ifp)->if_index < icmp6_ifstatmax \
601 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
602 icmp6_ifstat[(ifp)->if_index]->tag++; \
603 } \
604 } while (0)
605
606 #define icmp6_ifoutstat_inc(ifp, type, code) \
607 do { \
608 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
609 if (type < ICMP6_INFOMSG_MASK) \
610 icmp6_ifstat_inc(ifp, ifs6_out_error); \
611 switch(type) { \
612 case ICMP6_DST_UNREACH: \
613 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
614 if (code == ICMP6_DST_UNREACH_ADMIN) \
615 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
616 break; \
617 case ICMP6_PACKET_TOO_BIG: \
618 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
619 break; \
620 case ICMP6_TIME_EXCEEDED: \
621 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
622 break; \
623 case ICMP6_PARAM_PROB: \
624 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
625 break; \
626 case ICMP6_ECHO_REQUEST: \
627 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
628 break; \
629 case ICMP6_ECHO_REPLY: \
630 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
631 break; \
632 case MLD6_LISTENER_QUERY: \
633 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
634 break; \
635 case MLD6_LISTENER_REPORT: \
636 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
637 break; \
638 case MLD6_LISTENER_DONE: \
639 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
640 break; \
641 case ND_ROUTER_SOLICIT: \
642 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
643 break; \
644 case ND_ROUTER_ADVERT: \
645 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
646 break; \
647 case ND_NEIGHBOR_SOLICIT: \
648 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
649 break; \
650 case ND_NEIGHBOR_ADVERT: \
651 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
652 break; \
653 case ND_REDIRECT: \
654 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
655 break; \
656 } \
657 } while (0)
658
659 extern int icmp6_rediraccept; /* accept/process redirects */
660 extern int icmp6_redirtimeout; /* cache time for redirect routes */
661 #endif /* _KERNEL */
662
663 #endif /* not _NETINET_ICMP6_H_ */
664