igmp.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Linux NET3: Internet Group Management Protocol [IGMP]
  3. *
  4. * Authors:
  5. * Alan Cox <alan@lxorguk.ukuu.org.uk>
  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. */
  15. #ifndef _LINUX_IGMP_H
  16. #define _LINUX_IGMP_H
  17. #include <linux/skbuff.h>
  18. #include <linux/timer.h>
  19. #include <linux/in.h>
  20. #include <uapi/linux/igmp.h>
  21. static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
  22. {
  23. return (struct igmphdr *)skb_transport_header(skb);
  24. }
  25. static inline struct igmpv3_report *
  26. igmpv3_report_hdr(const struct sk_buff *skb)
  27. {
  28. return (struct igmpv3_report *)skb_transport_header(skb);
  29. }
  30. static inline struct igmpv3_query *
  31. igmpv3_query_hdr(const struct sk_buff *skb)
  32. {
  33. return (struct igmpv3_query *)skb_transport_header(skb);
  34. }
  35. extern int sysctl_igmp_max_memberships;
  36. extern int sysctl_igmp_max_msf;
  37. struct ip_sf_socklist {
  38. unsigned int sl_max;
  39. unsigned int sl_count;
  40. struct rcu_head rcu;
  41. __be32 sl_addr[0];
  42. };
  43. #define IP_SFLSIZE(count) (sizeof(struct ip_sf_socklist) + \
  44. (count) * sizeof(__be32))
  45. #define IP_SFBLOCK 10 /* allocate this many at once */
  46. /* ip_mc_socklist is real list now. Speed is not argument;
  47. this list never used in fast path code
  48. */
  49. struct ip_mc_socklist {
  50. struct ip_mc_socklist __rcu *next_rcu;
  51. struct ip_mreqn multi;
  52. unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
  53. struct ip_sf_socklist __rcu *sflist;
  54. struct rcu_head rcu;
  55. };
  56. struct ip_sf_list {
  57. struct ip_sf_list *sf_next;
  58. __be32 sf_inaddr;
  59. unsigned long sf_count[2]; /* include/exclude counts */
  60. unsigned char sf_gsresp; /* include in g & s response? */
  61. unsigned char sf_oldin; /* change state */
  62. unsigned char sf_crcount; /* retrans. left to send */
  63. };
  64. struct ip_mc_list {
  65. struct in_device *interface;
  66. __be32 multiaddr;
  67. unsigned int sfmode;
  68. struct ip_sf_list *sources;
  69. struct ip_sf_list *tomb;
  70. unsigned long sfcount[2];
  71. union {
  72. struct ip_mc_list *next;
  73. struct ip_mc_list __rcu *next_rcu;
  74. };
  75. struct ip_mc_list __rcu *next_hash;
  76. struct timer_list timer;
  77. int users;
  78. atomic_t refcnt;
  79. spinlock_t lock;
  80. char tm_running;
  81. char reporter;
  82. char unsolicit_count;
  83. char loaded;
  84. unsigned char gsquery; /* check source marks? */
  85. unsigned char crcount;
  86. struct rcu_head rcu;
  87. };
  88. /* V3 exponential field decoding */
  89. #define IGMPV3_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
  90. #define IGMPV3_EXP(thresh, nbmant, nbexp, value) \
  91. ((value) < (thresh) ? (value) : \
  92. ((IGMPV3_MASK(value, nbmant) | (1<<(nbmant))) << \
  93. (IGMPV3_MASK((value) >> (nbmant), nbexp) + (nbexp))))
  94. #define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
  95. #define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
  96. extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto);
  97. extern int igmp_rcv(struct sk_buff *);
  98. extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
  99. extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
  100. extern void ip_mc_drop_socket(struct sock *sk);
  101. extern int ip_mc_source(int add, int omode, struct sock *sk,
  102. struct ip_mreq_source *mreqs, int ifindex);
  103. extern int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf,int ifindex);
  104. extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
  105. struct ip_msfilter __user *optval, int __user *optlen);
  106. extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
  107. struct group_filter __user *optval, int __user *optlen);
  108. extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif);
  109. extern void ip_mc_init_dev(struct in_device *);
  110. extern void ip_mc_destroy_dev(struct in_device *);
  111. extern void ip_mc_up(struct in_device *);
  112. extern void ip_mc_down(struct in_device *);
  113. extern void ip_mc_unmap(struct in_device *);
  114. extern void ip_mc_remap(struct in_device *);
  115. extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
  116. extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
  117. extern void ip_mc_rejoin_groups(struct in_device *in_dev);
  118. #endif