]> git.ipfire.org Git - thirdparty/linux.git/blame - include/linux/igmp.h
Merge tag 'parisc-for-6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[thirdparty/linux.git] / include / linux / igmp.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
2/*
3 * Linux NET3: Internet Group Management Protocol [IGMP]
4 *
5 * Authors:
113aa838 6 * Alan Cox <alan@lxorguk.ukuu.org.uk>
1da177e4
LT
7 *
8 * Extended to talk the BSD extended IGMP protocol of mrouted 3.6
1da177e4 9 */
1da177e4
LT
10#ifndef _LINUX_IGMP_H
11#define _LINUX_IGMP_H
12
1da177e4 13#include <linux/skbuff.h>
d7fe0f24 14#include <linux/timer.h>
1da177e4 15#include <linux/in.h>
ba5ea614 16#include <linux/ip.h>
8851ab52 17#include <linux/refcount.h>
ac62f606 18#include <linux/sockptr.h>
607ca46e 19#include <uapi/linux/igmp.h>
1da177e4 20
cc32e054
JP
21static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
22{
23 return (struct igmphdr *)skb_transport_header(skb);
24}
25
26static inline struct igmpv3_report *
27 igmpv3_report_hdr(const struct sk_buff *skb)
28{
29 return (struct igmpv3_report *)skb_transport_header(skb);
30}
31
32static inline struct igmpv3_query *
33 igmpv3_query_hdr(const struct sk_buff *skb)
34{
35 return (struct igmpv3_query *)skb_transport_header(skb);
36}
37
d94d9fee 38struct ip_sf_socklist {
1da177e4
LT
39 unsigned int sl_max;
40 unsigned int sl_count;
c85bb41e 41 struct rcu_head rcu;
210d4e9c 42 __be32 sl_addr[] __counted_by(sl_max);
1da177e4
LT
43};
44
1da177e4
LT
45#define IP_SFBLOCK 10 /* allocate this many at once */
46
47/* ip_mc_socklist is real list now. Speed is not argument;
48 this list never used in fast path code
49 */
50
d94d9fee 51struct ip_mc_socklist {
1d7138de 52 struct ip_mc_socklist __rcu *next_rcu;
1da177e4
LT
53 struct ip_mreqn multi;
54 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
1d7138de 55 struct ip_sf_socklist __rcu *sflist;
c85bb41e 56 struct rcu_head rcu;
1da177e4
LT
57};
58
d94d9fee 59struct ip_sf_list {
1da177e4 60 struct ip_sf_list *sf_next;
1da177e4 61 unsigned long sf_count[2]; /* include/exclude counts */
0db355d4 62 __be32 sf_inaddr;
1da177e4
LT
63 unsigned char sf_gsresp; /* include in g & s response? */
64 unsigned char sf_oldin; /* change state */
65 unsigned char sf_crcount; /* retrans. left to send */
66};
67
d94d9fee 68struct ip_mc_list {
1da177e4 69 struct in_device *interface;
338fcf98 70 __be32 multiaddr;
1d7138de 71 unsigned int sfmode;
1da177e4
LT
72 struct ip_sf_list *sources;
73 struct ip_sf_list *tomb;
1da177e4 74 unsigned long sfcount[2];
1d7138de
ED
75 union {
76 struct ip_mc_list *next;
77 struct ip_mc_list __rcu *next_rcu;
78 };
e9897071 79 struct ip_mc_list __rcu *next_hash;
1da177e4
LT
80 struct timer_list timer;
81 int users;
8851ab52 82 refcount_t refcnt;
1da177e4
LT
83 spinlock_t lock;
84 char tm_running;
85 char reporter;
86 char unsolicit_count;
87 char loaded;
88 unsigned char gsquery; /* check source marks? */
89 unsigned char crcount;
1d7138de 90 struct rcu_head rcu;
1da177e4
LT
91};
92
93/* V3 exponential field decoding */
94#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
95#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
96 ((value) < (thresh) ? (value) : \
fb47ddb2 97 ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
1da177e4
LT
98 (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
99
100#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
101#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
102
ba5ea614
LL
103static inline int ip_mc_may_pull(struct sk_buff *skb, unsigned int len)
104{
105 if (skb_transport_offset(skb) + ip_transport_len(skb) < len)
083b78a9 106 return 0;
ba5ea614
LL
107
108 return pskb_may_pull(skb, len);
109}
110
2094acbb 111extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto);
1da177e4
LT
112extern int igmp_rcv(struct sk_buff *);
113extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
6e2059b5
HL
114extern int ip_mc_join_group_ssm(struct sock *sk, struct ip_mreqn *imr,
115 unsigned int mode);
1da177e4
LT
116extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
117extern void ip_mc_drop_socket(struct sock *sk);
118extern int ip_mc_source(int add, int omode, struct sock *sk,
119 struct ip_mreq_source *mreqs, int ifindex);
120extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
121extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
728f064c 122 sockptr_t optval, sockptr_t optlen);
1da177e4 123extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
728f064c 124 sockptr_t optval, size_t offset);
33e972bd 125extern int ip_mc_sf_allow(const struct sock *sk, __be32 local, __be32 rmt,
60d9b031 126 int dif, int sdif);
1da177e4
LT
127extern void ip_mc_init_dev(struct in_device *);
128extern void ip_mc_destroy_dev(struct in_device *);
129extern void ip_mc_up(struct in_device *);
130extern void ip_mc_down(struct in_device *);
75c78500
MS
131extern void ip_mc_unmap(struct in_device *);
132extern void ip_mc_remap(struct in_device *);
9fb20801
FF
133extern void __ip_mc_dec_group(struct in_device *in_dev, __be32 addr, gfp_t gfp);
134static inline void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
135{
136 return __ip_mc_dec_group(in_dev, addr, GFP_KERNEL);
137}
138extern void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
139 gfp_t gfp);
8f935bbd 140extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
ba5ea614 141int ip_mc_check_igmp(struct sk_buff *skb);
a816c7c7 142
1da177e4 143#endif