os/ossrv/genericopenlibs/openenvcore/include/netinet6/in6.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*	$FreeBSD: src/sys/netinet6/in6.h,v 1.36.2.2 2005/10/09 05:21:18 ume Exp $	*/
sl@0
     2
/*	$KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $	*/
sl@0
     3
sl@0
     4
/*-
sl@0
     5
 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
sl@0
     6
 * All rights reserved.
sl@0
     7
 *
sl@0
     8
 * Redistribution and use in source and binary forms, with or without
sl@0
     9
 * modification, are permitted provided that the following conditions
sl@0
    10
 * are met:
sl@0
    11
 * 1. Redistributions of source code must retain the above copyright
sl@0
    12
 *    notice, this list of conditions and the following disclaimer.
sl@0
    13
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    14
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    15
 *    documentation and/or other materials provided with the distribution.
sl@0
    16
 * 3. Neither the name of the project nor the names of its contributors
sl@0
    17
 *    may be used to endorse or promote products derived from this software
sl@0
    18
 *    without specific prior written permission.
sl@0
    19
 *
sl@0
    20
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
sl@0
    21
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    23
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
sl@0
    24
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    25
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    26
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    27
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    29
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    30
 * SUCH DAMAGE.
sl@0
    31
 */
sl@0
    32
sl@0
    33
/*-
sl@0
    34
 * Copyright (c) 1982, 1986, 1990, 1993
sl@0
    35
 *	The Regents of the University of California.  All rights reserved.
sl@0
    36
 *
sl@0
    37
 * Redistribution and use in source and binary forms, with or without
sl@0
    38
 * modification, are permitted provided that the following conditions
sl@0
    39
 * are met:
sl@0
    40
 * 1. Redistributions of source code must retain the above copyright
sl@0
    41
 *    notice, this list of conditions and the following disclaimer.
sl@0
    42
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    43
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    44
 *    documentation and/or other materials provided with the distribution.
sl@0
    45
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    46
 *    may be used to endorse or promote products derived from this software
sl@0
    47
 *    without specific prior written permission.
sl@0
    48
 *
sl@0
    49
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    50
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    51
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    52
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    53
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    54
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    55
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    56
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    57
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    58
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    59
 * SUCH DAMAGE.
sl@0
    60
* Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).  All rights reserved.
sl@0
    61
 *	@(#)in.h	8.3 (Berkeley) 1/3/94
sl@0
    62
 */
sl@0
    63
sl@0
    64
#ifndef __KAME_NETINET_IN_H_INCLUDED_
sl@0
    65
#error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
sl@0
    66
#endif
sl@0
    67
sl@0
    68
#ifndef _NETINET6_IN6_H_
sl@0
    69
#define _NETINET6_IN6_H_
sl@0
    70
sl@0
    71
/*
sl@0
    72
 * Identification of the network protocol stack
sl@0
    73
 * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
sl@0
    74
 * has the table of implementation/integration differences.
sl@0
    75
 */
sl@0
    76
#define __KAME__
sl@0
    77
#define __KAME_VERSION		"20010528/FreeBSD"
sl@0
    78
sl@0
    79
/*
sl@0
    80
 * Local port number conventions:
sl@0
    81
 *
sl@0
    82
 * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
sl@0
    83
 * unless a kernel is compiled with IPNOPRIVPORTS defined.
sl@0
    84
 *
sl@0
    85
 * When a user does a bind(2) or connect(2) with a port number of zero,
sl@0
    86
 * a non-conflicting local port address is chosen.
sl@0
    87
 *
sl@0
    88
 * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
sl@0
    89
 * that is settable by sysctl(3); net.inet.ip.anonportmin and
sl@0
    90
 * net.inet.ip.anonportmax respectively.
sl@0
    91
 *
sl@0
    92
 * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
sl@0
    93
 * default assignment range.
sl@0
    94
 *
sl@0
    95
 * The value IP_PORTRANGE_DEFAULT causes the default behavior.
sl@0
    96
 *
sl@0
    97
 * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
sl@0
    98
 * and exists only for FreeBSD compatibility purposes.
sl@0
    99
 *
sl@0
   100
 * The value IP_PORTRANGE_LOW changes the range to the "low" are
sl@0
   101
 * that is (by convention) restricted to privileged processes.
sl@0
   102
 * This convention is based on "vouchsafe" principles only.
sl@0
   103
 * It is only secure if you trust the remote host to restrict these ports.
sl@0
   104
 * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
sl@0
   105
 */
sl@0
   106
#if __BSD_VISIBLE
sl@0
   107
