aboutsummaryrefslogtreecommitdiff
path: root/src/service/fs/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/fs/fs.h')
-rw-r--r--src/service/fs/fs.h397
1 files changed, 397 insertions, 0 deletions
diff --git a/src/service/fs/fs.h b/src/service/fs/fs.h
new file mode 100644
index 000000000..c3bae65d2
--- /dev/null
+++ b/src/service/fs/fs.h
@@ -0,0 +1,397 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003--2012 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/fs.h
23 * @brief definitions for the entire fs module
24 * @author Igor Wronsky, Christian Grothoff
25 */
26#ifndef FS_H
27#define FS_H
28
29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h"
32
33#include "gnunet_fs_service.h"
34#include "gnunet_block_lib.h"
35#include "block_fs.h"
36
37
38/**
39 * Size of the individual blocks used for file-sharing.
40 */
41#define DBLOCK_SIZE (32 * 1024)
42
43/**
44 * Blocksize to use when hashing files for indexing (blocksize for IO,
45 * not for the DBlocks). Larger blocksizes can be more efficient but
46 * will be more disruptive as far as the scheduler is concerned.
47 */
48#define HASHING_BLOCKSIZE (1024 * 128)
49
50
51/**
52 * @brief content hash key
53 */
54struct ContentHashKey
55{
56 /**
57 * Hash of the original content, used for encryption.
58 */
59 struct GNUNET_HashCode key;
60
61 /**
62 * Hash of the encrypted content, used for querying.
63 */
64 struct GNUNET_HashCode query;
65};
66
67
68GNUNET_NETWORK_STRUCT_BEGIN
69
70
71/**
72 * Message sent from a GNUnet (fs) publishing activity to sign
73 * a LOC URI.
74 */
75struct RequestLocSignatureMessage
76{
77 /**
78 * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN.
79 */
80 struct GNUNET_MessageHeader header;
81
82 /**
83 * Requested signature purpose. For now, always
84 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
85 */
86 uint32_t purpose GNUNET_PACKED;
87
88 /**
89 * Requested expiration time.
90 */
91 struct GNUNET_TIME_AbsoluteNBO expiration_time;
92
93 /**
94 * Information about the shared file (to be signed).
95 */
96 struct ContentHashKey chk;
97
98 /**
99 * Size of the shared file (to be signed).
100 */
101 uint64_t file_length;
102};
103
104
105/**
106 * Message sent from the service with the signed LOC URI.
107 */
108struct ResponseLocSignatureMessage
109{
110 /**
111 * Message type will be
112 * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE.
113 */
114 struct GNUNET_MessageHeader header;
115
116 /**
117 * Purpose of the generated signature. For now, always
118 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
119 */
120 uint32_t purpose GNUNET_PACKED;
121
122 /**
123 * Expiration time that was actually used (rounded!).
124 */
125 struct GNUNET_TIME_AbsoluteNBO expiration_time;
126
127 /**
128 * The requested signature.
129 */
130 struct GNUNET_CRYPTO_EddsaSignature signature;
131
132 /**
133 * Identity of the peer sharing the file.
134 */
135 struct GNUNET_PeerIdentity peer;
136};
137
138
139/**
140 * Message sent from a GNUnet (fs) publishing activity to the
141 * gnunet-fs-service to initiate indexing of a file. The service is
142 * supposed to check if the specified file is available and has the
143 * same cryptographic hash. It should then respond with either a
144 * confirmation or a denial.
145 *
146 * On OSes where this works, it is considered acceptable if the
147 * service only checks that the path, device and inode match (it can
148 * then be assumed that the hash will also match without actually
149 * computing it; this is an optimization that should be safe given
150 * that the client is not our adversary).
151 */
152struct IndexStartMessage
153{
154 /**
155 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
156 */
157 struct GNUNET_MessageHeader header;
158
159 /**
160 * For alignment.
161 */
162 uint32_t reserved GNUNET_PACKED;
163
164 /**
165 * ID of device containing the file, as seen by the client. This
166 * device ID is obtained using a call like "statvfs" (and converting
167 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
168 * OS does not support this, in which case the service must do a
169 * full hash recomputation.
170 */
171 uint64_t device GNUNET_PACKED;
172
173 /**
174 * Inode of the file on the given device, as seen by the client
175 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
176 * support this, in which case the service must do a full hash
177 * recomputation.
178 */
179 uint64_t inode GNUNET_PACKED;
180
181 /**
182 * Hash of the file that we would like to index.
183 */
184 struct GNUNET_HashCode file_id;
185
186 /* this is followed by a 0-terminated
187 * filename of a file with the hash
188 * "file_id" as seen by the client */
189};
190
191
192/**
193 * Message send by FS service in response to a request
194 * asking for a list of all indexed files.
195 */
196struct IndexInfoMessage
197{
198 /**
199 * Message type will be
200 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
201 */
202 struct GNUNET_MessageHeader header;
203
204 /**
205 * Always zero.
206 */
207 uint32_t reserved GNUNET_PACKED;
208
209 /**
210 * Hash of the indexed file.
211 */
212 struct GNUNET_HashCode file_id;
213
214 /* this is followed by a 0-terminated
215 * filename of a file with the hash
216 * "file_id" as seen by the client */
217};
218
219
220/**
221 * Message sent from a GNUnet (fs) unindexing activity to the
222 * gnunet-service-fs to indicate that a file will be unindexed. The
223 * service is supposed to remove the file from the list of indexed
224 * files and response with a confirmation message (even if the file
225 * was already not on the list).
226 */
227struct UnindexMessage
228{
229 /**
230 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
231 */
232 struct GNUNET_MessageHeader header;
233
234 /**
235 * Always zero.
236 */
237 uint32_t reserved GNUNET_PACKED;
238
239 /**
240 * Hash of the file that we will unindex.
241 */
242 struct GNUNET_HashCode file_id;
243};
244
245
246/**
247 * No options.
248 */
249#define SEARCH_MESSAGE_OPTION_NONE 0
250
251/**
252 * Only search the local datastore (no network)
253 */
254#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
255
256/**
257 * Request is too large to fit in 64k format. The list of
258 * already-known search results will be continued in another message
259 * for the same type/query/target and additional already-known results
260 * following this one).
261 */
262#define SEARCH_MESSAGE_OPTION_CONTINUED 2
263
264
265/**
266 * Message sent from a GNUnet (fs) search activity to the
267 * gnunet-service-fs to start a search.
268 */
269struct SearchMessage
270{
271 /**
272 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
273 */
274 struct GNUNET_MessageHeader header;
275
276 /**
277 * Bitmask with options. Zero for no options, one for
278 * loopback-only, two for 'to be continued' (with a second search
279 * message for the same type/query/target and additional
280 * already-known results following this one). See
281 * SEARCH_MESSAGE_OPTION_ defines.
282 *
283 * Other bits are currently not defined.
284 */
285 uint32_t options GNUNET_PACKED;
286
287 /**
288 * Type of the content that we're looking for.
289 */
290 uint32_t type GNUNET_PACKED;
291
292 /**
293 * Desired anonymity level, big-endian.
294 */
295 uint32_t anonymity_level GNUNET_PACKED;
296
297 /**
298 * If the request is for a DBLOCK or IBLOCK, this is the identity of
299 * the peer that is known to have a response. Set to all-zeros if
300 * such a target is not known (note that even if OUR anonymity
301 * level is >0 we may happen to know the responder's identity;
302 * nevertheless, we should probably not use it for a DHT-lookup
303 * or similar blunt actions in order to avoid exposing ourselves).
304 * <p>
305 * Otherwise, "target" must be all zeros.
306 */
307 struct GNUNET_PeerIdentity target;
308
309 /**
310 * Hash of the public key for UBLOCKs; Hash of
311 * the CHK-encoded block for DBLOCKS and IBLOCKS.
312 */
313 struct GNUNET_HashCode query;
314
315 /* this is followed by the hash codes of already-known
316 * results (which should hence be excluded from what
317 * the service returns); naturally, this only applies
318 * to queries that can have multiple results (UBLOCKS).
319 */
320};
321
322
323/**
324 * Response from FS service with a result for a previous FS search.
325 * Note that queries for DBLOCKS and IBLOCKS that have received a
326 * single response are considered done. This message is transmitted
327 * between peers.
328 */
329struct PutMessage
330{
331 /**
332 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
333 */
334 struct GNUNET_MessageHeader header;
335
336 /**
337 * Type of the block (in big endian). Should never be zero.
338 */
339 uint32_t type GNUNET_PACKED;
340
341 /**
342 * When does this result expire?
343 */
344 struct GNUNET_TIME_AbsoluteNBO expiration;
345
346 /* this is followed by the actual encrypted content */
347};
348
349/**
350 * Response from FS service with a result for a previous FS search.
351 * Note that queries for DBLOCKS and IBLOCKS that have received a
352 * single response are considered done. This message is transmitted
353 * between the service and a client.
354 */
355struct ClientPutMessage
356{
357 /**
358 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
359 */
360 struct GNUNET_MessageHeader header;
361
362 /**
363 * Type of the block (in big endian). Should never be zero.
364 */
365 uint32_t type GNUNET_PACKED;
366
367 /**
368 * When does this result expire?
369 */
370 struct GNUNET_TIME_AbsoluteNBO expiration;
371
372 /**
373 * When was the last time we've tried to download this block?
374 * (FOREVER if unknown/not relevant)
375 */
376 struct GNUNET_TIME_AbsoluteNBO last_transmission;
377
378 /**
379 * How often did we transmit this query before getting an
380 * answer (estimate).
381 */
382 uint32_t num_transmissions;
383
384 /**
385 * How much respect did we offer (in total) before getting an
386 * answer (estimate).
387 */
388 uint32_t respect_offered;
389
390 /* this is followed by the actual encrypted content */
391};
392GNUNET_NETWORK_STRUCT_END
393
394
395#endif
396
397/* end of fs.h */