blob: 8aec818d0bf632f35cf79f0312ec9e14b0c0896c [file] [log] [blame]
Sven Eckelmann7db7d9f2017-11-19 15:05:11 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sven Eckelmanncfa55c62021-01-01 00:00:01 +01002/* Copyright (C) B.A.T.M.A.N. contributors:
Linus Lüssingc5caf4e2014-02-15 17:47:49 +01003 *
4 * Linus Lüssing
Linus Lüssingc5caf4e2014-02-15 17:47:49 +01005 */
6
7#ifndef _NET_BATMAN_ADV_MULTICAST_H_
8#define _NET_BATMAN_ADV_MULTICAST_H_
9
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020010#include "main.h"
11
Sven Eckelmann68a600d2019-05-24 20:11:17 +020012#include <linux/netlink.h>
Sven Eckelmann68a600d2019-05-24 20:11:17 +020013#include <linux/skbuff.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020014
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010015/**
Sven Eckelmann6f68b002015-09-06 21:38:49 +020016 * enum batadv_forw_mode - the way a packet should be forwarded as
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010017 */
18enum batadv_forw_mode {
Sven Eckelmann8b84cc42017-12-02 19:51:48 +010019 /**
20 * @BATADV_FORW_ALL: forward the packet to all nodes (currently via
21 * classic flooding)
22 */
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010023 BATADV_FORW_ALL,
Sven Eckelmann8b84cc42017-12-02 19:51:48 +010024
25 /**
Linus Lüssing32e72742019-03-23 05:47:41 +010026 * @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 /**
Sven Eckelmann8b84cc42017-12-02 19:51:48 +010033 * @BATADV_FORW_SINGLE: forward the packet to a single node (currently
34 * via the BATMAN unicast routing protocol)
35 */
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010036 BATADV_FORW_SINGLE,
Sven Eckelmann8b84cc42017-12-02 19:51:48 +010037
38 /** @BATADV_FORW_NONE: don't forward, drop it */
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010039 BATADV_FORW_NONE,
40};
41
Linus Lüssingc5caf4e2014-02-15 17:47:49 +010042#ifdef CONFIG_BATMAN_ADV_MCAST
43
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010044enum batadv_forw_mode
45batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
Linus Lüssing938f2e02022-01-01 06:27:13 +010046 struct batadv_orig_node **mcast_single_orig,
47 int *is_routable);
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010048
Linus Lüssing3236d212020-09-15 09:54:08 +020049int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
50 struct sk_buff *skb,
51 unsigned short vid,
52 struct batadv_orig_node *orig_node);
53
Linus Lüssing32e72742019-03-23 05:47:41 +010054int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
Linus Lüssing938f2e02022-01-01 06:27:13 +010055 unsigned short vid, int is_routable);
Linus Lüssing32e72742019-03-23 05:47:41 +010056
Linus Lüssing60432d72014-02-15 17:47:51 +010057void batadv_mcast_init(struct batadv_priv *bat_priv);
58
Linus Lüssing53dd9a62018-03-13 11:41:13 +010059int batadv_mcast_mesh_info_put(struct sk_buff *msg,
60 struct batadv_priv *bat_priv);
61
62int batadv_mcast_flags_dump(struct sk_buff *msg, struct netlink_callback *cb);
63
Linus Lüssingc5caf4e2014-02-15 17:47:49 +010064void batadv_mcast_free(struct batadv_priv *bat_priv);
65
Linus Lüssing60432d72014-02-15 17:47:51 +010066void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
67
Linus Lüssingc5caf4e2014-02-15 17:47:49 +010068#else
69
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010070static inline enum batadv_forw_mode
71batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
Linus Lüssing938f2e02022-01-01 06:27:13 +010072 struct batadv_orig_node **mcast_single_orig,
73 int *is_routable)
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010074{
75 return BATADV_FORW_ALL;
76}
77
Linus Lüssing32e72742019-03-23 05:47:41 +010078static inline int
Linus Lüssing3236d212020-09-15 09:54:08 +020079batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
80 struct sk_buff *skb,
81 unsigned short vid,
82 struct batadv_orig_node *orig_node)
83{
84 kfree_skb(skb);
85 return NET_XMIT_DROP;
86}
87
88static inline int
Linus Lüssing32e72742019-03-23 05:47:41 +010089batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
Linus Lüssing938f2e02022-01-01 06:27:13 +010090 unsigned short vid, int is_routable)
Linus Lüssing32e72742019-03-23 05:47:41 +010091{
92 kfree_skb(skb);
93 return NET_XMIT_DROP;
94}
95
Linus Lüssing60432d72014-02-15 17:47:51 +010096static inline int batadv_mcast_init(struct batadv_priv *bat_priv)
97{
98 return 0;
99}
100
Linus Lüssing53dd9a62018-03-13 11:41:13 +0100101static inline int
102batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv)
103{
104 return 0;
105}
106
107static inline int batadv_mcast_flags_dump(struct sk_buff *msg,
108 struct netlink_callback *cb)
109{
110 return -EOPNOTSUPP;
111}
112
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100113static inline void batadv_mcast_free(struct batadv_priv *bat_priv)
114{
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100115}
116
Linus Lüssing60432d72014-02-15 17:47:51 +0100117static inline void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node)
118{
Linus Lüssing60432d72014-02-15 17:47:51 +0100119}
120
Linus Lüssingc5caf4e2014-02-15 17:47:49 +0100121#endif /* CONFIG_BATMAN_ADV_MCAST */
122
123#endif /* _NET_BATMAN_ADV_MULTICAST_H_ */