icmp6.h revision 1.6 1 /* $NetBSD: icmp6.h,v 1.6 2000/02/28 12:08:21 itojun Exp $ */
2 /* $KAME: icmp6.h,v 1.6 2000/02/24 16:34:46 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_SUCESS 0 /* node information successful reply */
146 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
147 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
148
149 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
150 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
151 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
152
153 /* Used in kernel only */
154 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
155 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
156
157 /*
158 * Multicast Listener Discovery
159 */
160 struct mld6_hdr {
161 struct icmp6_hdr mld6_hdr;
162 struct in6_addr mld6_addr; /* multicast address */
163 };
164
165 #define mld6_type mld6_hdr.icmp6_type
166 #define mld6_code mld6_hdr.icmp6_code
167 #define mld6_cksum mld6_hdr.icmp6_cksum
168 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
169 #define mld6_reserved mld6_hdr.icmp6_data16[1]
170
171 /*
172 * Neighbor Discovery
173 */
174
175 struct nd_router_solicit { /* router solicitation */
176 struct icmp6_hdr nd_rs_hdr;
177 /* could be followed by options */
178 };
179
180 #define nd_rs_type nd_rs_hdr.icmp6_type
181 #define nd_rs_code nd_rs_hdr.icmp6_code
182 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
183 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
184
185 struct nd_router_advert { /* router advertisement */
186 struct icmp6_hdr nd_ra_hdr;
187 u_int32_t nd_ra_reachable; /* reachable time */
188 u_int32_t nd_ra_retransmit; /* retransmit timer */
189 /* could be followed by options */
190 };
191
192 #define nd_ra_type nd_ra_hdr.icmp6_type
193 #define nd_ra_code nd_ra_hdr.icmp6_code
194 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
195 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
196 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
197 #define ND_RA_FLAG_MANAGED 0x80
198 #define ND_RA_FLAG_OTHER 0x40
199 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
200
201 struct nd_neighbor_solicit { /* neighbor solicitation */
202 struct icmp6_hdr nd_ns_hdr;
203 struct in6_addr nd_ns_target; /*target address */
204 /* could be followed by options */
205 };
206
207 #define nd_ns_type nd_ns_hdr.icmp6_type
208 #define nd_ns_code nd_ns_hdr.icmp6_code
209 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
210 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
211
212 struct nd_neighbor_advert { /* neighbor advertisement */
213 struct icmp6_hdr nd_na_hdr;
214 struct in6_addr nd_na_target; /* target address */
215 /* could be followed by options */
216 };
217
218 #define nd_na_type nd_na_hdr.icmp6_type
219 #define nd_na_code nd_na_hdr.icmp6_code
220 #define nd_na_cksum nd_na_hdr.icmp6_cksum
221 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
222 #if BYTE_ORDER == BIG_ENDIAN
223 #define ND_NA_FLAG_ROUTER 0x80000000
224 #define ND_NA_FLAG_SOLICITED 0x40000000
225 #define ND_NA_FLAG_OVERRIDE 0x20000000
226 #else
227 #if BYTE_ORDER == LITTLE_ENDIAN
228 #define ND_NA_FLAG_ROUTER 0x80
229 #define ND_NA_FLAG_SOLICITED 0x40
230 #define ND_NA_FLAG_OVERRIDE 0x20
231 #endif
232 #endif
233
234 struct nd_redirect { /* redirect */
235 struct icmp6_hdr nd_rd_hdr;
236 struct in6_addr nd_rd_target; /* target address */
237 struct in6_addr nd_rd_dst; /* destination address */
238 /* could be followed by options */
239 };
240
241 #define nd_rd_type nd_rd_hdr.icmp6_type
242 #define nd_rd_code nd_rd_hdr.icmp6_code
243 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
244 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
245
246 struct nd_opt_hdr { /* Neighbor discovery option header */
247 u_int8_t nd_opt_type;
248 u_int8_t nd_opt_len;
249 /* followed by option specific data*/
250 };
251
252 #define ND_OPT_SOURCE_LINKADDR 1
253 #define ND_OPT_TARGET_LINKADDR 2
254 #define ND_OPT_PREFIX_INFORMATION 3
255 #define ND_OPT_REDIRECTED_HEADER 4
256 #define ND_OPT_MTU 5
257
258 struct nd_opt_prefix_info { /* prefix information */
259 u_int8_t nd_opt_pi_type;
260 u_int8_t nd_opt_pi_len;
261 u_int8_t nd_opt_pi_prefix_len;
262 u_int8_t nd_opt_pi_flags_reserved;
263 u_int32_t nd_opt_pi_valid_time;
264 u_int32_t nd_opt_pi_preferred_time;
265 u_int32_t nd_opt_pi_reserved2;
266 struct in6_addr nd_opt_pi_prefix;
267 };
268
269 #define ND_OPT_PI_FLAG_ONLINK 0x80
270 #define ND_OPT_PI_FLAG_AUTO 0x40
271
272 struct nd_opt_rd_hdr { /* redirected header */
273 u_int8_t nd_opt_rh_type;
274 u_int8_t nd_opt_rh_len;
275 u_int16_t nd_opt_rh_reserved1;
276 u_int32_t nd_opt_rh_reserved2;
277 /* followed by IP header and data */
278 };
279
280 struct nd_opt_mtu { /* MTU option */
281 u_int8_t nd_opt_mtu_type;
282 u_int8_t nd_opt_mtu_len;
283 u_int16_t nd_opt_mtu_reserved;
284 u_int32_t nd_opt_mtu_mtu;
285 };
286
287 /*
288 * icmp6 namelookup
289 */
290
291 struct icmp6_namelookup {
292 struct icmp6_hdr icmp6_nl_hdr;
293 u_int8_t icmp6_nl_nonce[8];
294 u_int32_t icmp6_nl_ttl;
295 #if 0
296 u_int8_t icmp6_nl_len;
297 u_int8_t icmp6_nl_name[3];
298 #endif
299 /* could be followed by options */
300 };
301
302 /*
303 * icmp6 node information
304 */
305 struct icmp6_nodeinfo {
306 struct icmp6_hdr icmp6_ni_hdr;
307 u_int8_t icmp6_ni_nonce[8];
308 /* could be followed by reply data */
309 };
310
311 #define ni_type icmp6_ni_hdr.icmp6_type
312 #define ni_code icmp6_ni_hdr.icmp6_code
313 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
314 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
315 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
316
317
318 #define NI_QTYPE_NOOP 0 /* NOOP */
319 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
320 #define NI_QTYPE_FQDN 2 /* FQDN */
321 #define NI_QTYPE_NODEADDR 3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */
322
323 #if BYTE_ORDER == BIG_ENDIAN
324 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
325 #define NI_FQDN_FLAG_VALIDTTL 0x1
326 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
327 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
328 #define NI_NODEADDR_FLAG_GLOBAL 0x4
329 #define NI_NODEADDR_FLAG_ALL 0x8
330 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
331 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
332 #elif BYTE_ORDER == LITTLE_ENDIAN
333 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
334 #define NI_FQDN_FLAG_VALIDTTL 0x0100
335 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
336 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
337 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
338 #define NI_NODEADDR_FLAG_ALL 0x0800
339 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
340 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
341 #endif
342
343 struct ni_reply_fqdn {
344 u_int32_t ni_fqdn_ttl; /* TTL */
345 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
346 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
347 };
348
349 /*
350 * Router Renumbering. as router-renum-08.txt
351 */
352 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
353 struct icmp6_router_renum { /* router renumbering header */
354 struct icmp6_hdr rr_hdr;
355 u_int8_t rr_segnum;
356 u_int8_t rr_test : 1;
357 u_int8_t rr_reqresult : 1;
358 u_int8_t rr_forceapply : 1;
359 u_int8_t rr_specsite : 1;
360 u_int8_t rr_prevdone : 1;
361 u_int8_t rr_flags_reserved : 3;
362 u_int16_t rr_maxdelay;
363 u_int32_t rr_reserved;
364 };
365 #elif BYTE_ORDER == LITTLE_ENDIAN
366 struct icmp6_router_renum { /* router renumbering header */
367 struct icmp6_hdr rr_hdr;
368 u_int8_t rr_segnum;
369 u_int8_t rr_flags_reserved : 3;
370 u_int8_t rr_prevdone : 1;
371 u_int8_t rr_specsite : 1;
372 u_int8_t rr_forceapply : 1;
373 u_int8_t rr_reqresult : 1;
374 u_int8_t rr_test : 1;
375 u_int16_t rr_maxdelay;
376 u_int32_t rr_reserved;
377 };
378 #endif /* BYTE_ORDER */
379
380 #define rr_type rr_hdr.icmp6_type
381 #define rr_code rr_hdr.icmp6_code
382 #define rr_cksum rr_hdr.icmp6_cksum
383 #define rr_seqnum rr_hdr.icmp6_data32[0]
384
385 struct rr_pco_match { /* match prefix part */
386 u_int8_t rpm_code;
387 u_int8_t rpm_len;
388 u_int8_t rpm_ordinal;
389 u_int8_t rpm_matchlen;
390 u_int8_t rpm_minlen;
391 u_int8_t rpm_maxlen;
392 u_int16_t rpm_reserved;
393 struct in6_addr rpm_prefix;
394 };
395
396 #define RPM_PCO_ADD 1
397 #define RPM_PCO_CHANGE 2
398 #define RPM_PCO_SETGLOBAL 3
399 #define RPM_PCO_MAX 4
400
401 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
402 struct rr_pco_use { /* use prefix part */
403 u_int8_t rpu_uselen;
404 u_int8_t rpu_keeplen;
405 u_int8_t rpu_mask_onlink : 1;
406 u_int8_t rpu_mask_autonomous : 1;
407 u_int8_t rpu_mask_reserved : 6;
408 u_int8_t rpu_onlink : 1;
409 u_int8_t rpu_autonomous : 1;
410 u_int8_t rpu_raflags_reserved : 6;
411 u_int32_t rpu_vltime;
412 u_int32_t rpu_pltime;
413 u_int32_t rpu_decr_vltime : 1;
414 u_int32_t rpu_decr_pltime : 1;
415 u_int32_t rpu_flags_reserved : 6;
416 u_int32_t rpu_reserved : 24;
417 struct in6_addr rpu_prefix;
418 };
419 #elif BYTE_ORDER == LITTLE_ENDIAN
420 struct rr_pco_use { /* use prefix part */
421 u_int8_t rpu_uselen;
422 u_int8_t rpu_keeplen;
423 u_int8_t rpu_mask_reserved : 6;
424 u_int8_t rpu_mask_autonomous : 1;
425 u_int8_t rpu_mask_onlink : 1;
426 u_int8_t rpu_raflags_reserved : 6;
427 u_int8_t rpu_autonomous : 1;
428 u_int8_t rpu_onlink : 1;
429 u_int32_t rpu_vltime;
430 u_int32_t rpu_pltime;
431 u_int32_t rpu_flags_reserved : 6;
432 u_int32_t rpu_decr_pltime : 1;
433 u_int32_t rpu_decr_vltime : 1;
434 u_int32_t rpu_reserved : 24;
435 struct in6_addr rpu_prefix;
436 };
437 #endif /* BYTE_ORDER */
438
439 #if BYTE_ORDER == BIG_ENDIAN /* net byte order */
440 struct rr_result { /* router renumbering result message */
441 u_int8_t rrr_reserved;
442 u_int8_t rrr_flags_reserved : 6;
443 u_int8_t rrr_outofbound : 1;
444 u_int8_t rrr_forbidden : 1;
445 u_int8_t rrr_ordinal;
446 u_int8_t rrr_matchedlen;
447 u_int32_t rrr_ifid;
448 struct in6_addr rrr_prefix;
449 };
450 #elif BYTE_ORDER == LITTLE_ENDIAN
451 struct rr_result { /* router renumbering result message */
452 u_int8_t rrr_reserved;
453 u_int8_t rrr_forbidden : 1;
454 u_int8_t rrr_outofbound : 1;
455 u_int8_t rrr_flags_reserved : 6;
456 u_int8_t rrr_ordinal;
457 u_int8_t rrr_matchedlen;
458 u_int32_t rrr_ifid;
459 struct in6_addr rrr_prefix;
460 };
461 #endif /* BYTE_ORDER */
462
463 /*
464 * icmp6 filter structures.
465 */
466
467 struct icmp6_filter {
468 u_int32_t icmp6_filter[8];
469 };
470
471 #ifdef _KERNEL
472 #define ICMP6_FILTER_SETPASSALL(filterp) \
473 do { \
474 int i; u_char *p; \
475 p = (u_char *)filterp; \
476 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
477 p[i] = 0xff; \
478 } while (0)
479 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
480 bzero(filterp, sizeof(struct icmp6_filter))
481 #else /* _KERNEL */
482 #define ICMP6_FILTER_SETPASSALL(filterp) \
483 memset(filterp, 0xff, sizeof(struct icmp6_filter))
484 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
485 memset(filterp, 0x00, sizeof(struct icmp6_filter))
486 #endif /* _KERNEL */
487
488 #define ICMP6_FILTER_SETPASS(type, filterp) \
489 (((filterp)->icmp6_filter[(type) >> 5]) |= (1 << ((type) & 31)))
490 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
491 (((filterp)->icmp6_filter[(type) >> 5]) &= ~(1 << ((type) & 31)))
492 #define ICMP6_FILTER_WILLPASS(type, filterp) \
493 ((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) != 0)
494 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
495 ((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) == 0)
496
497 /*
498 * Variables related to this implementation
499 * of the internet control message protocol version 6.
500 */
501 struct icmp6stat {
502 /* statistics related to icmp6 packets generated */
503 u_quad_t icp6s_error; /* # of calls to icmp6_error */
504 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
505 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
506 u_quad_t icp6s_outhist[256];
507 /* statistics related to input message processed */
508 u_quad_t icp6s_badcode; /* icmp6_code out of range */
509 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
510 u_quad_t icp6s_checksum; /* bad checksum */
511 u_quad_t icp6s_badlen; /* calculated bound mismatch */
512 u_quad_t icp6s_reflect; /* number of responses */
513 u_quad_t icp6s_inhist[256];
514 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
515 };
516
517 /*
518 * Names for ICMP sysctl objects
519 */
520 #define ICMPV6CTL_STATS 1
521 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
522 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
523 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
524 #define ICMPV6CTL_ND6_PRUNE 6
525 #define ICMPV6CTL_ND6_DELAY 8
526 #define ICMPV6CTL_ND6_UMAXTRIES 9
527 #define ICMPV6CTL_ND6_MMAXTRIES 10
528 #define ICMPV6CTL_ND6_USELOOPBACK 11
529 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
530 #define ICMPV6CTL_NODEINFO 13
531 #define ICMPV6CTL_MAXID 14
532
533 #define ICMPV6CTL_NAMES { \
534 { 0, 0 }, \
535 { 0, 0 }, \
536 { "rediraccept", CTLTYPE_INT }, \
537 { "redirtimeout", CTLTYPE_INT }, \
538 { 0, 0 }, \
539 { "errratelimit", CTLTYPE_INT }, \
540 { "nd6_prune", CTLTYPE_INT }, \
541 { 0, 0 }, \
542 { "nd6_delay", CTLTYPE_INT }, \
543 { "nd6_umaxtries", CTLTYPE_INT }, \
544 { "nd6_mmaxtries", CTLTYPE_INT }, \
545 { "nd6_useloopback", CTLTYPE_INT }, \
546 { 0, 0 }, \
547 { "nodeinfo", CTLTYPE_INT }, \
548 }
549
550 #define RTF_PROBEMTU RTF_PROTO1
551
552 #ifdef _KERNEL
553 # ifdef __STDC__
554 struct rtentry;
555 struct rttimer;
556 struct in6_multi;
557 # endif
558 void icmp6_init __P((void));
559 void icmp6_paramerror __P((struct mbuf *, int));
560 void icmp6_error __P((struct mbuf *, int, int, int));
561 int icmp6_input __P((struct mbuf **, int *, int));
562 void icmp6_fasttimo __P((void));
563 void icmp6_reflect __P((struct mbuf *, size_t));
564 void icmp6_prepare __P((struct mbuf *));
565 void icmp6_redirect_input __P((struct mbuf *, int));
566 void icmp6_redirect_output __P((struct mbuf *, struct rtentry *));
567 int icmp6_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
568
569 /* XXX: is this the right place for these macros? */
570 #define icmp6_ifstat_inc(ifp, tag) \
571 do { \
572 if ((ifp) && (ifp)->if_index <= if_index \
573 && (ifp)->if_index < icmp6_ifstatmax \
574 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
575 icmp6_ifstat[(ifp)->if_index]->tag++; \
576 } \
577 } while (0)
578
579 #define icmp6_ifoutstat_inc(ifp, type, code) \
580 do { \
581 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
582 if (type < ICMP6_INFOMSG_MASK) \
583 icmp6_ifstat_inc(ifp, ifs6_out_error); \
584 switch(type) { \
585 case ICMP6_DST_UNREACH: \
586 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
587 if (code == ICMP6_DST_UNREACH_ADMIN) \
588 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
589 break; \
590 case ICMP6_PACKET_TOO_BIG: \
591 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
592 break; \
593 case ICMP6_TIME_EXCEEDED: \
594 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
595 break; \
596 case ICMP6_PARAM_PROB: \
597 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
598 break; \
599 case ICMP6_ECHO_REQUEST: \
600 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
601 break; \
602 case ICMP6_ECHO_REPLY: \
603 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
604 break; \
605 case MLD6_LISTENER_QUERY: \
606 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
607 break; \
608 case MLD6_LISTENER_REPORT: \
609 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
610 break; \
611 case MLD6_LISTENER_DONE: \
612 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
613 break; \
614 case ND_ROUTER_SOLICIT: \
615 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
616 break; \
617 case ND_ROUTER_ADVERT: \
618 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
619 break; \
620 case ND_NEIGHBOR_SOLICIT: \
621 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
622 break; \
623 case ND_NEIGHBOR_ADVERT: \
624 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
625 break; \
626 case ND_REDIRECT: \
627 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
628 break; \
629 } \
630 } while (0)
631
632 extern int icmp6_rediraccept; /* accept/process redirects */
633 extern int icmp6_redirtimeout; /* cache time for redirect routes */
634 #endif /* _KERNEL */
635
636 #endif /* not _NETINET_ICMP6_H_ */
637