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