send.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors:
  2. *
  3. * Marek Lindner, Simon Wunderlich
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2 of the GNU General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _NET_BATMAN_ADV_SEND_H_
  18. #define _NET_BATMAN_ADV_SEND_H_
  19. #include "main.h"
  20. #include <linux/compiler.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/types.h>
  23. #include "packet.h"
  24. struct sk_buff;
  25. void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
  26. bool dropped);
  27. struct batadv_forw_packet *
  28. batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
  29. struct batadv_hard_iface *if_outgoing,
  30. atomic_t *queue_left,
  31. struct batadv_priv *bat_priv);
  32. bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
  33. void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
  34. struct batadv_forw_packet *forw_packet,
  35. unsigned long send_time);
  36. int batadv_send_skb_to_orig(struct sk_buff *skb,
  37. struct batadv_orig_node *orig_node,
  38. struct batadv_hard_iface *recv_if);
  39. int batadv_send_skb_packet(struct sk_buff *skb,
  40. struct batadv_hard_iface *hard_iface,
  41. const u8 *dst_addr);
  42. int batadv_send_broadcast_skb(struct sk_buff *skb,
  43. struct batadv_hard_iface *hard_iface);
  44. int batadv_send_unicast_skb(struct sk_buff *skb,
  45. struct batadv_neigh_node *neigh_node);
  46. int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
  47. const struct sk_buff *skb,
  48. unsigned long delay,
  49. bool own_packet);
  50. void
  51. batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
  52. const struct batadv_hard_iface *hard_iface);
  53. bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
  54. struct sk_buff *skb,
  55. struct batadv_orig_node *orig_node,
  56. int packet_subtype);
  57. int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
  58. struct sk_buff *skb, int packet_type,
  59. int packet_subtype,
  60. struct batadv_orig_node *orig_node,
  61. unsigned short vid);
  62. int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
  63. struct sk_buff *skb, int packet_type,
  64. int packet_subtype, u8 *dst_hint,
  65. unsigned short vid);
  66. int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
  67. unsigned short vid);
  68. /**
  69. * batadv_send_skb_via_tt - send an skb via TT lookup
  70. * @bat_priv: the bat priv with all the soft interface information
  71. * @skb: the payload to send
  72. * @dst_hint: can be used to override the destination contained in the skb
  73. * @vid: the vid to be used to search the translation table
  74. *
  75. * Look up the recipient node for the destination address in the ethernet
  76. * header via the translation table. Wrap the given skb into a batman-adv
  77. * unicast header. Then send this frame to the according destination node.
  78. *
  79. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  80. */
  81. static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
  82. struct sk_buff *skb, u8 *dst_hint,
  83. unsigned short vid)
  84. {
  85. return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
  86. dst_hint, vid);
  87. }
  88. /**
  89. * batadv_send_skb_via_tt_4addr - send an skb via TT lookup
  90. * @bat_priv: the bat priv with all the soft interface information
  91. * @skb: the payload to send
  92. * @packet_subtype: the unicast 4addr packet subtype to use
  93. * @dst_hint: can be used to override the destination contained in the skb
  94. * @vid: the vid to be used to search the translation table
  95. *
  96. * Look up the recipient node for the destination address in the ethernet
  97. * header via the translation table. Wrap the given skb into a batman-adv
  98. * unicast-4addr header. Then send this frame to the according destination
  99. * node.
  100. *
  101. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  102. */
  103. static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
  104. struct sk_buff *skb,
  105. int packet_subtype,
  106. u8 *dst_hint,
  107. unsigned short vid)
  108. {
  109. return batadv_send_skb_via_tt_generic(bat_priv, skb,
  110. BATADV_UNICAST_4ADDR,
  111. packet_subtype, dst_hint, vid);
  112. }
  113. #endif /* _NET_BATMAN_ADV_SEND_H_ */