#define	IPV6PORT_RESERVED	1024
sl@0
   108
#define	IPV6PORT_ANONMIN	49152
sl@0
   109
#define	IPV6PORT_ANONMAX	65535
sl@0
   110
#define	IPV6PORT_RESERVEDMIN	600
sl@0
   111
#define	IPV6PORT_RESERVEDMAX	(IPV6PORT_RESERVED-1)
sl@0
   112
#endif
sl@0
   113
sl@0
   114
/*
sl@0
   115
 * IPv6 address
sl@0
   116
 */
sl@0
   117
struct in6_addr {
sl@0
   118
	union {
sl@0
   119
		uint8_t		__u6_addr8[16];
sl@0
   120
		uint16_t	__u6_addr16[8];
sl@0
   121
		uint32_t	__u6_addr32[4];
sl@0
   122
	} __u6_addr;			/* 128-bit IP6 address */
sl@0
   123
};
sl@0
   124
sl@0
   125
#define s6_addr   __u6_addr.__u6_addr8
sl@0
   126
#ifdef _KERNEL	/* XXX nonstandard */
sl@0
   127
#define s6_addr8  __u6_addr.__u6_addr8
sl@0
   128
#define s6_addr16 __u6_addr.__u6_addr16
sl@0
   129
#define s6_addr32 __u6_addr.__u6_addr32
sl@0
   130
#endif
sl@0
   131
sl@0
   132
#define INET6_ADDRSTRLEN	46
sl@0
   133
sl@0
   134
/*
sl@0
   135
 * XXX missing POSIX.1-2001 macro IPPROTO_IPV6.
sl@0
   136
 */
sl@0
   137
sl@0
   138
/*
sl@0
   139
 * Socket address for IPv6
sl@0
   140
 */
sl@0
   141
#if __BSD_VISIBLE
sl@0
   142
#define SIN6_LEN
sl@0
   143
#endif
sl@0
   144
#ifdef __SYMBIAN32__
sl@0
   145
struct sockaddr_in6 {
sl@0
   146
	u_short 	sin6_family;	/* AF_INET6 */
sl@0
   147
	u_short 	sin6_port;	/* Transport layer port # */
sl@0
   148
	struct in6_addr	sin6_addr;	/* IP6 address */
sl@0
   149
	uint32_t	sin6_flowinfo;	/* IP6 flow information */
sl@0
   150
	uint32_t	sin6_scope_id;	/* scope zone index */
sl@0
   151
	uint8_t		sin6_len;	/* length of this struct */
sl@0
   152
};
sl@0
   153
#else
sl@0
   154
struct sockaddr_in6 {
sl@0
   155
	uint8_t		sin6_len;	/* length of this struct */
sl@0
   156
	sa_family_t	sin6_family;	/* AF_INET6 */
sl@0
   157
	in_port_t	sin6_port;	/* Transport layer port # */
sl@0
   158
	uint32_t	sin6_flowinfo;	/* IP6 flow information */
sl@0
   159
	struct in6_addr	sin6_addr;	/* IP6 address */
sl@0
   160
	uint32_t	sin6_scope_id;	/* scope zone index */
sl@0
   161
};
sl@0
   162
#endif
sl@0
   163
sl@0
   164
/*
sl@0
   165
 * Local definition for masks
sl@0
   166
 */
sl@0
   167
#ifdef _KERNEL	/* XXX nonstandard */
sl@0
   168
#define IN6MASK0	{{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
sl@0
   169
#define IN6MASK32	{{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
sl@0
   170
			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
sl@0
   171
#define IN6MASK64	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
sl@0
   172
			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
sl@0
   173
#define IN6MASK96	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
sl@0
   174
			    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
sl@0
   175
#define IN6MASK128	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
sl@0
   176
			    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
sl@0
   177
#endif
sl@0
   178
sl@0
   179
#ifdef _KERNEL
sl@0
   180
extern const struct sockaddr_in6 sa6_any;
sl@0
   181
sl@0
   182
extern const struct in6_addr in6mask0;
sl@0
   183
extern const struct in6_addr in6mask32;
sl@0
   184
extern const struct in6_addr in6mask64;
sl@0
   185
extern const struct in6_addr in6mask96;
sl@0
   186
extern const struct in6_addr in6mask128;
sl@0
   187
#endif /* _KERNEL */
sl@0
   188
sl@0
   189
/*
sl@0
   190
 * Macros started with IPV6_ADDR is KAME local
sl@0
   191
 */
sl@0
   192
#ifdef _KERNEL	/* XXX nonstandard */
sl@0
   193
