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