send.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Copyright (C) 2007-2017 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. struct sk_buff *skb);
  33. bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
  34. void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
  35. struct batadv_forw_packet *forw_packet,
  36. unsigned long send_time);
  37. bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
  38. int batadv_send_skb_to_orig(struct sk_buff *skb,
  39. struct batadv_orig_node *orig_node,
  40. struct batadv_hard_iface *recv_if);
  41. int batadv_send_skb_packet(struct sk_buff *skb,
  42. struct batadv_hard_iface *hard_iface,
  43. const u8 *dst_addr);
  44. int batadv_send_broadcast_skb(struct sk_buff *skb,
  45. struct batadv_hard_iface *hard_iface);
  46. int batadv_send_unicast_skb(struct sk_buff *skb,
  47. struct batadv_neigh_node *neigh_node);
  48. int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
  49. const struct sk_buff *skb,
  50. unsigned long delay,
  51. bool own_packet);
  52. void
  53. batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
  54. const struct batadv_hard_iface *hard_iface);
  55. bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
  56. struct sk_buff *skb,
  57. struct batadv_orig_node *orig_node,
  58. int packet_subtype);
  59. int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
  60. struct sk_buff *skb, int packet_type,
  61. int packet_subtype,
  62. struct batadv_orig_node *orig_node,
  63. unsigned short vid);
  64. int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
  65. struct sk_buff *skb, int packet_type,
  66. int packet_subtype, u8 *dst_hint,
  67. unsigned short vid);
  68. int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
  69. unsigned short vid);
  70. /**
  71. * batadv_send_skb_via_tt - send an skb via TT lookup
  72. * @bat_priv: the bat priv with all the soft interface information
  73. * @skb: the payload to send
  74. * @dst_hint: can be used to override the destination contained in the skb
  75. * @vid: the vid to be used to search the translation table
  76. *
  77. * Look up the recipient node for the destination address in the ethernet
  78. * header via the translation table. Wrap the given skb into a batman-adv
  79. * unicast header. Then send this frame to the according destination node.
  80. *
  81. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  82. */
  83. static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
  84. struct sk_buff *skb, u8 *dst_hint,
  85. unsigned short vid)
  86. {
  87. return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
  88. dst_hint, vid);
  89. }
  90. /**
  91. * batadv_send_skb_via_tt_4addr - send an skb via TT lookup
  92. * @bat_priv: the bat priv with all the soft interface information
  93. * @skb: the payload to send
  94. * @packet_subtype: the unicast 4addr packet subtype to use
  95. * @dst_hint: can be used to override the destination contained in the skb
  96. * @vid: the vid to be used to search the translation table
  97. *
  98. * Look up the recipient node for the destination address in the ethernet
  99. * header via the translation table. Wrap the given skb into a batman-adv
  100. * unicast-4addr header. Then send this frame to the according destination
  101. * node.
  102. *
  103. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  104. */
  105. static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
  106. struct sk_buff *skb,
  107. int packet_subtype,
  108. u8 *dst_hint,
  109. unsigned short vid)
  110. {
  111. return batadv_send_skb_via_tt_generic(bat_priv, skb,
  112. BATADV_UNICAST_4ADDR,
  113. packet_subtype, dst_hint, vid);
  114. }
  115. #endif /* _NET_BATMAN_ADV_SEND_H_ */