igmp.h revision 267654
1119418Sobrien/*-
291398Stmm * Copyright (c) 1988 Stephen Deering.
3108832Stmm * Copyright (c) 1992, 1993
491398Stmm *	The Regents of the University of California.  All rights reserved.
591398Stmm *
691398Stmm * This code is derived from software contributed to Berkeley by
791398Stmm * Stephen Deering of Stanford University.
891398Stmm *
991398Stmm * Redistribution and use in source and binary forms, with or without
1091398Stmm * modification, are permitted provided that the following conditions
1191398Stmm * are met:
1291398Stmm * 1. Redistributions of source code must retain the above copyright
1391398Stmm *    notice, this list of conditions and the following disclaimer.
1491398Stmm * 2. Redistributions in binary form must reproduce the above copyright
1591398Stmm *    notice, this list of conditions and the following disclaimer in the
1691398Stmm *    documentation and/or other materials provided with the distribution.
1791398Stmm * 4. Neither the name of the University nor the names of its contributors
1891398Stmm *    may be used to endorse or promote products derived from this software
1991398Stmm *    without specific prior written permission.
2091398Stmm *
2191398Stmm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2291398Stmm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2391398Stmm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2491398Stmm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2591398Stmm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2691398Stmm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2799726Sbenno * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2891398Stmm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2991398Stmm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30119418Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31119418Sobrien * SUCH DAMAGE.
32119418Sobrien *
3391398Stmm *	@(#)igmp.h	8.1 (Berkeley) 6/10/93
3491398Stmm * $FreeBSD: releng/9.3/sys/netinet/igmp.h 193938 2009-06-10 18:12:15Z imp $
3591398Stmm */
3691398Stmm
37115030Stmm#ifndef _NETINET_IGMP_H_
3891398Stmm#define _NETINET_IGMP_H_
39115030Stmm
4091398Stmm/*
41148368Smarius * Internet Group Management Protocol (IGMP) definitions.
42148368Smarius *
43148368Smarius * Written by Steve Deering, Stanford, May 1988.
44148368Smarius *
4591398Stmm * MULTICAST Revision: 3.5.1.2
4691398Stmm */
4791398Stmm
4891398Stmm/* Minimum length of any IGMP protocol message. */
4995533Smike#define IGMP_MINLEN			8
5091398Stmm
5191398Stmm/*
5291398Stmm * IGMPv1/v2 query and host report format.
53130026Sphk */
5491398Stmmstruct igmp {
5591398Stmm	u_char		igmp_type;	/* version & type of IGMP message  */
5691398Stmm	u_char		igmp_code;	/* subtype for routing msgs        */
57105982Stmm	u_short		igmp_cksum;	/* IP-style checksum               */
5891398Stmm	struct in_addr	igmp_group;	/* group address being reported    */
5991398Stmm};					/*  (zero for queries)             */
6091398Stmm
6191398Stmm/*
6291398Stmm * IGMP v3 query format.
63147256Sbrooks */
6491398Stmmstruct igmpv3 {
6591398Stmm	u_char		igmp_type;	/* version & type of IGMP message  */
6691398Stmm	u_char		igmp_code;	/* subtype for routing msgs        */
6791398Stmm	u_short		igmp_cksum;	/* IP-style checksum               */
6891398Stmm	struct in_addr	igmp_group;	/* group address being reported    */
6991398Stmm					/*  (zero for queries)             */
70119355Simp	u_char		igmp_misc;	/* reserved/suppress/robustness    */
71119355Simp	u_char		igmp_qqi;	/* querier's query interval        */
7291398Stmm	u_short		igmp_numsrc;	/* number of sources               */
7391398Stmm	/*struct in_addr	igmp_sources[1];*/ /* source addresses */
7491398Stmm};
7592739Salfred#define IGMP_V3_QUERY_MINLEN		12
7692739Salfred#define IGMP_EXP(x)			(((x) >> 4) & 0x07)
7792739Salfred#define IGMP_MANT(x)			((x) & 0x0f)
7892739Salfred#define IGMP_QRESV(x)			(((x) >> 4) & 0x0f)
79108832Stmm#define IGMP_SFLAG(x)			(((x) >> 3) & 0x01)
80108832Stmm#define IGMP_QRV(x)			((x) & 0x07)
8192739Salfred
8292739Salfredstruct igmp_grouprec {
8392739Salfred	u_char		ig_type;	/* record type */
8492739Salfred	u_char		ig_datalen;	/* length of auxiliary data */
8592739Salfred	u_short		ig_numsrc;	/* number of sources */
8692739Salfred	struct in_addr	ig_group;	/* group address being reported */
87108832Stmm	/*struct in_addr	ig_sources[1];*/ /* source addresses */
8892739Salfred};
8992739Salfred#define IGMP_GRPREC_HDRLEN		8
9092739Salfred
9192739Salfred/*
9292739Salfred * IGMPv3 host membership report header.
9392739Salfred */
9492739Salfredstruct igmp_report {
9592739Salfred	u_char		ir_type;	/* IGMP_v3_HOST_MEMBERSHIP_REPORT */
9692739Salfred	u_char		ir_rsv1;	/* must be zero */
9792739Salfred	u_short		ir_cksum;	/* checksum */
9891398Stmm	u_short		ir_rsv2;	/* must be zero */
9992739Salfred	u_short		ir_numgrps;	/* number of group records */
10092739Salfred	/*struct	igmp_grouprec ir_groups[1];*/	/* group records */
10192739Salfred};
102148368Smarius#define IGMP_V3_REPORT_MINLEN		8
10393045Stmm#define IGMP_V3_REPORT_MAXRECS		65535
104100587Sjake
10592739Salfred/*
10691398Stmm * Message types, including version number.
10792739Salfred */
10891398Stmm#define IGMP_HOST_MEMBERSHIP_QUERY	0x11	/* membership query         */
10991398Stmm#define IGMP_v1_HOST_MEMBERSHIP_REPORT	0x12	/* Ver. 1 membership report */
11091398Stmm#define IGMP_DVMRP			0x13	/* DVMRP routing message    */
11191398Stmm#define IGMP_PIM			0x14	/* PIMv1 message (historic) */
11291398Stmm#define IGMP_v2_HOST_MEMBERSHIP_REPORT	0x16	/* Ver. 2 membership report */
11391398Stmm#define IGMP_HOST_LEAVE_MESSAGE		0x17	/* Leave-group message     */
11491398Stmm#define IGMP_MTRACE_REPLY		0x1e	/* mtrace(8) reply */
11591398Stmm#define IGMP_MTRACE_QUERY		0x1f	/* mtrace(8) probe */
11691398Stmm#define IGMP_v3_HOST_MEMBERSHIP_REPORT	0x22	/* Ver. 3 membership report */
11791398Stmm
11891398Stmm/*
119115030Stmm * IGMPv3 report modes.
12091398Stmm */
12191398Stmm#define IGMP_DO_NOTHING			0	/* don't send a record */
12291398Stmm#define IGMP_MODE_IS_INCLUDE		1	/* MODE_IN */
12391398Stmm#define IGMP_MODE_IS_EXCLUDE		2	/* MODE_EX */
12491398Stmm#define IGMP_CHANGE_TO_INCLUDE_MODE	3	/* TO_IN */
12591398Stmm#define IGMP_CHANGE_TO_EXCLUDE_MODE	4	/* TO_EX */
12691398Stmm#define IGMP_ALLOW_NEW_SOURCES		5	/* ALLOW_NEW */
12791398Stmm#define IGMP_BLOCK_OLD_SOURCES		6	/* BLOCK_OLD */
12891398Stmm
12991398Stmm/*
130147256Sbrooks * IGMPv3 query types.
13191398Stmm */
13291398Stmm#define IGMP_V3_GENERAL_QUERY		1
13399726Sbenno#define IGMP_V3_GROUP_QUERY		2
13491398Stmm#define IGMP_V3_GROUP_SOURCE_QUERY	3
135147256Sbrooks
136147256Sbrooks/*
137147256Sbrooks * Maximum report interval for IGMP v1/v2 host membership reports [RFC 1112]
138147256Sbrooks */
13991398Stmm#define IGMP_V1V2_MAX_RI		10
14091398Stmm#define IGMP_MAX_HOST_REPORT_DELAY	IGMP_V1V2_MAX_RI
14191398Stmm
14291398Stmm/*
14391398Stmm * IGMP_TIMER_SCALE denotes that the igmp code field specifies
14491398Stmm * time in tenths of a second.
145117126Sscottl */
14691398Stmm#define IGMP_TIMER_SCALE		10
147147256Sbrooks
14891398Stmm#endif /* _NETINET_IGMP_H_ */
14991398Stmm