1139826Simp/*- 2191672Sbms * Copyright (c) 2009 Bruce Simpson. 353541Sshin * 453541Sshin * Redistribution and use in source and binary forms, with or without 553541Sshin * modification, are permitted provided that the following conditions 653541Sshin * are met: 753541Sshin * 1. Redistributions of source code must retain the above copyright 853541Sshin * notice, this list of conditions and the following disclaimer. 953541Sshin * 2. Redistributions in binary form must reproduce the above copyright 1053541Sshin * notice, this list of conditions and the following disclaimer in the 1153541Sshin * documentation and/or other materials provided with the distribution. 12191672Sbms * 3. The name of the author may not be used to endorse or promote 13191672Sbms * products derived from this software without specific prior written 14191672Sbms * permission. 1553541Sshin * 16191672Sbms * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1753541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1853541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19191672Sbms * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2053541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2153541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2253541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2353541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2453541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2553541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2653541Sshin * SUCH DAMAGE. 27174510Sobrien * 28174510Sobrien * $FreeBSD$ 2953541Sshin */ 3053541Sshin#ifndef _NETINET6_MLD6_VAR_H_ 3162587Sitojun#define _NETINET6_MLD6_VAR_H_ 3253541Sshin 33191672Sbms/* 34191672Sbms * Multicast Listener Discovery (MLD) 35191672Sbms * implementation-specific definitions. 36191672Sbms */ 37191672Sbms 3853541Sshin#ifdef _KERNEL 3953541Sshin 40191672Sbms/* 41191672Sbms * Per-link MLD state. 42191672Sbms */ 43191672Sbmsstruct mld_ifinfo { 44191672Sbms LIST_ENTRY(mld_ifinfo) mli_link; 45191672Sbms struct ifnet *mli_ifp; /* interface this instance belongs to */ 46191672Sbms uint32_t mli_version; /* MLDv1 Host Compatibility Mode */ 47191672Sbms uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */ 48191672Sbms uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/ 49191672Sbms uint32_t mli_flags; /* MLD per-interface flags */ 50191672Sbms uint32_t mli_rv; /* MLDv2 Robustness Variable */ 51191672Sbms uint32_t mli_qi; /* MLDv2 Query Interval (s) */ 52191672Sbms uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */ 53191672Sbms uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */ 54191672Sbms SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */ 55191672Sbms struct ifqueue mli_gq; /* queue of general query responses */ 56191672Sbms}; 57191672Sbms#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */ 58200871Sbms#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */ 5953541Sshin 60191672Sbms#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1) 61191672Sbms#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */ 62191672Sbms 6353541Sshin/* 64191672Sbms * MLD per-group states. 6553541Sshin */ 66191672Sbms#define MLD_NOT_MEMBER 0 /* Can garbage collect group */ 67191672Sbms#define MLD_SILENT_MEMBER 1 /* Do not perform MLD for group */ 68191672Sbms#define MLD_REPORTING_MEMBER 2 /* MLDv1 we are reporter */ 69191672Sbms#define MLD_IDLE_MEMBER 3 /* MLDv1 we reported last */ 70191672Sbms#define MLD_LAZY_MEMBER 4 /* MLDv1 other member reporting */ 71191672Sbms#define MLD_SLEEPING_MEMBER 5 /* MLDv1 start query response */ 72191672Sbms#define MLD_AWAKENING_MEMBER 6 /* MLDv1 group timer will start */ 73191672Sbms#define MLD_G_QUERY_PENDING_MEMBER 7 /* MLDv2 group query pending */ 74191672Sbms#define MLD_SG_QUERY_PENDING_MEMBER 8 /* MLDv2 source query pending */ 75191672Sbms#define MLD_LEAVING_MEMBER 9 /* MLDv2 dying gasp (pending last */ 76191672Sbms /* retransmission of INCLUDE {}) */ 7753541Sshin 78191672Sbms/* 79191672Sbms * MLD version tag. 80191672Sbms */ 81191672Sbms#define MLD_VERSION_NONE 0 /* Invalid */ 82191672Sbms#define MLD_VERSION_1 1 83191672Sbms#define MLD_VERSION_2 2 /* Default */ 84191672Sbms 85191672Sbms/* 86191672Sbms * MLDv2 protocol control variables. 87191672Sbms */ 88191672Sbms#define MLD_RV_INIT 2 /* Robustness Variable */ 89191672Sbms#define MLD_RV_MIN 1 90191672Sbms#define MLD_RV_MAX 7 91191672Sbms 92191672Sbms#define MLD_QI_INIT 125 /* Query Interval (s) */ 93191672Sbms#define MLD_QI_MIN 1 94191672Sbms#define MLD_QI_MAX 255 95191672Sbms 96191672Sbms#define MLD_QRI_INIT 10 /* Query Response Interval (s) */ 97191672Sbms#define MLD_QRI_MIN 1 98191672Sbms#define MLD_QRI_MAX 255 99191672Sbms 100191672Sbms#define MLD_URI_INIT 3 /* Unsolicited Report Interval (s) */ 101191672Sbms#define MLD_URI_MIN 0 102191672Sbms#define MLD_URI_MAX 10 103191672Sbms 104191672Sbms#define MLD_MAX_GS_SOURCES 256 /* # of sources in rx GS query */ 105191672Sbms#define MLD_MAX_G_GS_PACKETS 8 /* # of packets to answer G/GS */ 106191672Sbms#define MLD_MAX_STATE_CHANGE_PACKETS 8 /* # of packets per state change */ 107191672Sbms#define MLD_MAX_RESPONSE_PACKETS 16 /* # of packets for general query */ 108191672Sbms#define MLD_MAX_RESPONSE_BURST 4 /* # of responses to send at once */ 109191672Sbms#define MLD_RESPONSE_BURST_INTERVAL (PR_FASTHZ / 2) /* 500ms */ 110191672Sbms 111191672Sbms/* 112191672Sbms * MLD-specific mbuf flags. 113191672Sbms */ 114191672Sbms#define M_MLDV1 M_PROTO1 /* Packet is MLDv1 */ 115191672Sbms#define M_GROUPREC M_PROTO3 /* mbuf chain is a group record */ 116191672Sbms 117191672Sbms/* 118191672Sbms * Leading space for MLDv2 reports inside MTU. 119191672Sbms * 120191672Sbms * NOTE: This differs from IGMPv3 significantly. KAME IPv6 requires 121191672Sbms * that a fully formed mbuf chain *without* the Router Alert option 122191672Sbms * is passed to ip6_output(), however we must account for it in the 123191672Sbms * MTU if we need to split an MLDv2 report into several packets. 124191672Sbms * 125191672Sbms * We now put the MLDv2 report header in the initial mbuf containing 126191672Sbms * the IPv6 header. 127191672Sbms */ 128191672Sbms#define MLD_MTUSPACE (sizeof(struct ip6_hdr) + sizeof(struct mld_raopt) + \ 129191672Sbms sizeof(struct icmp6_hdr)) 130191672Sbms 131191672Sbms/* 132191672Sbms * Subsystem lock macros. 133191672Sbms * The MLD lock is only taken with MLD. Currently it is system-wide. 134191672Sbms * VIMAGE: The lock could be pushed to per-VIMAGE granularity in future. 135191672Sbms */ 136191672Sbms#define MLD_LOCK_INIT() mtx_init(&mld_mtx, "mld_mtx", NULL, MTX_DEF) 137191672Sbms#define MLD_LOCK_DESTROY() mtx_destroy(&mld_mtx) 138191672Sbms#define MLD_LOCK() mtx_lock(&mld_mtx) 139191672Sbms#define MLD_LOCK_ASSERT() mtx_assert(&mld_mtx, MA_OWNED) 140191672Sbms#define MLD_UNLOCK() mtx_unlock(&mld_mtx) 141191672Sbms#define MLD_UNLOCK_ASSERT() mtx_assert(&mld_mtx, MA_NOTOWNED) 142191672Sbms 143191672Sbms/* 144191672Sbms * Per-link MLD context. 145191672Sbms */ 146191672Sbms#define MLD_IFINFO(ifp) \ 147191672Sbms (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->mld_ifinfo) 148191672Sbms 149191672Sbmsint mld_change_state(struct in6_multi *, const int); 150191672Sbmsstruct mld_ifinfo * 151191672Sbms mld_domifattach(struct ifnet *); 152191672Sbmsvoid mld_domifdetach(struct ifnet *); 153191672Sbmsvoid mld_fasttimo(void); 154191672Sbmsvoid mld_ifdetach(struct ifnet *); 155191672Sbmsint mld_input(struct mbuf *, int, int); 156191672Sbmsvoid mld_slowtimo(void); 157191672Sbms 158191672Sbms#ifdef SYSCTL_DECL 159191672SbmsSYSCTL_DECL(_net_inet6_mld); 160191672Sbms#endif 161191672Sbms 16253541Sshin#endif /* _KERNEL */ 16353541Sshin 16453541Sshin#endif /* _NETINET6_MLD6_VAR_H_ */ 165