1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
4 * Marek Lindner, Simon Wunderlich
7 #ifndef _NET_BATMAN_ADV_SEND_H_
8 #define _NET_BATMAN_ADV_SEND_H_
12 #include <linux/compiler.h>
13 #include <linux/spinlock.h>
14 #include <linux/types.h>
15 #include <uapi/linux/batadv_packet.h>
19 void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
21 struct batadv_forw_packet *
22 batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
23 struct batadv_hard_iface *if_outgoing,
25 struct batadv_priv *bat_priv,
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);
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,
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,
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,
52 struct batadv_orig_node *orig_node,
54 int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
55 struct sk_buff *skb, int packet_type,
57 struct batadv_orig_node *orig_node,
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,
63 int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
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
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.
77 * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
79 static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
80 struct sk_buff *skb, u8 *dst_hint,
83 return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
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
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
100 * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
102 static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
108 return batadv_send_skb_via_tt_generic(bat_priv, skb,
109 BATADV_UNICAST_4ADDR,
110 packet_subtype, dst_hint, vid);
113 #endif /* _NET_BATMAN_ADV_SEND_H_ */