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