sl@0: /* $FreeBSD: src/sys/netinet6/in6.h,v 1.36.2.2 2005/10/09 05:21:18 ume Exp $ */ sl@0: /* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ */ sl@0: sl@0: /*- sl@0: * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 3. Neither the name of the project nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: */ sl@0: sl@0: /*- sl@0: * Copyright (c) 1982, 1986, 1990, 1993 sl@0: * The Regents of the University of California. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of the University nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * @(#)in.h 8.3 (Berkeley) 1/3/94 sl@0: */ sl@0: sl@0: #ifndef __KAME_NETINET_IN_H_INCLUDED_ sl@0: #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" sl@0: #endif sl@0: sl@0: #ifndef _NETINET6_IN6_H_ sl@0: #define _NETINET6_IN6_H_ sl@0: sl@0: /* sl@0: * Identification of the network protocol stack sl@0: * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE sl@0: * has the table of implementation/integration differences. sl@0: */ sl@0: #define __KAME__ sl@0: #define __KAME_VERSION "20010528/FreeBSD" sl@0: sl@0: /* sl@0: * Local port number conventions: sl@0: * sl@0: * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), sl@0: * unless a kernel is compiled with IPNOPRIVPORTS defined. sl@0: * sl@0: * When a user does a bind(2) or connect(2) with a port number of zero, sl@0: * a non-conflicting local port address is chosen. sl@0: * sl@0: * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although sl@0: * that is settable by sysctl(3); net.inet.ip.anonportmin and sl@0: * net.inet.ip.anonportmax respectively. sl@0: * sl@0: * A user may set the IPPROTO_IP option IP_PORTRANGE to change this sl@0: * default assignment range. sl@0: * sl@0: * The value IP_PORTRANGE_DEFAULT causes the default behavior. sl@0: * sl@0: * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, sl@0: * and exists only for FreeBSD compatibility purposes. sl@0: * sl@0: * The value IP_PORTRANGE_LOW changes the range to the "low" are sl@0: * that is (by convention) restricted to privileged processes. sl@0: * This convention is based on "vouchsafe" principles only. sl@0: * It is only secure if you trust the remote host to restrict these ports. sl@0: * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #define IPV6PORT_RESERVED 1024 sl@0: #define IPV6PORT_ANONMIN 49152 sl@0: #define IPV6PORT_ANONMAX 65535 sl@0: #define IPV6PORT_RESERVEDMIN 600 sl@0: #define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) sl@0: #endif sl@0: sl@0: /* sl@0: * IPv6 address sl@0: */ sl@0: struct in6_addr { sl@0: union { sl@0: uint8_t __u6_addr8[16]; sl@0: uint16_t __u6_addr16[8]; sl@0: uint32_t __u6_addr32[4]; sl@0: } __u6_addr; /* 128-bit IP6 address */ sl@0: }; sl@0: sl@0: #define s6_addr __u6_addr.__u6_addr8 sl@0: #ifdef _KERNEL /* XXX nonstandard */ sl@0: #define s6_addr8 __u6_addr.__u6_addr8 sl@0: #define s6_addr16 __u6_addr.__u6_addr16 sl@0: #define s6_addr32 __u6_addr.__u6_addr32 sl@0: #endif sl@0: sl@0: #define INET6_ADDRSTRLEN 46 sl@0: sl@0: /* sl@0: * XXX missing POSIX.1-2001 macro IPPROTO_IPV6. sl@0: */ sl@0: sl@0: /* sl@0: * Socket address for IPv6 sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #define SIN6_LEN sl@0: #endif sl@0: #ifdef __SYMBIAN32__ sl@0: struct sockaddr_in6 { sl@0: u_short sin6_family; /* AF_INET6 */ sl@0: u_short sin6_port; /* Transport layer port # */ sl@0: struct in6_addr sin6_addr; /* IP6 address */ sl@0: uint32_t sin6_flowinfo; /* IP6 flow information */ sl@0: uint32_t sin6_scope_id; /* scope zone index */ sl@0: uint8_t sin6_len; /* length of this struct */ sl@0: }; sl@0: #else sl@0: struct sockaddr_in6 { sl@0: uint8_t sin6_len; /* length of this struct */ sl@0: sa_family_t sin6_family; /* AF_INET6 */ sl@0: in_port_t sin6_port; /* Transport layer port # */ sl@0: uint32_t sin6_flowinfo; /* IP6 flow information */ sl@0: struct in6_addr sin6_addr; /* IP6 address */ sl@0: uint32_t sin6_scope_id; /* scope zone index */ sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: * Local definition for masks sl@0: */ sl@0: #ifdef _KERNEL /* XXX nonstandard */ sl@0: #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} sl@0: #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} sl@0: #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} sl@0: #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ sl@0: 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} sl@0: #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ sl@0: 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} sl@0: #endif sl@0: sl@0: #ifdef _KERNEL sl@0: extern const struct sockaddr_in6 sa6_any; sl@0: sl@0: extern const struct in6_addr in6mask0; sl@0: extern const struct in6_addr in6mask32; sl@0: extern const struct in6_addr in6mask64; sl@0: extern const struct in6_addr in6mask96; sl@0: extern const struct in6_addr in6mask128; sl@0: #endif /* _KERNEL */ sl@0: sl@0: /* sl@0: * Macros started with IPV6_ADDR is KAME local sl@0: */ sl@0: #ifdef _KERNEL /* XXX nonstandard */ sl@0: #if _BYTE_ORDER == _BIG_ENDIAN sl@0: #define IPV6_ADDR_INT32_ONE 1 sl@0: #define IPV6_ADDR_INT32_TWO 2 sl@0: #define IPV6_ADDR_INT32_MNL 0xff010000 sl@0: #define IPV6_ADDR_INT32_MLL 0xff020000 sl@0: #define IPV6_ADDR_INT32_SMP 0x0000ffff sl@0: #define IPV6_ADDR_INT16_ULL 0xfe80 sl@0: #define IPV6_ADDR_INT16_USL 0xfec0 sl@0: #define IPV6_ADDR_INT16_MLL 0xff02 sl@0: #elif _BYTE_ORDER == _LITTLE_ENDIAN sl@0: #define IPV6_ADDR_INT32_ONE 0x01000000 sl@0: #define IPV6_ADDR_INT32_TWO 0x02000000 sl@0: #define IPV6_ADDR_INT32_MNL 0x000001ff sl@0: #define IPV6_ADDR_INT32_MLL 0x000002ff sl@0: #define IPV6_ADDR_INT32_SMP 0xffff0000 sl@0: #define IPV6_ADDR_INT16_ULL 0x80fe sl@0: #define IPV6_ADDR_INT16_USL 0xc0fe sl@0: #define IPV6_ADDR_INT16_MLL 0x02ff sl@0: #endif sl@0: #endif sl@0: sl@0: /* sl@0: * Definition of some useful macros to handle IP6 addresses sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #define IN6ADDR_ANY_INIT \ sl@0: {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} sl@0: #define IN6ADDR_LOOPBACK_INIT \ sl@0: {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} sl@0: #define IN6ADDR_NODELOCAL_ALLNODES_INIT \ sl@0: {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} sl@0: #define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \ sl@0: {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} sl@0: #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ sl@0: {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} sl@0: #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ sl@0: {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ sl@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} sl@0: #endif sl@0: sl@0: #ifndef __SYMBIAN32__ sl@0: extern const struct in6_addr in6addr_any; sl@0: extern const struct in6_addr in6addr_loopback; sl@0: #if __BSD_VISIBLE sl@0: extern const struct in6_addr in6addr_nodelocal_allnodes; sl@0: extern const struct in6_addr in6addr_linklocal_allnodes; sl@0: extern const struct in6_addr in6addr_linklocal_allrouters; sl@0: #endif sl@0: #endif//__SYMBIAN32__ sl@0: sl@0: /* sl@0: * Equality sl@0: * NOTE: Some of kernel programming environment (for example, openbsd/sparc) sl@0: * does not supply memcmp(). For userland memcmp() is preferred as it is sl@0: * in ANSI standard. sl@0: */ sl@0: #ifdef _KERNEL sl@0: #define IN6_ARE_ADDR_EQUAL(a, b) \ sl@0: (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) sl@0: #else sl@0: #if __BSD_VISIBLE sl@0: #define IN6_ARE_ADDR_EQUAL(a, b) \ sl@0: (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) sl@0: #endif sl@0: #endif sl@0: sl@0: #ifdef _KERNEL /* non standard */ sl@0: /* see if two addresses are equal in a scope-conscious manner. */ sl@0: #define SA6_ARE_ADDR_EQUAL(a, b) \ sl@0: (((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \ sl@0: ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \ sl@0: (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0)) sl@0: #endif sl@0: sl@0: /* sl@0: * Unspecified sl@0: */ sl@0: #define IN6_IS_ADDR_UNSPECIFIED(a) \ sl@0: ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0)) sl@0: sl@0: /* sl@0: * Loopback sl@0: */ sl@0: #define IN6_IS_ADDR_LOOPBACK(a) \ sl@0: ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1))) sl@0: sl@0: /* sl@0: * IPv4 compatible sl@0: */ sl@0: #define IN6_IS_ADDR_V4COMPAT(a) \ sl@0: ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1))) sl@0: sl@0: /* sl@0: * Mapped sl@0: */ sl@0: #define IN6_IS_ADDR_V4MAPPED(a) \ sl@0: ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ sl@0: (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) sl@0: sl@0: /* sl@0: * KAME Scope Values sl@0: */ sl@0: sl@0: #ifdef _KERNEL /* XXX nonstandard */ sl@0: #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 sl@0: #define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 sl@0: #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 sl@0: #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 sl@0: #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ sl@0: #define IPV6_ADDR_SCOPE_GLOBAL 0x0e sl@0: #else sl@0: #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 sl@0: #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 sl@0: #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 sl@0: #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 sl@0: #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ sl@0: #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e sl@0: #endif sl@0: sl@0: /* sl@0: * Unicast Scope sl@0: * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). sl@0: */ sl@0: #define IN6_IS_ADDR_LINKLOCAL(a) \ sl@0: (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) sl@0: #define IN6_IS_ADDR_SITELOCAL(a) \ sl@0: (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) sl@0: sl@0: /* sl@0: * Multicast sl@0: */ sl@0: #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) sl@0: sl@0: #ifdef _KERNEL /* XXX nonstandard */ sl@0: #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) sl@0: #else sl@0: #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) sl@0: #endif sl@0: sl@0: /* sl@0: * Multicast Scope sl@0: */ sl@0: #ifdef _KERNEL /* refers nonstandard items */ sl@0: #define IN6_IS_ADDR_MC_NODELOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL)) sl@0: #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL)) sl@0: #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL)) sl@0: #define IN6_IS_ADDR_MC_SITELOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL)) sl@0: #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL)) sl@0: #define IN6_IS_ADDR_MC_GLOBAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL)) sl@0: #else sl@0: #define IN6_IS_ADDR_MC_NODELOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) sl@0: #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) sl@0: #define IN6_IS_ADDR_MC_SITELOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) sl@0: #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) sl@0: #define IN6_IS_ADDR_MC_GLOBAL(a) \ sl@0: (IN6_IS_ADDR_MULTICAST(a) && \ sl@0: (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) sl@0: #endif sl@0: sl@0: #ifdef _KERNEL /* nonstandard */ sl@0: /* sl@0: * KAME Scope sl@0: */ sl@0: #define IN6_IS_SCOPE_LINKLOCAL(a) \ sl@0: ((IN6_IS_ADDR_LINKLOCAL(a)) || \ sl@0: (IN6_IS_ADDR_MC_LINKLOCAL(a))) sl@0: sl@0: #define IFA6_IS_DEPRECATED(a) \ sl@0: ((a)->ia6_lifetime.ia6t_preferred != 0 && \ sl@0: (a)->ia6_lifetime.ia6t_preferred < time_second) sl@0: #define IFA6_IS_INVALID(a) \ sl@0: ((a)->ia6_lifetime.ia6t_expire != 0 && \ sl@0: (a)->ia6_lifetime.ia6t_expire < time_second) sl@0: #endif /* _KERNEL */ sl@0: sl@0: /* sl@0: * IP6 route structure sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: struct route_in6 { sl@0: struct rtentry *ro_rt; sl@0: struct sockaddr_in6 ro_dst; sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: * Options for use with [gs]etsockopt at the IPV6 level. sl@0: * First word of comment is data type; bool is stored in int. sl@0: */ sl@0: /* no hdrincl */ sl@0: #if 0 /* the followings are relic in IPv4 and hence are disabled */ sl@0: #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ sl@0: #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ sl@0: #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ sl@0: #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ sl@0: #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ sl@0: #endif sl@0: #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ sl@0: #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ sl@0: #define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ sl@0: #define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ sl@0: #define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */ sl@0: #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ sl@0: #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ sl@0: #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ sl@0: #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ sl@0: /* RFC2292 options */ sl@0: #ifdef _KERNEL sl@0: #define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */ sl@0: #define IPV6_2292HOPLIMIT 20 /* bool; hop limit */ sl@0: #define IPV6_2292NEXTHOP 21 /* bool; next hop addr */ sl@0: #define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */ sl@0: #define IPV6_2292DSTOPTS 23 /* bool; destinaion option */ sl@0: #define IPV6_2292RTHDR 24 /* bool; routing header */ sl@0: #define IPV6_2292PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ sl@0: #endif sl@0: sl@0: #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ sl@0: #define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */ sl@0: #ifndef _KERNEL sl@0: #define IPV6_BINDV6ONLY IPV6_V6ONLY sl@0: #endif sl@0: sl@0: #if 1 /* IPSEC */ sl@0: #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ sl@0: #endif sl@0: #define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */ sl@0: sl@0: #if 1 /* IPV6FIREWALL */ sl@0: #define IPV6_FW_ADD 30 /* add a firewall rule to chain */ sl@0: #define IPV6_FW_DEL 31 /* delete a firewall rule from chain */ sl@0: #define IPV6_FW_FLUSH 32 /* flush firewall rule chain */ sl@0: #define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */ sl@0: #define IPV6_FW_GET 34 /* get entire firewall rule chain */ sl@0: #endif sl@0: sl@0: /* new socket options introduced in RFC3542 */ sl@0: #define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */ sl@0: sl@0: #define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */ sl@0: #define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */ sl@0: #define IPV6_RECVRTHDR 38 /* bool; recv routing header */ sl@0: #define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */ sl@0: #define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */ sl@0: #ifdef _KERNEL sl@0: #define IPV6_RECVRTHDRDSTOPTS 41 /* bool; recv dst option before rthdr */ sl@0: #endif sl@0: sl@0: #define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */ sl@0: #define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */ sl@0: sl@0: #define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt), sl@0: 4 bytes int; MTU notification (cmsg) */ sl@0: #if 0 /*obsoleted during 2292bis -> 3542*/ sl@0: #define IPV6_REACHCONF 45 /* no data; ND reachability confirm sl@0: (cmsg only/not in of RFC3542) */ sl@0: #endif sl@0: sl@0: /* more new socket options introduced in RFC3542 */ sl@0: #define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */ sl@0: #define IPV6_HOPLIMIT 47 /* int; send hop limit */ sl@0: #define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */ sl@0: #define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */ sl@0: #define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */ sl@0: #define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */ sl@0: #if 0 sl@0: #define IPV6_PKTOPTIONS 52 /* buf/cmsghdr; set/get IPv6 options */ sl@0: /* obsoleted by RFC3542 */ sl@0: #endif sl@0: sl@0: #define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */ sl@0: sl@0: #define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */ sl@0: sl@0: #define IPV6_TCLASS 61 /* int; send traffic class value */ sl@0: #define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */ sl@0: sl@0: #define IPV6_PREFER_TEMPADDR 63 /* int; prefer temporary addresses as sl@0: * the source address. sl@0: */ sl@0: sl@0: /* to define items, should talk with KAME guys first, for *BSD compatibility */ sl@0: sl@0: #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ sl@0: #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ sl@0: #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ sl@0: sl@0: /* sl@0: * Defaults and limits for options sl@0: */ sl@0: #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ sl@0: #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ sl@0: sl@0: /* sl@0: * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. sl@0: */ sl@0: struct ipv6_mreq { sl@0: struct in6_addr ipv6mr_multiaddr; sl@0: unsigned int ipv6mr_interface; sl@0: }; sl@0: sl@0: /* sl@0: * IPV6_PKTINFO: Packet information(RFC2292 sec 5) sl@0: */ sl@0: struct in6_pktinfo { sl@0: struct in6_addr ipi6_addr; /* src/dst IPv6 address */ sl@0: unsigned int ipi6_ifindex; /* send/recv interface index */ sl@0: }; sl@0: sl@0: /* sl@0: * Control structure for IPV6_RECVPATHMTU socket option. sl@0: */ sl@0: struct ip6_mtuinfo { sl@0: struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */ sl@0: uint32_t ip6m_mtu; sl@0: }; sl@0: sl@0: /* sl@0: * Argument for IPV6_PORTRANGE: sl@0: * - which range to search when port is unspecified at bind() or connect() sl@0: */ sl@0: #define IPV6_PORTRANGE_DEFAULT 0 /* default range */ sl@0: #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ sl@0: #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* sl@0: * Definitions for inet6 sysctl operations. sl@0: * sl@0: * Third level is protocol number. sl@0: * Fourth level is desired variable within that protocol. sl@0: */ sl@0: #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ sl@0: sl@0: /* sl@0: * Names for IP sysctl objects sl@0: */ sl@0: #define IPV6CTL_FORWARDING 1 /* act as router */ sl@0: #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ sl@0: #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ sl@0: #ifdef notyet sl@0: #define IPV6CTL_DEFMTU 4 /* default MTU */ sl@0: #endif sl@0: #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ sl@0: #define IPV6CTL_STATS 6 /* stats */ sl@0: #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ sl@0: #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ sl@0: #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ sl@0: #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ sl@0: #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ sl@0: #define IPV6CTL_ACCEPT_RTADV 12 sl@0: #define IPV6CTL_KEEPFAITH 13 sl@0: #define IPV6CTL_LOG_INTERVAL 14 sl@0: #define IPV6CTL_HDRNESTLIMIT 15 sl@0: #define IPV6CTL_DAD_COUNT 16 sl@0: #define IPV6CTL_AUTO_FLOWLABEL 17 sl@0: #define IPV6CTL_DEFMCASTHLIM 18 sl@0: #define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ sl@0: #define IPV6CTL_KAME_VERSION 20 sl@0: #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ sl@0: #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ sl@0: #if 0 /* obsolete */ sl@0: #define IPV6CTL_MAPPED_ADDR 23 sl@0: #endif sl@0: #define IPV6CTL_V6ONLY 24 sl@0: #define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */ sl@0: #define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */ sl@0: #define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */ sl@0: sl@0: #define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */ sl@0: #define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */ sl@0: #define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */ sl@0: #define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ sl@0: #define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */ sl@0: #define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */ sl@0: #define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */ sl@0: sl@0: #define IPV6CTL_MAXFRAGS 41 /* max fragments */ sl@0: sl@0: /* New entries should be added here from current IPV6CTL_MAXID value. */ sl@0: /* to define items, should talk with KAME guys first, for *BSD compatibility */ sl@0: /* 42-44 is already used in KAME */ sl@0: #define IPV6CTL_STEALTH 45 sl@0: #define IPV6CTL_MAXID 46 sl@0: #endif /* __BSD_VISIBLE */ sl@0: sl@0: /* sl@0: * Redefinition of mbuf flags sl@0: */ sl@0: #define M_AUTHIPHDR M_PROTO2 sl@0: #define M_DECRYPTED M_PROTO3 sl@0: #define M_LOOP M_PROTO4 sl@0: #define M_AUTHIPDGM M_PROTO5 sl@0: sl@0: #ifdef _KERNEL sl@0: struct cmsghdr; sl@0: sl@0: struct sockaddr; sl@0: extern u_char ip6_protox[]; sl@0: #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) sl@0: #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) sl@0: #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) sl@0: sl@0: extern int (*faithprefix_p)(struct in6_addr *); sl@0: #endif /* _KERNEL */ sl@0: sl@0: #ifndef _SIZE_T_DECLARED sl@0: typedef __size_t size_t; sl@0: #define _SIZE_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _SOCKLEN_T_DECLARED sl@0: typedef __socklen_t socklen_t; sl@0: #define _SOCKLEN_T_DECLARED sl@0: #endif sl@0: sl@0: #if __BSD_VISIBLE sl@0: sl@0: __BEGIN_DECLS sl@0: struct cmsghdr; sl@0: __END_DECLS sl@0: sl@0: #endif /* __BSD_VISIBLE */ sl@0: sl@0: #endif /* !_NETINET6_IN6_H_ */