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_BCAST: forward the packet to all nodes via a batman-adv
21 	 *  broadcast packet
22 	 */
23 	BATADV_FORW_BCAST,
24 
25 	/**
26 	 * @BATADV_FORW_UCASTS: forward the packet to some nodes via one
27 	 *  or more batman-adv unicast packets
28 	 */
29 	BATADV_FORW_UCASTS,
30 
31 	/** @BATADV_FORW_NONE: don't forward, drop it */
32 	BATADV_FORW_NONE,
33 };
34 
35 #ifdef CONFIG_BATMAN_ADV_MCAST
36 
37 enum batadv_forw_mode
38 batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
39 		       int *is_routable);
40 
41 int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
42 			   unsigned short vid, int is_routable);
43 
44 void batadv_mcast_init(struct batadv_priv *bat_priv);
45 
46 int batadv_mcast_mesh_info_put(struct sk_buff *msg,
47 			       struct batadv_priv *bat_priv);
48 
49 int batadv_mcast_flags_dump(struct sk_buff *msg, struct netlink_callback *cb);
50 
51 void batadv_mcast_free(struct batadv_priv *bat_priv);
52 
53 void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
54 
55 #else
56 
57 static inline enum batadv_forw_mode
batadv_mcast_forw_mode(struct batadv_priv * bat_priv,struct sk_buff * skb,int * is_routable)58 batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
59 		       int *is_routable)
60 {
61 	return BATADV_FORW_BCAST;
62 }
63 
64 static inline int
batadv_mcast_forw_send(struct batadv_priv * bat_priv,struct sk_buff * skb,unsigned short vid,int is_routable)65 batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
66 		       unsigned short vid, int is_routable)
67 {
68 	kfree_skb(skb);
69 	return NET_XMIT_DROP;
70 }
71 
batadv_mcast_init(struct batadv_priv * bat_priv)72 static inline int batadv_mcast_init(struct batadv_priv *bat_priv)
73 {
74 	return 0;
75 }
76 
77 static inline int
batadv_mcast_mesh_info_put(struct sk_buff * msg,struct batadv_priv * bat_priv)78 batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv)
79 {
80 	return 0;
81 }
82 
batadv_mcast_flags_dump(struct sk_buff * msg,struct netlink_callback * cb)83 static inline int batadv_mcast_flags_dump(struct sk_buff *msg,
84 					  struct netlink_callback *cb)
85 {
86 	return -EOPNOTSUPP;
87 }
88 
batadv_mcast_free(struct batadv_priv * bat_priv)89 static inline void batadv_mcast_free(struct batadv_priv *bat_priv)
90 {
91 }
92 
batadv_mcast_purge_orig(struct batadv_orig_node * orig_node)93 static inline void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node)
94 {
95 }
96 
97 #endif /* CONFIG_BATMAN_ADV_MCAST */
98 
99 #endif /* _NET_BATMAN_ADV_MULTICAST_H_ */
100