root / lab4 / .minix-src / include / netinet6 / in6.h @ 13
History | View | Annotate | Download (28.3 KB)
1 | 13 | up20180614 | /* $NetBSD: in6.h,v 1.85 2015/08/07 08:11:33 ozaki-r Exp $ */
|
---|---|---|---|
2 | /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
|
||
3 | |||
4 | /*
|
||
5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||
6 | * All rights reserved.
|
||
7 | *
|
||
8 | * Redistribution and use in source and binary forms, with or without
|
||
9 | * modification, are permitted provided that the following conditions
|
||
10 | * are met:
|
||
11 | * 1. Redistributions of source code must retain the above copyright
|
||
12 | * notice, this list of conditions and the following disclaimer.
|
||
13 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
14 | * notice, this list of conditions and the following disclaimer in the
|
||
15 | * documentation and/or other materials provided with the distribution.
|
||
16 | * 3. Neither the name of the project nor the names of its contributors
|
||
17 | * may be used to endorse or promote products derived from this software
|
||
18 | * without specific prior written permission.
|
||
19 | *
|
||
20 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
30 | * SUCH DAMAGE.
|
||
31 | */
|
||
32 | |||
33 | /*
|
||
34 | * Copyright (c) 1982, 1986, 1990, 1993
|
||
35 | * The Regents of the University of California. All rights reserved.
|
||
36 | *
|
||
37 | * Redistribution and use in source and binary forms, with or without
|
||
38 | * modification, are permitted provided that the following conditions
|
||
39 | * are met:
|
||
40 | * 1. Redistributions of source code must retain the above copyright
|
||
41 | * notice, this list of conditions and the following disclaimer.
|
||
42 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
43 | * notice, this list of conditions and the following disclaimer in the
|
||
44 | * documentation and/or other materials provided with the distribution.
|
||
45 | * 3. Neither the name of the University nor the names of its contributors
|
||
46 | * may be used to endorse or promote products derived from this software
|
||
47 | * without specific prior written permission.
|
||
48 | *
|
||
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
59 | * SUCH DAMAGE.
|
||
60 | *
|
||
61 | * @(#)in.h 8.3 (Berkeley) 1/3/94
|
||
62 | */
|
||
63 | |||
64 | #ifndef _NETINET6_IN6_H_
|
||
65 | #define _NETINET6_IN6_H_
|
||
66 | |||
67 | #include <sys/featuretest.h> |
||
68 | |||
69 | #ifndef __KAME_NETINET_IN_H_INCLUDED_
|
||
70 | #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" |
||
71 | #endif
|
||
72 | |||
73 | #include <sys/socket.h> |
||
74 | |||
75 | /*
|
||
76 | * Identification of the network protocol stack
|
||
77 | * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
|
||
78 | * has the table of implementation/integration differences.
|
||
79 | */
|
||
80 | #define __KAME__
|
||
81 | #define __KAME_VERSION "NetBSD-current" |
||
82 | |||
83 | /*
|
||
84 | * Local port number conventions:
|
||
85 | *
|
||
86 | * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
|
||
87 | * unless a kernel is compiled with IPNOPRIVPORTS defined.
|
||
88 | *
|
||
89 | * When a user does a bind(2) or connect(2) with a port number of zero,
|
||
90 | * a non-conflicting local port address is chosen.
|
||
91 | *
|
||
92 | * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
|
||
93 | * that is settable by sysctl(3); net.inet.ip.anonportmin and
|
||
94 | * net.inet.ip.anonportmax respectively.
|
||
95 | *
|
||
96 | * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
|
||
97 | * default assignment range.
|
||
98 | *
|
||
99 | * The value IP_PORTRANGE_DEFAULT causes the default behavior.
|
||
100 | *
|
||
101 | * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
|
||
102 | * and exists only for FreeBSD compatibility purposes.
|
||
103 | *
|
||
104 | * The value IP_PORTRANGE_LOW changes the range to the "low" are
|
||
105 | * that is (by convention) restricted to privileged processes.
|
||
106 | * This convention is based on "vouchsafe" principles only.
|
||
107 | * It is only secure if you trust the remote host to restrict these ports.
|
||
108 | * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
|
||
109 | */
|
||
110 | |||
111 | #if defined(_NETBSD_SOURCE)
|
||
112 | #define IPV6PORT_RESERVED 1024 |
||
113 | #define IPV6PORT_ANONMIN 49152 |
||
114 | #define IPV6PORT_ANONMAX 65535 |
||
115 | #define IPV6PORT_RESERVEDMIN 600 |
||
116 | #define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) |
||
117 | #endif
|
||
118 | |||
119 | /*
|
||
120 | * IPv6 address
|
||
121 | */
|
||
122 | struct in6_addr {
|
||
123 | union {
|
||
124 | __uint8_t __u6_addr8[16];
|
||
125 | __uint16_t __u6_addr16[8];
|
||
126 | uint32_t __u6_addr32[4];
|
||
127 | } __u6_addr; /* 128-bit IP6 address */
|
||
128 | }; |
||
129 | |||
130 | #define s6_addr __u6_addr.__u6_addr8
|
||
131 | #ifdef _KERNEL /* XXX nonstandard */ |
||
132 | #define s6_addr8 __u6_addr.__u6_addr8
|
||
133 | #define s6_addr16 __u6_addr.__u6_addr16
|
||
134 | #define s6_addr32 __u6_addr.__u6_addr32
|
||
135 | #endif
|
||
136 | |||
137 | #define INET6_ADDRSTRLEN 46 |
||
138 | |||
139 | /*
|
||
140 | * Socket address for IPv6
|
||
141 | */
|
||
142 | #if defined(_NETBSD_SOURCE)
|
||
143 | #define SIN6_LEN
|
||
144 | #endif
|
||
145 | struct sockaddr_in6 {
|
||
146 | uint8_t sin6_len; /* length of this struct(socklen_t)*/
|
||
147 | sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */
|
||
148 | in_port_t sin6_port; /* Transport layer port */
|
||
149 | uint32_t sin6_flowinfo; /* IP6 flow information */
|
||
150 | struct in6_addr sin6_addr; /* IP6 address */ |
||
151 | uint32_t sin6_scope_id; /* scope zone index */
|
||
152 | }; |
||
153 | |||
154 | /*
|
||
155 | * Local definition for masks
|
||
156 | */
|
||
157 | #ifdef _KERNEL /* XXX nonstandard */ |
||
158 | #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} |
||
159 | #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \ |
||
160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} |
||
161 | #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ |
||
162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} |
||
163 | #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ |
||
164 | 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} |
||
165 | #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ |
||
166 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} |
||
167 | #endif
|
||
168 | |||
169 | #ifdef _KERNEL
|
||
170 | extern const struct sockaddr_in6 sa6_any; |
||
171 | |||
172 | extern const struct in6_addr in6mask0; |
||
173 | extern const struct in6_addr in6mask32; |
||
174 | extern const struct in6_addr in6mask64; |
||
175 | extern const struct in6_addr in6mask96; |
||
176 | extern const struct in6_addr in6mask128; |
||
177 | #endif /* _KERNEL */ |
||
178 | |||
179 | /*
|
||
180 | * Macros started with IPV6_ADDR is KAME local
|
||
181 | */
|
||
182 | #ifdef _KERNEL /* XXX nonstandard */ |
||
183 | #if BYTE_ORDER == BIG_ENDIAN
|
||
184 | #define IPV6_ADDR_INT32_ONE 1 |
||
185 | #define IPV6_ADDR_INT32_TWO 2 |
||
186 | #define IPV6_ADDR_INT32_MNL 0xff010000 |
||
187 | #define IPV6_ADDR_INT32_MLL 0xff020000 |
||
188 | #define IPV6_ADDR_INT32_SMP 0x0000ffff |
||
189 | #define IPV6_ADDR_INT16_ULL 0xfe80 |
||
190 | #define IPV6_ADDR_INT16_USL 0xfec0 |
||
191 | #define IPV6_ADDR_INT16_MLL 0xff02 |
||
192 | #elif BYTE_ORDER == LITTLE_ENDIAN
|
||
193 | #define IPV6_ADDR_INT32_ONE 0x01000000 |
||
194 | #define IPV6_ADDR_INT32_TWO 0x02000000 |
||
195 | #define IPV6_ADDR_INT32_MNL 0x000001ff |
||
196 | #define IPV6_ADDR_INT32_MLL 0x000002ff |
||
197 | #define IPV6_ADDR_INT32_SMP 0xffff0000 |
||
198 | #define IPV6_ADDR_INT16_ULL 0x80fe |
||
199 | #define IPV6_ADDR_INT16_USL 0xc0fe |
||
200 | #define IPV6_ADDR_INT16_MLL 0x02ff |
||
201 | #endif
|
||
202 | #endif
|
||
203 | |||
204 | /*
|
||
205 | * Definition of some useful macros to handle IP6 addresses
|
||
206 | */
|
||
207 | #define IN6ADDR_ANY_INIT \
|
||
208 | {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
||
209 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} |
||
210 | #define IN6ADDR_LOOPBACK_INIT \
|
||
211 | {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
||
212 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} |
||
213 | #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
|
||
214 | {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
||
215 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} |
||
216 | #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
|
||
217 | {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
||
218 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} |
||
219 | #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
|
||
220 | {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
||
221 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} |
||
222 | |||
223 | extern const struct in6_addr in6addr_any; |
||
224 | extern const struct in6_addr in6addr_loopback; |
||
225 | extern const struct in6_addr in6addr_nodelocal_allnodes; |
||
226 | extern const struct in6_addr in6addr_linklocal_allnodes; |
||
227 | extern const struct in6_addr in6addr_linklocal_allrouters; |
||
228 | |||
229 | #define IN6_ARE_ADDR_EQUAL(a, b) \
|
||
230 | (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) |
||
231 | |||
232 | /*
|
||
233 | * Unspecified
|
||
234 | */
|
||
235 | #define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||
236 | ((a)->__u6_addr.__u6_addr32[0] == 0 && \ |
||
237 | (a)->__u6_addr.__u6_addr32[1] == 0 && \ |
||
238 | (a)->__u6_addr.__u6_addr32[2] == 0 && \ |
||
239 | (a)->__u6_addr.__u6_addr32[3] == 0) |
||
240 | |||
241 | /*
|
||
242 | * Loopback
|
||
243 | */
|
||
244 | #define IN6_IS_ADDR_LOOPBACK(a) \
|
||
245 | ((a)->__u6_addr.__u6_addr32[0] == 0 && \ |
||
246 | (a)->__u6_addr.__u6_addr32[1] == 0 && \ |
||
247 | (a)->__u6_addr.__u6_addr32[2] == 0 && \ |
||
248 | (a)->__u6_addr.__u6_addr32[3] == ntohl(1)) |
||
249 | |||
250 | /*
|
||
251 | * IPv4 compatible
|
||
252 | */
|
||
253 | #define IN6_IS_ADDR_V4COMPAT(a) \
|
||
254 | ((a)->__u6_addr.__u6_addr32[0] == 0 && \ |
||
255 | (a)->__u6_addr.__u6_addr32[1] == 0 && \ |
||
256 | (a)->__u6_addr.__u6_addr32[2] == 0 && \ |
||
257 | (a)->__u6_addr.__u6_addr32[3] != 0 && \ |
||
258 | (a)->__u6_addr.__u6_addr32[3] != ntohl(1)) |
||
259 | |||
260 | /*
|
||
261 | * Mapped
|
||
262 | */
|
||
263 | #define IN6_IS_ADDR_V4MAPPED(a) \
|
||
264 | ((a)->__u6_addr.__u6_addr32[0] == 0 && \ |
||
265 | (a)->__u6_addr.__u6_addr32[1] == 0 && \ |
||
266 | (a)->__u6_addr.__u6_addr32[2] == ntohl(0x0000ffff)) |
||
267 | |||
268 | /*
|
||
269 | * KAME Scope Values
|
||
270 | */
|
||
271 | |||
272 | #ifdef _KERNEL /* XXX nonstandard */ |
||
273 | #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 |
||
274 | #define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 |
||
275 | #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 |
||
276 | #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 |
||
277 | #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ |
||
278 | #define IPV6_ADDR_SCOPE_GLOBAL 0x0e |
||
279 | #else
|
||
280 | #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 |
||
281 | #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 |
||
282 | #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 |
||
283 | #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ |
||
284 | #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e |
||
285 | #endif
|
||
286 | |||
287 | /*
|
||
288 | * Unicast Scope
|
||
289 | * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
|
||
290 | */
|
||
291 | #define IN6_IS_ADDR_LINKLOCAL(a) \
|
||
292 | (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) |
||
293 | #define IN6_IS_ADDR_SITELOCAL(a) \
|
||
294 | (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) |
||
295 | |||
296 | /*
|
||
297 | * Multicast
|
||
298 | */
|
||
299 | #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) |
||
300 | |||
301 | #ifdef _KERNEL /* XXX nonstandard */ |
||
302 | #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) |
||
303 | #else
|
||
304 | #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) |
||
305 | #endif
|
||
306 | |||
307 | /*
|
||
308 | * Multicast Scope
|
||
309 | */
|
||
310 | #ifdef _KERNEL /* refers nonstandard items */ |
||
311 | #define IN6_IS_ADDR_MC_NODELOCAL(a) \
|
||
312 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
313 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL)) |
||
314 | #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
|
||
315 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
316 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL)) |
||
317 | #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
|
||
318 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
319 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL)) |
||
320 | #define IN6_IS_ADDR_MC_SITELOCAL(a) \
|
||
321 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
322 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL)) |
||
323 | #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
|
||
324 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
325 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL)) |
||
326 | #define IN6_IS_ADDR_MC_GLOBAL(a) \
|
||
327 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
328 | (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL)) |
||
329 | #else
|
||
330 | #define IN6_IS_ADDR_MC_NODELOCAL(a) \
|
||
331 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
332 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) |
||
333 | #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
|
||
334 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
335 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) |
||
336 | #define IN6_IS_ADDR_MC_SITELOCAL(a) \
|
||
337 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
338 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) |
||
339 | #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
|
||
340 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
341 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) |
||
342 | #define IN6_IS_ADDR_MC_GLOBAL(a) \
|
||
343 | (IN6_IS_ADDR_MULTICAST(a) && \ |
||
344 | (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) |
||
345 | #endif
|
||
346 | |||
347 | #ifdef _KERNEL /* nonstandard */ |
||
348 | /*
|
||
349 | * KAME Scope
|
||
350 | */
|
||
351 | #define IN6_IS_SCOPE_LINKLOCAL(a) \
|
||
352 | ((IN6_IS_ADDR_LINKLOCAL(a)) || \ |
||
353 | (IN6_IS_ADDR_MC_LINKLOCAL(a))) |
||
354 | |||
355 | #define IN6_IS_SCOPE_EMBEDDABLE(__a) \
|
||
356 | (IN6_IS_SCOPE_LINKLOCAL(__a) || IN6_IS_ADDR_MC_INTFACELOCAL(__a)) |
||
357 | |||
358 | #define IFA6_IS_DEPRECATED(a) \
|
||
359 | ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \ |
||
360 | (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ |
||
361 | (a)->ia6_lifetime.ia6t_pltime) |
||
362 | #define IFA6_IS_INVALID(a) \
|
||
363 | ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \ |
||
364 | (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ |
||
365 | (a)->ia6_lifetime.ia6t_vltime) |
||
366 | #endif
|
||
367 | |||
368 | /*
|
||
369 | * Options for use with [gs]etsockopt at the IPV6 level.
|
||
370 | * First word of comment is data type; bool is stored in int.
|
||
371 | */
|
||
372 | /* no hdrincl */
|
||
373 | #if 0
|
||
374 | /* These are deprecated non-standard options which are no longer supported. */
|
||
375 | #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */
|
||
376 | #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */
|
||
377 | #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */
|
||
378 | #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */
|
||
379 | #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */
|
||
380 | #endif
|
||
381 | #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ |
||
382 | #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ |
||
383 | #define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ |
||
384 | #define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ |
||
385 | #define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */ |
||
386 | /* The join and leave membership option numbers need to match with the v4 ones */
|
||
387 | #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ |
||
388 | #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ |
||
389 | #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ |
||
390 | #if defined(_NETBSD_SOURCE)
|
||
391 | #define IPV6_PORTALGO 17 /* int; port selection algo (rfc6056) */ |
||
392 | #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ |
||
393 | #endif
|
||
394 | /* RFC2292 options */
|
||
395 | #ifdef _KERNEL
|
||
396 | #define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */ |
||
397 | #define IPV6_2292HOPLIMIT 20 /* bool; hop limit */ |
||
398 | #define IPV6_2292NEXTHOP 21 /* bool; next hop addr */ |
||
399 | #define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */ |
||
400 | #define IPV6_2292DSTOPTS 23 /* bool; destination option */ |
||
401 | #define IPV6_2292RTHDR 24 /* bool; routing header */ |
||
402 | #define IPV6_2292PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ |
||
403 | #endif
|
||
404 | #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ |
||
405 | #define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */ |
||
406 | |||
407 | #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ |
||
408 | #define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */ |
||
409 | |||
410 | /* new socket options introduced in RFC3542 */
|
||
411 | #define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */ |
||
412 | |||
413 | #define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */ |
||
414 | #define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */ |
||
415 | #define IPV6_RECVRTHDR 38 /* bool; recv routing header */ |
||
416 | #define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */ |
||
417 | #define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */ |
||
418 | #ifdef _KERNEL
|
||
419 | #define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */ |
||
420 | #endif
|
||
421 | #define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */ |
||
422 | #define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */ |
||
423 | #define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt), |
||
424 | 4 bytes int; MTU notification (cmsg) */
|
||
425 | |||
426 | /* more new socket options introduced in RFC3542 */
|
||
427 | #define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */ |
||
428 | #define IPV6_HOPLIMIT 47 /* int; send hop limit */ |
||
429 | #define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */ |
||
430 | #define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */ |
||
431 | #define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */ |
||
432 | #define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */ |
||
433 | |||
434 | #define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */ |
||
435 | #ifdef _KERNEL
|
||
436 | #define IPV6_OTCLASS 58 /* u_int8_t; send traffic class value */ |
||
437 | #endif
|
||
438 | |||
439 | #define IPV6_TCLASS 61 /* int; send traffic class value */ |
||
440 | #define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */ |
||
441 | #define IPV6_PREFER_TEMPADDR 63 /* int; prefer temporary address as |
||
442 | * the sorce address */
|
||
443 | /* to define items, should talk with KAME guys first, for *BSD compatibility */
|
||
444 | |||
445 | #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ |
||
446 | #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ |
||
447 | #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ |
||
448 | |||
449 | /*
|
||
450 | * Defaults and limits for options
|
||
451 | */
|
||
452 | #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ |
||
453 | #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ |
||
454 | |||
455 | /*
|
||
456 | * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
|
||
457 | */
|
||
458 | struct ipv6_mreq {
|
||
459 | struct in6_addr ipv6mr_multiaddr;
|
||
460 | unsigned int ipv6mr_interface; |
||
461 | }; |
||
462 | |||
463 | /*
|
||
464 | * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
|
||
465 | */
|
||
466 | struct in6_pktinfo {
|
||
467 | struct in6_addr ipi6_addr; /* src/dst IPv6 address */ |
||
468 | unsigned int ipi6_ifindex; /* send/recv interface index */ |
||
469 | }; |
||
470 | |||
471 | /*
|
||
472 | * Control structure for IPV6_RECVPATHMTU socket option.
|
||
473 | */
|
||
474 | struct ip6_mtuinfo {
|
||
475 | struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */ |
||
476 | uint32_t ip6m_mtu; |
||
477 | }; |
||
478 | |||
479 | /*
|
||
480 | * Argument for IPV6_PORTRANGE:
|
||
481 | * - which range to search when port is unspecified at bind() or connect()
|
||
482 | */
|
||
483 | #define IPV6_PORTRANGE_DEFAULT 0 /* default range */ |
||
484 | #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ |
||
485 | #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ |
||
486 | |||
487 | #if defined(_NETBSD_SOURCE)
|
||
488 | /*
|
||
489 | * Definitions for inet6 sysctl operations.
|
||
490 | *
|
||
491 | * Third level is protocol number.
|
||
492 | * Fourth level is desired variable within that protocol.
|
||
493 | */
|
||
494 | #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ |
||
495 | |||
496 | #define CTL_IPV6PROTO_NAMES { \
|
||
497 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
498 | { 0, 0 }, \ |
||
499 | { "tcp6", CTLTYPE_NODE }, \
|
||
500 | { 0, 0 }, \ |
||
501 | { 0, 0 }, \ |
||
502 | { 0, 0 }, \ |
||
503 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
504 | { 0, 0 }, \ |
||
505 | { 0, 0 }, \ |
||
506 | { "udp6", CTLTYPE_NODE }, \
|
||
507 | { 0, 0 }, \ |
||
508 | { 0, 0 }, \ |
||
509 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
510 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
511 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
512 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
513 | { 0, 0 }, \ |
||
514 | { "ip6", CTLTYPE_NODE }, \
|
||
515 | { 0, 0 }, \ |
||
516 | { 0, 0 }, \ |
||
517 | { 0, 0 }, \ |
||
518 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
519 | { 0, 0 }, \ |
||
520 | { "ipsec6", CTLTYPE_NODE }, \
|
||
521 | { 0, 0 }, \ |
||
522 | { 0, 0 }, \ |
||
523 | { 0, 0 }, \ |
||
524 | { 0, 0 }, \ |
||
525 | { 0, 0 }, \ |
||
526 | { 0, 0 }, \ |
||
527 | { "icmp6", CTLTYPE_NODE }, \
|
||
528 | { 0, 0 }, \ |
||
529 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
530 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
531 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
532 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
533 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
534 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
535 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
536 | { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ |
||
537 | { 0, 0 }, \ |
||
538 | { 0, 0 }, \ |
||
539 | { 0, 0 }, \ |
||
540 | { "pim6", CTLTYPE_NODE }, \
|
||
541 | } |
||
542 | |||
543 | /*
|
||
544 | * Names for IP sysctl objects
|
||
545 | */
|
||
546 | #define IPV6CTL_FORWARDING 1 /* act as router */ |
||
547 | #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ |
||
548 | #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ |
||
549 | #ifdef notyet
|
||
550 | #define IPV6CTL_DEFMTU 4 /* default MTU */ |
||
551 | #endif
|
||
552 | #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ |
||
553 | #define IPV6CTL_STATS 6 /* stats */ |
||
554 | #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ |
||
555 | #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ |
||
556 | #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ |
||
557 | #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ |
||
558 | #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ |
||
559 | #define IPV6CTL_ACCEPT_RTADV 12 |
||
560 | #define IPV6CTL_KEEPFAITH 13 |
||
561 | #define IPV6CTL_LOG_INTERVAL 14 |
||
562 | #define IPV6CTL_HDRNESTLIMIT 15 |
||
563 | #define IPV6CTL_DAD_COUNT 16 |
||
564 | #define IPV6CTL_AUTO_FLOWLABEL 17 |
||
565 | #define IPV6CTL_DEFMCASTHLIM 18 |
||
566 | #define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ |
||
567 | #define IPV6CTL_KAME_VERSION 20 |
||
568 | #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ |
||
569 | #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ |
||
570 | /* 23: reserved */
|
||
571 | #define IPV6CTL_V6ONLY 24 |
||
572 | /* 25 to 27: reserved */
|
||
573 | #define IPV6CTL_ANONPORTMIN 28 /* minimum ephemeral port */ |
||
574 | #define IPV6CTL_ANONPORTMAX 29 /* maximum ephemeral port */ |
||
575 | #define IPV6CTL_LOWPORTMIN 30 /* minimum reserved port */ |
||
576 | #define IPV6CTL_LOWPORTMAX 31 /* maximum reserved port */ |
||
577 | /* 32 to 34: reserved */
|
||
578 | #define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ |
||
579 | /* 36 to 38: reserved */
|
||
580 | #define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */ |
||
581 | /* 40: reserved */
|
||
582 | #define IPV6CTL_MAXFRAGS 41 /* max fragments */ |
||
583 | #define IPV6CTL_IFQ 42 /* IPv6 packet input queue */ |
||
584 | #define IPV6CTL_RTADV_MAXROUTES 43 /* maximum number of routes */ |
||
585 | /* via router advertisement */
|
||
586 | #define IPV6CTL_RTADV_NUMROUTES 44 /* current number of routes */ |
||
587 | /* via router advertisement */
|
||
588 | /* New entries should be added here from current IPV6CTL_MAXID value. */
|
||
589 | /* to define items, should talk with KAME guys first, for *BSD compatibility */
|
||
590 | #define IPV6CTL_MAXID 45 |
||
591 | |||
592 | #define IPV6CTL_NAMES { \
|
||
593 | { 0, 0 }, \ |
||
594 | { "forwarding", CTLTYPE_INT }, \
|
||
595 | { "redirect", CTLTYPE_INT }, \
|
||
596 | { "hlim", CTLTYPE_INT }, \
|
||
597 | { "mtu", CTLTYPE_INT }, \
|
||
598 | { "forwsrcrt", CTLTYPE_INT }, \
|
||
599 | { "stats", CTLTYPE_STRUCT }, \
|
||
600 | { 0, 0 }, \ |
||
601 | { "mrtproto", CTLTYPE_INT }, \
|
||
602 | { "maxfragpackets", CTLTYPE_INT }, \
|
||
603 | { "sourcecheck", CTLTYPE_INT }, \
|
||
604 | { "sourcecheck_logint", CTLTYPE_INT }, \
|
||
605 | { "accept_rtadv", CTLTYPE_INT }, \
|
||
606 | { "keepfaith", CTLTYPE_INT }, \
|
||
607 | { "log_interval", CTLTYPE_INT }, \
|
||
608 | { "hdrnestlimit", CTLTYPE_INT }, \
|
||
609 | { "dad_count", CTLTYPE_INT }, \
|
||
610 | { "auto_flowlabel", CTLTYPE_INT }, \
|
||
611 | { "defmcasthlim", CTLTYPE_INT }, \
|
||
612 | { "gifhlim", CTLTYPE_INT }, \
|
||
613 | { "kame_version", CTLTYPE_STRING }, \
|
||
614 | { "use_deprecated", CTLTYPE_INT }, \
|
||
615 | { "rr_prune", CTLTYPE_INT }, \
|
||
616 | { 0, 0 }, \ |
||
617 | { "v6only", CTLTYPE_INT }, \
|
||
618 | { 0, 0 }, \ |
||
619 | { 0, 0 }, \ |
||
620 | { 0, 0 }, \ |
||
621 | { "anonportmin", CTLTYPE_INT }, \
|
||
622 | { "anonportmax", CTLTYPE_INT }, \
|
||
623 | { "lowportmin", CTLTYPE_INT }, \
|
||
624 | { "lowportmax", CTLTYPE_INT }, \
|
||
625 | { 0, 0 }, \ |
||
626 | { 0, 0 }, \ |
||
627 | { 0, 0 }, \ |
||
628 | { 0, 0 }, \ |
||
629 | { 0, 0 }, \ |
||
630 | { 0, 0 }, \ |
||
631 | { 0, 0 }, \ |
||
632 | { 0, 0 }, \ |
||
633 | { 0, 0 }, \ |
||
634 | { "maxfrags", CTLTYPE_INT }, \
|
||
635 | { "ifq", CTLTYPE_NODE }, \
|
||
636 | { "rtadv_maxroutes", CTLTYPE_INT }, \
|
||
637 | { "rtadv_numroutes", CTLTYPE_INT }, \
|
||
638 | } |
||
639 | |||
640 | #endif /* _NETBSD_SOURCE */ |
||
641 | |||
642 | #ifdef _KERNEL
|
||
643 | struct cmsghdr;
|
||
644 | |||
645 | /*
|
||
646 | * in6_cksum_phdr:
|
||
647 | *
|
||
648 | * Compute significant parts of the IPv6 checksum pseudo-header
|
||
649 | * for use in a delayed TCP/UDP checksum calculation.
|
||
650 | *
|
||
651 | * Args:
|
||
652 | *
|
||
653 | * src Source IPv6 address
|
||
654 | * dst Destination IPv6 address
|
||
655 | * len htonl(proto-hdr-len)
|
||
656 | * nxt htonl(next-proto-number)
|
||
657 | *
|
||
658 | * NOTE: We expect the src and dst addresses to be 16-bit
|
||
659 | * aligned!
|
||
660 | */
|
||
661 | static __inline u_int16_t __unused
|
||
662 | in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst, |
||
663 | u_int32_t len, u_int32_t nxt) |
||
664 | { |
||
665 | u_int32_t sum = 0;
|
||
666 | const u_int16_t *w;
|
||
667 | |||
668 | /*LINTED*/
|
||
669 | w = (const u_int16_t *) src;
|
||
670 | sum += w[0];
|
||
671 | if (!IN6_IS_SCOPE_LINKLOCAL(src))
|
||
672 | sum += w[1];
|
||
673 | sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; |
||
674 | sum += w[6]; sum += w[7]; |
||
675 | |||
676 | /*LINTED*/
|
||
677 | w = (const u_int16_t *) dst;
|
||
678 | sum += w[0];
|
||
679 | if (!IN6_IS_SCOPE_LINKLOCAL(dst))
|
||
680 | sum += w[1];
|
||
681 | sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; |
||
682 | sum += w[6]; sum += w[7]; |
||
683 | |||
684 | sum += (u_int16_t)(len >> 16) + (u_int16_t)(len /*& 0xffff*/); |
||
685 | |||
686 | sum += (u_int16_t)(nxt >> 16) + (u_int16_t)(nxt /*& 0xffff*/); |
||
687 | |||
688 | sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); |
||
689 | |||
690 | if (sum > 0xffff) |
||
691 | sum -= 0xffff;
|
||
692 | |||
693 | return (sum);
|
||
694 | } |
||
695 | |||
696 | struct mbuf;
|
||
697 | struct ifnet;
|
||
698 | int sockaddr_in6_cmp(const struct sockaddr *, const struct sockaddr *); |
||
699 | struct sockaddr *sockaddr_in6_externalize(struct sockaddr *, socklen_t, |
||
700 | const struct sockaddr *); |
||
701 | int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t); |
||
702 | void in6_delayed_cksum(struct mbuf *); |
||
703 | int in6_localaddr(const struct in6_addr *); |
||
704 | int in6_addrscope(const struct in6_addr *); |
||
705 | struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *); |
||
706 | extern void in6_if_link_up(struct ifnet *); |
||
707 | extern void in6_if_link_down(struct ifnet *); |
||
708 | extern void in6_if_link_state_change(struct ifnet *, int); |
||
709 | extern void in6_if_up(struct ifnet *); |
||
710 | extern void in6_if_down(struct ifnet *); |
||
711 | #ifndef __FreeBSD__
|
||
712 | extern int in6_src_sysctl(void *, size_t *, void *, size_t); |
||
713 | #endif
|
||
714 | extern void addrsel_policy_init(void); |
||
715 | extern u_char ip6_protox[];
|
||
716 | |||
717 | #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) |
||
718 | #define satocsin6(sa) ((const struct sockaddr_in6 *)(sa)) |
||
719 | #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) |
||
720 | #define sin6tocsa(sin6) ((const struct sockaddr *)(sin6)) |
||
721 | #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) |
||
722 | |||
723 | static inline void |
||
724 | sockaddr_in6_init1(struct sockaddr_in6 *sin6, const struct in6_addr *addr, |
||
725 | in_port_t port, uint32_t flowinfo, uint32_t scope_id) |
||
726 | { |
||
727 | sin6->sin6_port = port; |
||
728 | sin6->sin6_flowinfo = flowinfo; |
||
729 | sin6->sin6_addr = *addr; |
||
730 | sin6->sin6_scope_id = scope_id; |
||
731 | } |
||
732 | |||
733 | static inline void |
||
734 | sockaddr_in6_init(struct sockaddr_in6 *sin6, const struct in6_addr *addr, |
||
735 | in_port_t port, uint32_t flowinfo, uint32_t scope_id) |
||
736 | { |
||
737 | sin6->sin6_family = AF_INET6; |
||
738 | sin6->sin6_len = sizeof(*sin6);
|
||
739 | sockaddr_in6_init1(sin6, addr, port, flowinfo, scope_id); |
||
740 | } |
||
741 | |||
742 | static inline struct sockaddr * |
||
743 | sockaddr_in6_alloc(const struct in6_addr *addr, in_port_t port, |
||
744 | uint32_t flowinfo, uint32_t scope_id, int flags)
|
||
745 | { |
||
746 | struct sockaddr *sa;
|
||
747 | |||
748 | if ((sa = sockaddr_alloc(AF_INET6, sizeof(struct sockaddr_in6), |
||
749 | flags)) == NULL)
|
||
750 | return NULL; |
||
751 | |||
752 | sockaddr_in6_init1(satosin6(sa), addr, port, flowinfo, scope_id); |
||
753 | |||
754 | return sa;
|
||
755 | } |
||
756 | #endif /* _KERNEL */ |
||
757 | |||
758 | #if defined(_NETBSD_SOURCE)
|
||
759 | |||
760 | #include <machine/ansi.h> |
||
761 | |||
762 | #ifdef _BSD_SIZE_T_
|
||
763 | typedef _BSD_SIZE_T_ size_t;
|
||
764 | #define _SIZE_T
|
||
765 | #undef _BSD_SIZE_T_
|
||
766 | #endif
|
||
767 | |||
768 | #include <sys/cdefs.h> |
||
769 | |||
770 | __BEGIN_DECLS |
||
771 | struct cmsghdr;
|
||
772 | |||
773 | void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); |
||
774 | void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *); |
||
775 | void in6_sin6_2_sin_in_sock(struct sockaddr *); |
||
776 | void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **); |
||
777 | |||
778 | #define INET6_IS_ADDR_LINKLOCAL 1 |
||
779 | #define INET6_IS_ADDR_MC_LINKLOCAL 2 |
||
780 | #define INET6_IS_ADDR_SITELOCAL 4 |
||
781 | void inet6_getscopeid(struct sockaddr_in6 *, int); |
||
782 | void inet6_putscopeid(struct sockaddr_in6 *, int); |
||
783 | |||
784 | extern int inet6_option_space(int); |
||
785 | extern int inet6_option_init(void *, struct cmsghdr **, int); |
||
786 | extern int inet6_option_append(struct cmsghdr *, const uint8_t *, |
||
787 | int, int); |
||
788 | extern uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int); |
||
789 | extern int inet6_option_next(const struct cmsghdr *, uint8_t **); |
||
790 | extern int inet6_option_find(const struct cmsghdr *, uint8_t **, int); |
||
791 | |||
792 | extern size_t inet6_rthdr_space(int, int); |
||
793 | extern struct cmsghdr *inet6_rthdr_init(void *, int); |
||
794 | extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, |
||
795 | unsigned int); |
||
796 | extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int); |
||
797 | #if 0 /* not implemented yet */
|
||
798 | extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *);
|
||
799 | #endif
|
||
800 | extern int inet6_rthdr_segments(const struct cmsghdr *); |
||
801 | extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int); |
||
802 | extern int inet6_rthdr_getflags(const struct cmsghdr *, int); |
||
803 | |||
804 | extern int inet6_opt_init(void *, socklen_t); |
||
805 | extern int inet6_opt_append(void *, socklen_t, int, uint8_t, |
||
806 | socklen_t, uint8_t, void **);
|
||
807 | extern int inet6_opt_finish(void *, socklen_t, int); |
||
808 | extern int inet6_opt_set_val(void *, int, void *, socklen_t); |
||
809 | |||
810 | extern int inet6_opt_next(void *, socklen_t, int, uint8_t *, |
||
811 | socklen_t *, void **);
|
||
812 | extern int inet6_opt_find(void *, socklen_t, int, uint8_t, |
||
813 | socklen_t *, void **);
|
||
814 | extern int inet6_opt_get_val(void *, int, void *, socklen_t); |
||
815 | extern socklen_t inet6_rth_space(int, int); |
||
816 | extern void *inet6_rth_init(void *, socklen_t, int, int); |
||
817 | extern int inet6_rth_add(void *, const struct in6_addr *); |
||
818 | extern int inet6_rth_reverse(const void *, void *); |
||
819 | extern int inet6_rth_segments(const void *); |
||
820 | extern struct in6_addr *inet6_rth_getaddr(const void *, int); |
||
821 | __END_DECLS |
||
822 | #endif /* _NETBSD_SOURCE */ |
||
823 | |||
824 | #if defined(_KERNEL) || defined(_TEST)
|
||
825 | int in6_print(char *, size_t, const struct in6_addr *); |
||
826 | #define IN6_PRINT(b, a) (in6_print((b), sizeof(b), (a)), (b)) |
||
827 | int sin6_print(char *, size_t, const void *); |
||
828 | #endif
|
||
829 | |||
830 | #endif /* !_NETINET6_IN6_H_ */ |