xref: /titanic_50/usr/src/uts/common/netinet/igmp.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * Internet Group Management Protocol (IGMP) definitions.
39  *
40  * Written by Steve Deering, Stanford, May 1988.
41  * Modified by Rosen Sharma, Stanford, Aug 1994
42  * Modified by Bill Fenner, Xerox PARC, April 1995
43  *
44  * MULTICAST 3.5.1.1
45  */
46 
47 /*
48  * IGMP packet format.
49  */
50 struct igmp {
51 	uchar_t		igmp_type;	/* version & type of IGMP message  */
52 	uchar_t		igmp_code;	/* code for routing sub-msgs	   */
53 	ushort_t	igmp_cksum;	/* IP-style checksum		   */
54 	struct in_addr	igmp_group;	/* group address being reported	   */
55 };					/*  (zero for queries)		   */
56 
57 /* IGMPv3 Membership Report common header */
58 struct igmp3r {
59 	uchar_t		igmp3r_type;	/* version & type of IGMP message  */
60 	uchar_t		igmp3r_code;	/* code for routing sub-msgs	   */
61 	ushort_t	igmp3r_cksum;	/* IP-style checksum		   */
62 	ushort_t	igmp3r_res;	/* Reserved			   */
63 	ushort_t	igmp3r_numrec;	/* Number of group records	   */
64 };
65 
66 /* IGMPv3 Group Record header */
67 struct grphdr {
68 	uchar_t		grphdr_type;	/* type of record		   */
69 	uchar_t		grphdr_auxlen;	/* auxiliary data length	   */
70 	ushort_t	grphdr_numsrc;	/* number of sources		   */
71 	struct in_addr	grphdr_group;	/* group address being reported	   */
72 };
73 
74 /* IGMPv3 Membership Query header */
75 struct igmp3q {
76 	uchar_t		igmp3q_type;	/* type of IGMP message		   */
77 	uchar_t		igmp3q_mxrt;	/* maximum response time	   */
78 	ushort_t	igmp3q_cksum;	/* IP-style checksum		   */
79 	struct in_addr	igmp3q_group;	/* group address being queried	   */
80 	ushort_t	igmp3q_res;	/* reserved			   */
81 	ushort_t	igmp3q_numsrc;	/* number of sources		   */
82 };
83 
84 #ifdef _KERNEL
85 typedef struct igmp_s {
86 	uint8_t		igmp_type;	/* version & type of IGMP message  */
87 	uint8_t		igmp_code;	/* code for routing sub-msgs	   */
88 	uint8_t		igmp_cksum[2];	/* IP-style checksum		   */
89 	uint8_t		igmp_group[4];	/* group address being reported	   */
90 } igmp_t;				/*  (zero for queries)		   */
91 
92 /* Aligned igmp header */
93 typedef struct igmpa_s {
94 	uint8_t		igmpa_type;	/* version & type of IGMP message  */
95 	uint8_t		igmpa_code;	/* code for routing sub-msgs	   */
96 	uint16_t	igmpa_cksum;	/* IP-style checksum		   */
97 	ipaddr_t	igmpa_group;	/* group address being reported	   */
98 } igmpa_t;				/*  (zero for queries)		   */
99 
100 /* Aligned IGMPv3 Membership Report common header */
101 typedef struct igmp3ra_s {
102 	uint8_t		igmp3ra_type;	/* version & type of IGMP message  */
103 	uint8_t		igmp3ra_res;	/* Reserved			   */
104 	uint16_t	igmp3ra_cksum;	/* IP-style checksum		   */
105 	uint16_t	igmp3ra_res1;	/* Reserved			   */
106 	uint16_t	igmp3ra_numrec;	/* Number of group records	   */
107 } igmp3ra_t;
108 
109 /* Aligned IGMPv3 Group Record header */
110 typedef struct grphdra_s {
111 	uint8_t		grphdra_type;	/* type of record		   */
112 	uint8_t		grphdra_auxlen;	/* auxiliary data length	   */
113 	uint16_t	grphdra_numsrc;	/* number of sources		   */
114 	ipaddr_t	grphdra_group;	/* group addrss being reported	   */
115 } grphdra_t;
116 
117 /* Aligned IGMpv3 Membership Query header */
118 typedef struct igmp3qa_s {
119 	uint8_t		igmp3qa_type;	/* type of IGMP message		   */
120 	uint8_t		igmp3qa_mxrc;	/* maximum response code	   */
121 	uint16_t	igmp3qa_cksum;	/* IP-style checksum		   */
122 	ipaddr_t	igmp3qa_group;	/* group address being queried	   */
123 	uint8_t		igmp3qa_sqrv;	/* S Flag, Q's Robustness Variable */
124 	uint8_t		igmp3qa_qqic;	/* Querier's Query Interval Code   */
125 	uint16_t	igmp3qa_numsrc;	/* number of sources		   */
126 } igmp3qa_t;
127 
128 #endif	/* _KERNEL */
129 
130 
131 #define	IGMP_MINLEN			8
132 #define	IGMP_V3_QUERY_MINLEN		12
133 
134 
135 /*
136  * Message types, including version number.
137  */
138 
139 #define	IGMP_MEMBERSHIP_QUERY		0x11	/* membership query    */
140 #define	IGMP_V1_MEMBERSHIP_REPORT	0x12	/* Vers.1 membership report */
141 #define	IGMP_V2_MEMBERSHIP_REPORT	0x16	/* Vers.2 membership report */
142 #define	IGMP_V3_MEMBERSHIP_REPORT	0x22	/* Vers.3 membership report */
143 #define	IGMP_V2_LEAVE_GROUP		0x17	/* Leave-group message	    */
144 #define	IGMP_DVMRP			0x13	/* DVMRP routing message    */
145 #define	IGMP_PIM			0x14	/* PIM routing message	    */
146 
147 #define	IGMP_MTRACE_RESP		0x1e  	/* traceroute resp to sender */
148 #define	IGMP_MTRACE			0x1f	/* mcast traceroute messages */
149 
150 #define	IGMP_MAX_HOST_REPORT_DELAY	10	/* max delay for response to */
151 						/* query (in seconds)	*/
152 						/* according to RFC1112 */
153 
154 #define	IGMP_V3_MAXRT_FPMIN		0x80	/* max resp code fp format */
155 #define	IGMP_V3_MAXRT_MANT_MASK		0x0f
156 #define	IGMP_V3_MAXRT_EXP_MASK		0x70
157 
158 #define	IGMP_V3_SFLAG_MASK		0x8	/* mask off s part of sqrv */
159 #define	IGMP_V3_RV_MASK			0x7	/* mask off qrv part of sqrv */
160 
161 #define	IGMP_V3_QQI_FPMIN		0x80	/* qqi code fp format */
162 #define	IGMP_V3_QQI_MANT_MASK		0x0f
163 #define	IGMP_V3_QQI_EXP_MASK		0x70
164 
165 /*
166  * IGMPv3/MLDv2-specific definitions
167  */
168 /*
169  * Group Record Types.  The values of these enums match the Record Type
170  * field values defined in RFCs 3376 and 3810 for IGMPv3 and MLDv2 reports.
171  */
172 typedef enum {
173 	MODE_IS_INCLUDE = 1,
174 	MODE_IS_EXCLUDE,
175 	CHANGE_TO_INCLUDE,
176 	CHANGE_TO_EXCLUDE,
177 	ALLOW_NEW_SOURCES,
178 	BLOCK_OLD_SOURCES
179 } mcast_record_t;
180 
181 /* Router Alert Option */
182 #define	RTRALERT_LEN			4
183 #define	RTRALERT_LEN_IN_WORDS		1
184 
185 /*
186  * The following four defininitions are for backwards compatibility.
187  * They should be removed as soon as all applications are updated to
188  * use the new constant names.
189  */
190 #define	IGMP_HOST_MEMBERSHIP_QUERY	IGMP_MEMBERSHIP_QUERY
191 #define	IGMP_HOST_MEMBERSHIP_REPORT	IGMP_V1_MEMBERSHIP_REPORT
192 #define	IGMP_HOST_NEW_MEMBERSHIP_REPORT	IGMP_V2_MEMBERSHIP_REPORT
193 #define	IGMP_HOST_LEAVE_MESSAGE		IGMP_V2_LEAVE_GROUP
194 
195 #ifdef	__cplusplus
196 }
197 #endif
198 
199 #endif	/* _NETINET_IGMP_H */
200