2  * Copyright (c) 2000-2016 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@ 
  30  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 
  31  * All rights reserved. 
  33  * Redistribution and use in source and binary forms, with or without 
  34  * modification, are permitted provided that the following conditions 
  36  * 1. Redistributions of source code must retain the above copyright 
  37  *    notice, this list of conditions and the following disclaimer. 
  38  * 2. Redistributions in binary form must reproduce the above copyright 
  39  *    notice, this list of conditions and the following disclaimer in the 
  40  *    documentation and/or other materials provided with the distribution. 
  41  * 3. Neither the name of the project nor the names of its contributors 
  42  *    may be used to endorse or promote products derived from this software 
  43  *    without specific prior written permission. 
  45  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 
  46  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  47  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  48  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 
  49  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
  50  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
  51  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  52  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  53  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
  54  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  59  * Copyright (c) 1985, 1986, 1993 
  60  *      The Regents of the University of California.  All rights reserved. 
  62  * Redistribution and use in source and binary forms, with or without 
  63  * modification, are permitted provided that the following conditions 
  65  * 1. Redistributions of source code must retain the above copyright 
  66  *    notice, this list of conditions and the following disclaimer. 
  67  * 2. Redistributions in binary form must reproduce the above copyright 
  68  *    notice, this list of conditions and the following disclaimer in the 
  69  *    documentation and/or other materials provided with the distribution. 
  70  * 3. All advertising materials mentioning features or use of this software 
  71  *    must display the following acknowledgement: 
  72  *      This product includes software developed by the University of 
  73  *      California, Berkeley and its contributors. 
  74  * 4. Neither the name of the University nor the names of its contributors 
  75  *    may be used to endorse or promote products derived from this software 
  76  *    without specific prior written permission. 
  78  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 
  79  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  80  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  81  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 
  82  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
  83  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
  84  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  85  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  86  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
  87  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  90  *      @(#)in_var.h    8.1 (Berkeley) 6/10/93 
  93 #ifndef _NETINET6_IN6_VAR_H_ 
  94 #define _NETINET6_IN6_VAR_H_ 
  95 #include <sys/appleapiopts.h> 
  96 #include <net/net_kev.h> 
  98 #ifdef BSD_KERNEL_PRIVATE 
 100 #include <sys/mcache.h> 
 101 #endif /* BSD_KERNEL_PRIVATE */ 
 102 #include <netinet6/scope6_var.h> 
 103 #include <sys/kern_event.h> 
 104 #include <net/ethernet.h> 
 107  * pltime/vltime are just for future reference (required to implements 2 
 108  * hour rule for hosts).  they should never be modified by nd6_timeout or 
 110  *      userland -> kernel: accept pltime/vltime 
 111  *      kernel -> userland: throw up everything 
 112  *      in kernel: modify preferred/expire only 
 114 struct in6_addrlifetime 
{ 
 115         time_t ia6t_expire
;     /* valid lifetime expiration time */ 
 116         time_t ia6t_preferred
;  /* preferred lifetime expiration time */ 
 117         u_int32_t ia6t_vltime
;  /* valid lifetime */ 
 118         u_int32_t ia6t_pltime
;  /* prefix lifetime */ 
 121 #ifdef BSD_KERNEL_PRIVATE 
 122 struct in6_addrlifetime_32 
{ 
 123         u_int32_t ia6t_expire
; 
 124         u_int32_t ia6t_preferred
; 
 125         u_int32_t ia6t_vltime
; 
 126         u_int32_t ia6t_pltime
; 
 129 struct in6_addrlifetime_64 
{ 
 130         u_int64_t ia6t_expire
; 
 131         u_int64_t ia6t_preferred
; 
 132         u_int32_t ia6t_vltime
; 
 133         u_int32_t ia6t_pltime
; 
 137  * Internal representation of ia6_lifetime (expiration in uptime unit) 
 139 struct in6_addrlifetime_i 
{ 
 140         u_int64_t ia6ti_expire
;         /* valid lifetime expiration time */ 
 141         u_int64_t ia6ti_preferred
;      /* preferred lifetime expiration time */ 
 142         u_int32_t ia6ti_vltime
;         /* valid lifetime */ 
 143         u_int32_t ia6ti_pltime
;         /* prefix lifetime */ 
 144         u_int64_t ia6ti_base_calendartime
; /* calendar time at creation */ 
 145         u_int64_t ia6ti_base_uptime
;    /* uptime at creation */ 
 149  * Interface address, IPv6 version.  One of these structures 
 150  * is allocated for each interface with an IPv6 address. 
 151  * The ifaddr structure contains the protocol-independent part 
 152  * of the structure and is assumed to be first. 
 156         struct ifaddr ia_ifa
;           /* protocol-independent info */ 
 157 #define ia_ifp          ia_ifa.ifa_ifp 
 158 #define ia_flags        ia_ifa.ifa_flags 
 159         struct sockaddr_in6 ia_addr
;    /* interface address */ 
 160         struct sockaddr_in6 ia_net
;     /* network number of interface */ 
 161         struct sockaddr_in6 ia_dstaddr
; /* space for destination addr */ 
 162         struct sockaddr_in6 ia_prefixmask
; /* prefix mask */ 
 163         u_int32_t ia_plen
;              /* prefix length */ 
 164         struct in6_ifaddr 
*ia_next
;     /* next in6 list of IP6 addresses */ 
 167         struct in6_addrlifetime_i ia6_lifetime
; 
 169          * the creation time of this address, which is 
 170          * currently used for temporary addresses only. 
 172         u_int64_t ia6_createtime
; 
 173         u_int64_t ia6_updatetime
; 
 175         /* back pointer to the ND prefix */ 
 176         struct nd_prefix 
*ia6_ndpr
; 
 178         /* multicast addresses joined from the kernel */ 
 179         LIST_HEAD(, in6_multi_mship
) ia6_memberships
; 
 182 #define ifatoia6(ifa)   ((struct in6_ifaddr *)(void *)(ifa)) 
 183 #endif /* BSD_KERNEL_PRIVATE */ 
 185 /* control structure to manage address selection policy */ 
 186 struct in6_addrpolicy 
{ 
 187         struct sockaddr_in6 addr
; /* prefix address */ 
 188         struct sockaddr_in6 addrmask
; /* prefix mask */ 
 189         int preced
;             /* precedence */ 
 190         int label
;              /* matching label */ 
 191         u_quad_t use
;           /* statistics */ 
 195  * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12). 
 198         u_quad_t ifs6_in_receive
;       /* # of total input datagram */ 
 199         u_quad_t ifs6_in_hdrerr
;        /* # of datagrams with invalid hdr */ 
 200         u_quad_t ifs6_in_toobig
;        /* # of datagrams exceeded MTU */ 
 201         u_quad_t ifs6_in_noroute
;       /* # of datagrams with no route */ 
 202         u_quad_t ifs6_in_addrerr
;       /* # of datagrams with invalid dst */ 
 203         u_quad_t ifs6_in_protounknown
;  /* # of datagrams with unknown proto */ 
 204                                         /* NOTE: increment on final dst if */ 
 205         u_quad_t ifs6_in_truncated
;     /* # of truncated datagrams */ 
 206         u_quad_t ifs6_in_discard
;       /* # of discarded datagrams */ 
 207                                         /* NOTE: fragment timeout is not here */ 
 208         u_quad_t ifs6_in_deliver
;       /* # of datagrams delivered to ULP */ 
 209                                         /* NOTE: increment on final dst if */ 
 210         u_quad_t ifs6_out_forward
;      /* # of datagrams forwarded */ 
 211                                         /* NOTE: increment on outgoing if */ 
 212         u_quad_t ifs6_out_request
;      /* # of outgoing datagrams from ULP */ 
 213                                         /* NOTE: does not include forwrads */ 
 214         u_quad_t ifs6_out_discard
;      /* # of discarded datagrams */ 
 215         u_quad_t ifs6_out_fragok
;       /* # of datagrams fragmented */ 
 216         u_quad_t ifs6_out_fragfail
;     /* # of datagrams failed on fragment */ 
 217         u_quad_t ifs6_out_fragcreat
;    /* # of fragment datagrams */ 
 218                                         /* NOTE: this is # after fragment */ 
 219         u_quad_t ifs6_reass_reqd
;       /* # of incoming fragmented packets */ 
 220                                         /* NOTE: increment on final dst if */ 
 221         u_quad_t ifs6_reass_ok
;         /* # of reassembled packets */ 
 222                                         /* NOTE: this is # after reass */ 
 223                                         /* NOTE: increment on final dst if */ 
 224         u_quad_t ifs6_atmfrag_rcvd
;     /* # of atomic fragments received */ 
 225         u_quad_t ifs6_reass_fail
;       /* # of reass failures */ 
 226                                         /* NOTE: may not be packet count */ 
 227                                         /* NOTE: increment on final dst if */ 
 228         u_quad_t ifs6_in_mcast
;         /* # of inbound multicast datagrams */ 
 229         u_quad_t ifs6_out_mcast
;        /* # of outbound multicast datagrams */ 
 231         u_quad_t ifs6_cantfoward_icmp6
; /* # of ICMPv6 packets received for unreachable dest */ 
 232         u_quad_t ifs6_addr_expiry_cnt
;  /* # of address expiry events (excluding privacy addresses) */ 
 233         u_quad_t ifs6_pfx_expiry_cnt
;   /* # of prefix expiry events */ 
 234         u_quad_t ifs6_defrtr_expiry_cnt
;        /* # of default router expiry events */ 
 238  * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry. 
 239  * XXX: I'm not sure if this file is the right place for this structure... 
 241 struct icmp6_ifstat 
{ 
 245         /* ipv6IfIcmpInMsgs, total # of input messages */ 
 246         u_quad_t ifs6_in_msg
; 
 247         /* ipv6IfIcmpInErrors, # of input error messages */ 
 248         u_quad_t ifs6_in_error
; 
 249         /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */ 
 250         u_quad_t ifs6_in_dstunreach
; 
 251         /* ipv6IfIcmpInAdminProhibs, # of input admin. prohibited errs */ 
 252         u_quad_t ifs6_in_adminprohib
; 
 253         /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */ 
 254         u_quad_t ifs6_in_timeexceed
; 
 255         /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */ 
 256         u_quad_t ifs6_in_paramprob
; 
 257         /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */ 
 258         u_quad_t ifs6_in_pkttoobig
; 
 259         /* ipv6IfIcmpInEchos, # of input echo requests */ 
 260         u_quad_t ifs6_in_echo
; 
 261         /* ipv6IfIcmpInEchoReplies, # of input echo replies */ 
 262         u_quad_t ifs6_in_echoreply
; 
 263         /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */ 
 264         u_quad_t ifs6_in_routersolicit
; 
 265         /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */ 
 266         u_quad_t ifs6_in_routeradvert
; 
 267         /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */ 
 268         u_quad_t ifs6_in_neighborsolicit
; 
 269         /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advs. */ 
 270         u_quad_t ifs6_in_neighboradvert
; 
 271         /* ipv6IfIcmpInRedirects, # of input redirects */ 
 272         u_quad_t ifs6_in_redirect
; 
 273         /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */ 
 274         u_quad_t ifs6_in_mldquery
; 
 275         /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */ 
 276         u_quad_t ifs6_in_mldreport
; 
 277         /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */ 
 278         u_quad_t ifs6_in_mlddone
; 
 281          * Output statistics. We should solve unresolved routing problem... 
 283         /* ipv6IfIcmpOutMsgs, total # of output messages */ 
 284         u_quad_t ifs6_out_msg
; 
 285         /* ipv6IfIcmpOutErrors, # of output error messages */ 
 286         u_quad_t ifs6_out_error
; 
 287         /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */ 
 288         u_quad_t ifs6_out_dstunreach
; 
 289         /* ipv6IfIcmpOutAdminProhibs, # of output admin. prohibited errs */ 
 290         u_quad_t ifs6_out_adminprohib
; 
 291         /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */ 
 292         u_quad_t ifs6_out_timeexceed
; 
 293         /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */ 
 294         u_quad_t ifs6_out_paramprob
; 
 295         /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */ 
 296         u_quad_t ifs6_out_pkttoobig
; 
 297         /* ipv6IfIcmpOutEchos, # of output echo requests */ 
 298         u_quad_t ifs6_out_echo
; 
 299         /* ipv6IfIcmpOutEchoReplies, # of output echo replies */ 
 300         u_quad_t ifs6_out_echoreply
; 
 301         /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */ 
 302         u_quad_t ifs6_out_routersolicit
; 
 303         /* ipv6IfIcmpOutRouterAdvertisements, # of output router advs. */ 
 304         u_quad_t ifs6_out_routeradvert
; 
 305         /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */ 
 306         u_quad_t ifs6_out_neighborsolicit
; 
 307         /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advs. */ 
 308         u_quad_t ifs6_out_neighboradvert
; 
 309         /* ipv6IfIcmpOutRedirects, # of output redirects */ 
 310         u_quad_t ifs6_out_redirect
; 
 311         /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */ 
 312         u_quad_t ifs6_out_mldquery
; 
 313         /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */ 
 314         u_quad_t ifs6_out_mldreport
; 
 315         /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */ 
 316         u_quad_t ifs6_out_mlddone
; 
 320         char    ifr_name
[IFNAMSIZ
]; 
 322                 struct  sockaddr_in6 ifru_addr
; 
 323                 struct  sockaddr_in6 ifru_dstaddr
; 
 329                 struct in6_addrlifetime ifru_lifetime
; 
 330                 struct in6_ifstat ifru_stat
; 
 331                 struct icmp6_ifstat ifru_icmp6stat
; 
 332                 u_int32_t ifru_scope_id
[SCOPE6_ID_MAX
]; 
 336 struct in6_aliasreq 
{ 
 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 ifra_lifetime
; 
 346 #define IN6_CGA_MODIFIER_LENGTH 16 
 348 struct in6_cga_modifier 
{ 
 349         u_int8_t octets
[IN6_CGA_MODIFIER_LENGTH
]; 
 352 struct in6_cga_prepare 
{ 
 353         struct in6_cga_modifier cga_modifier
; 
 354         u_int8_t cga_security_level
; 
 355         u_int8_t reserved_A
[15]; 
 358 #define IN6_CGA_KEY_MAXSIZE     2048    /* octets */ 
 360 struct in6_cga_nodecfg 
{ 
 361         struct iovec cga_privkey
; 
 362         struct iovec cga_pubkey
; 
 363         struct in6_cga_prepare cga_prepare
; 
 367  * XXX in6_llstartreq will be removed once 
 368  * configd adopts the more generically named 
 369  * in6_cgareq structure. 
 371 struct in6_llstartreq 
{ 
 372         char llsr_name
[IFNAMSIZ
]; 
 374         struct in6_cga_prepare llsr_cgaprep
; 
 375         struct in6_addrlifetime llsr_lifetime
; 
 379         char cgar_name
[IFNAMSIZ
]; 
 381         struct in6_cga_prepare cgar_cgaprep
; 
 382         struct in6_addrlifetime cgar_lifetime
; 
 385 #ifdef BSD_KERNEL_PRIVATE 
 387  * XXX Corresponding versions of in6_llstartreq 
 388  * will be removed after the new in6_cgareq is 
 391 struct in6_llstartreq_32 
{ 
 392         char llsr_name
[IFNAMSIZ
]; 
 394         struct in6_cga_prepare llsr_cgaprep
; 
 395         struct in6_addrlifetime_32 llsr_lifetime
; 
 398 struct in6_llstartreq_64 
{ 
 399         char llsr_name
[IFNAMSIZ
]; 
 401         struct in6_cga_prepare llsr_cgaprep
; 
 402         struct in6_addrlifetime_64 llsr_lifetime
; 
 405 struct in6_cgareq_32 
{ 
 406         char cgar_name
[IFNAMSIZ
]; 
 408         struct in6_cga_prepare cgar_cgaprep
; 
 409         struct in6_addrlifetime_32 cgar_lifetime
; 
 412 struct in6_cgareq_64 
{ 
 413         char cgar_name
[IFNAMSIZ
]; 
 415         struct in6_cga_prepare cgar_cgaprep
; 
 416         struct in6_addrlifetime_64 cgar_lifetime
; 
 419 #endif /* !BSD_KERNEL_PRIVATE */ 
 422 #ifdef BSD_KERNEL_PRIVATE 
 423 struct in6_aliasreq_32 
{ 
 424         char    ifra_name
[IFNAMSIZ
]; 
 425         struct  sockaddr_in6 ifra_addr
; 
 426         struct  sockaddr_in6 ifra_dstaddr
; 
 427         struct  sockaddr_in6 ifra_prefixmask
; 
 429         struct in6_addrlifetime_32 ifra_lifetime
; 
 432 struct in6_aliasreq_64 
{ 
 433         char    ifra_name
[IFNAMSIZ
]; 
 434         struct  sockaddr_in6 ifra_addr
; 
 435         struct  sockaddr_in6 ifra_dstaddr
; 
 436         struct  sockaddr_in6 ifra_prefixmask
; 
 438         struct in6_addrlifetime_64 ifra_lifetime
; 
 440 #endif /* BSD_KERNEL_PRIVATE */ 
 442 /* prefix type macro */ 
 443 #define IN6_PREFIX_ND   1 
 444 #define IN6_PREFIX_RR   2 
 447  * prefix related flags passed between kernel(NDP related part) and 
 448  * user land command(ifconfig) and daemon(rtadvd). 
 453                 u_char autonomous 
: 1; 
 456         u_char prf_reserved1
; 
 457         u_short prf_reserved2
; 
 458         /* want to put this on 4byte offset */ 
 460                 u_char decrvalid 
: 1; 
 461                 u_char decrprefd 
: 1; 
 464         u_char prf_reserved3
; 
 465         u_short prf_reserved4
; 
 468 struct  in6_prefixreq 
{ 
 469         char    ipr_name
[IFNAMSIZ
]; 
 472         u_int32_t ipr_vltime
; 
 473         u_int32_t ipr_pltime
; 
 474         struct in6_prflags ipr_flags
; 
 475         struct  sockaddr_in6 ipr_prefix
; 
 480 #define PR_ORIG_STATIC  2 
 481 #define PR_ORIG_KERNEL  3 
 483 #define ipr_raf_onlink          ipr_flags.prf_ra.onlink 
 484 #define ipr_raf_auto            ipr_flags.prf_ra.autonomous 
 486 #define ipr_statef_onlink       ipr_flags.prf_state.onlink 
 488 #define ipr_rrf_decrvalid       ipr_flags.prf_rr.decrvalid 
 489 #define ipr_rrf_decrprefd       ipr_flags.prf_rr.decrprefd 
 491 struct in6_rrenumreq 
{ 
 492         char    irr_name
[IFNAMSIZ
]; 
 494         u_char  irr_m_len
;      /* match len for matchprefix */ 
 495         u_char  irr_m_minlen
;   /* minlen for matching prefix */ 
 496         u_char  irr_m_maxlen
;   /* maxlen for matching prefix */ 
 497         u_char  irr_u_uselen
;   /* uselen for adding prefix */ 
 498         u_char  irr_u_keeplen
;  /* keeplen from matching prefix */ 
 499         struct irr_raflagmask 
{ 
 501                 u_char autonomous 
: 1; 
 504         u_int32_t irr_vltime
; 
 505         u_int32_t irr_pltime
; 
 506         struct in6_prflags irr_flags
; 
 507         struct  sockaddr_in6 irr_matchprefix
; 
 508         struct  sockaddr_in6 irr_useprefix
; 
 511 #define irr_raf_mask_onlink     irr_raflagmask.onlink 
 512 #define irr_raf_mask_auto       irr_raflagmask.autonomous 
 513 #define irr_raf_mask_reserved   irr_raflagmask.reserved 
 515 #define irr_raf_onlink          irr_flags.prf_ra.onlink 
 516 #define irr_raf_auto            irr_flags.prf_ra.autonomous 
 518 #define irr_statef_onlink       irr_flags.prf_state.onlink 
 520 #define irr_rrf                 irr_flags.prf_rr 
 521 #define irr_rrf_decrvalid       irr_flags.prf_rr.decrvalid 
 522 #define irr_rrf_decrprefd       irr_flags.prf_rr.decrprefd 
 525  * Event data, inet6 style. 
 527 struct kev_in6_addrlifetime 
{ 
 528         u_int32_t ia6t_expire
; 
 529         u_int32_t ia6t_preferred
; 
 530         u_int32_t ia6t_vltime
; 
 531         u_int32_t ia6t_pltime
; 
 534 struct kev_in6_data 
{ 
 535         struct net_event_data link_data
; 
 536         struct sockaddr_in6 ia_addr
;    /* interface address */ 
 537         struct sockaddr_in6 ia_net
;     /* network number of interface */ 
 538         struct sockaddr_in6 ia_dstaddr
; /* space for destination addr */ 
 539         struct sockaddr_in6 ia_prefixmask
; /* prefix mask */ 
 540         u_int32_t ia_plen
;              /* prefix length */ 
 541         u_int32_t ia6_flags
;            /* address flags from in6_ifaddr */ 
 542         struct kev_in6_addrlifetime ia_lifetime
; /* address life info */ 
 543         uint8_t ia_mac
[ETHER_ADDR_LEN
]; 
 546 #ifdef BSD_KERNEL_PRIVATE 
 547 /* Utility function used inside netinet6 kernel code for generating events */ 
 548 void in6_post_msg(struct ifnet 
*, u_int32_t
, struct in6_ifaddr 
*, uint8_t *mac
); 
 550 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)      (       \ 
 551         (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ 
 552         (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ 
 553         (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ 
 554         (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0) 
 557  * Given a pointer to an in6_ifaddr (ifaddr), 
 558  * return a pointer to the addr as a sockaddr_in6 
 560 #define IA6_IN6(ia)     (&((ia)->ia_addr.sin6_addr)) 
 561 #define IA6_DSTIN6(ia)  (&((ia)->ia_dstaddr.sin6_addr)) 
 562 #define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr)) 
 563 #define IA6_SIN6(ia)    (&((ia)->ia_addr)) 
 564 #define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr)) 
 566         (&((struct sockaddr_in6 *)(void *)((x)->ifa_addr))->sin6_addr) 
 567 #define IFA_DSTIN6(x)   \ 
 568         (&((struct sockaddr_in6 *)(void *)((x)->ifa_dstaddr))->sin6_addr) 
 569 #define IFPR_IN6(x)     \ 
 570         (&((struct sockaddr_in6 *)(void *)((x)->ifpr_prefix))->sin6_addr) 
 571 #endif /* BSD_KERNEL_PRIVATE */ 
 573 #define SIOCSIFADDR_IN6          _IOW('i', 12, struct in6_ifreq) 
 574 #define SIOCGIFADDR_IN6         _IOWR('i', 33, struct in6_ifreq) 
 577  * SIOCSxxx ioctls should be unused (see comments in in6.c), but 
 578  * we do not shift numbers for binary compatibility. 
 580 #define SIOCSIFDSTADDR_IN6      _IOW('i', 14, struct in6_ifreq) 
 581 #define SIOCSIFNETMASK_IN6      _IOW('i', 22, struct in6_ifreq) 
 583 #define SIOCGIFDSTADDR_IN6      _IOWR('i', 34, struct in6_ifreq) 
 584 #define SIOCGIFNETMASK_IN6      _IOWR('i', 37, struct in6_ifreq) 
 586 #define SIOCDIFADDR_IN6         _IOW('i', 25, struct in6_ifreq) 
 587 #define SIOCAIFADDR_IN6         _IOW('i', 26, struct in6_aliasreq) 
 588 #ifdef BSD_KERNEL_PRIVATE 
 589 #define SIOCAIFADDR_IN6_32      _IOW('i', 26, struct in6_aliasreq_32) 
 590 #define SIOCAIFADDR_IN6_64      _IOW('i', 26, struct in6_aliasreq_64) 
 591 #endif /* BSD_KERNEL_PRIVATE */ 
 593 #define SIOCSIFPHYADDR_IN6      _IOW('i', 62, struct in6_aliasreq) 
 594 #ifdef BSD_KERNEL_PRIVATE 
 595 #define SIOCSIFPHYADDR_IN6_32   _IOW('i', 62, struct in6_aliasreq_32) 
 596 #define SIOCSIFPHYADDR_IN6_64   _IOW('i', 62, struct in6_aliasreq_64) 
 597 #endif /* BSD_KERNEL_PRIVATE */ 
 598 #define SIOCGIFPSRCADDR_IN6     _IOWR('i', 63, struct in6_ifreq) 
 599 #define SIOCGIFPDSTADDR_IN6     _IOWR('i', 64, struct in6_ifreq) 
 600 #define SIOCGIFAFLAG_IN6        _IOWR('i', 73, struct in6_ifreq) 
 602 #define SIOCGDRLST_IN6          _IOWR('i', 74, struct in6_drlist) 
 603 #ifdef BSD_KERNEL_PRIVATE 
 604 #define SIOCGDRLST_IN6_32       _IOWR('i', 74, struct in6_drlist_32) 
 605 #define SIOCGDRLST_IN6_64       _IOWR('i', 74, struct in6_drlist_64) 
 606 #endif /* BSD_KERNEL_PRIVATE */ 
 608 #define SIOCGPRLST_IN6          _IOWR('i', 75, struct in6_prlist) 
 609 #ifdef BSD_KERNEL_PRIVATE 
 610 #define SIOCGPRLST_IN6_32       _IOWR('i', 75, struct in6_prlist_32) 
 611 #define SIOCGPRLST_IN6_64       _IOWR('i', 75, struct in6_prlist_64) 
 612 #endif /* BSD_KERNEL_PRIVATE */ 
 614 #define OSIOCGIFINFO_IN6        _IOWR('i', 108, struct in6_ondireq) 
 615 #define SIOCGIFINFO_IN6         _IOWR('i', 76, struct in6_ondireq) 
 616 #define SIOCSNDFLUSH_IN6        _IOWR('i', 77, struct in6_ifreq) 
 618 #define SIOCGNBRINFO_IN6        _IOWR('i', 78, struct in6_nbrinfo) 
 619 #ifdef BSD_KERNEL_PRIVATE 
 620 #define SIOCGNBRINFO_IN6_32     _IOWR('i', 78, struct in6_nbrinfo_32) 
 621 #define SIOCGNBRINFO_IN6_64     _IOWR('i', 78, struct in6_nbrinfo_64) 
 622 #endif /* BSD_KERNEL_PRIVATE */ 
 624 #define SIOCSPFXFLUSH_IN6       _IOWR('i', 79, struct in6_ifreq) 
 625 #define SIOCSRTRFLUSH_IN6       _IOWR('i', 80, struct in6_ifreq) 
 627 #define SIOCGIFALIFETIME_IN6    _IOWR('i', 81, struct in6_ifreq) 
 628 #define SIOCSIFALIFETIME_IN6    _IOWR('i', 82, struct in6_ifreq) 
 629 #define SIOCGIFSTAT_IN6         _IOWR('i', 83, struct in6_ifreq) 
 630 #define SIOCGIFSTAT_ICMP6       _IOWR('i', 84, struct in6_ifreq) 
 632 #define SIOCSDEFIFACE_IN6       _IOWR('i', 85, struct in6_ndifreq) 
 633 #define SIOCGDEFIFACE_IN6       _IOWR('i', 86, struct in6_ndifreq) 
 634 #ifdef BSD_KERNEL_PRIVATE 
 635 #define SIOCSDEFIFACE_IN6_32    _IOWR('i', 85, struct in6_ndifreq_32) 
 636 #define SIOCSDEFIFACE_IN6_64    _IOWR('i', 85, struct in6_ndifreq_64) 
 637 #define SIOCGDEFIFACE_IN6_32    _IOWR('i', 86, struct in6_ndifreq_32) 
 638 #define SIOCGDEFIFACE_IN6_64    _IOWR('i', 86, struct in6_ndifreq_64) 
 639 #endif /* BSD_KERNEL_PRIVATE */ 
 641 #define SIOCSIFINFO_FLAGS       _IOWR('i', 87, struct in6_ndireq) /* XXX */ 
 643 /* N.B.: These 3 ioctls are deprecated and won't work */ 
 644 #define SIOCSSCOPE6             _IOW('i', 88, struct in6_ifreq) 
 645 #define SIOCGSCOPE6             _IOWR('i', 89, struct in6_ifreq) 
 646 #define SIOCGSCOPE6DEF          _IOWR('i', 90, struct in6_ifreq) 
 648 #define SIOCSIFPREFIX_IN6       _IOW('i', 100, struct in6_prefixreq) /* set */ 
 649 #define SIOCGIFPREFIX_IN6       _IOWR('i', 101, struct in6_prefixreq) /* get */ 
 650 #define SIOCDIFPREFIX_IN6       _IOW('i', 102, struct in6_prefixreq) /* del */ 
 651 #define SIOCAIFPREFIX_IN6       _IOW('i', 103, struct in6_rrenumreq) /* add */ 
 654 #define SIOCCIFPREFIX_IN6       _IOW('i', 104, struct in6_rrenumreq) 
 657 #define SIOCSGIFPREFIX_IN6      _IOW('i', 105, struct in6_rrenumreq) 
 660  * multicast routing, get s/g pkt cnt, pkt cnt per interface. 
 662 #define SIOCGETSGCNT_IN6        _IOWR('u', 28, struct sioc_sg_req6) 
 663 #define SIOCGETMIFCNT_IN6       _IOWR('u', 107, struct sioc_mif_req6) 
 664 #ifdef BSD_KERNEL_PRIVATE 
 665 #define SIOCGETMIFCNT_IN6_32    _IOWR('u', 107, struct sioc_mif_req6_32) 
 666 #define SIOCGETMIFCNT_IN6_64    _IOWR('u', 107, struct sioc_mif_req6_64) 
 667 #endif /* BSD_KERNEL_PRIVATE */ 
 669 #define SIOCAADDRCTL_POLICY     _IOW('u', 108, struct in6_addrpolicy) 
 670 #define SIOCDADDRCTL_POLICY     _IOW('u', 109, struct in6_addrpolicy) 
 674  * temporary control calls to attach/detach IPv6 to/from an interface. 
 676 #define SIOCPROTOATTACH_IN6     _IOWR('i', 110, struct in6_aliasreq) 
 677 #ifdef BSD_KERNEL_PRIVATE 
 678 #define SIOCPROTOATTACH_IN6_32  _IOWR('i', 110, struct in6_aliasreq_32) 
 679 #define SIOCPROTOATTACH_IN6_64  _IOWR('i', 110, struct in6_aliasreq_64) 
 680 #endif /* BSD_KERNEL_PRIVATE */ 
 681 #define SIOCPROTODETACH_IN6     _IOWR('i', 111, struct in6_ifreq) 
 684  * start/stop aquiring linklocal on interface 
 686 #define SIOCLL_START            _IOWR('i', 130, struct in6_aliasreq) 
 687 #ifdef BSD_KERNEL_PRIVATE 
 688 #define SIOCLL_START_32         _IOWR('i', 130, struct in6_aliasreq_32) 
 689 #define SIOCLL_START_64         _IOWR('i', 130, struct in6_aliasreq_64) 
 690 #endif /* BSD_KERNEL_PRIVATE */ 
 691 #define SIOCLL_STOP             _IOWR('i', 131, struct in6_ifreq) 
 694  * accept rtadvd (and stop accepting) on this interface. 
 696 #define SIOCAUTOCONF_START      _IOWR('i', 132, struct in6_ifreq) 
 697 #define SIOCAUTOCONF_STOP       _IOWR('i', 133, struct in6_ifreq) 
 700  * add/remove default IPv6 router. 
 702 #define SIOCDRADD_IN6           _IOWR('u', 134, struct in6_defrouter) 
 703 #ifdef BSD_KERNEL_PRIVATE 
 704 #define SIOCDRADD_IN6_32        _IOWR('u', 134, struct in6_defrouter_32) 
 705 #define SIOCDRADD_IN6_64        _IOWR('u', 134, struct in6_defrouter_64) 
 706 #endif /* BSD_KERNEL_PRIVATE */ 
 707 #define SIOCDRDEL_IN6           _IOWR('u', 135, struct in6_defrouter) 
 708 #ifdef BSD_KERNEL_PRIVATE 
 709 #define SIOCDRDEL_IN6_32        _IOWR('u', 135, struct in6_defrouter_32) 
 710 #define SIOCDRDEL_IN6_64        _IOWR('u', 135, struct in6_defrouter_64) 
 711 #endif /* BSD_KERNEL_PRIVATE */ 
 714  * enable/disable IPv6 router mode on interface. 
 716 #define SIOCSETROUTERMODE_IN6   _IOWR('i', 136, struct in6_ifreq) 
 719  * start secure link-local interface addresses 
 721 #define SIOCLL_CGASTART         _IOW('i', 160, struct in6_cgareq) 
 722 #ifdef BSD_KERNEL_PRIVATE 
 723 #define SIOCLL_CGASTART_32      _IOW('i', 160, struct in6_cgareq_32) 
 724 #define SIOCLL_CGASTART_64      _IOW('i', 160, struct in6_cgareq_64) 
 726 #define SIOCGIFCGAPREP_IN6      _IOWR('i', 187, struct in6_cgareq) 
 727 #define SIOCSIFCGAPREP_IN6      _IOWR('i', 188, struct in6_cgareq) 
 731 #ifdef BSD_KERNEL_PRIVATE 
 733  * XXX: Do not extend IN6_IFF values beyond 16-bit.  We currently copy the 
 734  *      values from ia6_flags as is into m_pkthdr.{src,dst}_iff which are 
 735  *      defined as 16-bit variables.  We can relax this once we define a 
 736  *      unified set of interface flags for {ia,ia6}_flags and perform 
 737  *      translation between those and the publicly-defined ones below. 
 739 #endif /* BSD_KERNEL_PRIVATE */ 
 740 #define IN6_IFF_ANYCAST         0x0001  /* anycast address */ 
 741 #define IN6_IFF_TENTATIVE       0x0002  /* tentative address */ 
 742 #define IN6_IFF_DUPLICATED      0x0004  /* DAD detected duplicate */ 
 743 #define IN6_IFF_DETACHED        0x0008  /* may be detached from the link */ 
 744 #define IN6_IFF_DEPRECATED      0x0010  /* deprecated address */ 
 746 /* don't perform DAD on this address (used only at first SIOC* call) */ 
 747 #define IN6_IFF_NODAD           0x0020 
 749 #define IN6_IFF_AUTOCONF        0x0040  /* autoconfigurable address. */ 
 750 #define IN6_IFF_TEMPORARY       0x0080  /* temporary (anonymous) address. */ 
 751 #define IN6_IFF_DYNAMIC         0x0100  /* assigned by DHCPv6 service */ 
 752 #define IN6_IFF_OPTIMISTIC      0x0200  /* optimistic DAD, i.e. RFC 4429 */ 
 753 #define IN6_IFF_SECURED         0x0400  /* cryptographically generated */ 
 755 #define IN6_IFF_SWIFTDAD        0x0800  /* DAD with no delay */ 
 757 #define IN6_IFF_NOPFX           0x8000  /* Depreciated. Don't use. */ 
 759 /* Duplicate Address Detection [DAD] in progress. */ 
 760 #define IN6_IFF_DADPROGRESS     (IN6_IFF_TENTATIVE|IN6_IFF_OPTIMISTIC) 
 762 /* do not input/output */ 
 763 #define IN6_IFF_NOTREADY        (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED) 
 765 /* SLAAC/DHCPv6 address */ 
 766 #define IN6_IFF_NOTMANUAL       (IN6_IFF_AUTOCONF|IN6_IFF_DYNAMIC) 
 769 #define IN6_ARE_SCOPE_CMP(a, b)         ((a) - (b)) 
 770 #define IN6_ARE_SCOPE_EQUAL(a, b)       ((a) == (b)) 
 773 #ifdef BSD_KERNEL_PRIVATE 
 774 extern struct in6_ifaddr 
*in6_ifaddrs
; 
 776 extern struct icmp6stat icmp6stat
; 
 777 extern lck_rw_t in6_ifaddr_rwlock
; 
 778 extern lck_mtx_t proxy6_lock
; 
 779 extern u_char inet6ctlerrmap
[]; 
 780 extern u_int32_t in6_maxmtu
; 
 782 /* N.B.: if_inet6data is never freed once set, so we don't need to lock */ 
 783 #define in6_ifstat_inc_common(_ifp, _tag, _atomic) do {                 \ 
 784         if (_ifp != NULL && IN6_IFEXTRA(_ifp) != NULL) {                \ 
 787                             &IN6_IFEXTRA(_ifp)->in6_ifstat._tag, 1);    \ 
 789                         IN6_IFEXTRA(_ifp)->in6_ifstat._tag++;           \ 
 794 #define in6_ifstat_inc(_ifp, _tag) \ 
 795         in6_ifstat_inc_common(_ifp, _tag, TRUE) 
 797 /* non-atomic version (for fast paths) */ 
 798 #define in6_ifstat_inc_na(_ifp, _tag) \ 
 799         in6_ifstat_inc_common(_ifp, _tag, FALSE) 
 802  * Macro for finding the internet address structure (in6_ifaddr) corresponding 
 803  * to a given interface (ifnet structure). 
 806 #define IFP_TO_IA6(ifp, ia)                                             \ 
 807         /* struct ifnet *ifp; */                                        \ 
 808         /* struct in6_ifaddr *ia; */                                    \ 
 810         struct ifaddr *_ifa;                                            \ 
 811         ifnet_lock_assert(ifp, LCK_RW_ASSERT_HELD);                     \ 
 812         for (_ifa = (ifp)->if_addrlist.tqh_first; _ifa != NULL;         \ 
 813             _ifa = _ifa->ifa_list.tqe_next) {                           \ 
 815                 if (_ifa->ifa_addr->sa_family == AF_INET6) {            \ 
 816                         IFA_ADDREF_LOCKED(_ifa);                        \ 
 822         (ia) = (struct in6_ifaddr *)_ifa;                               \ 
 826  * IPv6 multicast MLD-layer source entry. 
 829         RB_ENTRY(ip6_msource
)   im6s_link
;      /* RB tree links */ 
 830         struct in6_addr         im6s_addr
; 
 832                 uint16_t        ex
;             /* # of exclusive members */ 
 833                 uint16_t        in
;             /* # of inclusive members */ 
 834         }                       im6s_st
[2];     /* state at t0, t1 */ 
 835         uint8_t                 im6s_stp
;       /* pending query */ 
 838 RB_HEAD(ip6_msource_tree
, ip6_msource
); 
 840 RB_PROTOTYPE_SC_PREV(__private_extern__
, ip6_msource_tree
, ip6_msource
, 
 841     im6s_link
, ip6_msource_cmp
); 
 844  * IPv6 multicast PCB-layer source entry. 
 846  * NOTE: overlapping use of struct ip6_msource fields at start. 
 849         RB_ENTRY(ip6_msource
)   im6s_link
;      /* Common field */ 
 850         struct in6_addr         im6s_addr
;      /* Common field */ 
 851         uint8_t                 im6sl_st
[2];    /* state before/at commit */ 
 855  * IPv6 multicast PCB-layer group filter descriptor. 
 858         struct ip6_msource_tree im6f_sources
; /* source list for (S,G) */ 
 859         u_long                  im6f_nsrc
;    /* # of source entries */ 
 860         uint8_t                 im6f_st
[2];   /* state before/at commit */ 
 864  * Legacy KAME IPv6 multicast membership descriptor. 
 866 struct in6_multi_mship 
{ 
 867         struct  in6_multi 
*i6mm_maddr
;  /* Multicast address pointer */ 
 868         LIST_ENTRY(in6_multi_mship
) i6mm_chain
;  /* multicast options chain */ 
 871 #ifdef BSD_KERNEL_PRIVATE 
 872 #include <netinet6/nd6_var.h> 
 873 #include <net/if_llatbl.h> 
 876  * Per-interface IPv6 structures. 
 879         struct scope6_id        scope6_id
; 
 880         struct in6_ifstat       in6_ifstat
; 
 881         struct icmp6_ifstat     icmp6_ifstat
; 
 882         struct nd_ifinfo        nd_ifinfo
; 
 884         u_int8_t                netsig
[IFNET_SIGNATURELEN
]; 
 885         struct ipv6_prefix      nat64_prefixes
[NAT64_MAX_NUM_PREFIXES
]; 
 886         struct lltable          
*ii_llt
;        /* NDP state */ 
 888 #define IN6_IFEXTRA(_ifp)       ((struct in6_ifextra *)(_ifp->if_inet6data)) 
 889 #define LLTABLE6(ifp)           ((IN6_IFEXTRA(ifp) == NULL) ? NULL : IN6_IFEXTRA(ifp)->ii_llt) 
 890 #endif /* BSD_KERNEL_PRIVATE */ 
 895  * IPv6 group descriptor. 
 897  * For every entry on an ifnet's if_multiaddrs list which represents 
 898  * an IP multicast group, there is one of these structures. 
 900  * If any source filters are present, then a node will exist in the RB-tree 
 901  * to permit fast lookup by source whenever an operation takes place. 
 902  * This permits pre-order traversal when we issue reports. 
 903  * Source filter trees are kept separately from the socket layer to 
 904  * greatly simplify locking. 
 906  * When MLDv2 is active, in6m_timer is the response to group query timer. 
 907  * The state-change timer in6m_sctimer is separate; whenever state changes 
 908  * for the group the state change record is generated and transmitted, 
 909  * and kept if retransmissions are necessary. 
 911  * The request count here is a count of requests for this address, not a 
 912  * count of pointers to this structure. 
 914  * FUTURE: in6m_entry is now only used when groups are being purged 
 915  * on a detaching ifnet.  It could be demoted to a SLIST_ENTRY. 
 918         decl_lck_mtx_data(, in6m_lock
); 
 919         u_int32_t in6m_refcount
;        /* reference count */ 
 920         u_int32_t in6m_reqcnt
;          /* request count for this address */ 
 921         u_int32_t in6m_debug
;           /* see ifa_debug flags */ 
 922         LIST_ENTRY(in6_multi
) in6m_entry
; /* list glue */ 
 923         struct  in6_addr in6m_addr
;     /* IP6 multicast address */ 
 924         struct  ifnet 
*in6m_ifp
;        /* back pointer to ifnet */ 
 925         struct  ifmultiaddr 
*in6m_ifma
; /* back pointer to ifmultiaddr */ 
 926         u_int   in6m_state
;             /* state of the membership */ 
 927         u_int   in6m_timer
;             /* MLD6 listener report timer */ 
 929         /* New fields for MLDv2 follow. */ 
 930         struct mld_ifinfo       
*in6m_mli
;      /* MLD info */ 
 931         SLIST_ENTRY(in6_multi
)   in6m_dtle
;     /* detached waiting for rele  */ 
 932         SLIST_ENTRY(in6_multi
)   in6m_nrele
;    /* to-be-released by MLD */ 
 933         u_int32_t                in6m_nrelecnt
; /* deferred release count */ 
 934         struct ip6_msource_tree  in6m_srcs
;     /* tree of sources */ 
 935         u_long                   in6m_nsrc
;     /* # of tree entries */ 
 937         struct ifqueue           in6m_scq
;  /* pending state-change packets */ 
 938         struct timeval           in6m_lastgsrtv
;        /* last G-S-R query */ 
 939         uint16_t                 in6m_sctimer
;  /* state-change timer */ 
 940         uint16_t                 in6m_scrv
;     /* state-change rexmit count */ 
 943          * SSM state counters which track state at T0 (the time the last 
 944          * state-change report's RV timer went to zero) and T1 
 945          * (time of pending report, i.e. now). 
 946          * Used for computing MLDv2 state-change reports. Several refcounts 
 947          * are maintained here to optimize for common use-cases. 
 950                 uint16_t        iss_fmode
;      /* MLD filter mode */ 
 951                 uint16_t        iss_asm
;        /* # of ASM listeners */ 
 952                 uint16_t        iss_ex
;         /* # of exclusive members */ 
 953                 uint16_t        iss_in
;         /* # of inclusive members */ 
 954                 uint16_t        iss_rec
;        /* # of recorded sources */ 
 955         }                       in6m_st
[2];     /* state at t0, t1 */ 
 957         void (*in6m_trace
)              /* callback fn for tracing refs */ 
 958             (struct in6_multi 
*, int); 
 961 #define IN6M_LOCK_ASSERT_HELD(_in6m)                                    \ 
 962         LCK_MTX_ASSERT(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_OWNED) 
 964 #define IN6M_LOCK_ASSERT_NOTHELD(_in6m)                                 \ 
 965         LCK_MTX_ASSERT(&(_in6m)->in6m_lock, LCK_MTX_ASSERT_NOTOWNED) 
 967 #define IN6M_LOCK(_in6m)                                                \ 
 968         lck_mtx_lock(&(_in6m)->in6m_lock) 
 970 #define IN6M_LOCK_SPIN(_in6m)                                           \ 
 971         lck_mtx_lock_spin(&(_in6m)->in6m_lock) 
 973 #define IN6M_CONVERT_LOCK(_in6m) do {                                   \ 
 974         IN6M_LOCK_ASSERT_HELD(_in6m);                                   \ 
 975         lck_mtx_convert_spin(&(_in6m)->in6m_lock);                      \ 
 978 #define IN6M_UNLOCK(_in6m)                                              \ 
 979         lck_mtx_unlock(&(_in6m)->in6m_lock) 
 981 #define IN6M_ADDREF(_in6m)                                              \ 
 982         in6m_addref(_in6m, 0) 
 984 #define IN6M_ADDREF_LOCKED(_in6m)                                       \ 
 985         in6m_addref(_in6m, 1) 
 987 #define IN6M_REMREF(_in6m)                                              \ 
 988         in6m_remref(_in6m, 0) 
 990 #define IN6M_REMREF_LOCKED(_in6m)                                       \ 
 991         in6m_remref(_in6m, 1) 
 993 /* flags to in6_update_ifa */ 
 994 #define IN6_IFAUPDATE_NOWAIT    0x1 /* don't block allocating memory */ 
 995 #define IN6_IFAUPDATE_1STADDR   0x2 /* first address on interface */ 
 996 #define IN6_IFAUPDATE_NEWADDR   0x4 /* new address on interface */ 
 997 #define IN6_IFAUPDATE_DADDELAY  0x8 /* must delay initial DAD probe */ 
1003 extern LIST_HEAD(in6_multihead
, in6_multi
) in6_multihead
; 
1006  * Structure used by macros below to remember position when stepping through 
1007  * all of the in6_multi records. 
1009 struct in6_multistep 
{ 
1010         struct in6_ifaddr 
*i_ia
; 
1011         struct in6_multi 
*i_in6m
; 
1015  * Macros for looking up the in6_multi record for a given IP6 multicast 
1016  * address on a given interface. If no matching record is found, "in6m" 
1019  * We do this differently compared other BSD implementations; instead of 
1020  * walking the if_multiaddrs list at the interface and returning the 
1021  * ifma_protospec value of a matching entry, we search the global list 
1022  * of in6_multi records and find it that way.  Otherwise either the two 
1023  * structures (in6_multi, ifmultiaddr) need to be ref counted both ways, 
1024  * which will make things too complicated, or they need to reside in the 
1025  * same protected domain, which they aren't. 
1027  * Must be called with in6_multihead_lock held. 
1029 #define IN6_LOOKUP_MULTI(addr, ifp, in6m)                               \ 
1030         /* struct in6_addr *addr; */                                    \ 
1031         /* struct ifnet *ifp; */                                        \ 
1032         /* struct in6_multi *in6m; */                                   \ 
1034         struct in6_multistep _step;                                     \ 
1035         IN6_FIRST_MULTI(_step, in6m);                                   \ 
1036         while ((in6m) != NULL) {                                        \ 
1037                 IN6M_LOCK_SPIN(in6m);                                   \ 
1038                 if ((in6m)->in6m_ifp == (ifp) &&                        \ 
1039                     IN6_ARE_ADDR_EQUAL(&(in6m)->in6m_addr, (addr))) {   \ 
1040                         IN6M_ADDREF_LOCKED(in6m);                       \ 
1041                         IN6M_UNLOCK(in6m);                              \ 
1044                 IN6M_UNLOCK(in6m);                                      \ 
1045                 IN6_NEXT_MULTI(_step, in6m);                            \ 
1050  * Macro to step through all of the in6_multi records, one at a time. 
1051  * The current position is remembered in "step", which the caller must 
1052  * provide.  IN6_FIRST_MULTI(), below, must be called to initialize "step" 
1053  * and get the first record.  Both macros return a NULL "in6m" when there 
1054  * are no remaining records. 
1056  * Must be called with in6_multihead_lock held. 
1058 #define IN6_NEXT_MULTI(step, in6m)                                      \ 
1059         /* struct in6_multistep step; */                                \ 
1060         /* struct in6_multi *in6m; */                                   \ 
1062         in6_multihead_lock_assert(LCK_RW_ASSERT_HELD);                  \ 
1063         if (((in6m) = (step).i_in6m) != NULL)                           \ 
1064                 (step).i_in6m = (step).i_in6m->in6m_entry.le_next;      \ 
1067 #define IN6_FIRST_MULTI(step, in6m)                                     \ 
1068         /* struct in6_multistep step; */                                \ 
1069         /* struct in6_multi *in6m */                                    \ 
1071         in6_multihead_lock_assert(LCK_RW_ASSERT_HELD);                  \ 
1072         (step).i_in6m = in6_multihead.lh_first;                         \ 
1073                 IN6_NEXT_MULTI((step), (in6m));                         \ 
1076 extern lck_mtx_t 
*inet6_domain_mutex
; 
1077 extern struct domain 
*inet6domain
; 
1081 /* Multicast private KPIs. */ 
1082 extern int im6o_mc_filter(const struct ip6_moptions 
*, const struct ifnet 
*, 
1083     const struct sockaddr_in6 
*, const struct sockaddr_in6 
*); 
1084 extern int in6_mc_join(struct ifnet 
*, const struct in6_addr 
*, 
1085     struct in6_mfilter 
*, struct in6_multi 
**, int); 
1086 extern int in6_mc_leave(struct in6_multi 
*, struct in6_mfilter 
*); 
1087 extern void in6m_clear_recorded(struct in6_multi 
*); 
1088 extern void in6m_commit(struct in6_multi 
*); 
1089 extern void in6m_purge(struct in6_multi 
*); 
1090 extern void in6m_print(const struct in6_multi 
*); 
1091 extern int in6m_record_source(struct in6_multi 
*, const struct in6_addr 
*); 
1092 extern int ip6_getmoptions(struct inpcb 
*, struct sockopt 
*); 
1093 extern int ip6_setmoptions(struct inpcb 
*, struct sockopt 
*); 
1094 /* Legacy KAME multicast private KPIs. */ 
1095 extern struct in6_multi_mship 
*in6_joingroup(struct ifnet 
*, 
1096     struct in6_addr 
*, int *, int); 
1097 extern int in6_leavegroup(struct in6_multi_mship 
*); 
1098 extern void in6_multi_init(void); 
1099 extern void in6m_addref(struct in6_multi 
*, int); 
1100 extern void in6m_remref(struct in6_multi 
*, int); 
1101 extern int in6_multi_detach(struct in6_multi 
*); 
1102 extern int in6_ifindex2scopeid(int); 
1103 extern int in6_mask2len(struct in6_addr 
*, u_char 
*); 
1104 extern void in6_len2mask(struct in6_addr 
*, int); 
1105 extern int in6_control(struct socket 
*, u_long
, caddr_t
, struct ifnet 
*, 
1107 extern int in6_update_ifa(struct ifnet 
*, struct in6_aliasreq 
*, int, 
1108     struct in6_ifaddr 
**); 
1109 extern void in6_purgeaddr(struct ifaddr 
*); 
1110 extern int in6if_do_dad(struct ifnet 
*); 
1111 extern void in6_purgeif(struct ifnet 
*); 
1112 extern void in6_savemkludge(struct in6_ifaddr 
*); 
1113 extern void in6_setmaxmtu(void); 
1114 extern void in6_restoremkludge(struct in6_ifaddr 
*, struct ifnet 
*); 
1115 extern void in6_purgemkludge(struct ifnet 
*); 
1116 extern struct in6_ifaddr 
*in6ifa_ifpforlinklocal(struct ifnet 
*, int); 
1117 extern struct in6_ifaddr 
*in6ifa_ifpwithaddr(struct ifnet 
*, struct in6_addr 
*); 
1118 extern struct in6_ifaddr 
*in6ifa_prproxyaddr(struct in6_addr 
*); 
1119 extern void in6ifa_getlifetime(struct in6_ifaddr 
*, 
1120     struct in6_addrlifetime 
*, int); 
1121 extern void in6ifa_setlifetime(struct in6_ifaddr 
*, struct in6_addrlifetime 
*); 
1122 extern char *ip6_sprintf(const struct in6_addr 
*); 
1123 extern int in6_addr2scopeid(struct ifnet 
*, struct in6_addr 
*); 
1124 extern int in6_matchlen(struct in6_addr 
*, struct in6_addr 
*); 
1125 extern int in6_are_prefix_equal(struct in6_addr 
*p1
, struct in6_addr 
*p2
, 
1127 extern void in6_prefixlen2mask(struct in6_addr 
*maskp
, int len
); 
1128 extern int in6_prefix_add_ifid(int iilen
, struct in6_ifaddr 
*ia
); 
1129 extern void in6_prefix_remove_ifid(int iilen
, struct in6_ifaddr 
*ia
); 
1130 extern void in6_purgeprefix(struct ifnet 
*); 
1131 extern void in6_purgeaddrs(struct ifnet 
*); 
1132 extern uint8_t im6s_get_mode(const struct in6_multi 
*, 
1133     const struct ip6_msource 
*, uint8_t); 
1134 extern void im6f_leave(struct in6_mfilter 
*); 
1135 extern void im6f_purge(struct in6_mfilter 
*); 
1136 extern int in6_embedscope(struct in6_addr 
*, const struct sockaddr_in6 
*, 
1137     struct inpcb 
*, struct ifnet 
**, struct ip6_pktopts 
*); 
1138 extern int in6_recoverscope(struct sockaddr_in6 
*, const struct in6_addr 
*, 
1140 extern void in6_aliasreq_64_to_32(struct in6_aliasreq_64 
*, 
1141     struct in6_aliasreq_32 
*); 
1142 extern void in6_aliasreq_32_to_64(struct in6_aliasreq_32 
*, 
1143     struct in6_aliasreq_64 
*); 
1144 extern void in6_ifaddr_init(void); 
1145 extern int in6_inithead(void **, int); 
1146 extern void in6_rtqdrain(void); 
1147 extern struct radix_node 
*in6_validate(struct radix_node 
*); 
1148 extern int  in6_if2idlen(struct ifnet 
*); 
1149 extern int in6_src_ioctl(u_long
, caddr_t
); 
1150 extern void in6_multihead_lock_exclusive(void); 
1151 extern void in6_multihead_lock_shared(void); 
1152 extern void in6_multihead_lock_assert(int); 
1153 extern void in6_multihead_lock_done(void); 
1155 extern void in6_cga_init(void); 
1156 extern void in6_cga_node_lock(void); 
1157 extern void in6_cga_node_unlock(void); 
1158 extern void in6_cga_query(struct in6_cga_nodecfg 
*); 
1159 extern int in6_cga_start(const struct in6_cga_nodecfg 
*); 
1160 extern int in6_cga_stop(void); 
1161 extern ssize_t 
in6_cga_parameters_prepare(void *, size_t, 
1162     const struct in6_addr 
*, u_int8_t
, const struct in6_cga_modifier 
*); 
1163 extern int in6_cga_generate(struct in6_cga_prepare 
*, u_int8_t
, 
1165 extern int in6_getconninfo(struct socket 
*, sae_connid_t
, uint32_t *, 
1166     uint32_t *, int32_t *, user_addr_t
, socklen_t 
*, 
1167     user_addr_t
, socklen_t 
*, uint32_t *, user_addr_t
, uint32_t *); 
1168 extern void in6_ip6_to_sockaddr(const struct in6_addr 
*ip6
, u_int16_t port
, 
1169                                                                 struct sockaddr_in6 
*sin6
, u_int32_t maxlen
); 
1171 #endif /* BSD_KERNEL_PRIVATE */ 
1172 #endif /* _NETINET6_IN6_VAR_H_ */