send.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. */
  6. #ifndef _NET_BATMAN_ADV_SEND_H_
  7. #define _NET_BATMAN_ADV_SEND_H_
  8. #include "main.h"
  9. #include <linux/compiler.h>
  10. #include <linux/skbuff.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/types.h>
  13. #include <uapi/linux/batadv_packet.h>
  14. void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
  15. bool dropped);
  16. struct batadv_forw_packet *
  17. batadv_forw_packet_alloc(struct batadv_hard_iface *if_incoming,
  18. struct batadv_hard_iface *if_outgoing,
  19. atomic_t *queue_left,
  20. struct batadv_priv *bat_priv,
  21. struct sk_buff *skb);
  22. bool batadv_forw_packet_steal(struct batadv_forw_packet *packet, spinlock_t *l);
  23. void batadv_forw_packet_ogmv1_queue(struct batadv_priv *bat_priv,
  24. struct batadv_forw_packet *forw_packet,
  25. unsigned long send_time);
  26. bool batadv_forw_packet_is_rebroadcast(struct batadv_forw_packet *forw_packet);
  27. int batadv_send_skb_to_orig(struct sk_buff *skb,
  28. struct batadv_orig_node *orig_node,
  29. struct batadv_hard_iface *recv_if);
  30. int batadv_send_skb_packet(struct sk_buff *skb,
  31. struct batadv_hard_iface *hard_iface,
  32. const u8 *dst_addr);
  33. int batadv_send_broadcast_skb(struct sk_buff *skb,
  34. struct batadv_hard_iface *hard_iface);
  35. int batadv_send_unicast_skb(struct sk_buff *skb,
  36. struct batadv_neigh_node *neigh_node);
  37. int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
  38. const struct sk_buff *skb,
  39. unsigned long delay,
  40. bool own_packet);
  41. void
  42. batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
  43. const struct batadv_hard_iface *hard_iface);
  44. bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
  45. struct sk_buff *skb,
  46. struct batadv_orig_node *orig_node,
  47. int packet_subtype);
  48. int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
  49. struct sk_buff *skb, int packet_type,
  50. int packet_subtype,
  51. struct batadv_orig_node *orig_node,
  52. unsigned short vid);
  53. int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
  54. struct sk_buff *skb, int packet_type,
  55. int packet_subtype, u8 *dst_hint,
  56. unsigned short vid);
  57. int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
  58. unsigned short vid);
  59. /**
  60. * batadv_send_skb_via_tt() - send an skb via TT lookup
  61. * @bat_priv: the bat priv with all the soft interface information
  62. * @skb: the payload to send
  63. * @dst_hint: can be used to override the destination contained in the skb
  64. * @vid: the vid to be used to search the translation table
  65. *
  66. * Look up the recipient node for the destination address in the ethernet
  67. * header via the translation table. Wrap the given skb into a batman-adv
  68. * unicast header. Then send this frame to the according destination node.
  69. *
  70. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  71. */
  72. static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
  73. struct sk_buff *skb, u8 *dst_hint,
  74. unsigned short vid)
  75. {
  76. return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
  77. dst_hint, vid);
  78. }
  79. /**
  80. * batadv_send_skb_via_tt_4addr() - send an skb via TT lookup
  81. * @bat_priv: the bat priv with all the soft interface information
  82. * @skb: the payload to send
  83. * @packet_subtype: the unicast 4addr packet subtype to use
  84. * @dst_hint: can be used to override the destination contained in the skb
  85. * @vid: the vid to be used to search the translation table
  86. *
  87. * Look up the recipient node for the destination address in the ethernet
  88. * header via the translation table. Wrap the given skb into a batman-adv
  89. * unicast-4addr header. Then send this frame to the according destination
  90. * node.
  91. *
  92. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
  93. */
  94. static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
  95. struct sk_buff *skb,
  96. int packet_subtype,
  97. u8 *dst_hint,
  98. unsigned short vid)
  99. {
  100. return batadv_send_skb_via_tt_generic(bat_priv, skb,
  101. BATADV_UNICAST_4ADDR,
  102. packet_subtype, dst_hint, vid);
  103. }
  104. #endif /* _NET_BATMAN_ADV_SEND_H_ */