]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet6/in6.h
xnu-1504.3.12.tar.gz
[apple/xnu.git] / bsd / netinet6 / in6.h
index 7c7a745fc89d7d1b697b4d6a594eae56fc6ef520..fb0479fde5711b47cb6e64587e6f06854a7d1f67 100644 (file)
@@ -1,4 +1,33 @@
-/*     $KAME: in6.h,v 1.40 2000/03/25 07:23:42 sumikawa Exp $  */
+/*
+ * Copyright (c) 2008 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+/*     $FreeBSD: src/sys/netinet6/in6.h,v 1.7.2.4 2001/07/04 09:45:23 ume Exp $        */
+/*     $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  */
 
 #ifndef __KAME_NETINET_IN_H_INCLUDED_
-#error "do not include netinet6/in6.h directly, include netinet/in.h"
+#error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
 #endif
 
 #ifndef _NETINET6_IN6_H_
 #define _NETINET6_IN6_H_
+#include <sys/appleapiopts.h>
+#include <sys/_types.h>
 
-#if !defined(_XOPEN_SOURCE)
-#include <sys/queue.h>
+
+#ifndef _SA_FAMILY_T
+#define _SA_FAMILY_T
+typedef __uint8_t              sa_family_t;
 #endif
 
 /*
  * Identification of the network protocol stack
+ * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
+ * has the table of implementation/integration differences.
  */
 #define __KAME__
-#define __KAME_VERSION         "STABLE 20000425"
+#define __KAME_VERSION         "20010528/apple-darwin"
 
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 /*
  * Local port number conventions:
  *
  * When a user does a bind(2) or connect(2) with a port number of zero,
  * a non-conflicting local port address is chosen.
  *
- * The default range is IPPORT_ANONMIX to IPPORT_ANONMAX, although
+ * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
  * that is settable by sysctl(3); net.inet.ip.anonportmin and
  * net.inet.ip.anonportmax respectively.
  *
 #define        IPV6PORT_ANONMAX        65535
 #define        IPV6PORT_RESERVEDMIN    600
 #define        IPV6PORT_RESERVEDMAX    (IPV6PORT_RESERVED-1)
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 
 /*
  * IPv6 address
  */
 struct in6_addr {
        union {
-               u_int8_t   __u6_addr8[16];
-               u_int16_t  __u6_addr16[8];
-               u_int32_t  __u6_addr32[4];
+               __uint8_t   __u6_addr8[16];
+               __uint16_t  __u6_addr16[8];
+               __uint32_t  __u6_addr32[4];
        } __u6_addr;                    /* 128-bit IP6 address */
 };
 
