icmp6.h revision 1.11 1 /* $NetBSD: icmp6.h,v 1.11 2000/07/28 04:06:52 itojun Exp $ */
2 /* $KAME: icmp6.h,v 1.18 2000/07/03 02:51:08 itojun 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 struct icmp6_router_renum { /* router renumbering header */
380 struct icmp6_hdr rr_hdr;
381 u_int8_t rr_segnum;
382 u_int8_t rr_flags;
383 u_int16_t rr_maxdelay;
384 u_int32_t rr_reserved;
385 };
386 #define ICMP6_RR_FLAGS_SEGNUM 0x80
387 #define ICMP6_RR_FLAGS_TEST 0x40
388 #define ICMP6_RR_FLAGS_REQRESULT 0x20
389 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x10
390 #define ICMP6_RR_FLAGS_SPECSITE 0x08
391 #define ICMP6_RR_FLAGS_PREVDONE 0x04
392
393 #define rr_type rr_hdr.icmp6_type
394 #define rr_code rr_hdr.icmp6_code
395 #define rr_cksum rr_hdr.icmp6_cksum
396 #define rr_seqnum rr_hdr.icmp6_data32[0]
397
398 struct rr_pco_match { /* match prefix part */
399 u_int8_t rpm_code;
400 u_int8_t rpm_len;
401 u_int8_t rpm_ordinal;
402 u_int8_t rpm_matchlen;
403 u_int8_t rpm_minlen;
404 u_int8_t rpm_maxlen;
405 u_int16_t rpm_reserved;
406 struct in6_addr rpm_prefix;
407 };
408
409 #define RPM_PCO_ADD 1
410 #define RPM_PCO_CHANGE 2
411 #define RPM_PCO_SETGLOBAL 3
412 #define RPM_PCO_MAX 4
413
414 struct rr_pco_use { /* use prefix part */
415 u_int8_t rpu_uselen;
416 u_int8_t rpu_keeplen;
417 u_int8_t rpu_ramask;
418 u_int8_t rpu_raflags;
419 u_int32_t rpu_vltime;
420 u_int32_t rpu_pltime;
421 u_int32_t rpu_flags;
422 struct in6_addr rpu_prefix;
423 };
424 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
425 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
426
427 #if BYTE_ORDER == BIG_ENDIAN
428 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
429 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
430 #elif BYTE_ORDER == LITTLE_ENDIAN
431 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
432 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
433 #endif
434
435 struct rr_result { /* router renumbering result message */
436 u_int16_t rrr_flags;
437 u_int8_t rrr_ordinal;
438 u_int8_t rrr_matchedlen;
439 u_int32_t rrr_ifid;
440 struct in6_addr rrr_prefix;
441 };
442 #if BYTE_ORDER == BIG_ENDIAN
443 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
444 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
445 #elif BYTE_ORDER == LITTLE_ENDIAN
446 #define ICMP6_RR_RESULT_FLAGS_OOB 0x02
447 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x01
448 #endif
449
450 /*
451 * icmp6 filter structures.
452 */
453
454 struct icmp6_filter {
455 u_int32_t icmp6_filt[8];
456 };
457
458 #ifdef _KERNEL
459 #define ICMP6_FILTER_SETPASSALL(filterp) \
460 do { \
461 int i; u_char *p; \
462 p = (u_char *)filterp; \
463 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
464 p[i] = 0xff; \
465 } while (0)
466 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
467 bzero(filterp, sizeof(struct icmp6_filter))
468 #else /* _KERNEL */
469 #define ICMP6_FILTER_SETPASSALL(filterp) \
470 memset(filterp, 0xff, sizeof(struct icmp6_filter))
471 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
472 memset(filterp, 0x00, sizeof(struct icmp6_filter))
473 #endif /* _KERNEL */
474
475 #define ICMP6_FILTER_SETPASS(type, filterp) \
476 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
477 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
478 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
479 #define ICMP6_FILTER_WILLPASS(type, filterp) \
480 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
481 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
482 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
483
484 /*
485 * Variables related to this implementation
486 * of the internet control message protocol version 6.
487 */
488 struct icmp6errstat {
489 u_quad_t icp6errs_dst_unreach_noroute;
490 u_quad_t icp6errs_dst_unreach_admin;
491 u_quad_t icp6errs_dst_unreach_beyondscope;
492 u_quad_t icp6errs_dst_unreach_addr;
493 u_quad_t icp6errs_dst_unreach_noport;
494 u_quad_t icp6errs_packet_too_big;
495 u_quad_t icp6errs_time_exceed_transit;
496 u_quad_t icp6errs_time_exceed_reassembly;
497 u_quad_t icp6errs_paramprob_header;
498 u_quad_t icp6errs_paramprob_nextheader;
499 u_quad_t icp6errs_paramprob_option;
500 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
501 u_quad_t icp6errs_unknown;
502 };
503
504 struct icmp6stat {
505 /* statistics related to icmp6 packets generated */
506 u_quad_t icp6s_error; /* # of calls to icmp6_error */
507 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
508 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
509 u_quad_t icp6s_outhist[256];
510 /* statistics related to input message processed */
511 u_quad_t icp6s_badcode; /* icmp6_code out of range */
512 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
513 u_quad_t icp6s_checksum; /* bad checksum */
514 u_quad_t icp6s_badlen; /* calculated bound mismatch */
515 u_quad_t icp6s_reflect; /* number of responses */
516 u_quad_t icp6s_inhist[256];
517 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
518 struct icmp6errstat icp6s_outerrhist;
519 #define icp6s_odst_unreach_noroute \
520 icp6s_outerrhist.icp6errs_dst_unreach_noroute
521 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
522 #define icp6s_odst_unreach_beyondscope \
523 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
524 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
525 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
526 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
527 #define icp6s_otime_exceed_transit \
528 icp6s_outerrhist.icp6errs_time_exceed_transit
529 #define icp6s_otime_exceed_reassembly \
530 icp6s_outerrhist.icp6errs_time_exceed_reassembly
531 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
532 #define icp6s_oparamprob_nextheader \
533 icp6s_outerrhist.icp6errs_paramprob_nextheader
534 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
535 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
536 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
537 };
538
539 /*
540 * Names for ICMP sysctl objects
541 */
542 #define ICMPV6CTL_STATS 1
543 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
544 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
545 #if 0 /*obsoleted*/
546 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
547 #endif
548 #define ICMPV6CTL_ND6_PRUNE 6
549 #define ICMPV6CTL_ND6_DELAY 8
550 #define ICMPV6CTL_ND6_UMAXTRIES 9
551 #define ICMPV6CTL_ND6_MMAXTRIES 10
552 #define ICMPV6CTL_ND6_USELOOPBACK 11
553 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
554 #define ICMPV6CTL_NODEINFO 13
555 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
556 #define ICMPV6CTL_ND6_MAXNUDHINT 15
557 #define ICMPV6CTL_MAXID 16
558
559 #define ICMPV6CTL_NAMES { \
560 { 0, 0 }, \
561 { 0, 0 }, \
562 { "rediraccept", CTLTYPE_INT }, \
563 { "redirtimeout", CTLTYPE_INT }, \
564 { 0, 0 }, \
565 { 0, 0 }, \
566 { "nd6_prune", CTLTYPE_INT }, \
567 { 0, 0 }, \
568 { "nd6_delay", CTLTYPE_INT }, \
569 { "nd6_umaxtries", CTLTYPE_INT }, \
570 { "nd6_mmaxtries", CTLTYPE_INT }, \
571 { "nd6_useloopback", CTLTYPE_INT }, \
572 { 0, 0 }, \
573 { "nodeinfo", CTLTYPE_INT }, \
574 { "errppslimit", CTLTYPE_INT }, \
575 { "nd6_maxnudhint", CTLTYPE_INT }, \
576 }
577
578 #define RTF_PROBEMTU RTF_PROTO1
579
580 #ifdef _KERNEL
581 # ifdef __STDC__
582 struct rtentry;
583 struct rttimer;
584 struct in6_multi;
585 # endif
586 void icmp6_init __P((void));
587 void icmp6_paramerror __P((struct mbuf *, int));
588 void icmp6_error __P((struct mbuf *, int, int, int));
589 int icmp6_input __P((struct mbuf **, int *, int));
590 void icmp6_fasttimo __P((void));
591 void icmp6_reflect __P((struct mbuf *, size_t));
592 void icmp6_prepare __P((struct mbuf *));
593 void icmp6_redirect_input __P((struct mbuf *, int));
594 void icmp6_redirect_output __P((struct mbuf *, struct rtentry *));
595 int icmp6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
596
597 /* XXX: is this the right place for these macros? */
598 #define icmp6_ifstat_inc(ifp, tag) \
599 do { \
600 if ((ifp) && (ifp)->if_index <= if_index \
601 && (ifp)->if_index < icmp6_ifstatmax \
602 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
603 icmp6_ifstat[(ifp)->if_index]->tag++; \
604 } \
605 } while (0)
606
607 #define icmp6_ifoutstat_inc(ifp, type, code) \
608 do { \
609 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
610 if (type < ICMP6_INFOMSG_MASK) \
611 icmp6_ifstat_inc(ifp, ifs6_out_error); \
612 switch(type) { \
613 case ICMP6_DST_UNREACH: \
614 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
615 if (code == ICMP6_DST_UNREACH_ADMIN) \
616 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
617 break; \
618 case ICMP6_PACKET_TOO_BIG: \
619 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
620 break; \
621 case ICMP6_TIME_EXCEEDED: \
622 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
623 break; \
624 case ICMP6_PARAM_PROB: \
625 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
626 break; \
627 case ICMP6_ECHO_REQUEST: \
628 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
629 break; \
630 case ICMP6_ECHO_REPLY: \
631 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
632 break; \
633 case MLD6_LISTENER_QUERY: \
634 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
635 break; \
636 case MLD6_LISTENER_REPORT: \
637 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
638 break; \
639 case MLD6_LISTENER_DONE: \
640 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
641 break; \
642 case ND_ROUTER_SOLICIT: \
643 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
644 break; \
645 case ND_ROUTER_ADVERT: \
646 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
647 break; \
648 case ND_NEIGHBOR_SOLICIT: \
649 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
650 break; \
651 case ND_NEIGHBOR_ADVERT: \
652 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
653 break; \
654 case ND_REDIRECT: \
655 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
656 break; \
657 } \
658 } while (0)
659
660 extern int icmp6_rediraccept; /* accept/process redirects */
661 extern int icmp6_redirtimeout; /* cache time for redirect routes */
662 #endif /* _KERNEL */
663
664 #endif /* not _NETINET_ICMP6_H_ */
665