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 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/>.
21 * @brief definitions for the entire fs module
22 * @author Igor Wronsky, Christian Grothoff
27 #include "gnunet_constants.h"
28 #include "gnunet_datastore_service.h"
29 #include "gnunet_dht_service.h"
30 #include "gnunet_fs_service.h"
31 #include "gnunet_block_lib.h"
36 * Size of the individual blocks used for file-sharing.
38 #define DBLOCK_SIZE (32 * 1024)
41 * Blocksize to use when hashing files for indexing (blocksize for IO,
42 * not for the DBlocks). Larger blocksizes can be more efficient but
43 * will be more disruptive as far as the scheduler is concerned.
45 #define HASHING_BLOCKSIZE (1024 * 128)
49 * @brief content hash key
54 * Hash of the original content, used for encryption.
56 struct GNUNET_HashCode key;
59 * Hash of the encrypted content, used for querying.
61 struct GNUNET_HashCode query;
65 GNUNET_NETWORK_STRUCT_BEGIN
69 * Message sent from a GNUnet (fs) publishing activity to sign
72 struct RequestLocSignatureMessage
76 * Message type will be #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN.
78 struct GNUNET_MessageHeader header;
81 * Requested signature purpose. For now, always
82 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
84 uint32_t purpose GNUNET_PACKED;
87 * Requested expiration time.
89 struct GNUNET_TIME_AbsoluteNBO expiration_time;
92 * Information about the shared file (to be signed).
94 struct ContentHashKey chk;
97 * Size of the shared file (to be signed).
104 * Message sent from the service with the signed LOC URI.
106 struct ResponseLocSignatureMessage
110 * Message type will be
111 * #GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE.
113 struct GNUNET_MessageHeader header;
116 * Purpose of the generated signature. For now, always
117 * #GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT.
119 uint32_t purpose GNUNET_PACKED;
122 * Expiration time that was actually used (rounded!).
124 struct GNUNET_TIME_AbsoluteNBO expiration_time;
127 * The requested signature.
129 struct GNUNET_CRYPTO_EddsaSignature signature;
132 * Identity of the peer sharing the file.
134 struct GNUNET_PeerIdentity peer;
139 * Message sent from a GNUnet (fs) publishing activity to the
140 * gnunet-fs-service to initiate indexing of a file. The service is
141 * supposed to check if the specified file is available and has the
142 * same cryptographic hash. It should then respond with either a
143 * confirmation or a denial.
145 * On OSes where this works, it is considered acceptable if the
146 * service only checks that the path, device and inode match (it can
147 * then be assumed that the hash will also match without actually
148 * computing it; this is an optimization that should be safe given
149 * that the client is not our adversary).
151 struct IndexStartMessage
155 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
157 struct GNUNET_MessageHeader header;
162 uint32_t reserved GNUNET_PACKED;
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.
171 uint64_t device GNUNET_PACKED;
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
179 uint64_t inode GNUNET_PACKED;
182 * Hash of the file that we would like to index.
184 struct GNUNET_HashCode file_id;
186 /* this is followed by a 0-terminated
187 * filename of a file with the hash
188 * "file_id" as seen by the client */
194 * Message send by FS service in response to a request
195 * asking for a list of all indexed files.
197 struct IndexInfoMessage
200 * Message type will be
201 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
203 struct GNUNET_MessageHeader header;
208 uint32_t reserved GNUNET_PACKED;
211 * Hash of the indexed file.
213 struct GNUNET_HashCode file_id;
215 /* this is followed by a 0-terminated
216 * filename of a file with the hash
217 * "file_id" as seen by the client */
223 * Message sent from a GNUnet (fs) unindexing activity to the
224 * gnunet-service-fs to indicate that a file will be unindexed. The
225 * service is supposed to remove the file from the list of indexed
226 * files and response with a confirmation message (even if the file
227 * was already not on the list).
229 struct UnindexMessage
233 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
235 struct GNUNET_MessageHeader header;
240 uint32_t reserved GNUNET_PACKED;
243 * Hash of the file that we will unindex.
245 struct GNUNET_HashCode file_id;
253 #define SEARCH_MESSAGE_OPTION_NONE 0
256 * Only search the local datastore (no network)
258 #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
261 * Request is too large to fit in 64k format. The list of
262 * already-known search results will be continued in another message
263 * for the same type/query/target and additional already-known results
264 * following this one).
266 #define SEARCH_MESSAGE_OPTION_CONTINUED 2
270 * Message sent from a GNUnet (fs) search activity to the
271 * gnunet-service-fs to start a search.
277 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
279 struct GNUNET_MessageHeader header;
282 * Bitmask with options. Zero for no options, one for
283 * loopback-only, two for 'to be continued' (with a second search
284 * message for the same type/query/target and additional
285 * already-known results following this one). See
286 * SEARCH_MESSAGE_OPTION_ defines.
288 * Other bits are currently not defined.
290 uint32_t options GNUNET_PACKED;
293 * Type of the content that we're looking for.
295 uint32_t type GNUNET_PACKED;
298 * Desired anonymity level, big-endian.
300 uint32_t anonymity_level GNUNET_PACKED;
303 * If the request is for a DBLOCK or IBLOCK, this is the identity of
304 * the peer that is known to have a response. Set to all-zeros if
305 * such a target is not known (note that even if OUR anonymity
306 * level is >0 we may happen to know the responder's identity;
307 * nevertheless, we should probably not use it for a DHT-lookup
308 * or similar blunt actions in order to avoid exposing ourselves).
310 * Otherwise, "target" must be all zeros.
312 struct GNUNET_PeerIdentity target;
315 * Hash of the public key for UBLOCKs; Hash of
316 * the CHK-encoded block for DBLOCKS and IBLOCKS.
318 struct GNUNET_HashCode query;
320 /* this is followed by the hash codes of already-known
321 * results (which should hence be excluded from what
322 * the service returns); naturally, this only applies
323 * to queries that can have multiple results (UBLOCKS).
329 * Response from FS service with a result for a previous FS search.
330 * Note that queries for DBLOCKS and IBLOCKS that have received a
331 * single response are considered done. This message is transmitted
338 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
340 struct GNUNET_MessageHeader header;
343 * Type of the block (in big endian). Should never be zero.
345 uint32_t type GNUNET_PACKED;
348 * When does this result expire?
350 struct GNUNET_TIME_AbsoluteNBO expiration;
352 /* this is followed by the actual encrypted content */
357 * Response from FS service with a result for a previous FS search.
358 * Note that queries for DBLOCKS and IBLOCKS that have received a
359 * single response are considered done. This message is transmitted
360 * between the service and a client.
362 struct ClientPutMessage
366 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
368 struct GNUNET_MessageHeader header;
371 * Type of the block (in big endian). Should never be zero.
373 uint32_t type GNUNET_PACKED;
376 * When does this result expire?
378 struct GNUNET_TIME_AbsoluteNBO expiration;
381 * When was the last time we've tried to download this block?
382 * (FOREVER if unknown/not relevant)
384 struct GNUNET_TIME_AbsoluteNBO last_transmission;
387 * How often did we transmit this query before getting an
390 uint32_t num_transmissions;
393 * How much respect did we offer (in total) before getting an
396 uint32_t respect_offered;
398 /* this is followed by the actual encrypted content */
401 GNUNET_NETWORK_STRUCT_END