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