18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (C) 2007-2020  B.A.T.M.A.N. contributors:
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Marek Lindner, Simon Wunderlich
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _NET_BATMAN_ADV_SEND_H_
88c2ecf20Sopenharmony_ci#define _NET_BATMAN_ADV_SEND_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "main.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/compiler.h>
138c2ecf20Sopenharmony_ci#include <linux/skbuff.h>
148c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
158c2ecf20Sopenharmony_ci#include <linux/types.h>
168c2ecf20Sopenharmony_ci#include <uapi/linux/batadv_packet.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_civoid batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
198c2ecf20Sopenharmony_ci			     bool dropped);
208c2ecf20Sopenharmony_cistruct batadv_forw_packet *
218c2ecf20Sopenharmony_cibatadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
228c2ecf20Sopenharmony_ci			 struct batadv_hard_iface *if_outgoing,
238c2ecf20Sopenharmony_ci			 atomic_t *queue_left,
248c2ecf20Sopenharmony_ci			 struct batadv_priv *bat_priv,
258c2ecf20Sopenharmony_ci			 struct sk_buff *skb);
268c2ecf20Sopenharmony_cibool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
278c2ecf20Sopenharmony_civoid batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
288c2ecf20Sopenharmony_ci				    struct batadv_forw_packet *forw_packet,
298c2ecf20Sopenharmony_ci				    unsigned long send_time);
308c2ecf20Sopenharmony_cibool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciint batadv_send_skb_to_orig(struct sk_buff *skb,
338c2ecf20Sopenharmony_ci			    struct batadv_orig_node *orig_node,
348c2ecf20Sopenharmony_ci			    struct batadv_hard_iface *recv_if);
358c2ecf20Sopenharmony_ciint batadv_send_skb_packet(struct sk_buff *skb,
368c2ecf20Sopenharmony_ci			   struct batadv_hard_iface *hard_iface,
378c2ecf20Sopenharmony_ci			   const u8 *dst_addr);
388c2ecf20Sopenharmony_ciint batadv_send_broadcast_skb(struct sk_buff *skb,
398c2ecf20Sopenharmony_ci			      struct batadv_hard_iface *hard_iface);
408c2ecf20Sopenharmony_ciint batadv_send_unicast_skb(struct sk_buff *skb,
418c2ecf20Sopenharmony_ci			    struct batadv_neigh_node *neigh_node);
428c2ecf20Sopenharmony_ciint batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
438c2ecf20Sopenharmony_ci				    const struct sk_buff *skb,
448c2ecf20Sopenharmony_ci				    unsigned long delay,
458c2ecf20Sopenharmony_ci				    bool own_packet);
468c2ecf20Sopenharmony_civoid
478c2ecf20Sopenharmony_cibatadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
488c2ecf20Sopenharmony_ci				 const struct batadv_hard_iface *hard_iface);
498c2ecf20Sopenharmony_cibool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
508c2ecf20Sopenharmony_ci					   struct sk_buff *skb,
518c2ecf20Sopenharmony_ci					   struct batadv_orig_node *orig_node,
528c2ecf20Sopenharmony_ci					   int packet_subtype);
538c2ecf20Sopenharmony_ciint batadv_send_skb_unicast(struct batadv_priv *bat_priv,
548c2ecf20Sopenharmony_ci			    struct sk_buff *skb, int packet_type,
558c2ecf20Sopenharmony_ci			    int packet_subtype,
568c2ecf20Sopenharmony_ci			    struct batadv_orig_node *orig_node,
578c2ecf20Sopenharmony_ci			    unsigned short vid);
588c2ecf20Sopenharmony_ciint batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
598c2ecf20Sopenharmony_ci				   struct sk_buff *skb, int packet_type,
608c2ecf20Sopenharmony_ci				   int packet_subtype, u8 *dst_hint,
618c2ecf20Sopenharmony_ci				   unsigned short vid);
628c2ecf20Sopenharmony_ciint batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
638c2ecf20Sopenharmony_ci			   unsigned short vid);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/**
668c2ecf20Sopenharmony_ci * batadv_send_skb_via_tt() - send an skb via TT lookup
678c2ecf20Sopenharmony_ci * @bat_priv: the bat priv with all the soft interface information
688c2ecf20Sopenharmony_ci * @skb: the payload to send
698c2ecf20Sopenharmony_ci * @dst_hint: can be used to override the destination contained in the skb
708c2ecf20Sopenharmony_ci * @vid: the vid to be used to search the translation table
718c2ecf20Sopenharmony_ci *
728c2ecf20Sopenharmony_ci * Look up the recipient node for the destination address in the ethernet
738c2ecf20Sopenharmony_ci * header via the translation table. Wrap the given skb into a batman-adv
748c2ecf20Sopenharmony_ci * unicast header. Then send this frame to the according destination node.
758c2ecf20Sopenharmony_ci *
768c2ecf20Sopenharmony_ci * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
778c2ecf20Sopenharmony_ci */
788c2ecf20Sopenharmony_cistatic inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
798c2ecf20Sopenharmony_ci					 struct sk_buff *skb, u8 *dst_hint,
808c2ecf20Sopenharmony_ci					 unsigned short vid)
818c2ecf20Sopenharmony_ci{
828c2ecf20Sopenharmony_ci	return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
838c2ecf20Sopenharmony_ci					      dst_hint, vid);
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/**
878c2ecf20Sopenharmony_ci * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
888c2ecf20Sopenharmony_ci * @bat_priv: the bat priv with all the soft interface information
898c2ecf20Sopenharmony_ci * @skb: the payload to send
908c2ecf20Sopenharmony_ci * @packet_subtype: the unicast 4addr packet subtype to use
918c2ecf20Sopenharmony_ci * @dst_hint: can be used to override the destination contained in the skb
928c2ecf20Sopenharmony_ci * @vid: the vid to be used to search the translation table
938c2ecf20Sopenharmony_ci *
948c2ecf20Sopenharmony_ci * Look up the recipient node for the destination address in the ethernet
958c2ecf20Sopenharmony_ci * header via the translation table. Wrap the given skb into a batman-adv
968c2ecf20Sopenharmony_ci * unicast-4addr header. Then send this frame to the according destination
978c2ecf20Sopenharmony_ci * node.
988c2ecf20Sopenharmony_ci *
998c2ecf20Sopenharmony_ci * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_cistatic inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
1028c2ecf20Sopenharmony_ci					       struct sk_buff *skb,
1038c2ecf20Sopenharmony_ci					       int packet_subtype,
1048c2ecf20Sopenharmony_ci					       u8 *dst_hint,
1058c2ecf20Sopenharmony_ci					       unsigned short vid)
1068c2ecf20Sopenharmony_ci{
1078c2ecf20Sopenharmony_ci	return batadv_send_skb_via_tt_generic(bat_priv, skb,
1088c2ecf20Sopenharmony_ci					      BATADV_UNICAST_4ADDR,
1098c2ecf20Sopenharmony_ci					      packet_subtype, dst_hint, vid);
1108c2ecf20Sopenharmony_ci}
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#endif /* _NET_BATMAN_ADV_SEND_H_ */
113