1c398230bSWarner Losh /*- 2*51369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*51369649SPedro F. Giffuni * 4df8bae1dSRodney W. Grimes * Copyright (c) 1988 Stephen Deering. 5df8bae1dSRodney W. Grimes * Copyright (c) 1992, 1993 6df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 7df8bae1dSRodney W. Grimes * 8df8bae1dSRodney W. Grimes * This code is derived from software contributed to Berkeley by 9df8bae1dSRodney W. Grimes * Stephen Deering of Stanford University. 10df8bae1dSRodney W. Grimes * 11df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 12df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 13df8bae1dSRodney W. Grimes * are met: 14df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 15df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 16df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 17df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 18df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 19fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 20df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 21df8bae1dSRodney W. Grimes * without specific prior written permission. 22df8bae1dSRodney W. Grimes * 23df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33df8bae1dSRodney W. Grimes * SUCH DAMAGE. 34df8bae1dSRodney W. Grimes */ 35df8bae1dSRodney W. Grimes 36707f139eSPaul Richards #ifndef _NETINET_IGMP_H_ 37707f139eSPaul Richards #define _NETINET_IGMP_H_ 38707f139eSPaul Richards 39f0068c4aSGarrett Wollman /* 40f0068c4aSGarrett Wollman * Internet Group Management Protocol (IGMP) definitions. 41f0068c4aSGarrett Wollman * 42f0068c4aSGarrett Wollman * Written by Steve Deering, Stanford, May 1988. 43f0068c4aSGarrett Wollman * 4449fa849bSBill Fenner * MULTICAST Revision: 3.5.1.2 45f0068c4aSGarrett Wollman */ 46df8bae1dSRodney W. Grimes 47346e3178SBruce M Simpson /* Minimum length of any IGMP protocol message. */ 48346e3178SBruce M Simpson #define IGMP_MINLEN 8 49346e3178SBruce M Simpson 50df8bae1dSRodney W. Grimes /* 51346e3178SBruce M Simpson * IGMPv1/v2 query and host report format. 52df8bae1dSRodney W. Grimes */ 53df8bae1dSRodney W. Grimes struct igmp { 54df8bae1dSRodney W. Grimes u_char igmp_type; /* version & type of IGMP message */ 551c5de19aSGarrett Wollman u_char igmp_code; /* subtype for routing msgs */ 56df8bae1dSRodney W. Grimes u_short igmp_cksum; /* IP-style checksum */ 57df8bae1dSRodney W. Grimes struct in_addr igmp_group; /* group address being reported */ 58df8bae1dSRodney W. Grimes }; /* (zero for queries) */ 59df8bae1dSRodney W. Grimes 60346e3178SBruce M Simpson /* 61346e3178SBruce M Simpson * IGMP v3 query format. 62346e3178SBruce M Simpson */ 6371498f30SBruce M Simpson struct igmpv3 { 6471498f30SBruce M Simpson u_char igmp_type; /* version & type of IGMP message */ 6571498f30SBruce M Simpson u_char igmp_code; /* subtype for routing msgs */ 6671498f30SBruce M Simpson u_short igmp_cksum; /* IP-style checksum */ 6771498f30SBruce M Simpson struct in_addr igmp_group; /* group address being reported */ 6871498f30SBruce M Simpson /* (zero for queries) */ 6971498f30SBruce M Simpson u_char igmp_misc; /* reserved/suppress/robustness */ 7071498f30SBruce M Simpson u_char igmp_qqi; /* querier's query interval */ 7171498f30SBruce M Simpson u_short igmp_numsrc; /* number of sources */ 7271498f30SBruce M Simpson /*struct in_addr igmp_sources[1];*/ /* source addresses */ 7371498f30SBruce M Simpson }; 74346e3178SBruce M Simpson #define IGMP_V3_QUERY_MINLEN 12 75346e3178SBruce M Simpson #define IGMP_EXP(x) (((x) >> 4) & 0x07) 76346e3178SBruce M Simpson #define IGMP_MANT(x) ((x) & 0x0f) 77346e3178SBruce M Simpson #define IGMP_QRESV(x) (((x) >> 4) & 0x0f) 78346e3178SBruce M Simpson #define IGMP_SFLAG(x) (((x) >> 3) & 0x01) 79346e3178SBruce M Simpson #define IGMP_QRV(x) ((x) & 0x07) 8071498f30SBruce M Simpson 8171498f30SBruce M Simpson struct igmp_grouprec { 8271498f30SBruce M Simpson u_char ig_type; /* record type */ 8371498f30SBruce M Simpson u_char ig_datalen; /* length of auxiliary data */ 8471498f30SBruce M Simpson u_short ig_numsrc; /* number of sources */ 8571498f30SBruce M Simpson struct in_addr ig_group; /* group address being reported */ 8671498f30SBruce M Simpson /*struct in_addr ig_sources[1];*/ /* source addresses */ 8771498f30SBruce M Simpson }; 8871498f30SBruce M Simpson #define IGMP_GRPREC_HDRLEN 8 8971498f30SBruce M Simpson 90346e3178SBruce M Simpson /* 91346e3178SBruce M Simpson * IGMPv3 host membership report header. 92346e3178SBruce M Simpson */ 93346e3178SBruce M Simpson struct igmp_report { 94346e3178SBruce M Simpson u_char ir_type; /* IGMP_v3_HOST_MEMBERSHIP_REPORT */ 95346e3178SBruce M Simpson u_char ir_rsv1; /* must be zero */ 96346e3178SBruce M Simpson u_short ir_cksum; /* checksum */ 97346e3178SBruce M Simpson u_short ir_rsv2; /* must be zero */ 98346e3178SBruce M Simpson u_short ir_numgrps; /* number of group records */ 99346e3178SBruce M Simpson /*struct igmp_grouprec ir_groups[1];*/ /* group records */ 100346e3178SBruce M Simpson }; 101346e3178SBruce M Simpson #define IGMP_V3_REPORT_MINLEN 8 102346e3178SBruce M Simpson #define IGMP_V3_REPORT_MAXRECS 65535 103df8bae1dSRodney W. Grimes 1041c5de19aSGarrett Wollman /* 1051c5de19aSGarrett Wollman * Message types, including version number. 1061c5de19aSGarrett Wollman */ 107346e3178SBruce M Simpson #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */ 108346e3178SBruce M Simpson #define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ 1091c5de19aSGarrett Wollman #define IGMP_DVMRP 0x13 /* DVMRP routing message */ 1101975dc40SBruce M Simpson #define IGMP_PIM 0x14 /* PIMv1 message (historic) */ 111346e3178SBruce M Simpson #define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ 112346e3178SBruce M Simpson #define IGMP_HOST_LEAVE_MESSAGE 0x17 /* Leave-group message */ 113346e3178SBruce M Simpson #define IGMP_MTRACE_REPLY 0x1e /* mtrace(8) reply */ 114346e3178SBruce M Simpson #define IGMP_MTRACE_QUERY 0x1f /* mtrace(8) probe */ 115346e3178SBruce M Simpson #define IGMP_v3_HOST_MEMBERSHIP_REPORT 0x22 /* Ver. 3 membership report */ 1161c5de19aSGarrett Wollman 1171c5de19aSGarrett Wollman /* 118346e3178SBruce M Simpson * IGMPv3 report modes. 1191c5de19aSGarrett Wollman */ 120346e3178SBruce M Simpson #define IGMP_DO_NOTHING 0 /* don't send a record */ 121346e3178SBruce M Simpson #define IGMP_MODE_IS_INCLUDE 1 /* MODE_IN */ 122346e3178SBruce M Simpson #define IGMP_MODE_IS_EXCLUDE 2 /* MODE_EX */ 123346e3178SBruce M Simpson #define IGMP_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */ 124346e3178SBruce M Simpson #define IGMP_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */ 125346e3178SBruce M Simpson #define IGMP_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */ 126346e3178SBruce M Simpson #define IGMP_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */ 127346e3178SBruce M Simpson 128346e3178SBruce M Simpson /* 129346e3178SBruce M Simpson * IGMPv3 query types. 130346e3178SBruce M Simpson */ 131346e3178SBruce M Simpson #define IGMP_V3_GENERAL_QUERY 1 132346e3178SBruce M Simpson #define IGMP_V3_GROUP_QUERY 2 133346e3178SBruce M Simpson #define IGMP_V3_GROUP_SOURCE_QUERY 3 134346e3178SBruce M Simpson 135346e3178SBruce M Simpson /* 136346e3178SBruce M Simpson * Maximum report interval for IGMP v1/v2 host membership reports [RFC 1112] 137346e3178SBruce M Simpson */ 138346e3178SBruce M Simpson #define IGMP_V1V2_MAX_RI 10 139346e3178SBruce M Simpson #define IGMP_MAX_HOST_REPORT_DELAY IGMP_V1V2_MAX_RI 140346e3178SBruce M Simpson 141346e3178SBruce M Simpson /* 142346e3178SBruce M Simpson * IGMP_TIMER_SCALE denotes that the igmp code field specifies 143346e3178SBruce M Simpson * time in tenths of a second. 144346e3178SBruce M Simpson */ 145346e3178SBruce M Simpson #define IGMP_TIMER_SCALE 10 146f0068c4aSGarrett Wollman 147f0068c4aSGarrett Wollman #endif /* _NETINET_IGMP_H_ */ 148