gnunet-service-ats_plugins.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2011-2014 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file ats/gnunet-service-ats_plugins.h
  19. * @brief ats service plugin management
  20. * @author Matthias Wachs
  21. * @author Christian Grothoff
  22. */
  23. #ifndef GNUNET_SERVICE_ATS_PLUGINS_H
  24. #define GNUNET_SERVICE_ATS_PLUGINS_H
  25. #include "gnunet-service-ats_addresses.h"
  26. /**
  27. * Initialize address subsystem. The addresses subsystem manages the addresses
  28. * known and current performance information. It has a solver component
  29. * responsible for the resource allocation. It tells the solver about changes
  30. * and receives updates when the solver changes the ressource allocation.
  31. *
  32. * @param cfg configuration to use
  33. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (failed to load
  34. * solver plugin)
  35. */
  36. int
  37. GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
  38. /**
  39. * Shutdown address subsystem.
  40. */
  41. void
  42. GAS_plugins_done (void);
  43. /**
  44. * The preference changed for a peer, update solver.
  45. *
  46. * @param peer the peer
  47. * @param kind the ATS kind
  48. * @param pref_rel the new relative preference value
  49. */
  50. void
  51. GAS_normalized_preference_changed (const struct GNUNET_PeerIdentity *peer,
  52. enum GNUNET_ATS_PreferenceKind kind,
  53. double pref_rel);
  54. /**
  55. * The relative value for a property changed
  56. *
  57. * @param address the peer
  58. * @param type the ATS type
  59. * @param prop_rel the new relative preference value
  60. */
  61. void
  62. GAS_normalized_property_changed (struct ATS_Address *address,
  63. uint32_t type,
  64. double prop_rel);
  65. /**
  66. * Tell the solver that the given address can now be used
  67. * for talking to the respective peer.
  68. *
  69. * @param new_address the new address
  70. * @param addr_net network scope the address is in
  71. * @param atsi performance data for the address
  72. * @param atsi_count size of the @a atsi array
  73. */
  74. void
  75. GAS_plugin_new_address (struct ATS_Address *new_address,
  76. enum GNUNET_ATS_Network_Type addr_net,
  77. const struct GNUNET_ATS_Information *atsi,
  78. uint32_t atsi_count);
  79. /**
  80. * Tell the solver that the given address is no longer valid
  81. * can cannot be used any longer.
  82. *
  83. * @param address address that was deleted
  84. */
  85. void
  86. GAS_plugin_delete_address (struct ATS_Address *address);
  87. /**
  88. * Tell the solver that the given client has expressed its
  89. * appreciation for the past performance of a given connection.
  90. *
  91. * @param application client providing the feedback
  92. * @param peer peer the feedback is about
  93. * @param scope timeframe the feedback applies to
  94. * @param kind performance property the feedback relates to
  95. * @param score_abs degree of the appreciation
  96. */
  97. void
  98. GAS_plugin_preference_feedback (struct GNUNET_SERVER_Client *application,
  99. const struct GNUNET_PeerIdentity *peer,
  100. const struct GNUNET_TIME_Relative scope,
  101. enum GNUNET_ATS_PreferenceKind kind,
  102. float score_abs);
  103. /**
  104. * Stop instant solving, there are many state updates
  105. * happening in bulk right now.
  106. */
  107. void
  108. GAS_plugin_solver_lock (void);
  109. /**
  110. * Resume instant solving, we are done with the bulk state updates.
  111. */
  112. void
  113. GAS_plugin_solver_unlock (void);
  114. /**
  115. * Notify the plugin that a request to connect to
  116. * a particular peer was given to us.
  117. *
  118. * @param pid identity of peer we now care about
  119. */
  120. void
  121. GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid);
  122. /**
  123. * Notify the plugin that a request to connect to
  124. * a particular peer was dropped.
  125. *
  126. * @param pid identity of peer we care now less about
  127. */
  128. void
  129. GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid);
  130. #endif