1686cdd19SJun-ichiro itojun Hagino /* $FreeBSD$ */ 233841545SHajimu UMEMOTO /* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ */ 3686cdd19SJun-ichiro itojun Hagino 476429de4SYoshinobu Inoue /* 576429de4SYoshinobu Inoue * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 676429de4SYoshinobu Inoue * All rights reserved. 776429de4SYoshinobu Inoue * 876429de4SYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 976429de4SYoshinobu Inoue * modification, are permitted provided that the following conditions 1076429de4SYoshinobu Inoue * are met: 1176429de4SYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 1276429de4SYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 1376429de4SYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 1476429de4SYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 1576429de4SYoshinobu Inoue * documentation and/or other materials provided with the distribution. 1676429de4SYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 1776429de4SYoshinobu Inoue * may be used to endorse or promote products derived from this software 1876429de4SYoshinobu Inoue * without specific prior written permission. 1976429de4SYoshinobu Inoue * 2076429de4SYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2176429de4SYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2276429de4SYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2376429de4SYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2476429de4SYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2576429de4SYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2676429de4SYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2776429de4SYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2876429de4SYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2976429de4SYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3076429de4SYoshinobu Inoue * SUCH DAMAGE. 3176429de4SYoshinobu Inoue */ 3276429de4SYoshinobu Inoue 3376429de4SYoshinobu Inoue /* 3476429de4SYoshinobu Inoue * Copyright (c) 1982, 1986, 1990, 1993 3576429de4SYoshinobu Inoue * The Regents of the University of California. All rights reserved. 3676429de4SYoshinobu Inoue * 3776429de4SYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 3876429de4SYoshinobu Inoue * modification, are permitted provided that the following conditions 3976429de4SYoshinobu Inoue * are met: 4076429de4SYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 4176429de4SYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 4276429de4SYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 4376429de4SYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 4476429de4SYoshinobu Inoue * documentation and/or other materials provided with the distribution. 4576429de4SYoshinobu Inoue * 3. All advertising materials mentioning features or use of this software 4676429de4SYoshinobu Inoue * must display the following acknowledgement: 4776429de4SYoshinobu Inoue * This product includes software developed by the University of 4876429de4SYoshinobu Inoue * California, Berkeley and its contributors. 4976429de4SYoshinobu Inoue * 4. Neither the name of the University nor the names of its contributors 5076429de4SYoshinobu Inoue * may be used to endorse or promote products derived from this software 5176429de4SYoshinobu Inoue * without specific prior written permission. 5276429de4SYoshinobu Inoue * 5376429de4SYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5476429de4SYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5576429de4SYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5676429de4SYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5776429de4SYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5876429de4SYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5976429de4SYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6076429de4SYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 6176429de4SYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6276429de4SYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6376429de4SYoshinobu Inoue * SUCH DAMAGE. 6476429de4SYoshinobu Inoue * 6576429de4SYoshinobu Inoue * @(#)in.h 8.3 (Berkeley) 1/3/94 6676429de4SYoshinobu Inoue */ 6776429de4SYoshinobu Inoue 68686cdd19SJun-ichiro itojun Hagino #ifndef __KAME_NETINET_IN_H_INCLUDED_ 6933841545SHajimu UMEMOTO #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553" 70686cdd19SJun-ichiro itojun Hagino #endif 71686cdd19SJun-ichiro itojun Hagino 7276429de4SYoshinobu Inoue #ifndef _NETINET6_IN6_H_ 7376429de4SYoshinobu Inoue #define _NETINET6_IN6_H_ 7476429de4SYoshinobu Inoue 7576429de4SYoshinobu Inoue /* 7676429de4SYoshinobu Inoue * Identification of the network protocol stack 7733841545SHajimu UMEMOTO * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE 7833841545SHajimu UMEMOTO * has the table of implementation/integration differences. 7976429de4SYoshinobu Inoue */ 8076429de4SYoshinobu Inoue #define __KAME__ 8133841545SHajimu UMEMOTO #define __KAME_VERSION "20010528/FreeBSD" 8276429de4SYoshinobu Inoue 8376429de4SYoshinobu Inoue /* 8476429de4SYoshinobu Inoue * Local port number conventions: 8576429de4SYoshinobu Inoue * 8676429de4SYoshinobu Inoue * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), 8776429de4SYoshinobu Inoue * unless a kernel is compiled with IPNOPRIVPORTS defined. 8876429de4SYoshinobu Inoue * 8976429de4SYoshinobu Inoue * When a user does a bind(2) or connect(2) with a port number of zero, 9076429de4SYoshinobu Inoue * a non-conflicting local port address is chosen. 9176429de4SYoshinobu Inoue * 92686cdd19SJun-ichiro itojun Hagino * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although 9376429de4SYoshinobu Inoue * that is settable by sysctl(3); net.inet.ip.anonportmin and 9476429de4SYoshinobu Inoue * net.inet.ip.anonportmax respectively. 9576429de4SYoshinobu Inoue * 9676429de4SYoshinobu Inoue * A user may set the IPPROTO_IP option IP_PORTRANGE to change this 9776429de4SYoshinobu Inoue * default assignment range. 9876429de4SYoshinobu Inoue * 9976429de4SYoshinobu Inoue * The value IP_PORTRANGE_DEFAULT causes the default behavior. 10076429de4SYoshinobu Inoue * 10176429de4SYoshinobu Inoue * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, 10276429de4SYoshinobu Inoue * and exists only for FreeBSD compatibility purposes. 10376429de4SYoshinobu Inoue * 10476429de4SYoshinobu Inoue * The value IP_PORTRANGE_LOW changes the range to the "low" are 10576429de4SYoshinobu Inoue * that is (by convention) restricted to privileged processes. 10676429de4SYoshinobu Inoue * This convention is based on "vouchsafe" principles only. 10776429de4SYoshinobu Inoue * It is only secure if you trust the remote host to restrict these ports. 10876429de4SYoshinobu Inoue * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. 10976429de4SYoshinobu Inoue */ 1109e2e036fSMike Barcroft #if __BSD_VISIBLE 11176429de4SYoshinobu Inoue #define IPV6PORT_RESERVED 1024 11276429de4SYoshinobu Inoue #define IPV6PORT_ANONMIN 49152 11376429de4SYoshinobu Inoue #define IPV6PORT_ANONMAX 65535 11476429de4SYoshinobu Inoue #define IPV6PORT_RESERVEDMIN 600 11576429de4SYoshinobu Inoue #define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) 1169e2e036fSMike Barcroft #endif 11776429de4SYoshinobu Inoue 11876429de4SYoshinobu Inoue /* 11976429de4SYoshinobu Inoue * IPv6 address 12076429de4SYoshinobu Inoue */ 12176429de4SYoshinobu Inoue struct in6_addr { 12276429de4SYoshinobu Inoue union { 1239e2e036fSMike Barcroft uint8_t __u6_addr8[16]; 1249e2e036fSMike Barcroft uint16_t __u6_addr16[8]; 1259e2e036fSMike Barcroft uint32_t __u6_addr32[4]; 12676429de4SYoshinobu Inoue } __u6_addr; /* 128-bit IP6 address */ 12776429de4SYoshinobu Inoue }; 12876429de4SYoshinobu Inoue 12976429de4SYoshinobu Inoue #define s6_addr __u6_addr.__u6_addr8 13076429de4SYoshinobu Inoue #ifdef _KERNEL /* XXX nonstandard */ 13176429de4SYoshinobu Inoue #define s6_addr8 __u6_addr.__u6_addr8 13276429de4SYoshinobu Inoue #define s6_addr16 __u6_addr.__u6_addr16 13376429de4SYoshinobu Inoue #define s6_addr32 __u6_addr.__u6_addr32 13476429de4SYoshinobu Inoue #endif 13576429de4SYoshinobu Inoue 13676429de4SYoshinobu Inoue #define INET6_ADDRSTRLEN 46 13776429de4SYoshinobu Inoue 13876429de4SYoshinobu Inoue /* 1399e2e036fSMike Barcroft * XXX missing POSIX.1-2001 macro IPPROTO_IPV6. 1409e2e036fSMike Barcroft */ 1419e2e036fSMike Barcroft 1429e2e036fSMike Barcroft /* 14376429de4SYoshinobu Inoue * Socket address for IPv6 14476429de4SYoshinobu Inoue */ 1459e2e036fSMike Barcroft #if __BSD_VISIBLE 14676429de4SYoshinobu Inoue #define SIN6_LEN 14776429de4SYoshinobu Inoue #endif 1489e2e036fSMike Barcroft 14976429de4SYoshinobu Inoue struct sockaddr_in6 { 150a5b71fafSHajimu UMEMOTO uint8_t sin6_len; /* length of this struct */ 1519e2e036fSMike Barcroft sa_family_t sin6_family; /* AF_INET6 */ 1529e2e036fSMike Barcroft in_port_t sin6_port; /* Transport layer port # */ 1539e2e036fSMike Barcroft uint32_t sin6_flowinfo; /* IP6 flow information */ 15476429de4SYoshinobu Inoue struct in6_addr sin6_addr; /* IP6 address */ 1559e2e036fSMike Barcroft uint32_t sin6_scope_id; /* scope zone index */ 15676429de4SYoshinobu Inoue }; 15776429de4SYoshinobu Inoue 15876429de4SYoshinobu Inoue /* 15976429de4SYoshinobu Inoue * Local definition for masks 16076429de4SYoshinobu Inoue */ 16176429de4SYoshinobu Inoue #ifdef _KERNEL /* XXX nonstandard */ 16276429de4SYoshinobu Inoue #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} 16376429de4SYoshinobu Inoue #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \ 16476429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 16576429de4SYoshinobu Inoue #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 16676429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 16776429de4SYoshinobu Inoue #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 16876429de4SYoshinobu Inoue 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} 16976429de4SYoshinobu Inoue #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ 17076429de4SYoshinobu Inoue 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}} 17176429de4SYoshinobu Inoue #endif 17276429de4SYoshinobu Inoue 17376429de4SYoshinobu Inoue #ifdef _KERNEL 17433841545SHajimu UMEMOTO extern const struct sockaddr_in6 sa6_any; 17533841545SHajimu UMEMOTO 17676429de4SYoshinobu Inoue extern const struct in6_addr in6mask0; 17776429de4SYoshinobu Inoue extern const struct in6_addr in6mask32; 17876429de4SYoshinobu Inoue extern const struct in6_addr in6mask64; 17976429de4SYoshinobu Inoue extern const struct in6_addr in6mask96; 18076429de4SYoshinobu Inoue extern const struct in6_addr in6mask128; 18176429de4SYoshinobu Inoue #endif /* _KERNEL */ 18276429de4SYoshinobu Inoue 18376429de4SYoshinobu Inoue /* 18476429de4SYoshinobu Inoue * Macros started with IPV6_ADDR is KAME local 18576429de4SYoshinobu Inoue */ 18676429de4SYoshinobu Inoue #ifdef _KERNEL /* XXX nonstandard */ 1879e2e036fSMike Barcroft #if _BYTE_ORDER == _BIG_ENDIAN 18876429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_ONE 1 18976429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_TWO 2 19076429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_MNL 0xff010000 19176429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_MLL 0xff020000 19276429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_SMP 0x0000ffff 19376429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_ULL 0xfe80 19476429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_USL 0xfec0 19576429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_MLL 0xff02 1969e2e036fSMike Barcroft #elif _BYTE_ORDER == _LITTLE_ENDIAN 19776429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_ONE 0x01000000 19876429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_TWO 0x02000000 19976429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_MNL 0x000001ff 20076429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_MLL 0x000002ff 20176429de4SYoshinobu Inoue #define IPV6_ADDR_INT32_SMP 0xffff0000 20276429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_ULL 0x80fe 20376429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_USL 0xc0fe 20476429de4SYoshinobu Inoue #define IPV6_ADDR_INT16_MLL 0x02ff 20576429de4SYoshinobu Inoue #endif 20676429de4SYoshinobu Inoue #endif 20776429de4SYoshinobu Inoue 20876429de4SYoshinobu Inoue /* 20976429de4SYoshinobu Inoue * Definition of some useful macros to handle IP6 addresses 21076429de4SYoshinobu Inoue */ 2119e2e036fSMike Barcroft #if __BSD_VISIBLE 21276429de4SYoshinobu Inoue #define IN6ADDR_ANY_INIT \ 21376429de4SYoshinobu Inoue {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 21476429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 21576429de4SYoshinobu Inoue #define IN6ADDR_LOOPBACK_INIT \ 21676429de4SYoshinobu Inoue {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 21776429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 21876429de4SYoshinobu Inoue #define IN6ADDR_NODELOCAL_ALLNODES_INIT \ 21976429de4SYoshinobu Inoue {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 22076429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 2219a4f9608SHajimu UMEMOTO #define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \ 2229a4f9608SHajimu UMEMOTO {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 2239a4f9608SHajimu UMEMOTO 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 22476429de4SYoshinobu Inoue #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ 22576429de4SYoshinobu Inoue {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 22676429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 22776429de4SYoshinobu Inoue #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 22876429de4SYoshinobu Inoue {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 22976429de4SYoshinobu Inoue 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} 2309e2e036fSMike Barcroft #endif 23176429de4SYoshinobu Inoue 23276429de4SYoshinobu Inoue extern const struct in6_addr in6addr_any; 23376429de4SYoshinobu Inoue extern const struct in6_addr in6addr_loopback; 2349e2e036fSMike Barcroft #if __BSD_VISIBLE 23576429de4SYoshinobu Inoue extern const struct in6_addr in6addr_nodelocal_allnodes; 23676429de4SYoshinobu Inoue extern const struct in6_addr in6addr_linklocal_allnodes; 23776429de4SYoshinobu Inoue extern const struct in6_addr in6addr_linklocal_allrouters; 2389e2e036fSMike Barcroft #endif 23976429de4SYoshinobu Inoue 24076429de4SYoshinobu Inoue /* 24176429de4SYoshinobu Inoue * Equality 242a082a654SJun-ichiro itojun Hagino * NOTE: Some of kernel programming environment (for example, openbsd/sparc) 243a082a654SJun-ichiro itojun Hagino * does not supply memcmp(). For userland memcmp() is preferred as it is 244a082a654SJun-ichiro itojun Hagino * in ANSI standard. 24576429de4SYoshinobu Inoue */ 246a082a654SJun-ichiro itojun Hagino #ifdef _KERNEL 247a082a654SJun-ichiro itojun Hagino #define IN6_ARE_ADDR_EQUAL(a, b) \ 248686cdd19SJun-ichiro itojun Hagino (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) 249a082a654SJun-ichiro itojun Hagino #else 2509e2e036fSMike Barcroft #if __BSD_VISIBLE 25176429de4SYoshinobu Inoue #define IN6_ARE_ADDR_EQUAL(a, b) \ 252686cdd19SJun-ichiro itojun Hagino (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) 253a082a654SJun-ichiro itojun Hagino #endif 2549e2e036fSMike Barcroft #endif 25576429de4SYoshinobu Inoue 25633841545SHajimu UMEMOTO #ifdef _KERNEL /* non standard */ 25733841545SHajimu UMEMOTO /* see if two addresses are equal in a scope-conscious manner. */ 25833841545SHajimu UMEMOTO #define SA6_ARE_ADDR_EQUAL(a, b) \ 25933841545SHajimu UMEMOTO (((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \ 26033841545SHajimu UMEMOTO ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \ 26133841545SHajimu UMEMOTO (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0)) 26233841545SHajimu UMEMOTO #endif 26333841545SHajimu UMEMOTO 26476429de4SYoshinobu Inoue /* 26576429de4SYoshinobu Inoue * Unspecified 26676429de4SYoshinobu Inoue */ 26776429de4SYoshinobu Inoue #define IN6_IS_ADDR_UNSPECIFIED(a) \ 26833841545SHajimu UMEMOTO ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ 26933841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ 27033841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ 27133841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0)) 27276429de4SYoshinobu Inoue 27376429de4SYoshinobu Inoue /* 27476429de4SYoshinobu Inoue * Loopback 27576429de4SYoshinobu Inoue */ 27676429de4SYoshinobu Inoue #define IN6_IS_ADDR_LOOPBACK(a) \ 27733841545SHajimu UMEMOTO ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ 27833841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ 27933841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ 28033841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1))) 28176429de4SYoshinobu Inoue 28276429de4SYoshinobu Inoue /* 28376429de4SYoshinobu Inoue * IPv4 compatible 28476429de4SYoshinobu Inoue */ 28576429de4SYoshinobu Inoue #define IN6_IS_ADDR_V4COMPAT(a) \ 28633841545SHajimu UMEMOTO ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ 28733841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ 28833841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ 28933841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \ 29033841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1))) 29176429de4SYoshinobu Inoue 29276429de4SYoshinobu Inoue /* 29376429de4SYoshinobu Inoue * Mapped 29476429de4SYoshinobu Inoue */ 29576429de4SYoshinobu Inoue #define IN6_IS_ADDR_V4MAPPED(a) \ 29633841545SHajimu UMEMOTO ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ 29733841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ 29833841545SHajimu UMEMOTO (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff))) 29976429de4SYoshinobu Inoue 30076429de4SYoshinobu Inoue /* 30176429de4SYoshinobu Inoue * KAME Scope Values 30276429de4SYoshinobu Inoue */ 30376429de4SYoshinobu Inoue 30476429de4SYoshinobu Inoue #ifdef _KERNEL /* XXX nonstandard */ 30576429de4SYoshinobu Inoue #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 3069a4f9608SHajimu UMEMOTO #define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 30776429de4SYoshinobu Inoue #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 30876429de4SYoshinobu Inoue #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 30976429de4SYoshinobu Inoue #define IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ 31076429de4SYoshinobu Inoue #define IPV6_ADDR_SCOPE_GLOBAL 0x0e 31176429de4SYoshinobu Inoue #else 31276429de4SYoshinobu Inoue #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 3139a4f9608SHajimu UMEMOTO #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 31476429de4SYoshinobu Inoue #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 31576429de4SYoshinobu Inoue #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 31676429de4SYoshinobu Inoue #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ 31776429de4SYoshinobu Inoue #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e 31876429de4SYoshinobu Inoue #endif 31976429de4SYoshinobu Inoue 32076429de4SYoshinobu Inoue /* 32176429de4SYoshinobu Inoue * Unicast Scope 32276429de4SYoshinobu Inoue * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). 32376429de4SYoshinobu Inoue */ 32476429de4SYoshinobu Inoue #define IN6_IS_ADDR_LINKLOCAL(a) \ 32576429de4SYoshinobu Inoue (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) 32676429de4SYoshinobu Inoue #define IN6_IS_ADDR_SITELOCAL(a) \ 32776429de4SYoshinobu Inoue (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) 32876429de4SYoshinobu Inoue 32976429de4SYoshinobu Inoue /* 33076429de4SYoshinobu Inoue * Multicast 33176429de4SYoshinobu Inoue */ 33276429de4SYoshinobu Inoue #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) 33376429de4SYoshinobu Inoue 33476429de4SYoshinobu Inoue #ifdef _KERNEL /* XXX nonstandard */ 33576429de4SYoshinobu Inoue #define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) 33676429de4SYoshinobu Inoue #else 33776429de4SYoshinobu Inoue #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) 33876429de4SYoshinobu Inoue #endif 33976429de4SYoshinobu Inoue 34076429de4SYoshinobu Inoue /* 34176429de4SYoshinobu Inoue * Multicast Scope 34276429de4SYoshinobu Inoue */ 34376429de4SYoshinobu Inoue #ifdef _KERNEL /* refers nonstandard items */ 34476429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_NODELOCAL(a) \ 34576429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 34676429de4SYoshinobu Inoue (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL)) 3479a4f9608SHajimu UMEMOTO #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \ 3489a4f9608SHajimu UMEMOTO (IN6_IS_ADDR_MULTICAST(a) && \ 3499a4f9608SHajimu UMEMOTO (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL)) 35076429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ 35176429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 35276429de4SYoshinobu Inoue (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL)) 35376429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_SITELOCAL(a) \ 35476429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 35576429de4SYoshinobu Inoue (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL)) 35676429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ 35776429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 35876429de4SYoshinobu Inoue (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL)) 35976429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_GLOBAL(a) \ 36076429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 36176429de4SYoshinobu Inoue (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL)) 36276429de4SYoshinobu Inoue #else 36376429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_NODELOCAL(a) \ 36476429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 36576429de4SYoshinobu Inoue (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) 36676429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ 36776429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 36876429de4SYoshinobu Inoue (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) 36976429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_SITELOCAL(a) \ 37076429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 37176429de4SYoshinobu Inoue (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) 37276429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ 37376429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 37476429de4SYoshinobu Inoue (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) 37576429de4SYoshinobu Inoue #define IN6_IS_ADDR_MC_GLOBAL(a) \ 37676429de4SYoshinobu Inoue (IN6_IS_ADDR_MULTICAST(a) && \ 37776429de4SYoshinobu Inoue (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) 37876429de4SYoshinobu Inoue #endif 37976429de4SYoshinobu Inoue 38033841545SHajimu UMEMOTO #ifdef _KERNEL /* nonstandard */ 38133841545SHajimu UMEMOTO /* 38276429de4SYoshinobu Inoue * KAME Scope 38376429de4SYoshinobu Inoue */ 38476429de4SYoshinobu Inoue #define IN6_IS_SCOPE_LINKLOCAL(a) \ 38576429de4SYoshinobu Inoue ((IN6_IS_ADDR_LINKLOCAL(a)) || \ 38676429de4SYoshinobu Inoue (IN6_IS_ADDR_MC_LINKLOCAL(a))) 38733841545SHajimu UMEMOTO 38833841545SHajimu UMEMOTO #define IFA6_IS_DEPRECATED(a) \ 38933841545SHajimu UMEMOTO ((a)->ia6_lifetime.ia6t_preferred != 0 && \ 39033841545SHajimu UMEMOTO (a)->ia6_lifetime.ia6t_preferred < time_second) 39133841545SHajimu UMEMOTO #define IFA6_IS_INVALID(a) \ 39233841545SHajimu UMEMOTO ((a)->ia6_lifetime.ia6t_expire != 0 && \ 39333841545SHajimu UMEMOTO (a)->ia6_lifetime.ia6t_expire < time_second) 39433841545SHajimu UMEMOTO #endif /* _KERNEL */ 39576429de4SYoshinobu Inoue 39676429de4SYoshinobu Inoue /* 39776429de4SYoshinobu Inoue * IP6 route structure 39876429de4SYoshinobu Inoue */ 3999e2e036fSMike Barcroft #if __BSD_VISIBLE 40076429de4SYoshinobu Inoue struct route_in6 { 40176429de4SYoshinobu Inoue struct rtentry *ro_rt; 40276429de4SYoshinobu Inoue struct sockaddr_in6 ro_dst; 40376429de4SYoshinobu Inoue }; 40476429de4SYoshinobu Inoue #endif 40576429de4SYoshinobu Inoue 40676429de4SYoshinobu Inoue /* 40776429de4SYoshinobu Inoue * Options for use with [gs]etsockopt at the IPV6 level. 40876429de4SYoshinobu Inoue * First word of comment is data type; bool is stored in int. 40976429de4SYoshinobu Inoue */ 4109e2e036fSMike Barcroft #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ 4119e2e036fSMike Barcroft #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ 4127b798624SHajimu UMEMOTO #define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ 4137b798624SHajimu UMEMOTO #define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ 4147b798624SHajimu UMEMOTO #define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */ 4159e2e036fSMike Barcroft #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ 4169e2e036fSMike Barcroft #define IPV6_V6ONLY 27 /* bool; only bind INET6 at wildcard bind */ 4179e2e036fSMike Barcroft 4189e2e036fSMike Barcroft #if __BSD_VISIBLE 41976429de4SYoshinobu Inoue /* no hdrincl */ 420686cdd19SJun-ichiro itojun Hagino #if 0 /* the followings are relic in IPv4 and hence are disabled */ 421686cdd19SJun-ichiro itojun Hagino #define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ 42276429de4SYoshinobu Inoue #define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ 42376429de4SYoshinobu Inoue #define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ 42476429de4SYoshinobu Inoue #define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ 42576429de4SYoshinobu Inoue #define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ 426686cdd19SJun-ichiro itojun Hagino #endif 427686cdd19SJun-ichiro itojun Hagino #define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ 42876429de4SYoshinobu Inoue #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ 42976429de4SYoshinobu Inoue #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ 43033841545SHajimu UMEMOTO /* RFC2292 options */ 43133841545SHajimu UMEMOTO #define IPV6_PKTINFO 19 /* bool; send/recv if, src/dst addr */ 43276429de4SYoshinobu Inoue #define IPV6_HOPLIMIT 20 /* bool; hop limit */ 43376429de4SYoshinobu Inoue #define IPV6_NEXTHOP 21 /* bool; next hop addr */ 43476429de4SYoshinobu Inoue #define IPV6_HOPOPTS 22 /* bool; hop-by-hop option */ 43576429de4SYoshinobu Inoue #define IPV6_DSTOPTS 23 /* bool; destination option */ 43676429de4SYoshinobu Inoue #define IPV6_RTHDR 24 /* bool; routing header */ 43776429de4SYoshinobu Inoue #define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */ 43876429de4SYoshinobu Inoue 43933841545SHajimu UMEMOTO #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ 44033841545SHajimu UMEMOTO #ifndef _KERNEL 44133841545SHajimu UMEMOTO #define IPV6_BINDV6ONLY IPV6_V6ONLY 44233841545SHajimu UMEMOTO #endif 44333841545SHajimu UMEMOTO 44433841545SHajimu UMEMOTO #if 1 /* IPSEC */ 44576429de4SYoshinobu Inoue #define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ 44633841545SHajimu UMEMOTO #endif 44776429de4SYoshinobu Inoue #define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */ 44876429de4SYoshinobu Inoue 44933841545SHajimu UMEMOTO #if 1 /* IPV6FIREWALL */ 45076429de4SYoshinobu Inoue #define IPV6_FW_ADD 30 /* add a firewall rule to chain */ 45176429de4SYoshinobu Inoue #define IPV6_FW_DEL 31 /* delete a firewall rule from chain */ 45276429de4SYoshinobu Inoue #define IPV6_FW_FLUSH 32 /* flush firewall rule chain */ 45376429de4SYoshinobu Inoue #define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */ 45476429de4SYoshinobu Inoue #define IPV6_FW_GET 34 /* get entire firewall rule chain */ 45533841545SHajimu UMEMOTO #endif 45633841545SHajimu UMEMOTO 45706f879c7SJun-ichiro itojun Hagino /* to define items, should talk with KAME guys first, for *BSD compatibility */ 45876429de4SYoshinobu Inoue 45976429de4SYoshinobu Inoue #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */ 46076429de4SYoshinobu Inoue #define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */ 46176429de4SYoshinobu Inoue #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ 46276429de4SYoshinobu Inoue 46376429de4SYoshinobu Inoue /* 46476429de4SYoshinobu Inoue * Defaults and limits for options 46576429de4SYoshinobu Inoue */ 46676429de4SYoshinobu Inoue #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ 46776429de4SYoshinobu Inoue #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 46876429de4SYoshinobu Inoue 46976429de4SYoshinobu Inoue /* 47076429de4SYoshinobu Inoue * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. 47176429de4SYoshinobu Inoue */ 47276429de4SYoshinobu Inoue struct ipv6_mreq { 47376429de4SYoshinobu Inoue struct in6_addr ipv6mr_multiaddr; 474686cdd19SJun-ichiro itojun Hagino unsigned int ipv6mr_interface; 47576429de4SYoshinobu Inoue }; 47676429de4SYoshinobu Inoue 47776429de4SYoshinobu Inoue /* 47876429de4SYoshinobu Inoue * IPV6_PKTINFO: Packet information(RFC2292 sec 5) 47976429de4SYoshinobu Inoue */ 48076429de4SYoshinobu Inoue struct in6_pktinfo { 48176429de4SYoshinobu Inoue struct in6_addr ipi6_addr; /* src/dst IPv6 address */ 482686cdd19SJun-ichiro itojun Hagino unsigned int ipi6_ifindex; /* send/recv interface index */ 48376429de4SYoshinobu Inoue }; 48476429de4SYoshinobu Inoue 48576429de4SYoshinobu Inoue /* 48676429de4SYoshinobu Inoue * Argument for IPV6_PORTRANGE: 48776429de4SYoshinobu Inoue * - which range to search when port is unspecified at bind() or connect() 48876429de4SYoshinobu Inoue */ 48976429de4SYoshinobu Inoue #define IPV6_PORTRANGE_DEFAULT 0 /* default range */ 49076429de4SYoshinobu Inoue #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 49176429de4SYoshinobu Inoue #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 49276429de4SYoshinobu Inoue 49376429de4SYoshinobu Inoue /* 49476429de4SYoshinobu Inoue * Definitions for inet6 sysctl operations. 49576429de4SYoshinobu Inoue * 49676429de4SYoshinobu Inoue * Third level is protocol number. 49776429de4SYoshinobu Inoue * Fourth level is desired variable within that protocol. 49876429de4SYoshinobu Inoue */ 49976429de4SYoshinobu Inoue #define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ 50076429de4SYoshinobu Inoue 50176429de4SYoshinobu Inoue /* 50276429de4SYoshinobu Inoue * Names for IP sysctl objects 50376429de4SYoshinobu Inoue */ 50476429de4SYoshinobu Inoue #define IPV6CTL_FORWARDING 1 /* act as router */ 50576429de4SYoshinobu Inoue #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/ 50676429de4SYoshinobu Inoue #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ 50776429de4SYoshinobu Inoue #ifdef notyet 50876429de4SYoshinobu Inoue #define IPV6CTL_DEFMTU 4 /* default MTU */ 50976429de4SYoshinobu Inoue #endif 51076429de4SYoshinobu Inoue #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ 51176429de4SYoshinobu Inoue #define IPV6CTL_STATS 6 /* stats */ 51276429de4SYoshinobu Inoue #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ 51376429de4SYoshinobu Inoue #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ 51476429de4SYoshinobu Inoue #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ 51576429de4SYoshinobu Inoue #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ 51676429de4SYoshinobu Inoue #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ 51776429de4SYoshinobu Inoue #define IPV6CTL_ACCEPT_RTADV 12 51876429de4SYoshinobu Inoue #define IPV6CTL_KEEPFAITH 13 51976429de4SYoshinobu Inoue #define IPV6CTL_LOG_INTERVAL 14 52076429de4SYoshinobu Inoue #define IPV6CTL_HDRNESTLIMIT 15 52176429de4SYoshinobu Inoue #define IPV6CTL_DAD_COUNT 16 52276429de4SYoshinobu Inoue #define IPV6CTL_AUTO_FLOWLABEL 17 52376429de4SYoshinobu Inoue #define IPV6CTL_DEFMCASTHLIM 18 52476429de4SYoshinobu Inoue #define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ 525cfa1ca9dSYoshinobu Inoue #define IPV6CTL_KAME_VERSION 20 52676429de4SYoshinobu Inoue #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */ 52776429de4SYoshinobu Inoue #define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ 52833841545SHajimu UMEMOTO #if 0 /* obsolete */ 52976429de4SYoshinobu Inoue #define IPV6CTL_MAPPED_ADDR 23 5307ee982bcSJun-ichiro itojun Hagino #endif 53133841545SHajimu UMEMOTO #define IPV6CTL_V6ONLY 24 5327ee982bcSJun-ichiro itojun Hagino #define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */ 5337ee982bcSJun-ichiro itojun Hagino #define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */ 5347ee982bcSJun-ichiro itojun Hagino #define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */ 53533841545SHajimu UMEMOTO 53633841545SHajimu UMEMOTO #define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */ 53733841545SHajimu UMEMOTO #define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */ 53833841545SHajimu UMEMOTO #define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */ 53933841545SHajimu UMEMOTO #define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ 54033841545SHajimu UMEMOTO #define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */ 54133841545SHajimu UMEMOTO 54276429de4SYoshinobu Inoue /* New entries should be added here from current IPV6CTL_MAXID value. */ 54306f879c7SJun-ichiro itojun Hagino /* to define items, should talk with KAME guys first, for *BSD compatibility */ 54433841545SHajimu UMEMOTO #define IPV6CTL_MAXID 37 54533841545SHajimu UMEMOTO 54682cd038dSYoshinobu Inoue /* 54782cd038dSYoshinobu Inoue * Redefinition of mbuf flags 54882cd038dSYoshinobu Inoue */ 54982cd038dSYoshinobu Inoue #define M_AUTHIPHDR M_PROTO2 55082cd038dSYoshinobu Inoue #define M_DECRYPTED M_PROTO3 55182cd038dSYoshinobu Inoue #define M_LOOP M_PROTO4 55282cd038dSYoshinobu Inoue #define M_AUTHIPDGM M_PROTO5 55382cd038dSYoshinobu Inoue 55476429de4SYoshinobu Inoue #ifdef _KERNEL 55576429de4SYoshinobu Inoue struct cmsghdr; 55676429de4SYoshinobu Inoue 557686cdd19SJun-ichiro itojun Hagino int in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t)); 55876429de4SYoshinobu Inoue int in6_localaddr __P((struct in6_addr *)); 55976429de4SYoshinobu Inoue int in6_addrscope __P((struct in6_addr *)); 56076429de4SYoshinobu Inoue struct in6_ifaddr *in6_ifawithscope __P((struct ifnet *, struct in6_addr *)); 56176429de4SYoshinobu Inoue struct in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *)); 56276429de4SYoshinobu Inoue extern void in6_if_up __P((struct ifnet *)); 56376429de4SYoshinobu Inoue struct sockaddr; 564620fa9ebSDarren Reed extern u_char ip6_protox[]; 56576429de4SYoshinobu Inoue 56676429de4SYoshinobu Inoue void in6_sin6_2_sin __P((struct sockaddr_in *sin, 56776429de4SYoshinobu Inoue struct sockaddr_in6 *sin6)); 56876429de4SYoshinobu Inoue void in6_sin_2_v4mapsin6 __P((struct sockaddr_in *sin, 56976429de4SYoshinobu Inoue struct sockaddr_in6 *sin6)); 57076429de4SYoshinobu Inoue void in6_sin6_2_sin_in_sock __P((struct sockaddr *nam)); 57176429de4SYoshinobu Inoue void in6_sin_2_v4mapsin6_in_sock __P((struct sockaddr **nam)); 57276429de4SYoshinobu Inoue 57376429de4SYoshinobu Inoue #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) 57476429de4SYoshinobu Inoue #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) 57576429de4SYoshinobu Inoue #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) 5769494d596SBrooks Davis 5779494d596SBrooks Davis extern int (*faithprefix_p)(struct in6_addr *); 57876429de4SYoshinobu Inoue #endif /* _KERNEL */ 57976429de4SYoshinobu Inoue 580abbd8902SMike Barcroft #ifndef _SIZE_T_DECLARED 581abbd8902SMike Barcroft typedef __size_t size_t; 582abbd8902SMike Barcroft #define _SIZE_T_DECLARED 5839e2e036fSMike Barcroft #endif 5849e2e036fSMike Barcroft 58576429de4SYoshinobu Inoue __BEGIN_DECLS 58676429de4SYoshinobu Inoue struct cmsghdr; 58776429de4SYoshinobu Inoue 58879c361bcSYoshinobu Inoue extern int inet6_option_space __P((int)); 58979c361bcSYoshinobu Inoue extern int inet6_option_init __P((void *, struct cmsghdr **, int)); 5909e2e036fSMike Barcroft extern int inet6_option_append __P((struct cmsghdr *, const uint8_t *, 59179c361bcSYoshinobu Inoue int, int)); 5929e2e036fSMike Barcroft extern uint8_t *inet6_option_alloc __P((struct cmsghdr *, int, int, int)); 5939e2e036fSMike Barcroft extern int inet6_option_next __P((const struct cmsghdr *, uint8_t **)); 5949e2e036fSMike Barcroft extern int inet6_option_find __P((const struct cmsghdr *, uint8_t **, int)); 59576429de4SYoshinobu Inoue 59676429de4SYoshinobu Inoue extern size_t inet6_rthdr_space __P((int, int)); 59776429de4SYoshinobu Inoue extern struct cmsghdr *inet6_rthdr_init __P((void *, int)); 59876429de4SYoshinobu Inoue extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *, 59933841545SHajimu UMEMOTO unsigned int)); 60033841545SHajimu UMEMOTO extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int)); 60133841545SHajimu UMEMOTO #if 0 /* not implemented yet */ 60233841545SHajimu UMEMOTO extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *)); 60333841545SHajimu UMEMOTO #endif 60476429de4SYoshinobu Inoue extern int inet6_rthdr_segments __P((const struct cmsghdr *)); 60576429de4SYoshinobu Inoue extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int)); 60676429de4SYoshinobu Inoue extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int)); 60733841545SHajimu UMEMOTO 60833841545SHajimu UMEMOTO extern int inet6_opt_init __P((void *, size_t)); 6099e2e036fSMike Barcroft extern int inet6_opt_append __P((void *, size_t, int, uint8_t, 6109e2e036fSMike Barcroft size_t, uint8_t, void **)); 61133841545SHajimu UMEMOTO extern int inet6_opt_finish __P((void *, size_t, int)); 61233841545SHajimu UMEMOTO extern int inet6_opt_set_val __P((void *, size_t, void *, int)); 61333841545SHajimu UMEMOTO 6149e2e036fSMike Barcroft extern int inet6_opt_next __P((void *, size_t, int, uint8_t *, 61533841545SHajimu UMEMOTO size_t *, void **)); 6169e2e036fSMike Barcroft extern int inet6_opt_find __P((void *, size_t, int, uint8_t, 61733841545SHajimu UMEMOTO size_t *, void **)); 61833841545SHajimu UMEMOTO extern int inet6_opt_get_val __P((void *, size_t, void *, int)); 61933841545SHajimu UMEMOTO extern size_t inet6_rth_space __P((int, int)); 62033841545SHajimu UMEMOTO extern void *inet6_rth_init __P((void *, int, int, int)); 62133841545SHajimu UMEMOTO extern int inet6_rth_add __P((void *, const struct in6_addr *)); 62233841545SHajimu UMEMOTO extern int inet6_rth_reverse __P((const void *, void *)); 62333841545SHajimu UMEMOTO extern int inet6_rth_segments __P((const void *)); 62433841545SHajimu UMEMOTO extern struct in6_addr *inet6_rth_getaddr __P((const void *, int)); 62576429de4SYoshinobu Inoue __END_DECLS 62676429de4SYoshinobu Inoue 6279e2e036fSMike Barcroft #endif /* __BSD_VISIBLE */ 6289e2e036fSMike Barcroft 62976429de4SYoshinobu Inoue #endif /* !_NETINET6_IN6_H_ */ 630