1*4f1223e8SApple OSS Distributions /* 2*4f1223e8SApple OSS Distributions * Copyright (c) 2000-2020 Apple Inc. All rights reserved. 3*4f1223e8SApple OSS Distributions * 4*4f1223e8SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*4f1223e8SApple OSS Distributions * 6*4f1223e8SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*4f1223e8SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*4f1223e8SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*4f1223e8SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*4f1223e8SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*4f1223e8SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*4f1223e8SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*4f1223e8SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*4f1223e8SApple OSS Distributions * 15*4f1223e8SApple OSS Distributions * Please obtain a copy of the License at 16*4f1223e8SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*4f1223e8SApple OSS Distributions * 18*4f1223e8SApple OSS Distributions * The Original Code and all software distributed under the License are 19*4f1223e8SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*4f1223e8SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*4f1223e8SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*4f1223e8SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*4f1223e8SApple OSS Distributions * Please see the License for the specific language governing rights and 24*4f1223e8SApple OSS Distributions * limitations under the License. 25*4f1223e8SApple OSS Distributions * 26*4f1223e8SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*4f1223e8SApple OSS Distributions */ 28*4f1223e8SApple OSS Distributions 29*4f1223e8SApple OSS Distributions /* $FreeBSD: src/sys/netinet6/mld6_var.h,v 1.1.2.1 2000/07/15 07:14:36 kris Exp $ */ 30*4f1223e8SApple OSS Distributions /* $KAME: mld6_var.h,v 1.4 2000/03/25 07:23:54 sumikawa Exp $ */ 31*4f1223e8SApple OSS Distributions 32*4f1223e8SApple OSS Distributions /* 33*4f1223e8SApple OSS Distributions * Copyright (C) 1998 WIDE Project. 34*4f1223e8SApple OSS Distributions * All rights reserved. 35*4f1223e8SApple OSS Distributions * 36*4f1223e8SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 37*4f1223e8SApple OSS Distributions * modification, are permitted provided that the following conditions 38*4f1223e8SApple OSS Distributions * are met: 39*4f1223e8SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 40*4f1223e8SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 41*4f1223e8SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 42*4f1223e8SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 43*4f1223e8SApple OSS Distributions * documentation and/or other materials provided with the distribution. 44*4f1223e8SApple OSS Distributions * 3. Neither the name of the project nor the names of its contributors 45*4f1223e8SApple OSS Distributions * may be used to endorse or promote products derived from this software 46*4f1223e8SApple OSS Distributions * without specific prior written permission. 47*4f1223e8SApple OSS Distributions * 48*4f1223e8SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 49*4f1223e8SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 50*4f1223e8SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 51*4f1223e8SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 52*4f1223e8SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53*4f1223e8SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54*4f1223e8SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55*4f1223e8SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56*4f1223e8SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57*4f1223e8SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58*4f1223e8SApple OSS Distributions * SUCH DAMAGE. 59*4f1223e8SApple OSS Distributions */ 60*4f1223e8SApple OSS Distributions 61*4f1223e8SApple OSS Distributions #ifndef _NETINET6_MLD6_VAR_H_ 62*4f1223e8SApple OSS Distributions #define _NETINET6_MLD6_VAR_H_ 63*4f1223e8SApple OSS Distributions #include <sys/appleapiopts.h> 64*4f1223e8SApple OSS Distributions 65*4f1223e8SApple OSS Distributions /* 66*4f1223e8SApple OSS Distributions * Multicast Listener Discovery (MLD) 67*4f1223e8SApple OSS Distributions * implementation-specific definitions. 68*4f1223e8SApple OSS Distributions */ 69*4f1223e8SApple OSS Distributions 70*4f1223e8SApple OSS Distributions #ifdef PRIVATE 71*4f1223e8SApple OSS Distributions /* 72*4f1223e8SApple OSS Distributions * Per-link MLD state. 73*4f1223e8SApple OSS Distributions */ 74*4f1223e8SApple OSS Distributions #ifndef XNU_KERNEL_PRIVATE 75*4f1223e8SApple OSS Distributions struct mld_ifinfo { 76*4f1223e8SApple OSS Distributions #else 77*4f1223e8SApple OSS Distributions struct mld_ifinfo_u { 78*4f1223e8SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */ 79*4f1223e8SApple OSS Distributions uint32_t mli_ifindex; /* interface this instance belongs to */ 80*4f1223e8SApple OSS Distributions uint32_t mli_version; /* MLDv1 Host Compatibility Mode */ 81*4f1223e8SApple OSS Distributions uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */ 82*4f1223e8SApple OSS Distributions uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/ 83*4f1223e8SApple OSS Distributions uint32_t mli_flags; /* MLD per-interface flags */ 84*4f1223e8SApple OSS Distributions uint32_t mli_rv; /* MLDv2 Robustness Variable */ 85*4f1223e8SApple OSS Distributions uint32_t mli_qi; /* MLDv2 Query Interval (s) */ 86*4f1223e8SApple OSS Distributions uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */ 87*4f1223e8SApple OSS Distributions uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */ 88*4f1223e8SApple OSS Distributions uint32_t _pad; 89*4f1223e8SApple OSS Distributions }; 90*4f1223e8SApple OSS Distributions 91*4f1223e8SApple OSS Distributions #define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */ 92*4f1223e8SApple OSS Distributions #define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */ 93*4f1223e8SApple OSS Distributions #define MLIF_PROCESSED 0x00000004 /* Entry has been processed and can be skipped */ 94*4f1223e8SApple OSS Distributions 95*4f1223e8SApple OSS Distributions /* 96*4f1223e8SApple OSS Distributions * MLD version tag. 97*4f1223e8SApple OSS Distributions */ 98*4f1223e8SApple OSS Distributions #define MLD_VERSION_NONE 0 /* Invalid */ 99*4f1223e8SApple OSS Distributions #define MLD_VERSION_1 1 100*4f1223e8SApple OSS Distributions #define MLD_VERSION_2 2 /* Default */ 101*4f1223e8SApple OSS Distributions #endif /* PRIVATE */ 102*4f1223e8SApple OSS Distributions 103*4f1223e8SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 104*4f1223e8SApple OSS Distributions #include <sys/syslog.h> 105*4f1223e8SApple OSS Distributions 106*4f1223e8SApple OSS Distributions #define MLD_DEBUG 1 107*4f1223e8SApple OSS Distributions #ifdef MLD_DEBUG 108*4f1223e8SApple OSS Distributions extern int mld_debug; 109*4f1223e8SApple OSS Distributions #define MLD_PRINTF(x) do { if (mld_debug) printf x; } while (0) 110*4f1223e8SApple OSS Distributions #else 111*4f1223e8SApple OSS Distributions #define MLD_PRINTF(x) 112*4f1223e8SApple OSS Distributions #endif 113*4f1223e8SApple OSS Distributions 114*4f1223e8SApple OSS Distributions #define MLD_RANDOM_DELAY(X) (RandomULong() % (X) + 1) 115*4f1223e8SApple OSS Distributions #define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */ 116*4f1223e8SApple OSS Distributions 117*4f1223e8SApple OSS Distributions /* 118*4f1223e8SApple OSS Distributions * MLD per-group states. 119*4f1223e8SApple OSS Distributions */ 120*4f1223e8SApple OSS Distributions #define MLD_NOT_MEMBER 0 /* Can garbage collect group */ 121*4f1223e8SApple OSS Distributions #define MLD_SILENT_MEMBER 1 /* Do not perform MLD for group */ 122*4f1223e8SApple OSS Distributions #define MLD_REPORTING_MEMBER 2 /* MLDv1 we are reporter */ 123*4f1223e8SApple OSS Distributions #define MLD_IDLE_MEMBER 3 /* MLDv1 we reported last */ 124*4f1223e8SApple OSS Distributions #define MLD_LAZY_MEMBER 4 /* MLDv1 other member reporting */ 125*4f1223e8SApple OSS Distributions #define MLD_SLEEPING_MEMBER 5 /* MLDv1 start query response */ 126*4f1223e8SApple OSS Distributions #define MLD_AWAKENING_MEMBER 6 /* MLDv1 group timer will start */ 127*4f1223e8SApple OSS Distributions #define MLD_G_QUERY_PENDING_MEMBER 7 /* MLDv2 group query pending */ 128*4f1223e8SApple OSS Distributions #define MLD_SG_QUERY_PENDING_MEMBER 8 /* MLDv2 source query pending */ 129*4f1223e8SApple OSS Distributions #define MLD_LEAVING_MEMBER 9 /* MLDv2 dying gasp (pending last */ 130*4f1223e8SApple OSS Distributions /* retransmission of INCLUDE {}) */ 131*4f1223e8SApple OSS Distributions /* 132*4f1223e8SApple OSS Distributions * MLDv2 protocol control variables. 133*4f1223e8SApple OSS Distributions */ 134*4f1223e8SApple OSS Distributions #define MLD_RV_INIT 2 /* Robustness Variable */ 135*4f1223e8SApple OSS Distributions #define MLD_RV_MIN 1 136*4f1223e8SApple OSS Distributions #define MLD_RV_MAX 7 137*4f1223e8SApple OSS Distributions 138*4f1223e8SApple OSS Distributions #define MLD_QI_INIT 125 /* Query Interval (s) */ 139*4f1223e8SApple OSS Distributions #define MLD_QI_MIN 1 140*4f1223e8SApple OSS Distributions #define MLD_QI_MAX 255 141*4f1223e8SApple OSS Distributions 142*4f1223e8SApple OSS Distributions #define MLD_QRI_INIT 10 /* Query Response Interval (s) */ 143*4f1223e8SApple OSS Distributions #define MLD_QRI_MIN 1 144*4f1223e8SApple OSS Distributions #define MLD_QRI_MAX 255 145*4f1223e8SApple OSS Distributions 146*4f1223e8SApple OSS Distributions #define MLD_URI_INIT 3 /* Unsolicited Report Interval (s) */ 147*4f1223e8SApple OSS Distributions #define MLD_URI_MIN 0 148*4f1223e8SApple OSS Distributions #define MLD_URI_MAX 10 149*4f1223e8SApple OSS Distributions 150*4f1223e8SApple OSS Distributions #define MLD_MAX_GS_SOURCES 256 /* # of sources in rx GS query */ 151*4f1223e8SApple OSS Distributions #define MLD_MAX_G_GS_PACKETS 8 /* # of packets to answer G/GS */ 152*4f1223e8SApple OSS Distributions #define MLD_MAX_STATE_CHANGE_PACKETS 8 /* # of packets per state change */ 153*4f1223e8SApple OSS Distributions #define MLD_MAX_RESPONSE_PACKETS 16 /* # of packets for general query */ 154*4f1223e8SApple OSS Distributions #define MLD_MAX_RESPONSE_BURST 4 /* # of responses to send at once */ 155*4f1223e8SApple OSS Distributions #define MLD_RESPONSE_BURST_INTERVAL 1 /* 1 second */ 156*4f1223e8SApple OSS Distributions 157*4f1223e8SApple OSS Distributions /* 158*4f1223e8SApple OSS Distributions * MLD-specific mbuf flags. 159*4f1223e8SApple OSS Distributions */ 160*4f1223e8SApple OSS Distributions #define M_MLDV1 M_PROTO1 /* Packet is MLDv1 */ 161*4f1223e8SApple OSS Distributions #define M_GROUPREC M_PROTO3 /* mbuf chain is a group record */ 162*4f1223e8SApple OSS Distributions 163*4f1223e8SApple OSS Distributions /* 164*4f1223e8SApple OSS Distributions * Leading space for MLDv2 reports inside MTU. 165*4f1223e8SApple OSS Distributions * 166*4f1223e8SApple OSS Distributions * NOTE: This differs from IGMPv3 significantly. KAME IPv6 requires 167*4f1223e8SApple OSS Distributions * that a fully formed mbuf chain *without* the Router Alert option 168*4f1223e8SApple OSS Distributions * is passed to ip6_output(), however we must account for it in the 169*4f1223e8SApple OSS Distributions * MTU if we need to split an MLDv2 report into several packets. 170*4f1223e8SApple OSS Distributions * 171*4f1223e8SApple OSS Distributions * We now put the MLDv2 report header in the initial mbuf containing 172*4f1223e8SApple OSS Distributions * the IPv6 header. 173*4f1223e8SApple OSS Distributions */ 174*4f1223e8SApple OSS Distributions #define MLD_MTUSPACE (sizeof(struct ip6_hdr) + sizeof(struct mld_raopt) + \ 175*4f1223e8SApple OSS Distributions sizeof(struct icmp6_hdr)) 176*4f1223e8SApple OSS Distributions 177*4f1223e8SApple OSS Distributions struct mld_ifinfo { 178*4f1223e8SApple OSS Distributions decl_lck_mtx_data(, mli_lock); 179*4f1223e8SApple OSS Distributions uint32_t mli_refcnt; /* reference count */ 180*4f1223e8SApple OSS Distributions uint32_t mli_debug; /* see ifa_debug flags */ 181*4f1223e8SApple OSS Distributions LIST_ENTRY(mld_ifinfo) mli_link; 182*4f1223e8SApple OSS Distributions struct ifnet *mli_ifp; /* interface this instance belongs to */ 183*4f1223e8SApple OSS Distributions uint32_t mli_version; /* MLDv1 Host Compatibility Mode */ 184*4f1223e8SApple OSS Distributions uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */ 185*4f1223e8SApple OSS Distributions uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/ 186*4f1223e8SApple OSS Distributions uint32_t mli_flags; /* MLD per-interface flags */ 187*4f1223e8SApple OSS Distributions uint32_t mli_rv; /* MLDv2 Robustness Variable */ 188*4f1223e8SApple OSS Distributions uint32_t mli_qi; /* MLDv2 Query Interval (s) */ 189*4f1223e8SApple OSS Distributions uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */ 190*4f1223e8SApple OSS Distributions uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */ 191*4f1223e8SApple OSS Distributions SLIST_HEAD(, in6_multi) mli_relinmhead; /* released groups */ 192*4f1223e8SApple OSS Distributions struct ifqueue mli_gq; /* queue of general query responses */ 193*4f1223e8SApple OSS Distributions struct ifqueue mli_v1q; /* MLDv1 message queue */ 194*4f1223e8SApple OSS Distributions }; 195*4f1223e8SApple OSS Distributions 196*4f1223e8SApple OSS Distributions #define MLI_LOCK_ASSERT_HELD(_mli) \ 197*4f1223e8SApple OSS Distributions LCK_MTX_ASSERT(&(_mli)->mli_lock, LCK_MTX_ASSERT_OWNED) 198*4f1223e8SApple OSS Distributions 199*4f1223e8SApple OSS Distributions #define MLI_LOCK_ASSERT_NOTHELD(_mli) \ 200*4f1223e8SApple OSS Distributions LCK_MTX_ASSERT(&(_mli)->mli_lock, LCK_MTX_ASSERT_NOTOWNED) 201*4f1223e8SApple OSS Distributions 202*4f1223e8SApple OSS Distributions #define MLI_LOCK(_mli) \ 203*4f1223e8SApple OSS Distributions lck_mtx_lock(&(_mli)->mli_lock) 204*4f1223e8SApple OSS Distributions 205*4f1223e8SApple OSS Distributions #define MLI_LOCK_SPIN(_mli) \ 206*4f1223e8SApple OSS Distributions lck_mtx_lock_spin(&(_mli)->mli_lock) 207*4f1223e8SApple OSS Distributions 208*4f1223e8SApple OSS Distributions #define MLI_CONVERT_LOCK(_mli) do { \ 209*4f1223e8SApple OSS Distributions MLI_LOCK_ASSERT_HELD(_mli); \ 210*4f1223e8SApple OSS Distributions lck_mtx_convert_spin(&(_mli)->mli_lock); \ 211*4f1223e8SApple OSS Distributions } while (0) 212*4f1223e8SApple OSS Distributions 213*4f1223e8SApple OSS Distributions #define MLI_UNLOCK(_mli) \ 214*4f1223e8SApple OSS Distributions lck_mtx_unlock(&(_mli)->mli_lock) 215*4f1223e8SApple OSS Distributions 216*4f1223e8SApple OSS Distributions #define MLI_ADDREF(_mli) \ 217*4f1223e8SApple OSS Distributions mli_addref(_mli, 0) 218*4f1223e8SApple OSS Distributions 219*4f1223e8SApple OSS Distributions #define MLI_ADDREF_LOCKED(_mli) \ 220*4f1223e8SApple OSS Distributions mli_addref(_mli, 1) 221*4f1223e8SApple OSS Distributions 222*4f1223e8SApple OSS Distributions #define MLI_REMREF(_mli) \ 223*4f1223e8SApple OSS Distributions mli_remref(_mli) 224*4f1223e8SApple OSS Distributions 225*4f1223e8SApple OSS Distributions /* 226*4f1223e8SApple OSS Distributions * Per-link MLD context. 227*4f1223e8SApple OSS Distributions */ 228*4f1223e8SApple OSS Distributions #define MLD_IFINFO(ifp) ((ifp)->if_mli) 229*4f1223e8SApple OSS Distributions 230*4f1223e8SApple OSS Distributions /* 231*4f1223e8SApple OSS Distributions * MLD timer schedule parameters 232*4f1223e8SApple OSS Distributions */ 233*4f1223e8SApple OSS Distributions struct mld_tparams { 234*4f1223e8SApple OSS Distributions int qpt; /* querier_present_timers_running6 */ 235*4f1223e8SApple OSS Distributions int it; /* interface_timers_running6 */ 236*4f1223e8SApple OSS Distributions int cst; /* current_state_timers_running6 */ 237*4f1223e8SApple OSS Distributions int sct; /* state_change_timers_running6 */ 238*4f1223e8SApple OSS Distributions bool fast; /* fast timer */ 239*4f1223e8SApple OSS Distributions }; 240*4f1223e8SApple OSS Distributions 241*4f1223e8SApple OSS Distributions extern int mld_change_state(struct in6_multi *, struct mld_tparams *, 242*4f1223e8SApple OSS Distributions const int); 243*4f1223e8SApple OSS Distributions extern struct mld_ifinfo *mld_domifattach(struct ifnet *, zalloc_flags_t); 244*4f1223e8SApple OSS Distributions extern void mld_domifreattach(struct mld_ifinfo *); 245*4f1223e8SApple OSS Distributions extern void mld_domifdetach(struct ifnet *); 246*4f1223e8SApple OSS Distributions extern void mld_fasttimo(void); 247*4f1223e8SApple OSS Distributions extern void mld_ifdetach(struct ifnet *); 248*4f1223e8SApple OSS Distributions extern int mld_input(struct mbuf *, int, int); 249*4f1223e8SApple OSS Distributions extern void mld_init(void); 250*4f1223e8SApple OSS Distributions extern void mld_set_timeout(struct mld_tparams *); 251*4f1223e8SApple OSS Distributions extern void mld_set_fast_timeout(struct mld_tparams *); 252*4f1223e8SApple OSS Distributions extern void mli_addref(struct mld_ifinfo *, int); 253*4f1223e8SApple OSS Distributions extern void mli_remref(struct mld_ifinfo *); 254*4f1223e8SApple OSS Distributions __private_extern__ void mld6_initsilent(struct ifnet *, struct mld_ifinfo *); 255*4f1223e8SApple OSS Distributions 256*4f1223e8SApple OSS Distributions #ifdef SYSCTL_DECL 257*4f1223e8SApple OSS Distributions SYSCTL_DECL(_net_inet6_mld); 258*4f1223e8SApple OSS Distributions #endif 259*4f1223e8SApple OSS Distributions 260*4f1223e8SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 261*4f1223e8SApple OSS Distributions #endif /* _NETINET6_MLD6_VAR_H_ */ 262