gnunet-service-fs.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2009, 2010 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 fs/gnunet-service-fs.h
  19. * @brief shared data structures of gnunet-service-fs.c
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_FS_H
  23. #define GNUNET_SERVICE_FS_H
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_statistics_service.h"
  26. #include "gnunet_transport_service.h"
  27. #include "gnunet_core_service.h"
  28. #include "gnunet_block_lib.h"
  29. #include "gnunet_ats_service.h"
  30. #include "fs.h"
  31. /**
  32. * By which amount do we decrement the TTL for simple forwarding /
  33. * indirection of the query; in milli-seconds. Set somewhat in
  34. * accordance to your network latency (above the time it'll take you
  35. * to send a packet and get a reply).
  36. */
  37. #define TTL_DECREMENT 5000
  38. /**
  39. * At what frequency should our datastore load decrease
  40. * automatically (since if we don't use it, clearly the
  41. * load must be going down).
  42. */
  43. #define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
  44. /**
  45. * Only the (mandatory) query is included.
  46. */
  47. #define GET_MESSAGE_BIT_QUERY_ONLY 0
  48. /**
  49. * The peer identity of a peer waiting for the
  50. * reply is included (used if the response
  51. * should be transmitted to someone other than
  52. * the sender of the GET).
  53. */
  54. #define GET_MESSAGE_BIT_RETURN_TO 1
  55. /**
  56. * The peer identity of a peer that had claimed to have the content
  57. * previously is included (can be used if responder-anonymity is not
  58. * desired; note that the precursor presumably lacked a direct
  59. * connection to the specified peer; still, the receiver is in no way
  60. * required to limit forwarding only to the specified peer, it should
  61. * only prefer it somewhat if possible).
  62. */
  63. #define GET_MESSAGE_BIT_TRANSMIT_TO 4
  64. GNUNET_NETWORK_STRUCT_BEGIN
  65. /**
  66. * Message sent between peers asking for FS-content.
  67. */
  68. struct GetMessage
  69. {
  70. /**
  71. * Message type will be #GNUNET_MESSAGE_TYPE_FS_GET.
  72. */
  73. struct GNUNET_MessageHeader header;
  74. /**
  75. * Type of the query (block type).
  76. */
  77. uint32_t type GNUNET_PACKED;
  78. /**
  79. * How important is this request (network byte order)
  80. */
  81. uint32_t priority GNUNET_PACKED;
  82. /**
  83. * Relative time to live in MILLISECONDS (network byte order)
  84. */
  85. int32_t ttl GNUNET_PACKED;
  86. /**
  87. * The content hash should be mutated using this value
  88. * before checking against the bloomfilter (used to
  89. * get many different filters for the same hash codes).
  90. * The number should be in big-endian format when used
  91. * for mingling.
  92. */
  93. uint32_t filter_mutator GNUNET_PACKED;
  94. /**
  95. * Which of the optional hash codes are present at the end of the
  96. * message? See GET_MESSAGE_BIT_xx constants. For each bit that is
  97. * set, an additional `struct GNUNET_HashCode` with the respective content
  98. * (in order of the bits) will be appended to the end of the GET
  99. * message.
  100. */
  101. uint32_t hash_bitmap GNUNET_PACKED;
  102. /**
  103. * Hashcodes of the file(s) we're looking for.
  104. * Details depend on the query type.
  105. */
  106. struct GNUNET_HashCode query;
  107. /* this is followed by PeerIdentities as specified in the "hash_bitmap";
  108. * after that, an optional bloomfilter (with bits set for replies
  109. * that should be suppressed) can be present */
  110. };
  111. /**
  112. * Message send by a peer that wants to be excluded
  113. * from migration for a while.
  114. */
  115. struct MigrationStopMessage
  116. {
  117. /**
  118. * Message type will be
  119. * GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP.
  120. */
  121. struct GNUNET_MessageHeader header;
  122. /**
  123. * Always zero.
  124. */
  125. uint32_t reserved GNUNET_PACKED;
  126. /**
  127. * How long should the block last?
  128. */
  129. struct GNUNET_TIME_RelativeNBO duration;
  130. };
  131. GNUNET_NETWORK_STRUCT_END
  132. /**
  133. * A connected peer.
  134. */
  135. struct GSF_ConnectedPeer;
  136. /**
  137. * An active request.
  138. */
  139. struct GSF_PendingRequest;
  140. /**
  141. * A local client.
  142. */
  143. struct GSF_LocalClient;
  144. /**
  145. * Information kept per plan per request ('pe' module).
  146. */
  147. struct GSF_RequestPlan;
  148. /**
  149. * Bijection between request plans and pending requests.
  150. */
  151. struct GSF_PendingRequestPlanBijection;
  152. /**
  153. * Our connection to the datastore.
  154. */
  155. extern struct GNUNET_DATASTORE_Handle *GSF_dsh;
  156. /**
  157. * Our configuration.
  158. */
  159. extern const struct GNUNET_CONFIGURATION_Handle *GSF_cfg;
  160. /**
  161. * Handle for reporting statistics.
  162. */
  163. extern struct GNUNET_STATISTICS_Handle *GSF_stats;
  164. /**
  165. * Pointer to handle to the core service (points to NULL until we've
  166. * connected to it).
  167. */
  168. extern struct GNUNET_CORE_Handle *GSF_core;
  169. /**
  170. * Handle for DHT operations.
  171. */
  172. extern struct GNUNET_DHT_Handle *GSF_dht;
  173. /**
  174. * How long do requests typically stay in the routing table?
  175. */
  176. extern struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
  177. /**
  178. * Running average of the observed latency to other peers (round trip).
  179. */
  180. extern struct GNUNET_TIME_Relative GSF_avg_latency;
  181. /**
  182. * Handle to ATS service.
  183. */
  184. extern struct GNUNET_ATS_PerformanceHandle *GSF_ats;
  185. /**
  186. * Typical priorities we're seeing from other peers right now. Since
  187. * most priorities will be zero, this value is the weighted average of
  188. * non-zero priorities seen "recently". In order to ensure that new
  189. * values do not dramatically change the ratio, values are first
  190. * "capped" to a reasonable range (+N of the current value) and then
  191. * averaged into the existing value by a ratio of 1:N. Hence
  192. * receiving the largest possible priority can still only raise our
  193. * "current_priorities" by at most 1.
  194. */
  195. extern double GSF_current_priorities;
  196. /**
  197. * How many query messages have we received 'recently' that
  198. * have not yet been claimed as cover traffic?
  199. */
  200. extern unsigned int GSF_cover_query_count;
  201. /**
  202. * How many content messages have we received 'recently' that
  203. * have not yet been claimed as cover traffic?
  204. */
  205. extern unsigned int GSF_cover_content_count;
  206. /**
  207. * Our block context.
  208. */
  209. extern struct GNUNET_BLOCK_Context *GSF_block_ctx;
  210. /**
  211. * Are we introducing randomized delays for better anonymity?
  212. */
  213. extern int GSF_enable_randomized_delays;
  214. /**
  215. * Size of the datastore queue we assume for common requests.
  216. */
  217. extern unsigned int GSF_datastore_queue_size;
  218. /**
  219. * Test if the DATABASE (GET) load on this peer is too high
  220. * to even consider processing the query at
  221. * all.
  222. *
  223. * @return GNUNET_YES if the load is too high to do anything (load high)
  224. * GNUNET_NO to process normally (load normal)
  225. * GNUNET_SYSERR to process for free (load low)
  226. */
  227. int
  228. GSF_test_get_load_too_high_ (uint32_t priority);
  229. /**
  230. * We've just now completed a datastore request. Update our
  231. * datastore load calculations.
  232. *
  233. * @param start time when the datastore request was issued
  234. */
  235. void
  236. GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start);
  237. #endif
  238. /* end of gnunet-service-fs.h */