2 This file is part of GNUnet.
3 (C) 2003--2012 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, 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
70 * Message sent from a GNUnet (fs) publishing activity to the
71 * gnunet-fs-service to initiate indexing of a file. The service is
72 * supposed to check if the specified file is available and has the
73 * same cryptographic hash. It should then respond with either a
74 * confirmation or a denial.
76 * On OSes where this works, it is considered acceptable if the
77 * service only checks that the path, device and inode match (it can
78 * then be assumed that the hash will also match without actually
79 * computing it; this is an optimization that should be safe given
80 * that the client is not our adversary).
82 struct IndexStartMessage
86 * Message type will be #GNUNET_MESSAGE_TYPE_FS_INDEX_START.
88 struct GNUNET_MessageHeader header;
93 uint32_t reserved GNUNET_PACKED;
96 * ID of device containing the file, as seen by the client. This
97 * device ID is obtained using a call like "statvfs" (and converting
98 * the "f_fsid" field to a 32-bit big-endian number). Use 0 if the
99 * OS does not support this, in which case the service must do a
100 * full hash recomputation.
102 uint64_t device GNUNET_PACKED;
105 * Inode of the file on the given device, as seen by the client
106 * ("st_ino" field from "struct stat"). Use 0 if the OS does not
107 * support this, in which case the service must do a full hash
110 uint64_t inode GNUNET_PACKED;
113 * Hash of the file that we would like to index.
115 struct GNUNET_HashCode file_id;
117 /* this is followed by a 0-terminated
118 * filename of a file with the hash
119 * "file_id" as seen by the client */
125 * Message send by FS service in response to a request
126 * asking for a list of all indexed files.
128 struct IndexInfoMessage
131 * Message type will be
132 * #GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_ENTRY.
134 struct GNUNET_MessageHeader header;
139 uint32_t reserved GNUNET_PACKED;
142 * Hash of the indexed file.
144 struct GNUNET_HashCode file_id;
146 /* this is followed by a 0-terminated
147 * filename of a file with the hash
148 * "file_id" as seen by the client */
154 * Message sent from a GNUnet (fs) unindexing activity to the
155 * gnunet-service-fs to indicate that a file will be unindexed. The
156 * service is supposed to remove the file from the list of indexed
157 * files and response with a confirmation message (even if the file
158 * was already not on the list).
160 struct UnindexMessage
164 * Message type will be #GNUNET_MESSAGE_TYPE_FS_UNINDEX.
166 struct GNUNET_MessageHeader header;
171 uint32_t reserved GNUNET_PACKED;
174 * Hash of the file that we will unindex.
176 struct GNUNET_HashCode file_id;
184 #define SEARCH_MESSAGE_OPTION_NONE 0
187 * Only search the local datastore (no network)
189 #define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
192 * Request is too large to fit in 64k format. The list of
193 * already-known search results will be continued in another message
194 * for the same type/query/target and additional already-known results
195 * following this one).
197 #define SEARCH_MESSAGE_OPTION_CONTINUED 2
201 * Message sent from a GNUnet (fs) search activity to the
202 * gnunet-service-fs to start a search.
208 * Message type will be #GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
210 struct GNUNET_MessageHeader header;
213 * Bitmask with options. Zero for no options, one for
214 * loopback-only, two for 'to be continued' (with a second search
215 * message for the same type/query/target and additional
216 * already-known results following this one). See
217 * SEARCH_MESSAGE_OPTION_ defines.
219 * Other bits are currently not defined.
221 uint32_t options GNUNET_PACKED;
224 * Type of the content that we're looking for.
226 uint32_t type GNUNET_PACKED;
229 * Desired anonymity level, big-endian.
231 uint32_t anonymity_level GNUNET_PACKED;
234 * If the request is for a DBLOCK or IBLOCK, this is the identity of
235 * the peer that is known to have a response. Set to all-zeros if
236 * such a target is not known (note that even if OUR anonymity
237 * level is >0 we may happen to know the responder's identity;
238 * nevertheless, we should probably not use it for a DHT-lookup
239 * or similar blunt actions in order to avoid exposing ourselves).
241 * Otherwise, "target" must be all zeros.
243 struct GNUNET_PeerIdentity target;
246 * Hash of the public key for UBLOCKs; Hash of
247 * the CHK-encoded block for DBLOCKS and IBLOCKS.
249 struct GNUNET_HashCode query;
251 /* this is followed by the hash codes of already-known
252 * results (which should hence be excluded from what
253 * the service returns); naturally, this only applies
254 * to queries that can have multiple results (UBLOCKS).
260 * Response from FS service with a result for a previous FS search.
261 * Note that queries for DBLOCKS and IBLOCKS that have received a
262 * single response are considered done. This message is transmitted
269 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
271 struct GNUNET_MessageHeader header;
274 * Type of the block (in big endian). Should never be zero.
276 uint32_t type GNUNET_PACKED;
279 * When does this result expire?
281 struct GNUNET_TIME_AbsoluteNBO expiration;
283 /* this is followed by the actual encrypted content */
288 * Response from FS service with a result for a previous FS search.
289 * Note that queries for DBLOCKS and IBLOCKS that have received a
290 * single response are considered done. This message is transmitted
291 * between the service and a client.
293 struct ClientPutMessage
297 * Message type will be #GNUNET_MESSAGE_TYPE_FS_PUT.
299 struct GNUNET_MessageHeader header;
302 * Type of the block (in big endian). Should never be zero.
304 uint32_t type GNUNET_PACKED;
307 * When does this result expire?
309 struct GNUNET_TIME_AbsoluteNBO expiration;
312 * When was the last time we've tried to download this block?
313 * (FOREVER if unknown/not relevant)
315 struct GNUNET_TIME_AbsoluteNBO last_transmission;
318 * How often did we transmit this query before getting an
321 uint32_t num_transmissions;
324 * How much respect did we offer (in total) before getting an
327 uint32_t respect_offered;
329 /* this is followed by the actual encrypted content */
332 GNUNET_NETWORK_STRUCT_END