Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Linux NET3: Internet Group Management Protocol [IGMP] | |
3 | * | |
4 | * Authors: | |
113aa838 | 5 | * Alan Cox <alan@lxorguk.ukuu.org.uk> |
1da177e4 LT |
6 | * |
7 | * Extended to talk the BSD extended IGMP protocol of mrouted 3.6 | |
8 | * | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU General Public License | |
12 | * as published by the Free Software Foundation; either version | |
13 | * 2 of the License, or (at your option) any later version. | |
14 | */ | |
1da177e4 LT |
15 | #ifndef _LINUX_IGMP_H |
16 | #define _LINUX_IGMP_H | |
17 | ||
1da177e4 | 18 | #include <linux/skbuff.h> |
d7fe0f24 | 19 | #include <linux/timer.h> |
1da177e4 | 20 | #include <linux/in.h> |
607ca46e | 21 | #include <uapi/linux/igmp.h> |
1da177e4 | 22 | |
cc32e054 JP |
23 | static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb) |
24 | { | |
25 | return (struct igmphdr *)skb_transport_header(skb); | |
26 | } | |
27 | ||
28 | static 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 | ||
34 | static 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 | ||
d94d9fee | 40 | struct ip_sf_socklist { |
1da177e4 LT |
41 | unsigned int sl_max; |
42 | unsigned int sl_count; | |
c85bb41e | 43 | struct rcu_head rcu; |
ea4d9e72 | 44 | __be32 sl_addr[0]; |
1da177e4 LT |
45 | }; |
46 | ||
47 | #define IP_SFLSIZE(count) (sizeof(struct ip_sf_socklist) + \ | |
63007727 | 48 | (count) * sizeof(__be32)) |
1da177e4 LT |
49 | |
50 | #define IP_SFBLOCK 10 /* allocate this many at once */ | |
51 | ||
52 | /* ip_mc_socklist is real list now. Speed is not argument; | |
53 | this list never used in fast path code | |
54 | */ | |
55 | ||
d94d9fee | 56 | struct ip_mc_socklist { |
1d7138de | 57 | struct ip_mc_socklist __rcu *next_rcu; |
1da177e4 LT |
58 | struct ip_mreqn multi; |
59 | unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */ | |
1d7138de | 60 | struct ip_sf_socklist __rcu *sflist; |
c85bb41e | 61 | struct rcu_head rcu; |
1da177e4 LT |
62 | }; |
63 | ||
d94d9fee | 64 | struct ip_sf_list { |
1da177e4 | 65 | struct ip_sf_list *sf_next; |
ea4d9e72 | 66 | __be32 sf_inaddr; |
1da177e4 LT |
67 | unsigned long sf_count[2]; /* include/exclude counts */ |
68 | unsigned char sf_gsresp; /* include in g & s response? */ | |
69 | unsigned char sf_oldin; /* change state */ | |
70 | unsigned char sf_crcount; /* retrans. left to send */ | |
71 | }; | |
72 | ||
d94d9fee | 73 | struct ip_mc_list { |
1da177e4 | 74 | struct in_device *interface; |
338fcf98 | 75 | __be32 multiaddr; |
1d7138de | 76 | unsigned int sfmode; |
1da177e4 LT |
77 | struct ip_sf_list *sources; |
78 | struct ip_sf_list *tomb; | |
1da177e4 | 79 | unsigned long sfcount[2]; |
1d7138de ED |
80 | union { |
81 | struct ip_mc_list *next; | |
82 | struct ip_mc_list __rcu *next_rcu; | |
83 | }; | |
e9897071 | 84 | struct ip_mc_list __rcu *next_hash; |
1da177e4 LT |
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; /* check source marks? */ | |
94 | unsigned char crcount; | |
1d7138de | 95 | struct rcu_head rcu; |
1da177e4 LT |
96 | }; |
97 | ||
98 | /* V3 exponential field decoding */ | |
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) : \ | |
fb47ddb2 | 102 | ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \ |
1da177e4 LT |
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 | ||
2094acbb | 108 | extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto); |
1da177e4 LT |
109 | extern int igmp_rcv(struct sk_buff *); |
110 | extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr); | |
111 | extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr); | |
112 | extern void ip_mc_drop_socket(struct sock *sk); | |
113 | extern int ip_mc_source(int add, int omode, struct sock *sk, | |
114 | struct ip_mreq_source *mreqs, int ifindex); | |
115 | extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex); | |
116 | extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, | |
117 | struct ip_msfilter __user *optval, int __user *optlen); | |
118 | extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, | |
119 | struct group_filter __user *optval, int __user *optlen); | |
c0cda068 | 120 | extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif); |
1da177e4 LT |
121 | extern void ip_mc_init_dev(struct in_device *); |
122 | extern void ip_mc_destroy_dev(struct in_device *); | |
123 | extern void ip_mc_up(struct in_device *); | |
124 | extern void ip_mc_down(struct in_device *); | |
75c78500 MS |
125 | extern void ip_mc_unmap(struct in_device *); |
126 | extern void ip_mc_remap(struct in_device *); | |
8f935bbd AV |
127 | extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr); |
128 | extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr); | |
9afd85c9 | 129 | int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed); |
a816c7c7 | 130 | |
1da177e4 | 131 | #endif |