#if _BYTE_ORDER == _BIG_ENDIAN
sl@0
   194
#define IPV6_ADDR_INT32_ONE	1
sl@0
   195
#define IPV6_ADDR_INT32_TWO	2
sl@0
   196
#define IPV6_ADDR_INT32_MNL	0xff010000
sl@0
   197
#define IPV6_ADDR_INT32_MLL	0xff020000
sl@0
   198
#define IPV6_ADDR_INT32_SMP	0x0000ffff
sl@0
   199
#define IPV6_ADDR_INT16_ULL	0xfe80
sl@0
   200
#define IPV6_ADDR_INT16_USL	0xfec0
sl@0
   201
#define IPV6_ADDR_INT16_MLL	0xff02
sl@0
   202
#elif _BYTE_ORDER == _LITTLE_ENDIAN
sl@0
   203
#define IPV6_ADDR_INT32_ONE	0x01000000
sl@0
   204
#define IPV6_ADDR_INT32_TWO	0x02000000
sl@0
   205
#define IPV6_ADDR_INT32_MNL	0x000001ff
sl@0
   206
#define IPV6_ADDR_INT32_MLL	0x000002ff
sl@0
   207
#define IPV6_ADDR_INT32_SMP	0xffff0000
sl@0
   208
#define IPV6_ADDR_INT16_ULL	0x80fe
sl@0
   209
#define IPV6_ADDR_INT16_USL	0xc0fe
sl@0
   210
#define IPV6_ADDR_INT16_MLL	0x02ff
sl@0
   211
#endif
sl@0
   212
#endif
sl@0
   213
sl@0
   214
/*
sl@0
   215
 * Definition of some useful macros to handle IP6 addresses
sl@0
   216
 */
sl@0
   217
#if __BSD_VISIBLE
sl@0
   218
#define IN6ADDR_ANY_INIT \
sl@0
   219
	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   220
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
sl@0
   221
#define IN6ADDR_LOOPBACK_INIT \
sl@0
   222
	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   223
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
sl@0
   224
