multicast.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2014-2020 B.A.T.M.A.N. contributors:
  3. *
  4. * Linus Lüssing
  5. */
  6. #ifndef _NET_BATMAN_ADV_MULTICAST_H_
  7. #define _NET_BATMAN_ADV_MULTICAST_H_
  8. #include "main.h"
  9. #include <linux/netlink.h>
  10. #include <linux/seq_file.h>
  11. #include <linux/skbuff.h>
  12. /**
  13. * enum batadv_forw_mode - the way a packet should be forwarded as
  14. */
  15. enum batadv_forw_mode {
  16. /**
  17. * @BATADV_FORW_ALL: forward the packet to all nodes (currently via
  18. * classic flooding)
  19. */
  20. BATADV_FORW_ALL,
  21. /**
  22. * @BATADV_FORW_SOME: forward the packet to some nodes (currently via
  23. * a multicast-to-unicast conversion and the BATMAN unicast routing
  24. * protocol)
  25. */
  26. BATADV_FORW_SOME,
  27. /**
  28. * @BATADV_FORW_SINGLE: forward the packet to a single node (currently
  29. * via the BATMAN unicast routing protocol)
  30. */
  31. BATADV_FORW_SINGLE,
  32. /** @BATADV_FORW_NONE: don't forward, drop it */
  33. BATADV_FORW_NONE,
  34. };
  35. #ifdef CONFIG_BATMAN_ADV_MCAST
  36. enum batadv_forw_mode
  37. batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
  38. struct batadv_orig_node **mcast_single_orig,
  39. int *is_routable);
  40. int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
  41. struct sk_buff *skb,
  42. unsigned short vid,
  43. struct batadv_orig_node *orig_node);
  44. int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
  45. unsigned short vid, int is_routable);
  46. void batadv_mcast_init(struct batadv_priv *bat_priv);
  47. int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset);
  48. int batadv_mcast_mesh_info_put(struct sk_buff *msg,
  49. struct batadv_priv *bat_priv);
  50. int batadv_mcast_flags_dump(struct sk_buff *msg, struct netlink_callback *cb);
  51. void batadv_mcast_free(struct batadv_priv *bat_priv);
  52. void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
  53. #else
  54. static inline enum batadv_forw_mode
  55. batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
  56. struct batadv_orig_node **mcast_single_orig,
  57. int *is_routable)
  58. {
  59. return BATADV_FORW_ALL;
  60. }
  61. static inline int
  62. batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
  63. struct sk_buff *skb,
  64. unsigned short vid,
  65. struct batadv_orig_node *orig_node)
  66. {
  67. kfree_skb(skb);
  68. return NET_XMIT_DROP;
  69. }
  70. static inline int
  71. batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
  72. unsigned short vid, int is_routable)
  73. {
  74. kfree_skb(skb);
  75. return NET_XMIT_DROP;
  76. }
  77. static inline int batadv_mcast_init(struct batadv_priv *bat_priv)
  78. {
  79. return 0;
  80. }
  81. static inline int
  82. batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv)
  83. {
  84. return 0;
  85. }
  86. static inline int batadv_mcast_flags_dump(struct sk_buff *msg,
  87. struct netlink_callback *cb)
  88. {
  89. return -EOPNOTSUPP;
  90. }
  91. static inline void batadv_mcast_free(struct batadv_priv *bat_priv)
  92. {
  93. }
  94. static inline void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node)
  95. {
  96. }
  97. #endif /* CONFIG_BATMAN_ADV_MCAST */
  98. #endif /* _NET_BATMAN_ADV_MULTICAST_H_ */