X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffs%2Ffs_api.h;h=be22ea73e7d8277bc636e9edb422443226424b73;hb=5f9face21a6ca311247c4f11a1f015691673cc9a;hp=154e63893dbe5c03915819a5dcb0298d86e4f5ac;hpb=237a4538616beadd40d3e918ad4b6597b4eb8561;p=oweals%2Fgnunet.git diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index 154e63893..be22ea73e 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h @@ -1,6 +1,6 @@ /* 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 @@ -14,8 +14,8 @@ 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. */ /** @@ -34,11 +34,6 @@ #include "block_fs.h" #include "fs.h" -/** - * Size of the individual blocks used for file-sharing. - */ -#define DBLOCK_SIZE (32*1024) - /** * Pick a multiple of 2 here to achive 8-byte alignment! We also * probably want DBlocks to have (roughly) the same size as IBlocks. @@ -125,7 +120,7 @@ struct Location /** * Identity of the peer sharing the file. */ - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer; + struct GNUNET_PeerIdentity peer; /** * Time when this location URI expires. @@ -133,39 +128,40 @@ struct Location 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_RsaSignature contentSignature; + struct GNUNET_CRYPTO_EddsaSignature contentSignature; }; /** * Types of URIs. */ -enum uri_types +enum GNUNET_FS_UriType { - /** - * Content-hash-key (simple file). - */ - chk, + /** + * Content-hash-key (simple file). + */ + GNUNET_FS_URI_CHK, - /** - * Signed key space (file in namespace). - */ - sks, + /** + * Signed key space (file in namespace). + */ + GNUNET_FS_URI_SKS, - /** - * Keyword search key (query with keywords). - */ - ksk, + /** + * Keyword search key (query with keywords). + */ + GNUNET_FS_URI_KSK, - /** - * Location (chk with identity of hosting peer). - */ - loc + /** + * Location (chk with identity of hosting peer). + */ + GNUNET_FS_URI_LOC }; + /** * A Universal Resource Identifier (URI), opaque. */ @@ -174,23 +170,20 @@ struct GNUNET_FS_Uri /** * Type of the URI. */ - enum uri_types type; + enum GNUNET_FS_UriType type; union { struct { /** - * Keywords start with a '+' if they are - * mandatory (in which case the '+' is NOT - * part of the keyword) and with a - * simple space if they are optional - * (in which case the space is ALSO not - * part of the actual keyword). + * Keywords start with a '+' if they are mandatory (in which + * case the '+' is NOT part of the keyword) and with a simple + * space if they are optional (in which case the space is ALSO + * not part of the actual keyword). * - * Double-quotes to protect spaces and - * %-encoding are NOT used internally - * (only in URI-strings). + * Double-quotes to protect spaces and %-encoding are NOT used + * internally (only in URI-strings). */ char **keywords; @@ -203,15 +196,16 @@ struct GNUNET_FS_Uri struct { /** - * Hash of the public key for the namespace. + * Identifier of the namespace. */ - GNUNET_HashCode namespace; + struct GNUNET_CRYPTO_EcdsaPublicKey ns; /** - * Human-readable identifier chosen for this - * entry in the namespace. + * Human-readable identifier chosen for this entry in the + * namespace. */ char *identifier; + } sks; /** @@ -274,6 +268,12 @@ struct GNUNET_FS_FileInformation */ 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. */ @@ -333,7 +333,7 @@ struct GNUNET_FS_FileInformation * over the entire file (when the indexing process is started). * Otherwise this field is not used. */ - GNUNET_HashCode file_id; + struct GNUNET_HashCode file_id; /** * Size of the file (in bytes). @@ -346,14 +346,14 @@ struct GNUNET_FS_FileInformation 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; @@ -382,6 +382,16 @@ struct GNUNET_FS_FileInformation */ 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; @@ -399,40 +409,21 @@ struct GNUNET_FS_FileInformation }; -/** - * The job is now ready to run and should use the given client - * handle to communicate with the FS service. - * - * @param cls closure - * @param client handle to use for FS communication - */ -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); - - - /** * 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 +}; /** @@ -453,12 +444,12 @@ struct GNUNET_FS_QueueEntry /** * Function to call when the job is started. */ - GNUNET_FS_QueueStart start; + GNUNET_SCHEDULER_TaskCallback start; /** * Function to call when the job needs to stop (or is done / dequeued). */ - GNUNET_FS_QueueStop stop; + GNUNET_SCHEDULER_TaskCallback stop; /** * Closure for start and stop. @@ -471,9 +462,9 @@ struct GNUNET_FS_QueueEntry struct GNUNET_FS_Handle *h; /** - * Client handle, or NULL if job is not running. + * Message queue handle, or NULL if job is not running. */ - struct GNUNET_CLIENT_Connection *client; + struct GNUNET_MQ_Handle *mq; /** * Time the job was originally queued. @@ -506,9 +497,12 @@ struct GNUNET_FS_QueueEntry */ unsigned int start_times; -}; - + /** + * #GNUNET_YES if the job is active now. + */ + int active; +}; /** @@ -518,7 +512,23 @@ struct GNUNET_FS_SearchResult { /** - * Search context this result belongs to. + * File-sharing context this result belongs to. + */ + 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. */ struct GNUNET_FS_SearchContext *sc; @@ -566,16 +576,16 @@ struct GNUNET_FS_SearchResult uint8_t *keyword_bitmap; /** - * Key for the search result + * Key for the search result based on the URI. */ - GNUNET_HashCode key; + struct GNUNET_HashCode key; /** * ID of the task that will clean up the probe_ctx should it not * 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; + struct GNUNET_SCHEDULER_Task * probe_cancel_task; /** * When did the current probe become active? @@ -587,6 +597,11 @@ struct GNUNET_FS_SearchResult */ struct GNUNET_TIME_Relative remaining_probe_time; + /** + * Anonymity level to use for probes using this search result. + */ + uint32_t anonymity; + /** * Number of mandatory keywords for which we have NOT yet found the * search result; when this value hits zero, the search result is @@ -626,17 +641,21 @@ struct GNUNET_FS_SearchResult * @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_SCHEDULER_TaskCallback start, + GNUNET_SCHEDULER_TaskCallback stop, + void *cls, + unsigned int blocks, enum GNUNET_FS_QueuePriority priority); /** * Dequeue a job from the queue. - * @param qh handle for the job + * + * @param qe handle for the job */ void -GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh); +GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe); /** @@ -647,7 +666,7 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh); * 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 @@ -656,12 +675,15 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh); * @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 @@ -679,22 +701,26 @@ GNUNET_FS_make_file_reader_context_ (const char *filename); * 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 @@ -704,7 +730,7 @@ GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, * 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, @@ -714,12 +740,10 @@ 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); /** @@ -730,7 +754,26 @@ GNUNET_FS_publish_main_ (void *cls, * @param file_id computed hash, NULL on error */ void -GNUNET_FS_unindex_process_hash_ (void *cls, const GNUNET_HashCode * file_id); +GNUNET_FS_unindex_process_hash_ (void *cls, + const struct GNUNET_HashCode *file_id); + + +/** + * Extract the keywords for KBlock removal + * + * @param uc context for the unindex operation. + */ +void +GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc); + + +/** + * If necessary, connect to the datastore and remove the KBlocks. + * + * @param uc context for the unindex operation. + */ +void +GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc); /** @@ -767,11 +810,9 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi, * 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); @@ -793,11 +834,13 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, * call the callback. * * @param pi structure to fill in + * @param h file-sharing handle * @param sc overall search context * @return value returned by the callback */ void * GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, + struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc); @@ -836,6 +879,7 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc); void GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr); + /** * Remove serialization/deserialization file from disk. * @@ -844,7 +888,8 @@ GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr); * @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); @@ -856,7 +901,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext, * @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); @@ -871,6 +917,7 @@ GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, 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 @@ -882,6 +929,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); 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 @@ -893,6 +941,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); 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 @@ -904,6 +953,7 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); 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 @@ -915,6 +965,7 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); 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 @@ -926,15 +977,17 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr); 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). @@ -944,24 +997,27 @@ GNUNET_FS_publish_signal_suspend_ (void *cls); 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 @@ -1004,11 +1060,12 @@ struct TopLevelActivity * * @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); @@ -1019,7 +1076,8 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, * @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); @@ -1078,11 +1136,27 @@ struct GNUNET_FS_Handle */ 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. @@ -1141,7 +1215,7 @@ struct GNUNET_FS_PublishContext /** * Namespace that we are publishing in, NULL if we have no namespace. */ - struct GNUNET_FS_Namespace *namespace; + struct GNUNET_CRYPTO_EcdsaPrivateKey *ns; /** * ID of the content in the namespace, NULL if we have no namespace. @@ -1160,10 +1234,10 @@ struct GNUNET_FS_PublishContext char *serialization; /** - * Our own client handle for the FS service; only briefly used when + * Our own message queue for the FS service; only briefly used when * we start to index a file, otherwise NULL. */ - struct GNUNET_CLIENT_Connection *client; + struct GNUNET_MQ_Handle *mq; /** * Current position in the file-tree for the upload. @@ -1201,7 +1275,7 @@ struct GNUNET_FS_PublishContext * 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. @@ -1226,13 +1300,19 @@ struct GNUNET_FS_PublishContext 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; @@ -1244,32 +1324,42 @@ struct GNUNET_FS_PublishContext */ enum UnindexState { - /** - * We're currently hashing the file. - */ + /** + * We're currently hashing the file. + */ UNINDEX_STATE_HASHING = 0, - /** - * We're telling the datastore to delete - * the respective entries. - */ + /** + * We're telling the datastore to delete + * the respective DBlocks and IBlocks. + */ UNINDEX_STATE_DS_REMOVE = 1, - /** - * We're notifying the FS service about - * the unindexing. - */ - UNINDEX_STATE_FS_NOTIFY = 2, + /** + * Find out which keywords apply. + */ + UNINDEX_STATE_EXTRACT_KEYWORDS = 2, - /** - * We're done. - */ - UNINDEX_STATE_COMPLETE = 3, + /** + * We're telling the datastore to remove KBlocks. + */ + UNINDEX_STATE_DS_REMOVE_KBLOCKS = 3, - /** - * We've encountered a fatal error. - */ - UNINDEX_STATE_ERROR = 4 + /** + * We're notifying the FS service about + * the unindexing. + */ + UNINDEX_STATE_FS_NOTIFY = 4, + + /** + * We're done. + */ + UNINDEX_STATE_COMPLETE = 5, + + /** + * We've encountered a fatal error. + */ + UNINDEX_STATE_ERROR = 6 }; @@ -1279,6 +1369,12 @@ enum UnindexState struct GNUNET_FS_UnindexContext { + /** + * 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; + /** * Global FS context. */ @@ -1289,6 +1385,21 @@ struct GNUNET_FS_UnindexContext */ struct TopLevelActivity *top; + /** + * Directory scanner to find keywords (KBlock removal). + */ + struct GNUNET_FS_DirScanner *dscan; + + /** + * Keywords found (telling us which KBlocks to remove). + */ + struct GNUNET_FS_Uri *ksk_uri; + + /** + * Current offset in KSK removal. + */ + uint32_t ksk_offset; + /** * Name of the file that we are unindexing. */ @@ -1301,9 +1412,9 @@ struct GNUNET_FS_UnindexContext /** * 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_MQ_Handle *mq; /** * Connection to the datastore service, only valid during the @@ -1326,6 +1437,22 @@ struct GNUNET_FS_UnindexContext */ struct GNUNET_DISK_FileHandle *fh; + /** + * Handle to datastore 'get_key' operation issued for + * obtaining KBlocks. + */ + struct GNUNET_DATASTORE_QueueEntry *dqe; + + /** + * Current key for decrypting UBLocks from 'get_key' operation. + */ + struct GNUNET_HashCode ukey; + + /** + * Current query of 'get_key' operation. + */ + struct GNUNET_HashCode uquery; + /** * Error message, NULL on success. */ @@ -1349,7 +1476,7 @@ struct GNUNET_FS_UnindexContext /** * Hash of the file's contents (once computed). */ - GNUNET_HashCode file_id; + struct GNUNET_HashCode file_id; /** * Current operatinonal phase. @@ -1360,21 +1487,26 @@ struct GNUNET_FS_UnindexContext /** - * Information we keep for each keyword in - * a keyword search. + * Information we keep for each keyword in a keyword search. */ struct SearchRequestEntry { + /** - * Hash of the original keyword, also known as the - * key (for decrypting the KBlock). + * Hash of the public key, also known as the query. */ - GNUNET_HashCode key; + struct GNUNET_HashCode uquery; /** - * Hash of the public key, also known as the query. + * Derived public key, hashes to 'uquery'. */ - GNUNET_HashCode query; + struct GNUNET_CRYPTO_EcdsaPublicKey dpub; + + /** + * The original keyword, used to derive the + * key (for decrypting the UBlock). + */ + char *keyword; /** * Map that contains a "struct GNUNET_FS_SearchResult" for each result that @@ -1424,7 +1556,7 @@ struct GNUNET_FS_SearchContext /** * Connection to the FS service. */ - struct GNUNET_CLIENT_Connection *client; + struct GNUNET_MQ_Handle *mq; /** * Pointer we keep for the client. @@ -1442,7 +1574,7 @@ struct GNUNET_FS_SearchContext 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). @@ -1461,24 +1593,17 @@ struct GNUNET_FS_SearchContext struct GNUNET_TIME_Absolute start_time; /** - * 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 - * artificial delay when trying to reconnect to the FS service. - */ - GNUNET_SCHEDULER_TaskIdentifier task; - - /** - * How many of the entries in the search request - * map have been passed to the service so far? + * How long to wait before we try to reconnect to FS service? */ - unsigned int search_request_map_offset; + struct GNUNET_TIME_Relative reconnect_backoff; /** - * How many of the keywords in the KSK - * map have been passed to the service so far? + * ID of a task that is using this struct and that must be cancelled + * when the search is being stopped (if not + * NULL). Used for the task that adds some + * artificial delay when trying to reconnect to the FS service. */ - unsigned int keyword_offset; + struct GNUNET_SCHEDULER_Task *task; /** * Anonymity level for the search. @@ -1504,65 +1629,65 @@ struct GNUNET_FS_SearchContext */ 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 }; @@ -1572,15 +1697,6 @@ enum BlockRequestState */ struct DownloadRequest { - /** - * While pending, we keep all download requests in a doubly-linked list. - */ - struct DownloadRequest *next; - - /** - * While pending, we keep all download requests in a doubly-linked list. - */ - struct DownloadRequest *prev; /** * Parent in the CHK-tree. @@ -1606,7 +1722,7 @@ struct DownloadRequest uint64_t offset; /** - * Number of entries in 'children' array. + * Number of entries in @e children array. */ unsigned int num_children; @@ -1616,14 +1732,14 @@ struct DownloadRequest unsigned int depth; /** - * State in the FSM. + * Offset of the CHK for this block in the parent block */ - enum BlockRequestState state; + unsigned int chk_idx; /** - * GNUNET_YES if this entry is in the pending list. + * State in the FSM. */ - int is_pending; + enum BlockRequestState state; }; @@ -1637,6 +1753,15 @@ void 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. */ @@ -1656,7 +1781,7 @@ struct GNUNET_FS_DownloadContext /** * Connection to the FS service. */ - struct GNUNET_CLIENT_Connection *client; + struct GNUNET_MQ_Handle *mq; /** * Parent download (used when downloading files @@ -1734,12 +1859,6 @@ struct GNUNET_FS_DownloadContext */ struct GNUNET_FS_QueueEntry *job_queue; - /** - * Non-NULL if we are currently having a request for - * transmission pending with the client handle. - */ - struct GNUNET_CLIENT_TransmitHandle *th; - /** * Tree encoder used for the reconstruction. */ @@ -1757,16 +1876,6 @@ struct GNUNET_FS_DownloadContext */ struct GNUNET_CONTAINER_MultiHashMap *active; - /** - * Head of linked list of pending requests. - */ - struct DownloadRequest *pending_head; - - /** - * Head of linked list of pending requests. - */ - struct DownloadRequest *pending_tail; - /** * Top-level download request. */ @@ -1781,12 +1890,12 @@ struct GNUNET_FS_DownloadContext /** * 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 @@ -1819,6 +1928,11 @@ struct GNUNET_FS_DownloadContext */ struct GNUNET_TIME_Absolute start_time; + /** + * How long to wait before we try to reconnect to FS service? + */ + struct GNUNET_TIME_Relative reconnect_backoff; + /** * Desired level of anonymity. */ @@ -1836,109 +1950,19 @@ struct GNUNET_FS_DownloadContext /** * 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; /** - * Have we started the receive continuation yet? + * Are we ready to issue requests (reconstructions are finished)? */ - int in_receive; + int issue_requests; }; -/** - * Information about an (updateable) node in the - * namespace. - */ -struct NamespaceUpdateNode -{ - /** - * Identifier for this node. - */ - char *id; - - /** - * Identifier of children of this node. - */ - char *update; - - /** - * Metadata for this entry. - */ - struct GNUNET_CONTAINER_MetaData *md; - - /** - * URI of this entry in the namespace. - */ - struct GNUNET_FS_Uri *uri; - - /** - * Namespace update generation ID. Used to ensure - * freshness of the tree_id. - */ - unsigned int nug; - - /** - * TREE this entry belongs to (if nug is current). - */ - unsigned int tree_id; - -}; - - -struct GNUNET_FS_Namespace -{ - - /** - * Handle to the FS service context. - */ - struct GNUNET_FS_Handle *h; - - /** - * Array with information about nodes in the namespace. - */ - struct NamespaceUpdateNode **update_nodes; - - /** - * Private key for the namespace. - */ - struct GNUNET_CRYPTO_RsaPrivateKey *key; - - /** - * Hash map mapping identifiers of update nodes - * to the update nodes (initialized on-demand). - */ - struct GNUNET_CONTAINER_MultiHashMap *update_map; - - /** - * Name of the file with the private key. - */ - char *filename; - - /** - * Name of the namespace. - */ - char *name; - - /** - * Size of the update nodes array. - */ - unsigned int update_node_count; - - /** - * Reference counter. - */ - unsigned int rc; - - /** - * Generator for unique nug numbers. - */ - unsigned int nug_gen; -}; - #endif /* end of fs_api.h */