gnunet-service-transport_ats.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2015 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file transport/gnunet-service-transport_ats.h
  18. * @brief interfacing between transport and ATS service
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_TRANSPORT_ATS_H
  22. #define GNUNET_SERVICE_TRANSPORT_ATS_H
  23. #include "gnunet_ats_service.h"
  24. /**
  25. * Initialize ATS subsystem.
  26. */
  27. void
  28. GST_ats_init (void);
  29. /**
  30. * Shutdown ATS subsystem.
  31. */
  32. void
  33. GST_ats_done (void);
  34. /**
  35. * Test if ATS knows about this @a address and @a session.
  36. * Note that even if the address is expired, we return
  37. * #GNUNET_YES if the respective session matches.
  38. *
  39. * @param address the address
  40. * @param session the session
  41. * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not.
  42. */
  43. int
  44. GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
  45. struct GNUNET_ATS_Session *session);
  46. /**
  47. * Test if ATS knows about this @a address. Note that
  48. * expired addresses do not count.
  49. *
  50. * @param address the address
  51. * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not.
  52. */
  53. int
  54. GST_ats_is_known_no_session (const struct GNUNET_HELLO_Address *address);
  55. /**
  56. * Temporarily block a valid address for use by ATS for address
  57. * suggestions. This function should be called if an address was
  58. * suggested by ATS but failed to perform (i.e. failure to establish a
  59. * session or to exchange the PING/PONG).
  60. *
  61. * @param address the address to block
  62. * @param session the session (can be NULL)
  63. */
  64. void
  65. GST_ats_block_address (const struct GNUNET_HELLO_Address *address,
  66. struct GNUNET_ATS_Session *session);
  67. /**
  68. * Reset address blocking time. Resets the exponential
  69. * back-off timer for this address to zero. Called when
  70. * an address was used to create a successful connection.
  71. *
  72. * @param address the address to reset the blocking timer
  73. * @param session the session (can be NULL)
  74. */
  75. void
  76. GST_ats_block_reset (const struct GNUNET_HELLO_Address *address,
  77. struct GNUNET_ATS_Session *session);
  78. /**
  79. * Notify ATS about a new inbound @a address. The @a address in
  80. * combination with the @a session must be new, but this function will
  81. * perform a santiy check. If the @a address is indeed new, make it
  82. * available to ATS.
  83. *
  84. * @param address the address
  85. * @param session the session
  86. * @param prop performance information
  87. */
  88. void
  89. GST_ats_add_inbound_address (const struct GNUNET_HELLO_Address *address,
  90. struct GNUNET_ATS_Session *session,
  91. const struct GNUNET_ATS_Properties *prop);
  92. /**
  93. * Notify ATS about a new address including the network this address is
  94. * located in. The address must NOT be inbound and must be new to ATS.
  95. *
  96. * @param address the address
  97. * @param prop performance information
  98. */
  99. void
  100. GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
  101. const struct GNUNET_ATS_Properties *prop);
  102. /**
  103. * Notify ATS about a new @a session now existing for the given
  104. * @a address. Essentially, an outbound @a address was used
  105. * to establish a @a session. It is safe to call this function
  106. * repeatedly for the same @a address and @a session pair.
  107. *
  108. * @param address the address
  109. * @param session the session
  110. */
  111. void
  112. GST_ats_new_session (const struct GNUNET_HELLO_Address *address,
  113. struct GNUNET_ATS_Session *session);
  114. /**
  115. * Notify ATS about utilization changes to an @a address.
  116. * Does nothing if the @a address is not known to us.
  117. *
  118. * @param address our information about the address
  119. * @param bps_in new utilization inbound
  120. * @param bps_out new utilization outbound
  121. */
  122. void
  123. GST_ats_update_utilization (const struct GNUNET_HELLO_Address *address,
  124. uint32_t bps_in,
  125. uint32_t bps_out);
  126. /**
  127. * Notify ATS about @a delay changes to properties of an @a address.
  128. * Does nothing if the @a address is not known to us.
  129. *
  130. * @param address the address
  131. * @param session the session
  132. * @param delay new delay value
  133. */
  134. void
  135. GST_ats_update_delay (const struct GNUNET_HELLO_Address *address,
  136. struct GNUNET_TIME_Relative delay);
  137. /**
  138. * Notify ATS about DV @a distance change to an @a address.
  139. * Does nothing if the @a address is not known to us.
  140. *
  141. * @param address the address
  142. * @param distance new distance value
  143. */
  144. void
  145. GST_ats_update_distance (const struct GNUNET_HELLO_Address *address,
  146. uint32_t distance);
  147. /**
  148. * Notify ATS that the @a session (but not the @a address) of
  149. * a given @a address is no longer relevant. (The @a session
  150. * went down.) This function may be called even if for the
  151. * respective outbound address #GST_ats_new_session() was
  152. * never called and thus the pair is unknown to ATS. In this
  153. * case, the call is simply ignored.
  154. *
  155. * @param address the address
  156. * @param session the session
  157. */
  158. void
  159. GST_ats_del_session (const struct GNUNET_HELLO_Address *address,
  160. struct GNUNET_ATS_Session *session);
  161. /**
  162. * Notify ATS that the address has expired and thus cannot
  163. * be used any longer. This function must only be called
  164. * if the corresponding session is already gone.
  165. *
  166. * @param address the address
  167. */
  168. void
  169. GST_ats_expire_address (const struct GNUNET_HELLO_Address *address);
  170. #endif