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