send.h 4.3 KB

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