/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 2009 Bruce Simpson.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. The name of the author may not be used to endorse or promote14* products derived from this software without specific prior written15* permission.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/29#ifndef _NETINET6_MLD6_VAR_H_30#define _NETINET6_MLD6_VAR_H_3132/*33* Multicast Listener Discovery (MLD)34* implementation-specific definitions.35*/3637/*38* MLD per-group states.39*/40#define MLD_NOT_MEMBER 0 /* Can garbage collect group */41#define MLD_SILENT_MEMBER 1 /* Do not perform MLD for group */42#define MLD_REPORTING_MEMBER 2 /* MLDv1 we are reporter */43#define MLD_IDLE_MEMBER 3 /* MLDv1 we reported last */44#define MLD_LAZY_MEMBER 4 /* MLDv1 other member reporting */45#define MLD_SLEEPING_MEMBER 5 /* MLDv1 start query response */46#define MLD_AWAKENING_MEMBER 6 /* MLDv1 group timer will start */47#define MLD_G_QUERY_PENDING_MEMBER 7 /* MLDv2 group query pending */48#define MLD_SG_QUERY_PENDING_MEMBER 8 /* MLDv2 source query pending */49#define MLD_LEAVING_MEMBER 9 /* MLDv2 dying gasp (pending last */50/* retransmission of INCLUDE {}) */5152/*53* MLD version tag.54*/55#define MLD_VERSION_NONE 0 /* Invalid */56#define MLD_VERSION_1 157#define MLD_VERSION_2 2 /* Default */5859/*60* MLDv2 protocol control variables.61*/62#define MLD_RV_INIT 2 /* Robustness Variable */63#define MLD_RV_MIN 164#define MLD_RV_MAX 76566#define MLD_QI_INIT 125 /* Query Interval (s) */67#define MLD_QI_MIN 168#define MLD_QI_MAX 2556970#define MLD_QRI_INIT 10 /* Query Response Interval (s) */71#define MLD_QRI_MIN 172#define MLD_QRI_MAX 2557374#define MLD_URI_INIT 3 /* Unsolicited Report Interval (s) */75#define MLD_URI_MIN 076#define MLD_URI_MAX 107778#define MLD_MAX_GS_SOURCES 256 /* # of sources in rx GS query */79#define MLD_MAX_G_GS_PACKETS 8 /* # of packets to answer G/GS */80#define MLD_MAX_STATE_CHANGE_PACKETS 8 /* # of packets per state change */81#define MLD_MAX_RESPONSE_PACKETS 16 /* # of packets for general query */82#define MLD_MAX_RESPONSE_BURST 4 /* # of responses to send at once */83#define MLD_RESPONSE_BURST_INTERVAL (MLD_FASTHZ / 2) /* 500ms */8485/*86* MLD-specific mbuf flags.87*/88#define M_MLDV1 M_PROTO1 /* Packet is MLDv1 */89#define M_GROUPREC M_PROTO3 /* mbuf chain is a group record */9091/*92* Leading space for MLDv2 reports inside MTU.93*94* NOTE: This differs from IGMPv3 significantly. KAME IPv6 requires95* that a fully formed mbuf chain *without* the Router Alert option96* is passed to ip6_output(), however we must account for it in the97* MTU if we need to split an MLDv2 report into several packets.98*99* We now put the MLDv2 report header in the initial mbuf containing100* the IPv6 header.101*/102#define MLD_MTUSPACE (sizeof(struct ip6_hdr) + sizeof(struct mld_raopt) + \103sizeof(struct icmp6_hdr))104105/*106* Structure returned by net.inet6.mld.ifinfo.107*/108struct mld_ifinfo {109uint32_t mli_version; /* MLDv1 Host Compatibility Mode */110uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */111uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/112uint32_t mli_flags; /* MLD per-interface flags */113#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */114#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */115uint32_t mli_rv; /* MLDv2 Robustness Variable */116uint32_t mli_qi; /* MLDv2 Query Interval (s) */117uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */118uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */119};120121#ifdef _KERNEL122/*123* Per-link MLD state.124*/125struct mld_ifsoftc {126LIST_ENTRY(mld_ifsoftc) mli_link;127struct ifnet *mli_ifp; /* interface this instance belongs to */128uint32_t mli_version; /* MLDv1 Host Compatibility Mode */129uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */130uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/131uint32_t mli_flags; /* MLD per-interface flags */132uint32_t mli_rv; /* MLDv2 Robustness Variable */133uint32_t mli_qi; /* MLDv2 Query Interval (s) */134uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */135uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */136struct mbufq mli_gq; /* queue of general query responses */137};138139#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)140#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */141142/*143* Subsystem lock macros.144* The MLD lock is only taken with MLD. Currently it is system-wide.145* VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.146*/147#define MLD_LOCK_INIT() mtx_init(&mld_mtx, "mld_mtx", NULL, MTX_DEF)148#define MLD_LOCK_DESTROY() mtx_destroy(&mld_mtx)149#define MLD_LOCK() mtx_lock(&mld_mtx)150#define MLD_LOCK_ASSERT() mtx_assert(&mld_mtx, MA_OWNED)151#define MLD_UNLOCK() mtx_unlock(&mld_mtx)152#define MLD_UNLOCK_ASSERT() mtx_assert(&mld_mtx, MA_NOTOWNED)153154/*155* Per-link MLD context.156*/157#define MLD_IFINFO(ifp) \158(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->mld_ifinfo)159160struct in6_multi_head;161int mld_change_state(struct in6_multi *, const int);162struct mld_ifsoftc *163mld_domifattach(struct ifnet *);164void mld_domifdetach(struct ifnet *);165void mld_ifdetach(struct ifnet *, struct in6_multi_head *);166int mld_input(struct mbuf **, int, int);167168#define MLD_SLOWHZ 2 /* 2 slow timeouts per second */169#define MLD_FASTHZ 5 /* 5 fast timeouts per second */170171#ifdef SYSCTL_DECL172SYSCTL_DECL(_net_inet6_mld);173#endif174175#endif /* _KERNEL */176177#endif /* _NETINET6_MLD6_VAR_H_ */178179180