xref: /linux/include/uapi/linux/igmp.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  *	Linux NET3:	Internet Group Management Protocol  [IGMP]
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  *	Authors:
6607ca46eSDavid Howells  *		Alan Cox <alan@lxorguk.ukuu.org.uk>
7607ca46eSDavid Howells  *
8607ca46eSDavid Howells  *	Extended to talk the BSD extended IGMP protocol of mrouted 3.6
9607ca46eSDavid Howells  *
10607ca46eSDavid Howells  *
11607ca46eSDavid Howells  *	This program is free software; you can redistribute it and/or
12607ca46eSDavid Howells  *	modify it under the terms of the GNU General Public License
13607ca46eSDavid Howells  *	as published by the Free Software Foundation; either version
14607ca46eSDavid Howells  *	2 of the License, or (at your option) any later version.
15607ca46eSDavid Howells  */
16607ca46eSDavid Howells 
17607ca46eSDavid Howells #ifndef _UAPI_LINUX_IGMP_H
18607ca46eSDavid Howells #define _UAPI_LINUX_IGMP_H
19607ca46eSDavid Howells 
20607ca46eSDavid Howells #include <linux/types.h>
21607ca46eSDavid Howells #include <asm/byteorder.h>
22607ca46eSDavid Howells 
23607ca46eSDavid Howells /*
24607ca46eSDavid Howells  *	IGMP protocol structures
25607ca46eSDavid Howells  */
26607ca46eSDavid Howells 
27607ca46eSDavid Howells /*
28607ca46eSDavid Howells  *	Header in on cable format
29607ca46eSDavid Howells  */
30607ca46eSDavid Howells 
31607ca46eSDavid Howells struct igmphdr {
32607ca46eSDavid Howells 	__u8 type;
33607ca46eSDavid Howells 	__u8 code;		/* For newer IGMP */
34607ca46eSDavid Howells 	__sum16 csum;
35607ca46eSDavid Howells 	__be32 group;
36607ca46eSDavid Howells };
37607ca46eSDavid Howells 
38607ca46eSDavid Howells /* V3 group record types [grec_type] */
39607ca46eSDavid Howells #define IGMPV3_MODE_IS_INCLUDE		1
40607ca46eSDavid Howells #define IGMPV3_MODE_IS_EXCLUDE		2
41607ca46eSDavid Howells #define IGMPV3_CHANGE_TO_INCLUDE	3
42607ca46eSDavid Howells #define IGMPV3_CHANGE_TO_EXCLUDE	4
43607ca46eSDavid Howells #define IGMPV3_ALLOW_NEW_SOURCES	5
44607ca46eSDavid Howells #define IGMPV3_BLOCK_OLD_SOURCES	6
45607ca46eSDavid Howells 
46607ca46eSDavid Howells struct igmpv3_grec {
47607ca46eSDavid Howells 	__u8	grec_type;
48607ca46eSDavid Howells 	__u8	grec_auxwords;
49607ca46eSDavid Howells 	__be16	grec_nsrcs;
50607ca46eSDavid Howells 	__be32	grec_mca;
51*94dfc73eSGustavo A. R. Silva 	__be32	grec_src[];
52607ca46eSDavid Howells };
53607ca46eSDavid Howells 
54607ca46eSDavid Howells struct igmpv3_report {
55607ca46eSDavid Howells 	__u8 type;
56607ca46eSDavid Howells 	__u8 resv1;
5753631a5fSLance Richardson 	__sum16 csum;
58607ca46eSDavid Howells 	__be16 resv2;
59607ca46eSDavid Howells 	__be16 ngrec;
60*94dfc73eSGustavo A. R. Silva 	struct igmpv3_grec grec[];
61607ca46eSDavid Howells };
62607ca46eSDavid Howells 
63607ca46eSDavid Howells struct igmpv3_query {
64607ca46eSDavid Howells 	__u8 type;
65607ca46eSDavid Howells 	__u8 code;
6653631a5fSLance Richardson 	__sum16 csum;
67607ca46eSDavid Howells 	__be32 group;
68607ca46eSDavid Howells #if defined(__LITTLE_ENDIAN_BITFIELD)
69607ca46eSDavid Howells 	__u8 qrv:3,
70607ca46eSDavid Howells 	     suppress:1,
71607ca46eSDavid Howells 	     resv:4;
72607ca46eSDavid Howells #elif defined(__BIG_ENDIAN_BITFIELD)
73607ca46eSDavid Howells 	__u8 resv:4,
74607ca46eSDavid Howells 	     suppress:1,
75607ca46eSDavid Howells 	     qrv:3;
76607ca46eSDavid Howells #else
77607ca46eSDavid Howells #error "Please fix <asm/byteorder.h>"
78607ca46eSDavid Howells #endif
79607ca46eSDavid Howells 	__u8 qqic;
80607ca46eSDavid Howells 	__be16 nsrcs;
81*94dfc73eSGustavo A. R. Silva 	__be32 srcs[];
82607ca46eSDavid Howells };
83607ca46eSDavid Howells 
84607ca46eSDavid Howells #define IGMP_HOST_MEMBERSHIP_QUERY	0x11	/* From RFC1112 */
85607ca46eSDavid Howells #define IGMP_HOST_MEMBERSHIP_REPORT	0x12	/* Ditto */
86607ca46eSDavid Howells #define IGMP_DVMRP			0x13	/* DVMRP routing */
87607ca46eSDavid Howells #define IGMP_PIM			0x14	/* PIM routing */
88607ca46eSDavid Howells #define IGMP_TRACE			0x15
89607ca46eSDavid Howells #define IGMPV2_HOST_MEMBERSHIP_REPORT	0x16	/* V2 version of 0x12 */
90607ca46eSDavid Howells #define IGMP_HOST_LEAVE_MESSAGE 	0x17
91607ca46eSDavid Howells #define IGMPV3_HOST_MEMBERSHIP_REPORT	0x22	/* V3 version of 0x12 */
92607ca46eSDavid Howells 
93607ca46eSDavid Howells #define IGMP_MTRACE_RESP		0x1e
94607ca46eSDavid Howells #define IGMP_MTRACE			0x1f
95607ca46eSDavid Howells 
964b3087c7SLinus Lüssing #define IGMP_MRDISC_ADV			0x30	/* From RFC4286 */
97607ca46eSDavid Howells 
98607ca46eSDavid Howells /*
99607ca46eSDavid Howells  *	Use the BSD names for these for compatibility
100607ca46eSDavid Howells  */
101607ca46eSDavid Howells 
102607ca46eSDavid Howells #define IGMP_DELAYING_MEMBER		0x01
103607ca46eSDavid Howells #define IGMP_IDLE_MEMBER		0x02
104607ca46eSDavid Howells #define IGMP_LAZY_MEMBER		0x03
105607ca46eSDavid Howells #define IGMP_SLEEPING_MEMBER		0x04
106607ca46eSDavid Howells #define IGMP_AWAKENING_MEMBER		0x05
107607ca46eSDavid Howells 
108607ca46eSDavid Howells #define IGMP_MINLEN			8
109607ca46eSDavid Howells 
110607ca46eSDavid Howells #define IGMP_MAX_HOST_REPORT_DELAY	10	/* max delay for response to */
111607ca46eSDavid Howells 						/* query (in seconds)	*/
112607ca46eSDavid Howells 
113607ca46eSDavid Howells #define IGMP_TIMER_SCALE		10	/* denotes that the igmphdr->timer field */
114607ca46eSDavid Howells 						/* specifies time in 10th of seconds	 */
115607ca46eSDavid Howells 
116607ca46eSDavid Howells #define IGMP_AGE_THRESHOLD		400	/* If this host don't hear any IGMP V1	*/
117607ca46eSDavid Howells 						/* message in this period of time,	*/
118607ca46eSDavid Howells 						/* revert to IGMP v2 router.		*/
119607ca46eSDavid Howells 
120607ca46eSDavid Howells #define IGMP_ALL_HOSTS		htonl(0xE0000001L)
121607ca46eSDavid Howells #define IGMP_ALL_ROUTER 	htonl(0xE0000002L)
122607ca46eSDavid Howells #define IGMPV3_ALL_MCR	 	htonl(0xE0000016L)
123607ca46eSDavid Howells #define IGMP_LOCAL_GROUP	htonl(0xE0000000L)
124607ca46eSDavid Howells #define IGMP_LOCAL_GROUP_MASK	htonl(0xFFFFFF00L)
125607ca46eSDavid Howells 
126607ca46eSDavid Howells /*
127607ca46eSDavid Howells  * struct for keeping the multicast list in
128607ca46eSDavid Howells  */
129607ca46eSDavid Howells 
130607ca46eSDavid Howells #endif /* _UAPI_LINUX_IGMP_H */
131