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