1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _LINUX_IGMP_H
16#define _LINUX_IGMP_H
17
18#include <linux/skbuff.h>
19#include <linux/timer.h>
20#include <linux/in.h>
21#include <uapi/linux/igmp.h>
22
23static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
24{
25 return (struct igmphdr *)skb_transport_header(skb);
26}
27
28static inline struct igmpv3_report *
29 igmpv3_report_hdr(const struct sk_buff *skb)
30{
31 return (struct igmpv3_report *)skb_transport_header(skb);
32}
33
34static inline struct igmpv3_query *
35 igmpv3_query_hdr(const struct sk_buff *skb)
36{
37 return (struct igmpv3_query *)skb_transport_header(skb);
38}
39
40struct ip_sf_socklist {
41 unsigned int sl_max;
42 unsigned int sl_count;
43 struct rcu_head rcu;
44 __be32 sl_addr[0];
45};
46
47#define IP_SFLSIZE(count) (sizeof(struct ip_sf_socklist) + \
48 (count) * sizeof(__be32))
49
50#define IP_SFBLOCK 10
51
52
53
54
55
56struct ip_mc_socklist {
57 struct ip_mc_socklist __rcu *next_rcu;
58 struct ip_mreqn multi;
59 unsigned int sfmode;
60 struct ip_sf_socklist __rcu *sflist;
61 struct rcu_head rcu;
62};
63
64struct ip_sf_list {
65 struct ip_sf_list *sf_next;
66 __be32 sf_inaddr;
67 unsigned long sf_count[2];
68 unsigned char sf_gsresp;
69 unsigned char sf_oldin;
70 unsigned char sf_crcount;
71};
72
73struct ip_mc_list {
74 struct in_device *interface;
75 __be32 multiaddr;
76 unsigned int sfmode;
77 struct ip_sf_list *sources;
78 struct ip_sf_list *tomb;
79 unsigned long sfcount[2];
80 union {
81 struct ip_mc_list *next;
82 struct ip_mc_list __rcu *next_rcu;
83 };
84 struct ip_mc_list __rcu *next_hash;
85 struct timer_list timer;
86 int users;
87 atomic_t refcnt;
88 spinlock_t lock;
89 char tm_running;
90 char reporter;
91 char unsolicit_count;
92 char loaded;
93 unsigned char gsquery;
94 unsigned char crcount;
95 struct rcu_head rcu;
96};
97
98
99#define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
100#define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
101 ((value) < (thresh) ? (value) : \
102 ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
103 (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
104
105#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
106#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
107
108extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto);
109extern int igmp_rcv(struct sk_buff *);
110extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
111extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
112extern void ip_mc_drop_socket(struct sock *sk);
113extern int ip_mc_source(int add, int omode, struct sock *sk,
114 struct ip_mreq_source *mreqs, int ifindex);
115extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
116extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
117 struct ip_msfilter __user *optval, int __user *optlen);
118extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
119 struct group_filter __user *optval, int __user *optlen);
120extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif);
121extern void ip_mc_init_dev(struct in_device *);
122extern void ip_mc_destroy_dev(struct in_device *);
123extern void ip_mc_up(struct in_device *);
124extern void ip_mc_down(struct in_device *);
125extern void ip_mc_unmap(struct in_device *);
126extern void ip_mc_remap(struct in_device *);
127extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
128extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
129int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed);
130
131#endif
132