Line data Source code
1 : /* $OpenBSD: in6.h,v 1.103 2018/09/11 21:04:03 bluhm Exp $ */
2 : /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
3 :
4 : /*
5 : * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 : * All rights reserved.
7 : *
8 : * Redistribution and use in source and binary forms, with or without
9 : * modification, are permitted provided that the following conditions
10 : * are met:
11 : * 1. Redistributions of source code must retain the above copyright
12 : * notice, this list of conditions and the following disclaimer.
13 : * 2. Redistributions in binary form must reproduce the above copyright
14 : * notice, this list of conditions and the following disclaimer in the
15 : * documentation and/or other materials provided with the distribution.
16 : * 3. Neither the name of the project nor the names of its contributors
17 : * may be used to endorse or promote products derived from this software
18 : * without specific prior written permission.
19 : *
20 : * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 : * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 : * SUCH DAMAGE.
31 : */
32 :
33 : /*
34 : * Copyright (c) 1982, 1986, 1990, 1993
35 : * The Regents of the University of California. All rights reserved.
36 : *
37 : * Redistribution and use in source and binary forms, with or without
38 : * modification, are permitted provided that the following conditions
39 : * are met:
40 : * 1. Redistributions of source code must retain the above copyright
41 : * notice, this list of conditions and the following disclaimer.
42 : * 2. Redistributions in binary form must reproduce the above copyright
43 : * notice, this list of conditions and the following disclaimer in the
44 : * documentation and/or other materials provided with the distribution.
45 : * 3. Neither the name of the University nor the names of its contributors
46 : * may be used to endorse or promote products derived from this software
47 : * without specific prior written permission.
48 : *
49 : * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 : * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 : * SUCH DAMAGE.
60 : *
61 : * @(#)in.h 8.3 (Berkeley) 1/3/94
62 : */
63 :
64 : #ifndef __KAME_NETINET_IN_H_INCLUDED_
65 : #error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553"
66 : #endif
67 :
68 : #ifndef _NETINET6_IN6_H_
69 : #define _NETINET6_IN6_H_
70 :
71 : /*
72 : * Identification of the network protocol stack
73 : * for *BSD-current/release: http://www.kame.net/dev/cvsweb2.cgi/kame/COVERAGE
74 : * has the table of implementation/integration differences.
75 : */
76 : #define __KAME__
77 :
78 : /*
79 : * IPv6 address
80 : */
81 : struct in6_addr {
82 : union {
83 : u_int8_t __u6_addr8[16];
84 : u_int16_t __u6_addr16[8];
85 : u_int32_t __u6_addr32[4];
86 : } __u6_addr; /* 128-bit IP6 address */
87 : };
88 :
89 : #define s6_addr __u6_addr.__u6_addr8
90 : #ifdef _KERNEL /* XXX nonstandard */
91 : #define s6_addr8 __u6_addr.__u6_addr8
92 : #define s6_addr16 __u6_addr.__u6_addr16
93 : #define s6_addr32 __u6_addr.__u6_addr32
94 : #endif
95 :
96 : #ifndef INET6_ADDRSTRLEN
97 : #define INET6_ADDRSTRLEN 46
98 : #endif
99 :
100 : /*
101 : * Socket address for IPv6
102 : */
103 : #if __BSD_VISIBLE
104 : #define SIN6_LEN /* Indicates sockaddr_in6 has a sin6_len field */
105 : #endif /* __BSD_VISIBLE */
106 : struct sockaddr_in6 {
107 : u_int8_t sin6_len; /* length of this struct(sa_family_t)*/
108 : sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */
109 : in_port_t sin6_port; /* Transport layer port # (in_port_t)*/
110 : u_int32_t sin6_flowinfo; /* IP6 flow information */
111 : struct in6_addr sin6_addr; /* IP6 address */
112 : u_int32_t sin6_scope_id; /* intface scope id */
113 : };
114 :
115 :
116 : /*
117 : * Local definition for masks
118 : */
119 : #ifdef _KERNEL /* XXX nonstandard */
120 : #define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
121 : #define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
122 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
123 : #define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
124 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
125 : #define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
126 : 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
127 : #define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
128 : 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
129 :
130 : extern const struct sockaddr_in6 sa6_any;
131 :
132 : extern const struct in6_addr in6mask0;
133 : extern const struct in6_addr in6mask32;
134 : extern const struct in6_addr in6mask64;
135 : extern const struct in6_addr in6mask96;
136 : extern const struct in6_addr in6mask128;
137 : #endif /* _KERNEL */
138 :
139 : /* Both kernel and libc define these for use */
140 : extern const struct in6_addr in6addr_any;
141 : extern const struct in6_addr in6addr_loopback;
142 : extern const struct in6_addr in6addr_intfacelocal_allnodes;
143 : extern const struct in6_addr in6addr_linklocal_allnodes;
144 : extern const struct in6_addr in6addr_linklocal_allrouters;
145 :
146 : #if __BSD_VISIBLE
147 : /*
148 : * IPv6 route structure
149 : */
150 : struct route_in6 {
151 : struct rtentry *ro_rt;
152 : u_long ro_tableid; /* padded to long for alignment */
153 : struct sockaddr_in6 ro_dst;
154 : };
155 :
156 : /*
157 : * Definition of some useful macros to handle IP6 addresses
158 : */
159 : #define IN6ADDR_ANY_INIT \
160 : {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
161 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
162 : #define IN6ADDR_LOOPBACK_INIT \
163 : {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
164 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
165 : #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
166 : {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
167 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
168 : #define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
169 : {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
170 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
171 : #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
172 : {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
173 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
174 : #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
175 : {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
176 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
177 :
178 : #define IN6_ARE_ADDR_EQUAL(a, b) \
179 : (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
180 :
181 : #endif /* __BSD_VISIBLE */
182 :
183 : /*
184 : * Macros started with IPV6_ADDR is KAME local
185 : */
186 : #define __IPV6_ADDR_INT32_ONE htonl(1)
187 : #define __IPV6_ADDR_INT32_TWO htonl(2)
188 : #define __IPV6_ADDR_INT32_MNL htonl(0xff010000)
189 : #define __IPV6_ADDR_INT32_MLL htonl(0xff020000)
190 : #define __IPV6_ADDR_INT32_SMP htonl(0x0000ffff)
191 : #define __IPV6_ADDR_INT16_ULL htons(0xfe80)
192 : #define __IPV6_ADDR_INT16_USL htons(0xfec0)
193 : #define __IPV6_ADDR_INT16_MLL htons(0xff02)
194 :
195 : /*
196 : * Unspecified
197 : */
198 : #define IN6_IS_ADDR_UNSPECIFIED(a) \
199 : ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
200 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
201 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
202 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
203 :
204 : /*
205 : * Loopback
206 : */
207 : #define IN6_IS_ADDR_LOOPBACK(a) \
208 : ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
209 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
210 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
211 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == __IPV6_ADDR_INT32_ONE))
212 :
213 : /*
214 : * IPv4 compatible
215 : */
216 : #define IN6_IS_ADDR_V4COMPAT(a) \
217 : ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
218 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
219 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
220 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \
221 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) != __IPV6_ADDR_INT32_ONE))
222 :
223 : /*
224 : * Mapped
225 : */
226 : #define IN6_IS_ADDR_V4MAPPED(a) \
227 : ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
228 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
229 : (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == __IPV6_ADDR_INT32_SMP))
230 :
231 : /*
232 : * Unicast Scope
233 : * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
234 : */
235 : #define IN6_IS_ADDR_LINKLOCAL(a) \
236 : (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
237 : #define IN6_IS_ADDR_SITELOCAL(a) \
238 : (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
239 :
240 : /*
241 : * Multicast
242 : */
243 : #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
244 : #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
245 :
246 : #define __IPV6_ADDR_SCOPE_NODELOCAL 0x01
247 : #define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
248 : #define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02
249 : #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
250 : #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
251 : #define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
252 :
253 : #define IN6_IS_ADDR_MC_NODELOCAL(a) \
254 : (IN6_IS_ADDR_MULTICAST(a) && \
255 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
256 : #define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
257 : (IN6_IS_ADDR_MULTICAST(a) && \
258 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_INTFACELOCAL))
259 : #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
260 : (IN6_IS_ADDR_MULTICAST(a) && \
261 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
262 : #define IN6_IS_ADDR_MC_SITELOCAL(a) \
263 : (IN6_IS_ADDR_MULTICAST(a) && \
264 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
265 : #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
266 : (IN6_IS_ADDR_MULTICAST(a) && \
267 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
268 : #define IN6_IS_ADDR_MC_GLOBAL(a) \
269 : (IN6_IS_ADDR_MULTICAST(a) && \
270 : (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
271 :
272 : #ifdef _KERNEL
273 : #define IN6_IS_SCOPE_LINKLOCAL(a) \
274 : ((IN6_IS_ADDR_LINKLOCAL(a)) || \
275 : (IN6_IS_ADDR_MC_LINKLOCAL(a)))
276 : #define IN6_IS_SCOPE_EMBED(a) \
277 : ((IN6_IS_ADDR_LINKLOCAL(a)) || \
278 : (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
279 : (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
280 :
281 : #define IFA6_IS_DEPRECATED(a) \
282 : ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
283 : (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
284 : (a)->ia6_lifetime.ia6t_pltime)
285 : #define IFA6_IS_INVALID(a) \
286 : ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
287 : (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
288 : (a)->ia6_lifetime.ia6t_vltime)
289 :
290 : #endif /* _KERNEL */
291 :
292 : /*
293 : * Options for use with [gs]etsockopt at the IPV6 level.
294 : * First word of comment is data type; bool is stored in int.
295 : */
296 : #define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
297 : #define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */
298 : #define IPV6_MULTICAST_HOPS 10 /* u_int; set/get IP6 multicast hops */
299 : #define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */
300 : #define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
301 : #define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
302 : #define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
303 : #if __BSD_VISIBLE
304 : #define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
305 : #endif
306 :
307 : #define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
308 : #define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */
309 :
310 : /* new socket options introduced in RFC3542 */
311 : #define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */
312 :
313 : #define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */
314 : #define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */
315 : #define IPV6_RECVRTHDR 38 /* bool; recv routing header */
316 : #define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */
317 : #define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */
318 :
319 : #define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */
320 : #define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */
321 :
322 : #define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt),
323 : 4 bytes int; MTU notification (cmsg) */
324 :
325 : /* More new socket options introduced in RFC3542 */
326 : #define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */
327 : #define IPV6_HOPLIMIT 47 /* int; send hop limit */
328 : #define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */
329 : #define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */
330 : #define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */
331 : #define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */
332 :
333 : #define IPV6_AUTH_LEVEL 53 /* int; authentication used */
334 : #define IPV6_ESP_TRANS_LEVEL 54 /* int; transport encryption */
335 : #define IPV6_ESP_NETWORK_LEVEL 55 /* int; full-packet encryption */
336 : #if __BSD_VISIBLE
337 : #define IPSEC6_OUTSA 56 /* set the outbound SA for a socket */
338 : #endif
339 : #define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */
340 :
341 : #define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */
342 : #define IPV6_IPCOMP_LEVEL 60 /* int; compression */
343 :
344 : #define IPV6_TCLASS 61 /* int; send traffic class value */
345 : #define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */
346 : #define IPV6_PIPEX 63 /* bool; using PIPEX */
347 :
348 : #define IPV6_RECVDSTPORT 64 /* bool; receive IP dst port w/dgram */
349 : #define IPV6_MINHOPCOUNT 65 /* int; minimum recv hop limit */
350 :
351 : #define IPV6_RTABLE 0x1021 /* int; routing table, see SO_RTABLE */
352 :
353 : /* to define items, should talk with KAME guys first, for *BSD compatibility */
354 : #define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor */
355 : #define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */
356 :
357 : /*
358 : * Defaults and limits for options
359 : */
360 : #define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
361 : #define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
362 :
363 : /*
364 : * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
365 : */
366 : struct ipv6_mreq {
367 : struct in6_addr ipv6mr_multiaddr;
368 : unsigned int ipv6mr_interface;
369 : };
370 :
371 : /*
372 : * IPV6_PKTINFO: Packet information(RFC3542 sec 6)
373 : */
374 : struct in6_pktinfo {
375 : struct in6_addr ipi6_addr; /* src/dst IPv6 address */
376 : unsigned int ipi6_ifindex; /* send/recv interface index */
377 : };
378 :
379 : /*
380 : * Control structure for IPV6_RECVPATHMTU socket option.
381 : * XXX Not allowed here by POSIX, but required by RFC 3542, so go
382 : * XXX with the code on the pavement.
383 : */
384 : struct ip6_mtuinfo {
385 : struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */
386 : u_int32_t ip6m_mtu;
387 : };
388 :
389 : /*
390 : * Argument for IPV6_PORTRANGE:
391 : * - which range to search when port is unspecified at bind() or connect()
392 : */
393 : #define IPV6_PORTRANGE_DEFAULT 0 /* default range */
394 : #define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
395 : #define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
396 :
397 : #ifdef __BSD_VISIBLE
398 :
399 : #ifndef _SOCKLEN_T_DEFINED_
400 : #define _SOCKLEN_T_DEFINED_
401 : typedef __socklen_t socklen_t; /* length type for network syscalls */
402 : #endif
403 :
404 : #endif /* __BSD_VISIBLE */
405 :
406 : #ifdef _KERNEL
407 : extern const u_char inet6ctlerrmap[];
408 : extern const struct in6_addr zeroin6_addr;
409 :
410 : struct mbuf;
411 : struct ifnet;
412 : struct cmsghdr;
413 :
414 : void ipv6_input(struct ifnet *, struct mbuf *);
415 :
416 : int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
417 : void in6_proto_cksum_out(struct mbuf *, struct ifnet *);
418 : int in6_localaddr(struct in6_addr *);
419 : int in6_addrscope(struct in6_addr *);
420 : struct in6_ifaddr *in6_ifawithscope(struct ifnet *, struct in6_addr *, u_int);
421 : int in6_mask2len(struct in6_addr *, u_char *);
422 : int in6_nam2sin6(const struct mbuf *, struct sockaddr_in6 **);
423 :
424 : struct inpcb;
425 :
426 : int in6_embedscope(struct in6_addr *, const struct sockaddr_in6 *,
427 : struct inpcb *);
428 : void in6_recoverscope(struct sockaddr_in6 *, const struct in6_addr *);
429 : void in6_clearscope(struct in6_addr *);
430 :
431 : struct sockaddr;
432 : struct sockaddr_in6;
433 : struct ifaddr;
434 : struct in6_ifaddr;
435 :
436 : /*
437 : * Convert between address family specific and general structs.
438 : * Inline functions check the source type and are stricter than
439 : * casts or defines.
440 : */
441 :
442 : static inline struct sockaddr_in6 *
443 0 : satosin6(struct sockaddr *sa)
444 : {
445 0 : return ((struct sockaddr_in6 *)(sa));
446 : }
447 :
448 : static inline struct sockaddr *
449 0 : sin6tosa(struct sockaddr_in6 *sin6)
450 : {
451 0 : return ((struct sockaddr *)(sin6));
452 : }
453 :
454 : static inline struct in6_ifaddr *
455 0 : ifatoia6(struct ifaddr *ifa)
456 : {
457 0 : return ((struct in6_ifaddr *)(ifa));
458 : }
459 :
460 : #endif /* _KERNEL */
461 :
462 : #if __BSD_VISIBLE
463 : /*
464 : * Definitions for inet6 sysctl operations.
465 : *
466 : * Third level is protocol number.
467 : * Fourth level is desired variable within that protocol.
468 : */
469 : #define IPV6PROTO_MAXID (IPPROTO_DIVERT + 1) /* don't list to IPV6PROTO_MAX */
470 :
471 : #define CTL_IPV6PROTO_NAMES { \
472 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
473 : { 0, 0 }, \
474 : { "tcp6", CTLTYPE_NODE }, \
475 : { 0, 0 }, \
476 : { 0, 0 }, \
477 : { 0, 0 }, \
478 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
479 : { 0, 0 }, \
480 : { 0, 0 }, \
481 : { "udp6", CTLTYPE_NODE }, \
482 : { 0, 0 }, \
483 : { 0, 0 }, \
484 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
485 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
486 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
487 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
488 : { 0, 0 }, \
489 : { "ip6", CTLTYPE_NODE }, \
490 : { 0, 0 }, \
491 : { 0, 0 }, \
492 : { 0, 0 }, \
493 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
494 : { 0, 0 }, \
495 : { "ipsec6", CTLTYPE_NODE }, \
496 : { 0, 0 }, \
497 : { 0, 0 }, \
498 : { 0, 0 }, \
499 : { 0, 0 }, \
500 : { 0, 0 }, \
501 : { 0, 0 }, \
502 : { "icmp6", CTLTYPE_NODE }, \
503 : { 0, 0 }, \
504 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
505 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
506 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
507 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
508 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
509 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
510 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
511 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
512 : { 0, 0 }, \
513 : { 0, 0 }, \
514 : { 0, 0 }, \
515 : { 0, 0 }, \
516 : { 0, 0 }, \
517 : { 0, 0 }, \
518 : { 0, 0 }, \
519 : { 0, 0 }, \
520 : { 0, 0 }, \
521 : { 0, 0 }, \
522 : /*110*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
523 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
524 : /*120*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
525 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
526 : /*130*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
527 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
528 : /*140*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
529 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
530 : /*150*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
531 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
532 : /*160*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
533 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
534 : /*170*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
535 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
536 : /*180*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
537 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
538 : /*190*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
539 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
540 : /*200*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
541 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
542 : /*210*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
543 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
544 : /*220*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
545 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
546 : /*230*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
547 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
548 : /*240*/ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
549 : { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
550 : /*250*/ { 0, 0 }, \
551 : { 0, 0 }, \
552 : { 0, 0 }, \
553 : { 0, 0 }, \
554 : { 0, 0 }, \
555 : { 0, 0 }, \
556 : { 0, 0 }, \
557 : { 0, 0 }, \
558 : { "divert", CTLTYPE_NODE }, \
559 : }
560 :
561 : /*
562 : * Names for IP sysctl objects
563 : */
564 : #define IPV6CTL_FORWARDING 1 /* act as router */
565 : #define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/
566 : #define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
567 : #define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
568 : #define IPV6CTL_STATS 6 /* stats */
569 : #define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
570 : #define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
571 : #define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
572 : #define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
573 : #define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
574 : #define IPV6CTL_ACCEPT_RTADV 12
575 : #define IPV6CTL_LOG_INTERVAL 14
576 : #define IPV6CTL_HDRNESTLIMIT 15
577 : #define IPV6CTL_DAD_COUNT 16
578 : #define IPV6CTL_AUTO_FLOWLABEL 17
579 : #define IPV6CTL_DEFMCASTHLIM 18
580 : #define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */
581 : /* 24 to 40: reserved */
582 : #define IPV6CTL_MAXFRAGS 41 /* max fragments */
583 : #define IPV6CTL_MFORWARDING 42
584 : #define IPV6CTL_MULTIPATH 43
585 : #define IPV6CTL_MCAST_PMTU 44 /* path MTU discovery for multicast */
586 : #define IPV6CTL_NEIGHBORGCTHRESH 45
587 : #define IPV6CTL_MAXDYNROUTES 48
588 : #define IPV6CTL_DAD_PENDING 49
589 : #define IPV6CTL_MTUDISCTIMEOUT 50
590 : #define IPV6CTL_IFQUEUE 51
591 : #define IPV6CTL_MRTMIF 52
592 : #define IPV6CTL_MRTMFC 53
593 : #define IPV6CTL_SOIIKEY 54
594 : #define IPV6CTL_MAXID 55
595 :
596 : /* New entries should be added here from current IPV6CTL_MAXID value. */
597 : /* to define items, should talk with KAME guys first, for *BSD compatibility */
598 :
599 : #define IPV6CTL_NAMES { \
600 : { 0, 0 }, \
601 : { "forwarding", CTLTYPE_INT }, \
602 : { "redirect", CTLTYPE_INT }, \
603 : { "hlim", CTLTYPE_INT }, \
604 : { 0, 0 }, \
605 : { "forwsrcrt", CTLTYPE_INT }, \
606 : { 0, 0 }, \
607 : { 0, 0 }, \
608 : { "mrtproto", CTLTYPE_INT }, \
609 : { "maxfragpackets", CTLTYPE_INT }, \
610 : { "sourcecheck", CTLTYPE_INT }, \
611 : { "sourcecheck_logint", CTLTYPE_INT }, \
612 : { 0, 0 }, \
613 : { 0, 0 }, \
614 : { "log_interval", CTLTYPE_INT }, \
615 : { "hdrnestlimit", CTLTYPE_INT }, \
616 : { "dad_count", CTLTYPE_INT }, \
617 : { "auto_flowlabel", CTLTYPE_INT }, \
618 : { "defmcasthlim", CTLTYPE_INT }, \
619 : { 0, 0 }, \
620 : { 0, 0 }, \
621 : { "use_deprecated", CTLTYPE_INT }, \
622 : { 0, 0 }, \
623 : { 0, 0 }, \
624 : { 0, 0 }, \
625 : { 0, 0 }, \
626 : { 0, 0 }, \
627 : { 0, 0 }, \
628 : { 0, 0 }, \
629 : { 0, 0 }, \
630 : { 0, 0 }, \
631 : { 0, 0 }, \
632 : { 0, 0 }, \
633 : { 0, 0 }, \
634 : { 0, 0 }, \
635 : { 0, 0 }, \
636 : { 0, 0 }, \
637 : { 0, 0 }, \
638 : { 0, 0 }, \
639 : { 0, 0 }, \
640 : { 0, 0 }, \
641 : { "maxfrags", CTLTYPE_INT }, \
642 : { "mforwarding", CTLTYPE_INT }, \
643 : { "multipath", CTLTYPE_INT }, \
644 : { "multicast_mtudisc", CTLTYPE_INT }, \
645 : { "neighborgcthresh", CTLTYPE_INT }, \
646 : { 0, 0 }, \
647 : { 0, 0 }, \
648 : { "maxdynroutes", CTLTYPE_INT }, \
649 : { "dad_pending", CTLTYPE_INT }, \
650 : { "mtudisctimeout", CTLTYPE_INT }, \
651 : { "ifq", CTLTYPE_NODE }, \
652 : { "mrtmif", CTLTYPE_STRUCT }, \
653 : { "mrtmfc", CTLTYPE_STRUCT }, \
654 : { "soiikey", CTLTYPE_STRING }, /* binary string */ \
655 : }
656 :
657 : #define IPV6CTL_VARS { \
658 : NULL, \
659 : &ip6_forwarding, \
660 : &ip6_sendredirects, \
661 : &ip6_defhlim, \
662 : NULL, \
663 : NULL, \
664 : NULL, \
665 : NULL, \
666 : NULL, \
667 : &ip6_maxfragpackets, \
668 : NULL, \
669 : NULL, \
670 : NULL, \
671 : NULL, \
672 : &ip6_log_interval, \
673 : &ip6_hdrnestlimit, \
674 : &ip6_dad_count, \
675 : &ip6_auto_flowlabel, \
676 : &ip6_defmcasthlim, \
677 : NULL, \
678 : NULL, \
679 : &ip6_use_deprecated, \
680 : NULL, \
681 : NULL, \
682 : NULL, \
683 : NULL, \
684 : NULL, \
685 : NULL, \
686 : NULL, \
687 : NULL, \
688 : NULL, \
689 : NULL, \
690 : NULL, \
691 : NULL, \
692 : NULL, \
693 : NULL, \
694 : NULL, \
695 : NULL, \
696 : NULL, \
697 : NULL, \
698 : NULL, \
699 : &ip6_maxfrags, \
700 : &ip6_mforwarding, \
701 : &ip6_multipath, \
702 : &ip6_mcast_pmtu, \
703 : &ip6_neighborgcthresh, \
704 : NULL, \
705 : NULL, \
706 : &ip6_maxdynroutes, \
707 : NULL, \
708 : NULL, \
709 : NULL, \
710 : NULL, \
711 : NULL, \
712 : }
713 :
714 : __BEGIN_DECLS
715 : struct cmsghdr;
716 :
717 : extern int inet6_opt_init(void *, socklen_t);
718 : extern int inet6_opt_append(void *, socklen_t, int, u_int8_t,
719 : socklen_t, u_int8_t, void **);
720 : extern int inet6_opt_finish(void *, socklen_t, int);
721 : extern int inet6_opt_set_val(void *, int, void *, socklen_t);
722 :
723 : extern int inet6_opt_next(void *, socklen_t, int, u_int8_t *,
724 : socklen_t *, void **);
725 : extern int inet6_opt_find(void *, socklen_t, int, u_int8_t,
726 : socklen_t *, void **);
727 : extern int inet6_opt_get_val(void *, int, void *, socklen_t);
728 :
729 : extern socklen_t inet6_rth_space(int, int);
730 : extern void *inet6_rth_init(void *, socklen_t, int, int);
731 : extern int inet6_rth_add(void *, const struct in6_addr *);
732 : extern int inet6_rth_reverse(const void *, void *);
733 : extern int inet6_rth_segments(const void *);
734 : extern struct in6_addr *inet6_rth_getaddr(const void *, int);
735 : __END_DECLS
736 : #endif /* __BSD_VISIBLE */
737 :
738 : #endif /* !_NETINET6_IN6_H_ */
|