in6.h revision 1.1.2.1 1 1.1.2.1 itojun /*
2 1.1.2.1 itojun * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 1.1.2.1 itojun * All rights reserved.
4 1.1.2.1 itojun *
5 1.1.2.1 itojun * Redistribution and use in source and binary forms, with or without
6 1.1.2.1 itojun * modification, are permitted provided that the following conditions
7 1.1.2.1 itojun * are met:
8 1.1.2.1 itojun * 1. Redistributions of source code must retain the above copyright
9 1.1.2.1 itojun * notice, this list of conditions and the following disclaimer.
10 1.1.2.1 itojun * 2. Redistributions in binary form must reproduce the above copyright
11 1.1.2.1 itojun * notice, this list of conditions and the following disclaimer in the
12 1.1.2.1 itojun * documentation and/or other materials provided with the distribution.
13 1.1.2.1 itojun * 3. Neither the name of the project nor the names of its contributors
14 1.1.2.1 itojun * may be used to endorse or promote products derived from this software
15 1.1.2.1 itojun * without specific prior written permission.
16 1.1.2.1 itojun *
17 1.1.2.1 itojun * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 1.1.2.1 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.1.2.1 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.1.2.1 itojun * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 1.1.2.1 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1.2.1 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.1.2.1 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.1.2.1 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.1.2.1 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.1.2.1 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.1.2.1 itojun * SUCH DAMAGE.
28 1.1.2.1 itojun */
29 1.1.2.1 itojun
30 1.1.2.1 itojun /*
31 1.1.2.1 itojun * Copyright (c) 1982, 1986, 1990, 1993
32 1.1.2.1 itojun * The Regents of the University of California. All rights reserved.
33 1.1.2.1 itojun *
34 1.1.2.1 itojun * Redistribution and use in source and binary forms, with or without
35 1.1.2.1 itojun * modification, are permitted provided that the following conditions
36 1.1.2.1 itojun * are met:
37 1.1.2.1 itojun * 1. Redistributions of source code must retain the above copyright
38 1.1.2.1 itojun * notice, this list of conditions and the following disclaimer.
39 1.1.2.1 itojun * 2. Redistributions in binary form must reproduce the above copyright
40 1.1.2.1 itojun * notice, this list of conditions and the following disclaimer in the
41 1.1.2.1 itojun * documentation and/or other materials provided with the distribution.
42 1.1.2.1 itojun * 3. All advertising materials mentioning features or use of this software
43 1.1.2.1 itojun * must display the following acknowledgement:
44 1.1.2.1 itojun * This product includes software developed by the University of
45 1.1.2.1 itojun * California, Berkeley and its contributors.
46 1.1.2.1 itojun * 4. Neither the name of the University nor the names of its contributors
47 1.1.2.1 itojun * may be used to endorse or promote products derived from this software
48 1.1.2.1 itojun * without specific prior written permission.
49 1.1.2.1 itojun *
50 1.1.2.1 itojun * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 1.1.2.1 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 1.1.2.1 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 1.1.2.1 itojun * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 1.1.2.1 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 1.1.2.1 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 1.1.2.1 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 1.1.2.1 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 1.1.2.1 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 1.1.2.1 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 1.1.2.1 itojun * SUCH DAMAGE.
61 1.1.2.1 itojun *
62 1.1.2.1 itojun * @(#)in.h 8.3 (Berkeley) 1/3/94
63 1.1.2.1 itojun */
64 1.1.2.1 itojun
65 1.1.2.1 itojun #ifndef _NETINET6_IN6_H_
66 1.1.2.1 itojun #define _NETINET6_IN6_H_
67 1.1.2.1 itojun
68 1.1.2.1 itojun #include <sys/queue.h>
69 1.1.2.1 itojun
70 1.1.2.1 itojun /*
71 1.1.2.1 itojun * Identification of the network protocol stack
72 1.1.2.1 itojun */
73 1.1.2.1 itojun #define __KAME__
74 1.1.2.1 itojun #define __KAME_VERSION "SNAP 19990628"
75 1.1.2.1 itojun
76 1.1.2.1 itojun /*
77 1.1.2.1 itojun * Local port number conventions:
78 1.1.2.1 itojun *
79 1.1.2.1 itojun * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
80 1.1.2.1 itojun * unless a kernel is compiled with IPNOPRIVPORTS defined.
81 1.1.2.1 itojun *
82 1.1.2.1 itojun * When a user does a bind(2) or connect(2) with a port number of zero,
83 1.1.2.1 itojun * a non-conflicting local port address is chosen.
84 1.1.2.1 itojun *
85 1.1.2.1 itojun * The default range is IPPORT_ANONMIX to IPPORT_ANONMAX, although
86 1.1.2.1 itojun * that is settable by sysctl(3); net.inet.ip.anonportmin and
87 1.1.2.1 itojun * net.inet.ip.anonportmax respectively.
88 1.1.2.1 itojun *
89 1.1.2.1 itojun * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
90 1.1.2.1 itojun * default assignment range.
91 1.1.2.1 itojun *
92 1.1.2.1 itojun * The value IP_PORTRANGE_DEFAULT causes the default behavior.
93 1.1.2.1 itojun *
94 1.1.2.1 itojun * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
95 1.1.2.1 itojun * and exists only for FreeBSD compatibility purposes.
96 1.1.2.1 itojun *
97 1.1.2.1 itojun * The value IP_PORTRANGE_LOW changes the range to the "low" are
98 1.1.2.1 itojun * that is (by convention) restricted to privileged processes.
99 1.1.2.1 itojun * This convention is based on "vouchsafe" principles only.
100 1.1.2.1 itojun * It is only secure if you trust the remote host to restrict these ports.
101 1.1.2.1 itojun * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
102 1.1.2.1 itojun */
103 1.1.2.1 itojun
104 1.1.2.1 itojun #define IPV6PORT_RESERVED 1024
105 1.1.2.1 itojun #define IPV6PORT_ANONMIN 49152
106 1.1.2.1 itojun #define IPV6PORT_ANONMAX 65535
107 1.1.2.1 itojun #define IPV6PORT_RESERVEDMIN 600
108 1.1.2.1 itojun #define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1)
109 1.1.2.1 itojun
110 1.1.2.1 itojun /*
111 1.1.2.1 itojun * IPv6 address
112 1.1.2.1 itojun */
113 1.1.2.1 itojun struct in6_addr {
114 1.1.2.1 itojun union {
115 1.1.2.1 itojun u_int32_t u6_addr32[4];
116 1.1.2.1 itojun u_int16_t u6_addr16[8];
117 1.1.2.1 itojun u_int8_t u6_addr8[16];
118 1.1.2.1 itojun } u6_addr; /* 128 bit IP6 address */
119 1.1.2.1 itojun };
120 1.1.2.1 itojun
121 1.1.2.1 itojun #define s6_addr32 u6_addr.u6_addr32
122 1.1.2.1 itojun #define s6_addr16 u6_addr.u6_addr16
123 1.1.2.1 itojun #define s6_addr8 u6_addr.u6_addr8
124 1.1.2.1 itojun #define s6_addr u6_addr.u6_addr8
125 1.1.2.1 itojun
126 1.1.2.1 itojun #define INET6_ADDRSTRLEN 46
127 1.1.2.1 itojun
128 1.1.2.1 itojun /*
129 1.1.2.1 itojun * Socket address for IPv6
130 1.1.2.1 itojun */
131 1.1.2.1 itojun #define SIN6_LEN
132 1.1.2.1 itojun struct sockaddr_in6 {
133 1.1.2.1 itojun u_char sin6_len; /* length of this struct(sa_family_t)*/
134 1.1.2.1 itojun u_char sin6_family; /* AF_INET6 (sa_family_t) */
135 1.1.2.1 itojun u_int16_t sin6_port; /* Transport layer port # (in_port_t)*/
136 1.1.2.1 itojun u_int32_t sin6_flowinfo; /* IP6 flow information */
137 1.1.2.1 itojun struct in6_addr sin6_addr; /* IP6 address */
138 1.1.2.1 itojun u_int32_t sin6_scope_id; /* intface scope id */
139 1.1.2.1 itojun };
140 1.1.2.1 itojun
141 1.1.2.1 itojun /*
142 1.1.2.1 itojun * Local definition for masks
143 1.1.2.1 itojun */
144 1.1.2.1 itojun #define IN6MASK0 {{{ 0, 0, 0, 0 }}}
145 1.1.2.1 itojun #define IN6MASK32 {{{ 0xffffffff, 0, 0, 0 }}}
146 1.1.2.1 itojun #define IN6MASK64 {{{ 0xffffffff, 0xffffffff, 0, 0 }}}
147 1.1.2.1 itojun #define IN6MASK96 {{{ 0xffffffff, 0xffffffff, 0xffffffff, 0 }}}
148 1.1.2.1 itojun #define IN6MASK128 {{{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }}}
149 1.1.2.1 itojun
150 1.1.2.1 itojun #ifdef _KERNEL
151 1.1.2.1 itojun extern const struct in6_addr in6mask0;
152 1.1.2.1 itojun extern const struct in6_addr in6mask32;
153 1.1.2.1 itojun extern const struct in6_addr in6mask64;
154 1.1.2.1 itojun extern const struct in6_addr in6mask96;
155 1.1.2.1 itojun extern const struct in6_addr in6mask128;
156 1.1.2.1 itojun #endif /* _KERNEL */
157 1.1.2.1 itojun
158 1.1.2.1 itojun /*
159 1.1.2.1 itojun * Macros started with IPV6_ADDR is KAME local
160 1.1.2.1 itojun */
161 1.1.2.1 itojun
162 1.1.2.1 itojun #if BYTE_ORDER == BIG_ENDIAN
163 1.1.2.1 itojun #define IPV6_ADDR_INT32_ONE 1
164 1.1.2.1 itojun #define IPV6_ADDR_INT32_TWO 2
165 1.1.2.1 itojun #define IPV6_ADDR_INT32_MNL 0xff010000
166 1.1.2.1 itojun #define IPV6_ADDR_INT32_MLL 0xff020000
167 1.1.2.1 itojun #define IPV6_ADDR_INT32_SMP 0x0000ffff
168 1.1.2.1 itojun #define IPV6_ADDR_INT16_ULL 0xfe80
169 1.1.2.1 itojun #define IPV6_ADDR_INT16_USL 0xfec0
170 1.1.2.1 itojun #define IPV6_ADDR_INT16_MLL 0xff02
171 1.1.2.1 itojun #elif BYTE_ORDER == LITTLE_ENDIAN
172 1.1.2.1 itojun #define IPV6_ADDR_INT32_ONE 0x01000000
173 1.1.2.1 itojun #define IPV6_ADDR_INT32_TWO 0x02000000
174 1.1.2.1 itojun #define IPV6_ADDR_INT32_MNL 0x000001ff
175 1.1.2.1 itojun #define IPV6_ADDR_INT32_MLL 0x000002ff
176 1.1.2.1 itojun #define IPV6_ADDR_INT32_SMP 0xffff0000
177 1.1.2.1 itojun #define IPV6_ADDR_INT16_ULL 0x80fe
178 1.1.2.1 itojun #define IPV6_ADDR_INT16_USL 0xc0fe
179 1.1.2.1 itojun #define IPV6_ADDR_INT16_MLL 0x02ff
180 1.1.2.1 itojun #endif
181 1.1.2.1 itojun
182 1.1.2.1 itojun /*
183 1.1.2.1 itojun * Definition of some useful macros to handle IP6 addresses
184 1.1.2.1 itojun */
185 1.1.2.1 itojun #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
186 1.1.2.1 itojun #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, IPV6_ADDR_INT32_ONE }}}
187 1.1.2.1 itojun #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
188 1.1.2.1 itojun {{{ IPV6_ADDR_INT32_MNL, 0, 0, IPV6_ADDR_INT32_ONE }}}
189 1.1.2.1 itojun #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
190 1.1.2.1 itojun {{{ IPV6_ADDR_INT32_MLL, 0, 0, IPV6_ADDR_INT32_ONE }}}
191 1.1.2.1 itojun #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
192 1.1.2.1 itojun {{{ IPV6_ADDR_INT32_MLL, 0, 0, IPV6_ADDR_INT32_TWO }}}
193 1.1.2.1 itojun
194 1.1.2.1 itojun extern const struct in6_addr in6addr_any;
195 1.1.2.1 itojun extern const struct in6_addr in6addr_loopback;
196 1.1.2.1 itojun extern const struct in6_addr in6addr_nodelocal_allnodes;
197 1.1.2.1 itojun extern const struct in6_addr in6addr_linklocal_allnodes;
198 1.1.2.1 itojun extern const struct in6_addr in6addr_linklocal_allrouters;
199 1.1.2.1 itojun
200 1.1.2.1 itojun /*
201 1.1.2.1 itojun * Equality
202 1.1.2.1 itojun */
203 1.1.2.1 itojun #define IN6_ARE_ADDR_EQUAL(a, b) \
204 1.1.2.1 itojun (((a)->s6_addr32[0] == (b)->s6_addr32[0]) && \
205 1.1.2.1 itojun ((a)->s6_addr32[1] == (b)->s6_addr32[1]) && \
206 1.1.2.1 itojun ((a)->s6_addr32[2] == (b)->s6_addr32[2]) && \
207 1.1.2.1 itojun ((a)->s6_addr32[3] == (b)->s6_addr32[3]))
208 1.1.2.1 itojun
209 1.1.2.1 itojun /*
210 1.1.2.1 itojun * Unspecified
211 1.1.2.1 itojun */
212 1.1.2.1 itojun #define IN6_IS_ADDR_UNSPECIFIED(a) \
213 1.1.2.1 itojun (((a)->s6_addr32[0] == 0) && \
214 1.1.2.1 itojun ((a)->s6_addr32[1] == 0) && \
215 1.1.2.1 itojun ((a)->s6_addr32[2] == 0) && \
216 1.1.2.1 itojun ((a)->s6_addr32[3] == 0))
217 1.1.2.1 itojun
218 1.1.2.1 itojun /*
219 1.1.2.1 itojun * Loopback
220 1.1.2.1 itojun */
221 1.1.2.1 itojun #define IN6_IS_ADDR_LOOPBACK(a) \
222 1.1.2.1 itojun (((a)->s6_addr32[0] == 0) && \
223 1.1.2.1 itojun ((a)->s6_addr32[1] == 0) && \
224 1.1.2.1 itojun ((a)->s6_addr32[2] == 0) && \
225 1.1.2.1 itojun ((a)->s6_addr32[3] == IPV6_ADDR_INT32_ONE))
226 1.1.2.1 itojun
227 1.1.2.1 itojun /*
228 1.1.2.1 itojun * IPv4 compatible
229 1.1.2.1 itojun */
230 1.1.2.1 itojun #define IN6_IS_ADDR_V4COMPAT(a) \
231 1.1.2.1 itojun (((a)->s6_addr32[0] == 0) && \
232 1.1.2.1 itojun ((a)->s6_addr32[1] == 0) && \
233 1.1.2.1 itojun ((a)->s6_addr32[2] == 0) && \
234 1.1.2.1 itojun ((a)->s6_addr32[3] != 0) && \
235 1.1.2.1 itojun ((a)->s6_addr32[3] != IPV6_ADDR_INT32_ONE))
236 1.1.2.1 itojun
237 1.1.2.1 itojun /*
238 1.1.2.1 itojun * Mapped
239 1.1.2.1 itojun */
240 1.1.2.1 itojun #define IN6_IS_ADDR_V4MAPPED(a) \
241 1.1.2.1 itojun (((a)->s6_addr32[0] == 0) && \
242 1.1.2.1 itojun ((a)->s6_addr32[1] == 0) && \
243 1.1.2.1 itojun ((a)->s6_addr32[2] == IPV6_ADDR_INT32_SMP))
244 1.1.2.1 itojun
245 1.1.2.1 itojun /*
246 1.1.2.1 itojun * KAME Scope Values
247 1.1.2.1 itojun */
248 1.1.2.1 itojun
249 1.1.2.1 itojun #define IPV6_ADDR_SCOPE_NODELOCAL 0x01
250 1.1.2.1 itojun #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
251 1.1.2.1 itojun #define IPV6_ADDR_SCOPE_SITELOCAL 0x05
252 1.1.2.1 itojun #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
253 1.1.2.1 itojun #define IPV6_ADDR_SCOPE_GLOBAL 0x0e
254 1.1.2.1 itojun
255 1.1.2.1 itojun /*
256 1.1.2.1 itojun * Unicast Scope
257 1.1.2.1 itojun */
258 1.1.2.1 itojun #define IN6_IS_ADDR_LINKLOCAL(a) \
259 1.1.2.1 itojun ((a)->s6_addr16[0] == IPV6_ADDR_INT16_ULL)
260 1.1.2.1 itojun #define IN6_IS_ADDR_SITELOCAL(a) \
261 1.1.2.1 itojun ((a)->s6_addr16[0] == IPV6_ADDR_INT16_USL)
262 1.1.2.1 itojun
263 1.1.2.1 itojun /*
264 1.1.2.1 itojun * Multicast
265 1.1.2.1 itojun */
266 1.1.2.1 itojun #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr8[0] == 0xff)
267 1.1.2.1 itojun
268 1.1.2.1 itojun #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr8[1] & 0x0f)
269 1.1.2.1 itojun
270 1.1.2.1 itojun /*
271 1.1.2.1 itojun * Multicast Scope
272 1.1.2.1 itojun */
273 1.1.2.1 itojun #define IN6_IS_ADDR_MC_NODELOCAL(a) \
274 1.1.2.1 itojun (IN6_IS_ADDR_MULTICAST(a) && \
275 1.1.2.1 itojun (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
276 1.1.2.1 itojun #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
277 1.1.2.1 itojun (IN6_IS_ADDR_MULTICAST(a) && \
278 1.1.2.1 itojun (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
279 1.1.2.1 itojun #define IN6_IS_ADDR_MC_SITELOCAL(a) \
280 1.1.2.1 itojun (IN6_IS_ADDR_MULTICAST(a) && \
281 1.1.2.1 itojun (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
282 1.1.2.1 itojun #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
283 1.1.2.1 itojun (IN6_IS_ADDR_MULTICAST(a) && \
284 1.1.2.1 itojun (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
285 1.1.2.1 itojun #define IN6_IS_ADDR_MC_GLOBAL(a) \
286 1.1.2.1 itojun (IN6_IS_ADDR_MULTICAST(a) && \
287 1.1.2.1 itojun (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
288 1.1.2.1 itojun
289 1.1.2.1 itojun /*
290 1.1.2.1 itojun * Wildcard Socket
291 1.1.2.1 itojun */
292 1.1.2.1 itojun #define IN6_IS_ADDR_ANY(a) IN6_IS_ADDR_UNSPECIFIED(a)
293 1.1.2.1 itojun
294 1.1.2.1 itojun /*
295 1.1.2.1 itojun * KAME Scope
296 1.1.2.1 itojun */
297 1.1.2.1 itojun #define IN6_IS_SCOPE_LINKLOCAL(a) \
298 1.1.2.1 itojun ((IN6_IS_ADDR_LINKLOCAL(a)) || \
299 1.1.2.1 itojun (IN6_IS_ADDR_MC_LINKLOCAL(a)))
300 1.1.2.1 itojun
301 1.1.2.1 itojun /*
302 1.1.2.1 itojun * IP6 route structure
303 1.1.2.1 itojun */
304 1.1.2.1 itojun struct route_in6 {
305 1.1.2.1 itojun struct rtentry *ro_rt;
306 1.1.2.1 itojun struct sockaddr_in6 ro_dst;
307 1.1.2.1 itojun };
308 1.1.2.1 itojun
309 1.1.2.1 itojun /*
310 1.1.2.1 itojun * Options for use with [gs]etsockopt at the IPV6 level.
311 1.1.2.1 itojun * First word of comment is data type; bool is stored in int.
312 1.1.2.1 itojun */
313 1.1.2.1 itojun #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */
314 1.1.2.1 itojun /* no hdrincl */
315 1.1.2.1 itojun #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
316 1.1.2.1 itojun #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
317 1.1.2.1 itojun #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */
318 1.1.2.1 itojun #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */
319 1.1.2.1 itojun #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */
320 1.1.2.1 itojun #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */
321 1.1.2.1 itojun #define IPV6_MULTICAST_IF 9 /* u_char; set/get IP6 multicast i/f */
322 1.1.2.1 itojun #define IPV6_MULTICAST_HOPS 10 /* u_char; set/get IP6 multicast hops */
323 1.1.2.1 itojun #define IPV6_MULTICAST_LOOP 11 /* u_char; set/get IP6 multicast loopback */
324 1.1.2.1 itojun #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
325 1.1.2.1 itojun #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
326 1.1.2.1 itojun #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
327 1.1.2.1 itojun #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
328 1.1.2.1 itojun #define IPV6_PKTINFO 19 /* bool; send/rcv if, src/dst addr */
329 1.1.2.1 itojun #define IPV6_HOPLIMIT 20 /* bool; hop limit */
330 1.1.2.1 itojun #define IPV6_NEXTHOP 21 /* bool; next hop addr */
331 1.1.2.1 itojun #define IPV6_HOPOPTS 22 /* bool; hop-by-hop option */
332 1.1.2.1 itojun #define IPV6_DSTOPTS 23 /* bool; destination option */
333 1.1.2.1 itojun #define IPV6_RTHDR 24 /* bool; routing header */
334 1.1.2.1 itojun #define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */
335 1.1.2.1 itojun #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
336 1.1.2.1 itojun #define IPV6_BINDV6ONLY 27 /* bool; only bind INET6 at null bind */
337 1.1.2.1 itojun
338 1.1.2.1 itojun #if 1 /*IPSEC*/
339 1.1.2.1 itojun #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */
340 1.1.2.1 itojun #endif
341 1.1.2.1 itojun #define IPV6_FAITH 32 /* bool; accept FAITH'ed connections */
342 1.1.2.1 itojun
343 1.1.2.1 itojun #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */
344 1.1.2.1 itojun #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */
345 1.1.2.1 itojun #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */
346 1.1.2.1 itojun
347 1.1.2.1 itojun /*
348 1.1.2.1 itojun * Defaults and limits for options
349 1.1.2.1 itojun */
350 1.1.2.1 itojun #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
351 1.1.2.1 itojun #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
352 1.1.2.1 itojun
353 1.1.2.1 itojun /*
354 1.1.2.1 itojun * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
355 1.1.2.1 itojun */
356 1.1.2.1 itojun struct ipv6_mreq {
357 1.1.2.1 itojun struct in6_addr ipv6mr_multiaddr;
358 1.1.2.1 itojun u_int ipv6mr_interface;
359 1.1.2.1 itojun };
360 1.1.2.1 itojun
361 1.1.2.1 itojun /*
362 1.1.2.1 itojun * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
363 1.1.2.1 itojun */
364 1.1.2.1 itojun struct in6_pktinfo {
365 1.1.2.1 itojun struct in6_addr ipi6_addr; /* src/dst IPv6 address */
366 1.1.2.1 itojun u_int ipi6_ifindex; /* send/recv interface index */
367 1.1.2.1 itojun };
368 1.1.2.1 itojun
369 1.1.2.1 itojun /*
370 1.1.2.1 itojun * Argument for IPV6_PORTRANGE:
371 1.1.2.1 itojun * - which range to search when port is unspecified at bind() or connect()
372 1.1.2.1 itojun */
373 1.1.2.1 itojun #define IPV6_PORTRANGE_DEFAULT 0 /* default range */
374 1.1.2.1 itojun #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
375 1.1.2.1 itojun #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
376 1.1.2.1 itojun
377 1.1.2.1 itojun /*
378 1.1.2.1 itojun * Definitions for inet6 sysctl operations.
379 1.1.2.1 itojun *
380 1.1.2.1 itojun * Third level is protocol number.
381 1.1.2.1 itojun * Fourth level is desired variable within that protocol.
382 1.1.2.1 itojun */
383 1.1.2.1 itojun #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */
384 1.1.2.1 itojun
385 1.1.2.1 itojun #define CTL_IPV6PROTO_NAMES { \
386 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
387 1.1.2.1 itojun { 0, 0 }, \
388 1.1.2.1 itojun { "tcp6", CTLTYPE_NODE }, \
389 1.1.2.1 itojun { 0, 0 }, \
390 1.1.2.1 itojun { 0, 0 }, \
391 1.1.2.1 itojun { 0, 0 }, \
392 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
393 1.1.2.1 itojun { 0, 0 }, \
394 1.1.2.1 itojun { 0, 0 }, \
395 1.1.2.1 itojun { "udp6", CTLTYPE_NODE }, \
396 1.1.2.1 itojun { 0, 0 }, \
397 1.1.2.1 itojun { 0, 0 }, \
398 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
399 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
400 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
401 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
402 1.1.2.1 itojun { 0, 0 }, \
403 1.1.2.1 itojun { "ip6", CTLTYPE_NODE }, \
404 1.1.2.1 itojun { 0, 0 }, \
405 1.1.2.1 itojun { 0, 0 }, \
406 1.1.2.1 itojun { 0, 0 }, \
407 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
408 1.1.2.1 itojun { "ipsec6", CTLTYPE_NODE }, \
409 1.1.2.1 itojun { 0, 0 }, \
410 1.1.2.1 itojun { 0, 0 }, \
411 1.1.2.1 itojun { 0, 0 }, \
412 1.1.2.1 itojun { 0, 0 }, \
413 1.1.2.1 itojun { 0, 0 }, \
414 1.1.2.1 itojun { 0, 0 }, \
415 1.1.2.1 itojun { 0, 0 }, \
416 1.1.2.1 itojun { "icmp6", CTLTYPE_NODE }, \
417 1.1.2.1 itojun { 0, 0 }, \
418 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
419 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
420 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
421 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
422 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
423 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
424 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
425 1.1.2.1 itojun { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
426 1.1.2.1 itojun { 0, 0 }, \
427 1.1.2.1 itojun { 0, 0 }, \
428 1.1.2.1 itojun { 0, 0 }, \
429 1.1.2.1 itojun { "pim6", CTLTYPE_NODE }, \
430 1.1.2.1 itojun }
431 1.1.2.1 itojun
432 1.1.2.1 itojun /*
433 1.1.2.1 itojun * Names for IP sysctl objects
434 1.1.2.1 itojun */
435 1.1.2.1 itojun #define IPV6CTL_FORWARDING 1 /* act as router */
436 1.1.2.1 itojun #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/
437 1.1.2.1 itojun #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
438 1.1.2.1 itojun #ifdef notyet
439 1.1.2.1 itojun #define IPV6CTL_DEFMTU 4 /* default MTU */
440 1.1.2.1 itojun #endif
441 1.1.2.1 itojun #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
442 1.1.2.1 itojun #define IPV6CTL_STATS 6 /* stats */
443 1.1.2.1 itojun #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
444 1.1.2.1 itojun #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
445 1.1.2.1 itojun #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
446 1.1.2.1 itojun #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
447 1.1.2.1 itojun #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
448 1.1.2.1 itojun #define IPV6CTL_ACCEPT_RTADV 12
449 1.1.2.1 itojun #define IPV6CTL_KEEPFAITH 13
450 1.1.2.1 itojun #define IPV6CTL_LOG_INTERVAL 14
451 1.1.2.1 itojun #define IPV6CTL_HDRNESTLIMIT 15
452 1.1.2.1 itojun #define IPV6CTL_DAD_COUNT 16
453 1.1.2.1 itojun #ifdef MAPPED_ADDR_ENABLED
454 1.1.2.1 itojun #define IPV6CTL_MAPPED_ADDR 18
455 1.1.2.1 itojun #endif /* MAPPED_ADDR_ENABLED */
456 1.1.2.1 itojun #define IPV6CTL_AUTO_FLOWLABEL 19
457 1.1.2.1 itojun #define IPV6CTL_DEFMCASTHLIM 20
458 1.1.2.1 itojun #define IPV6CTL_GIF_HLIM 21 /* default HLIM for gif encap packet */
459 1.1.2.1 itojun #define IPV6CTL_KAME_VERSION 22
460 1.1.2.1 itojun /* New entries should be added here from current IPV6CTL_MAXID value. */
461 1.1.2.1 itojun #define IPV6CTL_MAXID 23
462 1.1.2.1 itojun
463 1.1.2.1 itojun #ifdef MAPPED_ADDR_ENABLED
464 1.1.2.1 itojun #define IPV6CTL_NAMES_MAPPED_ADDR "mapped_addr"
465 1.1.2.1 itojun #define IPV6CTL_TYPE_MAPPED_ADDR CTLTYPE_INT
466 1.1.2.1 itojun #define IPV6CTL_VARS_MAPPED_ADDR &ip6_mapped_addr_on
467 1.1.2.1 itojun #else /* MAPPED_ADDR_ENABLED */
468 1.1.2.1 itojun #define IPV6CTL_NAMES_MAPPED_ADDR 0
469 1.1.2.1 itojun #define IPV6CTL_TYPE_MAPPED_ADDR 0
470 1.1.2.1 itojun #define IPV6CTL_VARS_MAPPED_ADDR 0
471 1.1.2.1 itojun #endif /* MAPPED_ADDR_ENABLED */
472 1.1.2.1 itojun
473 1.1.2.1 itojun #define IPV6CTL_NAMES { \
474 1.1.2.1 itojun { 0, 0 }, \
475 1.1.2.1 itojun { "forwarding", CTLTYPE_INT }, \
476 1.1.2.1 itojun { "redirect", CTLTYPE_INT }, \
477 1.1.2.1 itojun { "hlim", CTLTYPE_INT }, \
478 1.1.2.1 itojun { "mtu", CTLTYPE_INT }, \
479 1.1.2.1 itojun { "forwsrcrt", CTLTYPE_INT }, \
480 1.1.2.1 itojun { 0, 0 }, \
481 1.1.2.1 itojun { 0, 0 }, \
482 1.1.2.1 itojun { "mrtproto", CTLTYPE_INT }, \
483 1.1.2.1 itojun { "maxfragpackets", CTLTYPE_INT }, \
484 1.1.2.1 itojun { "sourcecheck", CTLTYPE_INT }, \
485 1.1.2.1 itojun { "sourcecheck_logint", CTLTYPE_INT }, \
486 1.1.2.1 itojun { "accept_rtadv", CTLTYPE_INT }, \
487 1.1.2.1 itojun { "keepfaith", CTLTYPE_INT }, \
488 1.1.2.1 itojun { "log_interval", CTLTYPE_INT }, \
489 1.1.2.1 itojun { "hdrnestlimit", CTLTYPE_INT }, \
490 1.1.2.1 itojun { "dad_count", CTLTYPE_INT }, \
491 1.1.2.1 itojun { 0, 0 }, \
492 1.1.2.1 itojun { IPV6CTL_NAMES_MAPPED_ADDR, IPV6CTL_TYPE_MAPPED_ADDR }, \
493 1.1.2.1 itojun { "auto_flowlabel", CTLTYPE_INT }, \
494 1.1.2.1 itojun { "defmcasthlim", CTLTYPE_INT }, \
495 1.1.2.1 itojun { "gifhlim", CTLTYPE_INT }, \
496 1.1.2.1 itojun { "kame_version", CTLTYPE_STRING }, \
497 1.1.2.1 itojun }
498 1.1.2.1 itojun
499 1.1.2.1 itojun #define IPV6CTL_VARS { \
500 1.1.2.1 itojun 0, \
501 1.1.2.1 itojun &ip6_forwarding, \
502 1.1.2.1 itojun &ip6_sendredirects, \
503 1.1.2.1 itojun &ip6_defhlim, \
504 1.1.2.1 itojun 0, \
505 1.1.2.1 itojun &ip6_forward_srcrt, \
506 1.1.2.1 itojun 0, \
507 1.1.2.1 itojun 0, \
508 1.1.2.1 itojun 0, \
509 1.1.2.1 itojun &ip6_maxfragpackets, \
510 1.1.2.1 itojun &ip6_sourcecheck, \
511 1.1.2.1 itojun &ip6_sourcecheck_interval, \
512 1.1.2.1 itojun &ip6_accept_rtadv, \
513 1.1.2.1 itojun &ip6_keepfaith, \
514 1.1.2.1 itojun &ip6_log_interval, \
515 1.1.2.1 itojun &ip6_hdrnestlimit, \
516 1.1.2.1 itojun &ip6_dad_count, \
517 1.1.2.1 itojun &0, \
518 1.1.2.1 itojun IPV6CTL_VARS_MAPPED_ADDR, \
519 1.1.2.1 itojun &auto_flowlabel, \
520 1.1.2.1 itojun &ip6_defmcasthlim, \
521 1.1.2.1 itojun &ip6_gif_hlim, \
522 1.1.2.1 itojun 0, \
523 1.1.2.1 itojun }
524 1.1.2.1 itojun
525 1.1.2.1 itojun #ifdef _KERNEL
526 1.1.2.1 itojun struct cmsghdr;
527 1.1.2.1 itojun
528 1.1.2.1 itojun int in6_canforward __P((struct in6_addr *, struct in6_addr *));
529 1.1.2.1 itojun int in6_cksum __P((struct mbuf *, u_int8_t, int, int));
530 1.1.2.1 itojun int in6_localaddr __P((struct in6_addr *));
531 1.1.2.1 itojun int in6_addrscope __P((struct in6_addr *));
532 1.1.2.1 itojun struct in6_ifaddr *in6_ifawithscope __P((struct ifnet *, struct in6_addr *));
533 1.1.2.1 itojun struct in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *));
534 1.1.2.1 itojun #ifdef MAPPED_ADDR_ENABLED
535 1.1.2.1 itojun void in6_sin6_2_sin __P((struct sockaddr_in *sin,
536 1.1.2.1 itojun struct sockaddr_in6 *sin6));
537 1.1.2.1 itojun void in6_sin6_2_sin_in_m __P((struct mbuf *addr6));
538 1.1.2.1 itojun void in6_sin_2_v4mapsin6 __P((struct sockaddr_in *sin,
539 1.1.2.1 itojun struct sockaddr_in6 *sin6));
540 1.1.2.1 itojun void in6_sin_2_v4mapsin6_in_m __P((struct mbuf *addr6));
541 1.1.2.1 itojun void in6_sin6_2_sin_in_sock __P((struct sockaddr *nam));
542 1.1.2.1 itojun void in6_sin_2_v4mapsin6_in_sock __P((struct sockaddr **nam));
543 1.1.2.1 itojun #endif /* MAPPED_ADDR_ENABLED */
544 1.1.2.1 itojun #ifdef RADISH
545 1.1.2.1 itojun struct radish;
546 1.1.2.1 itojun struct radish_head;
547 1.1.2.1 itojun int in6_rd_match __P((struct sockaddr *, struct radish_head *,
548 1.1.2.1 itojun struct radish **));
549 1.1.2.1 itojun #endif /* RADISH */
550 1.1.2.1 itojun extern void in6_if_up __P((struct ifnet *));
551 1.1.2.1 itojun
552 1.1.2.1 itojun #define satosin6(sa) ((struct sockaddr_in6 *)(sa))
553 1.1.2.1 itojun #define sin6tosa(sin6) ((struct sockaddr *)(sin6))
554 1.1.2.1 itojun #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
555 1.1.2.1 itojun #endif /* _KERNEL */
556 1.1.2.1 itojun
557 1.1.2.1 itojun __BEGIN_DECLS
558 1.1.2.1 itojun struct cmsghdr;
559 1.1.2.1 itojun
560 1.1.2.1 itojun extern int inet6_option_space(int);
561 1.1.2.1 itojun extern int inet6_option_init(void *, struct cmsghdr **, int);
562 1.1.2.1 itojun extern int inet6_option_append(struct cmsghdr *, const u_int8_t *, int, int);
563 1.1.2.1 itojun #if 0 /* not implemented yet */
564 1.1.2.1 itojun extern u_int8_t *inet6_option_alloc(struct cmsghdr *, int, int, int);
565 1.1.2.1 itojun extern int inet6_option_next(const struct cmsghdr *, u_int8_t **);
566 1.1.2.1 itojun extern int inet6_option_find(const struct cmsghdr *, u_int8_t *, int);
567 1.1.2.1 itojun #endif
568 1.1.2.1 itojun
569 1.1.2.1 itojun extern size_t inet6_rthdr_space __P((int, int));
570 1.1.2.1 itojun extern struct cmsghdr *inet6_rthdr_init __P((void *, int));
571 1.1.2.1 itojun extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *,
572 1.1.2.1 itojun unsigned int));
573 1.1.2.1 itojun extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int));
574 1.1.2.1 itojun #if 0 /* not implemented yet */
575 1.1.2.1 itojun extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *));
576 1.1.2.1 itojun #endif
577 1.1.2.1 itojun extern int inet6_rthdr_segments __P((const struct cmsghdr *));
578 1.1.2.1 itojun extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int));
579 1.1.2.1 itojun extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int));
580 1.1.2.1 itojun __END_DECLS
581 1.1.2.1 itojun
582 1.1.2.1 itojun #endif /* !_NETINET6_IN6_H_ */
583