igmp.h 4.1 KB

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