@@ -138,22 +175,22 @@ struct in6_addr {
 /*
  * Socket address for IPv6
  */
-#if !defined(_XOPEN_SOURCE)
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 #define SIN6_LEN
-#endif
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 struct sockaddr_in6 {
-       u_int8_t        sin6_len;       /* length of this struct(sa_family_t)*/
-       u_int8_t        sin6_family;    /* AF_INET6 (sa_family_t) */
-       u_int16_t       sin6_port;      /* Transport layer port # (in_port_t)*/
-       u_int32_t       sin6_flowinfo;  /* IP6 flow information */
+       __uint8_t       sin6_len;       /* length of this struct(sa_family_t)*/
+       sa_family_t     sin6_family;    /* AF_INET6 (sa_family_t) */
+       in_port_t       sin6_port;      /* Transport layer port # (in_port_t)*/
+       __uint32_t      sin6_flowinfo;  /* IP6 flow information */
        struct in6_addr sin6_addr;      /* IP6 address */
-       u_int32_t       sin6_scope_id;  /* intface scope id */
+       __uint32_t      sin6_scope_id;  /* scope zone index */
 };
 
+#ifdef KERNEL  /*XXX nonstandard*/
 /*
  * Local definition for masks
  */
-#ifdef KERNEL  /*XXX nonstandard*/
 #define IN6MASK0       {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
 #define IN6MASK32      {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
@@ -165,18 +202,20 @@ struct sockaddr_in6 {
                            0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
 #endif
 
-#ifdef KERNEL
+#ifdef KERNEL_PRIVATE
+extern const struct sockaddr_in6 sa6_any;
+
 extern const struct in6_addr in6mask0;
 extern const struct in6_addr in6mask32;
 extern const struct in6_addr in6mask64;
 extern const struct in6_addr in6mask96;
 extern const struct in6_addr in6mask128;
-#endif /* KERNEL */
+#endif /* KERNEL_PRIVATE */
 
+#ifdef KERNEL  /*XXX nonstandard*/
 /*
  * Macros started with IPV6_ADDR is KAME local
  */
-#ifdef KERNEL  /*XXX nonstandard*/
 #if BYTE_ORDER == BIG_ENDIAN
 #define IPV6_ADDR_INT32_ONE    1
 #define IPV6_ADDR_INT32_TWO    2
@@ -207,6 +246,7 @@ extern const struct in6_addr in6mask128;
 #define IN6ADDR_LOOPBACK_INIT \
        {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
        {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
@@ -216,14 +256,15 @@ extern const struct in6_addr in6mask128;
 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
        {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 
-#ifdef KERNEL
 extern const struct in6_addr in6addr_any;
 extern const struct in6_addr in6addr_loopback;
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 extern const struct in6_addr in6addr_nodelocal_allnodes;
 extern const struct in6_addr in6addr_linklocal_allnodes;
 extern const struct in6_addr in6addr_linklocal_allrouters;
-#endif
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 
 /*
  * Equality
@@ -233,47 +274,57 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
  */
 #ifdef KERNEL
 #define IN6_ARE_ADDR_EQUAL(a, b)                       \
-       (bcmp((a), (b), sizeof(struct in6_addr)) == 0)
+    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
 #else
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 #define IN6_ARE_ADDR_EQUAL(a, b)                       \
-       (memcmp((a), (b), sizeof(struct in6_addr)) == 0)
+    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#endif
+
+#ifdef KERNEL                  /* non standard */
+/* see if two addresses are equal in a scope-conscious manner. */
+#define SA6_ARE_ADDR_EQUAL(a, b) \
+       (((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \
+         ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \
+        (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0))
 #endif
 
 /*
  * Unspecified
  */
 #define IN6_IS_ADDR_UNSPECIFIED(a)     \
-       ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[12]) == 0))
+       ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
 
 /*
  * Loopback
  */
 #define IN6_IS_ADDR_LOOPBACK(a)                \
-       ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[12]) == ntohl(1)))
+       ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
 
 /*
  * IPv4 compatible
  */
 #define IN6_IS_ADDR_V4COMPAT(a)                \
-       ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[12]) != 0) &&    \
-        (*(u_int32_t *)(&(a)->s6_addr[12]) != ntohl(1)))
+       ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
 
 /*
  * Mapped
  */
 #define IN6_IS_ADDR_V4MAPPED(a)                      \
