2 This file is part of GNUnet.
3 (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 2, 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_datastore_service.h"
30 #include "gnunet_fs_service.h"
33 * Size of the individual blocks used for file-sharing.
35 #define GNUNET_FS_DBLOCK_SIZE (32*1024)
39 * Pick a multiple of 2 here to achive 8-byte alignment!
40 * We also probably want DBlocks to have (roughly) the
41 * same size as IBlocks. With SHA-512, the optimal
42 * value is 32768 byte / 128 byte = 256
43 * (128 byte = 2 * 512 bits). DO NOT CHANGE!
45 #define GNUNET_FS_CHK_PER_INODE 256
49 * Maximum size for a file to be considered for
50 * inlining in a directory.
52 #define GNUNET_FS_MAX_INLINE_SIZE 65536
57 * @brief content hash key
62 GNUNET_HashCode query;
67 * @brief complete information needed
74 * Total size of the file in bytes. (network byte order (!))
79 * Query and key of the top GNUNET_EC_IBlock.
81 struct ContentHashKey chk;
87 * Information about a file and its location
88 * (peer claiming to share the file).
93 * Information about the shared file.
95 struct FileIdentifier fi;
98 * Identity of the peer sharing the file.
100 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
103 * Time when this location URI expires.
105 struct GNUNET_TIME_Absolute expirationTime;
108 * RSA signature over the GNUNET_EC_FileIdentifier,
109 * GNUNET_hash of the peer and expiration time.
111 struct GNUNET_CRYPTO_RsaSignature contentSignature;
116 { chk, sks, ksk, loc };
119 * A Universal Resource Identifier (URI), opaque.
129 * Keywords start with a '+' if they are
130 * mandatory (in which case the '+' is NOT
131 * part of the keyword) and with a
132 * simple space if they are optional
133 * (in which case the space is ALSO not
134 * part of the actual keyword).
136 * Double-quotes to protect spaces and
137 * %-encoding are NOT used internally
138 * (only in URI-strings).
143 * Size of the keywords array.
145 unsigned int keywordCount;
151 * Hash of the public key for the namespace.
153 GNUNET_HashCode namespace;
156 * Human-readable identifier chosen for this
157 * entry in the namespace.
163 * Information needed to retrieve a file (content-hash-key
166 struct FileIdentifier chk;
169 * Information needed to retrieve a file including signed
170 * location (identity of a peer) of the content.
179 * Information for a file or directory that is
180 * about to be published.
182 struct GNUNET_FS_FileInformation
186 * Files in a directory are kept as a linked list.
188 struct GNUNET_FS_FileInformation *next;
191 * If this is a file in a directory, "dir" refers to
192 * the directory; otherwise NULL.
194 struct GNUNET_FS_FileInformation *dir;
197 * Pointer kept for the client.
202 * Metadata to use for the file.
204 struct GNUNET_CONTAINER_MetaData *meta;
207 * Keywords to use for KBlocks.
209 struct GNUNET_FS_Uri *keywords;
212 * CHK for this file or directory. NULL if
213 * we have not yet computed it.
215 struct GNUNET_FS_Uri *chk_uri;
218 * At what time should the content expire?
220 struct GNUNET_TIME_Absolute expirationTime;
223 * Under what filename is this struct serialized
224 * (for operational persistence).
229 * In-memory cache of the current CHK tree.
230 * This struct will contain the CHK values
231 * from the root to the currently processed
232 * node in the tree as identified by
233 * "current_depth" and "publish_offset".
234 * The "chktree" will be initially NULL,
235 * then allocated to a sufficient number of
236 * entries for the size of the file and
237 * finally freed once the upload is complete.
239 struct ContentHashKey *chk_tree;
242 * Number of entries in "chk_tree".
244 unsigned int chk_tree_depth;
247 * Depth in the CHK-tree at which we are
248 * currently publishing. 0 is the root
251 unsigned int current_depth;
254 * How many bytes of this file or directory have been
257 uint64_t publish_offset;
260 * Data describing either the file or the directory.
271 * Function that can be used to read the data for the file.
273 GNUNET_FS_DataReader reader;
276 * Closure for reader.
281 * Size of the file (in bytes).
286 * Should the file be indexed or inserted?
293 * Data for a directory.
298 * Name of the directory.
303 * Linked list of entries in the directory.
305 struct GNUNET_FS_FileInformation *entries;
308 * Size of the directory itself (in bytes); 0 if the
309 * size has not yet been calculated.
314 * Pointer to the data for the directory (or NULL if not
324 * Is this struct for a file or directory?
329 * Desired anonymity level.
331 unsigned int anonymity;
334 * Desired priority (for keeping the content in the DB).
336 unsigned int priority;
342 * Master context for most FS operations.
344 struct GNUNET_FS_Handle
349 struct GNUNET_SCHEDULER_Handle *sched;
352 * Configuration to use.
354 const struct GNUNET_CONFIGURATION_Handle *cfg;
357 * Name of our client.
362 * Function to call with updates on our progress.
364 GNUNET_FS_ProgressCallback upcb;
372 * Connection to the FS service.
374 struct GNUNET_CLIENT_Connection *client;
381 * Handle for controlling an upload.
383 struct GNUNET_FS_PublishContext
386 * Handle to the global fs context.
388 struct GNUNET_FS_Handle *h;
391 * Argument to pass to the client in callbacks.
396 * File-structure that is being shared.
398 struct GNUNET_FS_FileInformation *fi;
401 * Namespace that we are publishing in, NULL if we have no namespace.
403 struct GNUNET_FS_Namespace *namespace;
406 * ID of the content in the namespace, NULL if we have no namespace.
411 * ID for future updates, NULL if we have no namespace or no updates.
416 * ID of the task performing the upload. NO_TASK
417 * if the upload has completed.
419 GNUNET_SCHEDULER_TaskIdentifier upload_task;
422 * Current position in the file-tree for the
425 struct GNUNET_FS_FileInformation *fi_pos;
428 * Connection to the datastore service.
430 struct GNUNET_DATASTORE_Handle *dsh;
433 * Space reservation ID with datastore service
441 * Handle for controlling an unindexing operation.
443 struct GNUNET_FS_UnindexContext
449 * Handle for controlling a search.
451 struct GNUNET_FS_SearchContext
457 * Context for controlling a download.
459 struct GNUNET_FS_DownloadContext
463 struct GNUNET_FS_Namespace