Sven Eckelmann | 7db7d9f | 2017-11-19 15:05:11 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Sven Eckelmann | cfa55c6 | 2021-01-01 00:00:01 +0100 | [diff] [blame] | 2 | /* Copyright (C) B.A.T.M.A.N. contributors: |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 3 | * |
| 4 | * Linus Lüssing |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _NET_BATMAN_ADV_MULTICAST_H_ |
| 8 | #define _NET_BATMAN_ADV_MULTICAST_H_ |
| 9 | |
Sven Eckelmann | 1e2c2a4 | 2015-04-17 19:40:28 +0200 | [diff] [blame] | 10 | #include "main.h" |
| 11 | |
Sven Eckelmann | 68a600d | 2019-05-24 20:11:17 +0200 | [diff] [blame] | 12 | #include <linux/netlink.h> |
Sven Eckelmann | 68a600d | 2019-05-24 20:11:17 +0200 | [diff] [blame] | 13 | #include <linux/skbuff.h> |
Sven Eckelmann | 1e2c2a4 | 2015-04-17 19:40:28 +0200 | [diff] [blame] | 14 | |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 15 | /** |
Sven Eckelmann | 6f68b00 | 2015-09-06 21:38:49 +0200 | [diff] [blame] | 16 | * enum batadv_forw_mode - the way a packet should be forwarded as |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 17 | */ |
| 18 | enum batadv_forw_mode { |
Sven Eckelmann | 8b84cc4 | 2017-12-02 19:51:48 +0100 | [diff] [blame] | 19 | /** |
| 20 | * @BATADV_FORW_ALL: forward the packet to all nodes (currently via |
| 21 | * classic flooding) |
| 22 | */ |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 23 | BATADV_FORW_ALL, |
Sven Eckelmann | 8b84cc4 | 2017-12-02 19:51:48 +0100 | [diff] [blame] | 24 | |
| 25 | /** |
Linus Lüssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 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 | /** |
Sven Eckelmann | 8b84cc4 | 2017-12-02 19:51:48 +0100 | [diff] [blame] | 33 | * @BATADV_FORW_SINGLE: forward the packet to a single node (currently |
| 34 | * via the BATMAN unicast routing protocol) |
| 35 | */ |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 36 | BATADV_FORW_SINGLE, |
Sven Eckelmann | 8b84cc4 | 2017-12-02 19:51:48 +0100 | [diff] [blame] | 37 | |
| 38 | /** @BATADV_FORW_NONE: don't forward, drop it */ |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 39 | BATADV_FORW_NONE, |
| 40 | }; |
| 41 | |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 42 | #ifdef CONFIG_BATMAN_ADV_MCAST |
| 43 | |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 44 | enum batadv_forw_mode |
| 45 | batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, |
Linus Lüssing | 938f2e0 | 2022-01-01 06:27:13 +0100 | [diff] [blame] | 46 | struct batadv_orig_node **mcast_single_orig, |
| 47 | int *is_routable); |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 48 | |
Linus Lüssing | 3236d21 | 2020-09-15 09:54:08 +0200 | [diff] [blame] | 49 | int 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üssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 54 | int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, |
Linus Lüssing | 938f2e0 | 2022-01-01 06:27:13 +0100 | [diff] [blame] | 55 | unsigned short vid, int is_routable); |
Linus Lüssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 56 | |
Linus Lüssing | 60432d7 | 2014-02-15 17:47:51 +0100 | [diff] [blame] | 57 | void batadv_mcast_init(struct batadv_priv *bat_priv); |
| 58 | |
Linus Lüssing | 53dd9a6 | 2018-03-13 11:41:13 +0100 | [diff] [blame] | 59 | int batadv_mcast_mesh_info_put(struct sk_buff *msg, |
| 60 | struct batadv_priv *bat_priv); |
| 61 | |
| 62 | int batadv_mcast_flags_dump(struct sk_buff *msg, struct netlink_callback *cb); |
| 63 | |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 64 | void batadv_mcast_free(struct batadv_priv *bat_priv); |
| 65 | |
Linus Lüssing | 60432d7 | 2014-02-15 17:47:51 +0100 | [diff] [blame] | 66 | void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node); |
| 67 | |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 68 | #else |
| 69 | |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 70 | static inline enum batadv_forw_mode |
| 71 | batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, |
Linus Lüssing | 938f2e0 | 2022-01-01 06:27:13 +0100 | [diff] [blame] | 72 | struct batadv_orig_node **mcast_single_orig, |
| 73 | int *is_routable) |
Linus Lüssing | 1d8ab8d | 2014-02-15 17:47:52 +0100 | [diff] [blame] | 74 | { |
| 75 | return BATADV_FORW_ALL; |
| 76 | } |
| 77 | |
Linus Lüssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 78 | static inline int |
Linus Lüssing | 3236d21 | 2020-09-15 09:54:08 +0200 | [diff] [blame] | 79 | batadv_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 | |
| 88 | static inline int |
Linus Lüssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 89 | batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, |
Linus Lüssing | 938f2e0 | 2022-01-01 06:27:13 +0100 | [diff] [blame] | 90 | unsigned short vid, int is_routable) |
Linus Lüssing | 32e7274 | 2019-03-23 05:47:41 +0100 | [diff] [blame] | 91 | { |
| 92 | kfree_skb(skb); |
| 93 | return NET_XMIT_DROP; |
| 94 | } |
| 95 | |
Linus Lüssing | 60432d7 | 2014-02-15 17:47:51 +0100 | [diff] [blame] | 96 | static inline int batadv_mcast_init(struct batadv_priv *bat_priv) |
| 97 | { |
| 98 | return 0; |
| 99 | } |
| 100 | |
Linus Lüssing | 53dd9a6 | 2018-03-13 11:41:13 +0100 | [diff] [blame] | 101 | static inline int |
| 102 | batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv) |
| 103 | { |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static inline int batadv_mcast_flags_dump(struct sk_buff *msg, |
| 108 | struct netlink_callback *cb) |
| 109 | { |
| 110 | return -EOPNOTSUPP; |
| 111 | } |
| 112 | |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 113 | static inline void batadv_mcast_free(struct batadv_priv *bat_priv) |
| 114 | { |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 115 | } |
| 116 | |
Linus Lüssing | 60432d7 | 2014-02-15 17:47:51 +0100 | [diff] [blame] | 117 | static inline void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node) |
| 118 | { |
Linus Lüssing | 60432d7 | 2014-02-15 17:47:51 +0100 | [diff] [blame] | 119 | } |
| 120 | |
Linus Lüssing | c5caf4e | 2014-02-15 17:47:49 +0100 | [diff] [blame] | 121 | #endif /* CONFIG_BATMAN_ADV_MCAST */ |
| 122 | |
| 123 | #endif /* _NET_BATMAN_ADV_MULTICAST_H_ */ |