/*
This file is part of GNUnet.
- (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
/**
* Identity of the peer sharing the file.
*/
- struct GNUNET_CRYPTO_EccPublicSignKey peer;
+ struct GNUNET_PeerIdentity peer;
/**
* Time when this location URI expires.
struct GNUNET_TIME_Absolute expirationTime;
/**
- * RSA signature over the GNUNET_EC_FileIdentifier,
- * GNUNET_hash of the peer and expiration time.
+ * Signature over the GNUNET_EC_FileIdentifier,
+ * peer identity and expiration time.
*/
- struct GNUNET_CRYPTO_EccSignature contentSignature;
+ struct GNUNET_CRYPTO_EddsaSignature contentSignature;
};
*/
enum GNUNET_FS_UriType
{
- /**
- * Content-hash-key (simple file).
- */
+ /**
+ * Content-hash-key (simple file).
+ */
GNUNET_FS_URI_CHK,
- /**
- * Signed key space (file in namespace).
- */
+ /**
+ * Signed key space (file in namespace).
+ */
GNUNET_FS_URI_SKS,
- /**
- * Keyword search key (query with keywords).
- */
+ /**
+ * Keyword search key (query with keywords).
+ */
GNUNET_FS_URI_KSK,
- /**
- * Location (chk with identity of hosting peer).
- */
+ /**
+ * Location (chk with identity of hosting peer).
+ */
GNUNET_FS_URI_LOC
};
/**
* Identifier of the namespace.
*/
- struct GNUNET_CRYPTO_EccPublicSignKey ns;
+ struct GNUNET_CRYPTO_EcdsaPublicKey ns;
/**
* Human-readable identifier chosen for this entry in the
*/
struct GNUNET_FS_Uri *chk_uri;
+ /**
+ * SKS URI for this file or directory. NULL if
+ * we have not yet computed it.
+ */
+ struct GNUNET_FS_Uri *sks_uri;
+
/**
* Block options for the file.
*/
int do_index;
/**
- * Is "file_id" already valid? Set to GNUNET_YES once the hash
+ * Is "file_id" already valid? Set to #GNUNET_YES once the hash
* has been calculated.
*/
int have_hash;
/**
* Has the service confirmed our INDEX_START request?
- * GNUNET_YES if this step has been completed.
+ * #GNUNET_YES if this step has been completed.
*/
int index_start_confirmed;
*/
void *dir_data;
+ /**
+ * How much of the directory have we published (relative to @e contents_size).
+ */
+ uint64_t contents_completed;
+
+ /**
+ * Sum of all of the sizes of all of the files in the directory.
+ */
+ uint64_t contents_size;
+
} dir;
} data;
* @param cls closure
* @param client handle to use for FS communication
*/
-typedef void (*GNUNET_FS_QueueStart) (void *cls,
- struct GNUNET_CLIENT_Connection * client);
+typedef void
+(*GNUNET_FS_QueueStart) (void *cls,
+ struct GNUNET_CLIENT_Connection *client);
/**
* The job must now stop to run and should destry the client handle as
* soon as possible (ideally prior to returning).
*/
-typedef void (*GNUNET_FS_QueueStop) (void *cls);
+typedef void
+(*GNUNET_FS_QueueStop) (void *cls);
/**
* Priorities for the queue.
- */
+ */
enum GNUNET_FS_QueuePriority
- {
- /**
- * This is a probe (low priority).
- */
- GNUNET_FS_QUEUE_PRIORITY_PROBE,
+{
+ /**
+ * This is a probe (low priority).
+ */
+ GNUNET_FS_QUEUE_PRIORITY_PROBE,
- /**
- * Default priority.
- */
- GNUNET_FS_QUEUE_PRIORITY_NORMAL
- };
+ /**
+ * Default priority.
+ */
+ GNUNET_FS_QUEUE_PRIORITY_NORMAL
+};
/**
*/
struct GNUNET_FS_Handle *h;
+ /**
+ * Kept in a DLL while probing.
+ */
+ struct GNUNET_FS_SearchResult *next;
+
+ /**
+ * Kept in a DLL while probing.
+ */
+ struct GNUNET_FS_SearchResult *prev;
+
/**
* Search context this result belongs to; can be NULL
* for probes that come from a directory result.
uint8_t *keyword_bitmap;
/**
- * Key for the search result
+ * Key for the search result based on the URI.
*/
struct GNUNET_HashCode key;
* complete on time (and that will need to be cancelled if we clean
* up the search result before then).
*/
- GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task;
-
- /**
- * Task we use to report periodically to the application that the
- * probe is still running.
- */
- GNUNET_SCHEDULER_TaskIdentifier probe_ping_task;
+ struct GNUNET_SCHEDULER_Task * probe_cancel_task;
/**
* When did the current probe become active?
* @return queue handle
*/
struct GNUNET_FS_QueueEntry *
-GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start,
- GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks,
+GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
+ GNUNET_FS_QueueStart start,
+ GNUNET_FS_QueueStop stop,
+ void *cls,
+ unsigned int blocks,
enum GNUNET_FS_QueuePriority priority);
* that the caller might need to go backwards
* a bit at times
* @param max maximum number of bytes that should be
- * copied to buf; readers are not allowed
+ * copied to @a buf; readers are not allowed
* to provide less data unless there is an error;
* a value of "0" will be used at the end to allow
* the reader to clean up its internal state
* @return number of bytes written, usually "max", 0 on error
*/
size_t
-GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf,
+GNUNET_FS_data_reader_file_ (void *cls,
+ uint64_t offset,
+ size_t max,
+ void *buf,
char **emsg);
/**
- * Create the closure for the 'GNUNET_FS_data_reader_file_' callback.
+ * Create the closure for the #GNUNET_FS_data_reader_file_() callback.
*
* @param filename file to read
* @return closure to use
* that the caller might need to go backwards
* a bit at times
* @param max maximum number of bytes that should be
- * copied to buf; readers are not allowed
+ * copied to @a buf; readers are not allowed
* to provide less data unless there is an error;
* a value of "0" will be used at the end to allow
* the reader to clean up its internal state
* @param buf where the reader should write the data
* @param emsg location for the reader to store an error message
- * @return number of bytes written, usually "max", 0 on error
+ * @return number of bytes written, usually @a max, 0 on error
*/
size_t
-GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf,
+GNUNET_FS_data_reader_copy_ (void *cls,
+ uint64_t offset,
+ size_t max,
+ void *buf,
char **emsg);
+
/**
* Notification of FS that a search probe has made progress.
* This function is used INSTEAD of the client's event handler
- * for downloads where the GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.
+ * for downloads where the #GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.
*
* @param cls closure, always NULL (!), actual closure
* is in the client-context of the info struct
* for this operation; should be set to NULL for
* SUSPEND and STOPPED events). The value returned
* will be passed to future callbacks in the respective
- * field in the GNUNET_FS_ProgressInfo struct.
+ * field in the `struct GNUNET_FS_ProgressInfo`.
*/
void *
GNUNET_FS_search_probe_progress_ (void *cls,
/**
* Main function that performs the upload.
*
- * @param cls "struct GNUNET_FS_PublishContext" identifies the upload
- * @param tc task context
+ * @param cls `struct GNUNET_FS_PublishContext` identifies the upload
*/
void
-GNUNET_FS_publish_main_ (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+GNUNET_FS_publish_main_ (void *cls);
/**
* @param file_id computed hash, NULL on error
*/
void
-GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode * file_id);
+GNUNET_FS_unindex_process_hash_ (void *cls,
+ const struct GNUNET_HashCode *file_id);
/**
* request for the file.
*
* @param cls the 'struct GNUNET_FS_DownloadContext'
- * @param tc scheduler context
*/
void
-GNUNET_FS_download_start_task_ (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+GNUNET_FS_download_start_task_ (void *cls);
void
GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr);
+
/**
* Remove serialization/deserialization file from disk.
*
* @param ent entity identifier
*/
void
-GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
+GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
+ const char *ext,
const char *ent);
* @param uni unique name of parent
*/
void
-GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext,
+GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h,
+ const char *ext,
const char *uni);
void
GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f);
+
/**
* Synchronize this publishing struct with its mirror
* on disk. Note that all internal FS-operations that change
void
GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc);
+
/**
* Synchronize this unindex struct with its mirror
* on disk. Note that all internal FS-operations that change
void
GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc);
+
/**
* Synchronize this search struct with its mirror
* on disk. Note that all internal FS-operations that change
void
GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc);
+
/**
* Synchronize this search result with its mirror
* on disk. Note that all internal FS-operations that change
void
GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr);
+
/**
* Synchronize this download struct with its mirror
* on disk. Note that all internal FS-operations that change
void
GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc);
+
/**
* Create SUSPEND event for the given publish operation
* and then clean up our state (without stop signal).
*
- * @param cls the 'struct GNUNET_FS_PublishContext' to signal for
+ * @param cls the `struct GNUNET_FS_PublishContext` to signal for
*/
void
GNUNET_FS_publish_signal_suspend_ (void *cls);
+
/**
* Create SUSPEND event for the given search operation
* and then clean up our state (without stop signal).
void
GNUNET_FS_search_signal_suspend_ (void *cls);
+
/**
* Create SUSPEND event for the given download operation
* and then clean up our state (without stop signal).
*
- * @param cls the 'struct GNUNET_FS_DownloadContext' to signal for
+ * @param cls the `struct GNUNET_FS_DownloadContext` to signal for
*/
void
GNUNET_FS_download_signal_suspend_ (void *cls);
+
/**
* Create SUSPEND event for the given unindex operation
* and then clean up our state (without stop signal).
*
- * @param cls the 'struct GNUNET_FS_UnindexContext' to signal for
+ * @param cls the `struct GNUNET_FS_UnindexContext` to signal for
*/
void
GNUNET_FS_unindex_signal_suspend_ (void *cls);
+
/**
* Function signature of the functions that can be called
* to trigger suspend signals and clean-up for top-level
*
* @param h global fs handle
* @param ssf suspend signal function to use
- * @param ssf_cls closure for ssf
+ * @param ssf_cls closure for @a ssf
* @return fresh top-level activity handle
*/
struct TopLevelActivity *
-GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf,
+GNUNET_FS_make_top (struct GNUNET_FS_Handle *h,
+ SuspendSignalFunction ssf,
void *ssf_cls);
* @param top top level activity entry
*/
void
-GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top);
+GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
+ struct TopLevelActivity *top);
*/
struct GNUNET_FS_QueueEntry *pending_tail;
+ /**
+ * Head of active probes.
+ */
+ struct GNUNET_FS_SearchResult *probes_head;
+
+ /**
+ * Tail of active probes.
+ */
+ struct GNUNET_FS_SearchResult *probes_tail;
+
/**
* Task that processes the jobs in the running and pending queues
* (and moves jobs around as needed).
*/
- GNUNET_SCHEDULER_TaskIdentifier queue_job;
+ struct GNUNET_SCHEDULER_Task * queue_job;
+
+ /**
+ * Task we use to report periodically to the application that
+ * certain search probes (from @e probes_head) are still running.
+ */
+ struct GNUNET_SCHEDULER_Task * probe_ping_task;
/**
* Average time we take for a single request to be satisfied.
*/
struct GNUNET_FS_Handle *h;
+ /**
+ * Connection to FS service (only used for LOC URI signing).
+ */
+ struct GNUNET_CLIENT_Handle *fs_client;
+
/**
* Our top-level activity entry (if we are top-level, otherwise NULL).
*/
/**
* Namespace that we are publishing in, NULL if we have no namespace.
*/
- struct GNUNET_CRYPTO_EccPrivateKey *ns;
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *ns;
/**
* ID of the content in the namespace, NULL if we have no namespace.
* ID of the task performing the upload. NO_TASK if the upload has
* completed.
*/
- GNUNET_SCHEDULER_TaskIdentifier upload_task;
+ struct GNUNET_SCHEDULER_Task * upload_task;
/**
* Storage space to reserve for the operation.
int rid;
/**
- * Set to GNUNET_YES if all processing has completed.
+ * Set to #GNUNET_YES if we were able to publish any block.
+ * (and thus unindexing on error might make sense).
+ */
+ int any_done;
+
+ /**
+ * Set to #GNUNET_YES if all processing has completed.
*/
int all_done;
-
+
/**
- * Flag set to GNUNET_YES if the next callback from
- * GNUNET_FS_file_information_inspect should be skipped because it
+ * Flag set to #GNUNET_YES if the next callback from
+ * #GNUNET_FS_file_information_inspect should be skipped because it
* is for the directory which was already processed with the parent.
*/
int skip_next_fi_callback;
* the respective DBlocks and IBlocks.
*/
UNINDEX_STATE_DS_REMOVE = 1,
-
+
/**
* Find out which keywords apply.
*/
* the unindexing.
*/
UNINDEX_STATE_FS_NOTIFY = 4,
-
+
/**
* We're done.
*/
UNINDEX_STATE_COMPLETE = 5,
-
+
/**
* We've encountered a fatal error.
*/
* The content hash key of the last block we processed, will in the
* end be set to the CHK from the URI. Used to remove the KBlocks.
*/
- struct ContentHashKey chk;
+ struct ContentHashKey chk;
/**
* Global FS context.
/**
* Connection to the FS service, only valid during the
- * UNINDEX_STATE_FS_NOTIFY phase.
+ * #UNINDEX_STATE_FS_NOTIFY phase.
*/
struct GNUNET_CLIENT_Connection *client;
*/
struct GNUNET_HashCode uquery;
- /**
- * First content UID, 0 for none.
- */
- uint64_t first_uid;
-
/**
* Error message, NULL on success.
*/
*/
struct GNUNET_CRYPTO_FileHashContext *fhc;
+ /**
+ * Which values have we seen already?
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *seen_dh;
+
/**
* Overall size of the file.
*/
uint64_t file_size;
/**
- * Random offset given to 'GNUNET_DATASTORE_get_key'.
+ * Random offset given to #GNUNET_DATASTORE_get_key.
*/
uint64_t roff;
/**
- * Information we keep for each keyword in
- * a keyword search.
+ * Information we keep for each keyword in a keyword search.
*/
struct SearchRequestEntry
{
/**
* Derived public key, hashes to 'uquery'.
- */
- struct GNUNET_CRYPTO_EccPublicSignKey dpub;
+ */
+ struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
/**
* The original keyword, used to derive the
char *emsg;
/**
- * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
+ * Map that contains a `struct GNUNET_FS_SearchResult` for each result that
* was found in the search. The key for each entry is the XOR of
* the key and query in the CHK URI (as a unique identifier for the
* search result).
/**
* ID of a task that is using this struct and that must be cancelled
* when the search is being stopped (if not
- * GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some
+ * NULL). Used for the task that adds some
* artificial delay when trying to reconnect to the FS service.
*/
- GNUNET_SCHEDULER_TaskIdentifier task;
+ struct GNUNET_SCHEDULER_Task *task;
/**
* How many of the entries in the search request
*/
enum BlockRequestState
{
- /**
- * Initial state, block has only been allocated (since it is
- * relevant to the overall download request).
- */
+ /**
+ * Initial state, block has only been allocated (since it is
+ * relevant to the overall download request).
+ */
BRS_INIT = 0,
- /**
- * We've checked the block on the path down the tree, and the
- * content on disk did match the desired CHK, but not all
- * the way down, so at the bottom some blocks will still
- * need to be reconstructed).
- */
+ /**
+ * We've checked the block on the path down the tree, and the
+ * content on disk did match the desired CHK, but not all
+ * the way down, so at the bottom some blocks will still
+ * need to be reconstructed).
+ */
BRS_RECONSTRUCT_DOWN = 1,
- /**
- * We've calculated the CHK bottom-up based on the meta data.
- * This may work, but if it did we have to write the meta data to
- * disk at the end (and we still need to check against the
- * CHK set on top).
- */
+ /**
+ * We've calculated the CHK bottom-up based on the meta data.
+ * This may work, but if it did we have to write the meta data to
+ * disk at the end (and we still need to check against the
+ * CHK set on top).
+ */
BRS_RECONSTRUCT_META_UP = 2,
- /**
- * We've calculated the CHK bottom-up based on what we have on
- * disk, which may not be what the desired CHK is. If the
- * reconstructed CHKs match whatever comes from above, we're
- * done with the respective subtree.
- */
+ /**
+ * We've calculated the CHK bottom-up based on what we have on
+ * disk, which may not be what the desired CHK is. If the
+ * reconstructed CHKs match whatever comes from above, we're
+ * done with the respective subtree.
+ */
BRS_RECONSTRUCT_UP = 3,
- /**
- * We've determined the real, desired CHK for this block
- * (full tree reconstruction failed), request is now pending.
- * If the CHK that bubbled up through reconstruction did match
- * the top-level request, the state machine for the subtree
- * would have moved to BRS_DOWNLOAD_UP.
- */
+ /**
+ * We've determined the real, desired CHK for this block
+ * (full tree reconstruction failed), request is now pending.
+ * If the CHK that bubbled up through reconstruction did match
+ * the top-level request, the state machine for the subtree
+ * would have moved to BRS_DOWNLOAD_UP.
+ */
BRS_CHK_SET = 4,
- /**
- * We've successfully downloaded this block, but the children
- * still need to be either downloaded or verified (download
- * request propagates down). If the download fails, the
- * state machine for this block may move to
- * BRS_DOWNLOAD_ERROR instead.
- */
+ /**
+ * We've successfully downloaded this block, but the children
+ * still need to be either downloaded or verified (download
+ * request propagates down). If the download fails, the
+ * state machine for this block may move to
+ * BRS_DOWNLOAD_ERROR instead.
+ */
BRS_DOWNLOAD_DOWN = 5,
- /**
- * This block and all of its children have been downloaded
- * successfully (full completion propagates up).
- */
+ /**
+ * This block and all of its children have been downloaded
+ * successfully (full completion propagates up).
+ */
BRS_DOWNLOAD_UP = 6,
- /**
- * We got a block back that matched the query but did not hash to
- * the key (malicious publisher or hash collision); this block
- * can never be downloaded (error propagates up).
- */
+ /**
+ * We got a block back that matched the query but did not hash to
+ * the key (malicious publisher or hash collision); this block
+ * can never be downloaded (error propagates up).
+ */
BRS_ERROR = 7
};
enum BlockRequestState state;
/**
- * GNUNET_YES if this entry is in the pending list.
+ * #GNUNET_YES if this entry is in the pending list.
*/
int is_pending;
GNUNET_FS_free_download_request_ (struct DownloadRequest *dr);
+/**
+ * Stop the ping task for this search result.
+ *
+ * @param sr result to start pinging for.
+ */
+void
+GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr);
+
+
/**
* Context for controlling a download.
*/
/**
* ID of a task that is using this struct and that must be cancelled
* when the download is being stopped (if not
- * GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some
+ * NULL). Used for the task that adds some
* artificial delay when trying to reconnect to the FS service or
* the task processing incrementally the data on disk, or the
* task requesting blocks, etc.
*/
- GNUNET_SCHEDULER_TaskIdentifier task;
+ struct GNUNET_SCHEDULER_Task *task;
/**
* What is the first offset that we're interested
/**
* Flag set upon transitive completion (includes child downloads).
- * This flag is only set to GNUNET_YES for directories where all
+ * This flag is only set to #GNUNET_YES for directories where all
* child-downloads have also completed (and signalled completion).
*/
int has_finished;