The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet6/in6.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: in6.h,v 1.57 2006/10/31 00:29:30 cbiere Exp $  */
    2 /*      $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $    */
    3 
    4 /*
    5  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Neither the name of the project nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1982, 1986, 1990, 1993
   35  *      The Regents of the University of California.  All rights reserved.
   36  *
   37  * Redistribution and use in source and binary forms, with or without
   38  * modification, are permitted provided that the following conditions
   39  * are met:
   40  * 1. Redistributions of source code must retain the above copyright
   41  *    notice, this list of conditions and the following disclaimer.
   42  * 2. Redistributions in binary form must reproduce the above copyright
   43  *    notice, this list of conditions and the following disclaimer in the
   44  *    documentation and/or other materials provided with the distribution.
   45  * 3. Neither the name of the University nor the names of its contributors
   46  *    may be used to endorse or promote products derived from this software
   47  *    without specific prior written permission.
   48  *
   49  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   50  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   51  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   52  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   53  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   54  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   55  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   56  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   57  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   58  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   59  * SUCH DAMAGE.
   60  *
   61  *      @(#)in.h        8.3 (Berkeley) 1/3/94
   62  */
   63 
   64 #ifndef _NETINET6_IN6_H_
   65 #define _NETINET6_IN6_H_
   66 
   67 #ifndef __KAME_NETINET_IN_H_INCLUDED_
   68 #error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
   69 #endif
   70 
   71 #include <sys/socket.h>
   72 
   73 /*
   74  * Identification of the network protocol stack
   75  * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
   76  * has the table of implementation/integration differences.
   77  */
   78 #define __KAME__
   79 #define __KAME_VERSION          "NetBSD-current"
   80 
   81 /*
   82  * Local port number conventions:
   83  *
   84  * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
   85  * unless a kernel is compiled with IPNOPRIVPORTS defined.
   86  *
   87  * When a user does a bind(2) or connect(2) with a port number of zero,
   88  * a non-conflicting local port address is chosen.
   89  *
   90  * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
   91  * that is settable by sysctl(3); net.inet.ip.anonportmin and
   92  * net.inet.ip.anonportmax respectively.
   93  *
   94  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
   95  * default assignment range.
   96  *
   97  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
   98  *
   99  * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
  100  * and exists only for FreeBSD compatibility purposes.
  101  *
  102  * The value IP_PORTRANGE_LOW changes the range to the "low" are
  103  * that is (by convention) restricted to privileged processes.
  104  * This convention is based on "vouchsafe" principles only.
  105  * It is only secure if you trust the remote host to restrict these ports.
  106  * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
  107  */
  108 
  109 #if defined(_NETBSD_SOURCE)
  110 #define IPV6PORT_RESERVED       1024
  111 #define IPV6PORT_ANONMIN        49152
  112 #define IPV6PORT_ANONMAX        65535
  113 #define IPV6PORT_RESERVEDMIN    600
  114 #define IPV6PORT_RESERVEDMAX    (IPV6PORT_RESERVED-1)
  115 #endif
  116 
  117 /*
  118  * IPv6 address
  119  */
  120 struct in6_addr {
  121         union {
  122                 __uint8_t   __u6_addr8[16];
  123                 __uint16_t  __u6_addr16[8];
  124                 uint32_t  __u6_addr32[4];
  125         } __u6_addr;                    /* 128-bit IP6 address */
  126 };
  127 
  128 #define s6_addr   __u6_addr.__u6_addr8
  129 #ifdef _KERNEL  /* XXX nonstandard */
  130 #define s6_addr8  __u6_addr.__u6_addr8
  131 #define s6_addr16 __u6_addr.__u6_addr16
  132 #define s6_addr32 __u6_addr.__u6_addr32
  133 #endif
  134 
  135 #define INET6_ADDRSTRLEN        46
  136 
  137 /*
  138  * Socket address for IPv6
  139  */
  140 #if defined(_NETBSD_SOURCE)
  141 #define SIN6_LEN
  142 #endif
  143 struct sockaddr_in6 {
  144         uint8_t         sin6_len;       /* length of this struct(socklen_t)*/
  145         sa_family_t     sin6_family;    /* AF_INET6 (sa_family_t) */
  146         in_port_t       sin6_port;      /* Transport layer port */
  147         uint32_t        sin6_flowinfo;  /* IP6 flow information */
  148         struct in6_addr sin6_addr;      /* IP6 address */
  149         uint32_t        sin6_scope_id;  /* scope zone index */
  150 };
  151 
  152 /*
  153  * Local definition for masks
  154  */
  155 #ifdef _KERNEL  /* XXX nonstandard */
  156 #define IN6MASK0        {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
  157 #define IN6MASK32       {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
  158                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  159 #define IN6MASK64       {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  160                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  161 #define IN6MASK96       {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  162                             0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
  163 #define IN6MASK128      {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  164                             0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
  165 #endif
  166 
  167 #ifdef _KERNEL
  168 extern const struct sockaddr_in6 sa6_any;
  169 
  170 extern const struct in6_addr in6mask0;
  171 extern const struct in6_addr in6mask32;
  172 extern const struct in6_addr in6mask64;
  173 extern const struct in6_addr in6mask96;
  174 extern const struct in6_addr in6mask128;
  175 #endif /* _KERNEL */
  176 
  177 /*
  178  * Macros started with IPV6_ADDR is KAME local
  179  */
  180 #ifdef _KERNEL  /* XXX nonstandard */
  181 #if BYTE_ORDER == BIG_ENDIAN
  182 #define IPV6_ADDR_INT32_ONE     1
  183 #define IPV6_ADDR_INT32_TWO     2
  184 #define IPV6_ADDR_INT32_MNL     0xff010000
  185 #define IPV6_ADDR_INT32_MLL     0xff020000
  186 #define IPV6_ADDR_INT32_SMP     0x0000ffff
  187 #define IPV6_ADDR_INT16_ULL     0xfe80
  188 #define IPV6_ADDR_INT16_USL     0xfec0
  189 #define IPV6_ADDR_INT16_MLL     0xff02
  190 #elif BYTE_ORDER == LITTLE_ENDIAN
  191 #define IPV6_ADDR_INT32_ONE     0x01000000
  192 #define IPV6_ADDR_INT32_TWO     0x02000000
  193 #define IPV6_ADDR_INT32_MNL     0x000001ff
  194 #define IPV6_ADDR_INT32_MLL     0x000002ff
  195 #define IPV6_ADDR_INT32_SMP     0xffff0000
  196 #define IPV6_ADDR_INT16_ULL     0x80fe
  197 #define IPV6_ADDR_INT16_USL     0xc0fe
  198 #define IPV6_ADDR_INT16_MLL     0x02ff
  199 #endif
  200 #endif
  201 
  202 /*
  203  * Definition of some useful macros to handle IP6 addresses
  204  */
  205 #define IN6ADDR_ANY_INIT \
  206         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  207             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  208 #define IN6ADDR_LOOPBACK_INIT \
  209         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  210             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  211 #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
  212         {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  213             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  214 #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
  215         {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  216             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  217 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
  218         {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  219             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
  220 
  221 extern const struct in6_addr in6addr_any;
  222 extern const struct in6_addr in6addr_loopback;
  223 extern const struct in6_addr in6addr_nodelocal_allnodes;
  224 extern const struct in6_addr in6addr_linklocal_allnodes;
  225 extern const struct in6_addr in6addr_linklocal_allrouters;
  226 
  227 /*
  228  * Equality
  229  * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
  230  * does not supply memcmp().  For userland memcmp() is preferred as it is
  231  * in ANSI standard.
  232  */
  233 #ifdef _KERNEL
  234 #define IN6_ARE_ADDR_EQUAL(a, b)                        \
  235     (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
  236 #else
  237 #define IN6_ARE_ADDR_EQUAL(a, b)                        \
  238     (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
  239 #endif
  240 
  241 /*
  242  * Unspecified
  243  */
  244 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
  245         ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&  \
  246          (*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&  \
  247          (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&  \
  248          (*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
  249 
  250 /*
  251  * Loopback
  252  */
  253 #define IN6_IS_ADDR_LOOPBACK(a)         \
  254         ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&  \
  255          (*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&  \
  256          (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&  \
  257          (*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
  258 
  259 /*
  260  * IPv4 compatible
  261  */
  262 #define IN6_IS_ADDR_V4COMPAT(a)         \
  263         ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&  \
  264          (*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&  \
  265          (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&  \
  266          (*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \
  267          (*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
  268 
  269 /*
  270  * Mapped
  271  */
  272 #define IN6_IS_ADDR_V4MAPPED(a)               \
  273         ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&  \
  274          (*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&  \
  275          (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
  276 
  277 /*
  278  * KAME Scope Values
  279  */
  280 
  281 #ifdef _KERNEL  /* XXX nonstandard */
  282 #define IPV6_ADDR_SCOPE_NODELOCAL       0x01
  283 #define IPV6_ADDR_SCOPE_INTFACELOCAL    0x01
  284 #define IPV6_ADDR_SCOPE_LINKLOCAL       0x02
  285 #define IPV6_ADDR_SCOPE_SITELOCAL       0x05
  286 #define IPV6_ADDR_SCOPE_ORGLOCAL        0x08    /* just used in this file */
  287 #define IPV6_ADDR_SCOPE_GLOBAL          0x0e
  288 #else
  289 #define __IPV6_ADDR_SCOPE_NODELOCAL     0x01
  290 #define __IPV6_ADDR_SCOPE_LINKLOCAL     0x02
  291 #define __IPV6_ADDR_SCOPE_SITELOCAL     0x05
  292 #define __IPV6_ADDR_SCOPE_ORGLOCAL      0x08    /* just used in this file */
  293 #define __IPV6_ADDR_SCOPE_GLOBAL        0x0e
  294 #endif
  295 
  296 /*
  297  * Unicast Scope
  298  * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
  299  */
  300 #define IN6_IS_ADDR_LINKLOCAL(a)        \
  301         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
  302 #define IN6_IS_ADDR_SITELOCAL(a)        \
  303         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
  304 
  305 /*
  306  * Multicast
  307  */
  308 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
  309 
  310 #ifdef _KERNEL  /* XXX nonstandard */
  311 #define IPV6_ADDR_MC_SCOPE(a)           ((a)->s6_addr[1] & 0x0f)
  312 #else
  313 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
  314 #endif
  315 
  316 /*
  317  * Multicast Scope
  318  */
  319 #ifdef _KERNEL  /* refers nonstandard items */
  320 #define IN6_IS_ADDR_MC_NODELOCAL(a)     \
  321         (IN6_IS_ADDR_MULTICAST(a) &&    \
  322          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
  323 #define IN6_IS_ADDR_MC_INTFACELOCAL(a)  \
  324         (IN6_IS_ADDR_MULTICAST(a) &&    \
  325          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
  326 #define IN6_IS_ADDR_MC_LINKLOCAL(a)     \
  327         (IN6_IS_ADDR_MULTICAST(a) &&    \
  328          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
  329 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
  330         (IN6_IS_ADDR_MULTICAST(a) &&    \
  331          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
  332 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
  333         (IN6_IS_ADDR_MULTICAST(a) &&    \
  334          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
  335 #define IN6_IS_ADDR_MC_GLOBAL(a)        \
  336         (IN6_IS_ADDR_MULTICAST(a) &&    \
  337          (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
  338 #else
  339 #define IN6_IS_ADDR_MC_NODELOCAL(a)     \
  340         (IN6_IS_ADDR_MULTICAST(a) &&    \
  341          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
  342 #define IN6_IS_ADDR_MC_LINKLOCAL(a)     \
  343         (IN6_IS_ADDR_MULTICAST(a) &&    \
  344          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
  345 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
  346         (IN6_IS_ADDR_MULTICAST(a) &&    \
  347          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
  348 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
  349         (IN6_IS_ADDR_MULTICAST(a) &&    \
  350          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
  351 #define IN6_IS_ADDR_MC_GLOBAL(a)        \
  352         (IN6_IS_ADDR_MULTICAST(a) &&    \
  353          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
  354 #endif
  355 
  356 #ifdef _KERNEL  /* nonstandard */
  357 /*
  358  * KAME Scope
  359  */
  360 #define IN6_IS_SCOPE_LINKLOCAL(a)       \
  361         ((IN6_IS_ADDR_LINKLOCAL(a)) ||  \
  362          (IN6_IS_ADDR_MC_LINKLOCAL(a)))
  363 
  364 #define IN6_IS_SCOPE_EMBEDDABLE(__a)    \
  365     (IN6_IS_SCOPE_LINKLOCAL(__a) || IN6_IS_ADDR_MC_INTFACELOCAL(__a))
  366 
  367 #define IFA6_IS_DEPRECATED(a) \
  368         ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
  369          (u_int32_t)((time_second - (a)->ia6_updatetime)) > \
  370          (a)->ia6_lifetime.ia6t_pltime)
  371 #define IFA6_IS_INVALID(a) \
  372         ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
  373          (u_int32_t)((time_second - (a)->ia6_updatetime)) > \
  374          (a)->ia6_lifetime.ia6t_vltime)
  375 #endif
  376 
  377 /*
  378  * IP6 route structure
  379  */
  380 #if defined(_NETBSD_SOURCE)
  381 struct route_in6 {
  382         struct  rtentry *ro_rt;
  383         struct  sockaddr_in6 ro_dst;
  384 };
  385 #endif
  386 
  387 /*
  388  * Options for use with [gs]etsockopt at the IPV6 level.
  389  * First word of comment is data type; bool is stored in int.
  390  */
  391 /* no hdrincl */
  392 #if 0
  393 /* These are deprecated non-standard options which are no longer supported. */
  394 #define IPV6_OPTIONS            1  /* buf/ip6_opts; set/get IP6 options */
  395 #define IPV6_RECVOPTS           5  /* bool; receive all IP6 opts w/dgram */
  396 #define IPV6_RECVRETOPTS        6  /* bool; receive IP6 opts for response */
  397 #define IPV6_RECVDSTADDR        7  /* bool; receive IP6 dst addr w/dgram */
  398 #define IPV6_RETOPTS            8  /* ip6_opts; set/get IP6 options */
  399 #endif
  400 #define IPV6_SOCKOPT_RESERVED1  3  /* reserved for future use */
  401 #define IPV6_UNICAST_HOPS       4  /* int; IP6 hops */
  402 #define IPV6_MULTICAST_IF       9  /* u_int; set/get IP6 multicast i/f  */
  403 #define IPV6_MULTICAST_HOPS     10 /* int; set/get IP6 multicast hops */
  404 #define IPV6_MULTICAST_LOOP     11 /* u_int; set/get IP6 multicast loopback */
  405 #define IPV6_JOIN_GROUP         12 /* ip6_mreq; join a group membership */
  406 #define IPV6_LEAVE_GROUP        13 /* ip6_mreq; leave a group membership */
  407 #define IPV6_PORTRANGE          14 /* int; range to choose for unspec port */
  408 #if defined(_NETBSD_SOURCE)
  409 #define ICMP6_FILTER            18 /* icmp6_filter; icmp6 filter */
  410 #endif
  411 /* RFC2292 options */
  412 #ifdef _KERNEL
  413 #define IPV6_2292PKTINFO        19 /* bool; send/recv if, src/dst addr */
  414 #define IPV6_2292HOPLIMIT       20 /* bool; hop limit */
  415 #define IPV6_2292NEXTHOP        21 /* bool; next hop addr */
  416 #define IPV6_2292HOPOPTS        22 /* bool; hop-by-hop option */
  417 #define IPV6_2292DSTOPTS        23 /* bool; destinaion option */
  418 #define IPV6_2292RTHDR          24 /* bool; routing header */
  419 #define IPV6_2292PKTOPTIONS     25 /* buf/cmsghdr; set/get IPv6 options */
  420 #endif
  421 #define IPV6_CHECKSUM           26 /* int; checksum offset for raw socket */
  422 #define IPV6_V6ONLY             27 /* bool; make AF_INET6 sockets v6 only */
  423 
  424 #if 1 /* IPSEC */
  425 #define IPV6_IPSEC_POLICY       28 /* struct; get/set security policy */
  426 #endif
  427 #define IPV6_FAITH              29 /* bool; accept FAITH'ed connections */
  428 
  429 /* new socket options introduced in RFC3542 */
  430 #define IPV6_RTHDRDSTOPTS       35 /* ip6_dest; send dst option before rthdr */
  431 
  432 #define IPV6_RECVPKTINFO        36 /* bool; recv if, dst addr */
  433 #define IPV6_RECVHOPLIMIT       37 /* bool; recv hop limit */
  434 #define IPV6_RECVRTHDR          38 /* bool; recv routing header */
  435 #define IPV6_RECVHOPOPTS        39 /* bool; recv hop-by-hop option */
  436 #define IPV6_RECVDSTOPTS        40 /* bool; recv dst option after rthdr */
  437 #ifdef _KERNEL
  438 #define IPV6_RECVRTHDRDSTOPTS   41 /* bool; recv dst option before rthdr */
  439 #endif
  440 #define IPV6_USE_MIN_MTU        42 /* bool; send packets at the minimum MTU */
  441 #define IPV6_RECVPATHMTU        43 /* bool; notify an according MTU */
  442 #define IPV6_PATHMTU            44 /* mtuinfo; get the current path MTU (sopt),
  443                                       4 bytes int; MTU notification (cmsg) */
  444 
  445 /* more new socket options introduced in RFC3542 */
  446 #define IPV6_PKTINFO            46 /* in6_pktinfo; send if, src addr */
  447 #define IPV6_HOPLIMIT           47 /* int; send hop limit */
  448 #define IPV6_NEXTHOP            48 /* sockaddr; next hop addr */
  449 #define IPV6_HOPOPTS            49 /* ip6_hbh; send hop-by-hop option */
  450 #define IPV6_DSTOPTS            50 /* ip6_dest; send dst option befor rthdr */
  451 #define IPV6_RTHDR              51 /* ip6_rthdr; send routing header */
  452 
  453 #define IPV6_RECVTCLASS         57 /* bool; recv traffic class values */
  454 #ifdef _KERNEL
  455 #define IPV6_OTCLASS            58 /* u_int8_t; send traffic class value */
  456 #endif
  457 
  458 #define IPV6_TCLASS             61 /* int; send traffic class value */
  459 #define IPV6_DONTFRAG           62 /* bool; disable IPv6 fragmentation */
  460 /* to define items, should talk with KAME guys first, for *BSD compatibility */
  461 
  462 #define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
  463 #define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
  464 #define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
  465 
  466 /*
  467  * Defaults and limits for options
  468  */
  469 #define IPV6_DEFAULT_MULTICAST_HOPS 1   /* normally limit m'casts to 1 hop  */
  470 #define IPV6_DEFAULT_MULTICAST_LOOP 1   /* normally hear sends if a member  */
  471 
  472 /*
  473  * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
  474  */
  475 struct ipv6_mreq {
  476         struct in6_addr ipv6mr_multiaddr;
  477         unsigned int    ipv6mr_interface;
  478 };
  479 
  480 /*
  481  * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
  482  */
  483 struct in6_pktinfo {
  484         struct in6_addr ipi6_addr;      /* src/dst IPv6 address */
  485         unsigned int    ipi6_ifindex;   /* send/recv interface index */
  486 };
  487 
  488 /*
  489  * Control structure for IPV6_RECVPATHMTU socket option.
  490  */
  491 struct ip6_mtuinfo {
  492         struct sockaddr_in6 ip6m_addr;  /* or sockaddr_storage? */
  493         uint32_t ip6m_mtu;
  494 };
  495 
  496 /*
  497  * Argument for IPV6_PORTRANGE:
  498  * - which range to search when port is unspecified at bind() or connect()
  499  */
  500 #define IPV6_PORTRANGE_DEFAULT  0       /* default range */
  501 #define IPV6_PORTRANGE_HIGH     1       /* "high" - request firewall bypass */
  502 #define IPV6_PORTRANGE_LOW      2       /* "low" - vouchsafe security */
  503 
  504 #if defined(_NETBSD_SOURCE)
  505 /*
  506  * Definitions for inet6 sysctl operations.
  507  *
  508  * Third level is protocol number.
  509  * Fourth level is desired variable within that protocol.
  510  */
  511 #define IPV6PROTO_MAXID (IPPROTO_PIM + 1)       /* don't list to IPV6PROTO_MAX */
  512 
  513 #define CTL_IPV6PROTO_NAMES { \
  514         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  515         { 0, 0 }, \
  516         { "tcp6", CTLTYPE_NODE }, \
  517         { 0, 0 }, \
  518         { 0, 0 }, \
  519         { 0, 0 }, \
  520         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  521         { 0, 0 }, \
  522         { 0, 0 }, \
  523         { "udp6", CTLTYPE_NODE }, \
  524         { 0, 0 }, \
  525         { 0, 0 }, \
  526         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  527         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  528         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  529         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  530         { 0, 0 }, \
  531         { "ip6", CTLTYPE_NODE }, \
  532         { 0, 0 }, \
  533         { 0, 0 }, \
  534         { 0, 0 }, \
  535         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  536         { 0, 0 }, \
  537         { "ipsec6", CTLTYPE_NODE }, \
  538         { 0, 0 }, \
  539         { 0, 0 }, \
  540         { 0, 0 }, \
  541         { 0, 0 }, \
  542         { 0, 0 }, \
  543         { 0, 0 }, \
  544         { "icmp6", CTLTYPE_NODE }, \
  545         { 0, 0 }, \
  546         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  547         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  548         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  549         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  550         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  551         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  552         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  553         { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  554         { 0, 0 }, \
  555         { 0, 0 }, \
  556         { 0, 0 }, \
  557         { "pim6", CTLTYPE_NODE }, \
  558 }
  559 
  560 /*
  561  * Names for IP sysctl objects
  562  */
  563 #define IPV6CTL_FORWARDING      1       /* act as router */
  564 #define IPV6CTL_SENDREDIRECTS   2       /* may send redirects when forwarding*/
  565 #define IPV6CTL_DEFHLIM         3       /* default Hop-Limit */
  566 #ifdef notyet
  567 #define IPV6CTL_DEFMTU          4       /* default MTU */
  568 #endif
  569 #define IPV6CTL_FORWSRCRT       5       /* forward source-routed dgrams */
  570 #define IPV6CTL_STATS           6       /* stats */
  571 #define IPV6CTL_MRTSTATS        7       /* multicast forwarding stats */
  572 #define IPV6CTL_MRTPROTO        8       /* multicast routing protocol */
  573 #define IPV6CTL_MAXFRAGPACKETS  9       /* max packets reassembly queue */
  574 #define IPV6CTL_SOURCECHECK     10      /* verify source route and intf */
  575 #define IPV6CTL_SOURCECHECK_LOGINT 11   /* minimume logging interval */
  576 #define IPV6CTL_ACCEPT_RTADV    12
  577 #define IPV6CTL_KEEPFAITH       13
  578 #define IPV6CTL_LOG_INTERVAL    14
  579 #define IPV6CTL_HDRNESTLIMIT    15
  580 #define IPV6CTL_DAD_COUNT       16
  581 #define IPV6CTL_AUTO_FLOWLABEL  17
  582 #define IPV6CTL_DEFMCASTHLIM    18
  583 #define IPV6CTL_GIF_HLIM        19      /* default HLIM for gif encap packet */
  584 #define IPV6CTL_KAME_VERSION    20
  585 #define IPV6CTL_USE_DEPRECATED  21      /* use deprecated addr (RFC2462 5.5.4) */
  586 #define IPV6CTL_RR_PRUNE        22      /* walk timer for router renumbering */
  587 /* 23: reserved */
  588 #define IPV6CTL_V6ONLY          24
  589 /* 25 to 27: reserved */
  590 #define IPV6CTL_ANONPORTMIN     28      /* minimum ephemeral port */
  591 #define IPV6CTL_ANONPORTMAX     29      /* maximum ephemeral port */
  592 #define IPV6CTL_LOWPORTMIN      30      /* minimum reserved port */
  593 #define IPV6CTL_LOWPORTMAX      31      /* maximum reserved port */
  594 /* 32 to 38: reserved */
  595 #define IPV6CTL_USE_DEFAULTZONE 39      /* use default scope zone */
  596 /* 40: reserved */
  597 #define IPV6CTL_MAXFRAGS        41      /* max fragments */
  598 #define IPV6CTL_IFQ             42      /* ip6intrq node */
  599 /* New entries should be added here from current IPV6CTL_MAXID value. */
  600 /* to define items, should talk with KAME guys first, for *BSD compatibility */
  601 #define IPV6CTL_MAXID           43
  602 
  603 #define IPV6CTL_NAMES { \
  604         { 0, 0 }, \
  605         { "forwarding", CTLTYPE_INT }, \
  606         { "redirect", CTLTYPE_INT }, \
  607         { "hlim", CTLTYPE_INT }, \
  608         { "mtu", CTLTYPE_INT }, \
  609         { "forwsrcrt", CTLTYPE_INT }, \
  610         { "stats", CTLTYPE_STRUCT }, \
  611         { 0, 0 }, \
  612         { "mrtproto", CTLTYPE_INT }, \
  613         { "maxfragpackets", CTLTYPE_INT }, \
  614         { "sourcecheck", CTLTYPE_INT }, \
  615         { "sourcecheck_logint", CTLTYPE_INT }, \
  616         { "accept_rtadv", CTLTYPE_INT }, \
  617         { "keepfaith", CTLTYPE_INT }, \
  618         { "log_interval", CTLTYPE_INT }, \
  619         { "hdrnestlimit", CTLTYPE_INT }, \
  620         { "dad_count", CTLTYPE_INT }, \
  621         { "auto_flowlabel", CTLTYPE_INT }, \
  622         { "defmcasthlim", CTLTYPE_INT }, \
  623         { "gifhlim", CTLTYPE_INT }, \
  624         { "kame_version", CTLTYPE_STRING }, \
  625         { "use_deprecated", CTLTYPE_INT }, \
  626         { "rr_prune", CTLTYPE_INT }, \
  627         { 0, 0 }, \
  628         { "v6only", CTLTYPE_INT }, \
  629         { 0, 0 }, \
  630         { 0, 0 }, \
  631         { 0, 0 }, \
  632         { "anonportmin", CTLTYPE_INT }, \
  633         { "anonportmax", CTLTYPE_INT }, \
  634         { "lowportmin", CTLTYPE_INT }, \
  635         { "lowportmax", CTLTYPE_INT }, \
  636         { 0, 0 }, \
  637         { 0, 0 }, \
  638         { 0, 0 }, \
  639         { 0, 0 }, \
  640         { 0, 0 }, \
  641         { 0, 0 }, \
  642         { 0, 0 }, \
  643         { 0, 0 }, \
  644         { 0, 0 }, \
  645         { "maxfrags", CTLTYPE_INT }, \
  646         { "ifq", CTLTYPE_NODE }, \
  647 }
  648 
  649 #endif /* _NETBSD_SOURCE */
  650 
  651 #ifdef _KERNEL
  652 struct cmsghdr;
  653 
  654 /*
  655  * in6_cksum_phdr:
  656  *
  657  *      Compute significant parts of the IPv6 checksum pseudo-header
  658  *      for use in a delayed TCP/UDP checksum calculation.
  659  *
  660  *      Args:
  661  *
  662  *              src             Source IPv6 address
  663  *              dst             Destination IPv6 address
  664  *              len             htonl(proto-hdr-len)
  665  *              nxt             htonl(next-proto-number)
  666  *
  667  *      NOTE: We expect the src and dst addresses to be 16-bit
  668  *      aligned!
  669  */
  670 static __inline u_int16_t __attribute__((__unused__))
  671 in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst,
  672     u_int32_t len, u_int32_t nxt)
  673 {
  674         u_int32_t sum = 0;
  675         const u_int16_t *w;
  676 
  677         /*LINTED*/
  678         w = (const u_int16_t *) src;
  679         sum += w[0];
  680         if (!IN6_IS_SCOPE_LINKLOCAL(src))
  681                 sum += w[1];
  682         sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5];
  683         sum += w[6]; sum += w[7];
  684 
  685         /*LINTED*/
  686         w = (const u_int16_t *) dst;
  687         sum += w[0];
  688         if (!IN6_IS_SCOPE_LINKLOCAL(dst))
  689                 sum += w[1];
  690         sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5];
  691         sum += w[6]; sum += w[7];
  692 
  693         sum += (u_int16_t)(len >> 16) + (u_int16_t)(len /*& 0xffff*/);
  694 
  695         sum += (u_int16_t)(nxt >> 16) + (u_int16_t)(nxt /*& 0xffff*/);
  696 
  697         sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/);
  698 
  699         if (sum > 0xffff)
  700                 sum -= 0xffff;
  701 
  702         return (sum);
  703 }
  704 
  705 struct mbuf;
  706 struct ifnet;
  707 int     in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t));
  708 void    in6_delayed_cksum __P((struct mbuf *));
  709 int     in6_localaddr __P((struct in6_addr *));
  710 int     in6_addrscope __P((struct in6_addr *));
  711 struct  in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *));
  712 extern void in6_if_up __P((struct ifnet *));
  713 #ifndef __FreeBSD__
  714 extern int in6_src_sysctl __P((void *, size_t *, void *, size_t));
  715 #endif
  716 extern void addrsel_policy_init __P((void));
  717 extern  u_char  ip6_protox[];
  718 
  719 #define satosin6(sa)    ((struct sockaddr_in6 *)(sa))
  720 #define sin6tosa(sin6)  ((struct sockaddr *)(sin6))
  721 #define ifatoia6(ifa)   ((struct in6_ifaddr *)(ifa))
  722 #endif /* _KERNEL */
  723 
  724 #if defined(_NETBSD_SOURCE)
  725 
  726 #include <machine/ansi.h>
  727 
  728 #ifdef  _BSD_SIZE_T_
  729 typedef _BSD_SIZE_T_            size_t;
  730 #define _SIZE_T
  731 #undef  _BSD_SIZE_T_
  732 #endif
  733 
  734 #include <sys/cdefs.h>
  735 
  736 __BEGIN_DECLS
  737 struct cmsghdr;
  738 
  739 extern int inet6_option_space __P((int));
  740 extern int inet6_option_init __P((void *, struct cmsghdr **, int));
  741 extern int inet6_option_append __P((struct cmsghdr *, const uint8_t *,
  742         int, int));
  743 extern uint8_t *inet6_option_alloc __P((struct cmsghdr *, int, int, int));
  744 extern int inet6_option_next __P((const struct cmsghdr *, uint8_t **));
  745 extern int inet6_option_find __P((const struct cmsghdr *, uint8_t **, int));
  746 
  747 extern size_t inet6_rthdr_space __P((int, int));
  748 extern struct cmsghdr *inet6_rthdr_init __P((void *, int));
  749 extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *,
  750                 unsigned int));
  751 extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int));
  752 #if 0 /* not implemented yet */
  753 extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *));
  754 #endif
  755 extern int inet6_rthdr_segments __P((const struct cmsghdr *));
  756 extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int));
  757 extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int));
  758 
  759 extern int inet6_opt_init __P((void *, socklen_t));
  760 extern int inet6_opt_append __P((void *, socklen_t, int, uint8_t,
  761                 socklen_t, uint8_t, void **));
  762 extern int inet6_opt_finish __P((void *, socklen_t, int));
  763 extern int inet6_opt_set_val __P((void *, int, void *, socklen_t));
  764 
  765 extern int inet6_opt_next __P((void *, socklen_t, int, uint8_t *,
  766                 socklen_t *, void **));
  767 extern int inet6_opt_find __P((void *, socklen_t, int, uint8_t,
  768                 socklen_t *, void **));
  769 extern int inet6_opt_get_val __P((void *, int, void *, socklen_t));
  770 extern socklen_t inet6_rth_space __P((int, int));
  771 extern void *inet6_rth_init __P((void *, socklen_t, int, int));
  772 extern int inet6_rth_add __P((void *, const struct in6_addr *));
  773 extern int inet6_rth_reverse __P((const void *, void *));
  774 extern int inet6_rth_segments __P((const void *));
  775 extern struct in6_addr *inet6_rth_getaddr __P((const void *, int));
  776 __END_DECLS
  777 #endif /* _NETBSD_SOURCE */
  778 
  779 #endif /* !_NETINET6_IN6_H_ */

Cache object: f4a5998df34da0c344ae5068bc2bd333


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.