2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file fs/gnunet-service-fs.h
21 * @brief shared data structures of gnunet-service-fs.c
22 * @author Christian Grothoff
24 #ifndef GNUNET_SERVICE_FS_H
25 #define GNUNET_SERVICE_FS_H
27 #include "gnunet_util_lib.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet_transport_service.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_block_lib.h"
32 #include "gnunet_ats_service.h"
37 * By which amount do we decrement the TTL for simple forwarding /
38 * indirection of the query; in milli-seconds. Set somewhat in
39 * accordance to your network latency (above the time it'll take you
40 * to send a packet and get a reply).
42 #define TTL_DECREMENT 5000
45 * At what frequency should our datastore load decrease
46 * automatically (since if we don't use it, clearly the
47 * load must be going down).
49 #define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
52 * Only the (mandatory) query is included.
54 #define GET_MESSAGE_BIT_QUERY_ONLY 0
57 * The peer identity of a peer waiting for the
58 * reply is included (used if the response
59 * should be transmitted to someone other than
60 * the sender of the GET).
62 #define GET_MESSAGE_BIT_RETURN_TO 1
65 * The peer identity of a peer that had claimed to have the content
66 * previously is included (can be used if responder-anonymity is not
67 * desired; note that the precursor presumably lacked a direct
68 * connection to the specified peer; still, the receiver is in no way
69 * required to limit forwarding only to the specified peer, it should
70 * only prefer it somewhat if possible).
72 #define GET_MESSAGE_BIT_TRANSMIT_TO 4
75 GNUNET_NETWORK_STRUCT_BEGIN
78 * Message sent between peers asking for FS-content.
84 * Message type will be #GNUNET_MESSAGE_TYPE_FS_GET.
86 struct GNUNET_MessageHeader header;
89 * Type of the query (block type).
91 uint32_t type GNUNET_PACKED;
94 * How important is this request (network byte order)
96 uint32_t priority GNUNET_PACKED;
99 * Relative time to live in MILLISECONDS (network byte order)
101 int32_t ttl GNUNET_PACKED;
104 * The content hash should be mutated using this value
105 * before checking against the bloomfilter (used to
106 * get many different filters for the same hash codes).
107 * The number should be in big-endian format when used
110 uint32_t filter_mutator GNUNET_PACKED;
113 * Which of the optional hash codes are present at the end of the
114 * message? See GET_MESSAGE_BIT_xx constants. For each bit that is
115 * set, an additional `struct GNUNET_HashCode` with the respective content
116 * (in order of the bits) will be appended to the end of the GET
119 uint32_t hash_bitmap GNUNET_PACKED;
122 * Hashcodes of the file(s) we're looking for.
123 * Details depend on the query type.
125 struct GNUNET_HashCode query;
127 /* this is followed by PeerIdentities as specified in the "hash_bitmap";
128 * after that, an optional bloomfilter (with bits set for replies
129 * that should be suppressed) can be present */
134 * Message send by a peer that wants to be excluded
135 * from migration for a while.
137 struct MigrationStopMessage
140 * Message type will be
141 * GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP.
143 struct GNUNET_MessageHeader header;
148 uint32_t reserved GNUNET_PACKED;
151 * How long should the block last?
153 struct GNUNET_TIME_RelativeNBO duration;
156 GNUNET_NETWORK_STRUCT_END
161 struct GSF_ConnectedPeer;
166 struct GSF_PendingRequest;
171 struct GSF_LocalClient;
174 * Information kept per plan per request ('pe' module).
176 struct GSF_RequestPlan;
179 * Bijection between request plans and pending requests.
181 struct GSF_PendingRequestPlanBijection;
184 * Our connection to the datastore.
186 extern struct GNUNET_DATASTORE_Handle *GSF_dsh;
191 extern const struct GNUNET_CONFIGURATION_Handle *GSF_cfg;
194 * Handle for reporting statistics.
196 extern struct GNUNET_STATISTICS_Handle *GSF_stats;
199 * Pointer to handle to the core service (points to NULL until we've
202 extern struct GNUNET_CORE_Handle *GSF_core;
205 * Handle for DHT operations.
207 extern struct GNUNET_DHT_Handle *GSF_dht;
210 * How long do requests typically stay in the routing table?
212 extern struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
215 * Running average of the observed latency to other peers (round trip).
217 extern struct GNUNET_TIME_Relative GSF_avg_latency;
220 * Handle to ATS service.
222 extern struct GNUNET_ATS_PerformanceHandle *GSF_ats;
225 * Identity of this peer.
227 extern struct GNUNET_PeerIdentity GSF_my_id;
230 * Typical priorities we're seeing from other peers right now. Since
231 * most priorities will be zero, this value is the weighted average of
232 * non-zero priorities seen "recently". In order to ensure that new
233 * values do not dramatically change the ratio, values are first
234 * "capped" to a reasonable range (+N of the current value) and then
235 * averaged into the existing value by a ratio of 1:N. Hence
236 * receiving the largest possible priority can still only raise our
237 * "current_priorities" by at most 1.
239 extern double GSF_current_priorities;
242 * How many query messages have we received 'recently' that
243 * have not yet been claimed as cover traffic?
245 extern unsigned int GSF_cover_query_count;
248 * How many content messages have we received 'recently' that
249 * have not yet been claimed as cover traffic?
251 extern unsigned int GSF_cover_content_count;
256 extern struct GNUNET_BLOCK_Context *GSF_block_ctx;
259 * Are we introducing randomized delays for better anonymity?
261 extern int GSF_enable_randomized_delays;
264 * Size of the datastore queue we assume for common requests.
266 extern unsigned int GSF_datastore_queue_size;
270 * Function to be called after we're done processing
271 * replies from the local lookup. If the result status
272 * code indicates that there may be more replies, plan
273 * forwarding the request.
275 * @param cls closure (NULL)
276 * @param pr the pending request we were processing
277 * @param result final datastore lookup result
280 GSF_consider_forwarding (void *cls,
281 struct GSF_PendingRequest *pr,
282 enum GNUNET_BLOCK_EvaluationResult result);
286 * Test if the DATABASE (GET) load on this peer is too high
287 * to even consider processing the query at
290 * @return #GNUNET_YES if the load is too high to do anything (load high)
291 * #GNUNET_NO to process normally (load normal)
292 * #GNUNET_SYSERR to process for free (load low)
295 GSF_test_get_load_too_high_ (uint32_t priority);
299 * We've just now completed a datastore request. Update our
300 * datastore load calculations.
302 * @param start time when the datastore request was issued
305 GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start);
309 /* end of gnunet-service-fs.h */