11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Linux NET3:	Internet Group Management Protocol  [IGMP]
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Authors:
5113aa838ec3a235d883f8357d31d90e16c47fc89Alan Cox *		Alan Cox <alan@lxorguk.ukuu.org.uk>
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Extended to talk the BSD extended IGMP protocol of mrouted 3.6
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	This program is free software; you can redistribute it and/or
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	modify it under the terms of the GNU General Public License
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	as published by the Free Software Foundation; either version
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	2 of the License, or (at your option) any later version.
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _LINUX_IGMP_H
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _LINUX_IGMP_H
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
19de8b0bcafabfb4400aa028282293ce7d52307433Jaswinder Singh Rajput#include <linux/types.h>
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/byteorder.h>
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	IGMP protocol structures
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Header in on cable format
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
30d94d9fee9fa4e66a0b91640a694b8b10177075b3Eric Dumazetstruct igmphdr {
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 type;
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 code;		/* For newer IGMP */
339981a0e36a572e9fcf84bfab915fdc93bed0e3c9Al Viro	__sum16 csum;
34942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be32 group;
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* V3 group record types [grec_type] */
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_MODE_IS_INCLUDE		1
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_MODE_IS_EXCLUDE		2
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_CHANGE_TO_INCLUDE	3
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_CHANGE_TO_EXCLUDE	4
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_ALLOW_NEW_SOURCES	5
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_BLOCK_OLD_SOURCES	6
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct igmpv3_grec {
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8	grec_type;
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8	grec_auxwords;
48942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16	grec_nsrcs;
49942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be32	grec_mca;
50942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be32	grec_src[0];
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct igmpv3_report {
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 type;
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 resv1;
56942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16 csum;
57942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16 resv2;
58942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16 ngrec;
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct igmpv3_grec grec[0];
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct igmpv3_query {
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 type;
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 code;
65942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16 csum;
66942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be32 group;
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(__LITTLE_ENDIAN_BITFIELD)
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 qrv:3,
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	     suppress:1,
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	     resv:4;
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#elif defined(__BIG_ENDIAN_BITFIELD)
721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 resv:4,
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	     suppress:1,
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	     qrv:3;
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#error "Please fix <asm/byteorder.h>"
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	__u8 qqic;
79942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be16 nsrcs;
80942bf921e922560c05fde6afb00ddedf6224c608Al Viro	__be32 srcs[0];
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_HOST_MEMBERSHIP_QUERY	0x11	/* From RFC1112 */
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_HOST_MEMBERSHIP_REPORT	0x12	/* Ditto */
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_DVMRP			0x13	/* DVMRP routing */
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_PIM			0x14	/* PIM routing */
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_TRACE			0x15
887b26e5ebd8b27b0126a84ae7f9a42aa8293d6c48Francois-Xavier Le Bail#define IGMPV2_HOST_MEMBERSHIP_REPORT	0x16	/* V2 version of 0x12 */
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_HOST_LEAVE_MESSAGE 	0x17
907b26e5ebd8b27b0126a84ae7f9a42aa8293d6c48Francois-Xavier Le Bail#define IGMPV3_HOST_MEMBERSHIP_REPORT	0x22	/* V3 version of 0x12 */
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_MTRACE_RESP		0x1e
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_MTRACE			0x1f
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Use the BSD names for these for compatibility
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_DELAYING_MEMBER		0x01
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_IDLE_MEMBER		0x02
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_LAZY_MEMBER		0x03
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_SLEEPING_MEMBER		0x04
1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_AWAKENING_MEMBER		0x05
1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_MINLEN			8
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_MAX_HOST_REPORT_DELAY	10	/* max delay for response to */
1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						/* query (in seconds)	*/
1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_TIMER_SCALE		10	/* denotes that the igmphdr->timer field */
1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						/* specifies time in 10th of seconds	 */
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_AGE_THRESHOLD		400	/* If this host don't hear any IGMP V1	*/
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						/* message in this period of time,	*/
1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						/* revert to IGMP v2 router.		*/
1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_ALL_HOSTS		htonl(0xE0000001L)
1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_ALL_ROUTER 	htonl(0xE0000002L)
1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_ALL_MCR	 	htonl(0xE0000016L)
1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_LOCAL_GROUP	htonl(0xE0000000L)
1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMP_LOCAL_GROUP_MASK	htonl(0xFFFFFF00L)
1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * struct for keeping the multicast list in
1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef __KERNEL__
1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/skbuff.h>
130d7fe0f241dceade9c8d4af75498765c5ff7f27e6Al Viro#include <linux/timer.h>
1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/in.h>
1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
133cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perchesstatic inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
134cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches{
135cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches	return (struct igmphdr *)skb_transport_header(skb);
136cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches}
137cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches
138cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perchesstatic inline struct igmpv3_report *
139cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches			igmpv3_report_hdr(const struct sk_buff *skb)
140cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches{
141cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches	return (struct igmpv3_report *)skb_transport_header(skb);
142cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches}
143cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches
144cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perchesstatic inline struct igmpv3_query *
145cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches			igmpv3_query_hdr(const struct sk_buff *skb)
146cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches{
147cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches	return (struct igmpv3_query *)skb_transport_header(skb);
148cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches}
149cc32e05416b4023a5466a2f66e3c02236a771c5bJoe Perches
15020380731bc2897f2952ae055420972ded4cd786eArnaldo Carvalho de Meloextern int sysctl_igmp_max_memberships;
15120380731bc2897f2952ae055420972ded4cd786eArnaldo Carvalho de Meloextern int sysctl_igmp_max_msf;
15220380731bc2897f2952ae055420972ded4cd786eArnaldo Carvalho de Melo
153d94d9fee9fa4e66a0b91640a694b8b10177075b3Eric Dumazetstruct ip_sf_socklist {
1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int		sl_max;
1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int		sl_count;
156c85bb41e93184bf5494dde6d8fe5a81b564c84c8Flavio Leitner	struct rcu_head		rcu;
157ea4d9e7220d32348cc9742ba6d27de5165262664Al Viro	__be32			sl_addr[0];
1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IP_SFLSIZE(count)	(sizeof(struct ip_sf_socklist) + \
16163007727e0bb09e8d906f73d36a09b9fac0d5893Al Viro	(count) * sizeof(__be32))
1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IP_SFBLOCK	10	/* allocate this many at once */
1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ip_mc_socklist is real list now. Speed is not argument;
1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds   this list never used in fast path code
1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
169d94d9fee9fa4e66a0b91640a694b8b10177075b3Eric Dumazetstruct ip_mc_socklist {
1701d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	struct ip_mc_socklist __rcu *next_rcu;
1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct ip_mreqn		multi;
1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
1731d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	struct ip_sf_socklist __rcu	*sflist;
174c85bb41e93184bf5494dde6d8fe5a81b564c84c8Flavio Leitner	struct rcu_head		rcu;
1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
177d94d9fee9fa4e66a0b91640a694b8b10177075b3Eric Dumazetstruct ip_sf_list {
1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct ip_sf_list	*sf_next;
179ea4d9e7220d32348cc9742ba6d27de5165262664Al Viro	__be32			sf_inaddr;
1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned long		sf_count[2];	/* include/exclude counts */
1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char		sf_gsresp;	/* include in g & s response? */
1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char		sf_oldin;	/* change state */
1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char		sf_crcount;	/* retrans. left to send */
1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
186d94d9fee9fa4e66a0b91640a694b8b10177075b3Eric Dumazetstruct ip_mc_list {
1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct in_device	*interface;
188338fcf9886df9ad2873772197a73a57818973316Alexey Dobriyan	__be32			multiaddr;
1891d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	unsigned int		sfmode;
1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct ip_sf_list	*sources;
1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct ip_sf_list	*tomb;
1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned long		sfcount[2];
1931d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	union {
1941d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet		struct ip_mc_list *next;
1951d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet		struct ip_mc_list __rcu *next_rcu;
1961d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	};
1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct timer_list	timer;
1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int			users;
1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	atomic_t		refcnt;
2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	spinlock_t		lock;
2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char			tm_running;
2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char			reporter;
2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char			unsolicit_count;
2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char			loaded;
2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char		gsquery;	/* check source marks? */
2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned char		crcount;
2071d7138de878d1d4210727c1200193e69596f93b3Eric Dumazet	struct rcu_head		rcu;
2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* V3 exponential field decoding */
2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	((value) < (thresh) ? (value) : \
214fb47ddb2db9c18664bd7b06c201a2398885b64fcDavid L Stevens        ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds         (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
220dbdd9a52e38a4a93adfa4d0278801cce4fad98ebDavid S. Millerextern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto);
2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int igmp_rcv(struct sk_buff *);
2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void ip_mc_drop_socket(struct sock *sk);
2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_source(int add, int omode, struct sock *sk,
2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct ip_mreq_source *mreqs, int ifindex);
2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct ip_msfilter __user *optval, int __user *optlen);
2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct group_filter __user *optval, int __user *optlen);
232c0cda068aac3481d40795b115e4fd36f7d386e3aAl Viroextern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif);
2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void ip_mc_init_dev(struct in_device *);
2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void ip_mc_destroy_dev(struct in_device *);
2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void ip_mc_up(struct in_device *);
2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void ip_mc_down(struct in_device *);
23775c78500ddad74b229cd0691496b8549490496a2Moni Shouaextern void ip_mc_unmap(struct in_device *);
23875c78500ddad74b229cd0691496b8549490496a2Moni Shouaextern void ip_mc_remap(struct in_device *);
2398f935bbd7c6c66796c2403aefdab74bb48045bf6Al Viroextern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
2408f935bbd7c6c66796c2403aefdab74bb48045bf6Al Viroextern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
241866f3b25a2eb60d7529c227a0ecd80c3aba443fdEric Dumazetextern void ip_mc_rejoin_groups(struct in_device *in_dev);
242a816c7c712ff9f6770168b91facb9bfa9f0acd48Jay Vosburgh
2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
245