xref: /linux/net/batman-adv/send.h (revision ebf38fb7ab18ba60460bbd03de760ad5a2f435eb)
10b873931SAntonio Quartulli /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
2c6c8fea2SSven Eckelmann  *
3c6c8fea2SSven Eckelmann  * Marek Lindner, Simon Wunderlich
4c6c8fea2SSven Eckelmann  *
5c6c8fea2SSven Eckelmann  * This program is free software; you can redistribute it and/or
6c6c8fea2SSven Eckelmann  * modify it under the terms of version 2 of the GNU General Public
7c6c8fea2SSven Eckelmann  * License as published by the Free Software Foundation.
8c6c8fea2SSven Eckelmann  *
9c6c8fea2SSven Eckelmann  * This program is distributed in the hope that it will be useful, but
10c6c8fea2SSven Eckelmann  * WITHOUT ANY WARRANTY; without even the implied warranty of
11c6c8fea2SSven Eckelmann  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12c6c8fea2SSven Eckelmann  * General Public License for more details.
13c6c8fea2SSven Eckelmann  *
14c6c8fea2SSven Eckelmann  * You should have received a copy of the GNU General Public License
15*ebf38fb7SAntonio Quartulli  * along with this program; if not, see <http://www.gnu.org/licenses/>.
16c6c8fea2SSven Eckelmann  */
17c6c8fea2SSven Eckelmann 
18c6c8fea2SSven Eckelmann #ifndef _NET_BATMAN_ADV_SEND_H_
19c6c8fea2SSven Eckelmann #define _NET_BATMAN_ADV_SEND_H_
20c6c8fea2SSven Eckelmann 
2156303d34SSven Eckelmann int batadv_send_skb_packet(struct sk_buff *skb,
2256303d34SSven Eckelmann 			   struct batadv_hard_iface *hard_iface,
23747e4221SSven Eckelmann 			   const uint8_t *dst_addr);
24e91ecfc6SMartin Hundebøll int batadv_send_skb_to_orig(struct sk_buff *skb,
25bb351ba0SMartin Hundebøll 			    struct batadv_orig_node *orig_node,
26bb351ba0SMartin Hundebøll 			    struct batadv_hard_iface *recv_if);
2756303d34SSven Eckelmann void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface);
2856303d34SSven Eckelmann int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
299455e34cSSven Eckelmann 				    const struct sk_buff *skb,
309455e34cSSven Eckelmann 				    unsigned long delay);
319455e34cSSven Eckelmann void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work);
3256303d34SSven Eckelmann void
3356303d34SSven Eckelmann batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
3456303d34SSven Eckelmann 				 const struct batadv_hard_iface *hard_iface);
35f097e25dSMartin Hundebøll bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
36f097e25dSMartin Hundebøll 					   struct sk_buff *skb,
37f097e25dSMartin Hundebøll 					   struct batadv_orig_node *orig_node,
38f097e25dSMartin Hundebøll 					   int packet_subtype);
39e300d314SLinus Lüssing int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
40f097e25dSMartin Hundebøll 				   struct sk_buff *skb, int packet_type,
41e300d314SLinus Lüssing 				   int packet_subtype, unsigned short vid);
42e300d314SLinus Lüssing int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
43c018ad3dSAntonio Quartulli 			   unsigned short vid);
44f097e25dSMartin Hundebøll 
45f097e25dSMartin Hundebøll /**
46e300d314SLinus Lüssing  * batadv_send_skb_via_tt - send an skb via TT lookup
47f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
48f097e25dSMartin Hundebøll  * @skb: the payload to send
49c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
50f097e25dSMartin Hundebøll  *
51e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
52e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
53e300d314SLinus Lüssing  * unicast header. Then send this frame to the according destination node.
54e300d314SLinus Lüssing  *
55e300d314SLinus Lüssing  * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
56f097e25dSMartin Hundebøll  */
57e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
58c018ad3dSAntonio Quartulli 					 struct sk_buff *skb,
59c018ad3dSAntonio Quartulli 					 unsigned short vid)
60f097e25dSMartin Hundebøll {
61e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
62e300d314SLinus Lüssing 					      vid);
63f097e25dSMartin Hundebøll }
64f097e25dSMartin Hundebøll 
65f097e25dSMartin Hundebøll /**
66e300d314SLinus Lüssing  * batadv_send_skb_via_tt_4addr - send an skb via TT lookup
67f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
68f097e25dSMartin Hundebøll  * @skb: the payload to send
69f097e25dSMartin Hundebøll  * @packet_subtype: the unicast 4addr packet subtype to use
70c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
71f097e25dSMartin Hundebøll  *
72e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
73e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
74e300d314SLinus Lüssing  * unicast-4addr header. Then send this frame to the according destination
75e300d314SLinus Lüssing  * node.
76e300d314SLinus Lüssing  *
77e300d314SLinus Lüssing  * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
78f097e25dSMartin Hundebøll  */
79e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
80f097e25dSMartin Hundebøll 					       struct sk_buff *skb,
81c018ad3dSAntonio Quartulli 					       int packet_subtype,
82c018ad3dSAntonio Quartulli 					       unsigned short vid)
83f097e25dSMartin Hundebøll {
84e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb,
85f097e25dSMartin Hundebøll 					      BATADV_UNICAST_4ADDR,
86c018ad3dSAntonio Quartulli 					      packet_subtype, vid);
87f097e25dSMartin Hundebøll }
88c6c8fea2SSven Eckelmann 
89c6c8fea2SSven Eckelmann #endif /* _NET_BATMAN_ADV_SEND_H_ */
90