-       ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&     \
-        (*(u_int32_t *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
+       ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
 
 /*
  * KAME Scope Values
@@ -281,6 +332,7 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
 
 #ifdef KERNEL  /*XXX nonstandard*/
 #define IPV6_ADDR_SCOPE_NODELOCAL      0x01
+#define        IPV6_ADDR_SCOPE_INTFACELOCAL    0x01
 #define IPV6_ADDR_SCOPE_LINKLOCAL      0x02
 #define IPV6_ADDR_SCOPE_SITELOCAL      0x05
 #define IPV6_ADDR_SCOPE_ORGLOCAL       0x08    /* just used in this file */
@@ -320,6 +372,9 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
 #define IN6_IS_ADDR_MC_NODELOCAL(a)    \
        (IN6_IS_ADDR_MULTICAST(a) &&    \
         (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
+#define        IN6_IS_ADDR_MC_INTFACELOCAL(a)  \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+       (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
 #define IN6_IS_ADDR_MC_LINKLOCAL(a)    \
        (IN6_IS_ADDR_MULTICAST(a) &&    \
         (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
@@ -350,67 +405,91 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
         (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
 #endif
 
-/*
- * Wildcard Socket
- */
-#if 0  /*pre-RFC2553*/
-#define IN6_IS_ADDR_ANY(a)     IN6_IS_ADDR_UNSPECIFIED(a)
-#endif
-
+#ifdef KERNEL  /*nonstandard*/
 /*
  * KAME Scope
  */
-#ifdef KERNEL  /*nonstandard*/
 #define IN6_IS_SCOPE_LINKLOCAL(a)      \
        ((IN6_IS_ADDR_LINKLOCAL(a)) ||  \
         (IN6_IS_ADDR_MC_LINKLOCAL(a)))
-#endif
+
+#define IN6_IS_SCOPE_EMBED(a)                  \
+       ((IN6_IS_ADDR_LINKLOCAL(a)) ||          \
+       (IN6_IS_ADDR_MC_LINKLOCAL(a)) ||        \
+       (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
+
+#define IFA6_IS_DEPRECATED(a) \
+       ((a)->ia6_lifetime.ia6t_preferred != 0 && \
+        (a)->ia6_lifetime.ia6t_preferred < timenow.tv_sec)
+#define IFA6_IS_INVALID(a) \
+       ((a)->ia6_lifetime.ia6t_expire != 0 && \
+        (a)->ia6_lifetime.ia6t_expire < timenow.tv_sec)
+#endif /* KERNEL */
 
 /*
  * IP6 route structure
  */
-#if !defined(_XOPEN_SOURCE)
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#ifdef PRIVATE
 struct route_in6 {
-       struct  rtentry *ro_rt;
-       struct  sockaddr_in6 ro_dst;
+       /*
+        * N.B: struct route_in6 must begin with ro_rt and ro_flags
+        * because the code does some casts of a 'struct route_in6 *'
+        * to a 'struct route *'.
+        */
+       struct rtentry  *ro_rt;
+       __uint32_t      ro_flags;       /* route flags */
+       struct sockaddr_in6 ro_dst;
 };
-#endif
+#endif /* PRIVATE */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 
 /*
  * Options for use with [gs]etsockopt at the IPV6 level.
  * First word of comment is data type; bool is stored in int.
  */
 /* no hdrincl */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 #if 0 /* the followings are relic in IPv4 and hence are disabled */
 #define IPV6_OPTIONS           1  /* buf/ip6_opts; set/get IP6 options */
 #define IPV6_RECVOPTS          5  /* bool; receive all IP6 opts w/dgram */
 #define IPV6_RECVRETOPTS       6  /* bool; receive IP6 opts for response */
 #define IPV6_RECVDSTADDR       7  /* bool; receive IP6 dst addr w/dgram */
 #define IPV6_RETOPTS           8  /* ip6_opts; set/get IP6 options */
-#endif
+#endif /* 0 */
 #define IPV6_SOCKOPT_RESERVED1 3  /* reserved for future use */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 #define IPV6_UNICAST_HOPS      4  /* int; IP6 hops */
-#define IPV6_MULTICAST_IF      9  /* u_char; set/get IP6 multicast i/f  */
-#define IPV6_MULTICAST_HOPS    10 /* u_char; set/get IP6 multicast hops */
-#define IPV6_MULTICAST_LOOP    11 /* u_char; set/get IP6 multicast loopback */
+#define IPV6_MULTICAST_IF      9  /* __uint8_t; set/get IP6 multicast i/f  */
+#define IPV6_MULTICAST_HOPS    10 /* __uint8_t; set/get IP6 multicast hops */
+#define IPV6_MULTICAST_LOOP    11 /* __uint8_t; set/get IP6 mcast loopback */
 #define IPV6_JOIN_GROUP                12 /* ip6_mreq; join a group membership */
 #define IPV6_LEAVE_GROUP       13 /* ip6_mreq; leave a group membership */
+
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 #define IPV6_PORTRANGE         14 /* int; range to choose for unspec port */
 #define ICMP6_FILTER           18 /* icmp6_filter; icmp6 filter */
-#define IPV6_PKTINFO           19 /* in6_pktinfo; send if, src addr */
-#define IPV6_HOPLIMIT          20 /* int; send hop limit */
-#define IPV6_NEXTHOP           21 /* sockaddr; next hop addr */
-#define IPV6_HOPOPTS           22 /* ip6_hbh; send hop-by-hop option */
-#define IPV6_DSTOPTS           23 /* ip6_dest; send dst option befor rthdr */
-#define IPV6_RTHDR             24 /* ip6_rthdr; send routing header */
+/* RFC2292 options */
+#define IPV6_PKTINFO           19 /* bool; send/recv if, src/dst addr */
+#define IPV6_HOPLIMIT          20 /* bool; hop limit */
+#define IPV6_NEXTHOP           21 /* bool; next hop addr */
+#define IPV6_HOPOPTS           22 /* bool; hop-by-hop option */
+#define IPV6_DSTOPTS           23 /* bool; destination option */
+#define IPV6_RTHDR             24 /* bool; routing header */
 #define IPV6_PKTOPTIONS                25 /* buf/cmsghdr; set/get IPv6 options */
-                                  /* obsoleted by 2292bis */
+
 #define IPV6_CHECKSUM          26 /* int; checksum offset for raw socket */
-#define IPV6_BINDV6ONLY                27 /* bool; only bind INET6 at null bind */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
+#define IPV6_V6ONLY            27 /* bool; only bind INET6 at wildcard bind */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#ifndef KERNEL
+#define IPV6_BINDV6ONLY                IPV6_V6ONLY
+#endif /* KERNEL */
+
 
 #if 1 /*IPSEC*/
 #define IPV6_IPSEC_POLICY      28 /* struct; get/set security policy */
-#endif
+#endif /* 1 */
 #define IPV6_FAITH             29 /* bool; accept FAITH'ed connections */
 
 #if 1 /*IPV6FIREWALL*/
@@ -419,24 +498,12 @@ struct route_in6 {
 #define IPV6_FW_FLUSH          32 /* flush firewall rule chain */
 #define IPV6_FW_ZERO           33 /* clear single/all firewall counter(s) */
 #define IPV6_FW_GET            34 /* get entire firewall rule chain */
-#endif
-
-/* new socket options introduced in RFC2292bis */
-#define IPV6_RTHDRDSTOPTS      35 /* ip6_dest; send dst option before rthdr */
+#endif /* 1 */
 
-#define IPV6_RECVPKTINFO       36 /* bool; recv if, dst addr */
-#define IPV6_RECVHOPLIMIT      37 /* bool; recv hop limit */
-#define IPV6_RECVRTHDR         38 /* bool; recv routing header */
-#define IPV6_RECVHOPOPTS       39 /* bool; recv hop-by-hop option */
-#define IPV6_RECVDSTOPTS       40 /* bool; recv dst option after rthdr */
-#define IPV6_RECVRTHDRDSTOPTS  41 /* bool; recv dst option before rthdr */
+#define IPV6_RECVTCLASS         35 /* bool; recv traffic class values */
+#define IPV6_TCLASS             36 /* int; send traffic class value */
 
-#define IPV6_USE_MIN_MTU       42 /* bool; send packets at the minimum MTU */
-#define IPV6_RECVPATHMTU       43 /* bool; notify an according MTU */
-
-/* the followings are used as cmsg type only */
-#define IPV6_PATHMTU           44 /* 4 bytes int; MTU notification */
-#define IPV6_REACHCONF         45 /* no data; ND reachability confirm */
+/* to define items, should talk with KAME guys first, for *BSD compatibility */
 
 #define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
 #define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
@@ -453,15 +520,15 @@ struct route_in6 {
  */
 struct ipv6_mreq {
        struct in6_addr ipv6mr_multiaddr;
-       u_int           ipv6mr_interface;
+       unsigned int    ipv6mr_interface;
 };
 
 /*
  * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
  */
 struct in6_pktinfo {
-       struct in6_addr ipi6_addr;      /* src/dst IPv6 address */
-       u_int ipi6_ifindex;             /* send/recv interface index */
+       struct in6_addr ipi6_addr;      /* src/dst IPv6 address */
+       unsigned int    ipi6_ifindex;   /* send/recv interface index */
 };
 
 /*
@@ -472,7 +539,6 @@ struct in6_pktinfo {
 #define        IPV6_PORTRANGE_HIGH     1       /* "high" - request firewall bypass */
 #define        IPV6_PORTRANGE_LOW      2       /* "low" - vouchsafe security */
 
-#if !defined(_XOPEN_SOURCE)
 /*
  * Definitions for inet6 sysctl operations.
  *
@@ -481,6 +547,59 @@ struct in6_pktinfo {
  */
 #define IPV6PROTO_MAXID        (IPPROTO_PIM + 1)       /* don't list to IPV6PROTO_MAX */
 
+/*
+ * Names for IP sysctl objects
+ */
+#define IPV6CTL_FORWARDING     1       /* act as router */
+#define IPV6CTL_SENDREDIRECTS  2       /* may send redirects when forwarding*/
+#define IPV6CTL_DEFHLIM                3       /* default Hop-Limit */
+#ifdef notyet
+#define IPV6CTL_DEFMTU         4       /* default MTU */
+#endif
+#define IPV6CTL_FORWSRCRT      5       /* forward source-routed dgrams */
+#define IPV6CTL_STATS          6       /* stats */
+#define IPV6CTL_MRTSTATS       7       /* multicast forwarding stats */
+#define IPV6CTL_MRTPROTO       8       /* multicast routing protocol */
+#define IPV6CTL_MAXFRAGPACKETS 9       /* max packets reassembly queue */
+#define IPV6CTL_SOURCECHECK    10      /* verify source route and intf */
+#define IPV6CTL_SOURCECHECK_LOGINT 11  /* minimume logging interval */
+#define IPV6CTL_ACCEPT_RTADV   12
+#define IPV6CTL_KEEPFAITH      13
+#define IPV6CTL_LOG_INTERVAL   14
+#define IPV6CTL_HDRNESTLIMIT   15
+#define IPV6CTL_DAD_COUNT      16
+#define IPV6CTL_AUTO_FLOWLABEL 17
+#define IPV6CTL_DEFMCASTHLIM   18
+#define IPV6CTL_GIF_HLIM       19      /* default HLIM for gif encap packet */
+#define IPV6CTL_KAME_VERSION   20
+#define IPV6CTL_USE_DEPRECATED 21      /* use deprecated addr (RFC2462 5.5.4) */
+#define IPV6CTL_RR_PRUNE       22      /* walk timer for router renumbering */
+#if 0  /*obsolete*/
+#define IPV6CTL_MAPPED_ADDR    23
+#endif
+#define IPV6CTL_V6ONLY         24
+#define IPV6CTL_RTEXPIRE       25      /* cloned route expiration time */
+#define IPV6CTL_RTMINEXPIRE    26      /* min value for expiration time */
+#define IPV6CTL_RTMAXCACHE     27      /* trigger level for dynamic expire */
+
+#define IPV6CTL_USETEMPADDR    32      /* use temporary addresses (RFC3041) */
+#define IPV6CTL_TEMPPLTIME     33      /* preferred lifetime for tmpaddrs */
+#define IPV6CTL_TEMPVLTIME     34      /* valid lifetime for tmpaddrs */
+#define IPV6CTL_AUTO_LINKLOCAL 35      /* automatic link-local addr assign */
+#define IPV6CTL_RIP6STATS      36      /* raw_ip6 stats */
+
+#define IPV6CTL_MAXFRAGS        41      /* max fragments */
+
+#define IPV6CTL_NEIGHBORGCTHRESH 46
+#define IPV6CTL_MAXIFPREFIXES  47
+#define IPV6CTL_MAXIFDEFROUTERS 48
+#define IPV6CTL_MAXDYNROUTES   49
+
+/* New entries should be added here from current IPV6CTL_MAXID value. */
+/* to define items, should talk with KAME guys first, for *BSD compatibility */
+#define IPV6CTL_MAXID          50
+
+#ifdef KERNEL_PRIVATE
 #define CTL_IPV6PROTO_NAMES { \
        { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
        { 0, 0 }, \
@@ -527,184 +646,86 @@ struct in6_pktinfo {
        { 0, 0 }, \
        { "pim6", CTLTYPE_NODE }, \
 }
-
 /*
- * Names for IP sysctl objects
+ * Redefinition of mbuf flags
  */
-#define IPV6CTL_FORWARDING     1       /* act as router */
-#define IPV6CTL_SENDREDIRECTS  2       /* may send redirects when forwarding*/
-#define IPV6CTL_DEFHLIM                3       /* default Hop-Limit */
-#ifdef notyet
-#define IPV6CTL_DEFMTU         4       /* default MTU */
-#endif
-#define IPV6CTL_FORWSRCRT      5       /* forward source-routed dgrams */
-#define IPV6CTL_STATS          6       /* stats */
-#define IPV6CTL_MRTSTATS       7       /* multicast forwarding stats */
-#define IPV6CTL_MRTPROTO       8       /* multicast routing protocol */
-#define IPV6CTL_MAXFRAGPACKETS 9       /* max packets reassembly queue */
-#define IPV6CTL_SOURCECHECK    10      /* verify source route and intf */
-#define IPV6CTL_SOURCECHECK_LOGINT 11  /* minimume logging interval */
-#define IPV6CTL_ACCEPT_RTADV   12
-#define IPV6CTL_KEEPFAITH      13
-#define IPV6CTL_LOG_INTERVAL   14
-#define IPV6CTL_HDRNESTLIMIT   15
-#define IPV6CTL_DAD_COUNT      16
-#define IPV6CTL_AUTO_FLOWLABEL 17
-#define IPV6CTL_DEFMCASTHLIM   18
-#define IPV6CTL_GIF_HLIM       19      /* default HLIM for gif encap packet */
-#define IPV6CTL_KAME_VERSION   20
-#define IPV6CTL_USE_DEPRECATED 21      /* use deprecated addr (RFC2462 5.5.4) */
-#define IPV6CTL_RR_PRUNE       22      /* walk timer for router renumbering */
-#if MAPPED_ADDR_ENABLED
-#define IPV6CTL_MAPPED_ADDR    23
-#endif /* MAPPED_ADDR_ENABLED */
-/* New entries should be added here from current IPV6CTL_MAXID value. */
-#define IPV6CTL_MAXID          24
-
-#if MAPPED_ADDR_ENABLED
-#define IPV6CTL_NAMES_MAPPED_ADDR      "mapped_addr"
-#define IPV6CTL_TYPE_MAPPED_ADDR       CTLTYPE_INT
-#define IPV6CTL_VARS_MAPPED_ADDR       &ip6_mapped_addr_on
-#else  /* MAPPED_ADDR_ENABLED */
-#define IPV6CTL_NAMES_MAPPED_ADDR      0
-#define IPV6CTL_TYPE_MAPPED_ADDR       0
-#define IPV6CTL_VARS_MAPPED_ADDR       0
-#endif /* MAPPED_ADDR_ENABLED */
-
-#if IPV6CTL_BINDV6ONLY
-#define IPV6CTL_NAMES_BINDV6ONLY       "bindv6only"
-#define IPV6CTL_TYPE_BINDV6ONLY                CTLTYPE_INT
-#define IPV6CTL_VARS_BINDV6ONLY                &ip6_bindv6only
-#else
-#define IPV6CTL_NAMES_BINDV6ONLY       0
-#define IPV6CTL_TYPE_BINDV6ONLY        0
-#define IPV6CTL_VARS_BINDV6ONLY        0
-#endif
+#define        M_AUTHIPHDR     M_PROTO2
+#define        M_DECRYPTED     M_PROTO3
+#define        M_LOOP          M_PROTO4
+#define        M_AUTHIPDGM     M_PROTO5
 
-#define IPV6CTL_NAMES { \
-       { 0, 0 }, \
-       { "forwarding", CTLTYPE_INT }, \
-       { "redirect", CTLTYPE_INT }, \
-       { "hlim", CTLTYPE_INT }, \
-       { "mtu", CTLTYPE_INT }, \
-       { "forwsrcrt", CTLTYPE_INT }, \
-       { 0, 0 }, \
-       { 0, 0 }, \
-       { "mrtproto", CTLTYPE_INT }, \
-       { "maxfragpackets", CTLTYPE_INT }, \
-       { "sourcecheck", CTLTYPE_INT }, \
-       { "sourcecheck_logint", CTLTYPE_INT }, \
-       { "accept_rtadv", CTLTYPE_INT }, \
-       { "keepfaith", CTLTYPE_INT }, \
-       { "log_interval", CTLTYPE_INT }, \
-       { "hdrnestlimit", CTLTYPE_INT }, \
-       { "dad_count", CTLTYPE_INT }, \
-       { "auto_flowlabel", CTLTYPE_INT }, \
-       { "defmcasthlim", CTLTYPE_INT }, \
-       { "gifhlim", CTLTYPE_INT }, \
-       { "kame_version", CTLTYPE_STRING }, \
-       { "use_deprecated", CTLTYPE_INT }, \
-       { "rr_prune", CTLTYPE_INT }, \
-       { IPV6CTL_NAMES_MAPPED_ADDR, IPV6CTL_TYPE_MAPPED_ADDR }, \
-       { IPV6CTL_NAMES_BINDV6ONLY, IPV6CTL_TYPE_BINDV6ONLY }, \
-}
+struct cmsghdr;
+struct mbuf;
+struct ifnet;
+struct in6_aliasreq;
 
-#ifdef __bsdi__
-#define IPV6CTL_VARS { \
-       0, \
-       &ip6_forwarding, \
-       &ip6_sendredirects, \
-       &ip6_defhlim, \
-       0, \
-       &ip6_forward_srcrt, \
-       0, \
-       0, \
-       0, \
-       &ip6_maxfragpackets, \
-       &ip6_sourcecheck, \
-       &ip6_sourcecheck_interval, \
-       &ip6_accept_rtadv, \
-       &ip6_keepfaith, \
-       &ip6_log_interval, \
-       &ip6_hdrnestlimit, \
-       &ip6_dad_count, \
-       &ip6_auto_flowlabel, \
-       &ip6_defmcasthlim, \
-       &ip6_gif_hlim, \
-       0, \
-       &ip6_use_deprecated, \
-       &ip6_rr_prune, \
-       IPV6CTL_VARS_MAPPED_ADDR, \
-       IPV6CTL_VARS_BINDV6ONLY, \
-}
-#endif
-#endif /* !_XOPEN_SOURCE */
+#define        in6_cksum(m, n, o, l)   inet6_cksum(m, n, o, l)
 
-#ifdef KERNEL
-struct cmsghdr;
+extern u_int16_t inet6_cksum(struct mbuf *m, unsigned int proto,
+    unsigned int offset, unsigned int transport_len);
 
-int    in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t));
-int    in6_localaddr __P((struct in6_addr *));
-int    in6_addrscope __P((struct in6_addr *));
-struct in6_ifaddr *in6_ifawithscope __P((struct ifnet *, struct in6_addr *));
-struct in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *));
-extern void in6_if_up __P((struct ifnet *));
-#if MAPPED_ADDR_ENABLED
+extern int in6_localaddr(struct in6_addr *);
+extern int in6_addrscope(struct in6_addr *);
+extern struct in6_ifaddr *in6_ifawithscope(struct ifnet *, struct in6_addr *);
+extern struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *);
+extern int in6_if_up(struct ifnet *, struct in6_aliasreq *);
 struct sockaddr;
 
-void   in6_sin6_2_sin __P((struct sockaddr_in *sin,
-                           struct sockaddr_in6 *sin6));
-void   in6_sin_2_v4mapsin6 __P((struct sockaddr_in *sin,
-                                struct sockaddr_in6 *sin6));
-void   in6_sin6_2_sin_in_sock __P((struct sockaddr *nam));
-void   in6_sin_2_v4mapsin6_in_sock __P((struct sockaddr **nam));
-#endif /* MAPPED_ADDR_ENABLED */
+extern void in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6);
+extern void in6_sin_2_v4mapsin6(struct sockaddr_in *sin,
+    struct sockaddr_in6 *sin6);
+extern void in6_sin6_2_sin_in_sock(struct sockaddr *nam);
+extern int in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam);
 
 #define        satosin6(sa)    ((struct sockaddr_in6 *)(sa))
 #define        sin6tosa(sin6)  ((struct sockaddr *)(sin6))
 #define        ifatoia6(ifa)   ((struct in6_ifaddr *)(ifa))
-#endif /* KERNEL */
 
+extern int in6addr_local(struct in6_addr *);
+#endif /* KERNEL_PRIVATE */
+
+#ifndef KERNEL
 __BEGIN_DECLS
 struct cmsghdr;
 
-extern int inet6_option_space __P((int));
-extern int inet6_option_init __P((void *, struct cmsghdr **, int));
-extern int inet6_option_append __P((struct cmsghdr *, const u_int8_t *,
-       int, int));
-extern u_int8_t *inet6_option_alloc __P((struct cmsghdr *, int, int, int));
-extern int inet6_option_next __P((const struct cmsghdr *, u_int8_t **));
-extern int inet6_option_find __P((const struct cmsghdr *, u_int8_t **, int));
-
-extern size_t inet6_rthdr_space __P((int, int));
-extern struct cmsghdr *inet6_rthdr_init __P((void *, int));
-extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *,
-               unsigned int));
-extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int));
+extern int inet6_option_space(int);
+extern int inet6_option_init(void *, struct cmsghdr **, int);
+extern int inet6_option_append(struct cmsghdr *, const __uint8_t *,
+       int, int);
+extern __uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int);
+extern int inet6_option_next(const struct cmsghdr *, __uint8_t **);
+extern int inet6_option_find(const struct cmsghdr *, __uint8_t **, int);
+
+extern size_t inet6_rthdr_space(int, int);
+extern struct cmsghdr *inet6_rthdr_init(void *, int);
+extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *,
+               unsigned int);
+extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int);
 #if 0 /* not implemented yet */
-extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *));
+extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *);
 #endif
-extern int inet6_rthdr_segments __P((const struct cmsghdr *));
-extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int));
-extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int));
-
-extern int inet6_opt_init __P((void *, size_t));
-extern int inet6_opt_append __P((void *, size_t, int, u_int8_t,
-                                size_t, u_int8_t, void **));
-extern int inet6_opt_finish __P((void *, size_t, int));
-extern int inet6_opt_set_val __P((void *, size_t, void *, int));
-
-extern int inet6_opt_next __P((void *, size_t, int, u_int8_t *,
-                              size_t *, void **));
-extern int inet6_opt_find __P((void *, size_t, int, u_int8_t,
-                         size_t *, void **));
-extern int inet6_opt_get_val __P((void *, size_t, void *, int));
-extern size_t inet6_rth_space __P((int, int));
-extern void *inet6_rth_init __P((void *, int, int, int));
-extern int inet6_rth_add __P((void *, const struct in6_addr *));
-extern int inet6_rth_reverse __P((const void *, void *));
-extern int inet6_rth_segments __P((const void *));
-extern struct in6_addr *inet6_rth_getaddr __P((const void *, int));
+extern int inet6_rthdr_segments(const struct cmsghdr *);
+extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int);
+extern int inet6_rthdr_getflags(const struct cmsghdr *, int);
+
+extern int inet6_opt_init(void *, size_t);
+extern int inet6_opt_append(void *, size_t, int, __uint8_t,
+                                size_t, __uint8_t, void **);
+extern int inet6_opt_finish(void *, size_t, int);
+extern int inet6_opt_set_val(void *, size_t, void *, int);
+
+extern int inet6_opt_next(void *, size_t, int, __uint8_t *,
+                              size_t *, void **);
+extern int inet6_opt_find(void *, size_t, int, __uint8_t,
+                         size_t *, void **);
+extern int inet6_opt_get_val(void *, size_t, void *, int);
+extern size_t inet6_rth_space(int, int);
+extern void *inet6_rth_init(void *, int, int, int);
+extern int inet6_rth_add(void *, const struct in6_addr *);
+extern int inet6_rth_reverse(const void *, void *);
+extern int inet6_rth_segments(const void *);
+extern struct in6_addr *inet6_rth_getaddr(const void *, int);
 __END_DECLS
-
+#endif /* !KERNEL */
+#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
 #endif /* !_NETINET6_IN6_H_ */