1 /* $KAME: in6.h,v 1.40 2000/03/25 07:23:42 sumikawa Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * Copyright (c) 1982, 1986, 1990, 1993
34 * The Regents of the University of California. All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)in.h 8.3 (Berkeley) 1/3/94
67 #ifndef __KAME_NETINET_IN_H_INCLUDED_
68 #error "do not include netinet6/in6.h directly, include netinet/in.h"
71 #ifndef _NETINET6_IN6_H_
72 #define _NETINET6_IN6_H_
74 #if !defined(_XOPEN_SOURCE)
75 #include <sys/queue.h>
79 * Identification of the network protocol stack
82 #define __KAME_VERSION "STABLE 20000425"
85 * Local port number conventions:
87 * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
88 * unless a kernel is compiled with IPNOPRIVPORTS defined.
90 * When a user does a bind(2) or connect(2) with a port number of zero,
91 * a non-conflicting local port address is chosen.
93 * The default range is IPPORT_ANONMIX to IPPORT_ANONMAX, although
94 * that is settable by sysctl(3); net.inet.ip.anonportmin and
95 * net.inet.ip.anonportmax respectively.
97 * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
98 * default assignment range.
100 * The value IP_PORTRANGE_DEFAULT causes the default behavior.
102 * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
103 * and exists only for FreeBSD compatibility purposes.
105 * The value IP_PORTRANGE_LOW changes the range to the "low" are
106 * that is (by convention) restricted to privileged processes.
107 * This convention is based on "vouchsafe" principles only.
108 * It is only secure if you trust the remote host to restrict these ports.
109 * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
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)
123 u_int8_t __u6_addr8
[16];
124 u_int16_t __u6_addr16
[8];
125 u_int32_t __u6_addr32
[4];
126 } __u6_addr
; /* 128-bit IP6 address */
129 #define s6_addr __u6_addr.__u6_addr8
130 #ifdef KERNEL /*XXX nonstandard*/
131 #define s6_addr8 __u6_addr.__u6_addr8
132 #define s6_addr16 __u6_addr.__u6_addr16
133 #define s6_addr32 __u6_addr.__u6_addr32
136 #define INET6_ADDRSTRLEN 46
139 * Socket address for IPv6
141 #if !defined(_XOPEN_SOURCE)
144 struct sockaddr_in6
{
145 u_int8_t sin6_len
; /* length of this struct(sa_family_t)*/
146 u_int8_t sin6_family
; /* AF_INET6 (sa_family_t) */
147 u_int16_t sin6_port
; /* Transport layer port # (in_port_t)*/
148 u_int32_t sin6_flowinfo
; /* IP6 flow information */
149 struct in6_addr sin6_addr
; /* IP6 address */
150 u_int32_t sin6_scope_id
; /* intface scope id */
154 * Local definition for masks
156 #ifdef KERNEL /*XXX nonstandard*/
157 #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
158 #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
160 #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
162 #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
163 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
164 #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
165 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
169 extern const struct in6_addr in6mask0
;
170 extern const struct in6_addr in6mask32
;
171 extern const struct in6_addr in6mask64
;
172 extern const struct in6_addr in6mask96
;
173 extern const struct in6_addr in6mask128
;
177 * Macros started with IPV6_ADDR is KAME local
179 #ifdef KERNEL /*XXX nonstandard*/
180 #if BYTE_ORDER == BIG_ENDIAN
181 #define IPV6_ADDR_INT32_ONE 1
182 #define IPV6_ADDR_INT32_TWO 2
183 #define IPV6_ADDR_INT32_MNL 0xff010000
184 #define IPV6_ADDR_INT32_MLL 0xff020000
185 #define IPV6_ADDR_INT32_SMP 0x0000ffff
186 #define IPV6_ADDR_INT16_ULL 0xfe80
187 #define IPV6_ADDR_INT16_USL 0xfec0
188 #define IPV6_ADDR_INT16_MLL 0xff02
189 #elif BYTE_ORDER == LITTLE_ENDIAN
190 #define IPV6_ADDR_INT32_ONE 0x01000000
191 #define IPV6_ADDR_INT32_TWO 0x02000000
192 #define IPV6_ADDR_INT32_MNL 0x000001ff
193 #define IPV6_ADDR_INT32_MLL 0x000002ff
194 #define IPV6_ADDR_INT32_SMP 0xffff0000
195 #define IPV6_ADDR_INT16_ULL 0x80fe
196 #define IPV6_ADDR_INT16_USL 0xc0fe
197 #define IPV6_ADDR_INT16_MLL 0x02ff
202 * Definition of some useful macros to handle IP6 addresses
204 #define IN6ADDR_ANY_INIT \
205 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
207 #define IN6ADDR_LOOPBACK_INIT \
208 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
210 #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
211 {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
213 #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
214 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
216 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
217 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
221 extern const struct in6_addr in6addr_any
;
222 extern const struct in6_addr in6addr_loopback
;
223 extern const struct in6_addr in6addr_nodelocal_allnodes
;
224 extern const struct in6_addr in6addr_linklocal_allnodes
;
225 extern const struct in6_addr in6addr_linklocal_allrouters
;
230 * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
231 * does not supply memcmp(). For userland memcmp() is preferred as it is
235 #define IN6_ARE_ADDR_EQUAL(a, b) \
236 (bcmp((a), (b), sizeof(struct in6_addr)) == 0)
238 #define IN6_ARE_ADDR_EQUAL(a, b) \
239 (memcmp((a), (b), sizeof(struct in6_addr)) == 0)
245 #define IN6_IS_ADDR_UNSPECIFIED(a) \
246 ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) && \
247 (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) && \
248 (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) && \
249 (*(u_int32_t *)(&(a)->s6_addr[12]) == 0))
254 #define IN6_IS_ADDR_LOOPBACK(a) \
255 ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) && \
256 (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) && \
257 (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) && \
258 (*(u_int32_t *)(&(a)->s6_addr[12]) == ntohl(1)))
263 #define IN6_IS_ADDR_V4COMPAT(a) \
264 ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) && \
265 (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) && \
266 (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) && \
267 (*(u_int32_t *)(&(a)->s6_addr[12]) != 0) && \
268 (*(u_int32_t *)(&(a)->s6_addr[12]) != ntohl(1)))
273 #define IN6_IS_ADDR_V4MAPPED(a) \
274 ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) && \
275 (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) && \
276 (*(u_int32_t *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
282 #ifdef KERNEL /*XXX nonstandard*/
283 #define IPV6_ADDR_SCOPE_NODELOCAL 0x01
284 #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
285 #define IPV6_ADDR_SCOPE_SITELOCAL 0x05
286 #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
287 #define IPV6_ADDR_SCOPE_GLOBAL 0x0e
289 #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01
290 #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02
291 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
292 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
293 #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
298 * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
300 #define IN6_IS_ADDR_LINKLOCAL(a) \
301 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
302 #define IN6_IS_ADDR_SITELOCAL(a) \
303 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
308 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
310 #ifdef KERNEL /*XXX nonstandard*/
311 #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
313 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
319 #ifdef KERNEL /*refers nonstandard items */
320 #define IN6_IS_ADDR_MC_NODELOCAL(a) \
321 (IN6_IS_ADDR_MULTICAST(a) && \
322 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
323 #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
324 (IN6_IS_ADDR_MULTICAST(a) && \
325 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
326 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
327 (IN6_IS_ADDR_MULTICAST(a) && \
328 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
329 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
330 (IN6_IS_ADDR_MULTICAST(a) && \
331 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
332 #define IN6_IS_ADDR_MC_GLOBAL(a) \
333 (IN6_IS_ADDR_MULTICAST(a) && \
334 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
336 #define IN6_IS_ADDR_MC_NODELOCAL(a) \
337 (IN6_IS_ADDR_MULTICAST(a) && \
338 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
339 #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
340 (IN6_IS_ADDR_MULTICAST(a) && \
341 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
342 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
343 (IN6_IS_ADDR_MULTICAST(a) && \
344 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
345 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
346 (IN6_IS_ADDR_MULTICAST(a) && \
347 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
348 #define IN6_IS_ADDR_MC_GLOBAL(a) \
349 (IN6_IS_ADDR_MULTICAST(a) && \
350 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
356 #if 0 /*pre-RFC2553*/
357 #define IN6_IS_ADDR_ANY(a) IN6_IS_ADDR_UNSPECIFIED(a)
363 #ifdef KERNEL /*nonstandard*/
364 #define IN6_IS_SCOPE_LINKLOCAL(a) \
365 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
366 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
370 * IP6 route structure
372 #if !defined(_XOPEN_SOURCE)
374 struct rtentry
*ro_rt
;
375 struct sockaddr_in6 ro_dst
;
380 * Options for use with [gs]etsockopt at the IPV6 level.
381 * First word of comment is data type; bool is stored in int.
384 #if 0 /* the followings are relic in IPv4 and hence are disabled */
385 #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */
386 #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */
387 #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */
388 #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */
389 #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */
391 #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
392 #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
393 #define IPV6_MULTICAST_IF 9 /* u_char; set/get IP6 multicast i/f */
394 #define IPV6_MULTICAST_HOPS 10 /* u_char; set/get IP6 multicast hops */
395 #define IPV6_MULTICAST_LOOP 11 /* u_char; set/get IP6 multicast loopback */
396 #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
397 #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
398 #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
399 #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
400 #define IPV6_PKTINFO 19 /* in6_pktinfo; send if, src addr */
401 #define IPV6_HOPLIMIT 20 /* int; send hop limit */
402 #define IPV6_NEXTHOP 21 /* sockaddr; next hop addr */
403 #define IPV6_HOPOPTS 22 /* ip6_hbh; send hop-by-hop option */
404 #define IPV6_DSTOPTS 23 /* ip6_dest; send dst option befor rthdr */
405 #define IPV6_RTHDR 24 /* ip6_rthdr; send routing header */
406 #define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */
407 /* obsoleted by 2292bis */
408 #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
409 #define IPV6_BINDV6ONLY 27 /* bool; only bind INET6 at null bind */
412 #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */
414 #define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */
416 #if 1 /*IPV6FIREWALL*/
417 #define IPV6_FW_ADD 30 /* add a firewall rule to chain */
418 #define IPV6_FW_DEL 31 /* delete a firewall rule from chain */
419 #define IPV6_FW_FLUSH 32 /* flush firewall rule chain */
420 #define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */
421 #define IPV6_FW_GET 34 /* get entire firewall rule chain */
424 /* new socket options introduced in RFC2292bis */
425 #define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */
427 #define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */
428 #define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */
429 #define IPV6_RECVRTHDR 38 /* bool; recv routing header */
430 #define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */
431 #define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */
432 #define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */
434 #define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */
435 #define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */
437 /* the followings are used as cmsg type only */
438 #define IPV6_PATHMTU 44 /* 4 bytes int; MTU notification */
439 #define IPV6_REACHCONF 45 /* no data; ND reachability confirm */
441 #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */
442 #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */
443 #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */
446 * Defaults and limits for options
448 #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
449 #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
452 * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
455 struct in6_addr ipv6mr_multiaddr
;
456 u_int ipv6mr_interface
;
460 * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
463 struct in6_addr ipi6_addr
; /* src/dst IPv6 address */
464 u_int ipi6_ifindex
; /* send/recv interface index */
468 * Argument for IPV6_PORTRANGE:
469 * - which range to search when port is unspecified at bind() or connect()
471 #define IPV6_PORTRANGE_DEFAULT 0 /* default range */
472 #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
473 #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
475 #if !defined(_XOPEN_SOURCE)
477 * Definitions for inet6 sysctl operations.
479 * Third level is protocol number.
480 * Fourth level is desired variable within that protocol.
482 #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */
484 #define CTL_IPV6PROTO_NAMES { \
485 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
487 { "tcp6", CTLTYPE_NODE }, \
491 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
494 { "udp6", CTLTYPE_NODE }, \
497 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
498 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
499 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
500 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
502 { "ip6", CTLTYPE_NODE }, \
506 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
508 { "ipsec6", CTLTYPE_NODE }, \
515 { "icmp6", CTLTYPE_NODE }, \
517 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
518 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
519 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
520 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
521 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
522 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
523 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
524 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
528 { "pim6", CTLTYPE_NODE }, \
532 * Names for IP sysctl objects
534 #define IPV6CTL_FORWARDING 1 /* act as router */
535 #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/
536 #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
538 #define IPV6CTL_DEFMTU 4 /* default MTU */
540 #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
541 #define IPV6CTL_STATS 6 /* stats */
542 #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
543 #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
544 #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
545 #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
546 #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
547 #define IPV6CTL_ACCEPT_RTADV 12
548 #define IPV6CTL_KEEPFAITH 13
549 #define IPV6CTL_LOG_INTERVAL 14
550 #define IPV6CTL_HDRNESTLIMIT 15
551 #define IPV6CTL_DAD_COUNT 16
552 #define IPV6CTL_AUTO_FLOWLABEL 17
553 #define IPV6CTL_DEFMCASTHLIM 18
554 #define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */
555 #define IPV6CTL_KAME_VERSION 20
556 #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */
557 #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */
558 #if MAPPED_ADDR_ENABLED
559 #define IPV6CTL_MAPPED_ADDR 23
560 #endif /* MAPPED_ADDR_ENABLED */
561 /* New entries should be added here from current IPV6CTL_MAXID value. */
562 #define IPV6CTL_MAXID 24
564 #if MAPPED_ADDR_ENABLED
565 #define IPV6CTL_NAMES_MAPPED_ADDR "mapped_addr"
566 #define IPV6CTL_TYPE_MAPPED_ADDR CTLTYPE_INT
567 #define IPV6CTL_VARS_MAPPED_ADDR &ip6_mapped_addr_on
568 #else /* MAPPED_ADDR_ENABLED */
569 #define IPV6CTL_NAMES_MAPPED_ADDR 0
570 #define IPV6CTL_TYPE_MAPPED_ADDR 0
571 #define IPV6CTL_VARS_MAPPED_ADDR 0
572 #endif /* MAPPED_ADDR_ENABLED */
574 #if IPV6CTL_BINDV6ONLY
575 #define IPV6CTL_NAMES_BINDV6ONLY "bindv6only"
576 #define IPV6CTL_TYPE_BINDV6ONLY CTLTYPE_INT
577 #define IPV6CTL_VARS_BINDV6ONLY &ip6_bindv6only
579 #define IPV6CTL_NAMES_BINDV6ONLY 0
580 #define IPV6CTL_TYPE_BINDV6ONLY 0
581 #define IPV6CTL_VARS_BINDV6ONLY 0
584 #define IPV6CTL_NAMES { \
586 { "forwarding", CTLTYPE_INT }, \
587 { "redirect", CTLTYPE_INT }, \
588 { "hlim", CTLTYPE_INT }, \
589 { "mtu", CTLTYPE_INT }, \
590 { "forwsrcrt", CTLTYPE_INT }, \
593 { "mrtproto", CTLTYPE_INT }, \
594 { "maxfragpackets", CTLTYPE_INT }, \
595 { "sourcecheck", CTLTYPE_INT }, \
596 { "sourcecheck_logint", CTLTYPE_INT }, \
597 { "accept_rtadv", CTLTYPE_INT }, \
598 { "keepfaith", CTLTYPE_INT }, \
599 { "log_interval", CTLTYPE_INT }, \
600 { "hdrnestlimit", CTLTYPE_INT }, \
601 { "dad_count", CTLTYPE_INT }, \
602 { "auto_flowlabel", CTLTYPE_INT }, \
603 { "defmcasthlim", CTLTYPE_INT }, \
604 { "gifhlim", CTLTYPE_INT }, \
605 { "kame_version", CTLTYPE_STRING }, \
606 { "use_deprecated", CTLTYPE_INT }, \
607 { "rr_prune", CTLTYPE_INT }, \
608 { IPV6CTL_NAMES_MAPPED_ADDR, IPV6CTL_TYPE_MAPPED_ADDR }, \
609 { IPV6CTL_NAMES_BINDV6ONLY, IPV6CTL_TYPE_BINDV6ONLY }, \
613 #define IPV6CTL_VARS { \
616 &ip6_sendredirects, \
619 &ip6_forward_srcrt, \
623 &ip6_maxfragpackets, \
625 &ip6_sourcecheck_interval, \
631 &ip6_auto_flowlabel, \
635 &ip6_use_deprecated, \
637 IPV6CTL_VARS_MAPPED_ADDR, \
638 IPV6CTL_VARS_BINDV6ONLY, \
641 #endif /* !_XOPEN_SOURCE */
646 int in6_cksum
__P((struct mbuf
*, u_int8_t
, u_int32_t
, u_int32_t
));
647 int in6_localaddr
__P((struct in6_addr
*));
648 int in6_addrscope
__P((struct in6_addr
*));
649 struct in6_ifaddr
*in6_ifawithscope
__P((struct ifnet
*, struct in6_addr
*));
650 struct in6_ifaddr
*in6_ifawithifp
__P((struct ifnet
*, struct in6_addr
*));
651 extern void in6_if_up
__P((struct ifnet
*));
652 #if MAPPED_ADDR_ENABLED
655 void in6_sin6_2_sin
__P((struct sockaddr_in
*sin
,
656 struct sockaddr_in6
*sin6
));
657 void in6_sin_2_v4mapsin6
__P((struct sockaddr_in
*sin
,
658 struct sockaddr_in6
*sin6
));
659 void in6_sin6_2_sin_in_sock
__P((struct sockaddr
*nam
));
660 void in6_sin_2_v4mapsin6_in_sock
__P((struct sockaddr
**nam
));
661 #endif /* MAPPED_ADDR_ENABLED */
663 #define satosin6(sa) ((struct sockaddr_in6 *)(sa))
664 #define sin6tosa(sin6) ((struct sockaddr *)(sin6))
665 #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
671 extern int inet6_option_space
__P((int));
672 extern int inet6_option_init
__P((void *, struct cmsghdr
**, int));
673 extern int inet6_option_append
__P((struct cmsghdr
*, const u_int8_t
*,
675 extern u_int8_t
*inet6_option_alloc
__P((struct cmsghdr
*, int, int, int));
676 extern int inet6_option_next
__P((const struct cmsghdr
*, u_int8_t
**));
677 extern int inet6_option_find
__P((const struct cmsghdr
*, u_int8_t
**, int));
679 extern size_t inet6_rthdr_space
__P((int, int));
680 extern struct cmsghdr
*inet6_rthdr_init
__P((void *, int));
681 extern int inet6_rthdr_add
__P((struct cmsghdr
*, const struct in6_addr
*,
683 extern int inet6_rthdr_lasthop
__P((struct cmsghdr
*, unsigned int));
684 #if 0 /* not implemented yet */
685 extern int inet6_rthdr_reverse
__P((const struct cmsghdr
*, struct cmsghdr
*));
687 extern int inet6_rthdr_segments
__P((const struct cmsghdr
*));
688 extern struct in6_addr
*inet6_rthdr_getaddr
__P((struct cmsghdr
*, int));
689 extern int inet6_rthdr_getflags
__P((const struct cmsghdr
*, int));
691 extern int inet6_opt_init
__P((void *, size_t));
692 extern int inet6_opt_append
__P((void *, size_t, int, u_int8_t
,
693 size_t, u_int8_t
, void **));
694 extern int inet6_opt_finish
__P((void *, size_t, int));
695 extern int inet6_opt_set_val
__P((void *, size_t, void *, int));
697 extern int inet6_opt_next
__P((void *, size_t, int, u_int8_t
*,
699 extern int inet6_opt_find
__P((void *, size_t, int, u_int8_t
,
701 extern int inet6_opt_get_val
__P((void *, size_t, void *, int));
702 extern size_t inet6_rth_space
__P((int, int));
703 extern void *inet6_rth_init
__P((void *, int, int, int));
704 extern int inet6_rth_add
__P((void *, const struct in6_addr
*));
705 extern int inet6_rth_reverse
__P((const void *, void *));
706 extern int inet6_rth_segments
__P((const void *));
707 extern struct in6_addr
*inet6_rth_getaddr
__P((const void *, int));
710 #endif /* !_NETINET6_IN6_H_ */