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