in6.h

Go to the documentation of this file.
00001 /*      $FreeBSD: src/sys/netinet6/in6.h,v 1.36.2.2 2005/10/09 05:21:18 ume Exp $       */
00002 /*      $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $    */
00003 
00004 /*-
00005  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the project nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  */
00032 
00033 /*-
00034  * Copyright (c) 1982, 1986, 1990, 1993
00035  *      The Regents of the University of California.  All rights reserved.
00036  *
00037  * Redistribution and use in source and binary forms, with or without
00038  * modification, are permitted provided that the following conditions
00039  * are met:
00040  * 1. Redistributions of source code must retain the above copyright
00041  *    notice, this list of conditions and the following disclaimer.
00042  * 2. Redistributions in binary form must reproduce the above copyright
00043  *    notice, this list of conditions and the following disclaimer in the
00044  *    documentation and/or other materials provided with the distribution.
00045  * 4. Neither the name of the University nor the names of its contributors
00046  *    may be used to endorse or promote products derived from this software
00047  *    without specific prior written permission.
00048  *
00049  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00050  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00051  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00052  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00053  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00054  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00055  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00056  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00057  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00058  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00059  * SUCH DAMAGE.
00060 * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
00061  *      @(#)in.h        8.3 (Berkeley) 1/3/94
00062  */
00063 
00064 #ifndef __KAME_NETINET_IN_H_INCLUDED_
00065 #error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
00066 #endif
00067 
00068 #ifndef _NETINET6_IN6_H_
00069 #define _NETINET6_IN6_H_
00070 
00071 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00072 #define SYMBIAN
00073 #endif
00074 /*
00075  * Identification of the network protocol stack
00076  * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
00077  * has the table of implementation/integration differences.
00078  */
00079 #define __KAME__
00080 #define __KAME_VERSION          "20010528/FreeBSD"
00081 
00082 /*
00083  * Local port number conventions:
00084  *
00085  * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
00086  * unless a kernel is compiled with IPNOPRIVPORTS defined.
00087  *
00088  * When a user does a bind(2) or connect(2) with a port number of zero,
00089  * a non-conflicting local port address is chosen.
00090  *
00091  * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
00092  * that is settable by sysctl(3); net.inet.ip.anonportmin and
00093  * net.inet.ip.anonportmax respectively.
00094  *
00095  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
00096  * default assignment range.
00097  *
00098  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
00099  *
00100  * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
00101  * and exists only for FreeBSD compatibility purposes.
00102  *
00103  * The value IP_PORTRANGE_LOW changes the range to the "low" are
00104  * that is (by convention) restricted to privileged processes.
00105  * This convention is based on "vouchsafe" principles only.
00106  * It is only secure if you trust the remote host to restrict these ports.
00107  * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
00108  */
00109 #if __BSD_VISIBLE
00110 #define IPV6PORT_RESERVED       1024
00111 #define IPV6PORT_ANONMIN        49152
00112 #define IPV6PORT_ANONMAX        65535
00113 #define IPV6PORT_RESERVEDMIN    600
00114 #define IPV6PORT_RESERVEDMAX    (IPV6PORT_RESERVED-1)
00115 #endif
00116 
00117 /*
00118  * IPv6 address
00119  */
00120 struct in6_addr {
00121         union {
00122                 uint8_t         __u6_addr8[16];
00123                 uint16_t        __u6_addr16[8];
00124                 uint32_t        __u6_addr32[4];
00125         } __u6_addr;                    /* 128-bit IP6 address */
00126 };
00127 
00128 #define s6_addr   __u6_addr.__u6_addr8
00129 #ifdef _KERNEL  /* XXX nonstandard */
00130 #define s6_addr8  __u6_addr.__u6_addr8
00131 #define s6_addr16 __u6_addr.__u6_addr16
00132 #define s6_addr32 __u6_addr.__u6_addr32
00133 #endif
00134 
00135 #define INET6_ADDRSTRLEN        46
00136 
00137 /*
00138  * XXX missing POSIX.1-2001 macro IPPROTO_IPV6.
00139  */
00140 
00141 /*
00142  * Socket address for IPv6
00143  */
00144 #if __BSD_VISIBLE
00145 #define SIN6_LEN
00146 #endif
00147 #ifdef __SYMBIAN32__
00148 struct sockaddr_in6 {
00149         u_short         sin6_family;    /* AF_INET6 */
00150         u_short         sin6_port;      /* Transport layer port # */
00151         struct in6_addr sin6_addr;      /* IP6 address */
00152         uint32_t        sin6_flowinfo;  /* IP6 flow information */
00153         uint32_t        sin6_scope_id;  /* scope zone index */
00154         uint8_t         sin6_len;       /* length of this struct */
00155 };
00156 #else
00157 struct sockaddr_in6 {
00158         uint8_t         sin6_len;       /* length of this struct */
00159         sa_family_t     sin6_family;    /* AF_INET6 */
00160         in_port_t       sin6_port;      /* Transport layer port # */
00161         uint32_t        sin6_flowinfo;  /* IP6 flow information */
00162         struct in6_addr sin6_addr;      /* IP6 address */
00163         uint32_t        sin6_scope_id;  /* scope zone index */
00164 };
00165 #endif
00166 
00167 /*
00168  * Local definition for masks
00169  */
00170 #ifdef _KERNEL  /* XXX nonstandard */
00171 #define IN6MASK0        {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
00172 #define IN6MASK32       {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
00173                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
00174 #define IN6MASK64       {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00175                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
00176 #define IN6MASK96       {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00177                             0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
00178 #define IN6MASK128      {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00179                             0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
00180 #endif
00181 
00182 #ifdef _KERNEL
00183 extern const struct sockaddr_in6 sa6_any;
00184 
00185 extern const struct in6_addr in6mask0;
00186 extern const struct in6_addr in6mask32;
00187 extern const struct in6_addr in6mask64;
00188 extern const struct in6_addr in6mask96;
00189 extern const struct in6_addr in6mask128;
00190 #endif /* _KERNEL */
00191 
00192 /*
00193  * Macros started with IPV6_ADDR is KAME local
00194  */
00195 #ifdef _KERNEL  /* XXX nonstandard */
00196 #if _BYTE_ORDER == _BIG_ENDIAN
00197 #define IPV6_ADDR_INT32_ONE     1
00198 #define IPV6_ADDR_INT32_TWO     2
00199 #define IPV6_ADDR_INT32_MNL     0xff010000
00200 #define IPV6_ADDR_INT32_MLL     0xff020000
00201 #define IPV6_ADDR_INT32_SMP     0x0000ffff
00202 #define IPV6_ADDR_INT16_ULL     0xfe80
00203 #define IPV6_ADDR_INT16_USL     0xfec0
00204 #define IPV6_ADDR_INT16_MLL     0xff02
00205 #elif _BYTE_ORDER == _LITTLE_ENDIAN
00206 #define IPV6_ADDR_INT32_ONE     0x01000000
00207 #define IPV6_ADDR_INT32_TWO     0x02000000
00208 #define IPV6_ADDR_INT32_MNL     0x000001ff
00209 #define IPV6_ADDR_INT32_MLL     0x000002ff
00210 #define IPV6_ADDR_INT32_SMP     0xffff0000
00211 #define IPV6_ADDR_INT16_ULL     0x80fe
00212 #define IPV6_ADDR_INT16_USL     0xc0fe
00213 #define IPV6_ADDR_INT16_MLL     0x02ff
00214 #endif
00215 #endif
00216 
00217 /*
00218  * Definition of some useful macros to handle IP6 addresses
00219  */
00220 #if __BSD_VISIBLE
00221 #define IN6ADDR_ANY_INIT \
00222         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00223             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
00224 #define IN6ADDR_LOOPBACK_INIT \
00225         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00226             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
00227 #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
00228         {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00229             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
00230 #define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
00231         {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00232             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
00233 #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
00234         {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00235             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
00236 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
00237         {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
00238             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
00239 #endif
00240 
00241 extern const struct in6_addr in6addr_any;
00242 extern const struct in6_addr in6addr_loopback;
00243 #if __BSD_VISIBLE
00244 extern const struct in6_addr in6addr_nodelocal_allnodes;
00245 extern const struct in6_addr in6addr_linklocal_allnodes;
00246 extern const struct in6_addr in6addr_linklocal_allrouters;
00247 #endif
00248 
00249 /*
00250  * Equality
00251  * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
00252  * does not supply memcmp().  For userland memcmp() is preferred as it is
00253  * in ANSI standard.
00254  */
00255 #ifdef _KERNEL
00256 #define IN6_ARE_ADDR_EQUAL(a, b)                        \
00257     (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
00258 #else
00259 #if __BSD_VISIBLE
00260 #define IN6_ARE_ADDR_EQUAL(a, b)                        \
00261     (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
00262 #endif
00263 #endif
00264 
00265 #ifdef _KERNEL                  /* non standard */
00266 /* see if two addresses are equal in a scope-conscious manner. */
00267 #define SA6_ARE_ADDR_EQUAL(a, b) \
00268         (((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \
00269           ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \
00270          (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0))
00271 #endif
00272 
00273 /*
00274  * Unspecified
00275  */
00276 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
00277         ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
00278          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
00279          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
00280          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
00281 
00282 /*
00283  * Loopback
00284  */
00285 #define IN6_IS_ADDR_LOOPBACK(a)         \
00286         ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
00287          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
00288          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
00289          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
00290 
00291 /*
00292  * IPv4 compatible
00293  */
00294 #define IN6_IS_ADDR_V4COMPAT(a)         \
00295         ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
00296          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
00297          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
00298          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) &&        \
00299          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
00300 
00301 /*
00302  * Mapped
00303  */
00304 #define IN6_IS_ADDR_V4MAPPED(a)               \
00305         ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
00306          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
00307          (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
00308 
00309 /*
00310  * KAME Scope Values
00311  */
00312 
00313 #ifdef _KERNEL  /* XXX nonstandard */
00314 #define IPV6_ADDR_SCOPE_NODELOCAL       0x01
00315 #define IPV6_ADDR_SCOPE_INTFACELOCAL    0x01
00316 #define IPV6_ADDR_SCOPE_LINKLOCAL       0x02
00317 #define IPV6_ADDR_SCOPE_SITELOCAL       0x05
00318 #define IPV6_ADDR_SCOPE_ORGLOCAL        0x08    /* just used in this file */
00319 #define IPV6_ADDR_SCOPE_GLOBAL          0x0e
00320 #else
00321 #define __IPV6_ADDR_SCOPE_NODELOCAL     0x01
00322 #define __IPV6_ADDR_SCOPE_INTFACELOCAL  0x01
00323 #define __IPV6_ADDR_SCOPE_LINKLOCAL     0x02
00324 #define __IPV6_ADDR_SCOPE_SITELOCAL     0x05
00325 #define __IPV6_ADDR_SCOPE_ORGLOCAL      0x08    /* just used in this file */
00326 #define __IPV6_ADDR_SCOPE_GLOBAL        0x0e
00327 #endif
00328 
00329 /*
00330  * Unicast Scope
00331  * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
00332  */
00333 #define IN6_IS_ADDR_LINKLOCAL(a)        \
00334         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
00335 #define IN6_IS_ADDR_SITELOCAL(a)        \
00336         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
00337 
00338 /*
00339  * Multicast
00340  */
00341 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
00342 
00343 #ifdef _KERNEL  /* XXX nonstandard */
00344 #define IPV6_ADDR_MC_SCOPE(a)           ((a)->s6_addr[1] & 0x0f)
00345 #else
00346 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
00347 #endif
00348 
00349 /*
00350  * Multicast Scope
00351  */
00352 #ifdef _KERNEL  /* refers nonstandard items */
00353 #define IN6_IS_ADDR_MC_NODELOCAL(a)     \
00354         (IN6_IS_ADDR_MULTICAST(a) &&    \
00355          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
00356 #define IN6_IS_ADDR_MC_INTFACELOCAL(a)  \
00357         (IN6_IS_ADDR_MULTICAST(a) &&    \
00358          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
00359 #define IN6_IS_ADDR_MC_LINKLOCAL(a)     \
00360         (IN6_IS_ADDR_MULTICAST(a) &&    \
00361          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
00362 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
00363         (IN6_IS_ADDR_MULTICAST(a) &&    \
00364          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
00365 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
00366         (IN6_IS_ADDR_MULTICAST(a) &&    \
00367          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
00368 #define IN6_IS_ADDR_MC_GLOBAL(a)        \
00369         (IN6_IS_ADDR_MULTICAST(a) &&    \
00370          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
00371 #else
00372 #define IN6_IS_ADDR_MC_NODELOCAL(a)     \
00373         (IN6_IS_ADDR_MULTICAST(a) &&    \
00374          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
00375 #define IN6_IS_ADDR_MC_LINKLOCAL(a)     \
00376         (IN6_IS_ADDR_MULTICAST(a) &&    \
00377          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
00378 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
00379         (IN6_IS_ADDR_MULTICAST(a) &&    \
00380          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
00381 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
00382         (IN6_IS_ADDR_MULTICAST(a) &&    \
00383          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
00384 #define IN6_IS_ADDR_MC_GLOBAL(a)        \
00385         (IN6_IS_ADDR_MULTICAST(a) &&    \
00386          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
00387 #endif
00388 
00389 #ifdef _KERNEL  /* nonstandard */
00390 /*
00391  * KAME Scope
00392  */
00393 #define IN6_IS_SCOPE_LINKLOCAL(a)       \
00394         ((IN6_IS_ADDR_LINKLOCAL(a)) ||  \
00395          (IN6_IS_ADDR_MC_LINKLOCAL(a)))
00396 
00397 #define IFA6_IS_DEPRECATED(a) \
00398         ((a)->ia6_lifetime.ia6t_preferred != 0 && \
00399          (a)->ia6_lifetime.ia6t_preferred < time_second)
00400 #define IFA6_IS_INVALID(a) \
00401         ((a)->ia6_lifetime.ia6t_expire != 0 && \
00402          (a)->ia6_lifetime.ia6t_expire < time_second)
00403 #endif /* _KERNEL */
00404 
00405 /*
00406  * IP6 route structure
00407  */
00408 #if __BSD_VISIBLE
00409 struct route_in6 {
00410         struct  rtentry *ro_rt;
00411         struct  sockaddr_in6 ro_dst;
00412 };
00413 #endif
00414 
00415 /*
00416  * Options for use with [gs]etsockopt at the IPV6 level.
00417  * First word of comment is data type; bool is stored in int.
00418  */
00419 /* no hdrincl */
00420 #if 0 /* the followings are relic in IPv4 and hence are disabled */
00421 #define IPV6_OPTIONS            1  /* buf/ip6_opts; set/get IP6 options */
00422 #define IPV6_RECVOPTS           5  /* bool; receive all IP6 opts w/dgram */
00423 #define IPV6_RECVRETOPTS        6  /* bool; receive IP6 opts for response */
00424 #define IPV6_RECVDSTADDR        7  /* bool; receive IP6 dst addr w/dgram */
00425 #define IPV6_RETOPTS            8  /* ip6_opts; set/get IP6 options */
00426 #endif
00427 #define IPV6_SOCKOPT_RESERVED1  3  /* reserved for future use */
00428 #define IPV6_UNICAST_HOPS       4  /* int; IP6 hops */
00429 #define IPV6_MULTICAST_IF       9  /* u_int; set/get IP6 multicast i/f  */
00430 #define IPV6_MULTICAST_HOPS     10 /* int; set/get IP6 multicast hops */
00431 #define IPV6_MULTICAST_LOOP     11 /* u_int; set/get IP6 multicast loopback */
00432 #define IPV6_JOIN_GROUP         12 /* ip6_mreq; join a group membership */
00433 #define IPV6_LEAVE_GROUP        13 /* ip6_mreq; leave a group membership */
00434 #define IPV6_PORTRANGE          14 /* int; range to choose for unspec port */
00435 #define ICMP6_FILTER            18 /* icmp6_filter; icmp6 filter */
00436 /* RFC2292 options */
00437 #ifdef _KERNEL
00438 #define IPV6_2292PKTINFO        19 /* bool; send/recv if, src/dst addr */
00439 #define IPV6_2292HOPLIMIT       20 /* bool; hop limit */
00440 #define IPV6_2292NEXTHOP        21 /* bool; next hop addr */
00441 #define IPV6_2292HOPOPTS        22 /* bool; hop-by-hop option */
00442 #define IPV6_2292DSTOPTS        23 /* bool; destinaion option */
00443 #define IPV6_2292RTHDR          24 /* bool; routing header */
00444 #define IPV6_2292PKTOPTIONS     25 /* buf/cmsghdr; set/get IPv6 options */
00445 #endif
00446 
00447 #define IPV6_CHECKSUM           26 /* int; checksum offset for raw socket */
00448 #define IPV6_V6ONLY             27 /* bool; make AF_INET6 sockets v6 only */
00449 #ifndef _KERNEL
00450 #define IPV6_BINDV6ONLY         IPV6_V6ONLY
00451 #endif
00452 
00453 #if 1 /* IPSEC */
00454 #define IPV6_IPSEC_POLICY       28 /* struct; get/set security policy */
00455 #endif
00456 #define IPV6_FAITH              29 /* bool; accept FAITH'ed connections */
00457 
00458 #if 1 /* IPV6FIREWALL */
00459 #define IPV6_FW_ADD             30 /* add a firewall rule to chain */
00460 #define IPV6_FW_DEL             31 /* delete a firewall rule from chain */
00461 #define IPV6_FW_FLUSH           32 /* flush firewall rule chain */
00462 #define IPV6_FW_ZERO            33 /* clear single/all firewall counter(s) */
00463 #define IPV6_FW_GET             34 /* get entire firewall rule chain */
00464 #endif
00465 
00466 /* new socket options introduced in RFC3542 */
00467 #define IPV6_RTHDRDSTOPTS       35 /* ip6_dest; send dst option before rthdr */
00468 
00469 #define IPV6_RECVPKTINFO        36 /* bool; recv if, dst addr */
00470 #define IPV6_RECVHOPLIMIT       37 /* bool; recv hop limit */
00471 #define IPV6_RECVRTHDR          38 /* bool; recv routing header */
00472 #define IPV6_RECVHOPOPTS        39 /* bool; recv hop-by-hop option */
00473 #define IPV6_RECVDSTOPTS        40 /* bool; recv dst option after rthdr */
00474 #ifdef _KERNEL
00475 #define IPV6_RECVRTHDRDSTOPTS   41 /* bool; recv dst option before rthdr */
00476 #endif
00477 
00478 #define IPV6_USE_MIN_MTU        42 /* bool; send packets at the minimum MTU */
00479 #define IPV6_RECVPATHMTU        43 /* bool; notify an according MTU */
00480 
00481 #define IPV6_PATHMTU            44 /* mtuinfo; get the current path MTU (sopt),
00482                                       4 bytes int; MTU notification (cmsg) */
00483 #if 0 /*obsoleted during 2292bis -> 3542*/
00484 #define IPV6_REACHCONF          45 /* no data; ND reachability confirm
00485                                       (cmsg only/not in of RFC3542) */
00486 #endif
00487 
00488 /* more new socket options introduced in RFC3542 */
00489 #define IPV6_PKTINFO            46 /* in6_pktinfo; send if, src addr */
00490 #define IPV6_HOPLIMIT           47 /* int; send hop limit */
00491 #define IPV6_NEXTHOP            48 /* sockaddr; next hop addr */
00492 #define IPV6_HOPOPTS            49 /* ip6_hbh; send hop-by-hop option */
00493 #define IPV6_DSTOPTS            50 /* ip6_dest; send dst option befor rthdr */
00494 #define IPV6_RTHDR              51 /* ip6_rthdr; send routing header */
00495 #if 0
00496 #define IPV6_PKTOPTIONS         52 /* buf/cmsghdr; set/get IPv6 options */
00497                                    /* obsoleted by RFC3542 */
00498 #endif
00499 
00500 #define IPV6_RECVTCLASS         57 /* bool; recv traffic class values */
00501 
00502 #define IPV6_AUTOFLOWLABEL      59 /* bool; attach flowlabel automagically */
00503 
00504 #define IPV6_TCLASS             61 /* int; send traffic class value */
00505 #define IPV6_DONTFRAG           62 /* bool; disable IPv6 fragmentation */
00506 
00507 #define IPV6_PREFER_TEMPADDR    63 /* int; prefer temporary addresses as
00508                                     * the source address.
00509                                     */
00510 
00511 /* to define items, should talk with KAME guys first, for *BSD compatibility */
00512 
00513 #define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
00514 #define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
00515 #define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
00516 
00517 /*
00518  * Defaults and limits for options
00519  */
00520 #define IPV6_DEFAULT_MULTICAST_HOPS 1   /* normally limit m'casts to 1 hop */
00521 #define IPV6_DEFAULT_MULTICAST_LOOP 1   /* normally hear sends if a member */
00522 
00523 /*
00524  * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
00525  */
00526 struct ipv6_mreq {
00527         struct in6_addr ipv6mr_multiaddr;
00528         unsigned int    ipv6mr_interface;
00529 };
00530 
00531 /*
00532  * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
00533  */
00534 struct in6_pktinfo {
00535         struct in6_addr ipi6_addr;      /* src/dst IPv6 address */
00536         unsigned int    ipi6_ifindex;   /* send/recv interface index */
00537 };
00538 
00539 /*
00540  * Control structure for IPV6_RECVPATHMTU socket option.
00541  */
00542 struct ip6_mtuinfo {
00543         struct sockaddr_in6 ip6m_addr;  /* or sockaddr_storage? */
00544         uint32_t ip6m_mtu;
00545 };
00546 
00547 /*
00548  * Argument for IPV6_PORTRANGE:
00549  * - which range to search when port is unspecified at bind() or connect()
00550  */
00551 #define IPV6_PORTRANGE_DEFAULT  0       /* default range */
00552 #define IPV6_PORTRANGE_HIGH     1       /* "high" - request firewall bypass */
00553 #define IPV6_PORTRANGE_LOW      2       /* "low" - vouchsafe security */
00554 
00555 #if __BSD_VISIBLE
00556 /*
00557  * Definitions for inet6 sysctl operations.
00558  *
00559  * Third level is protocol number.
00560  * Fourth level is desired variable within that protocol.
00561  */
00562 #define IPV6PROTO_MAXID (IPPROTO_PIM + 1)       /* don't list to IPV6PROTO_MAX */
00563 
00564 /*
00565  * Names for IP sysctl objects
00566  */
00567 #define IPV6CTL_FORWARDING      1       /* act as router */
00568 #define IPV6CTL_SENDREDIRECTS   2       /* may send redirects when forwarding*/
00569 #define IPV6CTL_DEFHLIM         3       /* default Hop-Limit */
00570 #ifdef notyet
00571 #define IPV6CTL_DEFMTU          4       /* default MTU */
00572 #endif
00573 #define IPV6CTL_FORWSRCRT       5       /* forward source-routed dgrams */
00574 #define IPV6CTL_STATS           6       /* stats */
00575 #define IPV6CTL_MRTSTATS        7       /* multicast forwarding stats */
00576 #define IPV6CTL_MRTPROTO        8       /* multicast routing protocol */
00577 #define IPV6CTL_MAXFRAGPACKETS  9       /* max packets reassembly queue */
00578 #define IPV6CTL_SOURCECHECK     10      /* verify source route and intf */
00579 #define IPV6CTL_SOURCECHECK_LOGINT 11   /* minimume logging interval */
00580 #define IPV6CTL_ACCEPT_RTADV    12
00581 #define IPV6CTL_KEEPFAITH       13
00582 #define IPV6CTL_LOG_INTERVAL    14
00583 #define IPV6CTL_HDRNESTLIMIT    15
00584 #define IPV6CTL_DAD_COUNT       16
00585 #define IPV6CTL_AUTO_FLOWLABEL  17
00586 #define IPV6CTL_DEFMCASTHLIM    18
00587 #define IPV6CTL_GIF_HLIM        19      /* default HLIM for gif encap packet */
00588 #define IPV6CTL_KAME_VERSION    20
00589 #define IPV6CTL_USE_DEPRECATED  21      /* use deprecated addr (RFC2462 5.5.4) */
00590 #define IPV6CTL_RR_PRUNE        22      /* walk timer for router renumbering */
00591 #if 0   /* obsolete */
00592 #define IPV6CTL_MAPPED_ADDR     23
00593 #endif
00594 #define IPV6CTL_V6ONLY          24
00595 #define IPV6CTL_RTEXPIRE        25      /* cloned route expiration time */
00596 #define IPV6CTL_RTMINEXPIRE     26      /* min value for expiration time */
00597 #define IPV6CTL_RTMAXCACHE      27      /* trigger level for dynamic expire */
00598 
00599 #define IPV6CTL_USETEMPADDR     32      /* use temporary addresses (RFC3041) */
00600 #define IPV6CTL_TEMPPLTIME      33      /* preferred lifetime for tmpaddrs */
00601 #define IPV6CTL_TEMPVLTIME      34      /* valid lifetime for tmpaddrs */
00602 #define IPV6CTL_AUTO_LINKLOCAL  35      /* automatic link-local addr assign */
00603 #define IPV6CTL_RIP6STATS       36      /* raw_ip6 stats */
00604 #define IPV6CTL_PREFER_TEMPADDR 37      /* prefer temporary addr as src */
00605 #define IPV6CTL_ADDRCTLPOLICY   38      /* get/set address selection policy */
00606 
00607 #define IPV6CTL_MAXFRAGS        41      /* max fragments */
00608 
00609 /* New entries should be added here from current IPV6CTL_MAXID value. */
00610 /* to define items, should talk with KAME guys first, for *BSD compatibility */
00611 /* 42-44 is already used in KAME */
00612 #define IPV6CTL_STEALTH         45
00613 #define IPV6CTL_MAXID           46
00614 #endif /* __BSD_VISIBLE */
00615 
00616 /*
00617  * Redefinition of mbuf flags
00618  */
00619 #define M_AUTHIPHDR     M_PROTO2
00620 #define M_DECRYPTED     M_PROTO3
00621 #define M_LOOP          M_PROTO4
00622 #define M_AUTHIPDGM     M_PROTO5
00623 
00624 #ifdef _KERNEL
00625 struct cmsghdr;
00626 
00627 struct sockaddr;
00628 extern  u_char  ip6_protox[];
00629 #define satosin6(sa)    ((struct sockaddr_in6 *)(sa))
00630 #define sin6tosa(sin6)  ((struct sockaddr *)(sin6))
00631 #define ifatoia6(ifa)   ((struct in6_ifaddr *)(ifa))
00632 
00633 extern int      (*faithprefix_p)(struct in6_addr *);
00634 #endif /* _KERNEL */
00635 
00636 #ifndef _SIZE_T_DECLARED
00637 typedef __size_t        size_t;
00638 #define _SIZE_T_DECLARED
00639 #endif
00640 
00641 #ifndef _SOCKLEN_T_DECLARED
00642 typedef __socklen_t     socklen_t;
00643 #define _SOCKLEN_T_DECLARED
00644 #endif
00645 
00646 #if __BSD_VISIBLE
00647 
00648 __BEGIN_DECLS
00649 struct cmsghdr;
00650 __END_DECLS
00651 
00652 #endif /* __BSD_VISIBLE */
00653 
00654 #endif /* !_NETINET6_IN6_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top