gnunet-service-dht.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2016 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 dht/gnunet-service-dht.h
  18. * @brief GNUnet DHT globals
  19. * @author Christian Grothoff
  20. */
  21. #ifndef GNUNET_SERVICE_DHT_H
  22. #define GNUNET_SERVICE_DHT_H
  23. #include "gnunet_util_lib.h"
  24. #include "gnunet_statistics_service.h"
  25. #include "gnunet_transport_service.h"
  26. #include "gnunet_block_lib.h"
  27. #define DEBUG_DHT GNUNET_EXTRA_LOGGING
  28. /**
  29. * Configuration we use.
  30. */
  31. extern const struct GNUNET_CONFIGURATION_Handle *GDS_cfg;
  32. /**
  33. * Handle for the service.
  34. */
  35. extern struct GNUNET_SERVICE_Handle *GDS_service;
  36. /**
  37. * Our handle to the BLOCK library.
  38. */
  39. extern struct GNUNET_BLOCK_Context *GDS_block_context;
  40. /**
  41. * Handle for the statistics service.
  42. */
  43. extern struct GNUNET_STATISTICS_Handle *GDS_stats;
  44. /**
  45. * Our HELLO
  46. */
  47. extern struct GNUNET_MessageHeader *GDS_my_hello;
  48. /**
  49. * Handle a reply we've received from another peer. If the reply
  50. * matches any of our pending queries, forward it to the respective
  51. * client(s).
  52. *
  53. * @param expiration when will the reply expire
  54. * @param key the query this reply is for
  55. * @param get_path_length number of peers in @a get_path
  56. * @param get_path path the reply took on get
  57. * @param put_path_length number of peers in @a put_path
  58. * @param put_path path the reply took on put
  59. * @param type type of the reply
  60. * @param data_size number of bytes in @a data
  61. * @param data application payload data
  62. */
  63. void
  64. GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
  65. const struct GNUNET_HashCode *key,
  66. unsigned int get_path_length,
  67. const struct GNUNET_PeerIdentity *get_path,
  68. unsigned int put_path_length,
  69. const struct GNUNET_PeerIdentity *put_path,
  70. enum GNUNET_BLOCK_Type type,
  71. size_t data_size,
  72. const void *data);
  73. /**
  74. * Check if some client is monitoring GET messages and notify
  75. * them in that case.
  76. *
  77. * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
  78. * @param type The type of data in the request.
  79. * @param hop_count Hop count so far.
  80. * @param path_length number of entries in path (or 0 if not recorded).
  81. * @param path peers on the GET path (or NULL if not recorded).
  82. * @param desired_replication_level Desired replication level.
  83. * @param key Key of the requested data.
  84. */
  85. void
  86. GDS_CLIENTS_process_get (uint32_t options,
  87. enum GNUNET_BLOCK_Type type,
  88. uint32_t hop_count,
  89. uint32_t desired_replication_level,
  90. unsigned int path_length,
  91. const struct GNUNET_PeerIdentity *path,
  92. const struct GNUNET_HashCode *key);
  93. /**
  94. * Check if some client is monitoring GET RESP messages and notify
  95. * them in that case.
  96. *
  97. * @param type The type of data in the result.
  98. * @param get_path Peers on GET path (or NULL if not recorded).
  99. * @param get_path_length number of entries in @a get_path.
  100. * @param put_path peers on the PUT path (or NULL if not recorded).
  101. * @param put_path_length number of entries in @a get_path.
  102. * @param exp Expiration time of the data.
  103. * @param key Key of the @a data.
  104. * @param data Pointer to the result data.
  105. * @param size Number of bytes in @a data.
  106. */
  107. void
  108. GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
  109. const struct GNUNET_PeerIdentity *get_path,
  110. unsigned int get_path_length,
  111. const struct GNUNET_PeerIdentity *put_path,
  112. unsigned int put_path_length,
  113. struct GNUNET_TIME_Absolute exp,
  114. const struct GNUNET_HashCode *key,
  115. const void *data,
  116. size_t size);
  117. /**
  118. * Check if some client is monitoring PUT messages and notify
  119. * them in that case.
  120. *
  121. * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
  122. * @param type The type of data in the request.
  123. * @param hop_count Hop count so far.
  124. * @param path_length number of entries in path (or 0 if not recorded).
  125. * @param path peers on the PUT path (or NULL if not recorded).
  126. * @param desired_replication_level Desired replication level.
  127. * @param exp Expiration time of the data.
  128. * @param key Key under which data is to be stored.
  129. * @param data Pointer to the data carried.
  130. * @param size Number of bytes in data.
  131. */
  132. void
  133. GDS_CLIENTS_process_put (uint32_t options,
  134. enum GNUNET_BLOCK_Type type,
  135. uint32_t hop_count,
  136. uint32_t desired_replication_level,
  137. unsigned int path_length,
  138. const struct GNUNET_PeerIdentity *path,
  139. struct GNUNET_TIME_Absolute exp,
  140. const struct GNUNET_HashCode *key,
  141. const void *data,
  142. size_t size);
  143. #endif