#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
sl@0
   225
	{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   226
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
sl@0
   227
#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
sl@0
   228
	{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   229
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
sl@0
   230
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
sl@0
   231
	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   232
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
sl@0
   233
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
sl@0
   234
	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
sl@0
   235
	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
sl@0
   236
#endif
sl@0
   237
sl@0
   238
#ifndef __SYMBIAN32__
sl@0
   239
extern const struct in6_addr in6addr_any;
sl@0
   240
extern const struct in6_addr in6addr_loopback;
sl@0
   241
#if __BSD_VISIBLE
sl@0
   242
extern const struct in6_addr in6addr_nodelocal_allnodes;
sl@0
   243
extern const struct in6_addr in6addr_linklocal_allnodes;
sl@0
   244
extern const struct in6_addr in6addr_linklocal_allrouters;
sl@0
   245
#endif
sl@0
   246
#endif//__SYMBIAN32__
sl@0
   247
sl@0
   248
/*
sl@0
   249
 * Equality
sl@0
   250
 * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
sl@0
   251
 * does not supply memcmp().  For userland memcmp() is preferred as it is
sl@0
   252
 * in ANSI standard.
sl@0
   253
 */
sl@0
   254
#ifdef _KERNEL
sl@0
   255
#define IN6_ARE_ADDR_EQUAL(a, b)			\
sl@0
   256
    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
sl@0
   257
#else
sl@0
   258
#if __BSD_VISIBLE
sl@0
   259
#define IN6_ARE_ADDR_EQUAL(a, b)			\
sl@0
   260
    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
sl@0
   261
#endif
sl@0
   262
#endif
sl@0
   263
sl@0
   264
#ifdef _KERNEL			/* non standard */
sl@0
   265
/* see if two addresses are equal in a scope-conscious manner. */
sl@0
   266
#define SA6_ARE_ADDR_EQUAL(a, b) \
sl@0
   267
	(((a)->sin6_scope_id == 0 || (b)->sin6_scope_id == 0 || \
sl@0
   268
	  ((a)->sin6_scope_id == (b)->sin6_scope_id)) && \
sl@0
   269
	 (bcmp(&(a)->sin6_addr, &(b)->sin6_addr, sizeof(struct in6_addr)) == 0))
sl@0
   270
#endif
sl@0
   271
sl@0
   272
/*
sl@0
   273
 * Unspecified
sl@0
   274
 */
sl@0
   275
#define IN6_IS_ADDR_UNSPECIFIED(a)	\
sl@0
   276
	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
sl@0
   277
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
sl@0
   278
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
sl@0
   279
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
sl@0
   280
sl@0
   281
/*
sl@0
   282
 * Loopback
sl@0
   283
 */
sl@0
   284
#define IN6_IS_ADDR_LOOPBACK(a)		\
sl@0
   285
	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
sl@0
   286
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
sl@0
   287
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
sl@0
   288
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
sl@0
   289
sl@0
   290
/*
sl@0
   291
 * IPv4 compatible
sl@0
   292
 */
sl@0
   293
#define IN6_IS_ADDR_V4COMPAT(a)		\
sl@0
   294
	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
sl@0
   295
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
sl@0
   296
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&	\
sl@0
   297
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) &&	\
sl@0
   298
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
sl@0
   299
sl@0
   300
/*
sl@0
   301
 * Mapped
sl@0
   302
 */
sl@0
   303
#define IN6_IS_ADDR_V4MAPPED(a)		      \
sl@0
   304
	((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&	\
sl@0
   305
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&	\
sl@0
   306
	 (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
sl@0
   307
sl@0
   308
/*
sl@0
   309
 * KAME Scope Values
sl@0
   310
 */
sl@0
   311
sl@0
   312
#ifdef _KERNEL	/* XXX nonstandard */
sl@0
   313
#define IPV6_ADDR_SCOPE_NODELOCAL	0x01
sl@0
   314
#define IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
sl@0
   315
#define IPV6_ADDR_SCOPE_LINKLOCAL	0x02
sl@0
   316
#define IPV6_ADDR_SCOPE_SITELOCAL	0x05
sl@0
   317
#define IPV6_ADDR_SCOPE_ORGLOCAL	0x08	/* just used in this file */
sl@0
   318
#define IPV6_ADDR_SCOPE_GLOBAL		0x0e
sl@0
   319
#else
sl@0
   320
#define __IPV6_ADDR_SCOPE_NODELOCAL	0x01
sl@0
   321
#define __IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
sl@0
   322
#define __IPV6_ADDR_SCOPE_LINKLOCAL	0x02
sl@0
   323
#define __IPV6_ADDR_SCOPE_SITELOCAL	0x05
sl@0
   324
#define __IPV6_ADDR_SCOPE_ORGLOCAL	0x08	/* just used in this file */
sl@0
   325
#define __IPV6_ADDR_SCOPE_GLOBAL	0x0e
sl@0
   326
#endif
sl@0
   327
sl@0
   328
/*
sl@0
   329
 * Unicast Scope
sl@0
   330
 * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
sl@0
   331
 */
sl@0
   332
#define IN6_IS_ADDR_LINKLOCAL(a)	\
sl@0
   333
	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
sl@0
   334
#define IN6_IS_ADDR_SITELOCAL(a)	\
sl@0
   335
	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
sl@0
   336
sl@0
   337
/*
sl@0
   338
 * Multicast
sl@0
   339
 */
sl@0
   340
#define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr[0] == 0xff)
sl@0
   341
sl@0
   342
#ifdef _KERNEL	/* XXX nonstandard */
sl@0
   343
#define IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
sl@0
   344
#else
sl@0
   345
#define __IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
sl@0
   346
#endif
sl@0
   347
sl@0
   348
/*
sl@0
   349
 * Multicast Scope
sl@0
   350
 */
sl@0
   351
#ifdef _KERNEL	/* refers nonstandard items */
sl@0
   352
#define IN6_IS_ADDR_MC_NODELOCAL(a)	\
sl@0
   353
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   354
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
sl@0
   355
#define IN6_IS_ADDR_MC_INTFACELOCAL(a)	\
sl@0
   356
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   357
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
sl@0
   358
#define IN6_IS_ADDR_MC_LINKLOCAL(a)	\
sl@0
   359
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   360
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
sl@0
   361
#define IN6_IS_ADDR_MC_SITELOCAL(a)	\
sl@0
   362
	(IN6_IS_ADDR_MULTICAST(a) && 	\
sl@0
   363
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
sl@0
   364
#define IN6_IS_ADDR_MC_ORGLOCAL(a)	\
sl@0
   365
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   366
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
sl@0
   367
#define IN6_IS_ADDR_MC_GLOBAL(a)	\
sl@0
   368
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   369
	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
sl@0
   370
#else
sl@0
   371
#define IN6_IS_ADDR_MC_NODELOCAL(a)	\
sl@0
   372
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   373
	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
sl@0
   374
#define IN6_IS_ADDR_MC_LINKLOCAL(a)	\
sl@0
   375
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   376
	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
sl@0
   377
#define IN6_IS_ADDR_MC_SITELOCAL(a)	\
sl@0
   378
	(IN6_IS_ADDR_MULTICAST(a) && 	\
sl@0
   379
	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
sl@0
   380
#define IN6_IS_ADDR_MC_ORGLOCAL(a)	\
sl@0
   381
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   382
	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
sl@0
   383
#define IN6_IS_ADDR_MC_GLOBAL(a)	\
sl@0
   384
	(IN6_IS_ADDR_MULTICAST(a) &&	\
sl@0
   385
	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
sl@0
   386
#endif
sl@0
   387
sl@0
   388
#ifdef _KERNEL	/* nonstandard */
sl@0
   389
/*
sl@0
   390
 * KAME Scope
sl@0
   391
 */
sl@0
   392
#define IN6_IS_SCOPE_LINKLOCAL(a)	\
sl@0
   393
	((IN6_IS_ADDR_LINKLOCAL(a)) ||	\
sl@0
   394
	 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
sl@0
   395
sl@0
   396
#define IFA6_IS_DEPRECATED(a) \
sl@0
   397
	((a)->ia6_lifetime.ia6t_preferred != 0 && \
sl@0
   398
	 (a)->ia6_lifetime.ia6t_preferred < time_second)
sl@0
   399
#define IFA6_IS_INVALID(a) \
sl@0
   400
	((a)->ia6_lifetime.ia6t_expire != 0 && \
sl@0
   401
	 (a)->ia6_lifetime.ia6t_expire < time_second)
sl@0
   402
#endif /* _KERNEL */
sl@0
   403
sl@0
   404
/*
sl@0
   405
 * IP6 route structure
sl@0
   406
 */
sl@0
   407
#if __BSD_VISIBLE
sl@0
   408
struct route_in6 {
sl@0
   409
	struct	rtentry *ro_rt;
sl@0
   410
	struct	sockaddr_in6 ro_dst;
sl@0
   411
};
sl@0
   412
#endif
sl@0
   413
sl@0
   414
/*
sl@0
   415
 * Options for use with [gs]etsockopt at the IPV6 level.
sl@0
   416
 * First word of comment is data type; bool is stored in int.
sl@0
   417
 */
sl@0
   418
/* no hdrincl */
sl@0
   419
#if 0 /* the followings are relic in IPv4 and hence are disabled */
sl@0
   420
#define IPV6_OPTIONS		1  /* buf/ip6_opts; set/get IP6 options */
sl@0
   421
#define IPV6_RECVOPTS		5  /* bool; receive all IP6 opts w/dgram */
sl@0
   422
#define IPV6_RECVRETOPTS	6  /* bool; receive IP6 opts for response */
sl@0
   423
#define IPV6_RECVDSTADDR	7  /* bool; receive IP6 dst addr w/dgram */
sl@0
   424
#define IPV6_RETOPTS		8  /* ip6_opts; set/get IP6 options */
sl@0
   425
#endif
sl@0
   426
#define IPV6_SOCKOPT_RESERVED1	3  /* reserved for future use */
sl@0
   427
#define IPV6_UNICAST_HOPS	4  /* int; IP6 hops */
sl@0
   428
#define IPV6_MULTICAST_IF	9  /* u_int; set/get IP6 multicast i/f  */
sl@0
   429
#define IPV6_MULTICAST_HOPS	10 /* int; set/get IP6 multicast hops */
sl@0
   430
#define IPV6_MULTICAST_LOOP	11 /* u_int; set/get IP6 multicast loopback */
sl@0
   431
#define IPV6_JOIN_GROUP		12 /* ip6_mreq; join a group membership */
sl@0
   432
#define IPV6_LEAVE_GROUP	13 /* ip6_mreq; leave a group membership */
sl@0
   433
#define IPV6_PORTRANGE		14 /* int; range to choose for unspec port */
sl@0
   434
#define ICMP6_FILTER		18 /* icmp6_filter; icmp6 filter */
sl@0
   435
/* RFC2292 options */
sl@0
   436
#ifdef _KERNEL
sl@0
   437
#define IPV6_2292PKTINFO	19 /* bool; send/recv if, src/dst addr */
sl@0
   438
#define IPV6_2292HOPLIMIT	20 /* bool; hop limit */
sl@0
   439
#define IPV6_2292NEXTHOP	21 /* bool; next hop addr */
sl@0
   440
#define IPV6_2292HOPOPTS	22 /* bool; hop-by-hop option */
sl@0
   441
#define IPV6_2292DSTOPTS	23 /* bool; destinaion option */
sl@0
   442
#define IPV6_2292RTHDR		24 /* bool; routing header */
sl@0
   443
#define IPV6_2292PKTOPTIONS	25 /* buf/cmsghdr; set/get IPv6 options */
sl@0
   444
#endif
sl@0
   445
sl@0
   446
#define IPV6_CHECKSUM		26 /* int; checksum offset for raw socket */
sl@0
   447
#define IPV6_V6ONLY		27 /* bool; make AF_INET6 sockets v6 only */
sl@0
   448
#ifndef _KERNEL
sl@0
   449
#define IPV6_BINDV6ONLY		IPV6_V6ONLY
sl@0
   450
#endif
sl@0
   451
sl@0
   452
#if 1 /* IPSEC */
sl@0
   453
#define IPV6_IPSEC_POLICY	28 /* struct; get/set security policy */
sl@0
   454
#endif
sl@0
   455
#define IPV6_FAITH		29 /* bool; accept FAITH'ed connections */
sl@0
   456
sl@0
   457
#if 1 /* IPV6FIREWALL */
sl@0
   458
#define IPV6_FW_ADD		30 /* add a firewall rule to chain */
sl@0
   459
#define IPV6_FW_DEL		31 /* delete a firewall rule from chain */
sl@0
   460
#define IPV6_FW_FLUSH		32 /* flush firewall rule chain */
sl@0
   461
#define IPV6_FW_ZERO		33 /* clear single/all firewall counter(s) */
sl@0
   462
#define IPV6_FW_GET		34 /* get entire firewall rule chain */
sl@0
   463
#endif
sl@0
   464
sl@0
   465
/* new socket options introduced in RFC3542 */
sl@0
   466
#define IPV6_RTHDRDSTOPTS	35 /* ip6_dest; send dst option before rthdr */
sl@0
   467
sl@0
   468
#define IPV6_RECVPKTINFO	36 /* bool; recv if, dst addr */
sl@0
   469
#define IPV6_RECVHOPLIMIT	37 /* bool; recv hop limit */
sl@0
   470
#define IPV6_RECVRTHDR		38 /* bool; recv routing header */
sl@0
   471
#define IPV6_RECVHOPOPTS	39 /* bool; recv hop-by-hop option */
sl@0
   472
#define IPV6_RECVDSTOPTS	40 /* bool; recv dst option after rthdr */
sl@0
   473
#ifdef _KERNEL
sl@0
   474
#define IPV6_RECVRTHDRDSTOPTS	41 /* bool; recv dst option before rthdr */
sl@0
   475
#endif
sl@0
   476
sl@0
   477
#define IPV6_USE_MIN_MTU	42 /* bool; send packets at the minimum MTU */
sl@0
   478
#define IPV6_RECVPATHMTU	43 /* bool; notify an according MTU */
sl@0
   479
sl@0
   480
#define IPV6_PATHMTU		44 /* mtuinfo; get the current path MTU (sopt),
sl@0
   481
				      4 bytes int; MTU notification (cmsg) */
sl@0
   482
#if 0 /*obsoleted during 2292bis -> 3542*/
sl@0
   483
#define IPV6_REACHCONF		45 /* no data; ND reachability confirm
sl@0
   484
				      (cmsg only/not in of RFC3542) */
sl@0
   485
#endif
sl@0
   486
sl@0
   487
/* more new socket options introduced in RFC3542 */
sl@0
   488
#define IPV6_PKTINFO		46 /* in6_pktinfo; send if, src addr */
sl@0
   489
#define IPV6_HOPLIMIT		47 /* int; send hop limit */
sl@0
   490
#define IPV6_NEXTHOP		48 /* sockaddr; next hop addr */
sl@0
   491
#define IPV6_HOPOPTS		49 /* ip6_hbh; send hop-by-hop option */
sl@0
   492
#define IPV6_DSTOPTS		50 /* ip6_dest; send dst option befor rthdr */
sl@0
   493
#define IPV6_RTHDR		51 /* ip6_rthdr; send routing header */
sl@0
   494
#if 0
sl@0
   495
#define IPV6_PKTOPTIONS		52 /* buf/cmsghdr; set/get IPv6 options */
sl@0
   496
				   /* obsoleted by RFC3542 */
sl@0
   497
#endif
sl@0
   498
sl@0
   499
#define IPV6_RECVTCLASS		57 /* bool; recv traffic class values */
sl@0
   500
sl@0
   501
#define IPV6_AUTOFLOWLABEL	59 /* bool; attach flowlabel automagically */
sl@0
   502
sl@0
   503
#define IPV6_TCLASS		61 /* int; send traffic class value */
sl@0
   504
#define IPV6_DONTFRAG		62 /* bool; disable IPv6 fragmentation */
sl@0
   505
sl@0
   506
#define IPV6_PREFER_TEMPADDR	63 /* int; prefer temporary addresses as
sl@0
   507
				    * the source address.
sl@0
   508
				    */
sl@0
   509
sl@0
   510
/* to define items, should talk with KAME guys first, for *BSD compatibility */
sl@0
   511
sl@0
   512
#define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
sl@0
   513
#define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
sl@0
   514
#define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
sl@0
   515
sl@0
   516
/*
sl@0
   517
 * Defaults and limits for options
sl@0
   518
 */
sl@0
   519
#define IPV6_DEFAULT_MULTICAST_HOPS 1	/* normally limit m'casts to 1 hop */
sl@0
   520
#define IPV6_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member */
sl@0
   521
sl@0
   522
/*
sl@0
   523
 * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
sl@0
   524
 */
sl@0
   525
struct ipv6_mreq {
sl@0
   526
	struct in6_addr	ipv6mr_multiaddr;
sl@0
   527
	unsigned int	ipv6mr_interface;
sl@0
   528
};
sl@0
   529
sl@0
   530
/*
sl@0
   531
 * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
sl@0
   532
 */
sl@0
   533
struct in6_pktinfo {
sl@0
   534
	struct in6_addr	ipi6_addr;	/* src/dst IPv6 address */
sl@0
   535
	unsigned int	ipi6_ifindex;	/* send/recv interface index */
sl@0
   536
};
sl@0
   537
sl@0
   538
/*
sl@0
   539
 * Control structure for IPV6_RECVPATHMTU socket option.
sl@0
   540
 */
sl@0
   541
struct ip6_mtuinfo {
sl@0
   542
	struct sockaddr_in6 ip6m_addr;	/* or sockaddr_storage? */
sl@0
   543
	uint32_t ip6m_mtu;
sl@0
   544
};
sl@0
   545
sl@0
   546
/*
sl@0
   547
 * Argument for IPV6_PORTRANGE:
sl@0
   548
 * - which range to search when port is unspecified at bind() or connect()
sl@0
   549
 */
sl@0
   550
#define	IPV6_PORTRANGE_DEFAULT	0	/* default range */
sl@0
   551
#define	IPV6_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
sl@0
   552
#define	IPV6_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
sl@0
   553
sl@0
   554
#if __BSD_VISIBLE
sl@0
   555
/*
sl@0
   556
 * Definitions for inet6 sysctl operations.
sl@0
   557
 *
sl@0
   558
 * Third level is protocol number.
sl@0
   559
 * Fourth level is desired variable within that protocol.
sl@0
   560
 */
sl@0
   561
#define IPV6PROTO_MAXID	(IPPROTO_PIM + 1)	/* don't list to IPV6PROTO_MAX */
sl@0
   562
sl@0
   563
/*
sl@0
   564
 * Names for IP sysctl objects
sl@0
   565
 */
sl@0
   566
#define IPV6CTL_FORWARDING	1	/* act as router */
sl@0
   567
#define IPV6CTL_SENDREDIRECTS	2	/* may send redirects when forwarding*/
sl@0
   568
#define IPV6CTL_DEFHLIM		3	/* default Hop-Limit */
sl@0
   569
#ifdef notyet
sl@0
   570
#define IPV6CTL_DEFMTU		4	/* default MTU */
sl@0
   571
#endif
sl@0
   572
#define IPV6CTL_FORWSRCRT	5	/* forward source-routed dgrams */
sl@0
   573
#define IPV6CTL_STATS		6	/* stats */
sl@0
   574
#define IPV6CTL_MRTSTATS	7	/* multicast forwarding stats */
sl@0
   575
#define IPV6CTL_MRTPROTO	8	/* multicast routing protocol */
sl@0
   576
#define IPV6CTL_MAXFRAGPACKETS	9	/* max packets reassembly queue */
sl@0
   577
#define IPV6CTL_SOURCECHECK	10	/* verify source route and intf */
sl@0
   578
#define IPV6CTL_SOURCECHECK_LOGINT 11	/* minimume logging interval */
sl@0
   579
#define IPV6CTL_ACCEPT_RTADV	12
sl@0
   580
#define IPV6CTL_KEEPFAITH	13
sl@0
   581
#define IPV6CTL_LOG_INTERVAL	14
sl@0
   582
#define IPV6CTL_HDRNESTLIMIT	15
sl@0
   583
#define IPV6CTL_DAD_COUNT	16
sl@0
   584
#define IPV6CTL_AUTO_FLOWLABEL	17
sl@0
   585
#define IPV6CTL_DEFMCASTHLIM	18
sl@0
   586
#define IPV6CTL_GIF_HLIM	19	/* default HLIM for gif encap packet */
sl@0
   587
#define IPV6CTL_KAME_VERSION	20
sl@0
   588
#define IPV6CTL_USE_DEPRECATED	21	/* use deprecated addr (RFC2462 5.5.4) */
sl@0
   589
#define IPV6CTL_RR_PRUNE	22	/* walk timer for router renumbering */
sl@0
   590
#if 0	/* obsolete */
sl@0
   591
#define IPV6CTL_MAPPED_ADDR	23
sl@0
   592
#endif
sl@0
   593
#define IPV6CTL_V6ONLY		24
sl@0
   594
#define IPV6CTL_RTEXPIRE	25	/* cloned route expiration time */
sl@0
   595
#define IPV6CTL_RTMINEXPIRE	26	/* min value for expiration time */
sl@0
   596
#define IPV6CTL_RTMAXCACHE	27	/* trigger level for dynamic expire */
sl@0
   597
sl@0
   598
#define IPV6CTL_USETEMPADDR	32	/* use temporary addresses (RFC3041) */
sl@0
   599
#define IPV6CTL_TEMPPLTIME	33	/* preferred lifetime for tmpaddrs */
sl@0
   600
#define IPV6CTL_TEMPVLTIME	34	/* valid lifetime for tmpaddrs */
sl@0
   601
#define IPV6CTL_AUTO_LINKLOCAL	35	/* automatic link-local addr assign */
sl@0
   602
#define IPV6CTL_RIP6STATS	36	/* raw_ip6 stats */
sl@0
   603
#define IPV6CTL_PREFER_TEMPADDR	37	/* prefer temporary addr as src */
sl@0
   604
#define IPV6CTL_ADDRCTLPOLICY	38	/* get/set address selection policy */
sl@0
   605
sl@0
   606
#define IPV6CTL_MAXFRAGS	41	/* max fragments */
sl@0
   607
sl@0
   608
/* New entries should be added here from current IPV6CTL_MAXID value. */
sl@0
   609
/* to define items, should talk with KAME guys first, for *BSD compatibility */
sl@0
   610
/* 42-44 is already used in KAME */
sl@0
   611
#define IPV6CTL_STEALTH		45
sl@0
   612
#define IPV6CTL_MAXID		46
sl@0
   613
#endif /* __BSD_VISIBLE */
sl@0
   614
sl@0
   615
/*
sl@0
   616
 * Redefinition of mbuf flags
sl@0
   617
 */
sl@0
   618
#define	M_AUTHIPHDR	M_PROTO2
sl@0
   619
#define	M_DECRYPTED	M_PROTO3
sl@0
   620
#define	M_LOOP		M_PROTO4
sl@0
   621
#define	M_AUTHIPDGM	M_PROTO5
sl@0
   622
sl@0
   623
#ifdef _KERNEL
sl@0
   624
struct cmsghdr;
sl@0
   625
sl@0
   626
struct sockaddr;
sl@0
   627
extern	u_char	ip6_protox[];
sl@0
   628
#define	satosin6(sa)	((struct sockaddr_in6 *)(sa))
sl@0
   629
#define	sin6tosa(sin6)	((struct sockaddr *)(sin6))
sl@0
   630
#define	ifatoia6(ifa)	((struct in6_ifaddr *)(ifa))
sl@0
   631
sl@0
   632
extern int	(*faithprefix_p)(struct in6_addr *);
sl@0
   633
#endif /* _KERNEL */
sl@0
   634
sl@0
   635
#ifndef _SIZE_T_DECLARED
sl@0
   636
typedef	__size_t	size_t;
sl@0
   637
#define	_SIZE_T_DECLARED
sl@0
   638
#endif
sl@0
   639
sl@0
   640
#ifndef _SOCKLEN_T_DECLARED
sl@0
   641
typedef	__socklen_t	socklen_t;
sl@0
   642
#define	_SOCKLEN_T_DECLARED
sl@0
   643
#endif
sl@0
   644
sl@0
   645
#if __BSD_VISIBLE
sl@0
   646
sl@0
   647
__BEGIN_DECLS
sl@0
   648
struct cmsghdr;
sl@0
   649
__END_DECLS
sl@0
   650
sl@0
   651
#endif /* __BSD_VISIBLE */
sl@0
   652
sl@0
   653
#endif /* !_NETINET6_IN6_H_ */