gnunet-service-ats_plugins.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2011-2014 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 ats/gnunet-service-ats_plugins.h
  18. * @brief ats service plugin management
  19. * @author Matthias Wachs
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_ATS_PLUGINS_H
  23. #define GNUNET_SERVICE_ATS_PLUGINS_H
  24. #include "gnunet-service-ats_addresses.h"
  25. /**
  26. * Initialize address subsystem. The addresses subsystem manages the addresses
  27. * known and current performance information. It has a solver component
  28. * responsible for the resource allocation. It tells the solver about changes
  29. * and receives updates when the solver changes the ressource allocation.
  30. *
  31. * @param cfg configuration to use
  32. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (failed to load
  33. * solver plugin)
  34. */
  35. int
  36. GAS_plugin_init(const struct GNUNET_CONFIGURATION_Handle *cfg);
  37. /**
  38. * Shutdown address subsystem.
  39. */
  40. void
  41. GAS_plugin_done(void);
  42. /**
  43. * The preference changed for a peer, update solver.
  44. *
  45. * @param peer the peer
  46. * @param kind the ATS kind
  47. * @param pref_rel the new relative preference value
  48. */
  49. void
  50. GAS_plugin_notify_preference_changed(const struct GNUNET_PeerIdentity *peer,
  51. enum GNUNET_ATS_PreferenceKind kind,
  52. double pref_rel);
  53. /**
  54. * The relative value for a property changed.
  55. *
  56. * @param address the peer
  57. */
  58. void
  59. GAS_plugin_notify_property_changed(struct ATS_Address *address);
  60. /**
  61. * Tell the solver that the given address can now be used
  62. * for talking to the respective peer.
  63. *
  64. * @param new_address the new address
  65. * @param addr_net network scope the address is in
  66. */
  67. void
  68. GAS_plugin_new_address(struct ATS_Address *new_address);
  69. /**
  70. * Tell the solver that the given address is no longer valid
  71. * can cannot be used any longer.
  72. *
  73. * @param address address that was deleted
  74. */
  75. void
  76. GAS_plugin_delete_address(struct ATS_Address *address);
  77. /**
  78. * Tell the solver that the given client has expressed its
  79. * appreciation for the past performance of a given connection.
  80. *
  81. * @param application client providing the feedback
  82. * @param peer peer the feedback is about
  83. * @param scope timeframe the feedback applies to
  84. * @param kind performance property the feedback relates to
  85. * @param score_abs degree of the appreciation
  86. */
  87. void
  88. GAS_plugin_notify_feedback(struct GNUNET_SERVICE_Client *application,
  89. const struct GNUNET_PeerIdentity *peer,
  90. const struct GNUNET_TIME_Relative scope,
  91. enum GNUNET_ATS_PreferenceKind kind,
  92. float score_abs);
  93. /**
  94. * Stop instant solving, there are many state updates
  95. * happening in bulk right now.
  96. */
  97. void
  98. GAS_plugin_solver_lock(void);
  99. /**
  100. * Resume instant solving, we are done with the bulk state updates.
  101. */
  102. void
  103. GAS_plugin_solver_unlock(void);
  104. /**
  105. * Notify the plugin that a request to connect to
  106. * a particular peer was given to us.
  107. *
  108. * @param pid identity of peer we now care about
  109. */
  110. void
  111. GAS_plugin_request_connect_start(const struct GNUNET_PeerIdentity *pid);
  112. /**
  113. * Notify the plugin that a request to connect to
  114. * a particular peer was dropped.
  115. *
  116. * @param pid identity of peer we care now less about
  117. */
  118. void
  119. GAS_plugin_request_connect_stop(const struct GNUNET_PeerIdentity *pid);
  120. #endif