aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_api.h
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 11:55:21 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 11:55:21 +0200
commit579d9473bb75072303789599b23be9b0203336fc (patch)
tree687506d1968bd2a391b71b8832d1e97905db3ca8 /src/fs/fs_api.h
parentb56e4e05ad919c7191260fcf1d78b1f8d739871a (diff)
downloadgnunet-579d9473bb75072303789599b23be9b0203336fc.tar.gz
gnunet-579d9473bb75072303789599b23be9b0203336fc.zip
BUILD: Move fs to contrib/service
Diffstat (limited to 'src/fs/fs_api.h')
-rw-r--r--src/fs/fs_api.h1941
1 files changed, 0 insertions, 1941 deletions
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
deleted file mode 100644
index fdda91928..000000000
--- a/src/fs/fs_api.h
+++ /dev/null
@@ -1,1941 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file fs/fs_api.h
23 * @brief shared definitions for the FS library
24 * @author Igor Wronsky, Christian Grothoff
25 */
26#ifndef FS_API_H
27#define FS_API_H
28
29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h"
32
33#include "gnunet_fs_service.h"
34#include "gnunet_block_lib.h"
35#include "block_fs.h"
36#include "fs.h"
37
38/**
39 * Pick a multiple of 2 here to achieve 8-byte alignment! We also
40 * probably want DBlocks to have (roughly) the same size as IBlocks.
41 * With SHA-512, the optimal value is 32768 byte / 128 byte = 256 (128
42 * byte = 2 * 512 bits). DO NOT CHANGE!
43 */
44#define CHK_PER_INODE 256
45
46/**
47 * Maximum size for a file to be considered for inlining in a
48 * directory.
49 */
50#define MAX_INLINE_SIZE 65536
51
52/**
53 * Name of the directory with top-level searches.
54 */
55#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH "search"
56
57/**
58 * Name of the directory with sub-searches (namespace-updates).
59 */
60#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH "search-child"
61
62/**
63 * Name of the directory with master downloads (not associated
64 * with search or part of another download).
65 */
66#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD "download"
67
68/**
69 * Name of the directory with downloads that are part of another
70 * download or a search.
71 */
72#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD "download-child"
73
74/**
75 * Name of the directory with publishing operations.
76 */
77#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH "publish"
78
79/**
80 * Name of the directory with files that are being published
81 */
82#define GNUNET_FS_SYNC_PATH_FILE_INFO "publish-file"
83
84/**
85 * Name of the directory with unindex operations.
86 */
87#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX "unindex"
88
89
90/**
91 * @brief complete information needed
92 * to download a file.
93 */
94struct FileIdentifier
95{
96 /**
97 * Total size of the file in bytes. (network byte order (!))
98 */
99 uint64_t file_length;
100
101 /**
102 * Query and key of the top GNUNET_EC_IBlock.
103 */
104 struct ContentHashKey chk;
105};
106
107
108/**
109 * Information about a file and its location
110 * (peer claiming to share the file).
111 */
112struct Location
113{
114 /**
115 * Information about the shared file.
116 */
117 struct FileIdentifier fi;
118
119 /**
120 * Identity of the peer sharing the file.
121 */
122 struct GNUNET_PeerIdentity peer;
123
124 /**
125 * Time when this location URI expires.
126 */
127 struct GNUNET_TIME_Absolute expirationTime;
128
129 /**
130 * Signature over the GNUNET_EC_FileIdentifier,
131 * peer identity and expiration time.
132 */
133 struct GNUNET_CRYPTO_EddsaSignature contentSignature;
134};
135
136/**
137 * Types of URIs.
138 */
139enum GNUNET_FS_UriType
140{
141 /**
142 * Content-hash-key (simple file).
143 */
144 GNUNET_FS_URI_CHK,
145
146 /**
147 * Signed key space (file in namespace).
148 */
149 GNUNET_FS_URI_SKS,
150
151 /**
152 * Keyword search key (query with keywords).
153 */
154 GNUNET_FS_URI_KSK,
155
156 /**
157 * Location (chk with identity of hosting peer).
158 */
159 GNUNET_FS_URI_LOC
160};
161
162
163/**
164 * A Universal Resource Identifier (URI), opaque.
165 */
166struct GNUNET_FS_Uri
167{
168 /**
169 * Type of the URI.
170 */
171 enum GNUNET_FS_UriType type;
172
173 union
174 {
175 struct
176 {
177 /**
178 * Keywords start with a '+' if they are mandatory (in which
179 * case the '+' is NOT part of the keyword) and with a simple
180 * space if they are optional (in which case the space is ALSO
181 * not part of the actual keyword).
182 *
183 * Double-quotes to protect spaces and %-encoding are NOT used
184 * internally (only in URI-strings).
185 */
186 char **keywords;
187
188 /**
189 * Size of the keywords array.
190 */
191 unsigned int keywordCount;
192 } ksk;
193
194 struct
195 {
196 /**
197 * Identifier of the namespace.
198 */
199 struct GNUNET_CRYPTO_EcdsaPublicKey ns;
200
201 /**
202 * Human-readable identifier chosen for this entry in the
203 * namespace.
204 */
205 char *identifier;
206 } sks;
207
208 /**
209 * Information needed to retrieve a file (content-hash-key
210 * plus file size).
211 */
212 struct FileIdentifier chk;
213
214 /**
215 * Information needed to retrieve a file including signed
216 * location (identity of a peer) of the content.
217 */
218 struct Location loc;
219 } data;
220};
221
222
223/**
224 * Information for a file or directory that is
225 * about to be published.
226 */
227struct GNUNET_FS_FileInformation
228{
229 /**
230 * Files in a directory are kept as a linked list.
231 */
232 struct GNUNET_FS_FileInformation *next;
233
234 /**
235 * If this is a file in a directory, "dir" refers to
236 * the directory; otherwise NULL.
237 */
238 struct GNUNET_FS_FileInformation *dir;
239
240 /**
241 * Handle to the master context.
242 */
243 struct GNUNET_FS_Handle *h;
244
245 /**
246 * Pointer kept for the client.
247 */
248 void *client_info;
249
250 /**
251 * Metadata to use for the file.
252 */
253 struct GNUNET_FS_MetaData *meta;
254
255 /**
256 * Keywords to use for KBlocks.
257 */
258 struct GNUNET_FS_Uri *keywords;
259
260 /**
261 * CHK for this file or directory. NULL if
262 * we have not yet computed it.
263 */
264 struct GNUNET_FS_Uri *chk_uri;
265
266 /**
267 * SKS URI for this file or directory. NULL if
268 * we have not yet computed it.
269 */
270 struct GNUNET_FS_Uri *sks_uri;
271
272 /**
273 * Block options for the file.
274 */
275 struct GNUNET_FS_BlockOptions bo;
276
277 /**
278 * At what time did we start this upload?
279 */
280 struct GNUNET_TIME_Absolute start_time;
281
282 /**
283 * Under what filename is this struct serialized
284 * (for operational persistence). Should be determined
285 * using 'mktemp'.
286 */
287 char *serialization;
288
289 /**
290 * Encoder being used to publish this file.
291 */
292 struct GNUNET_FS_TreeEncoder *te;
293
294 /**
295 * Error message (non-NULL if this operation failed).
296 */
297 char *emsg;
298
299 /**
300 * Name of the file or directory (must be an absolute path).
301 */
302 char *filename;
303
304 /**
305 * Data describing either the file or the directory.
306 */
307 union
308 {
309 /**
310 * Data for a file.
311 */
312 struct
313 {
314 /**
315 * Function that can be used to read the data for the file.
316 */
317 GNUNET_FS_DataReader reader;
318
319 /**
320 * Closure for reader.
321 */
322 void *reader_cls;
323
324 /**
325 * If this file is being indexed, this value is set to the hash
326 * over the entire file (when the indexing process is started).
327 * Otherwise this field is not used.
328 */
329 struct GNUNET_HashCode file_id;
330
331 /**
332 * Size of the file (in bytes).
333 */
334 uint64_t file_size;
335
336 /**
337 * Should the file be indexed or inserted?
338 */
339 int do_index;
340
341 /**
342 * Is "file_id" already valid? Set to #GNUNET_YES once the hash
343 * has been calculated.
344 */
345 int have_hash;
346
347 /**
348 * Has the service confirmed our INDEX_START request?
349 * #GNUNET_YES if this step has been completed.
350 */
351 int index_start_confirmed;
352 } file;
353
354 /**
355 * Data for a directory.
356 */
357 struct
358 {
359 /**
360 * Linked list of entries in the directory.
361 */
362 struct GNUNET_FS_FileInformation *entries;
363
364 /**
365 * Size of the directory itself (in bytes); 0 if the
366 * size has not yet been calculated.
367 */
368 size_t dir_size;
369
370 /**
371 * Pointer to the data for the directory (or NULL if not
372 * available).
373 */
374 void *dir_data;
375
376 /**
377 * How much of the directory have we published (relative to @e contents_size).
378 */
379 uint64_t contents_completed;
380
381 /**
382 * Sum of all of the sizes of all of the files in the directory.
383 */
384 uint64_t contents_size;
385 } dir;
386 } data;
387
388 /**
389 * Is this struct for a file or directory?
390 */
391 int is_directory;
392
393 /**
394 * Are we done publishing this file?
395 */
396 int is_published;
397};
398
399
400/**
401 * Priorities for the queue.
402 */
403enum GNUNET_FS_QueuePriority
404{
405 /**
406 * This is a probe (low priority).
407 */
408 GNUNET_FS_QUEUE_PRIORITY_PROBE,
409
410 /**
411 * Default priority.
412 */
413 GNUNET_FS_QUEUE_PRIORITY_NORMAL
414};
415
416
417/**
418 * Entry in the job queue.
419 */
420struct GNUNET_FS_QueueEntry
421{
422 /**
423 * This is a linked list.
424 */
425 struct GNUNET_FS_QueueEntry *next;
426
427 /**
428 * This is a linked list.
429 */
430 struct GNUNET_FS_QueueEntry *prev;
431
432 /**
433 * Function to call when the job is started.
434 */
435 GNUNET_SCHEDULER_TaskCallback start;
436
437 /**
438 * Function to call when the job needs to stop (or is done / dequeued).
439 */
440 GNUNET_SCHEDULER_TaskCallback stop;
441
442 /**
443 * Closure for start and stop.
444 */
445 void *cls;
446
447 /**
448 * Handle to FS primary context.
449 */
450 struct GNUNET_FS_Handle *h;
451
452 /**
453 * Message queue handle, or NULL if job is not running.
454 */
455 struct GNUNET_MQ_Handle *mq;
456
457 /**
458 * Time the job was originally queued.
459 */
460 struct GNUNET_TIME_Absolute queue_time;
461
462 /**
463 * Time the job was started last.
464 */
465 struct GNUNET_TIME_Absolute start_time;
466
467 /**
468 * Total amount of time the job has been running (except for the
469 * current run).
470 */
471 struct GNUNET_TIME_Relative run_time;
472
473 /**
474 * How many blocks do the active downloads have?
475 */
476 unsigned int blocks;
477
478 /**
479 * How important is this download?
480 */
481 enum GNUNET_FS_QueuePriority priority;
482
483 /**
484 * How often have we (re)started this download?
485 */
486 unsigned int start_times;
487
488 /**
489 * #GNUNET_YES if the job is active now.
490 */
491 int active;
492};
493
494
495/**
496 * Information we store for each search result.
497 */
498struct GNUNET_FS_SearchResult
499{
500 /**
501 * File-sharing context this result belongs to.
502 */
503 struct GNUNET_FS_Handle *h;
504
505 /**
506 * Kept in a DLL while probing.
507 */
508 struct GNUNET_FS_SearchResult *next;
509
510 /**
511 * Kept in a DLL while probing.
512 */
513 struct GNUNET_FS_SearchResult *prev;
514
515 /**
516 * Search context this result belongs to; can be NULL
517 * for probes that come from a directory result.
518 */
519 struct GNUNET_FS_SearchContext *sc;
520
521 /**
522 * URI to which this search result refers to.
523 */
524 struct GNUNET_FS_Uri *uri;
525
526 /**
527 * Metadata for the search result.
528 */
529 struct GNUNET_FS_MetaData *meta;
530
531 /**
532 * Client info for this search result.
533 */
534 void *client_info;
535
536 /**
537 * ID of a job that is currently probing this results' availability
538 * (NULL if we are not currently probing).
539 */
540 struct GNUNET_FS_DownloadContext *probe_ctx;
541
542 /**
543 * ID of an associated download based on this search result (or
544 * NULL for none).
545 */
546 struct GNUNET_FS_DownloadContext *download;
547
548 /**
549 * If this search result triggered an update search, this field
550 * links to the update search.
551 */
552 struct GNUNET_FS_SearchContext *update_search;
553
554 /**
555 * Name under which this search result is stored on disk.
556 */
557 char *serialization;
558
559 /**
560 * Bitmap that specifies precisely which keywords have been matched already.
561 */
562 uint8_t *keyword_bitmap;
563
564 /**
565 * Key for the search result based on the URI.
566 */
567 struct GNUNET_HashCode key;
568
569 /**
570 * ID of the task that will clean up the probe_ctx should it not
571 * complete on time (and that will need to be cancelled if we clean
572 * up the search result before then).
573 */
574 struct GNUNET_SCHEDULER_Task *probe_cancel_task;
575
576 /**
577 * When did the current probe become active?
578 */
579 struct GNUNET_TIME_Absolute probe_active_time;
580
581 /**
582 * How much longer should we run the current probe before giving up?
583 */
584 struct GNUNET_TIME_Relative remaining_probe_time;
585
586 /**
587 * Anonymity level to use for probes using this search result.
588 */
589 uint32_t anonymity;
590
591 /**
592 * Number of mandatory keywords for which we have NOT yet found the
593 * search result; when this value hits zero, the search result is
594 * given to the callback.
595 */
596 uint32_t mandatory_missing;
597
598 /**
599 * Number of optional keywords under which this result was also
600 * found.
601 */
602 uint32_t optional_support;
603
604 /**
605 * Number of availability tests that have succeeded for this result.
606 */
607 uint32_t availability_success;
608
609 /**
610 * Number of availability trials that we have performed for this
611 * search result.
612 */
613 uint32_t availability_trials;
614};
615
616
617/**
618 * Add a job to the queue.
619 *
620 * @param h handle to the overall FS state
621 * @param start function to call to begin the job
622 * @param stop function to call to pause the job, or on dequeue (if the job was running)
623 * @param cls closure for start and stop
624 * @param blocks number of blocks this download has
625 * @param priority how important is this download
626 * @return queue handle
627 */
628struct GNUNET_FS_QueueEntry *
629GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
630 GNUNET_SCHEDULER_TaskCallback start,
631 GNUNET_SCHEDULER_TaskCallback stop,
632 void *cls,
633 unsigned int blocks,
634 enum GNUNET_FS_QueuePriority priority);
635
636
637/**
638 * Dequeue a job from the queue.
639 *
640 * @param qe handle for the job
641 */
642void
643GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe);
644
645
646/**
647 * Function that provides data by reading from a file.
648 *
649 * @param cls closure (points to the file information)
650 * @param offset offset to read from; it is possible
651 * that the caller might need to go backwards
652 * a bit at times
653 * @param max maximum number of bytes that should be
654 * copied to @a buf; readers are not allowed
655 * to provide less data unless there is an error;
656 * a value of "0" will be used at the end to allow
657 * the reader to clean up its internal state
658 * @param buf where the reader should write the data
659 * @param emsg location for the reader to store an error message
660 * @return number of bytes written, usually "max", 0 on error
661 */
662size_t
663GNUNET_FS_data_reader_file_ (void *cls,
664 uint64_t offset,
665 size_t max,
666 void *buf,
667 char **emsg);
668
669
670/**
671 * Create the closure for the #GNUNET_FS_data_reader_file_() callback.
672 *
673 * @param filename file to read
674 * @return closure to use, NULL on error
675 */
676void *
677GNUNET_FS_make_file_reader_context_ (const char *filename);
678
679
680/**
681 * Function that provides data by copying from a buffer.
682 *
683 * @param cls closure (points to the buffer)
684 * @param offset offset to read from; it is possible
685 * that the caller might need to go backwards
686 * a bit at times
687 * @param max maximum number of bytes that should be
688 * copied to @a buf; readers are not allowed
689 * to provide less data unless there is an error;
690 * a value of "0" will be used at the end to allow
691 * the reader to clean up its internal state
692 * @param buf where the reader should write the data
693 * @param emsg location for the reader to store an error message
694 * @return number of bytes written, usually @a max, 0 on error
695 */
696size_t
697GNUNET_FS_data_reader_copy_ (void *cls,
698 uint64_t offset,
699 size_t max,
700 void *buf,
701 char **emsg);
702
703
704/**
705 * Notification of FS that a search probe has made progress.
706 * This function is used INSTEAD of the client's event handler
707 * for downloads where the #GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.
708 *
709 * @param cls closure, always NULL (!), actual closure
710 * is in the client-context of the info struct
711 * @param info details about the event, specifying the event type
712 * and various bits about the event
713 * @return client-context (for the next progress call
714 * for this operation; should be set to NULL for
715 * SUSPEND and STOPPED events). The value returned
716 * will be passed to future callbacks in the respective
717 * field in the `struct GNUNET_FS_ProgressInfo`.
718 */
719void *
720GNUNET_FS_search_probe_progress_ (void *cls,
721 const struct GNUNET_FS_ProgressInfo *info);
722
723
724/**
725 * Main function that performs the upload.
726 *
727 * @param cls `struct GNUNET_FS_PublishContext` identifies the upload
728 */
729void
730GNUNET_FS_publish_main_ (void *cls);
731
732
733/**
734 * Function called once the hash of the file
735 * that is being unindexed has been computed.
736 *
737 * @param cls closure, unindex context
738 * @param file_id computed hash, NULL on error
739 */
740void
741GNUNET_FS_unindex_process_hash_ (void *cls,
742 const struct GNUNET_HashCode *file_id);
743
744
745/**
746 * Extract the keywords for KBlock removal
747 *
748 * @param uc context for the unindex operation.
749 */
750void
751GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc);
752
753
754/**
755 * If necessary, connect to the datastore and remove the KBlocks.
756 *
757 * @param uc context for the unindex operation.
758 */
759void
760GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc);
761
762
763/**
764 * Fill in all of the generic fields for a publish event and call the
765 * callback.
766 *
767 * @param pi structure to fill in
768 * @param pc overall publishing context
769 * @param p file information for the file being published
770 * @param offset where in the file are we so far
771 * @return value returned from callback
772 */
773void *
774GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
775 struct GNUNET_FS_PublishContext *pc,
776 const struct GNUNET_FS_FileInformation *p,
777 uint64_t offset);
778
779
780/**
781 * Fill in all of the generic fields for a download event and call the
782 * callback.
783 *
784 * @param pi structure to fill in
785 * @param dc overall download context
786 */
787void
788GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
789 struct GNUNET_FS_DownloadContext *dc);
790
791
792/**
793 * Task that creates the initial (top-level) download
794 * request for the file.
795 *
796 * @param cls the 'struct GNUNET_FS_DownloadContext'
797 */
798void
799GNUNET_FS_download_start_task_ (void *cls);
800
801
802/**
803 * Fill in all of the generic fields for
804 * an unindex event and call the callback.
805 *
806 * @param pi structure to fill in
807 * @param uc overall unindex context
808 * @param offset where we are in the file (for progress)
809 */
810void
811GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
812 struct GNUNET_FS_UnindexContext *uc,
813 uint64_t offset);
814
815/**
816 * Fill in all of the generic fields for a search event and
817 * call the callback.
818 *
819 * @param pi structure to fill in
820 * @param h file-sharing handle
821 * @param sc overall search context
822 * @return value returned by the callback
823 */
824void *
825GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
826 struct GNUNET_FS_Handle *h,
827 struct GNUNET_FS_SearchContext *sc);
828
829
830/**
831 * Connect to the datastore and remove the blocks.
832 *
833 * @param uc context for the unindex operation.
834 */
835void
836GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc);
837
838/**
839 * Build the request and actually initiate the search using the
840 * GNUnet FS service.
841 *
842 * @param sc search context
843 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
844 */
845int
846GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc);
847
848/**
849 * Start the downloading process (by entering the queue).
850 *
851 * @param dc our download context
852 */
853void
854GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc);
855
856
857/**
858 * Start download probes for the given search result.
859 *
860 * @param sr the search result
861 */
862void
863GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr);
864
865
866/**
867 * Remove serialization/deserialization file from disk.
868 *
869 * @param h master context
870 * @param ext component of the path
871 * @param ent entity identifier
872 */
873void
874GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
875 const char *ext,
876 const char *ent);
877
878
879/**
880 * Remove serialization/deserialization directory from disk.
881 *
882 * @param h master context
883 * @param ext component of the path
884 * @param uni unique name of parent
885 */
886void
887GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h,
888 const char *ext,
889 const char *uni);
890
891
892/**
893 * Synchronize this file-information struct with its mirror
894 * on disk. Note that all internal FS-operations that change
895 * file information data should already call "sync" internally,
896 * so this function is likely not useful for clients.
897 *
898 * @param fi the struct to sync
899 */
900void
901GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f);
902
903
904/**
905 * Synchronize this publishing struct with its mirror
906 * on disk. Note that all internal FS-operations that change
907 * publishing structs should already call "sync" internally,
908 * so this function is likely not useful for clients.
909 *
910 * @param pc the struct to sync
911 */
912void
913GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc);
914
915
916/**
917 * Synchronize this unindex struct with its mirror
918 * on disk. Note that all internal FS-operations that change
919 * publishing structs should already call "sync" internally,
920 * so this function is likely not useful for clients.
921 *
922 * @param uc the struct to sync
923 */
924void
925GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc);
926
927
928/**
929 * Synchronize this search struct with its mirror
930 * on disk. Note that all internal FS-operations that change
931 * publishing structs should already call "sync" internally,
932 * so this function is likely not useful for clients.
933 *
934 * @param sc the struct to sync
935 */
936void
937GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc);
938
939
940/**
941 * Synchronize this search result with its mirror
942 * on disk. Note that all internal FS-operations that change
943 * publishing structs should already call "sync" internally,
944 * so this function is likely not useful for clients.
945 *
946 * @param sr the struct to sync
947 */
948void
949GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr);
950
951
952/**
953 * Synchronize this download struct with its mirror
954 * on disk. Note that all internal FS-operations that change
955 * publishing structs should already call "sync" internally,
956 * so this function is likely not useful for clients.
957 *
958 * @param dc the struct to sync
959 */
960void
961GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc);
962
963
964/**
965 * Create SUSPEND event for the given publish operation
966 * and then clean up our state (without stop signal).
967 *
968 * @param cls the `struct GNUNET_FS_PublishContext` to signal for
969 */
970void
971GNUNET_FS_publish_signal_suspend_ (void *cls);
972
973
974/**
975 * Create SUSPEND event for the given search operation
976 * and then clean up our state (without stop signal).
977 *
978 * @param cls the 'struct GNUNET_FS_SearchContext' to signal for
979 */
980void
981GNUNET_FS_search_signal_suspend_ (void *cls);
982
983
984/**
985 * Create SUSPEND event for the given download operation
986 * and then clean up our state (without stop signal).
987 *
988 * @param cls the `struct GNUNET_FS_DownloadContext` to signal for
989 */
990void
991GNUNET_FS_download_signal_suspend_ (void *cls);
992
993
994/**
995 * Create SUSPEND event for the given unindex operation
996 * and then clean up our state (without stop signal).
997 *
998 * @param cls the `struct GNUNET_FS_UnindexContext` to signal for
999 */
1000void
1001GNUNET_FS_unindex_signal_suspend_ (void *cls);
1002
1003
1004/**
1005 * Function signature of the functions that can be called
1006 * to trigger suspend signals and clean-up for top-level
1007 * activities.
1008 *
1009 * @param cls closure
1010 */
1011typedef void (*SuspendSignalFunction) (void *cls);
1012
1013/**
1014 * We track all of the top-level activities of FS
1015 * so that we can signal 'suspend' on shutdown.
1016 */
1017struct TopLevelActivity
1018{
1019 /**
1020 * This is a doubly-linked list.
1021 */
1022 struct TopLevelActivity *next;
1023
1024 /**
1025 * This is a doubly-linked list.
1026 */
1027 struct TopLevelActivity *prev;
1028
1029 /**
1030 * Function to call for suspend-signalling and clean up.
1031 */
1032 SuspendSignalFunction ssf;
1033
1034 /**
1035 * Closure for 'ssf' (some struct GNUNET_FS_XXXHandle*)
1036 */
1037 void *ssf_cls;
1038};
1039
1040
1041/**
1042 * Create a top-level activity entry.
1043 *
1044 * @param h global fs handle
1045 * @param ssf suspend signal function to use
1046 * @param ssf_cls closure for @a ssf
1047 * @return fresh top-level activity handle
1048 */
1049struct TopLevelActivity *
1050GNUNET_FS_make_top (struct GNUNET_FS_Handle *h,
1051 SuspendSignalFunction ssf,
1052 void *ssf_cls);
1053
1054
1055/**
1056 * Destroy a top-level activity entry.
1057 *
1058 * @param h global fs handle
1059 * @param top top level activity entry
1060 */
1061void
1062GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
1063 struct TopLevelActivity *top);
1064
1065
1066/**
1067 * Master context for most FS operations.
1068 */
1069struct GNUNET_FS_Handle
1070{
1071 /**
1072 * Configuration to use.
1073 */
1074 const struct GNUNET_CONFIGURATION_Handle *cfg;
1075
1076 /**
1077 * Name of our client.
1078 */
1079 char *client_name;
1080
1081 /**
1082 * Function to call with updates on our progress.
1083 */
1084 GNUNET_FS_ProgressCallback upcb;
1085
1086 /**
1087 * Closure for upcb.
1088 */
1089 void *upcb_cls;
1090
1091 /**
1092 * Head of DLL of top-level activities.
1093 */
1094 struct TopLevelActivity *top_head;
1095
1096 /**
1097 * Tail of DLL of top-level activities.
1098 */
1099 struct TopLevelActivity *top_tail;
1100
1101 /**
1102 * Head of DLL of running jobs.
1103 */
1104 struct GNUNET_FS_QueueEntry *running_head;
1105
1106 /**
1107 * Tail of DLL of running jobs.
1108 */
1109 struct GNUNET_FS_QueueEntry *running_tail;
1110
1111 /**
1112 * Head of DLL of pending jobs.
1113 */
1114 struct GNUNET_FS_QueueEntry *pending_head;
1115
1116 /**
1117 * Tail of DLL of pending jobs.
1118 */
1119 struct GNUNET_FS_QueueEntry *pending_tail;
1120
1121 /**
1122 * Head of active probes.
1123 */
1124 struct GNUNET_FS_SearchResult *probes_head;
1125
1126 /**
1127 * Tail of active probes.
1128 */
1129 struct GNUNET_FS_SearchResult *probes_tail;
1130
1131 /**
1132 * Task that processes the jobs in the running and pending queues
1133 * (and moves jobs around as needed).
1134 */
1135 struct GNUNET_SCHEDULER_Task *queue_job;
1136
1137 /**
1138 * Task we use to report periodically to the application that
1139 * certain search probes (from @e probes_head) are still running.
1140 */
1141 struct GNUNET_SCHEDULER_Task *probe_ping_task;
1142
1143 /**
1144 * Average time we take for a single request to be satisfied.
1145 * FIXME: not yet calculated properly...
1146 */
1147 struct GNUNET_TIME_Relative avg_block_latency;
1148
1149 /**
1150 * How many actual downloads do we have running right now?
1151 */
1152 unsigned int active_downloads;
1153
1154 /**
1155 * How many blocks do the active downloads have?
1156 */
1157 unsigned int active_blocks;
1158
1159 /**
1160 * General flags.
1161 */
1162 enum GNUNET_FS_Flags flags;
1163
1164 /**
1165 * Maximum number of parallel downloads.
1166 */
1167 unsigned int max_parallel_downloads;
1168
1169 /**
1170 * Maximum number of parallel requests.
1171 */
1172 unsigned int max_parallel_requests;
1173};
1174
1175
1176/**
1177 * Handle for controlling a publication process.
1178 */
1179struct GNUNET_FS_PublishContext
1180{
1181 /**
1182 * Handle to the global fs context.
1183 */
1184 struct GNUNET_FS_Handle *h;
1185
1186 /**
1187 * Our top-level activity entry (if we are top-level, otherwise NULL).
1188 */
1189 struct TopLevelActivity *top;
1190
1191 /**
1192 * File-structure that is being shared.
1193 */
1194 struct GNUNET_FS_FileInformation *fi;
1195
1196 /**
1197 * Namespace that we are publishing in, NULL if we have no namespace.
1198 */
1199 struct GNUNET_CRYPTO_EcdsaPrivateKey *ns;
1200
1201 /**
1202 * ID of the content in the namespace, NULL if we have no namespace.
1203 */
1204 char *nid;
1205
1206 /**
1207 * ID for future updates, NULL if we have no namespace or no updates.
1208 */
1209 char *nuid;
1210
1211 /**
1212 * Filename used for serializing information about this operation
1213 * (should be determined using 'mktemp').
1214 */
1215 char *serialization;
1216
1217 /**
1218 * Our own message queue for the FS service; only briefly used when
1219 * we start to index a file, otherwise NULL.
1220 */
1221 struct GNUNET_MQ_Handle *mq;
1222
1223 /**
1224 * Current position in the file-tree for the upload.
1225 */
1226 struct GNUNET_FS_FileInformation *fi_pos;
1227
1228 /**
1229 * Non-null if we are currently hashing a file.
1230 */
1231 struct GNUNET_CRYPTO_FileHashContext *fhc;
1232
1233 /**
1234 * Connection to the datastore service.
1235 */
1236 struct GNUNET_DATASTORE_Handle *dsh;
1237
1238 /**
1239 * Queue entry for reservation/unreservation.
1240 */
1241 struct GNUNET_DATASTORE_QueueEntry *qre;
1242
1243 /**
1244 * Context for SKS publishing operation that is part of this publishing operation
1245 * (NULL if not active).
1246 */
1247 struct GNUNET_FS_PublishSksContext *sks_pc;
1248
1249 /**
1250 * Context for KSK publishing operation that is part of this publishing operation
1251 * (NULL if not active).
1252 */
1253 struct GNUNET_FS_PublishKskContext *ksk_pc;
1254
1255 /**
1256 * ID of the task performing the upload. NO_TASK if the upload has
1257 * completed.
1258 */
1259 struct GNUNET_SCHEDULER_Task *upload_task;
1260
1261 /**
1262 * Storage space to reserve for the operation.
1263 */
1264 uint64_t reserve_space;
1265
1266 /**
1267 * Overall number of entries to reserve for the
1268 * publish operation.
1269 */
1270 uint32_t reserve_entries;
1271
1272 /**
1273 * Options for publishing.
1274 */
1275 enum GNUNET_FS_PublishOptions options;
1276
1277 /**
1278 * Space reservation ID with datastore service
1279 * for this upload.
1280 */
1281 int rid;
1282
1283 /**
1284 * Set to #GNUNET_YES if we were able to publish any block.
1285 * (and thus unindexing on error might make sense).
1286 */
1287 int any_done;
1288
1289 /**
1290 * Set to #GNUNET_YES if all processing has completed.
1291 */
1292 int all_done;
1293
1294 /**
1295 * Flag set to #GNUNET_YES if the next callback from
1296 * #GNUNET_FS_file_information_inspect should be skipped because it
1297 * is for the directory which was already processed with the parent.
1298 */
1299 int skip_next_fi_callback;
1300};
1301
1302
1303/**
1304 * Phases of unindex processing (state machine).
1305 */
1306enum UnindexState
1307{
1308 /**
1309 * We're currently hashing the file.
1310 */
1311 UNINDEX_STATE_HASHING = 0,
1312
1313 /**
1314 * We're telling the datastore to delete
1315 * the respective DBlocks and IBlocks.
1316 */
1317 UNINDEX_STATE_DS_REMOVE = 1,
1318
1319 /**
1320 * Find out which keywords apply.
1321 */
1322 UNINDEX_STATE_EXTRACT_KEYWORDS = 2,
1323
1324 /**
1325 * We're telling the datastore to remove KBlocks.
1326 */
1327 UNINDEX_STATE_DS_REMOVE_KBLOCKS = 3,
1328
1329 /**
1330 * We're notifying the FS service about
1331 * the unindexing.
1332 */
1333 UNINDEX_STATE_FS_NOTIFY = 4,
1334
1335 /**
1336 * We're done.
1337 */
1338 UNINDEX_STATE_COMPLETE = 5,
1339
1340 /**
1341 * We've encountered a fatal error.
1342 */
1343 UNINDEX_STATE_ERROR = 6
1344};
1345
1346
1347/**
1348 * Handle for controlling an unindexing operation.
1349 */
1350struct GNUNET_FS_UnindexContext
1351{
1352 /**
1353 * The content hash key of the last block we processed, will in the
1354 * end be set to the CHK from the URI. Used to remove the KBlocks.
1355 */
1356 struct ContentHashKey chk;
1357
1358 /**
1359 * Global FS context.
1360 */
1361 struct GNUNET_FS_Handle *h;
1362
1363 /**
1364 * Our top-level activity entry.
1365 */
1366 struct TopLevelActivity *top;
1367
1368 /**
1369 * Directory scanner to find keywords (KBlock removal).
1370 */
1371 struct GNUNET_FS_DirScanner *dscan;
1372
1373 /**
1374 * Keywords found (telling us which KBlocks to remove).
1375 */
1376 struct GNUNET_FS_Uri *ksk_uri;
1377
1378 /**
1379 * Current offset in KSK removal.
1380 */
1381 uint32_t ksk_offset;
1382
1383 /**
1384 * Name of the file that we are unindexing.
1385 */
1386 char *filename;
1387
1388 /**
1389 * Short name under which we are serializing the state of this operation.
1390 */
1391 char *serialization;
1392
1393 /**
1394 * Connection to the FS service, only valid during the
1395 * #UNINDEX_STATE_FS_NOTIFY phase.
1396 */
1397 struct GNUNET_MQ_Handle *mq;
1398
1399 /**
1400 * Connection to the datastore service, only valid during the
1401 * UNINDEX_STATE_DS_NOTIFY phase.
1402 */
1403 struct GNUNET_DATASTORE_Handle *dsh;
1404
1405 /**
1406 * Pointer kept for the client.
1407 */
1408 void *client_info;
1409
1410 /**
1411 * Merkle-ish tree encoder context.
1412 */
1413 struct GNUNET_FS_TreeEncoder *tc;
1414
1415 /**
1416 * Handle used to read the file.
1417 */
1418 struct GNUNET_DISK_FileHandle *fh;
1419
1420 /**
1421 * Handle to datastore 'get_key' operation issued for
1422 * obtaining KBlocks.
1423 */
1424 struct GNUNET_DATASTORE_QueueEntry *dqe;
1425
1426 /**
1427 * Current key for decrypting UBLocks from 'get_key' operation.
1428 */
1429 struct GNUNET_HashCode ukey;
1430
1431 /**
1432 * Current query of 'get_key' operation.
1433 */
1434 struct GNUNET_HashCode uquery;
1435
1436 /**
1437 * Error message, NULL on success.
1438 */
1439 char *emsg;
1440
1441 /**
1442 * Context for hashing of the file.
1443 */
1444 struct GNUNET_CRYPTO_FileHashContext *fhc;
1445
1446 /**
1447 * Overall size of the file.
1448 */
1449 uint64_t file_size;
1450
1451 /**
1452 * When did we start?
1453 */
1454 struct GNUNET_TIME_Absolute start_time;
1455
1456 /**
1457 * Hash of the file's contents (once computed).
1458 */
1459 struct GNUNET_HashCode file_id;
1460
1461 /**
1462 * Current operatinonal phase.
1463 */
1464 enum UnindexState state;
1465};
1466
1467
1468/**
1469 * Information we keep for each keyword in a keyword search.
1470 */
1471struct SearchRequestEntry
1472{
1473 /**
1474 * Hash of the public key, also known as the query.
1475 */
1476 struct GNUNET_HashCode uquery;
1477
1478 /**
1479 * Derived public key, hashes to 'uquery'.
1480 */
1481 struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
1482
1483 /**
1484 * The original keyword, used to derive the
1485 * key (for decrypting the UBlock).
1486 */
1487 char *keyword;
1488
1489 /**
1490 * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
1491 * was found under this keyword. Note that the entries will point
1492 * to the same locations as those in the master result map (in
1493 * "struct GNUNET_FS_SearchContext"), so they should not be freed.
1494 * The key for each entry is the XOR of the key and query in the CHK
1495 * URI (as a unique identifier for the search result).
1496 */
1497 struct GNUNET_CONTAINER_MultiHashMap *results;
1498
1499 /**
1500 * Is this keyword a mandatory keyword
1501 * (started with '+')?
1502 */
1503 int mandatory;
1504};
1505
1506
1507/**
1508 * Handle for controlling a search.
1509 */
1510struct GNUNET_FS_SearchContext
1511{
1512 /**
1513 * Handle to the global FS context.
1514 */
1515 struct GNUNET_FS_Handle *h;
1516
1517 /**
1518 * Our top-level activity entry (if we are top-level, otherwise NULL).
1519 */
1520 struct TopLevelActivity *top;
1521
1522 /**
1523 * List of keywords that we're looking for.
1524 */
1525 struct GNUNET_FS_Uri *uri;
1526
1527 /**
1528 * For update-searches, link to the search result that triggered
1529 * the update search; otherwise NULL.
1530 */
1531 struct GNUNET_FS_SearchResult *psearch_result;
1532
1533 /**
1534 * Connection to the FS service.
1535 */
1536 struct GNUNET_MQ_Handle *mq;
1537
1538 /**
1539 * Pointer we keep for the client.
1540 */
1541 void *client_info;
1542
1543 /**
1544 * Name of the file on disk we use for persistence.
1545 */
1546 char *serialization;
1547
1548 /**
1549 * Error message (non-NULL if this operation failed).
1550 */
1551 char *emsg;
1552
1553 /**
1554 * Map that contains a `struct GNUNET_FS_SearchResult` for each result that
1555 * was found in the search. The key for each entry is the XOR of
1556 * the key and query in the CHK URI (as a unique identifier for the
1557 * search result).
1558 */
1559 struct GNUNET_CONTAINER_MultiHashMap *master_result_map;
1560
1561 /**
1562 * Per-keyword information for a keyword search. This array will
1563 * have exactly as many entries as there were keywords.
1564 */
1565 struct SearchRequestEntry *requests;
1566
1567 /**
1568 * When did we start?
1569 */
1570 struct GNUNET_TIME_Absolute start_time;
1571
1572 /**
1573 * How long to wait before we try to reconnect to FS service?
1574 */
1575 struct GNUNET_TIME_Relative reconnect_backoff;
1576
1577 /**
1578 * ID of a task that is using this struct and that must be cancelled
1579 * when the search is being stopped (if not
1580 * NULL). Used for the task that adds some
1581 * artificial delay when trying to reconnect to the FS service.
1582 */
1583 struct GNUNET_SCHEDULER_Task *task;
1584
1585 /**
1586 * Anonymity level for the search.
1587 */
1588 uint32_t anonymity;
1589
1590 /**
1591 * Number of mandatory keywords in this query.
1592 */
1593 uint32_t mandatory_count;
1594
1595 /**
1596 * Options for the search.
1597 */
1598 enum GNUNET_FS_SearchOptions options;
1599};
1600
1601
1602/**
1603 * FSM for possible states a block can go through. The typical
1604 * order of progression is linear through the states, alternatives
1605 * are documented in the comments.
1606 */
1607enum BlockRequestState
1608{
1609 /**
1610 * Initial state, block has only been allocated (since it is
1611 * relevant to the overall download request).
1612 */
1613 BRS_INIT = 0,
1614
1615 /**
1616 * We've checked the block on the path down the tree, and the
1617 * content on disk did match the desired CHK, but not all
1618 * the way down, so at the bottom some blocks will still
1619 * need to be reconstructed).
1620 */
1621 BRS_RECONSTRUCT_DOWN = 1,
1622
1623 /**
1624 * We've calculated the CHK bottom-up based on the meta data.
1625 * This may work, but if it did we have to write the meta data to
1626 * disk at the end (and we still need to check against the
1627 * CHK set on top).
1628 */
1629 BRS_RECONSTRUCT_META_UP = 2,
1630
1631 /**
1632 * We've calculated the CHK bottom-up based on what we have on
1633 * disk, which may not be what the desired CHK is. If the
1634 * reconstructed CHKs match whatever comes from above, we're
1635 * done with the respective subtree.
1636 */
1637 BRS_RECONSTRUCT_UP = 3,
1638
1639 /**
1640 * We've determined the real, desired CHK for this block
1641 * (full tree reconstruction failed), request is now pending.
1642 * If the CHK that bubbled up through reconstruction did match
1643 * the top-level request, the state machine for the subtree
1644 * would have moved to BRS_DOWNLOAD_UP.
1645 */
1646 BRS_CHK_SET = 4,
1647
1648 /**
1649 * We've successfully downloaded this block, but the children
1650 * still need to be either downloaded or verified (download
1651 * request propagates down). If the download fails, the
1652 * state machine for this block may move to
1653 * BRS_DOWNLOAD_ERROR instead.
1654 */
1655 BRS_DOWNLOAD_DOWN = 5,
1656
1657 /**
1658 * This block and all of its children have been downloaded
1659 * successfully (full completion propagates up).
1660 */
1661 BRS_DOWNLOAD_UP = 6,
1662
1663 /**
1664 * We got a block back that matched the query but did not hash to
1665 * the key (malicious publisher or hash collision); this block
1666 * can never be downloaded (error propagates up).
1667 */
1668 BRS_ERROR = 7
1669};
1670
1671
1672/**
1673 * Information about an active download request.
1674 */
1675struct DownloadRequest
1676{
1677 /**
1678 * Parent in the CHK-tree.
1679 */
1680 struct DownloadRequest *parent;
1681
1682 /**
1683 * Array (!) of child-requests, or NULL for the bottom of the tree.
1684 */
1685 struct DownloadRequest **children;
1686
1687 /**
1688 * CHK for the request for this block (set during reconstruction
1689 * to what we have on disk, later to what we want to have).
1690 */
1691 struct ContentHashKey chk;
1692
1693 /**
1694 * Offset of the corresponding block. Specifically, first (!) byte of
1695 * the first DBLOCK in the subtree induced by block represented by
1696 * this request.
1697 */
1698 uint64_t offset;
1699
1700 /**
1701 * Number of entries in @e children array.
1702 */
1703 unsigned int num_children;
1704
1705 /**
1706 * Depth of the corresponding block in the tree. 0==DBLOCKs.
1707 */
1708 unsigned int depth;
1709
1710 /**
1711 * Offset of the CHK for this block in the parent block
1712 */
1713 unsigned int chk_idx;
1714
1715 /**
1716 * State in the FSM.
1717 */
1718 enum BlockRequestState state;
1719};
1720
1721
1722/**
1723 * (recursively) free download request structure
1724 *
1725 * @param dr request to free
1726 */
1727void
1728GNUNET_FS_free_download_request_ (struct DownloadRequest *dr);
1729
1730
1731/**
1732 * Stop the ping task for this search result.
1733 *
1734 * @param sr result to start pinging for.
1735 */
1736void
1737GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr);
1738
1739
1740/**
1741 * Context for controlling a download.
1742 */
1743struct GNUNET_FS_DownloadContext
1744{
1745 /**
1746 * Global FS context.
1747 */
1748 struct GNUNET_FS_Handle *h;
1749
1750 /**
1751 * Our top-level activity entry (if we are top-level, otherwise NULL).
1752 */
1753 struct TopLevelActivity *top;
1754
1755 /**
1756 * Connection to the FS service.
1757 */
1758 struct GNUNET_MQ_Handle *mq;
1759
1760 /**
1761 * Parent download (used when downloading files
1762 * in directories).
1763 */
1764 struct GNUNET_FS_DownloadContext *parent;
1765
1766 /**
1767 * Associated search (used when downloading files
1768 * based on search results), or NULL for none.
1769 */
1770 struct GNUNET_FS_SearchResult *search;
1771
1772 /**
1773 * Head of list of child downloads.
1774 */
1775 struct GNUNET_FS_DownloadContext *child_head;
1776
1777 /**
1778 * Tail of list of child downloads.
1779 */
1780 struct GNUNET_FS_DownloadContext *child_tail;
1781
1782 /**
1783 * Previous download belonging to the same parent.
1784 */
1785 struct GNUNET_FS_DownloadContext *prev;
1786
1787 /**
1788 * Next download belonging to the same parent.
1789 */
1790 struct GNUNET_FS_DownloadContext *next;
1791
1792 /**
1793 * Context kept for the client.
1794 */
1795 void *client_info;
1796
1797 /**
1798 * URI that identifies the file that we are downloading.
1799 */
1800 struct GNUNET_FS_Uri *uri;
1801
1802 /**
1803 * Known meta-data for the file (can be NULL).
1804 */
1805 struct GNUNET_FS_MetaData *meta;
1806
1807 /**
1808 * Error message, NULL if we're doing OK.
1809 */
1810 char *emsg;
1811
1812 /**
1813 * Random portion of filename we use for syncing state of this
1814 * download.
1815 */
1816 char *serialization;
1817
1818 /**
1819 * Where are we writing the data (name of the
1820 * file, can be NULL!).
1821 */
1822 char *filename;
1823
1824 /**
1825 * Where are we writing the data temporarily (name of the
1826 * file, can be NULL!); used if we do not have a permanent
1827 * name and we are a directory and we do a recursive download.
1828 */
1829 char *temp_filename;
1830
1831 /**
1832 * Our entry in the job queue.
1833 */
1834 struct GNUNET_FS_QueueEntry *job_queue;
1835
1836 /**
1837 * Tree encoder used for the reconstruction.
1838 */
1839 struct GNUNET_FS_TreeEncoder *te;
1840
1841 /**
1842 * File handle for reading data from an existing file
1843 * (to pass to tree encoder).
1844 */
1845 struct GNUNET_DISK_FileHandle *rfh;
1846
1847 /**
1848 * Map of active requests (those waiting for a response). The key
1849 * is the hash of the encryped block (aka query).
1850 */
1851 struct GNUNET_CONTAINER_MultiHashMap *active;
1852
1853 /**
1854 * Top-level download request.
1855 */
1856 struct DownloadRequest *top_request;
1857
1858 /**
1859 * Identity of the peer having the content, or all-zeros
1860 * if we don't know of such a peer.
1861 */
1862 struct GNUNET_PeerIdentity target;
1863
1864 /**
1865 * ID of a task that is using this struct and that must be cancelled
1866 * when the download is being stopped (if not
1867 * NULL). Used for the task that adds some
1868 * artificial delay when trying to reconnect to the FS service or
1869 * the task processing incrementally the data on disk, or the
1870 * task requesting blocks, etc.
1871 */
1872 struct GNUNET_SCHEDULER_Task *task;
1873
1874 /**
1875 * What is the first offset that we're interested
1876 * in?
1877 */
1878 uint64_t offset;
1879
1880 /**
1881 * How many bytes starting from offset are desired?
1882 * This is NOT the overall length of the file!
1883 */
1884 uint64_t length;
1885
1886 /**
1887 * How many bytes have we already received within
1888 * the specified range (DBlocks only).
1889 */
1890 uint64_t completed;
1891
1892 /**
1893 * What was the size of the file on disk that we're downloading
1894 * before we started? Used to detect if there is a point in
1895 * checking an existing block on disk for matching the desired
1896 * content. 0 if the file did not exist already.
1897 */
1898 uint64_t old_file_size;
1899
1900 /**
1901 * Time download was started.
1902 */
1903 struct GNUNET_TIME_Absolute start_time;
1904
1905 /**
1906 * How long to wait before we try to reconnect to FS service?
1907 */
1908 struct GNUNET_TIME_Relative reconnect_backoff;
1909
1910 /**
1911 * Desired level of anonymity.
1912 */
1913 uint32_t anonymity;
1914
1915 /**
1916 * The depth of the file-tree.
1917 */
1918 unsigned int treedepth;
1919
1920 /**
1921 * Options for the download.
1922 */
1923 enum GNUNET_FS_DownloadOptions options;
1924
1925 /**
1926 * Flag set upon transitive completion (includes child downloads).
1927 * This flag is only set to #GNUNET_YES for directories where all
1928 * child-downloads have also completed (and signalled completion).
1929 */
1930 int has_finished;
1931
1932 /**
1933 * Are we ready to issue requests (reconstructions are finished)?
1934 */
1935 int issue_requests;
1936};
1937
1938
1939#endif
1940
1941/* end of fs_api.h */