xref: /linux/net/batman-adv/send.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
17db7d9f3SSven Eckelmann /* SPDX-License-Identifier: GPL-2.0 */
2cfa55c6dSSven Eckelmann /* Copyright (C) B.A.T.M.A.N. contributors:
3c6c8fea2SSven Eckelmann  *
4c6c8fea2SSven Eckelmann  * Marek Lindner, Simon Wunderlich
5c6c8fea2SSven Eckelmann  */
6c6c8fea2SSven Eckelmann 
7c6c8fea2SSven Eckelmann #ifndef _NET_BATMAN_ADV_SEND_H_
8c6c8fea2SSven Eckelmann #define _NET_BATMAN_ADV_SEND_H_
9c6c8fea2SSven Eckelmann 
101e2c2a4fSSven Eckelmann #include "main.h"
111e2c2a4fSSven Eckelmann 
121e2c2a4fSSven Eckelmann #include <linux/compiler.h>
1368a600deSSven Eckelmann #include <linux/skbuff.h>
149b4aec64SLinus Lüssing #include <linux/spinlock.h>
151e2c2a4fSSven Eckelmann #include <linux/types.h>
16fec149f5SSven Eckelmann #include <uapi/linux/batadv_packet.h>
171e2c2a4fSSven Eckelmann 
18bd687fe4SSven Eckelmann void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
19bd687fe4SSven Eckelmann 			     bool dropped);
20a65e5481SLinus Lüssing struct batadv_forw_packet *
21a65e5481SLinus Lüssing batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
22a65e5481SLinus Lüssing 			 struct batadv_hard_iface *if_outgoing,
23a65e5481SLinus Lüssing 			 atomic_t *queue_left,
2499ba18efSLinus Lüssing 			 struct batadv_priv *bat_priv,
2599ba18efSLinus Lüssing 			 struct sk_buff *skb);
269b4aec64SLinus Lüssing bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
279b4aec64SLinus Lüssing void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
289b4aec64SLinus Lüssing 				    struct batadv_forw_packet *forw_packet,
299b4aec64SLinus Lüssing 				    unsigned long send_time);
30e2d9ba43SLinus Lüssing bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
31a65e5481SLinus Lüssing 
32e91ecfc6SMartin Hundebøll int batadv_send_skb_to_orig(struct sk_buff *skb,
33bb351ba0SMartin Hundebøll 			    struct batadv_orig_node *orig_node,
34bb351ba0SMartin Hundebøll 			    struct batadv_hard_iface *recv_if);
3595d39278SAntonio Quartulli int batadv_send_skb_packet(struct sk_buff *skb,
3695d39278SAntonio Quartulli 			   struct batadv_hard_iface *hard_iface,
3795d39278SAntonio Quartulli 			   const u8 *dst_addr);
3895d39278SAntonio Quartulli int batadv_send_broadcast_skb(struct sk_buff *skb,
3995d39278SAntonio Quartulli 			      struct batadv_hard_iface *hard_iface);
4095d39278SAntonio Quartulli int batadv_send_unicast_skb(struct sk_buff *skb,
4195d39278SAntonio Quartulli 			    struct batadv_neigh_node *neigh_node);
42*3f693390SLinus Lüssing int batadv_forw_bcast_packet(struct batadv_priv *bat_priv,
43*3f693390SLinus Lüssing 			     struct sk_buff *skb,
44*3f693390SLinus Lüssing 			     unsigned long delay,
45*3f693390SLinus Lüssing 			     bool own_packet);
46*3f693390SLinus Lüssing void batadv_send_bcast_packet(struct batadv_priv *bat_priv,
47*3f693390SLinus Lüssing 			      struct sk_buff *skb,
483111beedSLinus Lüssing 			      unsigned long delay,
493111beedSLinus Lüssing 			      bool own_packet);
5056303d34SSven Eckelmann void
5156303d34SSven Eckelmann batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
5256303d34SSven Eckelmann 				 const struct batadv_hard_iface *hard_iface);
53f097e25dSMartin Hundebøll bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
54f097e25dSMartin Hundebøll 					   struct sk_buff *skb,
55f097e25dSMartin Hundebøll 					   struct batadv_orig_node *orig_node,
56f097e25dSMartin Hundebøll 					   int packet_subtype);
571d8ab8d3SLinus Lüssing int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
581d8ab8d3SLinus Lüssing 			    struct sk_buff *skb, int packet_type,
591d8ab8d3SLinus Lüssing 			    int packet_subtype,
601d8ab8d3SLinus Lüssing 			    struct batadv_orig_node *orig_node,
611d8ab8d3SLinus Lüssing 			    unsigned short vid);
62e300d314SLinus Lüssing int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
63f097e25dSMartin Hundebøll 				   struct sk_buff *skb, int packet_type,
646b5e971aSSven Eckelmann 				   int packet_subtype, u8 *dst_hint,
656c413b1cSAntonio Quartulli 				   unsigned short vid);
66e300d314SLinus Lüssing int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
67c018ad3dSAntonio Quartulli 			   unsigned short vid);
68f097e25dSMartin Hundebøll 
69f097e25dSMartin Hundebøll /**
707e9a8c2cSSven Eckelmann  * batadv_send_skb_via_tt() - send an skb via TT lookup
71f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
72f097e25dSMartin Hundebøll  * @skb: the payload to send
73c5d3a652SAntonio Quartulli  * @dst_hint: can be used to override the destination contained in the skb
74c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
75f097e25dSMartin Hundebøll  *
76e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
77e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
78e300d314SLinus Lüssing  * unicast header. Then send this frame to the according destination node.
79e300d314SLinus Lüssing  *
8062fe710fSSven Eckelmann  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
81f097e25dSMartin Hundebøll  */
batadv_send_skb_via_tt(struct batadv_priv * bat_priv,struct sk_buff * skb,u8 * dst_hint,unsigned short vid)82e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
836b5e971aSSven Eckelmann 					 struct sk_buff *skb, u8 *dst_hint,
84c018ad3dSAntonio Quartulli 					 unsigned short vid)
85f097e25dSMartin Hundebøll {
86e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
876c413b1cSAntonio Quartulli 					      dst_hint, vid);
88f097e25dSMartin Hundebøll }
89f097e25dSMartin Hundebøll 
90f097e25dSMartin Hundebøll /**
917e9a8c2cSSven Eckelmann  * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
92f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
93f097e25dSMartin Hundebøll  * @skb: the payload to send
94f097e25dSMartin Hundebøll  * @packet_subtype: the unicast 4addr packet subtype to use
95c5d3a652SAntonio Quartulli  * @dst_hint: can be used to override the destination contained in the skb
96c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
97f097e25dSMartin Hundebøll  *
98e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
99e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
100e300d314SLinus Lüssing  * unicast-4addr header. Then send this frame to the according destination
101e300d314SLinus Lüssing  * node.
102e300d314SLinus Lüssing  *
10362fe710fSSven Eckelmann  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
104f097e25dSMartin Hundebøll  */
batadv_send_skb_via_tt_4addr(struct batadv_priv * bat_priv,struct sk_buff * skb,int packet_subtype,u8 * dst_hint,unsigned short vid)105e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
106f097e25dSMartin Hundebøll 					       struct sk_buff *skb,
107c018ad3dSAntonio Quartulli 					       int packet_subtype,
1086b5e971aSSven Eckelmann 					       u8 *dst_hint,
109c018ad3dSAntonio Quartulli 					       unsigned short vid)
110f097e25dSMartin Hundebøll {
111e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb,
112f097e25dSMartin Hundebøll 					      BATADV_UNICAST_4ADDR,
1136c413b1cSAntonio Quartulli 					      packet_subtype, dst_hint, vid);
114f097e25dSMartin Hundebøll }
115c6c8fea2SSven Eckelmann 
116c6c8fea2SSven Eckelmann #endif /* _NET_BATMAN_ADV_SEND_H_ */
117