Merge tag 'armsoc-defconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[platform/kernel/linux-starfive.git] / net / batman-adv / send.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2007-2019  B.A.T.M.A.N. contributors:
3  *
4  * Marek Lindner, Simon Wunderlich
5  */
6
7 #ifndef _NET_BATMAN_ADV_SEND_H_
8 #define _NET_BATMAN_ADV_SEND_H_
9
10 #include "main.h"
11
12 #include <linux/compiler.h>
13 #include <linux/spinlock.h>
14 #include <linux/types.h>
15 #include <uapi/linux/batadv_packet.h>
16
17 struct sk_buff;
18
19 void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
20                              bool dropped);
21 struct batadv_forw_packet *
22 batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
23                          struct batadv_hard_iface *if_outgoing,
24                          atomic_t *queue_left,
25                          struct batadv_priv *bat_priv,
26                          struct sk_buff *skb);
27 bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
28 void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
29                                     struct batadv_forw_packet *forw_packet,
30                                     unsigned long send_time);
31 bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
32
33 int batadv_send_skb_to_orig(struct sk_buff *skb,
34                             struct batadv_orig_node *orig_node,
35                             struct batadv_hard_iface *recv_if);
36 int batadv_send_skb_packet(struct sk_buff *skb,
37                            struct batadv_hard_iface *hard_iface,
38                            const u8 *dst_addr);
39 int batadv_send_broadcast_skb(struct sk_buff *skb,
40                               struct batadv_hard_iface *hard_iface);
41 int batadv_send_unicast_skb(struct sk_buff *skb,
42                             struct batadv_neigh_node *neigh_node);
43 int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
44                                     const struct sk_buff *skb,
45                                     unsigned long delay,
46                                     bool own_packet);
47 void
48 batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
49                                  const struct batadv_hard_iface *hard_iface);
50 bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
51                                            struct sk_buff *skb,
52                                            struct batadv_orig_node *orig_node,
53                                            int packet_subtype);
54 int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
55                             struct sk_buff *skb, int packet_type,
56                             int packet_subtype,
57                             struct batadv_orig_node *orig_node,
58                             unsigned short vid);
59 int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
60                                    struct sk_buff *skb, int packet_type,
61                                    int packet_subtype, u8 *dst_hint,
62                                    unsigned short vid);
63 int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
64                            unsigned short vid);
65
66 /**
67  * batadv_send_skb_via_tt() - send an skb via TT lookup
68  * @bat_priv: the bat priv with all the soft interface information
69  * @skb: the payload to send
70  * @dst_hint: can be used to override the destination contained in the skb
71  * @vid: the vid to be used to search the translation table
72  *
73  * Look up the recipient node for the destination address in the ethernet
74  * header via the translation table. Wrap the given skb into a batman-adv
75  * unicast header. Then send this frame to the according destination node.
76  *
77  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
78  */
79 static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
80                                          struct sk_buff *skb, u8 *dst_hint,
81                                          unsigned short vid)
82 {
83         return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
84                                               dst_hint, vid);
85 }
86
87 /**
88  * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
89  * @bat_priv: the bat priv with all the soft interface information
90  * @skb: the payload to send
91  * @packet_subtype: the unicast 4addr packet subtype to use
92  * @dst_hint: can be used to override the destination contained in the skb
93  * @vid: the vid to be used to search the translation table
94  *
95  * Look up the recipient node for the destination address in the ethernet
96  * header via the translation table. Wrap the given skb into a batman-adv
97  * unicast-4addr header. Then send this frame to the according destination
98  * node.
99  *
100  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
101  */
102 static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
103                                                struct sk_buff *skb,
104                                                int packet_subtype,
105                                                u8 *dst_hint,
106                                                unsigned short vid)
107 {
108         return batadv_send_skb_via_tt_generic(bat_priv, skb,
109                                               BATADV_UNICAST_4ADDR,
110                                               packet_subtype, dst_hint, vid);
111 }
112
113 #endif /* _NET_BATMAN_ADV_SEND_H_ */