2 This file is part of GNUnet.
3 Copyright (C) 2003--2012 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
23 * @brief definitions for the entire fs module
24 * @author Igor Wronsky, Christian Grothoff
29 #include "gnunet_constants.h"
30 #include "gnunet_datastore_service.h"
31 #include "gnunet_dht_service.h"
32 #include "gnunet_fs_service.h"
33 #include "gnunet_block_lib.h"
38 * Size of the individual blocks used for file-sharing.
40 #define DBLOCK_SIZE (32 * 1024)
43 * Blocksize to use when hashing files for indexing (blocksize for IO,
44 * not for the DBlocks). Larger blocksizes can be more efficient but
45 * will be more disruptive as far as the scheduler is concerned.
47 #define HASHING_BLOCKSIZE (1024 * 128)
51 * @brief content hash key
56 * Hash of the original content, used for encryption.
58 struct GNUNET_HashCode key;
61 * Hash of the encrypted content, used for querying.
63 struct GNUNET_HashCode query;
67 GNUNET_NETWORK_STRUCT_BEGIN
71 * Message sent from a GNUnet (fs) publishing activity to sign
74 struct RequestLocSignatureMessage
78 * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN.
80 struct GNUNET_MessageHeader header;
83 * Requested signature purpose. For now, always
84 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
86 uint32_t purpose GNUNET_PACKED;
89 * Requested expiration time.
91 struct GNUNET_TIME_AbsoluteNBO expiration_time;
94 * Information about the shared file (to be signed).
96 struct ContentHashKey chk;
99 * Size of the shared file (to be signed).
101 uint64_t file_length;
106 * Message sent from the service with the signed LOC URI.
108 struct ResponseLocSignatureMessage
112 * Message type will be
113 * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE.
115 struct GNUNET_MessageHeader header;
118 * Purpose of the generated signature. For now, always
119 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
121 uint32_t purpose GNUNET_PACKED;
124 * Expiration time that was actually used (rounded!).
126 struct GNUNET_TIME_AbsoluteNBO expiration_time;
129 * The requested signature.
131 struct GNUNET_CRYPTO_EddsaSignature signature;
134 * Identity of the peer sharing the file.
136 struct GNUNET_PeerIdentity peer;
141 * Message sent from a GNUnet (fs) publishing activity to the
142 * gnunet-fs-service to initiate indexing of a file. The service is
143 * supposed to check if the specified file is available and has the
144 * same cryptographic hash. It should then respond with either a
145 * confirmation or a denial.
147 * On OSes where this works, it is considered acceptable if the
148 * service only checks that the path, device and inode match (it can
149 * then be assumed that the hash will also match without actually
150 * computing it; this is an optimization that should be safe given
151 * that the client is not our adversary).
153 struct IndexStartMessage
157 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
159 struct GNUNET_MessageHeader header;
164 uint32_t reserved GNUNET_PACKED;
167 * ID of device containing the file, as seen by the client. This
168 * device ID is obtained using a call like "statvfs" (and converting
169 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
170 * OS does not support this, in which case the service must do a
171 * full hash recomputation.
173 uint64_t device GNUNET_PACKED;
176 * Inode of the file on the given device, as seen by the client
177 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
178 * support this, in which case the service must do a full hash
181 uint64_t inode GNUNET_PACKED;
184 * Hash of the file that we would like to index.
186 struct GNUNET_HashCode file_id;
188 /* this is followed by a 0-terminated
189 * filename of a file with the hash
190 * "file_id" as seen by the client */
196 * Message send by FS service in response to a request
197 * asking for a list of all indexed files.
199 struct IndexInfoMessage
202 * Message type will be
203 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
205 struct GNUNET_MessageHeader header;
210 uint32_t reserved GNUNET_PACKED;
213 * Hash of the indexed file.
215 struct GNUNET_HashCode file_id;
217 /* this is followed by a 0-terminated
218 * filename of a file with the hash
219 * "file_id" as seen by the client */
225 * Message sent from a GNUnet (fs) unindexing activity to the
226 * gnunet-service-fs to indicate that a file will be unindexed. The
227 * service is supposed to remove the file from the list of indexed
228 * files and response with a confirmation message (even if the file
229 * was already not on the list).
231 struct UnindexMessage
235 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
237 struct GNUNET_MessageHeader header;
242 uint32_t reserved GNUNET_PACKED;
245 * Hash of the file that we will unindex.
247 struct GNUNET_HashCode file_id;
255 #define SEARCH_MESSAGE_OPTION_NONE 0
258 * Only search the local datastore (no network)
260 #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
263 * Request is too large to fit in 64k format. The list of
264 * already-known search results will be continued in another message
265 * for the same type/query/target and additional already-known results
266 * following this one).
268 #define SEARCH_MESSAGE_OPTION_CONTINUED 2
272 * Message sent from a GNUnet (fs) search activity to the
273 * gnunet-service-fs to start a search.
279 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
281 struct GNUNET_MessageHeader header;
284 * Bitmask with options. Zero for no options, one for
285 * loopback-only, two for 'to be continued' (with a second search
286 * message for the same type/query/target and additional
287 * already-known results following this one). See
288 * SEARCH_MESSAGE_OPTION_ defines.
290 * Other bits are currently not defined.
292 uint32_t options GNUNET_PACKED;
295 * Type of the content that we're looking for.
297 uint32_t type GNUNET_PACKED;
300 * Desired anonymity level, big-endian.
302 uint32_t anonymity_level GNUNET_PACKED;
305 * If the request is for a DBLOCK or IBLOCK, this is the identity of
306 * the peer that is known to have a response. Set to all-zeros if
307 * such a target is not known (note that even if OUR anonymity
308 * level is >0 we may happen to know the responder's identity;
309 * nevertheless, we should probably not use it for a DHT-lookup
310 * or similar blunt actions in order to avoid exposing ourselves).
312 * Otherwise, "target" must be all zeros.
314 struct GNUNET_PeerIdentity target;
317 * Hash of the public key for UBLOCKs; Hash of
318 * the CHK-encoded block for DBLOCKS and IBLOCKS.
320 struct GNUNET_HashCode query;
322 /* this is followed by the hash codes of already-known
323 * results (which should hence be excluded from what
324 * the service returns); naturally, this only applies
325 * to queries that can have multiple results (UBLOCKS).
331 * Response from FS service with a result for a previous FS search.
332 * Note that queries for DBLOCKS and IBLOCKS that have received a
333 * single response are considered done. This message is transmitted
340 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
342 struct GNUNET_MessageHeader header;
345 * Type of the block (in big endian). Should never be zero.
347 uint32_t type GNUNET_PACKED;
350 * When does this result expire?
352 struct GNUNET_TIME_AbsoluteNBO expiration;
354 /* this is followed by the actual encrypted content */
359 * Response from FS service with a result for a previous FS search.
360 * Note that queries for DBLOCKS and IBLOCKS that have received a
361 * single response are considered done. This message is transmitted
362 * between the service and a client.
364 struct ClientPutMessage
368 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
370 struct GNUNET_MessageHeader header;
373 * Type of the block (in big endian). Should never be zero.
375 uint32_t type GNUNET_PACKED;
378 * When does this result expire?
380 struct GNUNET_TIME_AbsoluteNBO expiration;
383 * When was the last time we've tried to download this block?
384 * (FOREVER if unknown/not relevant)
386 struct GNUNET_TIME_AbsoluteNBO last_transmission;
389 * How often did we transmit this query before getting an
392 uint32_t num_transmissions;
395 * How much respect did we offer (in total) before getting an
398 uint32_t respect_offered;
400 /* this is followed by the actual encrypted content */
403 GNUNET_NETWORK_STRUCT_END