gnunet-service-xdht_clients.h 5.5 KB

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