os/ossrv/genericopenlibs/openenvcore/include/netinet6/in6.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/netinet6/in6.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,653 @@
     1.4 +/*	$FreeBSD: src/sys/netinet6/in6.h,v 1.36.2.2 2005/10/09 05:21:18 ume Exp $	*/
     1.5 +/*	$KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $	*/
     1.6 +
     1.7 +/*-
     1.8 + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
     1.9 + * All rights reserved.
    1.10 + *
    1.11 + * Redistribution and use in source and binary forms, with or without
    1.12 + * modification, are permitted provided that the following conditions
    1.13 + * are met:
    1.14 + * 1. Redistributions of source code must retain the above copyright
    1.15 + *    notice, this list of conditions and the following disclaimer.
    1.16 + * 2. Redistributions in binary form must reproduce the above copyright
    1.17 + *    notice, this list of conditions and the following disclaimer in the
    1.18 + *    documentation and/or other materials provided with the distribution.
    1.19 + * 3. Neither the name of the project nor the names of its contributors
    1.20 + *    may be used to endorse or promote products derived from this software
    1.21 + *    without specific prior written permission.
    1.22 + *
    1.23 + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
    1.24 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.25 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.26 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
    1.27 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.28 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.29 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.30 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.31 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.32 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.33 + * SUCH DAMAGE.
    1.34 + */
    1.35 +
    1.36 +/*-
    1.37 + * Copyright (c) 1982, 1986, 1990, 1993
    1.38 + *	The Regents of the University of California.  All rights reserved.
    1.39 + *
    1.40 + * Redistribution and use in source and binary forms, with or without
    1.41 + * modification, are permitted provided that the following conditions
    1.42 + * are met:
    1.43 + * 1. Redistributions of source code must retain the above copyright
    1.44 + *    notice, this list of conditions and the following disclaimer.
    1.45 + * 2. Redistributions in binary form must reproduce the above copyright
    1.46 + *    notice, this list of conditions and the following disclaimer in the
    1.47 + *    documentation and/or other materials provided with the distribution.
    1.48 + * 4. Neither the name of the University nor the names of its contributors
    1.49 + *    may be used to endorse or promote products derived from this software
    1.50 + *    without specific prior written permission.
    1.51 + *
    1.52 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    1.53 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.54 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.55 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    1.56 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.57 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.58 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.59 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.60 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.61 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.62 + * SUCH DAMAGE.
    1.63 +* Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).  All rights reserved.
    1.64 + *	@(#)in.h	8.3 (Berkeley) 1/3/94
    1.65 + */
    1.66 +
    1.67 +#ifndef __KAME_NETINET_IN_H_INCLUDED_
    1.68 +#error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
    1.69 +#endif
    1.70 +
    1.71 +#ifndef _NETINET6_IN6_H_
    1.72 +#define _NETINET6_IN6_H_
    1.73 +
    1.74 +/*
    1.75 + * Identification of the network protocol stack
    1.76 + * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
    1.77 + * has the table of implementation/integration differences.
    1.78 + */
    1.79 +#define __KAME__
    1.80 +#define __KAME_VERSION		"20010528/FreeBSD"
    1.81 +
    1.82 +/*
    1.83 + * Local port number conventions:
    1.84 + *
    1.85 + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
    1.86 + * unless a kernel is compiled with IPNOPRIVPORTS defined.
    1.87 + *
    1.88 + * When a user does a bind(2) or connect(2) with a port number of zero,
    1.89 + * a non-conflicting local port address is chosen.
    1.90 + *
    1.91 + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
    1.92 + * that is settable by sysctl(3); net.inet.ip.anonportmin and
    1.93 + * net.inet.ip.anonportmax respectively.
    1.94 + *
    1.95 + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
    1.96 + * default assignment range.
    1.97 + *
    1.98 + * The value IP_PORTRANGE_DEFAULT causes the default behavior.
    1.99 + *
   1.100 + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
   1.101 + * and exists only for FreeBSD compatibility purposes.
   1.102 + *
   1.103 + * The value IP_PORTRANGE_LOW changes the range to the "low" are
   1.104 + * that is (by convention) restricted to privileged processes.
   1.105 + * This convention is based on "vouchsafe" principles only.
   1.106 + * It is only secure if you trust the remote host to restrict these ports.
   1.107 + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
   1.108 + */
   1.109 +#if __BSD_VISIBLE
   1.110 +#define	IPV6PORT_RESERVED	1024
   1.111 +#define	IPV6PORT_ANONMIN	49152
   1.112 +#define	IPV6PORT_ANONMAX	65535
   1.113 +#define	IPV6PORT_RESERVEDMIN	600
   1.114 +#define	IPV6PORT_RESERVEDMAX	(IPV6PORT_RESERVED-1)
   1.115 +#endif
   1.116 +
   1.117 +/*
   1.118 + * IPv6 address
   1.119 + */
   1.120 +struct in6_addr {
   1.121 +	union {
   1.122 +		uint8_t		__u6_addr8[16];
   1.123 +		uint16_t	__u6_addr16[8];
   1.124 +		uint32_t	__u6_addr32[4];
   1.125 +	} __u6_addr;			/* 128-bit IP6 address */
   1.126 +};
   1.127 +
   1.128 +#define s6_addr   __u6_addr.__u6_addr8
   1.129 +#ifdef _KERNEL	/* XXX nonstandard */
   1.130 +#define s6_addr8  __u6_addr.__u6_addr8
   1.131 +#define s6_addr16 __u6_addr.__u6_addr16
   1.132 +#define s6_addr32 __u6_addr.__u6_addr32
   1.133 +#endif
   1.134 +
   1.135 +#define INET6_ADDRSTRLEN	46
   1.136 +
   1.137 +/*
   1.138 + * XXX missing POSIX.1-2001 macro IPPROTO_IPV6.
   1.139 + */
   1.140 +
   1.141 +/*
   1.142 + * Socket address for IPv6
   1.143 + */
   1.144 +#if __BSD_VISIBLE
   1.145 +#define SIN6_LEN
   1.146 +#endif
   1.147 +#ifdef __SYMBIAN32__
   1.148 +struct sockaddr_in6 {
   1.149 +	u_short 	sin6_family;	/* AF_INET6 */
   1.150 +	u_short 	sin6_port;	/* Transport layer port # */
   1.151 +	struct in6_addr	sin6_addr;	/* IP6 address */
   1.152 +	uint32_t	sin6_flowinfo;	/* IP6 flow information */
   1.153 +	uint32_t	sin6_scope_id;	/* scope zone index */
   1.154 +	uint8_t		sin6_len;	/* length of this struct */
   1.155 +};
   1.156 +#else
   1.157 +struct sockaddr_in6 {
   1.158 +	uint8_t		sin6_len;	/* length of this struct */
   1.159 +	sa_family_t	sin6_family;	/* AF_INET6 */
   1.160 +	in_port_t	sin6_port;	/* Transport layer port # */
   1.161 +	uint32_t	sin6_flowinfo;	/* IP6 flow information */
   1.162 +	struct in6_addr	sin6_addr;	/* IP6 address */
   1.163 +	uint32_t	sin6_scope_id;	/* scope zone index */
   1.164 +};
   1.165 +#endif
   1.166 +
   1.167 +/*
   1.168 + * Local definition for masks
   1.169 + */
   1.170 +#ifdef _KERNEL	/* XXX nonstandard */
   1.171 +#define IN6MASK0	{{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
   1.172 +#define IN6MASK32	{{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
   1.173 +			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
   1.174 +#define IN6MASK64	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
   1.175 +			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
   1.176 +#define IN6MASK96	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
   1.177 +			    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
   1.178 +#define IN6MASK128	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
   1.179 +			    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
   1.180 +#endif
   1.181 +
   1.182 +#ifdef _KERNEL
   1.183 +extern const struct sockaddr_in6 sa6_any;
   1.184 +
   1.185 +extern const struct in6_addr in6mask0;
   1.186 +extern const struct in6_addr in6mask32;
   1.187 +extern const struct in6_addr in6mask64;
   1.188 +extern const struct in6_addr in6mask96;
   1.189 +extern const struct in6_addr in6mask128;
   1.190 +#endif /* _KERNEL */
   1.191 +
   1.192 +/*
   1.193 + * Macros started with IPV6_ADDR is KAME local
   1.194 + */
   1.195 +#ifdef _KERNEL	/* XXX nonstandard */
   1.196 +#if _BYTE_ORDER == _BIG_ENDIAN
   1.197 +#define IPV6_ADDR_INT32_ONE	1
   1.198 +#define IPV6_ADDR_INT32_TWO	2
   1.199 +#define IPV6_ADDR_INT32_MNL	0xff010000
   1.200 +#define IPV6_ADDR_INT32_MLL	0xff020000
   1.201 +#define IPV6_ADDR_INT32_SMP	0x0000ffff
   1.202 +#define IPV6_ADDR_INT16_ULL	0xfe80
   1.203 +#define IPV6_ADDR_INT16_USL	0xfec0
   1.204 +#define IPV6_ADDR_INT16_MLL	0xff02
   1.205 +#elif _BYTE_ORDER == _LITTLE_ENDIAN
   1.206 +#define IPV6_ADDR_INT32_ONE	0x01000000
   1.207 +#define IPV6_ADDR_INT32_TWO	0x02000000
   1.208 +#define IPV6_ADDR_INT32_MNL	0x000001ff
   1.209 +#define IPV6_ADDR_INT32_MLL	0x000002ff
   1.210 +#define IPV6_ADDR_INT32_SMP	0xffff0000
   1.211 +#define IPV6_ADDR_INT16_ULL	0x80fe
   1.212 +#define IPV6_ADDR_INT16_USL	0xc0fe
   1.213 +#define IPV6_ADDR_INT16_MLL	0x02ff
   1.214 +#endif
   1.215 +#endif
   1.216 +
   1.217 +/*
   1.218 + * Definition of some useful macros to handle IP6 addresses
   1.219 + */
   1.220 +#if __BSD_VISIBLE
   1.221 +#define IN6ADDR_ANY_INIT \
   1.222 +	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.223 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
   1.224 +#define IN6ADDR_LOOPBACK_INIT \
   1.225 +	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.226 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
   1.227 +#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
   1.228 +	{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.229 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
   1.230 +#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
   1.231 +	{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.232 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
   1.233 +#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
   1.234 +	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.235 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
   1.236 +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
   1.237 +	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
   1.238 +	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
   1.239 +#endif
   1.240 +
   1.241 +#ifndef __SYMBIAN32__
   1.242 +extern const struct in6_addr in6addr_any;
   1.243 +extern const struct in6_addr in6addr_loopback;
   1.244 +#if __BSD_VISIBLE
   1.245 +extern const struct in6_addr in6addr_nodelocal_allnodes;
   1.246 +extern const struct in6_addr in6addr_linklocal_allnodes;
   1.247 +extern const struct in6_addr in6addr_linklocal_allrouters;
   1.248 +#endif
   1.249 +#endif//__SYMBIAN32__
   1.250 +
   1.251 +/*
   1.252 + * Equality
   1.253 + * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
   1.254 + * does not supply memcmp().  For userland memcmp() is preferred as it is
   1.255 + * in ANSI standard.
   1.256 + */
   1.257 +#ifdef _KERNEL
   1.258 +#define IN6_ARE_ADDR_EQUAL(a, b)			\
   1.259 +    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
   1.260 +#else
   1.261 +#if __BSD_VISIBLE
   1.262 +#define IN6_ARE_ADDR_EQUAL(a, b)			\
   1.263 +    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
   1.264 +#endif
   1.265 +#endif
   1.266 +
   1.267 +#ifdef _KERNEL			/* non standard */
   1.268 +/* see if two addresses are equal in a scope-conscious manner. */
   1.269 +#define SA6_ARE_ADDR_EQUAL(a, b) \
   1.270 +	(((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \
   1.271 +	  ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \
   1.272 +	 (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0))
   1.273 +#endif
   1.274 +
   1.275 +/*
   1.276 + * Unspecified
   1.277 + */
   1.278 +#define IN6_IS_ADDR_UNSPECIFIED(a)	\
   1.279 +	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
   1.280 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
   1.281 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
   1.282 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
   1.283 +
   1.284 +/*
   1.285 + * Loopback
   1.286 + */
   1.287 +#define IN6_IS_ADDR_LOOPBACK(a)		\
   1.288 +	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
   1.289 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
   1.290 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
   1.291 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
   1.292 +
   1.293 +/*
   1.294 + * IPv4 compatible
   1.295 + */
   1.296 +#define IN6_IS_ADDR_V4COMPAT(a)		\
   1.297 +	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
   1.298 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
   1.299 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
   1.300 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) &&	\
   1.301 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
   1.302 +
   1.303 +/*
   1.304 + * Mapped
   1.305 + */
   1.306 +#define IN6_IS_ADDR_V4MAPPED(a)		      \
   1.307 +	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
   1.308 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
   1.309 +	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
   1.310 +
   1.311 +/*
   1.312 + * KAME Scope Values
   1.313 + */
   1.314 +
   1.315 +#ifdef _KERNEL	/* XXX nonstandard */
   1.316 +#define IPV6_ADDR_SCOPE_NODELOCAL	0x01
   1.317 +#define IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
   1.318 +#define IPV6_ADDR_SCOPE_LINKLOCAL	0x02
   1.319 +#define IPV6_ADDR_SCOPE_SITELOCAL	0x05
   1.320 +#define IPV6_ADDR_SCOPE_ORGLOCAL	0x08	/* just used in this file */
   1.321 +#define IPV6_ADDR_SCOPE_GLOBAL		0x0e
   1.322 +#else
   1.323 +#define __IPV6_ADDR_SCOPE_NODELOCAL	0x01
   1.324 +#define __IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
   1.325 +#define __IPV6_ADDR_SCOPE_LINKLOCAL	0x02
   1.326 +#define __IPV6_ADDR_SCOPE_SITELOCAL	0x05
   1.327 +#define __IPV6_ADDR_SCOPE_ORGLOCAL	0x08	/* just used in this file */
   1.328 +#define __IPV6_ADDR_SCOPE_GLOBAL	0x0e
   1.329 +#endif
   1.330 +
   1.331 +/*
   1.332 + * Unicast Scope
   1.333 + * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
   1.334 + */
   1.335 +#define IN6_IS_ADDR_LINKLOCAL(a)	\
   1.336 +	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
   1.337 +#define IN6_IS_ADDR_SITELOCAL(a)	\
   1.338 +	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
   1.339 +
   1.340 +/*
   1.341 + * Multicast
   1.342 + */
   1.343 +#define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr[0] == 0xff)
   1.344 +
   1.345 +#ifdef _KERNEL	/* XXX nonstandard */
   1.346 +#define IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
   1.347 +#else
   1.348 +#define __IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
   1.349 +#endif
   1.350 +
   1.351 +/*
   1.352 + * Multicast Scope
   1.353 + */
   1.354 +#ifdef _KERNEL	/* refers nonstandard items */
   1.355 +#define IN6_IS_ADDR_MC_NODELOCAL(a)	\
   1.356 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.357 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
   1.358 +#define IN6_IS_ADDR_MC_INTFACELOCAL(a)	\
   1.359 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.360 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
   1.361 +#define IN6_IS_ADDR_MC_LINKLOCAL(a)	\
   1.362 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.363 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
   1.364 +#define IN6_IS_ADDR_MC_SITELOCAL(a)	\
   1.365 +	(IN6_IS_ADDR_MULTICAST(a) && 	\
   1.366 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
   1.367 +#define IN6_IS_ADDR_MC_ORGLOCAL(a)	\
   1.368 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.369 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
   1.370 +#define IN6_IS_ADDR_MC_GLOBAL(a)	\
   1.371 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.372 +	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
   1.373 +#else
   1.374 +#define IN6_IS_ADDR_MC_NODELOCAL(a)	\
   1.375 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.376 +	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
   1.377 +#define IN6_IS_ADDR_MC_LINKLOCAL(a)	\
   1.378 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.379 +	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
   1.380 +#define IN6_IS_ADDR_MC_SITELOCAL(a)	\
   1.381 +	(IN6_IS_ADDR_MULTICAST(a) && 	\
   1.382 +	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
   1.383 +#define IN6_IS_ADDR_MC_ORGLOCAL(a)	\
   1.384 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.385 +	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
   1.386 +#define IN6_IS_ADDR_MC_GLOBAL(a)	\
   1.387 +	(IN6_IS_ADDR_MULTICAST(a) &&	\
   1.388 +	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
   1.389 +#endif
   1.390 +
   1.391 +#ifdef _KERNEL	/* nonstandard */
   1.392 +/*
   1.393 + * KAME Scope
   1.394 + */
   1.395 +#define IN6_IS_SCOPE_LINKLOCAL(a)	\
   1.396 +	((IN6_IS_ADDR_LINKLOCAL(a)) ||	\
   1.397 +	 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
   1.398 +
   1.399 +#define IFA6_IS_DEPRECATED(a) \
   1.400 +	((a)->ia6_lifetime.ia6t_preferred != 0 && \
   1.401 +	 (a)->ia6_lifetime.ia6t_preferred < time_second)
   1.402 +#define IFA6_IS_INVALID(a) \
   1.403 +	((a)->ia6_lifetime.ia6t_expire != 0 && \
   1.404 +	 (a)->ia6_lifetime.ia6t_expire < time_second)
   1.405 +#endif /* _KERNEL */
   1.406 +
   1.407 +/*
   1.408 + * IP6 route structure
   1.409 + */
   1.410 +#if __BSD_VISIBLE
   1.411 +struct route_in6 {
   1.412 +	struct	rtentry *ro_rt;
   1.413 +	struct	sockaddr_in6 ro_dst;
   1.414 +};
   1.415 +#endif
   1.416 +
   1.417 +/*
   1.418 + * Options for use with [gs]etsockopt at the IPV6 level.
   1.419 + * First word of comment is data type; bool is stored in int.
   1.420 + */
   1.421 +/* no hdrincl */
   1.422 +#if 0 /* the followings are relic in IPv4 and hence are disabled */
   1.423 +#define IPV6_OPTIONS		1  /* buf/ip6_opts; set/get IP6 options */
   1.424 +#define IPV6_RECVOPTS		5  /* bool; receive all IP6 opts w/dgram */
   1.425 +#define IPV6_RECVRETOPTS	6  /* bool; receive IP6 opts for response */
   1.426 +#define IPV6_RECVDSTADDR	7  /* bool; receive IP6 dst addr w/dgram */
   1.427 +#define IPV6_RETOPTS		8  /* ip6_opts; set/get IP6 options */
   1.428 +#endif
   1.429 +#define IPV6_SOCKOPT_RESERVED1	3  /* reserved for future use */
   1.430 +#define IPV6_UNICAST_HOPS	4  /* int; IP6 hops */
   1.431 +#define IPV6_MULTICAST_IF	9  /* u_int; set/get IP6 multicast i/f  */
   1.432 +#define IPV6_MULTICAST_HOPS	10 /* int; set/get IP6 multicast hops */
   1.433 +#define IPV6_MULTICAST_LOOP	11 /* u_int; set/get IP6 multicast loopback */
   1.434 +#define IPV6_JOIN_GROUP		12 /* ip6_mreq; join a group membership */
   1.435 +#define IPV6_LEAVE_GROUP	13 /* ip6_mreq; leave a group membership */
   1.436 +#define IPV6_PORTRANGE		14 /* int; range to choose for unspec port */
   1.437 +#define ICMP6_FILTER		18 /* icmp6_filter; icmp6 filter */
   1.438 +/* RFC2292 options */
   1.439 +#ifdef _KERNEL
   1.440 +#define IPV6_2292PKTINFO	19 /* bool; send/recv if, src/dst addr */
   1.441 +#define IPV6_2292HOPLIMIT	20 /* bool; hop limit */
   1.442 +#define IPV6_2292NEXTHOP	21 /* bool; next hop addr */
   1.443 +#define IPV6_2292HOPOPTS	22 /* bool; hop-by-hop option */
   1.444 +#define IPV6_2292DSTOPTS	23 /* bool; destinaion option */
   1.445 +#define IPV6_2292RTHDR		24 /* bool; routing header */
   1.446 +#define IPV6_2292PKTOPTIONS	25 /* buf/cmsghdr; set/get IPv6 options */
   1.447 +#endif
   1.448 +
   1.449 +#define IPV6_CHECKSUM		26 /* int; checksum offset for raw socket */
   1.450 +#define IPV6_V6ONLY		27 /* bool; make AF_INET6 sockets v6 only */
   1.451 +#ifndef _KERNEL
   1.452 +#define IPV6_BINDV6ONLY		IPV6_V6ONLY
   1.453 +#endif
   1.454 +
   1.455 +#if 1 /* IPSEC */
   1.456 +#define IPV6_IPSEC_POLICY	28 /* struct; get/set security policy */
   1.457 +#endif
   1.458 +#define IPV6_FAITH		29 /* bool; accept FAITH'ed connections */
   1.459 +
   1.460 +#if 1 /* IPV6FIREWALL */
   1.461 +#define IPV6_FW_ADD		30 /* add a firewall rule to chain */
   1.462 +#define IPV6_FW_DEL		31 /* delete a firewall rule from chain */
   1.463 +#define IPV6_FW_FLUSH		32 /* flush firewall rule chain */
   1.464 +#define IPV6_FW_ZERO		33 /* clear single/all firewall counter(s) */
   1.465 +#define IPV6_FW_GET		34 /* get entire firewall rule chain */
   1.466 +#endif
   1.467 +
   1.468 +/* new socket options introduced in RFC3542 */
   1.469 +#define IPV6_RTHDRDSTOPTS	35 /* ip6_dest; send dst option before rthdr */
   1.470 +
   1.471 +#define IPV6_RECVPKTINFO	36 /* bool; recv if, dst addr */
   1.472 +#define IPV6_RECVHOPLIMIT	37 /* bool; recv hop limit */
   1.473 +#define IPV6_RECVRTHDR		38 /* bool; recv routing header */
   1.474 +#define IPV6_RECVHOPOPTS	39 /* bool; recv hop-by-hop option */
   1.475 +#define IPV6_RECVDSTOPTS	40 /* bool; recv dst option after rthdr */
   1.476 +#ifdef _KERNEL
   1.477 +#define IPV6_RECVRTHDRDSTOPTS	41 /* bool; recv dst option before rthdr */
   1.478 +#endif
   1.479 +
   1.480 +#define IPV6_USE_MIN_MTU	42 /* bool; send packets at the minimum MTU */
   1.481 +#define IPV6_RECVPATHMTU	43 /* bool; notify an according MTU */
   1.482 +
   1.483 +#define IPV6_PATHMTU		44 /* mtuinfo; get the current path MTU (sopt),
   1.484 +				      4 bytes int; MTU notification (cmsg) */
   1.485 +#if 0 /*obsoleted during 2292bis -> 3542*/
   1.486 +#define IPV6_REACHCONF		45 /* no data; ND reachability confirm
   1.487 +				      (cmsg only/not in of RFC3542) */
   1.488 +#endif
   1.489 +
   1.490 +/* more new socket options introduced in RFC3542 */
   1.491 +#define IPV6_PKTINFO		46 /* in6_pktinfo; send if, src addr */
   1.492 +#define IPV6_HOPLIMIT		47 /* int; send hop limit */
   1.493 +#define IPV6_NEXTHOP		48 /* sockaddr; next hop addr */
   1.494 +#define IPV6_HOPOPTS		49 /* ip6_hbh; send hop-by-hop option */
   1.495 +#define IPV6_DSTOPTS		50 /* ip6_dest; send dst option befor rthdr */
   1.496 +#define IPV6_RTHDR		51 /* ip6_rthdr; send routing header */
   1.497 +#if 0
   1.498 +#define IPV6_PKTOPTIONS		52 /* buf/cmsghdr; set/get IPv6 options */
   1.499 +				   /* obsoleted by RFC3542 */
   1.500 +#endif
   1.501 +
   1.502 +#define IPV6_RECVTCLASS		57 /* bool; recv traffic class values */
   1.503 +
   1.504 +#define IPV6_AUTOFLOWLABEL	59 /* bool; attach flowlabel automagically */
   1.505 +
   1.506 +#define IPV6_TCLASS		61 /* int; send traffic class value */
   1.507 +#define IPV6_DONTFRAG		62 /* bool; disable IPv6 fragmentation */
   1.508 +
   1.509 +#define IPV6_PREFER_TEMPADDR	63 /* int; prefer temporary addresses as
   1.510 +				    * the source address.
   1.511 +				    */
   1.512 +
   1.513 +/* to define items, should talk with KAME guys first, for *BSD compatibility */
   1.514 +
   1.515 +#define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
   1.516 +#define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
   1.517 +#define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
   1.518 +
   1.519 +/*
   1.520 + * Defaults and limits for options
   1.521 + */
   1.522 +#define IPV6_DEFAULT_MULTICAST_HOPS 1	/* normally limit m'casts to 1 hop */
   1.523 +#define IPV6_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member */
   1.524 +
   1.525 +/*
   1.526 + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
   1.527 + */
   1.528 +struct ipv6_mreq {
   1.529 +	struct in6_addr	ipv6mr_multiaddr;
   1.530 +	unsigned int	ipv6mr_interface;
   1.531 +};
   1.532 +
   1.533 +/*
   1.534 + * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
   1.535 + */
   1.536 +struct in6_pktinfo {
   1.537 +	struct in6_addr	ipi6_addr;	/* src/dst IPv6 address */
   1.538 +	unsigned int	ipi6_ifindex;	/* send/recv interface index */
   1.539 +};
   1.540 +
   1.541 +/*
   1.542 + * Control structure for IPV6_RECVPATHMTU socket option.
   1.543 + */
   1.544 +struct ip6_mtuinfo {
   1.545 +	struct sockaddr_in6 ip6m_addr;	/* or sockaddr_storage? */
   1.546 +	uint32_t ip6m_mtu;
   1.547 +};
   1.548 +
   1.549 +/*
   1.550 + * Argument for IPV6_PORTRANGE:
   1.551 + * - which range to search when port is unspecified at bind() or connect()
   1.552 + */
   1.553 +#define	IPV6_PORTRANGE_DEFAULT	0	/* default range */
   1.554 +#define	IPV6_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
   1.555 +#define	IPV6_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
   1.556 +
   1.557 +#if __BSD_VISIBLE
   1.558 +/*
   1.559 + * Definitions for inet6 sysctl operations.
   1.560 + *
   1.561 + * Third level is protocol number.
   1.562 + * Fourth level is desired variable within that protocol.
   1.563 + */
   1.564 +#define IPV6PROTO_MAXID	(IPPROTO_PIM + 1)	/* don't list to IPV6PROTO_MAX */
   1.565 +
   1.566 +/*
   1.567 + * Names for IP sysctl objects
   1.568 + */
   1.569 +#define IPV6CTL_FORWARDING	1	/* act as router */
   1.570 +#define IPV6CTL_SENDREDIRECTS	2	/* may send redirects when forwarding*/
   1.571 +#define IPV6CTL_DEFHLIM		3	/* default Hop-Limit */
   1.572 +#ifdef notyet
   1.573 +#define IPV6CTL_DEFMTU		4	/* default MTU */
   1.574 +#endif
   1.575 +#define IPV6CTL_FORWSRCRT	5	/* forward source-routed dgrams */
   1.576 +#define IPV6CTL_STATS		6	/* stats */
   1.577 +#define IPV6CTL_MRTSTATS	7	/* multicast forwarding stats */
   1.578 +#define IPV6CTL_MRTPROTO	8	/* multicast routing protocol */
   1.579 +#define IPV6CTL_MAXFRAGPACKETS	9	/* max packets reassembly queue */
   1.580 +#define IPV6CTL_SOURCECHECK	10	/* verify source route and intf */
   1.581 +#define IPV6CTL_SOURCECHECK_LOGINT 11	/* minimume logging interval */
   1.582 +#define IPV6CTL_ACCEPT_RTADV	12
   1.583 +#define IPV6CTL_KEEPFAITH	13
   1.584 +#define IPV6CTL_LOG_INTERVAL	14
   1.585 +#define IPV6CTL_HDRNESTLIMIT	15
   1.586 +#define IPV6CTL_DAD_COUNT	16
   1.587 +#define IPV6CTL_AUTO_FLOWLABEL	17
   1.588 +#define IPV6CTL_DEFMCASTHLIM	18
   1.589 +#define IPV6CTL_GIF_HLIM	19	/* default HLIM for gif encap packet */
   1.590 +#define IPV6CTL_KAME_VERSION	20
   1.591 +#define IPV6CTL_USE_DEPRECATED	21	/* use deprecated addr (RFC2462 5.5.4) */
   1.592 +#define IPV6CTL_RR_PRUNE	22	/* walk timer for router renumbering */
   1.593 +#if 0	/* obsolete */
   1.594 +#define IPV6CTL_MAPPED_ADDR	23
   1.595 +#endif
   1.596 +#define IPV6CTL_V6ONLY		24
   1.597 +#define IPV6CTL_RTEXPIRE	25	/* cloned route expiration time */
   1.598 +#define IPV6CTL_RTMINEXPIRE	26	/* min value for expiration time */
   1.599 +#define IPV6CTL_RTMAXCACHE	27	/* trigger level for dynamic expire */
   1.600 +
   1.601 +#define IPV6CTL_USETEMPADDR	32	/* use temporary addresses (RFC3041) */
   1.602 +#define IPV6CTL_TEMPPLTIME	33	/* preferred lifetime for tmpaddrs */
   1.603 +#define IPV6CTL_TEMPVLTIME	34	/* valid lifetime for tmpaddrs */
   1.604 +#define IPV6CTL_AUTO_LINKLOCAL	35	/* automatic link-local addr assign */
   1.605 +#define IPV6CTL_RIP6STATS	36	/* raw_ip6 stats */
   1.606 +#define IPV6CTL_PREFER_TEMPADDR	37	/* prefer temporary addr as src */
   1.607 +#define IPV6CTL_ADDRCTLPOLICY	38	/* get/set address selection policy */
   1.608 +
   1.609 +#define IPV6CTL_MAXFRAGS	41	/* max fragments */
   1.610 +
   1.611 +/* New entries should be added here from current IPV6CTL_MAXID value. */
   1.612 +/* to define items, should talk with KAME guys first, for *BSD compatibility */
   1.613 +/* 42-44 is already used in KAME */
   1.614 +#define IPV6CTL_STEALTH		45
   1.615 +#define IPV6CTL_MAXID		46
   1.616 +#endif /* __BSD_VISIBLE */
   1.617 +
   1.618 +/*
   1.619 + * Redefinition of mbuf flags
   1.620 + */
   1.621 +#define	M_AUTHIPHDR	M_PROTO2
   1.622 +#define	M_DECRYPTED	M_PROTO3
   1.623 +#define	M_LOOP		M_PROTO4
   1.624 +#define	M_AUTHIPDGM	M_PROTO5
   1.625 +
   1.626 +#ifdef _KERNEL
   1.627 +struct cmsghdr;
   1.628 +
   1.629 +struct sockaddr;
   1.630 +extern	u_char	ip6_protox[];
   1.631 +#define	satosin6(sa)	((struct sockaddr_in6 *)(sa))
   1.632 +#define	sin6tosa(sin6)	((struct sockaddr *)(sin6))
   1.633 +#define	ifatoia6(ifa)	((struct in6_ifaddr *)(ifa))
   1.634 +
   1.635 +extern int	(*faithprefix_p)(struct in6_addr *);
   1.636 +#endif /* _KERNEL */
   1.637 +
   1.638 +#ifndef _SIZE_T_DECLARED
   1.639 +typedef	__size_t	size_t;
   1.640 +#define	_SIZE_T_DECLARED
   1.641 +#endif
   1.642 +
   1.643 +#ifndef _SOCKLEN_T_DECLARED
   1.644 +typedef	__socklen_t	socklen_t;
   1.645 +#define	_SOCKLEN_T_DECLARED
   1.646 +#endif
   1.647 +
   1.648 +#if __BSD_VISIBLE
   1.649 +
   1.650 +__BEGIN_DECLS
   1.651 +struct cmsghdr;
   1.652 +__END_DECLS
   1.653 +
   1.654 +#endif /* __BSD_VISIBLE */
   1.655 +
   1.656 +#endif /* !_NETINET6_IN6_H_ */