#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.
/**
* Identity of the peer sharing the file.
*/
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer;
+ struct GNUNET_PeerIdentity peer;
/**
* Time when this location URI expires.
* RSA signature over the GNUNET_EC_FileIdentifier,
* GNUNET_hash of the peer and expiration time.
*/
- struct GNUNET_CRYPTO_RsaSignature contentSignature;
+ struct GNUNET_CRYPTO_EccSignature contentSignature;
};
/**
* Types of URIs.
*/
-enum uri_types
+enum GNUNET_FS_UriType
{
/**
* Content-hash-key (simple file).
*/
- chk,
+ GNUNET_FS_URI_CHK,
/**
* Signed key space (file in namespace).
*/
- sks,
+ GNUNET_FS_URI_SKS,
/**
* Keyword search key (query with keywords).
*/
- ksk,
+ GNUNET_FS_URI_KSK,
/**
* Location (chk with identity of hosting peer).
*/
- loc
+ GNUNET_FS_URI_LOC
};
+
/**
* A Universal Resource Identifier (URI), opaque.
*/
/**
* 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;
struct
{
/**
- * Hash of the public key for the namespace.
+ * Identifier of the namespace.
*/
- GNUNET_HashCode namespace;
+ struct GNUNET_CRYPTO_EccPublicSignKey ns;
/**
- * Human-readable identifier chosen for this
- * entry in the namespace.
+ * Human-readable identifier chosen for this entry in the
+ * namespace.
*/
char *identifier;
+
} sks;
/**
* 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).
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;
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,
+
+ /**
+ * Default priority.
+ */
+ GNUNET_FS_QUEUE_PRIORITY_NORMAL
+ };
+
+
/**
* Entry in the job queue.
*/
*/
unsigned int blocks;
+ /**
+ * How important is this download?
+ */
+ enum GNUNET_FS_QueuePriority priority;
+
/**
* How often have we (re)started this download?
*/
};
-
-
/**
* Information we store for each search result.
*/
{
/**
- * Search context this result belongs to.
+ * File-sharing context this result belongs to.
+ */
+ struct GNUNET_FS_Handle *h;
+
+ /**
+ * Search context this result belongs to; can be NULL
+ * for probes that come from a directory result.
*/
struct GNUNET_FS_SearchContext *sc;
/**
* Key for the search result
*/
- GNUNET_HashCode key;
+ struct GNUNET_HashCode key;
/**
* ID of the task that will clean up the probe_ctx should it not
*/
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;
+
/**
* When did the current probe become active?
*/
*/
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
* @param stop function to call to pause the job, or on dequeue (if the job was running)
* @param cls closure for start and stop
* @param blocks number of blocks this download has
+ * @param priority how important is this download
* @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_QueueStop 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);
/**
* @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);
/**
* 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);
/**
* Namespace that we are publishing in, NULL if we have no namespace.
*/
- struct GNUNET_FS_Namespace *namespace;
+ struct GNUNET_CRYPTO_EccPrivateKey *ns;
/**
* ID of the content in the namespace, NULL if we have no namespace.
*/
struct GNUNET_DATASTORE_QueueEntry *qre;
+ /**
+ * Context for SKS publishing operation that is part of this publishing operation
+ * (NULL if not active).
+ */
+ struct GNUNET_FS_PublishSksContext *sks_pc;
+
+ /**
+ * Context for KSK publishing operation that is part of this publishing operation
+ * (NULL if not active).
+ */
+ struct GNUNET_FS_PublishKskContext *ksk_pc;
+
/**
* ID of the task performing the upload. NO_TASK if the upload has
* completed.
*/
uint32_t reserve_entries;
- /**
- * Typically GNUNET_NO. Set to GNUNET_YES if "upload_task" is
- * GNUNET_SCHEDULER_NO_TASK and we're waiting for a response from
- * the datastore service (in which case this struct must not be
- * freed until we have that response). If someone tries to stop the
- * download for good during this period, "in_network_wait" is set to
- * GNUNET_SYSERR which will cause the struct to be destroyed right
- * after we have the reply (or timeout) from the datastore service.
- */
- int in_network_wait;
-
/**
* Options for publishing.
*/
* 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
*/
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
};
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.
*/
*/
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.
*/
*/
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;
+
+ /**
+ * First content UID, 0 for none.
+ */
+ uint64_t first_uid;
+
/**
* Error message, NULL on success.
*/
*/
uint64_t file_size;
+ /**
+ * Random offset given to 'GNUNET_DATASTORE_get_key'.
+ */
+ uint64_t roff;
+
/**
* When did we start?
*/
/**
* Hash of the file's contents (once computed).
*/
- GNUNET_HashCode file_id;
+ struct GNUNET_HashCode file_id;
/**
* Current operatinonal phase.
*/
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'.
+ */
+ struct GNUNET_CRYPTO_EccPublicSignKey dpub;
+
+ /**
+ * The original keyword, used to derive the
+ * key (for decrypting the UBlock).
*/
- GNUNET_HashCode query;
+ char *keyword;
/**
* Map that contains a "struct GNUNET_FS_SearchResult" for each result that
*/
struct GNUNET_TIME_Absolute start_time;
+ /**
+ * How long to wait before we try to reconnect to FS service?
+ */
+ struct GNUNET_TIME_Relative reconnect_backoff;
+
/**
* ID of a task that is using this struct and that must be cancelled
* when the search is being stopped (if not
*/
unsigned int depth;
+ /**
+ * Offset of the CHK for this block in the parent block
+ */
+ unsigned int chk_idx;
+
/**
* State in the FSM.
*/
*/
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.
*/
*/
int in_receive;
-};
-
-
-/**
- * Information about an (updateable) node in the
- * namespace.
- */
-struct NamespaceUpdateNode
-{
- /**
- * Identifier for this node.
- */
- char *id;
-
/**
- * Identifier of children of this node.
+ * Are we ready to issue requests (reconstructions are finished)?
*/
- 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;
+ int issue_requests;
};
-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 */