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