Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (C) B.A.T.M.A.N. contributors:
0003  *
0004  * Marek Lindner, Simon Wunderlich
0005  */
0006 
0007 #ifndef _NET_BATMAN_ADV_SEND_H_
0008 #define _NET_BATMAN_ADV_SEND_H_
0009 
0010 #include "main.h"
0011 
0012 #include <linux/compiler.h>
0013 #include <linux/skbuff.h>
0014 #include <linux/spinlock.h>
0015 #include <linux/types.h>
0016 #include <uapi/linux/batadv_packet.h>
0017 
0018 void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
0019                  bool dropped);
0020 struct batadv_forw_packet *
0021 batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
0022              struct batadv_hard_iface *if_outgoing,
0023              atomic_t *queue_left,
0024              struct batadv_priv *bat_priv,
0025              struct sk_buff *skb);
0026 bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
0027 void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
0028                     struct batadv_forw_packet *forw_packet,
0029                     unsigned long send_time);
0030 bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
0031 
0032 int batadv_send_skb_to_orig(struct sk_buff *skb,
0033                 struct batadv_orig_node *orig_node,
0034                 struct batadv_hard_iface *recv_if);
0035 int batadv_send_skb_packet(struct sk_buff *skb,
0036                struct batadv_hard_iface *hard_iface,
0037                const u8 *dst_addr);
0038 int batadv_send_broadcast_skb(struct sk_buff *skb,
0039                   struct batadv_hard_iface *hard_iface);
0040 int batadv_send_unicast_skb(struct sk_buff *skb,
0041                 struct batadv_neigh_node *neigh_node);
0042 int batadv_forw_bcast_packet(struct batadv_priv *bat_priv,
0043                  struct sk_buff *skb,
0044                  unsigned long delay,
0045                  bool own_packet);
0046 void batadv_send_bcast_packet(struct batadv_priv *bat_priv,
0047                   struct sk_buff *skb,
0048                   unsigned long delay,
0049                   bool own_packet);
0050 void
0051 batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
0052                  const struct batadv_hard_iface *hard_iface);
0053 bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
0054                        struct sk_buff *skb,
0055                        struct batadv_orig_node *orig_node,
0056                        int packet_subtype);
0057 int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
0058                 struct sk_buff *skb, int packet_type,
0059                 int packet_subtype,
0060                 struct batadv_orig_node *orig_node,
0061                 unsigned short vid);
0062 int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
0063                    struct sk_buff *skb, int packet_type,
0064                    int packet_subtype, u8 *dst_hint,
0065                    unsigned short vid);
0066 int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
0067                unsigned short vid);
0068 
0069 /**
0070  * batadv_send_skb_via_tt() - send an skb via TT lookup
0071  * @bat_priv: the bat priv with all the soft interface information
0072  * @skb: the payload to send
0073  * @dst_hint: can be used to override the destination contained in the skb
0074  * @vid: the vid to be used to search the translation table
0075  *
0076  * Look up the recipient node for the destination address in the ethernet
0077  * header via the translation table. Wrap the given skb into a batman-adv
0078  * unicast header. Then send this frame to the according destination node.
0079  *
0080  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
0081  */
0082 static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
0083                      struct sk_buff *skb, u8 *dst_hint,
0084                      unsigned short vid)
0085 {
0086     return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
0087                           dst_hint, vid);
0088 }
0089 
0090 /**
0091  * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
0092  * @bat_priv: the bat priv with all the soft interface information
0093  * @skb: the payload to send
0094  * @packet_subtype: the unicast 4addr packet subtype to use
0095  * @dst_hint: can be used to override the destination contained in the skb
0096  * @vid: the vid to be used to search the translation table
0097  *
0098  * Look up the recipient node for the destination address in the ethernet
0099  * header via the translation table. Wrap the given skb into a batman-adv
0100  * unicast-4addr header. Then send this frame to the according destination
0101  * node.
0102  *
0103  * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
0104  */
0105 static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
0106                            struct sk_buff *skb,
0107                            int packet_subtype,
0108                            u8 *dst_hint,
0109                            unsigned short vid)
0110 {
0111     return batadv_send_skb_via_tt_generic(bat_priv, skb,
0112                           BATADV_UNICAST_4ADDR,
0113                           packet_subtype, dst_hint, vid);
0114 }
0115 
0116 #endif /* _NET_BATMAN_ADV_SEND_H_ */