1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/netinet6/in6.h
|
4 |
|
|
//
|
5 |
|
|
//==========================================================================
|
6 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
7 |
|
|
//
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
//
|
10 |
|
|
// Portions of this software may have been derived from OpenBSD,
|
11 |
|
|
// FreeBSD or other sources, and are covered by the appropriate
|
12 |
|
|
// copyright disclaimers included herein.
|
13 |
|
|
//
|
14 |
|
|
// Portions created by Red Hat are
|
15 |
|
|
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
16 |
|
|
//
|
17 |
|
|
// -------------------------------------------
|
18 |
|
|
//
|
19 |
|
|
//####BSDCOPYRIGHTEND####
|
20 |
|
|
//==========================================================================
|
21 |
|
|
|
22 |
|
|
/* $KAME: in6.h,v 1.115 2002/01/02 06:43:13 jinmei Exp $ */
|
23 |
|
|
|
24 |
|
|
/*
|
25 |
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
26 |
|
|
* All rights reserved.
|
27 |
|
|
*
|
28 |
|
|
* Redistribution and use in source and binary forms, with or without
|
29 |
|
|
* modification, are permitted provided that the following conditions
|
30 |
|
|
* are met:
|
31 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
32 |
|
|
* notice, this list of conditions and the following disclaimer.
|
33 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
34 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
35 |
|
|
* documentation and/or other materials provided with the distribution.
|
36 |
|
|
* 3. Neither the name of the project nor the names of its contributors
|
37 |
|
|
* may be used to endorse or promote products derived from this software
|
38 |
|
|
* without specific prior written permission.
|
39 |
|
|
*
|
40 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
41 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
43 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
44 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
45 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
46 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
48 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
49 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
50 |
|
|
* SUCH DAMAGE.
|
51 |
|
|
*/
|
52 |
|
|
|
53 |
|
|
/*
|
54 |
|
|
* Copyright (c) 1982, 1986, 1990, 1993
|
55 |
|
|
* The Regents of the University of California. All rights reserved.
|
56 |
|
|
*
|
57 |
|
|
* Redistribution and use in source and binary forms, with or without
|
58 |
|
|
* modification, are permitted provided that the following conditions
|
59 |
|
|
* are met:
|
60 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
61 |
|
|
* notice, this list of conditions and the following disclaimer.
|
62 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
63 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
64 |
|
|
* documentation and/or other materials provided with the distribution.
|
65 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
66 |
|
|
* must display the following acknowledgement:
|
67 |
|
|
* This product includes software developed by the University of
|
68 |
|
|
* California, Berkeley and its contributors.
|
69 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
70 |
|
|
* may be used to endorse or promote products derived from this software
|
71 |
|
|
* without specific prior written permission.
|
72 |
|
|
*
|
73 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
74 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
75 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
76 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
77 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
78 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
79 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
80 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
81 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
82 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
83 |
|
|
* SUCH DAMAGE.
|
84 |
|
|
*
|
85 |
|
|
* @(#)in.h 8.3 (Berkeley) 1/3/94
|
86 |
|
|
*/
|
87 |
|
|
|
88 |
|
|
#ifndef __KAME_NETINET_IN_H_INCLUDED_
|
89 |
|
|
#error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553"
|
90 |
|
|
#endif
|
91 |
|
|
|
92 |
|
|
#ifndef _NETINET6_IN6_H_
|
93 |
|
|
#define _NETINET6_IN6_H_
|
94 |
|
|
|
95 |
|
|
/*
|
96 |
|
|
* Identification of the network protocol stack
|
97 |
|
|
* for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
|
98 |
|
|
* has the table of implementation/integration differences.
|
99 |
|
|
*/
|
100 |
|
|
#define __KAME__
|
101 |
|
|
#define __KAME_VERSION "SNAP 20020107"
|
102 |
|
|
|
103 |
|
|
/*
|
104 |
|
|
* Local port number conventions:
|
105 |
|
|
*
|
106 |
|
|
* Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
|
107 |
|
|
* unless a kernel is compiled with IPNOPRIVPORTS defined.
|
108 |
|
|
*
|
109 |
|
|
* When a user does a bind(2) or connect(2) with a port number of zero,
|
110 |
|
|
* a non-conflicting local port address is chosen.
|
111 |
|
|
*
|
112 |
|
|
* The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
|
113 |
|
|
* that is settable by sysctl(3); net.inet.ip.anonportmin and
|
114 |
|
|
* net.inet.ip.anonportmax respectively.
|
115 |
|
|
*
|
116 |
|
|
* A user may set the IPPROTO_IP option IP_PORTRANGE to change this
|
117 |
|
|
* default assignment range.
|
118 |
|
|
*
|
119 |
|
|
* The value IP_PORTRANGE_DEFAULT causes the default behavior.
|
120 |
|
|
*
|
121 |
|
|
* The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
|
122 |
|
|
* and exists only for FreeBSD compatibility purposes.
|
123 |
|
|
*
|
124 |
|
|
* The value IP_PORTRANGE_LOW changes the range to the "low" are
|
125 |
|
|
* that is (by convention) restricted to privileged processes.
|
126 |
|
|
* This convention is based on "vouchsafe" principles only.
|
127 |
|
|
* It is only secure if you trust the remote host to restrict these ports.
|
128 |
|
|
* The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
|
129 |
|
|
*/
|
130 |
|
|
|
131 |
|
|
#define IPV6PORT_RESERVED 1024
|
132 |
|
|
#define IPV6PORT_ANONMIN 49152
|
133 |
|
|
#define IPV6PORT_ANONMAX 65535
|
134 |
|
|
#define IPV6PORT_RESERVEDMIN 600
|
135 |
|
|
#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1)
|
136 |
|
|
|
137 |
|
|
/*
|
138 |
|
|
* IPv6 address
|
139 |
|
|
*/
|
140 |
|
|
struct in6_addr {
|
141 |
|
|
union {
|
142 |
|
|
u_int8_t __u6_addr8[16];
|
143 |
|
|
u_int16_t __u6_addr16[8];
|
144 |
|
|
u_int32_t __u6_addr32[4];
|
145 |
|
|
} __u6_addr; /* 128-bit IP6 address */
|
146 |
|
|
};
|
147 |
|
|
|
148 |
|
|
#define s6_addr __u6_addr.__u6_addr8
|
149 |
|
|
#ifdef _KERNEL /* XXX nonstandard */
|
150 |
|
|
#define s6_addr8 __u6_addr.__u6_addr8
|
151 |
|
|
#define s6_addr16 __u6_addr.__u6_addr16
|
152 |
|
|
#define s6_addr32 __u6_addr.__u6_addr32
|
153 |
|
|
#endif
|
154 |
|
|
|
155 |
|
|
#define INET6_ADDRSTRLEN 46
|
156 |
|
|
|
157 |
|
|
/*
|
158 |
|
|
* Socket address for IPv6
|
159 |
|
|
*/
|
160 |
|
|
#ifndef _XOPEN_SOURCE
|
161 |
|
|
#define SIN6_LEN
|
162 |
|
|
#endif
|
163 |
|
|
struct sockaddr_in6 {
|
164 |
|
|
u_int8_t sin6_len; /* length of this struct(sa_family_t)*/
|
165 |
|
|
u_int8_t sin6_family; /* AF_INET6 (sa_family_t) */
|
166 |
|
|
u_int16_t sin6_port; /* Transport layer port # (in_port_t)*/
|
167 |
|
|
u_int32_t sin6_flowinfo; /* IP6 flow information */
|
168 |
|
|
struct in6_addr sin6_addr; /* IP6 address */
|
169 |
|
|
u_int32_t sin6_scope_id; /* scope zone index */
|
170 |
|
|
};
|
171 |
|
|
|
172 |
|
|
/*
|
173 |
|
|
* Local definition for masks
|
174 |
|
|
*/
|
175 |
|
|
#ifdef _KERNEL /* XXX nonstandard */
|
176 |
|
|
#define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
|
177 |
|
|
#define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
|
178 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
|
179 |
|
|
#define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
180 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
|
181 |
|
|
#define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
182 |
|
|
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
|
183 |
|
|
#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
184 |
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
|
185 |
|
|
#endif
|
186 |
|
|
|
187 |
|
|
#ifdef _KERNEL
|
188 |
|
|
extern const struct sockaddr_in6 sa6_any;
|
189 |
|
|
|
190 |
|
|
extern const struct in6_addr in6mask0;
|
191 |
|
|
extern const struct in6_addr in6mask32;
|
192 |
|
|
extern const struct in6_addr in6mask64;
|
193 |
|
|
extern const struct in6_addr in6mask96;
|
194 |
|
|
extern const struct in6_addr in6mask128;
|
195 |
|
|
#endif /* _KERNEL */
|
196 |
|
|
|
197 |
|
|
/*
|
198 |
|
|
* Macros started with IPV6_ADDR is KAME local
|
199 |
|
|
*/
|
200 |
|
|
#ifdef _KERNEL /* XXX nonstandard */
|
201 |
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
202 |
|
|
#define IPV6_ADDR_INT32_ONE 1
|
203 |
|
|
#define IPV6_ADDR_INT32_TWO 2
|
204 |
|
|
#define IPV6_ADDR_INT32_MNL 0xff010000
|
205 |
|
|
#define IPV6_ADDR_INT32_MLL 0xff020000
|
206 |
|
|
#define IPV6_ADDR_INT32_SMP 0x0000ffff
|
207 |
|
|
#define IPV6_ADDR_INT16_ULL 0xfe80
|
208 |
|
|
#define IPV6_ADDR_INT16_USL 0xfec0
|
209 |
|
|
#define IPV6_ADDR_INT16_MLL 0xff02
|
210 |
|
|
#elif BYTE_ORDER == LITTLE_ENDIAN
|
211 |
|
|
#define IPV6_ADDR_INT32_ONE 0x01000000
|
212 |
|
|
#define IPV6_ADDR_INT32_TWO 0x02000000
|
213 |
|
|
#define IPV6_ADDR_INT32_MNL 0x000001ff
|
214 |
|
|
#define IPV6_ADDR_INT32_MLL 0x000002ff
|
215 |
|
|
#define IPV6_ADDR_INT32_SMP 0xffff0000
|
216 |
|
|
#define IPV6_ADDR_INT16_ULL 0x80fe
|
217 |
|
|
#define IPV6_ADDR_INT16_USL 0xc0fe
|
218 |
|
|
#define IPV6_ADDR_INT16_MLL 0x02ff
|
219 |
|
|
#endif
|
220 |
|
|
#endif
|
221 |
|
|
|
222 |
|
|
/*
|
223 |
|
|
* Definition of some useful macros to handle IP6 addresses
|
224 |
|
|
*/
|
225 |
|
|
#define IN6ADDR_ANY_INIT \
|
226 |
|
|
{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
227 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
|
228 |
|
|
#define IN6ADDR_LOOPBACK_INIT \
|
229 |
|
|
{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
230 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
231 |
|
|
#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
|
232 |
|
|
{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
233 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
234 |
|
|
#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
|
235 |
|
|
{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
236 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
237 |
|
|
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
|
238 |
|
|
{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
239 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
|
240 |
|
|
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
|
241 |
|
|
{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
242 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
|
243 |
|
|
|
244 |
|
|
extern const struct in6_addr in6addr_any;
|
245 |
|
|
extern const struct in6_addr in6addr_loopback;
|
246 |
|
|
extern const struct in6_addr in6addr_nodelocal_allnodes;
|
247 |
|
|
extern const struct in6_addr in6addr_linklocal_allnodes;
|
248 |
|
|
extern const struct in6_addr in6addr_linklocal_allrouters;
|
249 |
|
|
|
250 |
|
|
/*
|
251 |
|
|
* Equality
|
252 |
|
|
* NOTE: Some of kernel programming environment (for example, openbsd/sparc)
|
253 |
|
|
* does not supply memcmp(). For userland memcmp() is preferred as it is
|
254 |
|
|
* in ANSI standard.
|
255 |
|
|
*/
|
256 |
|
|
#ifdef _KERNEL
|
257 |
|
|
#define IN6_ARE_ADDR_EQUAL(a, b) \
|
258 |
|
|
(bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
|
259 |
|
|
#else
|
260 |
|
|
#define IN6_ARE_ADDR_EQUAL(a, b) \
|
261 |
|
|
(memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
|
262 |
|
|
#endif
|
263 |
|
|
|
264 |
|
|
#ifdef _KERNEL /* non standard */
|
265 |
|
|
/* see if two addresses are equal in a scope-conscious manner. */
|
266 |
|
|
#define SA6_ARE_ADDR_EQUAL(a, b) \
|
267 |
|
|
(((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \
|
268 |
|
|
((a)->sin6_scope_id == (b)->sin6_scope_id)) && \
|
269 |
|
|
(bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0))
|
270 |
|
|
#endif
|
271 |
|
|
|
272 |
|
|
/*
|
273 |
|
|
* Unspecified
|
274 |
|
|
*/
|
275 |
|
|
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
276 |
|
|
((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
|
277 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
|
278 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
|
279 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
|
280 |
|
|
|
281 |
|
|
/*
|
282 |
|
|
* Loopback
|
283 |
|
|
*/
|
284 |
|
|
#define IN6_IS_ADDR_LOOPBACK(a) \
|
285 |
|
|
((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
|
286 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
|
287 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
|
288 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
|
289 |
|
|
|
290 |
|
|
/*
|
291 |
|
|
* IPv4 compatible
|
292 |
|
|
*/
|
293 |
|
|
#define IN6_IS_ADDR_V4COMPAT(a) \
|
294 |
|
|
((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
|
295 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
|
296 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
|
297 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \
|
298 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
|
299 |
|
|
|
300 |
|
|
/*
|
301 |
|
|
* Mapped
|
302 |
|
|
*/
|
303 |
|
|
#define IN6_IS_ADDR_V4MAPPED(a) \
|
304 |
|
|
((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
|
305 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
|
306 |
|
|
(*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
|
307 |
|
|
|
308 |
|
|
/*
|
309 |
|
|
* KAME Scope Values
|
310 |
|
|
*/
|
311 |
|
|
|
312 |
|
|
#ifdef _KERNEL /* XXX nonstandard */
|
313 |
|
|
#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
|
314 |
|
|
#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
|
315 |
|
|
#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
|
316 |
|
|
#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
|
317 |
|
|
#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
|
318 |
|
|
#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
|
319 |
|
|
#else
|
320 |
|
|
#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01
|
321 |
|
|
#define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
|
322 |
|
|
#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02
|
323 |
|
|
#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
|
324 |
|
|
#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
|
325 |
|
|
#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
|
326 |
|
|
#endif
|
327 |
|
|
|
328 |
|
|
/*
|
329 |
|
|
* Unicast Scope
|
330 |
|
|
* Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
|
331 |
|
|
*/
|
332 |
|
|
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
333 |
|
|
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
|
334 |
|
|
#define IN6_IS_ADDR_SITELOCAL(a) \
|
335 |
|
|
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
|
336 |
|
|
|
337 |
|
|
/*
|
338 |
|
|
* Multicast
|
339 |
|
|
*/
|
340 |
|
|
#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
|
341 |
|
|
|
342 |
|
|
#ifdef _KERNEL /* XXX nonstandard */
|
343 |
|
|
#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
|
344 |
|
|
#else
|
345 |
|
|
#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
|
346 |
|
|
#endif
|
347 |
|
|
|
348 |
|
|
/*
|
349 |
|
|
* Multicast Scope
|
350 |
|
|
*/
|
351 |
|
|
#ifdef _KERNEL /* refers nonstandard items */
|
352 |
|
|
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
|
353 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
354 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
|
355 |
|
|
#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
|
356 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
357 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
|
358 |
|
|
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
|
359 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
360 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
|
361 |
|
|
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
|
362 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
363 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
|
364 |
|
|
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
|
365 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
366 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
|
367 |
|
|
#define IN6_IS_ADDR_MC_GLOBAL(a) \
|
368 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
369 |
|
|
(IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
|
370 |
|
|
#else
|
371 |
|
|
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
|
372 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
373 |
|
|
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
|
374 |
|
|
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
|
375 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
376 |
|
|
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
|
377 |
|
|
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
|
378 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
379 |
|
|
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
|
380 |
|
|
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
|
381 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
382 |
|
|
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
|
383 |
|
|
#define IN6_IS_ADDR_MC_GLOBAL(a) \
|
384 |
|
|
(IN6_IS_ADDR_MULTICAST(a) && \
|
385 |
|
|
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
|
386 |
|
|
#endif
|
387 |
|
|
|
388 |
|
|
#ifdef _KERNEL /* nonstandard */
|
389 |
|
|
/*
|
390 |
|
|
* KAME Scope
|
391 |
|
|
*/
|
392 |
|
|
#define IN6_IS_SCOPE_LINKLOCAL(a) \
|
393 |
|
|
((IN6_IS_ADDR_LINKLOCAL(a)) || \
|
394 |
|
|
(IN6_IS_ADDR_MC_LINKLOCAL(a)))
|
395 |
|
|
|
396 |
|
|
#if (defined(__FreeBSD__) && __FreeBSD__ >= 3)
|
397 |
|
|
#define IFA6_IS_DEPRECATED(a) \
|
398 |
|
|
((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
|
399 |
|
|
(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
|
400 |
|
|
(a)->ia6_lifetime.ia6t_pltime)
|
401 |
|
|
#define IFA6_IS_INVALID(a) \
|
402 |
|
|
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
|
403 |
|
|
(u_int32_t)((time_second - (a)->ia6_updatetime)) > \
|
404 |
|
|
(a)->ia6_lifetime.ia6t_vltime)
|
405 |
|
|
#else
|
406 |
|
|
#define IFA6_IS_DEPRECATED(a) \
|
407 |
|
|
((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
|
408 |
|
|
(u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \
|
409 |
|
|
(a)->ia6_lifetime.ia6t_pltime)
|
410 |
|
|
#define IFA6_IS_INVALID(a) \
|
411 |
|
|
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
|
412 |
|
|
(u_int32_t)((time.tv_sec - (a)->ia6_updatetime)) > \
|
413 |
|
|
(a)->ia6_lifetime.ia6t_vltime)
|
414 |
|
|
#endif
|
415 |
|
|
#endif /* _KERNEL */
|
416 |
|
|
|
417 |
|
|
/*
|
418 |
|
|
* IP6 route structure
|
419 |
|
|
*/
|
420 |
|
|
#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
|
421 |
|
|
#ifndef _XOPEN_SOURCE
|
422 |
|
|
#ifndef NEW_STRUCT_ROUTE
|
423 |
|
|
struct route_in6 {
|
424 |
|
|
struct rtentry *ro_rt;
|
425 |
|
|
struct sockaddr_in6 ro_dst;
|
426 |
|
|
};
|
427 |
|
|
#endif /* !NEW_STRUCT_ROUTE */
|
428 |
|
|
#endif
|
429 |
|
|
#endif
|
430 |
|
|
|
431 |
|
|
/*
|
432 |
|
|
* Options for use with [gs]etsockopt at the IPV6 level.
|
433 |
|
|
* First word of comment is data type; bool is stored in int.
|
434 |
|
|
*/
|
435 |
|
|
/* no hdrincl */
|
436 |
|
|
#if 0 /* the followings are relic in IPv4 and hence are disabled */
|
437 |
|
|
#define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */
|
438 |
|
|
#define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */
|
439 |
|
|
#define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */
|
440 |
|
|
#define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */
|
441 |
|
|
#define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */
|
442 |
|
|
#endif
|
443 |
|
|
#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
|
444 |
|
|
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
|
445 |
|
|
#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */
|
446 |
|
|
#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */
|
447 |
|
|
#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */
|
448 |
|
|
#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
|
449 |
|
|
#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
|
450 |
|
|
#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
|
451 |
|
|
#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
|
452 |
|
|
/* RFC2292 options */
|
453 |
|
|
#ifdef _KERNEL
|
454 |
|
|
#define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */
|
455 |
|
|
#define IPV6_2292HOPLIMIT 20 /* bool; hop limit */
|
456 |
|
|
#define IPV6_2292NEXTHOP 21 /* bool; next hop addr */
|
457 |
|
|
#define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */
|
458 |
|
|
#define IPV6_2292DSTOPTS 23 /* bool; destinaion option */
|
459 |
|
|
#define IPV6_2292RTHDR 24 /* bool; routing header */
|
460 |
|
|
#define IPV6_2292PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */
|
461 |
|
|
#endif
|
462 |
|
|
|
463 |
|
|
#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
|
464 |
|
|
#define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */
|
465 |
|
|
#ifndef _KERNEL
|
466 |
|
|
#define IPV6_BINDV6ONLY IPV6_V6ONLY
|
467 |
|
|
#endif
|
468 |
|
|
|
469 |
|
|
#if 1 /* IPSEC */
|
470 |
|
|
#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */
|
471 |
|
|
#endif
|
472 |
|
|
#define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */
|
473 |
|
|
|
474 |
|
|
#if 1 /* IPV6FIREWALL */
|
475 |
|
|
#define IPV6_FW_ADD 30 /* add a firewall rule to chain */
|
476 |
|
|
#define IPV6_FW_DEL 31 /* delete a firewall rule from chain */
|
477 |
|
|
#define IPV6_FW_FLUSH 32 /* flush firewall rule chain */
|
478 |
|
|
#define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */
|
479 |
|
|
#define IPV6_FW_GET 34 /* get entire firewall rule chain */
|
480 |
|
|
#endif
|
481 |
|
|
|
482 |
|
|
/* new socket options introduced in RFC2292bis */
|
483 |
|
|
#define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */
|
484 |
|
|
|
485 |
|
|
#define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */
|
486 |
|
|
#define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */
|
487 |
|
|
#define IPV6_RECVRTHDR 38 /* bool; recv routing header */
|
488 |
|
|
#define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */
|
489 |
|
|
#define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */
|
490 |
|
|
#ifdef _KERNEL
|
491 |
|
|
#define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */
|
492 |
|
|
#endif
|
493 |
|
|
|
494 |
|
|
#define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */
|
495 |
|
|
#define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */
|
496 |
|
|
|
497 |
|
|
#define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt),
|
498 |
|
|
4 bytes int; MTU notification (cmsg) */
|
499 |
|
|
#define IPV6_REACHCONF 45 /* no data; ND reachability confirm
|
500 |
|
|
(cmsg only) */
|
501 |
|
|
|
502 |
|
|
/* more new socket options introduced in RFC2292bis */
|
503 |
|
|
#define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */
|
504 |
|
|
#define IPV6_HOPLIMIT 47 /* int; send hop limit */
|
505 |
|
|
#define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */
|
506 |
|
|
#define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */
|
507 |
|
|
#define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */
|
508 |
|
|
#define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */
|
509 |
|
|
#if 0
|
510 |
|
|
#define IPV6_PKTOPTIONS 52 /* buf/cmsghdr; set/get IPv6 options */
|
511 |
|
|
/* obsoleted by 2292bis */
|
512 |
|
|
#endif
|
513 |
|
|
|
514 |
|
|
#ifdef __OpenBSD__
|
515 |
|
|
#define IPV6_AUTH_LEVEL 53 /* int; authentication used */
|
516 |
|
|
#define IPV6_ESP_TRANS_LEVEL 54 /* int; transport encryption */
|
517 |
|
|
#define IPV6_ESP_NETWORK_LEVEL 55 /* int; full-packet encryption */
|
518 |
|
|
#define IPSEC6_OUTSA 56 /* set the outbound SA for a socket */
|
519 |
|
|
#endif
|
520 |
|
|
|
521 |
|
|
#define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */
|
522 |
|
|
#ifdef _KERNEL
|
523 |
|
|
#define IPV6_OTCLASS 58 /* u_int8_t; send traffic class value */
|
524 |
|
|
#endif
|
525 |
|
|
#define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */
|
526 |
|
|
|
527 |
|
|
#ifdef __OpenBSD__
|
528 |
|
|
#define IPV6_IPCOMP_LEVEL 60 /* int; compression */
|
529 |
|
|
#endif
|
530 |
|
|
|
531 |
|
|
#define IPV6_TCLASS 61 /* int; send traffic class value */
|
532 |
|
|
#define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */
|
533 |
|
|
|
534 |
|
|
/* to define items, should talk with KAME guys first, for *BSD compatibility */
|
535 |
|
|
|
536 |
|
|
#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */
|
537 |
|
|
#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */
|
538 |
|
|
#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */
|
539 |
|
|
|
540 |
|
|
/*
|
541 |
|
|
* Defaults and limits for options
|
542 |
|
|
*/
|
543 |
|
|
#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
|
544 |
|
|
#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
|
545 |
|
|
|
546 |
|
|
/*
|
547 |
|
|
* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
|
548 |
|
|
*/
|
549 |
|
|
struct ipv6_mreq {
|
550 |
|
|
struct in6_addr ipv6mr_multiaddr;
|
551 |
|
|
unsigned int ipv6mr_interface;
|
552 |
|
|
};
|
553 |
|
|
|
554 |
|
|
/*
|
555 |
|
|
* IPV6_PKTINFO: Packet information(RFC2292 sec 5)
|
556 |
|
|
*/
|
557 |
|
|
struct in6_pktinfo {
|
558 |
|
|
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
559 |
|
|
unsigned int ipi6_ifindex; /* send/recv interface index */
|
560 |
|
|
};
|
561 |
|
|
|
562 |
|
|
/*
|
563 |
|
|
* Control structure for IPV6_RECVPATHMTU socket option.
|
564 |
|
|
* Note that this structure is not fully conformant to rfc2292bis-02.
|
565 |
|
|
* However, since how to tell the destination of the path (or the path itself)
|
566 |
|
|
* to the application is not determined, we use our original structure.
|
567 |
|
|
*/
|
568 |
|
|
struct ip6_mtuinfo {
|
569 |
|
|
struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */
|
570 |
|
|
u_int32_t ip6m_mtu;
|
571 |
|
|
};
|
572 |
|
|
|
573 |
|
|
/*
|
574 |
|
|
* Argument for IPV6_PORTRANGE:
|
575 |
|
|
* - which range to search when port is unspecified at bind() or connect()
|
576 |
|
|
*/
|
577 |
|
|
#define IPV6_PORTRANGE_DEFAULT 0 /* default range */
|
578 |
|
|
#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
|
579 |
|
|
#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
|
580 |
|
|
|
581 |
|
|
#ifndef _XOPEN_SOURCE
|
582 |
|
|
/*
|
583 |
|
|
* Definitions for inet6 sysctl operations.
|
584 |
|
|
*
|
585 |
|
|
* Third level is protocol number.
|
586 |
|
|
* Fourth level is desired variable within that protocol.
|
587 |
|
|
*/
|
588 |
|
|
#define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */
|
589 |
|
|
|
590 |
|
|
#define CTL_IPV6PROTO_NAMES { \
|
591 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
592 |
|
|
{ 0, 0 }, \
|
593 |
|
|
{ "tcp6", CTLTYPE_NODE }, \
|
594 |
|
|
{ 0, 0 }, \
|
595 |
|
|
{ 0, 0 }, \
|
596 |
|
|
{ 0, 0 }, \
|
597 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
598 |
|
|
{ 0, 0 }, \
|
599 |
|
|
{ 0, 0 }, \
|
600 |
|
|
{ "udp6", CTLTYPE_NODE }, \
|
601 |
|
|
{ 0, 0 }, \
|
602 |
|
|
{ 0, 0 }, \
|
603 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
604 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
605 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
606 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
607 |
|
|
{ 0, 0 }, \
|
608 |
|
|
{ "ip6", CTLTYPE_NODE }, \
|
609 |
|
|
{ 0, 0 }, \
|
610 |
|
|
{ 0, 0 }, \
|
611 |
|
|
{ 0, 0 }, \
|
612 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
613 |
|
|
{ 0, 0 }, \
|
614 |
|
|
{ "ipsec6", CTLTYPE_NODE }, \
|
615 |
|
|
{ 0, 0 }, \
|
616 |
|
|
{ 0, 0 }, \
|
617 |
|
|
{ 0, 0 }, \
|
618 |
|
|
{ 0, 0 }, \
|
619 |
|
|
{ 0, 0 }, \
|
620 |
|
|
{ 0, 0 }, \
|
621 |
|
|
{ "icmp6", CTLTYPE_NODE }, \
|
622 |
|
|
{ 0, 0 }, \
|
623 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
624 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
625 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
626 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
627 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
628 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
629 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
630 |
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
|
631 |
|
|
{ 0, 0 }, \
|
632 |
|
|
{ 0, 0 }, \
|
633 |
|
|
{ 0, 0 }, \
|
634 |
|
|
{ "pim6", CTLTYPE_NODE }, \
|
635 |
|
|
}
|
636 |
|
|
|
637 |
|
|
/*
|
638 |
|
|
* Names for IP sysctl objects
|
639 |
|
|
*/
|
640 |
|
|
#define IPV6CTL_FORWARDING 1 /* act as router */
|
641 |
|
|
#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/
|
642 |
|
|
#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
|
643 |
|
|
#ifdef notyet
|
644 |
|
|
#define IPV6CTL_DEFMTU 4 /* default MTU */
|
645 |
|
|
#endif
|
646 |
|
|
#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
|
647 |
|
|
#define IPV6CTL_STATS 6 /* stats */
|
648 |
|
|
#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
|
649 |
|
|
#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
|
650 |
|
|
#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
|
651 |
|
|
#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
|
652 |
|
|
#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
|
653 |
|
|
#define IPV6CTL_ACCEPT_RTADV 12
|
654 |
|
|
#define IPV6CTL_KEEPFAITH 13
|
655 |
|
|
#define IPV6CTL_LOG_INTERVAL 14
|
656 |
|
|
#define IPV6CTL_HDRNESTLIMIT 15
|
657 |
|
|
#define IPV6CTL_DAD_COUNT 16
|
658 |
|
|
#define IPV6CTL_AUTO_FLOWLABEL 17
|
659 |
|
|
#define IPV6CTL_DEFMCASTHLIM 18
|
660 |
|
|
#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */
|
661 |
|
|
#define IPV6CTL_KAME_VERSION 20
|
662 |
|
|
#define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */
|
663 |
|
|
#define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */
|
664 |
|
|
#if 0 /* obsolete */
|
665 |
|
|
#define IPV6CTL_MAPPED_ADDR 23
|
666 |
|
|
#endif
|
667 |
|
|
#define IPV6CTL_V6ONLY 24
|
668 |
|
|
#ifdef __FreeBSD__
|
669 |
|
|
#define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */
|
670 |
|
|
#define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */
|
671 |
|
|
#define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */
|
672 |
|
|
#endif
|
673 |
|
|
#ifdef __NetBSD__
|
674 |
|
|
#define IPV6CTL_ANONPORTMIN 28 /* minimum ephemeral port */
|
675 |
|
|
#define IPV6CTL_ANONPORTMAX 29 /* maximum ephemeral port */
|
676 |
|
|
#define IPV6CTL_LOWPORTMIN 30 /* minimum reserved port */
|
677 |
|
|
#define IPV6CTL_LOWPORTMAX 31 /* maximum reserved port */
|
678 |
|
|
#endif
|
679 |
|
|
#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses for
|
680 |
|
|
privacy extension */
|
681 |
|
|
#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */
|
682 |
|
|
#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */
|
683 |
|
|
#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */
|
684 |
|
|
#define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */
|
685 |
|
|
#define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */
|
686 |
|
|
#define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */
|
687 |
|
|
#define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */
|
688 |
|
|
|
689 |
|
|
/* New entries should be added here from current IPV6CTL_MAXID value. */
|
690 |
|
|
/* to define items, should talk with KAME guys first, for *BSD compatibility */
|
691 |
|
|
#define IPV6CTL_MAXID 40
|
692 |
|
|
|
693 |
|
|
#ifdef IPV6CTL_RTEXPIRE
|
694 |
|
|
#define __IPV6CTL_NAMES_RTEXPIRE "rtexpire"
|
695 |
|
|
#define __IPV6CTL_TYPE_RTEXPIRE CTLTYPE_INT
|
696 |
|
|
#define __IPV6CTL_VARS_RTEXPIRE 0 /* &rtq_reallyold */
|
697 |
|
|
#else
|
698 |
|
|
#define __IPV6CTL_NAMES_RTEXPIRE 0
|
699 |
|
|
#define __IPV6CTL_TYPE_RTEXPIRE 0
|
700 |
|
|
#define __IPV6CTL_VARS_RTEXPIRE 0
|
701 |
|
|
#endif
|
702 |
|
|
|
703 |
|
|
#ifdef IPV6CTL_RTMINEXPIRE
|
704 |
|
|
#define __IPV6CTL_NAMES_RTMINEXPIRE "minexpire"
|
705 |
|
|
#define __IPV6CTL_TYPE_RTMINEXPIRE CTLTYPE_INT
|
706 |
|
|
#define __IPV6CTL_VARS_RTMINEXPIRE 0 /* &rtq_minreallyold */
|
707 |
|
|
#else
|
708 |
|
|
#define __IPV6CTL_NAMES_RTMINEXPIRE 0
|
709 |
|
|
#define __IPV6CTL_TYPE_RTMINEXPIRE 0
|
710 |
|
|
#define __IPV6CTL_VARS_RTMINEXPIRE 0
|
711 |
|
|
#endif
|
712 |
|
|
|
713 |
|
|
#ifdef IPV6CTL_RTMAXCACHE
|
714 |
|
|
#define __IPV6CTL_NAMES_RTMAXCACHE "maxcache"
|
715 |
|
|
#define __IPV6CTL_TYPE_RTMAXCACHE CTLTYPE_INT
|
716 |
|
|
#define __IPV6CTL_VARS_RTMAXCACHE 0 /* &rtq_toomany */
|
717 |
|
|
#else
|
718 |
|
|
#define __IPV6CTL_NAMES_RTMAXCACHE 0
|
719 |
|
|
#define __IPV6CTL_TYPE_RTMAXCACHE 0
|
720 |
|
|
#define __IPV6CTL_VARS_RTMAXCACHE 0
|
721 |
|
|
#endif
|
722 |
|
|
|
723 |
|
|
#ifdef IPV6CTL_ANONPORTMIN
|
724 |
|
|
#define __IPV6CTL_NAMES_ANONPORTMIN "anonportmin"
|
725 |
|
|
#define __IPV6CTL_TYPE_ANONPORTMIN CTLTYPE_INT
|
726 |
|
|
#define __IPV6CTL_VARS_ANONPORTMIN 0
|
727 |
|
|
#else
|
728 |
|
|
#define __IPV6CTL_NAMES_ANONPORTMIN 0
|
729 |
|
|
#define __IPV6CTL_TYPE_ANONPORTMIN 0
|
730 |
|
|
#define __IPV6CTL_VARS_ANONPORTMIN 0
|
731 |
|
|
#endif
|
732 |
|
|
|
733 |
|
|
#ifdef IPV6CTL_ANONPORTMAX
|
734 |
|
|
#define __IPV6CTL_NAMES_ANONPORTMAX "anonportmax"
|
735 |
|
|
#define __IPV6CTL_TYPE_ANONPORTMAX CTLTYPE_INT
|
736 |
|
|
#define __IPV6CTL_VARS_ANONPORTMAX 0
|
737 |
|
|
#else
|
738 |
|
|
#define __IPV6CTL_NAMES_ANONPORTMAX 0
|
739 |
|
|
#define __IPV6CTL_TYPE_ANONPORTMAX 0
|
740 |
|
|
#define __IPV6CTL_VARS_ANONPORTMAX 0
|
741 |
|
|
#endif
|
742 |
|
|
|
743 |
|
|
#ifdef IPV6CTL_LOWPORTMIN
|
744 |
|
|
#define __IPV6CTL_NAMES_LOWPORTMIN "lowportmin"
|
745 |
|
|
#define __IPV6CTL_TYPE_LOWPORTMIN CTLTYPE_INT
|
746 |
|
|
#define __IPV6CTL_VARS_LOWPORTMIN 0
|
747 |
|
|
#else
|
748 |
|
|
#define __IPV6CTL_NAMES_LOWPORTMIN 0
|
749 |
|
|
#define __IPV6CTL_TYPE_LOWPORTMIN 0
|
750 |
|
|
#define __IPV6CTL_VARS_LOWPORTMIN 0
|
751 |
|
|
#endif
|
752 |
|
|
|
753 |
|
|
#ifdef IPV6CTL_LOWPORTMAX
|
754 |
|
|
#define __IPV6CTL_NAMES_LOWPORTMAX "lowportmax"
|
755 |
|
|
#define __IPV6CTL_TYPE_LOWPORTMAX CTLTYPE_INT
|
756 |
|
|
#define __IPV6CTL_VARS_LOWPORTMAX 0
|
757 |
|
|
#else
|
758 |
|
|
#define __IPV6CTL_NAMES_LOWPORTMAX 0
|
759 |
|
|
#define __IPV6CTL_TYPE_LOWPORTMAX 0
|
760 |
|
|
#define __IPV6CTL_VARS_LOWPORTMAX 0
|
761 |
|
|
#endif
|
762 |
|
|
|
763 |
|
|
|
764 |
|
|
#define IPV6CTL_NAMES { \
|
765 |
|
|
{ 0, 0 }, \
|
766 |
|
|
{ "forwarding", CTLTYPE_INT }, \
|
767 |
|
|
{ "redirect", CTLTYPE_INT }, \
|
768 |
|
|
{ "hlim", CTLTYPE_INT }, \
|
769 |
|
|
{ "mtu", CTLTYPE_INT }, \
|
770 |
|
|
{ "forwsrcrt", CTLTYPE_INT }, \
|
771 |
|
|
{ 0, 0 }, \
|
772 |
|
|
{ 0, 0 }, \
|
773 |
|
|
{ "mrtproto", CTLTYPE_INT }, \
|
774 |
|
|
{ "maxfragpackets", CTLTYPE_INT }, \
|
775 |
|
|
{ "sourcecheck", CTLTYPE_INT }, \
|
776 |
|
|
{ "sourcecheck_logint", CTLTYPE_INT }, \
|
777 |
|
|
{ "accept_rtadv", CTLTYPE_INT }, \
|
778 |
|
|
{ "keepfaith", CTLTYPE_INT }, \
|
779 |
|
|
{ "log_interval", CTLTYPE_INT }, \
|
780 |
|
|
{ "hdrnestlimit", CTLTYPE_INT }, \
|
781 |
|
|
{ "dad_count", CTLTYPE_INT }, \
|
782 |
|
|
{ "auto_flowlabel", CTLTYPE_INT }, \
|
783 |
|
|
{ "defmcasthlim", CTLTYPE_INT }, \
|
784 |
|
|
{ "gifhlim", CTLTYPE_INT }, \
|
785 |
|
|
{ "kame_version", CTLTYPE_STRING }, \
|
786 |
|
|
{ "use_deprecated", CTLTYPE_INT }, \
|
787 |
|
|
{ "rr_prune", CTLTYPE_INT }, \
|
788 |
|
|
{ 0, 0 }, \
|
789 |
|
|
{ "v6only", CTLTYPE_INT }, \
|
790 |
|
|
{ __IPV6CTL_NAMES_RTEXPIRE, __IPV6CTL_TYPE_RTEXPIRE }, \
|
791 |
|
|
{ __IPV6CTL_NAMES_RTMINEXPIRE, __IPV6CTL_TYPE_RTMINEXPIRE }, \
|
792 |
|
|
{ __IPV6CTL_NAMES_RTMAXCACHE, __IPV6CTL_TYPE_RTMAXCACHE }, \
|
793 |
|
|
{ __IPV6CTL_NAMES_ANONPORTMIN, __IPV6CTL_TYPE_ANONPORTMIN }, \
|
794 |
|
|
{ __IPV6CTL_NAMES_ANONPORTMAX, __IPV6CTL_TYPE_ANONPORTMAX }, \
|
795 |
|
|
{ __IPV6CTL_NAMES_LOWPORTMIN, __IPV6CTL_TYPE_LOWPORTMIN }, \
|
796 |
|
|
{ __IPV6CTL_NAMES_LOWPORTMAX, __IPV6CTL_TYPE_LOWPORTMAX }, \
|
797 |
|
|
{ "use_tempaddr", CTLTYPE_INT }, \
|
798 |
|
|
{ "temppltime", CTLTYPE_INT }, \
|
799 |
|
|
{ "tempvltime", CTLTYPE_INT }, \
|
800 |
|
|
{ "auto_linklocal", CTLTYPE_INT }, \
|
801 |
|
|
{ 0, 0 }, \
|
802 |
|
|
{ "prefer_tempaddr", CTLTYPE_INT }, \
|
803 |
|
|
{ 0, 0 }, \
|
804 |
|
|
{ "use_defaultzone", CTLTYPE_INT }, \
|
805 |
|
|
}
|
806 |
|
|
|
807 |
|
|
#ifdef __bsdi__
|
808 |
|
|
#define IPV6CTL_VARS { \
|
809 |
|
|
0, \
|
810 |
|
|
&ip6_forwarding, \
|
811 |
|
|
&ip6_sendredirects, \
|
812 |
|
|
&ip6_defhlim, \
|
813 |
|
|
0, \
|
814 |
|
|
&ip6_forward_srcrt, \
|
815 |
|
|
0, \
|
816 |
|
|
0, \
|
817 |
|
|
0, \
|
818 |
|
|
&ip6_maxfragpackets, \
|
819 |
|
|
&ip6_sourcecheck, \
|
820 |
|
|
&ip6_sourcecheck_interval, \
|
821 |
|
|
&ip6_accept_rtadv, \
|
822 |
|
|
&ip6_keepfaith, \
|
823 |
|
|
&ip6_log_interval, \
|
824 |
|
|
&ip6_hdrnestlimit, \
|
825 |
|
|
&ip6_dad_count, \
|
826 |
|
|
&ip6_auto_flowlabel, \
|
827 |
|
|
&ip6_defmcasthlim, \
|
828 |
|
|
&ip6_gif_hlim, \
|
829 |
|
|
0, \
|
830 |
|
|
&ip6_use_deprecated, \
|
831 |
|
|
&ip6_rr_prune, \
|
832 |
|
|
0, \
|
833 |
|
|
&ip6_v6only, \
|
834 |
|
|
__IPV6CTL_VARS_RTEXPIRE, \
|
835 |
|
|
__IPV6CTL_VARS_RTMINEXPIRE, \
|
836 |
|
|
__IPV6CTL_VARS_RTMAXCACHE, \
|
837 |
|
|
__IPV6CTL_VARS_ANONPORTMIN, \
|
838 |
|
|
__IPV6CTL_VARS_ANONPORTMAX, \
|
839 |
|
|
__IPV6CTL_VARS_LOWPORTMIN, \
|
840 |
|
|
__IPV6CTL_VARS_LOWPORTMAX, \
|
841 |
|
|
&ip6_use_tempaddr, \
|
842 |
|
|
&ip6_temp_preferred_lifetime, \
|
843 |
|
|
&ip6_temp_valid_lifetime, \
|
844 |
|
|
&ip6_auto_linklocal, \
|
845 |
|
|
0, \
|
846 |
|
|
&ip6_prefer_tempaddr, \
|
847 |
|
|
0, \
|
848 |
|
|
&ip6_use_defzone,\
|
849 |
|
|
}
|
850 |
|
|
#endif
|
851 |
|
|
#endif /* !_XOPEN_SOURCE */
|
852 |
|
|
|
853 |
|
|
/*
|
854 |
|
|
* Redefinition of mbuf flags
|
855 |
|
|
*/
|
856 |
|
|
#define M_AUTHIPHDR M_PROTO2
|
857 |
|
|
#define M_DECRYPTED M_PROTO3
|
858 |
|
|
#define M_LOOP M_PROTO4
|
859 |
|
|
#define M_AUTHIPDGM M_PROTO5
|
860 |
|
|
|
861 |
|
|
#ifdef _KERNEL
|
862 |
|
|
struct cmsghdr;
|
863 |
|
|
struct mbuf;
|
864 |
|
|
struct ifnet;
|
865 |
|
|
|
866 |
|
|
int in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t));
|
867 |
|
|
int in6_localaddr __P((struct in6_addr *));
|
868 |
|
|
int in6_addrscope __P((struct in6_addr *));
|
869 |
|
|
struct in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *));
|
870 |
|
|
extern void in6_if_up __P((struct ifnet *));
|
871 |
|
|
struct sockaddr;
|
872 |
|
|
|
873 |
|
|
void in6_sin6_2_sin __P((struct sockaddr_in *sin,
|
874 |
|
|
struct sockaddr_in6 *sin6));
|
875 |
|
|
void in6_sin_2_v4mapsin6 __P((struct sockaddr_in *sin,
|
876 |
|
|
struct sockaddr_in6 *sin6));
|
877 |
|
|
void in6_sin6_2_sin_in_sock __P((struct sockaddr *nam));
|
878 |
|
|
void in6_sin_2_v4mapsin6_in_sock __P((struct sockaddr **nam));
|
879 |
|
|
extern void addrsel_policy_init __P((void));
|
880 |
|
|
|
881 |
|
|
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
|
882 |
|
|
#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
|
883 |
|
|
#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
|
884 |
|
|
#endif /* _KERNEL */
|
885 |
|
|
|
886 |
|
|
__BEGIN_DECLS
|
887 |
|
|
struct cmsghdr;
|
888 |
|
|
|
889 |
|
|
extern int inet6_option_space __P((int));
|
890 |
|
|
extern int inet6_option_init __P((void *, struct cmsghdr **, int));
|
891 |
|
|
extern int inet6_option_append __P((struct cmsghdr *, const u_int8_t *,
|
892 |
|
|
int, int));
|
893 |
|
|
extern u_int8_t *inet6_option_alloc __P((struct cmsghdr *, int, int, int));
|
894 |
|
|
extern int inet6_option_next __P((const struct cmsghdr *, u_int8_t **));
|
895 |
|
|
extern int inet6_option_find __P((const struct cmsghdr *, u_int8_t **, int));
|
896 |
|
|
|
897 |
|
|
extern size_t inet6_rthdr_space __P((int, int));
|
898 |
|
|
extern struct cmsghdr *inet6_rthdr_init __P((void *, int));
|
899 |
|
|
extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *,
|
900 |
|
|
unsigned int));
|
901 |
|
|
extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int));
|
902 |
|
|
#if 0 /* not implemented yet */
|
903 |
|
|
extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *));
|
904 |
|
|
#endif
|
905 |
|
|
extern int inet6_rthdr_segments __P((const struct cmsghdr *));
|
906 |
|
|
extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int));
|
907 |
|
|
extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int));
|
908 |
|
|
|
909 |
|
|
extern int inet6_opt_init __P((void *, size_t));
|
910 |
|
|
extern int inet6_opt_append __P((void *, size_t, int, u_int8_t,
|
911 |
|
|
size_t, u_int8_t, void **));
|
912 |
|
|
extern int inet6_opt_finish __P((void *, size_t, int));
|
913 |
|
|
extern int inet6_opt_set_val __P((void *, size_t, void *, int));
|
914 |
|
|
|
915 |
|
|
extern int inet6_opt_next __P((void *, size_t, int, u_int8_t *,
|
916 |
|
|
size_t *, void **));
|
917 |
|
|
extern int inet6_opt_find __P((void *, size_t, int, u_int8_t,
|
918 |
|
|
size_t *, void **));
|
919 |
|
|
extern int inet6_opt_get_val __P((void *, size_t, void *, int));
|
920 |
|
|
extern size_t inet6_rth_space __P((int, int));
|
921 |
|
|
extern void *inet6_rth_init __P((void *, int, int, int));
|
922 |
|
|
extern int inet6_rth_add __P((void *, const struct in6_addr *));
|
923 |
|
|
extern int inet6_rth_reverse __P((const void *, void *));
|
924 |
|
|
extern int inet6_rth_segments __P((const void *));
|
925 |
|
|
extern struct in6_addr *inet6_rth_getaddr __P((const void *, int));
|
926 |
|
|
|
927 |
|
|
/* the followings two are experimental. should not merge them to *BSD. */
|
928 |
|
|
struct sockaddr; /* XXX */
|
929 |
|
|
|
930 |
|
|
extern int addr2scopetype __P((struct sockaddr *));
|
931 |
|
|
extern int inet_zoneid __P((int, int, char *, u_int32_t *));
|
932 |
|
|
__END_DECLS
|
933 |
|
|
|
934 |
|
|
#endif /* !_NETINET6_IN6_H_ */
|