gnunet-service-xdht_neighbours.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_neighbours.h
  19. * @brief GNUnet DHT routing code
  20. * @author Supriti Singh
  21. */
  22. #ifndef GNUNET_SERVICE_XDHT_NEIGHBOURS_H
  23. #define GNUNET_SERVICE_XDHT_NEIGHBOURS_H
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_block_lib.h"
  26. #include "gnunet_dht_service.h"
  27. #if ENABLE_MALICIOUS
  28. /**
  29. * Set the ENABLE_MALICIOUS value to malicious.
  30. * @param malicious
  31. */
  32. int
  33. GDS_NEIGHBOURS_act_malicious (unsigned int malicious);
  34. #endif
  35. /**
  36. * Handle the put request from the client.
  37. * @param key Key for the content
  38. * @param block_type Type of the block
  39. * @param options Routing options
  40. * @param desired_replication_level Desired replication count
  41. * @param expiration_time When does the content expire
  42. * @param data Content to store
  43. * @param data_size Size of content @a data in bytes
  44. */
  45. void
  46. GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key,
  47. enum GNUNET_BLOCK_Type block_type,
  48. enum GNUNET_DHT_RouteOption options,
  49. uint32_t desired_replication_level,
  50. struct GNUNET_TIME_Absolute expiration_time,
  51. const void *data, size_t data_size);
  52. /**
  53. * Handle the get request from the client file. If I am destination do
  54. * datacache put and return. Else find the target friend and forward message
  55. * to it.
  56. * @param key Key for the content
  57. * @param block_type Type of the block
  58. * @param options Routing options
  59. * @param desired_replication_level Desired replication count
  60. */
  61. void
  62. GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key,
  63. enum GNUNET_BLOCK_Type block_type,
  64. enum GNUNET_DHT_RouteOption options,
  65. uint32_t desired_replication_level);
  66. /**
  67. * Send the get result to requesting client.
  68. * @param key Key of the requested data.
  69. * @param type Block type
  70. * @param target_peer Next peer to forward the message to.
  71. * @param source_peer Peer which has the data for the key.
  72. * @param put_path_length Number of peers in @a put_path
  73. * @param put_path Path taken to put the data at its stored location.
  74. * @param get_path_length Number of peers in @a get_path
  75. * @param get_path Path taken to reach to the location of the key.
  76. * @param expiration When will this result expire?
  77. * @param data Payload to store
  78. * @param data_size Size of the @a data
  79. */
  80. void
  81. GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
  82. enum GNUNET_BLOCK_Type type,
  83. const struct GNUNET_PeerIdentity *target_peer,
  84. const struct GNUNET_PeerIdentity *source_peer,
  85. unsigned int put_path_length,
  86. const struct GNUNET_PeerIdentity *put_path,
  87. unsigned int get_path_length,
  88. const struct GNUNET_PeerIdentity *get_path,
  89. struct GNUNET_TIME_Absolute expiration,
  90. const void *data, size_t data_size);
  91. /**
  92. * Construct a trail teardown message and forward it to target friend.
  93. * @param trail_id Unique identifier of the trail.
  94. * @param trail_direction Direction of trail.
  95. * @param target_friend Friend to get this message.
  96. */
  97. void
  98. GDS_NEIGHBOURS_send_trail_teardown (const struct GNUNET_HashCode *trail_id,
  99. unsigned int trail_direction,
  100. const struct GNUNET_PeerIdentity *peer);
  101. /**
  102. * Return friend corresponding to peer.
  103. * @param peer
  104. * @return Friend
  105. */
  106. struct FriendInfo *
  107. GDS_NEIGHBOURS_get_friend (struct GNUNET_PeerIdentity peer);
  108. /**
  109. * Initialize neighbours subsystem.
  110. *
  111. * @return #GNUNET_OK on success,
  112. * #GNUNET_SYSERR on error
  113. */
  114. int
  115. GDS_NEIGHBOURS_init (void);
  116. /**
  117. * Shutdown neighbours subsystem.
  118. */
  119. void
  120. GDS_NEIGHBOURS_done (void);
  121. /**
  122. * Get my identity
  123. *
  124. * @return my identity
  125. */
  126. struct GNUNET_PeerIdentity
  127. GDS_NEIGHBOURS_get_my_id (void);
  128. #endif