blob: 8c7399dd06ca74b7cc1eb93d494f117eeff9c51f [file] [log] [blame]
Sven Eckelmann7db7d9f2017-11-19 15:05:11 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sven Eckelmannac79cbb2017-01-01 00:00:00 +01002/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00003 *
4 * Marek Lindner, Simon Wunderlich
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
Antonio Quartulliebf38fb2013-11-03 20:40:48 +010016 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000017 */
18
19#ifndef _NET_BATMAN_ADV_SEND_H_
20#define _NET_BATMAN_ADV_SEND_H_
21
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020022#include "main.h"
23
24#include <linux/compiler.h>
Linus Lüssing9b4aec62016-11-01 09:44:44 +010025#include <linux/spinlock.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020026#include <linux/types.h>
27
28#include "packet.h"
29
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020030struct sk_buff;
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020031
Sven Eckelmannbd687fe2016-07-17 21:04:00 +020032void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
33 bool dropped);
Linus Lüssinga65e5482016-06-20 21:39:54 +020034struct batadv_forw_packet *
35batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
36 struct batadv_hard_iface *if_outgoing,
37 atomic_t *queue_left,
Linus Lüssing99ba18e2017-02-17 11:17:06 +010038 struct batadv_priv *bat_priv,
39 struct sk_buff *skb);
Linus Lüssing9b4aec62016-11-01 09:44:44 +010040bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
41void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
42 struct batadv_forw_packet *forw_packet,
43 unsigned long send_time);
Linus Lüssinge2d9ba42017-02-17 11:17:07 +010044bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
Linus Lüssinga65e5482016-06-20 21:39:54 +020045
Martin Hundebølle91ecfc2013-04-20 13:54:39 +020046int batadv_send_skb_to_orig(struct sk_buff *skb,
47 struct batadv_orig_node *orig_node,
48 struct batadv_hard_iface *recv_if);
Antonio Quartulli95d39272016-01-16 16:40:15 +080049int batadv_send_skb_packet(struct sk_buff *skb,
50 struct batadv_hard_iface *hard_iface,
51 const u8 *dst_addr);
52int batadv_send_broadcast_skb(struct sk_buff *skb,
53 struct batadv_hard_iface *hard_iface);
54int batadv_send_unicast_skb(struct sk_buff *skb,
55 struct batadv_neigh_node *neigh_node);
Sven Eckelmann56303d32012-06-05 22:31:31 +020056int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
Sven Eckelmann9455e342012-05-12 02:09:37 +020057 const struct sk_buff *skb,
Linus Lüssing3111bee2016-08-07 12:34:19 +020058 unsigned long delay,
59 bool own_packet);
Sven Eckelmann56303d32012-06-05 22:31:31 +020060void
61batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
62 const struct batadv_hard_iface *hard_iface);
Martin Hundebøllf097e252013-05-23 16:53:01 +020063bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
64 struct sk_buff *skb,
65 struct batadv_orig_node *orig_node,
66 int packet_subtype);
Linus Lüssing1d8ab8d2014-02-15 17:47:52 +010067int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
68 struct sk_buff *skb, int packet_type,
69 int packet_subtype,
70 struct batadv_orig_node *orig_node,
71 unsigned short vid);
Linus Lüssinge300d312013-07-03 10:40:00 +020072int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
73 struct sk_buff *skb, int packet_type,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020074 int packet_subtype, u8 *dst_hint,
Antonio Quartulli6c413b12013-11-05 19:31:08 +010075 unsigned short vid);
Linus Lüssinge300d312013-07-03 10:40:00 +020076int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
77 unsigned short vid);
Martin Hundebøllf097e252013-05-23 16:53:01 +020078
79/**
Sven Eckelmann7e9a8c22017-12-02 19:51:47 +010080 * batadv_send_skb_via_tt() - send an skb via TT lookup
Martin Hundebøllf097e252013-05-23 16:53:01 +020081 * @bat_priv: the bat priv with all the soft interface information
82 * @skb: the payload to send
Antonio Quartullic5d3a652014-02-15 11:58:01 +010083 * @dst_hint: can be used to override the destination contained in the skb
Antonio Quartullic018ad32013-06-04 12:11:39 +020084 * @vid: the vid to be used to search the translation table
Martin Hundebøllf097e252013-05-23 16:53:01 +020085 *
Linus Lüssinge300d312013-07-03 10:40:00 +020086 * Look up the recipient node for the destination address in the ethernet
87 * header via the translation table. Wrap the given skb into a batman-adv
88 * unicast header. Then send this frame to the according destination node.
89 *
Sven Eckelmann62fe7102015-09-15 19:00:48 +020090 * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
Martin Hundebøllf097e252013-05-23 16:53:01 +020091 */
Linus Lüssinge300d312013-07-03 10:40:00 +020092static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020093 struct sk_buff *skb, u8 *dst_hint,
Linus Lüssinge300d312013-07-03 10:40:00 +020094 unsigned short vid)
Martin Hundebøllf097e252013-05-23 16:53:01 +020095{
Linus Lüssinge300d312013-07-03 10:40:00 +020096 return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
Antonio Quartulli6c413b12013-11-05 19:31:08 +010097 dst_hint, vid);
Martin Hundebøllf097e252013-05-23 16:53:01 +020098}
99
100/**
Sven Eckelmann7e9a8c22017-12-02 19:51:47 +0100101 * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
Martin Hundebøllf097e252013-05-23 16:53:01 +0200102 * @bat_priv: the bat priv with all the soft interface information
103 * @skb: the payload to send
104 * @packet_subtype: the unicast 4addr packet subtype to use
Antonio Quartullic5d3a652014-02-15 11:58:01 +0100105 * @dst_hint: can be used to override the destination contained in the skb
Antonio Quartullic018ad32013-06-04 12:11:39 +0200106 * @vid: the vid to be used to search the translation table
Martin Hundebøllf097e252013-05-23 16:53:01 +0200107 *
Linus Lüssinge300d312013-07-03 10:40:00 +0200108 * Look up the recipient node for the destination address in the ethernet
109 * header via the translation table. Wrap the given skb into a batman-adv
110 * unicast-4addr header. Then send this frame to the according destination
111 * node.
112 *
Sven Eckelmann62fe7102015-09-15 19:00:48 +0200113 * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
Martin Hundebøllf097e252013-05-23 16:53:01 +0200114 */
Linus Lüssinge300d312013-07-03 10:40:00 +0200115static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
116 struct sk_buff *skb,
117 int packet_subtype,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200118 u8 *dst_hint,
Linus Lüssinge300d312013-07-03 10:40:00 +0200119 unsigned short vid)
Martin Hundebøllf097e252013-05-23 16:53:01 +0200120{
Linus Lüssinge300d312013-07-03 10:40:00 +0200121 return batadv_send_skb_via_tt_generic(bat_priv, skb,
122 BATADV_UNICAST_4ADDR,
Antonio Quartulli6c413b12013-11-05 19:31:08 +0100123 packet_subtype, dst_hint, vid);
Martin Hundebøllf097e252013-05-23 16:53:01 +0200124}
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000125
126#endif /* _NET_BATMAN_ADV_SEND_H_ */