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