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 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/seq_file.h> 14#include <linux/skbuff.h> 15 16/** 17 * enum batadv_forw_mode - the way a packet should be forwarded as 18 */ 19enum batadv_forw_mode { 20 /** 21 * @BATADV_FORW_ALL: forward the packet to all nodes (currently via 22 * classic flooding) 23 */ 24 BATADV_FORW_ALL, 25 26 /** 27 * @BATADV_FORW_SOME: forward the packet to some nodes (currently via 28 * a multicast-to-unicast conversion and the BATMAN unicast routing 29 * protocol) 30 */ 31 BATADV_FORW_SOME, 32 33 /** 34 * @BATADV_FORW_SINGLE: forward the packet to a single node (currently 35 * via the BATMAN unicast routing protocol) 36 */ 37 BATADV_FORW_SINGLE, 38 39 /** @BATADV_FORW_NONE: don't forward, drop it */ 40 BATADV_FORW_NONE, 41}; 42 43#ifdef CONFIG_BATMAN_ADV_MCAST 44 45enum batadv_forw_mode 46batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, 47 struct batadv_orig_node **mcast_single_orig, 48 int *is_routable); 49 50int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, 51 struct sk_buff *skb, 52 unsigned short vid, 53 struct batadv_orig_node *orig_node); 54 55int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, 56 unsigned short vid, int is_routable); 57 58void batadv_mcast_init(struct batadv_priv *bat_priv); 59 60int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset); 61 62int batadv_mcast_mesh_info_put(struct sk_buff *msg, 63 struct batadv_priv *bat_priv); 64 65int batadv_mcast_flags_dump(struct sk_buff *msg, struct netlink_callback *cb); 66 67void batadv_mcast_free(struct batadv_priv *bat_priv); 68 69void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node); 70 71#else 72 73static inline enum batadv_forw_mode 74batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, 75 struct batadv_orig_node **mcast_single_orig, 76 int *is_routable) 77{ 78 return BATADV_FORW_ALL; 79} 80 81static inline int 82batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv, 83 struct sk_buff *skb, 84 unsigned short vid, 85 struct batadv_orig_node *orig_node) 86{ 87 kfree_skb(skb); 88 return NET_XMIT_DROP; 89} 90 91static inline int 92batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, 93 unsigned short vid, int is_routable) 94{ 95 kfree_skb(skb); 96 return NET_XMIT_DROP; 97} 98 99static inline int batadv_mcast_init(struct batadv_priv *bat_priv) 100{ 101 return 0; 102} 103 104static inline int 105batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv) 106{ 107 return 0; 108} 109 110static inline int batadv_mcast_flags_dump(struct sk_buff *msg, 111 struct netlink_callback *cb) 112{ 113 return -EOPNOTSUPP; 114} 115 116static inline void batadv_mcast_free(struct batadv_priv *bat_priv) 117{ 118} 119 120static inline void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node) 121{ 122} 123 124#endif /* CONFIG_BATMAN_ADV_MCAST */ 125 126#endif /* _NET_BATMAN_ADV_MULTICAST_H_ */ 127