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 it
6 under the terms of the GNU 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.
18 * @brief definitions for the entire fs module
19 * @author Igor Wronsky, Christian Grothoff
24 #include "gnunet_constants.h"
25 #include "gnunet_datastore_service.h"
26 #include "gnunet_dht_service.h"
27 #include "gnunet_fs_service.h"
28 #include "gnunet_block_lib.h"
33 * Size of the individual blocks used for file-sharing.
35 #define DBLOCK_SIZE (32 * 1024)
38 * Blocksize to use when hashing files for indexing (blocksize for IO,
39 * not for the DBlocks). Larger blocksizes can be more efficient but
40 * will be more disruptive as far as the scheduler is concerned.
42 #define HASHING_BLOCKSIZE (1024 * 128)
46 * @brief content hash key
51 * Hash of the original content, used for encryption.
53 struct GNUNET_HashCode key;
56 * Hash of the encrypted content, used for querying.
58 struct GNUNET_HashCode query;
62 GNUNET_NETWORK_STRUCT_BEGIN
66 * Message sent from a GNUnet (fs) publishing activity to sign
69 struct RequestLocSignatureMessage
73 * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN.
75 struct GNUNET_MessageHeader header;
78 * Requested signature purpose. For now, always
79 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
81 uint32_t purpose GNUNET_PACKED;
84 * Requested expiration time.
86 struct GNUNET_TIME_AbsoluteNBO expiration_time;
89 * Information about the shared file (to be signed).
91 struct ContentHashKey chk;
94 * Size of the shared file (to be signed).
101 * Message sent from the service with the signed LOC URI.
103 struct ResponseLocSignatureMessage
107 * Message type will be
108 * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE.
110 struct GNUNET_MessageHeader header;
113 * Purpose of the generated signature. For now, always
114 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
116 uint32_t purpose GNUNET_PACKED;
119 * Expiration time that was actually used (rounded!).
121 struct GNUNET_TIME_AbsoluteNBO expiration_time;
124 * The requested signature.
126 struct GNUNET_CRYPTO_EddsaSignature signature;
129 * Identity of the peer sharing the file.
131 struct GNUNET_PeerIdentity peer;
136 * Message sent from a GNUnet (fs) publishing activity to the
137 * gnunet-fs-service to initiate indexing of a file. The service is
138 * supposed to check if the specified file is available and has the
139 * same cryptographic hash. It should then respond with either a
140 * confirmation or a denial.
142 * On OSes where this works, it is considered acceptable if the
143 * service only checks that the path, device and inode match (it can
144 * then be assumed that the hash will also match without actually
145 * computing it; this is an optimization that should be safe given
146 * that the client is not our adversary).
148 struct IndexStartMessage
152 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
154 struct GNUNET_MessageHeader header;
159 uint32_t reserved GNUNET_PACKED;
162 * ID of device containing the file, as seen by the client. This
163 * device ID is obtained using a call like "statvfs" (and converting
164 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
165 * OS does not support this, in which case the service must do a
166 * full hash recomputation.
168 uint64_t device GNUNET_PACKED;
171 * Inode of the file on the given device, as seen by the client
172 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
173 * support this, in which case the service must do a full hash
176 uint64_t inode GNUNET_PACKED;
179 * Hash of the file that we would like to index.
181 struct GNUNET_HashCode file_id;
183 /* this is followed by a 0-terminated
184 * filename of a file with the hash
185 * "file_id" as seen by the client */
191 * Message send by FS service in response to a request
192 * asking for a list of all indexed files.
194 struct IndexInfoMessage
197 * Message type will be
198 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
200 struct GNUNET_MessageHeader header;
205 uint32_t reserved GNUNET_PACKED;
208 * Hash of the indexed file.
210 struct GNUNET_HashCode file_id;
212 /* this is followed by a 0-terminated
213 * filename of a file with the hash
214 * "file_id" as seen by the client */
220 * Message sent from a GNUnet (fs) unindexing activity to the
221 * gnunet-service-fs to indicate that a file will be unindexed. The
222 * service is supposed to remove the file from the list of indexed
223 * files and response with a confirmation message (even if the file
224 * was already not on the list).
226 struct UnindexMessage
230 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
232 struct GNUNET_MessageHeader header;
237 uint32_t reserved GNUNET_PACKED;
240 * Hash of the file that we will unindex.
242 struct GNUNET_HashCode file_id;
250 #define SEARCH_MESSAGE_OPTION_NONE 0
253 * Only search the local datastore (no network)
255 #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
258 * Request is too large to fit in 64k format. The list of
259 * already-known search results will be continued in another message
260 * for the same type/query/target and additional already-known results
261 * following this one).
263 #define SEARCH_MESSAGE_OPTION_CONTINUED 2
267 * Message sent from a GNUnet (fs) search activity to the
268 * gnunet-service-fs to start a search.
274 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
276 struct GNUNET_MessageHeader header;
279 * Bitmask with options. Zero for no options, one for
280 * loopback-only, two for 'to be continued' (with a second search
281 * message for the same type/query/target and additional
282 * already-known results following this one). See
283 * SEARCH_MESSAGE_OPTION_ defines.
285 * Other bits are currently not defined.
287 uint32_t options GNUNET_PACKED;
290 * Type of the content that we're looking for.
292 uint32_t type GNUNET_PACKED;
295 * Desired anonymity level, big-endian.
297 uint32_t anonymity_level GNUNET_PACKED;
300 * If the request is for a DBLOCK or IBLOCK, this is the identity of
301 * the peer that is known to have a response. Set to all-zeros if
302 * such a target is not known (note that even if OUR anonymity
303 * level is >0 we may happen to know the responder's identity;
304 * nevertheless, we should probably not use it for a DHT-lookup
305 * or similar blunt actions in order to avoid exposing ourselves).
307 * Otherwise, "target" must be all zeros.
309 struct GNUNET_PeerIdentity target;
312 * Hash of the public key for UBLOCKs; Hash of
313 * the CHK-encoded block for DBLOCKS and IBLOCKS.
315 struct GNUNET_HashCode query;
317 /* this is followed by the hash codes of already-known
318 * results (which should hence be excluded from what
319 * the service returns); naturally, this only applies
320 * to queries that can have multiple results (UBLOCKS).
326 * Response from FS service with a result for a previous FS search.
327 * Note that queries for DBLOCKS and IBLOCKS that have received a
328 * single response are considered done. This message is transmitted
335 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
337 struct GNUNET_MessageHeader header;
340 * Type of the block (in big endian). Should never be zero.
342 uint32_t type GNUNET_PACKED;
345 * When does this result expire?
347 struct GNUNET_TIME_AbsoluteNBO expiration;
349 /* this is followed by the actual encrypted content */
354 * Response from FS service with a result for a previous FS search.
355 * Note that queries for DBLOCKS and IBLOCKS that have received a
356 * single response are considered done. This message is transmitted
357 * between the service and a client.
359 struct ClientPutMessage
363 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
365 struct GNUNET_MessageHeader header;
368 * Type of the block (in big endian). Should never be zero.
370 uint32_t type GNUNET_PACKED;
373 * When does this result expire?
375 struct GNUNET_TIME_AbsoluteNBO expiration;
378 * When was the last time we've tried to download this block?
379 * (FOREVER if unknown/not relevant)
381 struct GNUNET_TIME_AbsoluteNBO last_transmission;
384 * How often did we transmit this query before getting an
387 uint32_t num_transmissions;
390 * How much respect did we offer (in total) before getting an
393 uint32_t respect_offered;
395 /* this is followed by the actual encrypted content */
398 GNUNET_NETWORK_STRUCT_END