send.h 4.0 KB

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