aboutsummaryrefslogtreecommitdiff
path: root/src/service/fs/gnunet-service-fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/fs/gnunet-service-fs.h')
-rw-r--r--src/service/fs/gnunet-service-fs.h304
1 files changed, 304 insertions, 0 deletions
diff --git a/src/service/fs/gnunet-service-fs.h b/src/service/fs/gnunet-service-fs.h
new file mode 100644
index 000000000..e102a1fba
--- /dev/null
+++ b/src/service/fs/gnunet-service-fs.h
@@ -0,0 +1,304 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010 GNUnet e.V.
4
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.
9
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.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file fs/gnunet-service-fs.h
23 * @brief shared data structures of gnunet-service-fs.c
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SERVICE_FS_H
27#define GNUNET_SERVICE_FS_H
28
29#include "gnunet_util_lib.h"
30#include "gnunet_statistics_service.h"
31#include "gnunet_core_service.h"
32#include "gnunet_block_lib.h"
33#include "fs.h"
34
35
36/**
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).
41 */
42#define TTL_DECREMENT 5000
43
44/**
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).
48 */
49#define DATASTORE_LOAD_AUTODECLINE GNUNET_TIME_relative_multiply ( \
50 GNUNET_TIME_UNIT_MILLISECONDS, 250)
51
52/**
53 * Only the (mandatory) query is included.
54 */
55#define GET_MESSAGE_BIT_QUERY_ONLY 0
56
57/**
58 * The peer identity of a peer waiting for the
59 * reply is included (used if the response
60 * should be transmitted to someone other than
61 * the sender of the GET).
62 */
63#define GET_MESSAGE_BIT_RETURN_TO 1
64
65/**
66 * The peer identity of a peer that had claimed to have the content
67 * previously is included (can be used if responder-anonymity is not
68 * desired; note that the precursor presumably lacked a direct
69 * connection to the specified peer; still, the receiver is in no way
70 * required to limit forwarding only to the specified peer, it should
71 * only prefer it somewhat if possible).
72 */
73#define GET_MESSAGE_BIT_TRANSMIT_TO 4
74
75
76GNUNET_NETWORK_STRUCT_BEGIN
77
78/**
79 * Message sent between peers asking for FS-content.
80 */
81struct GetMessage
82{
83 /**
84 * Message type will be #GNUNET_MESSAGE_TYPE_FS_GET.
85 */
86 struct GNUNET_MessageHeader header;
87
88 /**
89 * Type of the query (block type).
90 */
91 uint32_t type GNUNET_PACKED;
92
93 /**
94 * How important is this request (network byte order)
95 */
96 uint32_t priority GNUNET_PACKED;
97
98 /**
99 * Relative time to live in MILLISECONDS (network byte order)
100 */
101 int32_t ttl GNUNET_PACKED;
102
103 /**
104 * These days not used.
105 */
106 uint32_t reserved GNUNET_PACKED;
107
108 /**
109 * Which of the optional hash codes are present at the end of the
110 * message? See GET_MESSAGE_BIT_xx constants. For each bit that is
111 * set, an additional `struct GNUNET_HashCode` with the respective content
112 * (in order of the bits) will be appended to the end of the GET
113 * message.
114 */
115 uint32_t hash_bitmap GNUNET_PACKED;
116
117 /**
118 * Hashcodes of the file(s) we're looking for.
119 * Details depend on the query type.
120 */
121 struct GNUNET_HashCode query;
122
123 /* this is followed by PeerIdentities as specified in the "hash_bitmap";
124 * after that, an optional bloomfilter (with bits set for replies
125 * that should be suppressed) can be present */
126};
127
128
129/**
130 * Message send by a peer that wants to be excluded
131 * from migration for a while.
132 */
133struct MigrationStopMessage
134{
135 /**
136 * Message type will be
137 * GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP.
138 */
139 struct GNUNET_MessageHeader header;
140
141 /**
142 * Always zero.
143 */
144 uint32_t reserved GNUNET_PACKED;
145
146 /**
147 * How long should the block last?
148 */
149 struct GNUNET_TIME_RelativeNBO duration;
150};
151GNUNET_NETWORK_STRUCT_END
152
153/**
154 * A connected peer.
155 */
156struct GSF_ConnectedPeer;
157
158/**
159 * An active request.
160 */
161struct GSF_PendingRequest;
162
163/**
164 * A local client.
165 */
166struct GSF_LocalClient;
167
168/**
169 * Information kept per plan per request ('pe' module).
170 */
171struct GSF_RequestPlan;
172
173/**
174 * Bijection between request plans and pending requests.
175 */
176struct GSF_PendingRequestPlanBijection;
177
178/**
179 * Our connection to the datastore.
180 */
181extern struct GNUNET_DATASTORE_Handle *GSF_dsh;
182
183/**
184 * Our configuration.
185 */
186extern const struct GNUNET_CONFIGURATION_Handle *GSF_cfg;
187
188/**
189 * Handle for reporting statistics.
190 */
191extern struct GNUNET_STATISTICS_Handle *GSF_stats;
192
193/**
194 * Pointer to handle to the core service (points to NULL until we've
195 * connected to it).
196 */
197extern struct GNUNET_CORE_Handle *GSF_core;
198
199/**
200 * Handle for DHT operations.
201 */
202extern struct GNUNET_DHT_Handle *GSF_dht;
203
204/**
205 * How long do requests typically stay in the routing table?
206 */
207extern struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
208
209/**
210 * Running average of the observed latency to other peers (round trip).
211 */
212extern struct GNUNET_TIME_Relative GSF_avg_latency;
213
214/**
215 * Handle to ATS service.
216 */
217extern struct GNUNET_ATS_PerformanceHandle *GSF_ats;
218
219/**
220 * Identity of this peer.
221 */
222extern struct GNUNET_PeerIdentity GSF_my_id;
223
224/**
225 * Typical priorities we're seeing from other peers right now. Since
226 * most priorities will be zero, this value is the weighted average of
227 * non-zero priorities seen "recently". In order to ensure that new
228 * values do not dramatically change the ratio, values are first
229 * "capped" to a reasonable range (+N of the current value) and then
230 * averaged into the existing value by a ratio of 1:N. Hence
231 * receiving the largest possible priority can still only raise our
232 * "current_priorities" by at most 1.
233 */
234extern double GSF_current_priorities;
235
236/**
237 * How many query messages have we received 'recently' that
238 * have not yet been claimed as cover traffic?
239 */
240extern unsigned int GSF_cover_query_count;
241
242/**
243 * How many content messages have we received 'recently' that
244 * have not yet been claimed as cover traffic?
245 */
246extern unsigned int GSF_cover_content_count;
247
248/**
249 * Our block context.
250 */
251extern struct GNUNET_BLOCK_Context *GSF_block_ctx;
252
253/**
254 * Are we introducing randomized delays for better anonymity?
255 */
256extern int GSF_enable_randomized_delays;
257
258/**
259 * Size of the datastore queue we assume for common requests.
260 */
261extern unsigned int GSF_datastore_queue_size;
262
263
264/**
265 * Function to be called after we're done processing
266 * replies from the local lookup. If the result status
267 * code indicates that there may be more replies, plan
268 * forwarding the request.
269 *
270 * @param cls closure (NULL)
271 * @param pr the pending request we were processing
272 * @param result final datastore lookup result
273 */
274void
275GSF_consider_forwarding (void *cls,
276 struct GSF_PendingRequest *pr,
277 enum GNUNET_BLOCK_ReplyEvaluationResult result);
278
279
280/**
281 * Test if the DATABASE (GET) load on this peer is too high
282 * to even consider processing the query at
283 * all.
284 *
285 * @return #GNUNET_YES if the load is too high to do anything (load high)
286 * #GNUNET_NO to process normally (load normal)
287 * #GNUNET_SYSERR to process for free (load low)
288 */
289int
290GSF_test_get_load_too_high_ (uint32_t priority);
291
292
293/**
294 * We've just now completed a datastore request. Update our
295 * datastore load calculations.
296 *
297 * @param start time when the datastore request was issued
298 */
299void
300GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start);
301
302
303#endif
304/* end of gnunet-service-fs.h */