send.h 4.3 KB

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