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