xref: /illumos-gate/usr/src/uts/common/netinet/igmp.h (revision 86d949f9497332fe19be6b5d711d265eb957439f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /* Copyright (c) 1990 Mentat Inc. */
27 
28 #ifndef	_NETINET_IGMP_H
29 #define	_NETINET_IGMP_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Internet Group Management Protocol (IGMP) definitions.
37  *
38  * Written by Steve Deering, Stanford, May 1988.
39  * Modified by Rosen Sharma, Stanford, Aug 1994
40  * Modified by Bill Fenner, Xerox PARC, April 1995
41  *
42  * MULTICAST 3.5.1.1
43  */
44 
45 /*
46  * IGMP packet format.
47  */
48 struct igmp {
49 	uchar_t		igmp_type;	/* version & type of IGMP message  */
50 	uchar_t		igmp_code;	/* code for routing sub-msgs	   */
51 	ushort_t	igmp_cksum;	/* IP-style checksum		   */
52 	struct in_addr	igmp_group;	/* group address being reported	   */
53 };					/*  (zero for queries)		   */
54 
55 /* IGMPv3 Membership Report common header */
56 struct igmp3r {
57 	uchar_t		igmp3r_type;	/* version & type of IGMP message  */
58 	uchar_t		igmp3r_code;	/* code for routing sub-msgs	   */
59 	ushort_t	igmp3r_cksum;	/* IP-style checksum		   */
60 	ushort_t	igmp3r_res;	/* Reserved			   */
61 	ushort_t	igmp3r_numrec;	/* Number of group records	   */
62 };
63 
64 /* IGMPv3 Group Record header */
65 struct grphdr {
66 	uchar_t		grphdr_type;	/* type of record		   */
67 	uchar_t		grphdr_auxlen;	/* auxiliary data length	   */
68 	ushort_t	grphdr_numsrc;	/* number of sources		   */
69 	struct in_addr	grphdr_group;	/* group address being reported	   */
70 };
71 
72 /* IGMPv3 Membership Query header */
73 struct igmp3q {
74 	uchar_t		igmp3q_type;	/* type of IGMP message		   */
75 	uchar_t		igmp3q_mxrt;	/* maximum response time	   */
76 	ushort_t	igmp3q_cksum;	/* IP-style checksum		   */
77 	struct in_addr	igmp3q_group;	/* group address being queried	   */
78 	ushort_t	igmp3q_res;	/* reserved			   */
79 	ushort_t	igmp3q_numsrc;	/* number of sources		   */
80 };
81 
82 #ifdef _KERNEL
83 typedef struct igmp_s {
84 	uint8_t		igmp_type;	/* version & type of IGMP message  */
85 	uint8_t		igmp_code;	/* code for routing sub-msgs	   */
86 	uint8_t		igmp_cksum[2];	/* IP-style checksum		   */
87 	uint8_t		igmp_group[4];	/* group address being reported	   */
88 } igmp_t;				/*  (zero for queries)		   */
89 
90 /* Aligned igmp header */
91 typedef struct igmpa_s {
92 	uint8_t		igmpa_type;	/* version & type of IGMP message  */
93 	uint8_t		igmpa_code;	/* code for routing sub-msgs	   */
94 	uint16_t	igmpa_cksum;	/* IP-style checksum		   */
95 	ipaddr_t	igmpa_group;	/* group address being reported	   */
96 } igmpa_t;				/*  (zero for queries)		   */
97 
98 /* Aligned IGMPv3 Membership Report common header */
99 typedef struct igmp3ra_s {
100 	uint8_t		igmp3ra_type;	/* version & type of IGMP message  */
101 	uint8_t		igmp3ra_res;	/* Reserved			   */
102 	uint16_t	igmp3ra_cksum;	/* IP-style checksum		   */
103 	uint16_t	igmp3ra_res1;	/* Reserved			   */
104 	uint16_t	igmp3ra_numrec;	/* Number of group records	   */
105 } igmp3ra_t;
106 
107 /* Aligned IGMPv3 Group Record header */
108 typedef struct grphdra_s {
109 	uint8_t		grphdra_type;	/* type of record		   */
110 	uint8_t		grphdra_auxlen;	/* auxiliary data length	   */
111 	uint16_t	grphdra_numsrc;	/* number of sources		   */
112 	ipaddr_t	grphdra_group;	/* group addrss being reported	   */
113 } grphdra_t;
114 
115 /* Aligned IGMpv3 Membership Query header */
116 typedef struct igmp3qa_s {
117 	uint8_t		igmp3qa_type;	/* type of IGMP message		   */
118 	uint8_t		igmp3qa_mxrc;	/* maximum response code	   */
119 	uint16_t	igmp3qa_cksum;	/* IP-style checksum		   */
120 	ipaddr_t	igmp3qa_group;	/* group address being queried	   */
121 	uint8_t		igmp3qa_sqrv;	/* S Flag, Q's Robustness Variable */
122 	uint8_t		igmp3qa_qqic;	/* Querier's Query Interval Code   */
123 	uint16_t	igmp3qa_numsrc;	/* number of sources		   */
124 } igmp3qa_t;
125 
126 #endif	/* _KERNEL */
127 
128 
129 #define	IGMP_MINLEN			8
130 #define	IGMP_V3_QUERY_MINLEN		12
131 
132 
133 /*
134  * Message types, including version number.
135  */
136 
137 #define	IGMP_MEMBERSHIP_QUERY		0x11	/* membership query    */
138 #define	IGMP_V1_MEMBERSHIP_REPORT	0x12	/* Vers.1 membership report */
139 #define	IGMP_V2_MEMBERSHIP_REPORT	0x16	/* Vers.2 membership report */
140 #define	IGMP_V3_MEMBERSHIP_REPORT	0x22	/* Vers.3 membership report */
141 #define	IGMP_V2_LEAVE_GROUP		0x17	/* Leave-group message	    */
142 #define	IGMP_DVMRP			0x13	/* DVMRP routing message    */
143 #define	IGMP_PIM			0x14	/* PIM routing message	    */
144 
145 #define	IGMP_MTRACE_RESP		0x1e  	/* traceroute resp to sender */
146 #define	IGMP_MTRACE			0x1f	/* mcast traceroute messages */
147 
148 #define	IGMP_MAX_HOST_REPORT_DELAY	10	/* max delay for response to */
149 						/* query (in seconds)	*/
150 						/* according to RFC1112 */
151 
152 #define	IGMP_V3_MAXRT_FPMIN		0x80	/* max resp code fp format */
153 #define	IGMP_V3_MAXRT_MANT_MASK		0x0f
154 #define	IGMP_V3_MAXRT_EXP_MASK		0x70
155 
156 #define	IGMP_V3_SFLAG_MASK		0x8	/* mask off s part of sqrv */
157 #define	IGMP_V3_RV_MASK			0x7	/* mask off qrv part of sqrv */
158 
159 #define	IGMP_V3_QQI_FPMIN		0x80	/* qqi code fp format */
160 #define	IGMP_V3_QQI_MANT_MASK		0x0f
161 #define	IGMP_V3_QQI_EXP_MASK		0x70
162 
163 /*
164  * IGMPv3/MLDv2-specific definitions
165  */
166 /*
167  * Group Record Types.  The values of these enums match the Record Type
168  * field values defined in RFCs 3376 and 3810 for IGMPv3 and MLDv2 reports.
169  */
170 typedef enum {
171 	MODE_IS_INCLUDE = 1,
172 	MODE_IS_EXCLUDE,
173 	CHANGE_TO_INCLUDE,
174 	CHANGE_TO_EXCLUDE,
175 	ALLOW_NEW_SOURCES,
176 	BLOCK_OLD_SOURCES
177 } mcast_record_t;
178 
179 /* Router Alert Option */
180 #define	RTRALERT_LEN			4
181 #define	RTRALERT_LEN_IN_WORDS		1
182 
183 /*
184  * The following four defininitions are for backwards compatibility.
185  * They should be removed as soon as all applications are updated to
186  * use the new constant names.
187  */
188 #define	IGMP_HOST_MEMBERSHIP_QUERY	IGMP_MEMBERSHIP_QUERY
189 #define	IGMP_HOST_MEMBERSHIP_REPORT	IGMP_V1_MEMBERSHIP_REPORT
190 #define	IGMP_HOST_NEW_MEMBERSHIP_REPORT	IGMP_V2_MEMBERSHIP_REPORT
191 #define	IGMP_HOST_LEAVE_MESSAGE		IGMP_V2_LEAVE_GROUP
192 
193 #ifdef	__cplusplus
194 }
195 #endif
196 
197 #endif	/* _NETINET_IGMP_H */
198