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