gnunet-service-dht_neighbours.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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-dht_neighbours.h
  19. * @brief GNUnet DHT routing code
  20. * @author Christian Grothoff
  21. * @author Nathan Evans
  22. */
  23. #ifndef GNUNET_SERVICE_DHT_NEIGHBOURS_H
  24. #define GNUNET_SERVICE_DHT_NEIGHBOURS_H
  25. #include "gnunet_util_lib.h"
  26. #include "gnunet_block_lib.h"
  27. #include "gnunet_dht_service.h"
  28. /**
  29. * Perform a PUT operation. Forwards the given request to other
  30. * peers. Does not store the data locally. Does not give the
  31. * data to local clients. May do nothing if this is the only
  32. * peer in the network (or if we are the closest peer in the
  33. * network).
  34. *
  35. * @param type type of the block
  36. * @param options routing options
  37. * @param desired_replication_level desired replication level
  38. * @param expiration_time when does the content expire
  39. * @param hop_count how many hops has this message traversed so far
  40. * @param bf Bloom filter of peers this PUT has already traversed
  41. * @param key key for the content
  42. * @param put_path_length number of entries in put_path
  43. * @param put_path peers this request has traversed so far (if tracked)
  44. * @param data payload to store
  45. * @param data_size number of bytes in data
  46. * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not
  47. */
  48. int
  49. GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
  50. enum GNUNET_DHT_RouteOption options,
  51. uint32_t desired_replication_level,
  52. struct GNUNET_TIME_Absolute expiration_time,
  53. uint32_t hop_count,
  54. struct GNUNET_CONTAINER_BloomFilter *bf,
  55. const struct GNUNET_HashCode * key,
  56. unsigned int put_path_length,
  57. struct GNUNET_PeerIdentity *put_path,
  58. const void *data, size_t data_size);
  59. /**
  60. * Perform a GET operation. Forwards the given request to other
  61. * peers. Does not lookup the key locally. May do nothing if this is
  62. * the only peer in the network (or if we are the closest peer in the
  63. * network).
  64. *
  65. * @param type type of the block
  66. * @param options routing options
  67. * @param desired_replication_level desired replication count
  68. * @param hop_count how many hops did this request traverse so far?
  69. * @param key key for the content
  70. * @param xquery extended query
  71. * @param xquery_size number of bytes in @a xquery
  72. * @param reply_bf bloomfilter to filter duplicates
  73. * @param reply_bf_mutator mutator for @a reply_bf
  74. * @param peer_bf filter for peers not to select (again, updated)
  75. * @return #GNUNET_OK if the request was forwarded, #GNUNET_NO if not
  76. */
  77. int
  78. GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
  79. enum GNUNET_DHT_RouteOption options,
  80. uint32_t desired_replication_level,
  81. uint32_t hop_count,
  82. const struct GNUNET_HashCode *key,
  83. const void *xquery, size_t xquery_size,
  84. const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
  85. uint32_t reply_bf_mutator,
  86. struct GNUNET_CONTAINER_BloomFilter *peer_bf);
  87. /**
  88. * Handle a reply (route to origin). Only forwards the reply back to
  89. * other peers waiting for it. Does not do local caching or
  90. * forwarding to local clients.
  91. *
  92. * @param target neighbour that should receive the block (if still connected)
  93. * @param type type of the block
  94. * @param expiration_time when does the content expire
  95. * @param key key for the content
  96. * @param put_path_length number of entries in put_path
  97. * @param put_path peers the original PUT traversed (if tracked)
  98. * @param get_path_length number of entries in put_path
  99. * @param get_path peers this reply has traversed so far (if tracked)
  100. * @param data payload of the reply
  101. * @param data_size number of bytes in data
  102. */
  103. void
  104. GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
  105. enum GNUNET_BLOCK_Type type,
  106. struct GNUNET_TIME_Absolute expiration_time,
  107. const struct GNUNET_HashCode * key,
  108. unsigned int put_path_length,
  109. const struct GNUNET_PeerIdentity *put_path,
  110. unsigned int get_path_length,
  111. const struct GNUNET_PeerIdentity *get_path,
  112. const void *data, size_t data_size);
  113. /**
  114. * Initialize neighbours subsystem.
  115. *
  116. * @return GNUNET_OK on success, GNUNET_SYSERR on error
  117. */
  118. int
  119. GDS_NEIGHBOURS_init (void);
  120. /**
  121. * Shutdown neighbours subsystem.
  122. */
  123. void
  124. GDS_NEIGHBOURS_done (void);
  125. /**
  126. * Get the ID of the local node.
  127. *
  128. * @return identity of the local node
  129. */
  130. struct GNUNET_PeerIdentity *
  131. GDS_NEIGHBOURS_get_id ();
  132. #endif