84 for (i = 1; i < depth; i++)
240 "Matching %u byte block for `%s' at offset %llu already present, no need for download!\n",
243 (
unsigned long long) dr->
offset);
305 size = (size_t) size64;
306 if (size64 != (uint64_t)
size)
311 "Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
333 _ (
"Directory too large for system address space\n"));
347 "Failed to access full directory contents of `%s' for recursive download\n"),
453 odata_len = data_len;
481 data = (
const char *) chks;
486 if (dr->
offset > data_len)
529 _ (
"Failed to open file `%s' for writing"),
542 _ (
"Failed to open file `%s' for writing"),
563 pi.
value.
download.specifics.progress.block_download_duration =
604 enum EXTRACTOR_MetaType
type,
605 enum EXTRACTOR_MetaFormat format,
606 const char *data_mime_type,
612 if (EXTRACTOR_METATYPE_GNUNET_FULL_DATA !=
type)
615 "Found %u bytes of FD!\n",
616 (
unsigned int) data_len);
673 uint64_t child_block_size;
705 while (NULL != dr->
parent)
819 "Scheduling download at offset %llu and depth %u for `%s'\n",
820 (
unsigned long long) dr->
offset,
837#define GNUNET_FS_URI_CHK_PREFIX GNUNET_FS_URI_PREFIX GNUNET_FS_URI_CHK_INFIX
891 else if (
'.' == fn[0])
905 while (NULL != (pos = strstr (fn,
"\\")))
910 while (NULL != (pos = strstr (fn,
"../")))
930 while ((strlen (sfn) > 0) && (
'/' ==
filename[strlen (sfn) - 1]))
931 sfn[strlen (sfn) - 1] =
'\0';
956 if ((NULL != full_name) &&
961 "Failed to create directory for recursive download of `%s'\n"),
970 "Triggering recursive download of size %llu with %u bytes MD\n",
1030 "Received %u byte block `%s' matching pending request at depth %u and offset %llu/%llu\n",
1031 (
unsigned int) prc->
size,
1034 (
unsigned long long) dr->
offset,
1040 if (prc->
size != bs)
1044 "Internal error or bogus download URI (expected %llu bytes at depth %u and offset %llu/%llu, got %llu bytes)",
1045 (
unsigned long long) bs,
1047 (
unsigned long long) dr->
offset,
1049 (
unsigned long long) prc->
size);
1051 while (NULL != dr->
parent)
1089 _ (
"Download failed: could not open file `%s': %s"),
1095 "Saving decrypted block to disk at offset %llu\n",
1096 (
unsigned long long) off);
1100 _ (
"Failed to seek to offset %llu in file `%s': %s"),
1101 (
unsigned long long) off,
1110 _ (
"Failed to write block of %u bytes at offset %llu in file `%s': %s"),
1111 (
unsigned int) prc->
size,
1112 (
unsigned long long) off,
1164 pi.
value.
download.specifics.progress.block_download_duration =
1167 pi.
value.
download.specifics.progress.block_download_duration =
1177 "Download completed, truncating file to desired length %llu\n",
1201 "Triggering downloads of children (this block was at depth %u and offset %llu)\n",
1203 (
unsigned long long) dr->
offset);
1309 uint16_t msize = ntohs (cm->
header.
size) -
sizeof(*cm);
1322 "Received result for query `%s' from FS service\n",
1350 "Transmitting download request failed, trying to reconnect\n");
1380 "Connecting to `%s'-service failed, will try again.\n",
1402 "Moving all requests back to pending list\n");
1412 "Will try to reconnect in %s\n",
1488 uint64_t file_start_offset,
1489 uint64_t desired_length)
1493 unsigned int head_skip;
1494 uint64_t child_block_size;
1508 if (dr_offset < file_start_offset)
1510 head_skip = (file_start_offset - dr_offset) / child_block_size;
1519 (file_start_offset + desired_length - dr_offset) / child_block_size;
1521 file_start_offset + desired_length - dr_offset)
1528 "Block at offset %llu and depth %u has %u children\n",
1529 (
unsigned long long) dr_offset,
1545 dr_offset + (i + head_skip) * child_block_size,
1570 if (NULL !=
dc->
rfh)
1621 uint16_t block_size)
1639 "Block %u < %u irrelevant for our range\n",
1648 "Block %u > %u irrelevant for our range\n",
1658 "Matched TE block with request at offset %llu and depth %u in state %d\n",
1659 (
unsigned long long) dr->
offset,
1683 "Reconstruction succeeded, can use block at offset %llu, depth %u\n",
1684 (
unsigned long long)
offset,
1705 pi.
value.
download.specifics.progress.block_download_duration =
1713 "Download completed, truncating file to desired length %llu\n",
1730 "Reconstruction failed, need to download block at offset %llu, depth %u\n",
1731 (
unsigned long long)
offset,
1862 if (NULL !=
dc->
rfh)
1866 "Trying top-down reconstruction for `%s'\n",
1879 if (NULL !=
dc->
rfh)
1908 "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
1914 if (NULL !=
dc->
rfh)
1924 if (NULL !=
dc->
rfh)
1928 "Trying bottom-up reconstruction of file `%s'\n",
1957 if (NULL !=
dc->
top)
1987 if (NULL !=
dc->
rfh)
2032 const char *tempname,
2050 "Starting download %p, %u bytes at offset %llu\n",
2053 (
unsigned long long)
offset);
2082 if (NULL != tempname)
2088 "Starting download `%s' of %llu bytes with tree depth %u\n",
2090 (
unsigned long long)
length,
2103 const char *tempname,
2139 const char *tempname,
2148 if ((NULL == sr) || (NULL != sr->
download))
2202 "Download %p put into queue as job %p\n",
2257 int search_was_null;
2259 if (NULL !=
dc->
top)
2266 search_was_null = (NULL ==
dc->
search);
2292 ((NULL !=
dc->
parent) || (! search_was_null))
2315 if ((0 != unlink (
dc->
filename)) && (ENOENT != errno))
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Envelope * env
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
struct GNUNET_FS_QueueEntry * 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)
Add a job to the queue.
void GNUNET_FS_download_sync_(struct GNUNET_FS_DownloadContext *dc)
Synchronize this download struct with its mirror on disk.
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
void GNUNET_FS_remove_sync_dir_(struct GNUNET_FS_Handle *h, const char *ext, const char *uni)
Remove serialization/deserialization directory from disk.
void GNUNET_FS_dequeue_(struct GNUNET_FS_QueueEntry *qe)
Dequeue a job from the queue.
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
shared definitions for the FS library
@ BRS_DOWNLOAD_UP
This block and all of its children have been downloaded successfully (full completion propagates up).
@ BRS_RECONSTRUCT_META_UP
We've calculated the CHK bottom-up based on the meta data.
@ BRS_CHK_SET
We've determined the real, desired CHK for this block (full tree reconstruction failed),...
@ BRS_ERROR
We got a block back that matched the query but did not hash to the key (malicious publisher or hash c...
@ BRS_RECONSTRUCT_DOWN
We've checked the block on the path down the tree, and the content on disk did match the desired CHK,...
@ BRS_INIT
Initial state, block has only been allocated (since it is relevant to the overall download request).
@ BRS_DOWNLOAD_DOWN
We've successfully downloaded this block, but the children still need to be either downloaded or veri...
@ BRS_RECONSTRUCT_UP
We've calculated the CHK bottom-up based on what we have on disk, which may not be what the desired C...
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD
Name of the directory with master downloads (not associated with search or part of another download).
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
void * GNUNET_FS_search_probe_progress_(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Notification of FS that a search probe has made progress.
#define CHK_PER_INODE
Pick a multiple of 2 here to achieve 8-byte alignment! We also probably want DBlocks to have (roughly...
@ GNUNET_FS_QUEUE_PRIORITY_NORMAL
Default priority.
@ GNUNET_FS_QUEUE_PRIORITY_PROBE
This is a probe (low priority).
#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
Name of the directory with downloads that are part of another download or a search.
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
static int retry_entry(void *cls, const struct GNUNET_HashCode *key, void *entry)
Add entries to the message queue.
static void reconstruct_cb(void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
Function called asking for the current (encoded) block to be processed.
static void propagate_up(struct DownloadRequest *dr)
Set the state of the given download request to BRS_DOWNLOAD_UP and propagate it up the tree.
static void check_completed(struct GNUNET_FS_DownloadContext *dc)
Check if all child-downloads have completed (or trigger them if necessary) and once we're completely ...
static void handle_put(void *cls, const struct ClientPutMessage *cm)
Type of a function to call when we receive a message from the service.
static int check_put(void *cls, const struct ClientPutMessage *cm)
Type of a function to call when we check the PUT message from the service.
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
static void activate_fs_download(void *cls)
We're allowed to ask the FS service for our blocks.
static size_t fh_reader(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the ...
static void try_top_down_reconstruction(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr)
Try top-down reconstruction.
static struct DownloadRequest * create_download_request(struct DownloadRequest *parent, unsigned int chk_idx, unsigned int depth, uint64_t dr_offset, uint64_t file_start_offset, uint64_t desired_length)
(recursively) Create a download request structure.
static int match_full_data(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len)
Type of a function that libextractor calls for each meta data item found.
static int process_result_with_request(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over entries in the pending requests in the 'active' map for the reply that we just got.
void GNUNET_FS_download_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
Fill in all of the generic fields for a download event and call the callback.
static void deactivate_fs_download(void *cls)
We must stop to ask the FS service for our blocks.
void GNUNET_FS_download_start_task_(void *cls)
Task that creates the initial (top-level) download request for the file.
static struct GNUNET_FS_DownloadContext * create_download_context(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx)
Helper function to setup the download context.
static void reconstruct_cont(void *cls)
Continuation after a possible attempt to reconstruct the current IBlock from the existing file.
static int is_recursive_download(struct GNUNET_FS_DownloadContext *dc)
Determine if the given download (options and meta data) should cause use to try to do a recursive dow...
static int encrypt_existing_match(struct GNUNET_FS_DownloadContext *dc, const struct ContentHashKey *chk, struct DownloadRequest *dr, const char *block, size_t len, int do_store)
We've found a matching block without downloading it.
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
static void try_match_block(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr, const char *data, size_t data_len)
We got a block of plaintext data (from the meta data).
static void trigger_recursive_download(void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, size_t length, const void *data)
We found an entry in a directory.
void GNUNET_FS_download_start_downloading_(struct GNUNET_FS_DownloadContext *dc)
Start the downloading process (by entering the queue).
static uint64_t compute_disk_offset(uint64_t fsize, uint64_t off, unsigned int depth)
We're storing the IBLOCKS after the DBLOCKS on disk (so that we only have to truncate the file once w...
static void get_next_block(void *cls)
Task requesting the next block from the tree encoder.
static void full_recursive_download(struct GNUNET_FS_DownloadContext *dc)
We're done downloading a directory.
#define GNUNET_FS_URI_CHK_PREFIX
static void download_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void try_reconnect(struct GNUNET_FS_DownloadContext *dc)
We've lost our connection with the FS service.
static void schedule_block_download(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr)
Schedule the download of the specified block in the tree.
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
uint64_t GNUNET_FS_tree_compute_tree_size(unsigned int depth)
Calculate how many bytes of payload a block tree of the given depth MAY correspond to at most (this f...
size_t GNUNET_FS_tree_calculate_block_size(uint64_t fsize, uint64_t offset, unsigned int depth)
Compute how many bytes of data should be stored in the specified block.
Merkle-tree-ish-CHK file encoding for GNUnet.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
static char * plugin_name
Name of our plugin.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int anonymity
static struct GNUNET_FS_DownloadContext * dc
static OpusEncoder * enc
OPUS encoder.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
API for file sharing via GNUnet.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
@ GNUNET_DISK_MAP_TYPE_READ
Read-only memory map.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
GNUNET_FS_DownloadOptions
Options for downloading.
int GNUNET_FS_directory_list_contents(size_t size, const void *data, uint64_t offset, GNUNET_FS_DirectoryEntryProcessor dep, void *dep_cls)
Iterate over all entries in a directory.
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
int GNUNET_FS_uri_test_equal(const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
Test if two URIs are equal.
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx, struct GNUNET_FS_DownloadContext *parent)
Download parts of a file.
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
void GNUNET_FS_download_resume(struct GNUNET_FS_DownloadContext *dc)
Resume a suspended download.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start_from_search(struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchResult *sr, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx)
Download parts of a file based on a search result.
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
#define GNUNET_FS_DIRECTORY_EXT
char * GNUNET_FS_meta_data_suggest_filename(const struct GNUNET_FS_MetaData *md)
Suggest a filename based on given metadata.
void GNUNET_FS_download_suspend(struct GNUNET_FS_DownloadContext *dc)
Suspend a download.
int GNUNET_FS_uri_loc_get_peer_identity(const struct GNUNET_FS_Uri *uri, struct GNUNET_PeerIdentity *peer)
Obtain the identity of the peer offering the data.
@ GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY
Only search the local host, do not search remote systems (no P2P)
@ GNUNET_FS_SEARCH_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_DOWNLOAD_IS_PROBE
Internal option used to flag this download as a 'probe' for a search result.
@ GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE
Do a recursive download (that is, automatically trigger the download of files in directories).
@ GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY
Only download from the local host, do not access remote systems (no P2P)
@ GNUNET_FS_DOWNLOAD_NO_TEMPORARIES
Do not append temporary data to the target file (for the IBlocks).
@ GNUNET_FS_STATUS_DOWNLOAD_INACTIVE
Notification that this download is no longer actively being pursued (back in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_ERROR
Notification that this download encountered an error.
@ GNUNET_FS_STATUS_DOWNLOAD_COMPLETED
Notification that this download completed.
@ GNUNET_FS_STATUS_DOWNLOAD_SUSPEND
Notification that this download was suspended.
@ GNUNET_FS_STATUS_DOWNLOAD_START
Notification that we have started this download.
@ GNUNET_FS_STATUS_DOWNLOAD_PROGRESS
Notification about progress with this download.
@ GNUNET_FS_STATUS_DOWNLOAD_ACTIVE
Notification that this download is now actively being pursued (as opposed to waiting in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_STOPPED
Notification that this download was stopped (final event with respect to this action).
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains_value(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Check if the map contains the given value under the given key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void * cls
Closure for mv and cb.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH
Client asks FS service to start a (keyword) search.
#define GNUNET_MESSAGE_TYPE_FS_PUT
P2P response with content or active migration of content.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta(struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
Calculate the estimate time of arrival/completion for an operation.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_FS_DBLOCK
Data block (leaf) in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_IBLOCK
Inner block in the CHK tree.
Response from FS service with a result for a previous FS search.
uint32_t respect_offered
How much respect did we offer (in total) before getting an answer (estimate).
uint32_t type
Type of the block (in big endian).
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
struct GNUNET_TIME_AbsoluteNBO last_transmission
When was the last time we've tried to download this block? (FOREVER if unknown/not relevant)
uint32_t num_transmissions
How often did we transmit this query before getting an answer (estimate).
struct GNUNET_HashCode key
Hash of the original content, used for encryption.
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Information about an active download request.
struct DownloadRequest ** children
Array (!) of child-requests, or NULL for the bottom of the tree.
unsigned int chk_idx
Offset of the CHK for this block in the parent block.
unsigned int num_children
Number of entries in children array.
uint64_t offset
Offset of the corresponding block.
enum BlockRequestState state
State in the FSM.
unsigned int depth
Depth of the corresponding block in the tree.
struct DownloadRequest * parent
Parent in the CHK-tree.
struct ContentHashKey chk
CHK for the request for this block (set during reconstruction to what we have on disk,...
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
uint64_t file_length
Total size of the file in bytes.
Handle used to access files (and pipes).
Handle for a memory-mapping operation.
Context for controlling a download.
int has_finished
Flag set upon transitive completion (includes child downloads).
unsigned int treedepth
The depth of the file-tree.
char * filename
Where are we writing the data (name of the file, can be NULL!).
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
struct GNUNET_DISK_FileHandle * rfh
File handle for reading data from an existing file (to pass to tree encoder).
struct GNUNET_FS_MetaData * meta
Known meta-data for the file (can be NULL).
void * client_info
Context kept for the client.
uint64_t old_file_size
What was the size of the file on disk that we're downloading before we started? Used to detect if the...
int issue_requests
Are we ready to issue requests (reconstructions are finished)?
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
uint64_t offset
What is the first offset that we're interested in?
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
char * emsg
Error message, NULL if we're doing OK.
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the download is being stopped ...
struct GNUNET_FS_TreeEncoder * te
Tree encoder used for the reconstruction.
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none.
struct GNUNET_FS_DownloadContext * child_tail
Tail of list of child downloads.
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
struct GNUNET_FS_DownloadContext * child_head
Head of list of child downloads.
struct GNUNET_TIME_Relative reconnect_backoff
How long to wait before we try to reconnect to FS service?
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file!
char * serialization
Random portion of filename we use for syncing state of this download.
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
uint32_t anonymity
Desired level of anonymity.
char * temp_filename
Where are we writing the data temporarily (name of the file, can be NULL!); used if we do not have a ...
struct GNUNET_FS_DownloadContext * next
Next download belonging to the same parent.
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
struct DownloadRequest * top_request
Top-level download request.
struct GNUNET_PeerIdentity target
Identity of the peer having the content, or all-zeros if we don't know of such a peer.
enum GNUNET_FS_DownloadOptions options
Options for the download.
struct GNUNET_FS_Handle * h
Global FS context.
struct GNUNET_TIME_Absolute start_time
Time download was started.
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Master context for most FS operations.
void * upcb_cls
Closure for upcb.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Argument given to the progress callback with information about what is going on.
struct GNUNET_FS_ProgressInfo::@21::GNUNET_FS_DownloadStatusEvent download
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
enum GNUNET_FS_Status status
Specific status code (determines the event type).
union GNUNET_FS_ProgressInfo::@21 value
Values that depend on the event type.
Information we store for each search result.
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
void * client_info
Client info for this search result.
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results' availability (NULL if we are not currently probin...
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
struct GNUNET_FS_MetaData * meta
Metadata for the search result.
A Universal Resource Identifier (URI), opaque.
union GNUNET_FS_Uri::@49 data
enum GNUNET_FS_UriType type
Type of the URI.
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content.
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Message handler for a specific message type.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
uint64_t rel_value_us
The actual value.
struct FileIdentifier fi
Information about the shared file.
Closure for iterator processing results.
uint32_t respect_offered
how much respect did we offer to get this reply?
size_t size
Number of bytes in data.
int do_store
Flag to indicate if this block should be stored on disk.
struct GNUNET_FS_DownloadContext * dc
Our download context.
struct GNUNET_TIME_Absolute last_transmission
When did we last transmit the request?
const void * data
Data found in P2P network.
uint32_t num_transmissions
how often did we transmit the query?
enum GNUNET_BLOCK_Type type
Type of data.
struct GNUNET_HashCode query
Hash of data.
Message sent from a GNUnet (fs) search activity to the gnunet-service-fs to start a search.
struct GNUNET_PeerIdentity target
If the request is for a DBLOCK or IBLOCK, this is the identity of the peer that is known to have a re...
uint32_t type
Type of the content that we're looking for.
struct GNUNET_HashCode query
Hash of the public key for UBLOCKs; Hash of the CHK-encoded block for DBLOCKS and IBLOCKS.
uint32_t anonymity_level
Desired anonymity level, big-endian.
uint32_t options
Bitmask with options.