2 * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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 $ */
33 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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.
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
62 * Copyright (c) 1985, 1986, 1993
63 * The Regents of the University of California. All rights reserved.
65 * Redistribution and use in source and binary forms, with or without
66 * modification, are permitted provided that the following conditions
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.
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
93 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
96 #ifndef _NETINET6_IN6_VAR_H_
97 #define _NETINET6_IN6_VAR_H_
98 #include <sys/appleapiopts.h>
100 #ifdef XNU_KERNEL_PRIVATE
101 #include <sys/tree.h>
102 #include <sys/mcache.h>
106 #include <sys/kern_event.h>
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
113 * userland -> kernel: accept pltime/vltime
114 * kernel -> userland: throw up everything
115 * in kernel: modify preferred/expire only
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 */
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
;
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
;
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.
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 */
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.
161 time_t ia6_updatetime
;
163 struct ifprefix
*ia6_ifpr
; /* back pointer to ifprefix */
165 /* back pointer to the ND prefix (for autoconfigured addresses only) */
166 struct nd_prefix
*ia6_ndpr
;
168 /* multicast addresses joined from the kernel */
169 LIST_HEAD(, in6_multi_mship
) ia6_memberships
;
171 #endif /* XNU_KERNEL_PRIVATE */
173 /* control structure to manage address selection policy */
174 struct 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 */
183 * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
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 */
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...
223 struct icmp6_ifstat
{
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
;
263 * Output statistics. We should solve unresolved routing problem...
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
;
302 char ifr_name
[IFNAMSIZ
];
304 struct sockaddr_in6 ifru_addr
;
305 struct sockaddr_in6 ifru_dstaddr
;
310 struct in6_addrlifetime ifru_lifetime
;
311 struct in6_ifstat ifru_stat
;
312 struct icmp6_ifstat ifru_icmp6stat
;
313 u_int32_t ifru_scope_id
[16];
317 struct 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
;
323 struct in6_addrlifetime ifra_lifetime
;
326 #ifdef XNU_KERNEL_PRIVATE
327 struct 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
;
333 struct in6_addrlifetime_32 ifra_lifetime
;
336 struct 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
;
342 struct in6_addrlifetime_64 ifra_lifetime
;
344 #endif /* XNU_KERNEL_PRIVATE */
346 /* prefix type macro */
347 #define IN6_PREFIX_ND 1
348 #define IN6_PREFIX_RR 2
351 * prefix related flags passed between kernel(NDP related part) and
352 * user land command(ifconfig) and daemon(rtadvd).
357 u_char autonomous
: 1;
360 u_char prf_reserved1
;
361 u_short prf_reserved2
;
362 /* want to put this on 4byte offset */
364 u_char decrvalid
: 1;
365 u_char decrprefd
: 1;
368 u_char prf_reserved3
;
369 u_short prf_reserved4
;
372 struct in6_prefixreq
{
373 char ipr_name
[IFNAMSIZ
];
376 u_int32_t ipr_vltime
;
377 u_int32_t ipr_pltime
;
378 struct in6_prflags ipr_flags
;
379 struct sockaddr_in6 ipr_prefix
;
384 #define PR_ORIG_STATIC 2
385 #define PR_ORIG_KERNEL 3
387 #define ipr_raf_onlink ipr_flags.prf_ra.onlink
388 #define ipr_raf_auto ipr_flags.prf_ra.autonomous
390 #define ipr_statef_onlink ipr_flags.prf_state.onlink
392 #define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid
393 #define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd
395 struct in6_rrenumreq
{
396 char irr_name
[IFNAMSIZ
];
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
{
405 u_char autonomous
: 1;
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
;
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
419 #define irr_raf_onlink irr_flags.prf_ra.onlink
420 #define irr_raf_auto irr_flags.prf_ra.autonomous
422 #define irr_statef_onlink irr_flags.prf_state.onlink
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
428 #ifdef XNU_KERNEL_PRIVATE
430 * Given a pointer to an in6_ifaddr (ifaddr),
431 * return a pointer to the addr as a sockaddr_in6
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)
441 #define IFPR_IN6(x) (&((struct sockaddr_in6 *)((x)->ifpr_prefix))->sin6_addr)
442 #endif /* XNU_KERNEL_PRIVATE */
445 * Event data, internet6 style.
448 struct 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
;
455 struct 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 */
463 struct kev_in6_addrlifetime ia_lifetime
; /* address life info */
467 * Define inet6 event subclass and specific inet6 events.
470 #define KEV_INET6_SUBCLASS 6 /* inet6 subclass identifier */
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 */
479 #ifdef XNU_KERNEL_PRIVATE
480 /* Utility function used inside netinet6 kernel code for generating events */
481 void in6_post_msg(struct ifnet
*, u_int32_t
, struct in6_ifaddr
*);
482 #endif /* XNU_KERNEL_PRIVATE */
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 )
490 #define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq)
491 #define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq)
494 * SIOCSxxx ioctls should be unused (see comments in in6.c), but
495 * we do not shift numbers for binary compatibility.
497 #define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq)
498 #define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq)
500 #define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
501 #define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
503 #define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
504 #define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
505 #ifdef XNU_KERNEL_PRIVATE
506 #define SIOCAIFADDR_IN6_32 _IOW('i', 26, struct in6_aliasreq_32)
507 #define SIOCAIFADDR_IN6_64 _IOW('i', 26, struct in6_aliasreq_64)
508 #endif /* XNU_KERNEL_PRIVATE */
510 #define SIOCSIFPHYADDR_IN6 _IOW('i', 62, struct in6_aliasreq)
511 #ifdef XNU_KERNEL_PRIVATE
512 #define SIOCSIFPHYADDR_IN6_32 _IOW('i', 62, struct in6_aliasreq_32)
513 #define SIOCSIFPHYADDR_IN6_64 _IOW('i', 62, struct in6_aliasreq_64)
514 #endif /* XNU_KERNEL_PRIVATE */
515 #define SIOCGIFPSRCADDR_IN6 _IOWR('i', 63, struct in6_ifreq)
516 #define SIOCGIFPDSTADDR_IN6 _IOWR('i', 64, struct in6_ifreq)
517 #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
518 #define SIOCGDRLST_IN6 _IOWR('i', 74, struct in6_drlist)
519 #ifdef XNU_KERNEL_PRIVATE
520 #define SIOCGDRLST_IN6_32 _IOWR('i', 74, struct in6_drlist_32)
521 #define SIOCGDRLST_IN6_64 _IOWR('i', 74, struct in6_drlist_64)
522 #endif /* XNU_KERNEL_PRIVATE */
523 #define SIOCGPRLST_IN6 _IOWR('i', 75, struct in6_prlist)
524 #ifdef XNU_KERNEL_PRIVATE
525 #define SIOCGPRLST_IN6_32 _IOWR('i', 75, struct in6_prlist_32)
526 #define SIOCGPRLST_IN6_64 _IOWR('i', 75, struct in6_prlist_64)
527 #endif /* XNU_KERNEL_PRIVATE */
528 #define OSIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ondireq)
529 #define SIOCGIFINFO_IN6 _IOWR('i', 76, struct in6_ondireq)
530 #define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
531 #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
532 #ifdef XNU_KERNEL_PRIVATE
533 #define SIOCGNBRINFO_IN6_32 _IOWR('i', 78, struct in6_nbrinfo_32)
534 #define SIOCGNBRINFO_IN6_64 _IOWR('i', 78, struct in6_nbrinfo_64)
535 #endif /* XNU_KERNEL_PRIVATE */
536 #define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq)
537 #define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
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)
544 #define SIOCSDEFIFACE_IN6 _IOWR('i', 85, struct in6_ndifreq)
545 #define SIOCGDEFIFACE_IN6 _IOWR('i', 86, struct in6_ndifreq)
546 #ifdef XNU_KERNEL_PRIVATE
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)
551 #endif /* XNU_KERNEL_PRIVATE */
553 #define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */
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)
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 */
568 #define SIOCGETSGCNT_IN6 _IOWR('u', 28, \
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 */
572 #ifdef XNU_KERNEL_PRIVATE
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)
575 #endif /* XNU_KERNEL_PRIVATE */
577 #define SIOCAADDRCTL_POLICY _IOW('u', 108, struct in6_addrpolicy)
578 #define SIOCDADDRCTL_POLICY _IOW('u', 109, struct in6_addrpolicy)
582 * temporary control calls to attach/detach IP to/from an ethernet interface
584 #define SIOCPROTOATTACH_IN6 _IOWR('i', 110, struct in6_aliasreq) /* attach proto to interface */
585 #ifdef XNU_KERNEL_PRIVATE
586 #define SIOCPROTOATTACH_IN6_32 _IOWR('i', 110, struct in6_aliasreq_32)
587 #define SIOCPROTOATTACH_IN6_64 _IOWR('i', 110, struct in6_aliasreq_64)
588 #endif /* XNU_KERNEL_PRIVATE */
589 #define SIOCPROTODETACH_IN6 _IOWR('i', 111, struct in6_ifreq) /* detach proto from interface */
591 #define SIOCLL_START _IOWR('i', 130, struct in6_aliasreq) /* start aquiring linklocal on interface */
592 #ifdef XNU_KERNEL_PRIVATE
593 #define SIOCLL_START_32 _IOWR('i', 130, struct in6_aliasreq_32)
594 #define SIOCLL_START_64 _IOWR('i', 130, struct in6_aliasreq_64)
595 #endif /* XNU_KERNEL_PRIVATE */
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 */
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 */
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)
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.
626 /* do not input/output */
627 #define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
630 #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
631 #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
634 #ifdef XNU_KERNEL_PRIVATE
635 extern struct in6_ifaddr
*in6_ifaddrs
;
637 extern struct in6_ifstat
**in6_ifstat
;
638 extern size_t in6_ifstatmax
;
639 extern struct icmp6stat icmp6stat
;
640 extern struct icmp6_ifstat
**icmp6_ifstat
;
641 extern size_t icmp6_ifstatmax
;
642 extern lck_rw_t in6_ifs_rwlock
;
643 #define in6_ifstat_inc(ifp, tag) \
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); \
652 lck_rw_done(&in6_ifs_rwlock); \
655 __private_extern__ lck_rw_t in6_ifaddr_rwlock
;
657 extern struct ifqueue ip6intrq
; /* IP6 packet input queue */
658 extern struct in6_addr zeroin6_addr
;
659 extern u_char inet6ctlerrmap
[];
660 extern u_int32_t in6_maxmtu
;
663 * Macro for finding the internet address structure (in6_ifaddr) corresponding
664 * to a given interface (ifnet structure).
667 #define IFP_TO_IA6(ifp, ia) \
668 /* struct ifnet *ifp; */ \
669 /* struct in6_ifaddr *ia; */ \
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) { \
676 if (_ifa->ifa_addr->sa_family == AF_INET6) { \
677 IFA_ADDREF_LOCKED(_ifa); \
683 (ia) = (struct in6_ifaddr *)_ifa; \
687 * IPv6 multicast MLD-layer source entry.
690 RB_ENTRY(ip6_msource
) im6s_link
; /* RB tree links */
691 struct in6_addr im6s_addr
;
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 */
699 RB_HEAD(ip6_msource_tree
, ip6_msource
);
701 RB_PROTOTYPE_SC_PREV(__private_extern__
, ip6_msource_tree
, ip6_msource
,
702 im6s_link
, ip6_msource_cmp
);
705 * IPv6 multicast PCB-layer source entry.
707 * NOTE: overlapping use of struct ip6_msource fields at start.
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 */
716 * IPv6 multicast PCB-layer group filter descriptor.
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 */
725 * Legacy KAME IPv6 multicast membership descriptor.
727 struct in6_multi_mship
{
728 struct in6_multi
*i6mm_maddr
; /* Multicast address pointer */
729 LIST_ENTRY(in6_multi_mship
) i6mm_chain
; /* multicast options chain */
735 * The request count here is a count of requests for this address, not a
736 * count of pointers to this structure.
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 */
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 */
746 struct ifmultiaddr
*in6m_ifma
; /* back pointer to ifmultiaddr */
747 u_int in6m_state
; /* state of the membership */
748 u_int in6m_timer
; /* MLD6 listener report timer */
749 /* New fields for MLDv2 follow. */
750 struct mld_ifinfo
*in6m_mli
; /* MLD info */
751 SLIST_ENTRY(in6_multi
) in6m_dtle
; /* detached waiting for rele */
752 SLIST_ENTRY(in6_multi
) in6m_nrele
; /* to-be-released by MLD */
753 u_int32_t in6m_nrelecnt
; /* deferred release count */
754 struct ip6_msource_tree in6m_srcs
; /* tree of sources */
755 u_long in6m_nsrc
; /* # of tree entries */
757 struct ifqueue in6m_scq
; /* queue of pending
758 * state-change packets */
759 struct timeval in6m_lastgsrtv
; /* last G-S-R query */
760 uint16_t in6m_sctimer
; /* state-change timer */
761 uint16_t in6m_scrv
; /* state-change rexmit count */
763 * SSM state counters which track state at T0 (the time the last
764 * state-change report's RV timer went to zero) and T1
765 * (time of pending report, i.e. now).
766 * Used for computing MLDv2 state-change reports. Several refcounts
767 * are maintained here to optimize for common use-cases.
770 uint16_t iss_fmode
; /* MLD filter mode */
771 uint16_t iss_asm
; /* # of ASM listeners */
772 uint16_t iss_ex
; /* # of exclusive members */
773 uint16_t iss_in
; /* # of inclusive members */
774 uint16_t iss_rec
; /* # of recorded sources */
775 } in6m_st
[2]; /* state at t0, t1 */
777 void (*in6m_trace
) /* callback fn for tracing refs */
778 (struct in6_multi
*, int);
781 #define IN6M_LOCK_ASSERT_HELD(_in6m) \
782 lck_mtx_assert(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_OWNED)
784 #define IN6M_LOCK_ASSERT_NOTHELD(_in6m) \
785 lck_mtx_assert(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_NOTOWNED)
787 #define IN6M_LOCK(_in6m) \
788 lck_mtx_lock(&(_in6m)->in6m_lock)
790 #define IN6M_LOCK_SPIN(_in6m) \
791 lck_mtx_lock_spin(&(_in6m)->in6m_lock)
793 #define IN6M_CONVERT_LOCK(_in6m) do { \
794 IN6M_LOCK_ASSERT_HELD(_in6m); \
795 lck_mtx_convert_spin(&(_in6m)->in6m_lock); \
798 #define IN6M_UNLOCK(_in6m) \
799 lck_mtx_unlock(&(_in6m)->in6m_lock)
801 #define IN6M_ADDREF(_in6m) \
802 in6m_addref(_in6m, 0)
804 #define IN6M_ADDREF_LOCKED(_in6m) \
805 in6m_addref(_in6m, 1)
807 #define IN6M_REMREF(_in6m) \
808 in6m_remref(_in6m, 0)
810 #define IN6M_REMREF_LOCKED(_in6m) \
811 in6m_remref(_in6m, 1)
813 #define IN6M_TIMER_UNDEF -1
815 /* flags to in6_update_ifa */
816 #define IN6_IFAUPDATE_DADDELAY 0x1 /* first time to configure an address */
822 extern LIST_HEAD(in6_multihead
, in6_multi
) in6_multihead
;
825 * Structure used by macros below to remember position when stepping through
826 * all of the in6_multi records.
828 struct in6_multistep
{
829 struct in6_ifaddr
*i_ia
;
830 struct in6_multi
*i_in6m
;
834 * Macros for looking up the in6_multi record for a given IP6 multicast
835 * address on a given interface. If no matching record is found, "in6m"
838 * We do this differently compared other BSD implementations; instead of
839 * walking the if_multiaddrs list at the interface and returning the
840 * ifma_protospec value of a matching entry, we search the global list
841 * of in6_multi records and find it that way. Otherwise either the two
842 * structures (in6_multi, ifmultiaddr) need to be ref counted both ways,
843 * which will make things too complicated, or they need to reside in the
844 * same protected domain, which they aren't.
846 * Must be called with in6_multihead_lock held.
848 #define IN6_LOOKUP_MULTI(addr, ifp, in6m) \
849 /* struct in6_addr *addr; */ \
850 /* struct ifnet *ifp; */ \
851 /* struct in6_multi *in6m; */ \
853 struct in6_multistep _step; \
854 IN6_FIRST_MULTI(_step, in6m); \
855 while ((in6m) != NULL) { \
856 IN6M_LOCK_SPIN(in6m); \
857 if ((in6m)->in6m_ifp == (ifp) && \
858 IN6_ARE_ADDR_EQUAL(&(in6m)->in6m_addr, (addr))) { \
859 IN6M_ADDREF_LOCKED(in6m); \
864 IN6_NEXT_MULTI(_step, in6m); \
869 * Macro to step through all of the in6_multi records, one at a time.
870 * The current position is remembered in "step", which the caller must
871 * provide. IN6_FIRST_MULTI(), below, must be called to initialize "step"
872 * and get the first record. Both macros return a NULL "in6m" when there
873 * are no remaining records.
875 * Must be called with in6_multihead_lock held.
877 #define IN6_NEXT_MULTI(step, in6m) \
878 /* struct in6_multistep step; */ \
879 /* struct in6_multi *in6m; */ \
881 in6_multihead_lock_assert(LCK_RW_ASSERT_HELD); \
882 if (((in6m) = (step).i_in6m) != NULL) \
883 (step).i_in6m = (step).i_in6m->in6m_entry.le_next; \
886 #define IN6_FIRST_MULTI(step, in6m) \
887 /* struct in6_multistep step; */ \
888 /* struct in6_multi *in6m */ \
890 in6_multihead_lock_assert(LCK_RW_ASSERT_HELD); \
891 (step).i_in6m = in6_multihead.lh_first; \
892 IN6_NEXT_MULTI((step), (in6m)); \
895 /* Multicast private KPIs. */
896 extern int im6o_mc_filter(const struct ip6_moptions
*, const struct ifnet
*,
897 const struct sockaddr
*, const struct sockaddr
*);
898 extern int in6_mc_join(struct ifnet
*, const struct in6_addr
*,
899 struct in6_mfilter
*, struct in6_multi
**, int);
900 extern int in6_mc_leave(struct in6_multi
*, struct in6_mfilter
*);
901 extern void in6m_clear_recorded(struct in6_multi
*);
902 extern void in6m_commit(struct in6_multi
*);
903 extern void in6m_purge(struct in6_multi
*);
904 extern void in6m_print(const struct in6_multi
*);
905 extern int in6m_record_source(struct in6_multi
*, const struct in6_addr
*);
906 extern int ip6_getmoptions(struct inpcb
*, struct sockopt
*);
907 extern int ip6_setmoptions(struct inpcb
*, struct sockopt
*);
909 /* Legacy KAME multicast private KPIs. */
910 extern struct in6_multi_mship
*in6_joingroup(struct ifnet
*,
911 struct in6_addr
*, int *, int);
912 extern int in6_leavegroup(struct in6_multi_mship
*);
914 extern void in6_multi_init(void);
915 extern void in6m_addref(struct in6_multi
*, int);
916 extern void in6m_remref(struct in6_multi
*, int);
917 extern int in6_multi_detach(struct in6_multi
*);
918 extern int in6_ifindex2scopeid(int);
919 extern int in6_mask2len(struct in6_addr
*, u_char
*);
920 extern void in6_len2mask(struct in6_addr
*, int);
921 extern int in6_control(struct socket
*, u_long
, caddr_t
, struct ifnet
*,
923 extern int in6_update_ifa(struct ifnet
*, struct in6_aliasreq
*,
924 struct in6_ifaddr
*, int, int);
925 extern void in6_purgeaddr(struct ifaddr
*);
926 extern int in6if_do_dad(struct ifnet
*);
927 extern void in6_purgeif(struct ifnet
*);
928 extern void in6_savemkludge(struct in6_ifaddr
*);
929 extern void in6_setmaxmtu(void);
930 extern void in6_restoremkludge(struct in6_ifaddr
*, struct ifnet
*);
931 extern void in6_purgemkludge(struct ifnet
*);
932 extern struct in6_ifaddr
*in6ifa_ifpforlinklocal(struct ifnet
*, int);
933 extern struct in6_ifaddr
*in6ifa_ifpwithaddr(struct ifnet
*, struct in6_addr
*);
934 extern char *ip6_sprintf(const struct in6_addr
*);
935 extern int in6_addr2scopeid(struct ifnet
*, struct in6_addr
*);
936 extern int in6_matchlen(struct in6_addr
*, struct in6_addr
*);
937 extern int in6_are_prefix_equal(struct in6_addr
*p1
, struct in6_addr
*p2
,
939 extern void in6_prefixlen2mask(struct in6_addr
*maskp
, int len
);
940 extern int in6_prefix_add_ifid(int iilen
, struct in6_ifaddr
*ia
);
941 extern void in6_prefix_remove_ifid(int iilen
, struct in6_ifaddr
*ia
);
942 extern void in6_purgeprefix(struct ifnet
*);
943 extern void in6_purgeaddrs(struct ifnet
*);
945 extern int in6_is_addr_deprecated(struct sockaddr_in6
*);
946 extern uint8_t im6s_get_mode(const struct in6_multi
*,
947 const struct ip6_msource
*, uint8_t);
949 extern void im6f_leave(struct in6_mfilter
*);
950 extern void im6f_purge(struct in6_mfilter
*);
955 extern int in6_embedscope(struct in6_addr
*, const struct sockaddr_in6
*,
956 struct inpcb
*, struct ifnet
**, struct ip6_pktopts
*);
957 extern int in6_recoverscope(struct sockaddr_in6
*, const struct in6_addr
*,
959 extern void in6_aliasreq_64_to_32(struct in6_aliasreq_64
*,
960 struct in6_aliasreq_32
*);
961 extern void in6_aliasreq_32_to_64(struct in6_aliasreq_32
*,
962 struct in6_aliasreq_64
*);
963 extern void in6_ifaddr_init(void);
964 extern void in6_rtqdrain(void);
965 extern struct radix_node
*in6_validate(struct radix_node
*);
966 extern int in6_if2idlen(struct ifnet
*);
967 extern int in6_src_ioctl (u_long
, caddr_t
);
969 __private_extern__
void in6_multihead_lock_exclusive(void);
970 __private_extern__
void in6_multihead_lock_shared(void);
971 __private_extern__
void in6_multihead_lock_assert(int);
972 __private_extern__
void in6_multihead_lock_done(void);
973 #endif /* XNU_KERNEL_PRIVATE */
974 #endif /* _NETINET6_IN6_VAR_H_ */