xref: /freebsd/sys/netinet6/mld6.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
10279cfbeSBruce M Simpson /*-
2*fe267a55SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
3*fe267a55SPedro F. Giffuni  *
40279cfbeSBruce M Simpson  * Copyright (c) 2009 Bruce Simpson.
50279cfbeSBruce M Simpson  *
60279cfbeSBruce M Simpson  * Redistribution and use in source and binary forms, with or without
70279cfbeSBruce M Simpson  * modification, are permitted provided that the following conditions
80279cfbeSBruce M Simpson  * are met:
90279cfbeSBruce M Simpson  * 1. Redistributions of source code must retain the above copyright
100279cfbeSBruce M Simpson  *    notice, this list of conditions and the following disclaimer.
110279cfbeSBruce M Simpson  * 2. Redistributions in binary form must reproduce the above copyright
120279cfbeSBruce M Simpson  *    notice, this list of conditions and the following disclaimer in the
130279cfbeSBruce M Simpson  *    documentation and/or other materials provided with the distribution.
140279cfbeSBruce M Simpson  * 3. The name of the author may not be used to endorse or promote
150279cfbeSBruce M Simpson  *    products derived from this software without specific prior written
160279cfbeSBruce M Simpson  *    permission.
170279cfbeSBruce M Simpson  *
180279cfbeSBruce M Simpson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
190279cfbeSBruce M Simpson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
200279cfbeSBruce M Simpson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
210279cfbeSBruce M Simpson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
220279cfbeSBruce M Simpson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
230279cfbeSBruce M Simpson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
240279cfbeSBruce M Simpson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
250279cfbeSBruce M Simpson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
260279cfbeSBruce M Simpson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
270279cfbeSBruce M Simpson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
280279cfbeSBruce M Simpson  * SUCH DAMAGE.
290279cfbeSBruce M Simpson  */
300279cfbeSBruce M Simpson 
310279cfbeSBruce M Simpson #ifndef _NETINET6_MLD6_H_
320279cfbeSBruce M Simpson #define _NETINET6_MLD6_H_
330279cfbeSBruce M Simpson 
340279cfbeSBruce M Simpson /*
350279cfbeSBruce M Simpson  * Multicast Listener Discovery (MLD) definitions.
360279cfbeSBruce M Simpson  */
370279cfbeSBruce M Simpson 
380279cfbeSBruce M Simpson /* Minimum length of any MLD protocol message. */
390279cfbeSBruce M Simpson #define MLD_MINLEN	sizeof(struct icmp6_hdr)
400279cfbeSBruce M Simpson 
410279cfbeSBruce M Simpson /*
420279cfbeSBruce M Simpson  * MLD v2 query format.
430279cfbeSBruce M Simpson  * See <netinet/icmp6.h> for struct mld_hdr
440279cfbeSBruce M Simpson  * (MLDv1 query and host report format).
450279cfbeSBruce M Simpson  */
460279cfbeSBruce M Simpson struct mldv2_query {
470279cfbeSBruce M Simpson 	struct icmp6_hdr	mld_icmp6_hdr;	/* ICMPv6 header */
480279cfbeSBruce M Simpson 	struct in6_addr		mld_addr;	/* address being queried */
490279cfbeSBruce M Simpson 	uint8_t		mld_misc;	/* reserved/suppress/robustness   */
500279cfbeSBruce M Simpson 	uint8_t		mld_qqi;	/* querier's query interval       */
510279cfbeSBruce M Simpson 	uint16_t	mld_numsrc;	/* number of sources              */
520279cfbeSBruce M Simpson 	/* followed by 1..numsrc source addresses */
530279cfbeSBruce M Simpson } __packed;
540279cfbeSBruce M Simpson #define MLD_V2_QUERY_MINLEN		sizeof(struct mldv2_query)
550279cfbeSBruce M Simpson #define MLD_MRC_EXP(x)			((ntohs((x)) >> 12) & 0x0007)
560279cfbeSBruce M Simpson #define MLD_MRC_MANT(x)			(ntohs((x)) & 0x0fff)
570279cfbeSBruce M Simpson #define MLD_QQIC_EXP(x)			(((x) >> 4) & 0x07)
580279cfbeSBruce M Simpson #define MLD_QQIC_MANT(x)		((x) & 0x0f)
590279cfbeSBruce M Simpson #define MLD_QRESV(x)			(((x) >> 4) & 0x0f)
600279cfbeSBruce M Simpson #define MLD_SFLAG(x)			(((x) >> 3) & 0x01)
610279cfbeSBruce M Simpson #define MLD_QRV(x)			((x) & 0x07)
620279cfbeSBruce M Simpson 
630279cfbeSBruce M Simpson /*
640279cfbeSBruce M Simpson  * MLDv2 host membership report header.
650279cfbeSBruce M Simpson  * mld_type: MLDV2_LISTENER_REPORT
660279cfbeSBruce M Simpson  */
670279cfbeSBruce M Simpson struct mldv2_report {
680279cfbeSBruce M Simpson 	struct icmp6_hdr	mld_icmp6_hdr;
690279cfbeSBruce M Simpson 	/* followed by 1..numgrps records */
700279cfbeSBruce M Simpson } __packed;
710279cfbeSBruce M Simpson /* overlaid on struct icmp6_hdr. */
720279cfbeSBruce M Simpson #define mld_numrecs	mld_icmp6_hdr.icmp6_data16[1]
730279cfbeSBruce M Simpson 
740279cfbeSBruce M Simpson struct mldv2_record {
750279cfbeSBruce M Simpson 	uint8_t			mr_type;	/* record type */
760279cfbeSBruce M Simpson 	uint8_t			mr_datalen;	/* length of auxiliary data */
770279cfbeSBruce M Simpson 	uint16_t		mr_numsrc;	/* number of sources */
780279cfbeSBruce M Simpson 	struct in6_addr		mr_addr;	/* address being reported */
790279cfbeSBruce M Simpson 	/* followed by 1..numsrc source addresses */
800279cfbeSBruce M Simpson } __packed;
810279cfbeSBruce M Simpson #define MLD_V2_REPORT_MAXRECS		65535
820279cfbeSBruce M Simpson 
830279cfbeSBruce M Simpson /*
840279cfbeSBruce M Simpson  * MLDv2 report modes.
850279cfbeSBruce M Simpson  */
860279cfbeSBruce M Simpson #define MLD_DO_NOTHING			0	/* don't send a record */
870279cfbeSBruce M Simpson #define MLD_MODE_IS_INCLUDE		1	/* MODE_IN */
880279cfbeSBruce M Simpson #define MLD_MODE_IS_EXCLUDE		2	/* MODE_EX */
890279cfbeSBruce M Simpson #define MLD_CHANGE_TO_INCLUDE_MODE	3	/* TO_IN */
900279cfbeSBruce M Simpson #define MLD_CHANGE_TO_EXCLUDE_MODE	4	/* TO_EX */
910279cfbeSBruce M Simpson #define MLD_ALLOW_NEW_SOURCES		5	/* ALLOW_NEW */
920279cfbeSBruce M Simpson #define MLD_BLOCK_OLD_SOURCES		6	/* BLOCK_OLD */
930279cfbeSBruce M Simpson 
940279cfbeSBruce M Simpson /*
950279cfbeSBruce M Simpson  * MLDv2 query types.
960279cfbeSBruce M Simpson  */
970279cfbeSBruce M Simpson #define MLD_V2_GENERAL_QUERY		1
980279cfbeSBruce M Simpson #define MLD_V2_GROUP_QUERY		2
990279cfbeSBruce M Simpson #define MLD_V2_GROUP_SOURCE_QUERY	3
1000279cfbeSBruce M Simpson 
1010279cfbeSBruce M Simpson /*
1020279cfbeSBruce M Simpson  * Maximum report interval for MLDv1 host membership reports.
1030279cfbeSBruce M Simpson  */
1040279cfbeSBruce M Simpson #define MLD_V1_MAX_RI			10
1050279cfbeSBruce M Simpson 
1060279cfbeSBruce M Simpson /*
1070279cfbeSBruce M Simpson  * MLD_TIMER_SCALE denotes that the MLD code field specifies
1080279cfbeSBruce M Simpson  * time in milliseconds.
1090279cfbeSBruce M Simpson  */
1100279cfbeSBruce M Simpson #define MLD_TIMER_SCALE			1000
1110279cfbeSBruce M Simpson 
1120279cfbeSBruce M Simpson #endif /* _NETINET6_MLD6_H_ */
113