]> git.saurik.com Git - apple/xnu.git/blame - bsd/netinet6/in6_var.h
xnu-1699.22.73.tar.gz
[apple/xnu.git] / bsd / netinet6 / in6_var.h
CommitLineData
b0d623f7 1/*
6d2010ae 2 * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
b0d623f7
A
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
9bccf70c
A
29/* $FreeBSD: src/sys/netinet6/in6_var.h,v 1.3.2.2 2001/07/03 11:01:52 ume Exp $ */
30/* $KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $ */
31
1c79356b
A
32/*
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the project nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60
61/*
62 * Copyright (c) 1985, 1986, 1993
63 * The Regents of the University of California. All rights reserved.
64 *
65 * Redistribution and use in source and binary forms, with or without
66 * modification, are permitted provided that the following conditions
67 * are met:
68 * 1. Redistributions of source code must retain the above copyright
69 * notice, this list of conditions and the following disclaimer.
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in the
72 * documentation and/or other materials provided with the distribution.
73 * 3. All advertising materials mentioning features or use of this software
74 * must display the following acknowledgement:
75 * This product includes software developed by the University of
76 * California, Berkeley and its contributors.
77 * 4. Neither the name of the University nor the names of its contributors
78 * may be used to endorse or promote products derived from this software
79 * without specific prior written permission.
80 *
81 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
82 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
84 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
85 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
91 * SUCH DAMAGE.
92 *
93 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
94 */
95
96#ifndef _NETINET6_IN6_VAR_H_
97#define _NETINET6_IN6_VAR_H_
9bccf70c
A
98#include <sys/appleapiopts.h>
99
6d2010ae
A
100#ifdef XNU_KERNEL_PRIVATE
101#include <sys/tree.h>
102#include <sys/mcache.h>
103#endif
104
9bccf70c
A
105#ifdef __APPLE__
106#include <sys/kern_event.h>
107#endif
1c79356b 108
1c79356b
A
109/*
110 * pltime/vltime are just for future reference (required to implements 2
111 * hour rule for hosts). they should never be modified by nd6_timeout or
112 * anywhere else.
113 * userland -> kernel: accept pltime/vltime
55e303ae 114 * kernel -> userland: throw up everything
1c79356b
A
115 * in kernel: modify preferred/expire only
116 */
117struct in6_addrlifetime {
118 time_t ia6t_expire; /* valid lifetime expiration time */
119 time_t ia6t_preferred; /* preferred lifetime expiration time */
120 u_int32_t ia6t_vltime; /* valid lifetime */
121 u_int32_t ia6t_pltime; /* prefix lifetime */
122};
123
6d2010ae 124#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
125struct in6_addrlifetime_32 {
126 u_int32_t ia6t_expire;
127 u_int32_t ia6t_preferred;
128 u_int32_t ia6t_vltime;
129 u_int32_t ia6t_pltime;
130};
131
132struct in6_addrlifetime_64 {
6d2010ae
A
133 u_int64_t ia6t_expire;
134 u_int64_t ia6t_preferred;
135 u_int32_t ia6t_vltime;
b0d623f7
A
136 u_int32_t ia6t_pltime;
137};
138
139/*
140 * Interface address, IPv6 version. One of these structures
141 * is allocated for each interface with an IPv6 address.
142 * The ifaddr structure contains the protocol-independent part
143 * of the structure and is assumed to be first.
144 */
1c79356b
A
145struct in6_ifaddr {
146 struct ifaddr ia_ifa; /* protocol-independent info */
147#define ia_ifp ia_ifa.ifa_ifp
148#define ia_flags ia_ifa.ifa_flags
149 struct sockaddr_in6 ia_addr; /* interface address */
150 struct sockaddr_in6 ia_net; /* network number of interface */
151 struct sockaddr_in6 ia_dstaddr; /* space for destination addr */
152 struct sockaddr_in6 ia_prefixmask; /* prefix mask */
153 u_int32_t ia_plen; /* prefix length */
154 struct in6_ifaddr *ia_next; /* next in6 list of IP6 addresses */
1c79356b
A
155 int ia6_flags;
156
9bccf70c 157 struct in6_addrlifetime ia6_lifetime;
6d2010ae
A
158 time_t ia6_createtime; /* the creation time of this address, which is
159 * currently used for temporary addresses only.
160 */
161 time_t ia6_updatetime;
162
1c79356b 163 struct ifprefix *ia6_ifpr; /* back pointer to ifprefix */
9bccf70c 164
6d2010ae
A
165 /* back pointer to the ND prefix (for autoconfigured addresses only) */
166 struct nd_prefix *ia6_ndpr;
167
168 /* multicast addresses joined from the kernel */
169 LIST_HEAD(, in6_multi_mship) ia6_memberships;
170};
171#endif /* XNU_KERNEL_PRIVATE */
172
173/* control structure to manage address selection policy */
174struct in6_addrpolicy {
175 struct sockaddr_in6 addr; /* prefix address */
176 struct sockaddr_in6 addrmask; /* prefix mask */
177 int preced; /* precedence */
178 int label; /* matching label */
179 u_quad_t use; /* statistics */
1c79356b
A
180};
181
182/*
183 * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
184 */
185struct in6_ifstat {
186 u_quad_t ifs6_in_receive; /* # of total input datagram */
187 u_quad_t ifs6_in_hdrerr; /* # of datagrams with invalid hdr */
188 u_quad_t ifs6_in_toobig; /* # of datagrams exceeded MTU */
189 u_quad_t ifs6_in_noroute; /* # of datagrams with no route */
190 u_quad_t ifs6_in_addrerr; /* # of datagrams with invalid dst */
191 u_quad_t ifs6_in_protounknown; /* # of datagrams with unknown proto */
192 /* NOTE: increment on final dst if */
193 u_quad_t ifs6_in_truncated; /* # of truncated datagrams */
194 u_quad_t ifs6_in_discard; /* # of discarded datagrams */
195 /* NOTE: fragment timeout is not here */
196 u_quad_t ifs6_in_deliver; /* # of datagrams delivered to ULP */
197 /* NOTE: increment on final dst if */
198 u_quad_t ifs6_out_forward; /* # of datagrams forwarded */
199 /* NOTE: increment on outgoing if */
200 u_quad_t ifs6_out_request; /* # of outgoing datagrams from ULP */
201 /* NOTE: does not include forwrads */
202 u_quad_t ifs6_out_discard; /* # of discarded datagrams */
203 u_quad_t ifs6_out_fragok; /* # of datagrams fragmented */
204 u_quad_t ifs6_out_fragfail; /* # of datagrams failed on fragment */
205 u_quad_t ifs6_out_fragcreat; /* # of fragment datagrams */
206 /* NOTE: this is # after fragment */
207 u_quad_t ifs6_reass_reqd; /* # of incoming fragmented packets */
208 /* NOTE: increment on final dst if */
209 u_quad_t ifs6_reass_ok; /* # of reassembled packets */
210 /* NOTE: this is # after reass */
211 /* NOTE: increment on final dst if */
212 u_quad_t ifs6_reass_fail; /* # of reass failures */
213 /* NOTE: may not be packet count */
214 /* NOTE: increment on final dst if */
215 u_quad_t ifs6_in_mcast; /* # of inbound multicast datagrams */
216 u_quad_t ifs6_out_mcast; /* # of outbound multicast datagrams */
217};
218
219/*
220 * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
221 * XXX: I'm not sure if this file is the right place for this structure...
222 */
223struct icmp6_ifstat {
224 /*
225 * Input statistics
226 */
227 /* ipv6IfIcmpInMsgs, total # of input messages */
228 u_quad_t ifs6_in_msg;
229 /* ipv6IfIcmpInErrors, # of input error messages */
230 u_quad_t ifs6_in_error;
231 /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
232 u_quad_t ifs6_in_dstunreach;
233 /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
234 u_quad_t ifs6_in_adminprohib;
235 /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
236 u_quad_t ifs6_in_timeexceed;
237 /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
238 u_quad_t ifs6_in_paramprob;
239 /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
240 u_quad_t ifs6_in_pkttoobig;
241 /* ipv6IfIcmpInEchos, # of input echo requests */
242 u_quad_t ifs6_in_echo;
243 /* ipv6IfIcmpInEchoReplies, # of input echo replies */
244 u_quad_t ifs6_in_echoreply;
245 /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
246 u_quad_t ifs6_in_routersolicit;
247 /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
248 u_quad_t ifs6_in_routeradvert;
249 /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
250 u_quad_t ifs6_in_neighborsolicit;
251 /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
252 u_quad_t ifs6_in_neighboradvert;
253 /* ipv6IfIcmpInRedirects, # of input redirects */
254 u_quad_t ifs6_in_redirect;
255 /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
256 u_quad_t ifs6_in_mldquery;
257 /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
258 u_quad_t ifs6_in_mldreport;
259 /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
260 u_quad_t ifs6_in_mlddone;
261
262 /*
263 * Output statistics. We should solve unresolved routing problem...
264 */
265 /* ipv6IfIcmpOutMsgs, total # of output messages */
266 u_quad_t ifs6_out_msg;
267 /* ipv6IfIcmpOutErrors, # of output error messages */
268 u_quad_t ifs6_out_error;
269 /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
270 u_quad_t ifs6_out_dstunreach;
271 /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
272 u_quad_t ifs6_out_adminprohib;
273 /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
274 u_quad_t ifs6_out_timeexceed;
275 /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
276 u_quad_t ifs6_out_paramprob;
277 /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
278 u_quad_t ifs6_out_pkttoobig;
279 /* ipv6IfIcmpOutEchos, # of output echo requests */
280 u_quad_t ifs6_out_echo;
281 /* ipv6IfIcmpOutEchoReplies, # of output echo replies */
282 u_quad_t ifs6_out_echoreply;
283 /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
284 u_quad_t ifs6_out_routersolicit;
285 /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
286 u_quad_t ifs6_out_routeradvert;
287 /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
288 u_quad_t ifs6_out_neighborsolicit;
289 /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
290 u_quad_t ifs6_out_neighboradvert;
291 /* ipv6IfIcmpOutRedirects, # of output redirects */
292 u_quad_t ifs6_out_redirect;
293 /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
294 u_quad_t ifs6_out_mldquery;
295 /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
296 u_quad_t ifs6_out_mldreport;
297 /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
298 u_quad_t ifs6_out_mlddone;
299};
300
301struct in6_ifreq {
302 char ifr_name[IFNAMSIZ];
303 union {
304 struct sockaddr_in6 ifru_addr;
305 struct sockaddr_in6 ifru_dstaddr;
6d2010ae 306 int ifru_flags;
1c79356b
A
307 int ifru_flags6;
308 int ifru_metric;
309 caddr_t ifru_data;
310 struct in6_addrlifetime ifru_lifetime;
311 struct in6_ifstat ifru_stat;
312 struct icmp6_ifstat ifru_icmp6stat;
9bccf70c 313 u_int32_t ifru_scope_id[16];
1c79356b
A
314 } ifr_ifru;
315};
316
317struct in6_aliasreq {
318 char ifra_name[IFNAMSIZ];
319 struct sockaddr_in6 ifra_addr;
320 struct sockaddr_in6 ifra_dstaddr;
321 struct sockaddr_in6 ifra_prefixmask;
322 int ifra_flags;
323 struct in6_addrlifetime ifra_lifetime;
324};
325
6d2010ae 326#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
327struct in6_aliasreq_32 {
328 char ifra_name[IFNAMSIZ];
329 struct sockaddr_in6 ifra_addr;
330 struct sockaddr_in6 ifra_dstaddr;
331 struct sockaddr_in6 ifra_prefixmask;
332 int ifra_flags;
333 struct in6_addrlifetime_32 ifra_lifetime;
334};
335
336struct in6_aliasreq_64 {
337 char ifra_name[IFNAMSIZ];
338 struct sockaddr_in6 ifra_addr;
339 struct sockaddr_in6 ifra_dstaddr;
340 struct sockaddr_in6 ifra_prefixmask;
341 int ifra_flags;
342 struct in6_addrlifetime_64 ifra_lifetime;
343};
6d2010ae 344#endif /* XNU_KERNEL_PRIVATE */
b0d623f7 345
1c79356b
A
346/* prefix type macro */
347#define IN6_PREFIX_ND 1
348#define IN6_PREFIX_RR 2
349
350/*
351 * prefix related flags passed between kernel(NDP related part) and
352 * user land command(ifconfig) and daemon(rtadvd).
353 */
354struct in6_prflags {
355 struct prf_ra {
356 u_char onlink : 1;
357 u_char autonomous : 1;
358 u_char reserved : 6;
359 } prf_ra;
360 u_char prf_reserved1;
361 u_short prf_reserved2;
362 /* want to put this on 4byte offset */
363 struct prf_rr {
364 u_char decrvalid : 1;
365 u_char decrprefd : 1;
366 u_char reserved : 6;
367 } prf_rr;
368 u_char prf_reserved3;
369 u_short prf_reserved4;
370};
371
372struct in6_prefixreq {
373 char ipr_name[IFNAMSIZ];
374 u_char ipr_origin;
375 u_char ipr_plen;
376 u_int32_t ipr_vltime;
377 u_int32_t ipr_pltime;
378 struct in6_prflags ipr_flags;
379 struct sockaddr_in6 ipr_prefix;
380};
381
382#define PR_ORIG_RA 0
383#define PR_ORIG_RR 1
384#define PR_ORIG_STATIC 2
385#define PR_ORIG_KERNEL 3
386
387#define ipr_raf_onlink ipr_flags.prf_ra.onlink
388#define ipr_raf_auto ipr_flags.prf_ra.autonomous
389
390#define ipr_statef_onlink ipr_flags.prf_state.onlink
391
392#define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid
393#define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd
394
395struct in6_rrenumreq {
396 char irr_name[IFNAMSIZ];
397 u_char irr_origin;
398 u_char irr_m_len; /* match len for matchprefix */
399 u_char irr_m_minlen; /* minlen for matching prefix */
400 u_char irr_m_maxlen; /* maxlen for matching prefix */
401 u_char irr_u_uselen; /* uselen for adding prefix */
402 u_char irr_u_keeplen; /* keeplen from matching prefix */
403 struct irr_raflagmask {
404 u_char onlink : 1;
405 u_char autonomous : 1;
406 u_char reserved : 6;
407 } irr_raflagmask;
408 u_int32_t irr_vltime;
409 u_int32_t irr_pltime;
410 struct in6_prflags irr_flags;
411 struct sockaddr_in6 irr_matchprefix;
412 struct sockaddr_in6 irr_useprefix;
413};
414
415#define irr_raf_mask_onlink irr_raflagmask.onlink
416#define irr_raf_mask_auto irr_raflagmask.autonomous
417#define irr_raf_mask_reserved irr_raflagmask.reserved
418
419#define irr_raf_onlink irr_flags.prf_ra.onlink
420#define irr_raf_auto irr_flags.prf_ra.autonomous
421
422#define irr_statef_onlink irr_flags.prf_state.onlink
423
424#define irr_rrf irr_flags.prf_rr
425#define irr_rrf_decrvalid irr_flags.prf_rr.decrvalid
426#define irr_rrf_decrprefd irr_flags.prf_rr.decrprefd
427
6d2010ae 428#ifdef XNU_KERNEL_PRIVATE
1c79356b
A
429/*
430 * Given a pointer to an in6_ifaddr (ifaddr),
431 * return a pointer to the addr as a sockaddr_in6
432 */
433#define IA6_IN6(ia) (&((ia)->ia_addr.sin6_addr))
434#define IA6_DSTIN6(ia) (&((ia)->ia_dstaddr.sin6_addr))
435#define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr))
436#define IA6_SIN6(ia) (&((ia)->ia_addr))
437#define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr))
438#define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
439#define IFA_DSTIN6(x) (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
440
441#define IFPR_IN6(x) (&((struct sockaddr_in6 *)((x)->ifpr_prefix))->sin6_addr)
6d2010ae 442#endif /* XNU_KERNEL_PRIVATE */
1c79356b 443
9bccf70c
A
444/*
445 * Event data, internet6 style.
446 */
447
b0d623f7
A
448struct kev_in6_addrlifetime {
449 u_int32_t ia6t_expire;
450 u_int32_t ia6t_preferred;
451 u_int32_t ia6t_vltime;
452 u_int32_t ia6t_pltime;
453};
454
9bccf70c
A
455struct kev_in6_data {
456 struct net_event_data link_data;
457 struct sockaddr_in6 ia_addr; /* interface address */
458 struct sockaddr_in6 ia_net; /* network number of interface */
459 struct sockaddr_in6 ia_dstaddr; /* space for destination addr */
460 struct sockaddr_in6 ia_prefixmask; /* prefix mask */
461 u_int32_t ia_plen; /* prefix length */
462 u_int32_t ia6_flags; /* address flags from in6_ifaddr */
b0d623f7 463 struct kev_in6_addrlifetime ia_lifetime; /* address life info */
9bccf70c
A
464};
465
9bccf70c
A
466/*
467 * Define inet6 event subclass and specific inet6 events.
468 */
469
470#define KEV_INET6_SUBCLASS 6 /* inet6 subclass identifier */
471
472#define KEV_INET6_NEW_USER_ADDR 1 /* Userland configured IPv6 address */
473#define KEV_INET6_CHANGED_ADDR 2 /* Address changed event (future) */
474#define KEV_INET6_ADDR_DELETED 3 /* IPv6 add. in ia_addr field was deleted */
475#define KEV_INET6_NEW_LL_ADDR 4 /* Autoconfigured linklocal address has appeared */
476#define KEV_INET6_NEW_RTADV_ADDR 5 /* Autoconf router advertised address has appeared */
477#define KEV_INET6_DEFROUTER 6 /* Default router dectected by kernel */
478
6d2010ae 479#ifdef XNU_KERNEL_PRIVATE
9bccf70c 480/* Utility function used inside netinet6 kernel code for generating events */
b0d623f7 481void in6_post_msg(struct ifnet *, u_int32_t, struct in6_ifaddr *);
6d2010ae 482#endif /* XNU_KERNEL_PRIVATE */
9bccf70c 483
1c79356b
A
484#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
485 (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
486 (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
487 (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
488 (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
1c79356b
A
489
490#define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq)
491#define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq)
492
1c79356b
A
493/*
494 * SIOCSxxx ioctls should be unused (see comments in in6.c), but
495 * we do not shift numbers for binary compatibility.
496 */
497#define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq)
498#define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq)
1c79356b
A
499
500#define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
501#define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
502
503#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
504#define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
6d2010ae 505#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
506#define SIOCAIFADDR_IN6_32 _IOW('i', 26, struct in6_aliasreq_32)
507#define SIOCAIFADDR_IN6_64 _IOW('i', 26, struct in6_aliasreq_64)
6d2010ae 508#endif /* XNU_KERNEL_PRIVATE */
1c79356b 509
9bccf70c 510#define SIOCSIFPHYADDR_IN6 _IOW('i', 62, struct in6_aliasreq)
6d2010ae 511#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
512#define SIOCSIFPHYADDR_IN6_32 _IOW('i', 62, struct in6_aliasreq_32)
513#define SIOCSIFPHYADDR_IN6_64 _IOW('i', 62, struct in6_aliasreq_64)
6d2010ae 514#endif /* XNU_KERNEL_PRIVATE */
9bccf70c
A
515#define SIOCGIFPSRCADDR_IN6 _IOWR('i', 63, struct in6_ifreq)
516#define SIOCGIFPDSTADDR_IN6 _IOWR('i', 64, struct in6_ifreq)
1c79356b 517#define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
1c79356b 518#define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist)
6d2010ae 519#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
520#define SIOCGDRLST_IN6_32 _IOWR('i', 74, struct in6_drlist_32)
521#define SIOCGDRLST_IN6_64 _IOWR('i', 74, struct in6_drlist_64)
6d2010ae 522#endif /* XNU_KERNEL_PRIVATE */
1c79356b 523#define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_prlist)
6d2010ae 524#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
525#define SIOCGPRLST_IN6_32 _IOWR('i', 75, struct in6_prlist_32)
526#define SIOCGPRLST_IN6_64 _IOWR('i', 75, struct in6_prlist_64)
6d2010ae 527#endif /* XNU_KERNEL_PRIVATE */
9bccf70c
A
528#define OSIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ondireq)
529#define SIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq)
1c79356b
A
530#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
531#define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
6d2010ae 532#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
533#define SIOCGNBRINFO_IN6_32 _IOWR('i', 78, struct in6_nbrinfo_32)
534#define SIOCGNBRINFO_IN6_64 _IOWR('i', 78, struct in6_nbrinfo_64)
6d2010ae 535#endif /* XNU_KERNEL_PRIVATE */
1c79356b
A
536#define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq)
537#define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
538
539#define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq)
540#define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq)
541#define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq)
542#define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq)
543
544#define SIOCSDEFIFACE_IN6 _IOWR('i', 85, struct in6_ndifreq)
545#define SIOCGDEFIFACE_IN6 _IOWR('i', 86, struct in6_ndifreq)
6d2010ae 546#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
547#define SIOCSDEFIFACE_IN6_32 _IOWR('i', 85, struct in6_ndifreq_32)
548#define SIOCSDEFIFACE_IN6_64 _IOWR('i', 85, struct in6_ndifreq_64)
549#define SIOCGDEFIFACE_IN6_32 _IOWR('i', 86, struct in6_ndifreq_32)
550#define SIOCGDEFIFACE_IN6_64 _IOWR('i', 86, struct in6_ndifreq_64)
6d2010ae 551#endif /* XNU_KERNEL_PRIVATE */
1c79356b
A
552
553#define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */
554
9bccf70c
A
555#define SIOCSSCOPE6 _IOW('i', 88, struct in6_ifreq)
556#define SIOCGSCOPE6 _IOWR('i', 89, struct in6_ifreq)
557#define SIOCGSCOPE6DEF _IOWR('i', 90, struct in6_ifreq)
558
1c79356b
A
559#define SIOCSIFPREFIX_IN6 _IOW('i', 100, struct in6_prefixreq) /* set */
560#define SIOCGIFPREFIX_IN6 _IOWR('i', 101, struct in6_prefixreq) /* get */
561#define SIOCDIFPREFIX_IN6 _IOW('i', 102, struct in6_prefixreq) /* del */
562#define SIOCAIFPREFIX_IN6 _IOW('i', 103, struct in6_rrenumreq) /* add */
563#define SIOCCIFPREFIX_IN6 _IOW('i', 104, \
564 struct in6_rrenumreq) /* change */
565#define SIOCSGIFPREFIX_IN6 _IOW('i', 105, \
566 struct in6_rrenumreq) /* set global */
567
9bccf70c 568#define SIOCGETSGCNT_IN6 _IOWR('u', 28, \
1c79356b
A
569 struct sioc_sg_req6) /* get s,g pkt cnt */
570#define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \
571 struct sioc_mif_req6) /* get pkt cnt per if */
6d2010ae 572#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
573#define SIOCGETMIFCNT_IN6_32 _IOWR('u', 107, struct sioc_mif_req6_32)
574#define SIOCGETMIFCNT_IN6_64 _IOWR('u', 107, struct sioc_mif_req6_64)
6d2010ae
A
575#endif /* XNU_KERNEL_PRIVATE */
576
577#define SIOCAADDRCTL_POLICY _IOW('u', 108, struct in6_addrpolicy)
578#define SIOCDADDRCTL_POLICY _IOW('u', 109, struct in6_addrpolicy)
1c79356b 579
2d21ac55 580#ifdef PRIVATE
55e303ae
A
581/*
582 * temporary control calls to attach/detach IP to/from an ethernet interface
583 */
584#define SIOCPROTOATTACH_IN6 _IOWR('i', 110, struct in6_aliasreq) /* attach proto to interface */
6d2010ae 585#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
586#define SIOCPROTOATTACH_IN6_32 _IOWR('i', 110, struct in6_aliasreq_32)
587#define SIOCPROTOATTACH_IN6_64 _IOWR('i', 110, struct in6_aliasreq_64)
6d2010ae 588#endif /* XNU_KERNEL_PRIVATE */
55e303ae
A
589#define SIOCPROTODETACH_IN6 _IOWR('i', 111, struct in6_ifreq) /* detach proto from interface */
590
591#define SIOCLL_START _IOWR('i', 130, struct in6_aliasreq) /* start aquiring linklocal on interface */
6d2010ae 592#ifdef XNU_KERNEL_PRIVATE
b0d623f7
A
593#define SIOCLL_START_32 _IOWR('i', 130, struct in6_aliasreq_32)
594#define SIOCLL_START_64 _IOWR('i', 130, struct in6_aliasreq_64)
6d2010ae 595#endif /* XNU_KERNEL_PRIVATE */
55e303ae
A
596#define SIOCLL_STOP _IOWR('i', 131, struct in6_ifreq) /* deconfigure linklocal from interface */
597#define SIOCAUTOCONF_START _IOWR('i', 132, struct in6_ifreq) /* accept rtadvd on this interface */
598#define SIOCAUTOCONF_STOP _IOWR('i', 133, struct in6_ifreq) /* stop accepting rtadv for this interface */
6d2010ae
A
599
600#define SIOCDRADD_IN6 _IOWR('u', 134, struct in6_defrouter)
601#ifdef XNU_KERNEL_PRIVATE
602#define SIOCDRADD_IN6_32 _IOWR('u', 134, struct in6_defrouter_32)
603#define SIOCDRADD_IN6_64 _IOWR('u', 134, struct in6_defrouter_64)
604#endif /* XNU_KERNEL_PRIVATE */
605#define SIOCDRDEL_IN6 _IOWR('u', 135, struct in6_defrouter)
606#ifdef XNU_KERNEL_PRIVATE
607#define SIOCDRDEL_IN6_32 _IOWR('u', 135, struct in6_defrouter_32)
608#define SIOCDRDEL_IN6_64 _IOWR('u', 135, struct in6_defrouter_64)
609#endif /* XNU_KERNEL_PRIVATE */
2d21ac55 610#endif /* PRIVATE */
55e303ae 611
1c79356b
A
612#define IN6_IFF_ANYCAST 0x01 /* anycast address */
613#define IN6_IFF_TENTATIVE 0x02 /* tentative address */
614#define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */
615#define IN6_IFF_DETACHED 0x08 /* may be detached from the link */
616#define IN6_IFF_DEPRECATED 0x10 /* deprecated address */
617#define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address
618 * (used only at first SIOC* call)
619 */
9bccf70c
A
620#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
621#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */
622#define IN6_IFF_NOPFX 0x8000 /* skip kernel prefix management.
623 * XXX: this should be temporary.
624 */
1c79356b
A
625
626/* do not input/output */
627#define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
628
629#ifdef KERNEL
630#define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
631#define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
b0d623f7 632#endif /* KERNEL */
1c79356b 633
6d2010ae 634#ifdef XNU_KERNEL_PRIVATE
91447636 635extern struct in6_ifaddr *in6_ifaddrs;
1c79356b
A
636
637extern struct in6_ifstat **in6_ifstat;
638extern size_t in6_ifstatmax;
639extern struct icmp6stat icmp6stat;
640extern struct icmp6_ifstat **icmp6_ifstat;
641extern size_t icmp6_ifstatmax;
6d2010ae 642extern lck_rw_t in6_ifs_rwlock;
1c79356b 643#define in6_ifstat_inc(ifp, tag) \
6d2010ae
A
644do { \
645 lck_rw_lock_shared(&in6_ifs_rwlock); \
646 int _z_index = ifp ? ifp->if_index : 0; \
647 if ((_z_index) && _z_index <= if_index \
648 && _z_index < (signed)in6_ifstatmax \
649 && in6_ifstat && in6_ifstat[_z_index]) { \
650 atomic_add_64(&in6_ifstat[_z_index]->tag, 1); \
651 } \
652 lck_rw_done(&in6_ifs_rwlock); \
1c79356b
A
653} while (0)
654
6d2010ae
A
655__private_extern__ lck_rw_t in6_ifaddr_rwlock;
656
1c79356b
A
657extern struct ifqueue ip6intrq; /* IP6 packet input queue */
658extern struct in6_addr zeroin6_addr;
659extern u_char inet6ctlerrmap[];
b0d623f7 660extern u_int32_t in6_maxmtu;
1c79356b
A
661
662/*
663 * Macro for finding the internet address structure (in6_ifaddr) corresponding
664 * to a given interface (ifnet structure).
665 */
1c79356b
A
666
667#define IFP_TO_IA6(ifp, ia) \
668/* struct ifnet *ifp; */ \
669/* struct in6_ifaddr *ia; */ \
670do { \
6d2010ae
A
671 struct ifaddr *_ifa; \
672 ifnet_lock_assert(ifp, LCK_RW_ASSERT_HELD); \
673 for (_ifa = (ifp)->if_addrlist.tqh_first; _ifa != NULL; \
674 _ifa = _ifa->ifa_list.tqe_next) { \
675 IFA_LOCK(_ifa); \
676 if (_ifa->ifa_addr->sa_family == AF_INET6) { \
677 IFA_ADDREF_LOCKED(_ifa); \
678 IFA_UNLOCK(_ifa); \
1c79356b 679 break; \
6d2010ae
A
680 } \
681 IFA_UNLOCK(_ifa); \
1c79356b 682 } \
6d2010ae 683 (ia) = (struct in6_ifaddr *)_ifa; \
1c79356b 684} while (0)
1c79356b 685
1c79356b 686/*
6d2010ae
A
687 * IPv6 multicast MLD-layer source entry.
688 */
689struct ip6_msource {
690 RB_ENTRY(ip6_msource) im6s_link; /* RB tree links */
691 struct in6_addr im6s_addr;
692 struct im6s_st {
693 uint16_t ex; /* # of exclusive members */
694 uint16_t in; /* # of inclusive members */
695 } im6s_st[2]; /* state at t0, t1 */
696 uint8_t im6s_stp; /* pending query */
697};
698
699RB_HEAD(ip6_msource_tree, ip6_msource);
700
701RB_PROTOTYPE_SC_PREV(__private_extern__, ip6_msource_tree, ip6_msource,
702 im6s_link, ip6_msource_cmp);
703
704/*
705 * IPv6 multicast PCB-layer source entry.
706 *
707 * NOTE: overlapping use of struct ip6_msource fields at start.
708 */
709struct in6_msource {
710 RB_ENTRY(ip6_msource) im6s_link; /* Common field */
711 struct in6_addr im6s_addr; /* Common field */
712 uint8_t im6sl_st[2]; /* state before/at commit */
713};
714
715/*
716 * IPv6 multicast PCB-layer group filter descriptor.
717 */
718struct in6_mfilter {
719 struct ip6_msource_tree im6f_sources; /* source list for (S,G) */
720 u_long im6f_nsrc; /* # of source entries */
721 uint8_t im6f_st[2]; /* state before/at commit */
722};
723
724/*
725 * Legacy KAME IPv6 multicast membership descriptor.
1c79356b
A
726 */
727struct in6_multi_mship {
728 struct in6_multi *i6mm_maddr; /* Multicast address pointer */
729 LIST_ENTRY(in6_multi_mship) i6mm_chain; /* multicast options chain */
730};
731
6d2010ae
A
732struct mld_ifinfo;
733
734/*
735 * The request count here is a count of requests for this address, not a
736 * count of pointers to this structure.
737 */
1c79356b 738struct in6_multi {
6d2010ae
A
739 decl_lck_mtx_data(, in6m_lock);
740 u_int32_t in6m_refcount; /* reference count */
741 u_int32_t in6m_reqcnt; /* request count for this address */
742 u_int32_t in6m_debug; /* see ifa_debug flags */
1c79356b
A
743 LIST_ENTRY(in6_multi) in6m_entry; /* list glue */
744 struct in6_addr in6m_addr; /* IP6 multicast address */
745 struct ifnet *in6m_ifp; /* back pointer to ifnet */
1c79356b 746 struct ifmultiaddr *in6m_ifma; /* back pointer to ifmultiaddr */
1c79356b
A
747 u_int in6m_state; /* state of the membership */
748 u_int in6m_timer; /* MLD6 listener report timer */
6d2010ae
A
749 /* New fields for MLDv2 follow. */
750 struct mld_ifinfo *in6m_mli; /* MLD info */
751 SLIST_ENTRY(in6_multi) in6m_nrele; /* to-be-released by MLD */
752 u_int32_t in6m_nrelecnt; /* deferred release count */
753 struct ip6_msource_tree in6m_srcs; /* tree of sources */
754 u_long in6m_nsrc; /* # of tree entries */
755
756 struct ifqueue in6m_scq; /* queue of pending
757 * state-change packets */
758 struct timeval in6m_lastgsrtv; /* last G-S-R query */
759 uint16_t in6m_sctimer; /* state-change timer */
760 uint16_t in6m_scrv; /* state-change rexmit count */
761 /*
762 * SSM state counters which track state at T0 (the time the last
763 * state-change report's RV timer went to zero) and T1
764 * (time of pending report, i.e. now).
765 * Used for computing MLDv2 state-change reports. Several refcounts
766 * are maintained here to optimize for common use-cases.
767 */
768 struct in6m_st {
769 uint16_t iss_fmode; /* MLD filter mode */
770 uint16_t iss_asm; /* # of ASM listeners */
771 uint16_t iss_ex; /* # of exclusive members */
772 uint16_t iss_in; /* # of inclusive members */
773 uint16_t iss_rec; /* # of recorded sources */
774 } in6m_st[2]; /* state at t0, t1 */
775
776 void (*in6m_trace) /* callback fn for tracing refs */
777 (struct in6_multi *, int);
1c79356b
A
778};
779
6d2010ae
A
780#define IN6M_LOCK_ASSERT_HELD(_in6m) \
781 lck_mtx_assert(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_OWNED)
782
783#define IN6M_LOCK_ASSERT_NOTHELD(_in6m) \
784 lck_mtx_assert(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_NOTOWNED)
785
786#define IN6M_LOCK(_in6m) \
787 lck_mtx_lock(&(_in6m)->in6m_lock)
788
789#define IN6M_LOCK_SPIN(_in6m) \
790 lck_mtx_lock_spin(&(_in6m)->in6m_lock)
791
792#define IN6M_CONVERT_LOCK(_in6m) do { \
793 IN6M_LOCK_ASSERT_HELD(_in6m); \
794 lck_mtx_convert_spin(&(_in6m)->in6m_lock); \
795} while (0)
796
797#define IN6M_UNLOCK(_in6m) \
798 lck_mtx_unlock(&(_in6m)->in6m_lock)
799
800#define IN6M_ADDREF(_in6m) \
801 in6m_addref(_in6m, 0)
802
803#define IN6M_ADDREF_LOCKED(_in6m) \
804 in6m_addref(_in6m, 1)
805
806#define IN6M_REMREF(_in6m) \
807 in6m_remref(_in6m, 0)
808
809#define IN6M_REMREF_LOCKED(_in6m) \
810 in6m_remref(_in6m, 1)
811
812#define IN6M_TIMER_UNDEF -1
813
814/* flags to in6_update_ifa */
815#define IN6_IFAUPDATE_DADDELAY 0x1 /* first time to configure an address */
816
817struct ip6_moptions;
818struct sockopt;
819struct inpcb;
820
1c79356b 821extern LIST_HEAD(in6_multihead, in6_multi) in6_multihead;
1c79356b
A
822
823/*
824 * Structure used by macros below to remember position when stepping through
55e303ae 825 * all of the in6_multi records.
1c79356b
A
826 */
827struct in6_multistep {
828 struct in6_ifaddr *i_ia;
829 struct in6_multi *i_in6m;
830};
831
832/*
833 * Macros for looking up the in6_multi record for a given IP6 multicast
834 * address on a given interface. If no matching record is found, "in6m"
6d2010ae
A
835 * returns NULL.
836 *
837 * We do this differently compared other BSD implementations; instead of
838 * walking the if_multiaddrs list at the interface and returning the
839 * ifma_protospec value of a matching entry, we search the global list
840 * of in6_multi records and find it that way. Otherwise either the two
841 * structures (in6_multi, ifmultiaddr) need to be ref counted both ways,
842 * which will make things too complicated, or they need to reside in the
843 * same protected domain, which they aren't.
844 *
845 * Must be called with in6_multihead_lock held.
1c79356b 846 */
6d2010ae
A
847#define IN6_LOOKUP_MULTI(addr, ifp, in6m) \
848 /* struct in6_addr *addr; */ \
849 /* struct ifnet *ifp; */ \
850 /* struct in6_multi *in6m; */ \
851do { \
852 struct in6_multistep _step; \
853 IN6_FIRST_MULTI(_step, in6m); \
854 while ((in6m) != NULL) { \
855 IN6M_LOCK_SPIN(in6m); \
856 if ((in6m)->in6m_ifp == (ifp) && \
857 IN6_ARE_ADDR_EQUAL(&(in6m)->in6m_addr, (addr))) { \
858 IN6M_ADDREF_LOCKED(in6m); \
859 IN6M_UNLOCK(in6m); \
860 break; \
861 } \
862 IN6M_UNLOCK(in6m); \
863 IN6_NEXT_MULTI(_step, in6m); \
864 } \
1c79356b
A
865} while(0)
866
867/*
868 * Macro to step through all of the in6_multi records, one at a time.
869 * The current position is remembered in "step", which the caller must
870 * provide. IN6_FIRST_MULTI(), below, must be called to initialize "step"
871 * and get the first record. Both macros return a NULL "in6m" when there
872 * are no remaining records.
6d2010ae
A
873 *
874 * Must be called with in6_multihead_lock held.
1c79356b
A
875 */
876#define IN6_NEXT_MULTI(step, in6m) \
6d2010ae
A
877 /* struct in6_multistep step; */ \
878 /* struct in6_multi *in6m; */ \
879do { \
880 in6_multihead_lock_assert(LCK_RW_ASSERT_HELD); \
881 if (((in6m) = (step).i_in6m) != NULL) \
882 (step).i_in6m = (step).i_in6m->in6m_entry.le_next; \
883} while (0)
1c79356b 884
6d2010ae
A
885#define IN6_FIRST_MULTI(step, in6m) \
886 /* struct in6_multistep step; */ \
887 /* struct in6_multi *in6m */ \
888do { \
889 in6_multihead_lock_assert(LCK_RW_ASSERT_HELD); \
890 (step).i_in6m = in6_multihead.lh_first; \
891 IN6_NEXT_MULTI((step), (in6m)); \
892} while (0)
1c79356b 893
6d2010ae
A
894/* Multicast private KPIs. */
895extern int im6o_mc_filter(const struct ip6_moptions *, const struct ifnet *,
896 const struct sockaddr *, const struct sockaddr *);
897extern int in6_mc_join(struct ifnet *, const struct in6_addr *,
898 struct in6_mfilter *, struct in6_multi **, int);
899extern int in6_mc_leave(struct in6_multi *, struct in6_mfilter *);
900extern void in6m_clear_recorded(struct in6_multi *);
901extern void in6m_commit(struct in6_multi *);
902extern void in6m_purge(struct in6_multi *);
903extern void in6m_print(const struct in6_multi *);
904extern int in6m_record_source(struct in6_multi *, const struct in6_addr *);
905extern int ip6_getmoptions(struct inpcb *, struct sockopt *);
906extern int ip6_setmoptions(struct inpcb *, struct sockopt *);
907
908/* Legacy KAME multicast private KPIs. */
909extern struct in6_multi_mship *in6_joingroup(struct ifnet *,
910 struct in6_addr *, int *, int);
911extern int in6_leavegroup(struct in6_multi_mship *);
912
913extern void in6_multi_init(void);
914extern void in6m_addref(struct in6_multi *, int);
915extern void in6m_remref(struct in6_multi *, int);
916extern int in6_multi_detach(struct in6_multi *);
b0d623f7
A
917extern int in6_ifindex2scopeid(int);
918extern int in6_mask2len(struct in6_addr *, u_char *);
919extern void in6_len2mask(struct in6_addr *, int);
920extern int in6_control(struct socket *, u_long, caddr_t, struct ifnet *,
921 struct proc *);
922extern int in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
6d2010ae
A
923 struct in6_ifaddr *, int, int);
924extern void in6_purgeaddr(struct ifaddr *);
b0d623f7
A
925extern int in6if_do_dad(struct ifnet *);
926extern void in6_purgeif(struct ifnet *);
927extern void in6_savemkludge(struct in6_ifaddr *);
928extern void in6_setmaxmtu(void);
929extern void in6_restoremkludge(struct in6_ifaddr *, struct ifnet *);
930extern void in6_purgemkludge(struct ifnet *);
931extern struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
932extern struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
933extern char *ip6_sprintf(const struct in6_addr *);
934extern int in6_addr2scopeid(struct ifnet *, struct in6_addr *);
935extern int in6_matchlen(struct in6_addr *, struct in6_addr *);
936extern int in6_are_prefix_equal(struct in6_addr *p1, struct in6_addr *p2,
937 int len);
938extern void in6_prefixlen2mask(struct in6_addr *maskp, int len);
939extern int in6_prefix_add_ifid(int iilen, struct in6_ifaddr *ia);
940extern void in6_prefix_remove_ifid(int iilen, struct in6_ifaddr *ia);
941extern void in6_purgeprefix(struct ifnet *);
6d2010ae 942extern void in6_purgeaddrs(struct ifnet *);
b0d623f7
A
943
944extern int in6_is_addr_deprecated(struct sockaddr_in6 *);
6d2010ae
A
945extern uint8_t im6s_get_mode(const struct in6_multi *,
946 const struct ip6_msource *, uint8_t);
947
948extern void im6f_leave(struct in6_mfilter *);
949extern void im6f_purge(struct in6_mfilter *);
b0d623f7 950
9bccf70c 951struct inpcb;
6d2010ae 952struct ip6_pktopts;
1c79356b 953
b0d623f7 954extern int in6_embedscope(struct in6_addr *, const struct sockaddr_in6 *,
6d2010ae 955 struct inpcb *, struct ifnet **, struct ip6_pktopts *);
b0d623f7
A
956extern int in6_recoverscope(struct sockaddr_in6 *, const struct in6_addr *,
957 struct ifnet *);
b0d623f7
A
958extern void in6_aliasreq_64_to_32(struct in6_aliasreq_64 *,
959 struct in6_aliasreq_32 *);
960extern void in6_aliasreq_32_to_64(struct in6_aliasreq_32 *,
961 struct in6_aliasreq_64 *);
962extern void in6_ifaddr_init(void);
d1ecb069 963extern void in6_rtqdrain(void);
6d2010ae
A
964extern struct radix_node *in6_validate(struct radix_node *);
965extern int in6_if2idlen(struct ifnet *);
966extern int in6_src_ioctl (u_long, caddr_t);
967
968__private_extern__ void in6_multihead_lock_exclusive(void);
969__private_extern__ void in6_multihead_lock_shared(void);
970__private_extern__ void in6_multihead_lock_assert(int);
971__private_extern__ void in6_multihead_lock_done(void);
972#endif /* XNU_KERNEL_PRIVATE */
0c530ab8 973#endif /* _NETINET6_IN6_VAR_H_ */