xref: /linux/net/batman-adv/send.h (revision c5d3a652a3cf180e7a4b670d73517a0dfbbefebc)
1e19f9759SSimon Wunderlich /* Copyright (C) 2007-2014 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
15ebf38fb7SAntonio 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,
416c413b1cSAntonio Quartulli 				   int packet_subtype, uint8_t *dst_hint,
426c413b1cSAntonio Quartulli 				   unsigned short vid);
43e300d314SLinus Lüssing int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
44c018ad3dSAntonio Quartulli 			   unsigned short vid);
45f097e25dSMartin Hundebøll 
46f097e25dSMartin Hundebøll /**
47e300d314SLinus Lüssing  * batadv_send_skb_via_tt - send an skb via TT lookup
48f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
49f097e25dSMartin Hundebøll  * @skb: the payload to send
50*c5d3a652SAntonio Quartulli  * @dst_hint: can be used to override the destination contained in the skb
51c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
52f097e25dSMartin Hundebøll  *
53e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
54e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
55e300d314SLinus Lüssing  * unicast header. Then send this frame to the according destination node.
56e300d314SLinus Lüssing  *
57e300d314SLinus Lüssing  * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
58f097e25dSMartin Hundebøll  */
59e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
606c413b1cSAntonio Quartulli 					 struct sk_buff *skb, uint8_t *dst_hint,
61c018ad3dSAntonio Quartulli 					 unsigned short vid)
62f097e25dSMartin Hundebøll {
63e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
646c413b1cSAntonio Quartulli 					      dst_hint, vid);
65f097e25dSMartin Hundebøll }
66f097e25dSMartin Hundebøll 
67f097e25dSMartin Hundebøll /**
68e300d314SLinus Lüssing  * batadv_send_skb_via_tt_4addr - send an skb via TT lookup
69f097e25dSMartin Hundebøll  * @bat_priv: the bat priv with all the soft interface information
70f097e25dSMartin Hundebøll  * @skb: the payload to send
71f097e25dSMartin Hundebøll  * @packet_subtype: the unicast 4addr packet subtype to use
72*c5d3a652SAntonio Quartulli  * @dst_hint: can be used to override the destination contained in the skb
73c018ad3dSAntonio Quartulli  * @vid: the vid to be used to search the translation table
74f097e25dSMartin Hundebøll  *
75e300d314SLinus Lüssing  * Look up the recipient node for the destination address in the ethernet
76e300d314SLinus Lüssing  * header via the translation table. Wrap the given skb into a batman-adv
77e300d314SLinus Lüssing  * unicast-4addr header. Then send this frame to the according destination
78e300d314SLinus Lüssing  * node.
79e300d314SLinus Lüssing  *
80e300d314SLinus Lüssing  * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
81f097e25dSMartin Hundebøll  */
82e300d314SLinus Lüssing static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
83f097e25dSMartin Hundebøll 					       struct sk_buff *skb,
84c018ad3dSAntonio Quartulli 					       int packet_subtype,
856c413b1cSAntonio Quartulli 					       uint8_t *dst_hint,
86c018ad3dSAntonio Quartulli 					       unsigned short vid)
87f097e25dSMartin Hundebøll {
88e300d314SLinus Lüssing 	return batadv_send_skb_via_tt_generic(bat_priv, skb,
89f097e25dSMartin Hundebøll 					      BATADV_UNICAST_4ADDR,
906c413b1cSAntonio Quartulli 					      packet_subtype, dst_hint, vid);
91f097e25dSMartin Hundebøll }
92c6c8fea2SSven Eckelmann 
93c6c8fea2SSven Eckelmann #endif /* _NET_BATMAN_ADV_SEND_H_ */
94