2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file fs/fs_download.c
22 * @brief download methods
23 * @author Christian Grothoff
26 * - persistence (can wait)
27 * - location URI suppport (can wait, easy)
28 * - different priority for scheduling probe downloads?
29 * - check if iblocks can be computed from existing blocks (can wait, hard)
32 #include "gnunet_constants.h"
33 #include "gnunet_fs_service.h"
37 #define DEBUG_DOWNLOAD GNUNET_NO
40 * Determine if the given download (options and meta data) should cause
41 * use to try to do a recursive download.
44 is_recursive_download (struct GNUNET_FS_DownloadContext *dc)
46 return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) &&
47 ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
48 ( (dc->meta == NULL) &&
49 ( (NULL == dc->filename) ||
50 ( (strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
52 strstr (dc->filename + strlen(dc->filename) - strlen(GNUNET_FS_DIRECTORY_EXT),
53 GNUNET_FS_DIRECTORY_EXT)) ) ) ) );
58 * We're storing the IBLOCKS after the DBLOCKS on disk (so that we
59 * only have to truncate the file once we're done).
61 * Given the offset of a block (with respect to the DBLOCKS) and its
62 * depth, return the offset where we would store this block in the
65 * @param fsize overall file size
66 * @param off offset of the block in the file
67 * @param depth depth of the block in the tree
68 * @param treedepth maximum depth of the tree
69 * @return off for DBLOCKS (depth == treedepth),
70 * otherwise an offset past the end
71 * of the file that does not overlap
72 * with the range for any other block
75 compute_disk_offset (uint64_t fsize,
78 unsigned int treedepth)
81 uint64_t lsize; /* what is the size of all IBlocks for depth "i"? */
82 uint64_t loff; /* where do IBlocks for depth "i" start? */
83 unsigned int ioff; /* which IBlock corresponds to "off" at depth "i"? */
85 if (depth == treedepth)
87 /* first IBlocks start at the end of file, rounded up
88 to full DBLOCK_SIZE */
89 loff = ((fsize + DBLOCK_SIZE - 1) / DBLOCK_SIZE) * DBLOCK_SIZE;
90 lsize = ( (fsize + DBLOCK_SIZE-1) / DBLOCK_SIZE) * sizeof (struct ContentHashKey);
91 GNUNET_assert (0 == (off % DBLOCK_SIZE));
92 ioff = (off / DBLOCK_SIZE);
93 for (i=treedepth-1;i>depth;i--)
96 lsize = (lsize + CHK_PER_INODE - 1) / CHK_PER_INODE;
97 GNUNET_assert (lsize > 0);
98 GNUNET_assert (0 == (ioff % CHK_PER_INODE));
99 ioff /= CHK_PER_INODE;
101 return loff + ioff * sizeof (struct ContentHashKey);
106 * Given a file of the specified treedepth and a block at the given
107 * offset and depth, calculate the offset for the CHK at the given
110 * @param offset the offset of the first
111 * DBLOCK in the subtree of the
113 * @param depth the depth of the IBLOCK in the tree
114 * @param treedepth overall depth of the tree
115 * @param k which CHK in the IBLOCK are we
117 * @return offset if k=0, otherwise an appropriately
118 * larger value (i.e., if depth = treedepth-1,
119 * the returned value should be offset+DBLOCK_SIZE)
122 compute_dblock_offset (uint64_t offset,
124 unsigned int treedepth,
128 uint64_t lsize; /* what is the size of the sum of all DBlocks
129 that a CHK at depth i corresponds to? */
131 if (depth == treedepth)
134 for (i=treedepth-1;i>depth;i--)
135 lsize *= CHK_PER_INODE;
136 return offset + k * lsize;
141 * Fill in all of the generic fields for a download event and call the
144 * @param pi structure to fill in
145 * @param dc overall download context
148 GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
149 struct GNUNET_FS_DownloadContext *dc)
151 pi->value.download.dc = dc;
152 pi->value.download.cctx
154 pi->value.download.pctx
155 = (dc->parent == NULL) ? NULL : dc->parent->client_info;
156 pi->value.download.sctx
157 = (dc->search == NULL) ? NULL : dc->search->client_info;
158 pi->value.download.uri
160 pi->value.download.filename
162 pi->value.download.size
164 pi->value.download.duration
165 = GNUNET_TIME_absolute_get_duration (dc->start_time);
166 pi->value.download.completed
168 pi->value.download.anonymity
170 pi->value.download.eta
171 = GNUNET_TIME_calculate_eta (dc->start_time,
174 if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
175 dc->client_info = dc->h->upcb (dc->h->upcb_cls,
178 dc->client_info = GNUNET_FS_search_probe_progress_ (NULL,
183 * We're ready to transmit a search request to the
184 * file-sharing service. Do it. If there is
185 * more than one request pending, try to send
186 * multiple or request another transmission.
189 * @param size number of bytes available in buf
190 * @param buf where the callee should write the message
191 * @return number of bytes written to buf
194 transmit_download_request (void *cls,
200 * Closure for iterator processing results.
202 struct ProcessResultClosure
208 GNUNET_HashCode query;
211 * Data found in P2P network.
216 * Our download context.
218 struct GNUNET_FS_DownloadContext *dc;
221 * Number of bytes in data.
228 enum GNUNET_BLOCK_Type type;
231 * Flag to indicate if this block should be stored on disk.
239 * Iterator over entries in the pending requests in the 'active' map for the
240 * reply that we just got.
242 * @param cls closure (our 'struct ProcessResultClosure')
243 * @param key query for the given value / request
244 * @param value value in the hash map (a 'struct DownloadRequest')
245 * @return GNUNET_YES (we should continue to iterate); unless serious error
248 process_result_with_request (void *cls,
249 const GNUNET_HashCode * key,
255 * Schedule the download of the specified block in the tree.
257 * @param dc overall download this block belongs to
258 * @param chk content-hash-key of the block
259 * @param offset offset of the block in the file
260 * (for IBlocks, the offset is the lowest
261 * offset of any DBlock in the subtree under
263 * @param depth depth of the block, 0 is the root of the tree
266 schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
267 const struct ContentHashKey *chk,
271 struct DownloadRequest *sm;
275 char block[DBLOCK_SIZE];
277 struct ProcessResultClosure prc;
278 struct GNUNET_DISK_FileHandle *fh;
281 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
282 "Scheduling download at offset %llu and depth %u for `%s'\n",
283 (unsigned long long) offset,
285 GNUNET_h2s (&chk->query));
287 total = GNUNET_ntohll (dc->uri->data.chk.file_length);
288 off = compute_disk_offset (total,
292 len = GNUNET_FS_tree_calculate_block_size (total,
296 sm = GNUNET_malloc (sizeof (struct DownloadRequest));
300 sm->is_pending = GNUNET_YES;
301 sm->next = dc->pending;
303 GNUNET_CONTAINER_multihashmap_put (dc->active,
306 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
308 if ( (dc->old_file_size > off) &&
309 (dc->filename != NULL) )
311 fh = GNUNET_DISK_file_open (dc->filename,
312 GNUNET_DISK_OPEN_READ,
313 GNUNET_DISK_PERM_NONE);
317 GNUNET_DISK_file_seek (fh,
319 GNUNET_DISK_SEEK_SET) ) &&
321 GNUNET_DISK_file_read (fh,
325 GNUNET_CRYPTO_hash (block, len, &key);
326 if (0 == memcmp (&key,
328 sizeof (GNUNET_HashCode)))
331 struct GNUNET_CRYPTO_AesSessionKey sk;
332 struct GNUNET_CRYPTO_AesInitializationVector iv;
333 GNUNET_HashCode query;
335 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv);
336 GNUNET_CRYPTO_aes_encrypt (block, len,
340 GNUNET_CRYPTO_hash (enc, len, &query);
341 if (0 == memcmp (&query,
343 sizeof (GNUNET_HashCode)))
345 /* already got it! */
349 prc.type = (dc->treedepth == depth)
350 ? GNUNET_BLOCK_TYPE_DBLOCK
351 : GNUNET_BLOCK_TYPE_IBLOCK;
352 prc.query = chk->query;
353 prc.do_store = GNUNET_NO; /* useless */
354 process_result_with_request (&prc,
366 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
367 if (depth < dc->treedepth)
369 // FIXME: try if we could
370 // reconstitute this IBLOCK
371 // from the existing blocks on disk (can wait)
372 // (read block(s), encode, compare with
373 // query; if matches, simply return)
376 if ( (dc->th == NULL) &&
377 (dc->client != NULL) )
378 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client,
379 sizeof (struct SearchMessage),
380 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
382 &transmit_download_request,
389 * Suggest a filename based on given metadata.
391 * @param md given meta data
392 * @return NULL if meta data is useless for suggesting a filename
395 GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData *md)
397 static const char *mimeMap[][2] = {
398 {"application/bz2", ".bz2"},
399 {"application/gnunet-directory", ".gnd"},
400 {"application/java", ".class"},
401 {"application/msword", ".doc"},
402 {"application/ogg", ".ogg"},
403 {"application/pdf", ".pdf"},
404 {"application/pgp-keys", ".key"},
405 {"application/pgp-signature", ".pgp"},
406 {"application/postscript", ".ps"},
407 {"application/rar", ".rar"},
408 {"application/rtf", ".rtf"},
409 {"application/xml", ".xml"},
410 {"application/x-debian-package", ".deb"},
411 {"application/x-dvi", ".dvi"},
412 {"applixation/x-flac", ".flac"},
413 {"applixation/x-gzip", ".gz"},
414 {"application/x-java-archive", ".jar"},
415 {"application/x-java-vm", ".class"},
416 {"application/x-python-code", ".pyc"},
417 {"application/x-redhat-package-manager", ".rpm"},
418 {"application/x-rpm", ".rpm"},
419 {"application/x-tar", ".tar"},
420 {"application/x-tex-pk", ".pk"},
421 {"application/x-texinfo", ".texinfo"},
422 {"application/x-xcf", ".xcf"},
423 {"application/x-xfig", ".xfig"},
424 {"application/zip", ".zip"},
426 {"audio/midi", ".midi"},
427 {"audio/mpeg", ".mp3"},
428 {"audio/real", ".rm"},
429 {"audio/x-wav", ".wav"},
431 {"image/gif", ".gif"},
432 {"image/jpeg", ".jpg"},
433 {"image/pcx", ".pcx"},
434 {"image/png", ".png"},
435 {"image/tiff", ".tiff"},
436 {"image/x-ms-bmp", ".bmp"},
437 {"image/x-xpixmap", ".xpm"},
439 {"text/css", ".css"},
440 {"text/html", ".html"},
441 {"text/plain", ".txt"},
442 {"text/rtf", ".rtf"},
443 {"text/x-c++hdr", ".h++"},
444 {"text/x-c++src", ".c++"},
445 {"text/x-chdr", ".h"},
446 {"text/x-csrc", ".c"},
447 {"text/x-java", ".java"},
448 {"text/x-moc", ".moc"},
449 {"text/x-pascal", ".pas"},
450 {"text/x-perl", ".pl"},
451 {"text/x-python", ".py"},
452 {"text/x-tex", ".tex"},
454 {"video/avi", ".avi"},
455 {"video/mpeg", ".mpeg"},
456 {"video/quicktime", ".qt"},
457 {"video/real", ".rm"},
458 {"video/x-msvideo", ".avi"},
467 ret = GNUNET_CONTAINER_meta_data_get_by_type (md,
468 EXTRACTOR_METATYPE_FILENAME);
472 mime = GNUNET_CONTAINER_meta_data_get_by_type (md,
473 EXTRACTOR_METATYPE_MIMETYPE);
477 while ( (mimeMap[i][0] != NULL) &&
478 (0 != strcmp (mime, mimeMap[i][0])))
480 if (mimeMap[i][1] == NULL)
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG |
482 GNUNET_ERROR_TYPE_BULK,
483 _("Did not find mime type `%s' in extension list.\n"),
489 base = GNUNET_CONTAINER_meta_data_get_first_by_types (md,
490 EXTRACTOR_METATYPE_TITLE,
491 EXTRACTOR_METATYPE_BOOK_TITLE,
492 EXTRACTOR_METATYPE_ORIGINAL_TITLE,
493 EXTRACTOR_METATYPE_PACKAGE_NAME,
494 EXTRACTOR_METATYPE_URL,
495 EXTRACTOR_METATYPE_URI,
496 EXTRACTOR_METATYPE_DESCRIPTION,
497 EXTRACTOR_METATYPE_ISRC,
498 EXTRACTOR_METATYPE_JOURNAL_NAME,
499 EXTRACTOR_METATYPE_AUTHOR_NAME,
500 EXTRACTOR_METATYPE_SUBJECT,
501 EXTRACTOR_METATYPE_ALBUM,
502 EXTRACTOR_METATYPE_ARTIST,
503 EXTRACTOR_METATYPE_KEYWORDS,
504 EXTRACTOR_METATYPE_COMMENT,
505 EXTRACTOR_METATYPE_UNKNOWN,
507 if ( (base == NULL) &&
511 return GNUNET_strdup (ext);
514 GNUNET_asprintf (&ret,
524 * We've lost our connection with the FS service.
525 * Re-establish it and re-transmit all of our
528 * @param dc download context that is having trouble
531 try_reconnect (struct GNUNET_FS_DownloadContext *dc);
535 * We found an entry in a directory. Check if the respective child
536 * already exists and if not create the respective child download.
538 * @param cls the parent download
539 * @param filename name of the file in the directory
540 * @param uri URI of the file (CHK or LOC)
541 * @param meta meta data of the file
542 * @param length number of bytes in data
543 * @param data contents of the file (or NULL if they were not inlined)
546 trigger_recursive_download (void *cls,
547 const char *filename,
548 const struct GNUNET_FS_Uri *uri,
549 const struct GNUNET_CONTAINER_MetaData *meta,
555 * We're done downloading a directory. Open the file and
556 * trigger all of the (remaining) child downloads.
558 * @param dc context of download that just completed
561 full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
566 struct GNUNET_DISK_FileHandle *h;
567 struct GNUNET_DISK_MapHandle *m;
569 size64 = GNUNET_FS_uri_chk_get_file_size (dc->uri);
570 size = (size_t) size64;
571 if (size64 != (uint64_t) size)
573 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
574 _("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
577 if (dc->filename != NULL)
579 h = GNUNET_DISK_file_open (dc->filename,
580 GNUNET_DISK_OPEN_READ,
581 GNUNET_DISK_PERM_NONE);
585 GNUNET_assert (dc->temp_filename != NULL);
586 h = GNUNET_DISK_file_open (dc->temp_filename,
587 GNUNET_DISK_OPEN_READ,
588 GNUNET_DISK_PERM_NONE);
592 data = GNUNET_DISK_file_map (h, &m, GNUNET_DISK_MAP_TYPE_READ, size);
595 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
596 _("Directory too large for system address space\n"));
600 GNUNET_FS_directory_list_contents (size,
603 &trigger_recursive_download,
605 GNUNET_DISK_file_unmap (m);
607 GNUNET_DISK_file_close (h);
608 if (dc->filename == NULL)
610 if (0 != UNLINK (dc->temp_filename))
611 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
614 GNUNET_free (dc->temp_filename);
615 dc->temp_filename = NULL;
621 * Check if all child-downloads have completed and
622 * if so, signal completion (and possibly recurse to
626 check_completed (struct GNUNET_FS_DownloadContext *dc)
628 struct GNUNET_FS_ProgressInfo pi;
629 struct GNUNET_FS_DownloadContext *pos;
631 pos = dc->child_head;
634 if ( (pos->emsg == NULL) &&
635 (pos->completed < pos->length) )
636 return; /* not done yet */
637 if ( (pos->child_head != NULL) &&
638 (pos->has_finished != GNUNET_YES) )
639 return; /* not transitively done yet */
642 dc->has_finished = GNUNET_YES;
643 /* signal completion */
644 pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED;
645 GNUNET_FS_download_make_status_ (&pi, dc);
646 if (dc->parent != NULL)
647 check_completed (dc->parent);
652 * We found an entry in a directory. Check if the respective child
653 * already exists and if not create the respective child download.
655 * @param cls the parent download
656 * @param filename name of the file in the directory
657 * @param uri URI of the file (CHK or LOC)
658 * @param meta meta data of the file
659 * @param length number of bytes in data
660 * @param data contents of the file (or NULL if they were not inlined)
663 trigger_recursive_download (void *cls,
664 const char *filename,
665 const struct GNUNET_FS_Uri *uri,
666 const struct GNUNET_CONTAINER_MetaData *meta,
670 struct GNUNET_FS_DownloadContext *dc = cls;
671 struct GNUNET_FS_DownloadContext *cpos;
672 struct GNUNET_DISK_FileHandle *fh;
674 const char *real_name;
682 return; /* entry for the directory itself */
683 cpos = dc->child_head;
686 if ( (GNUNET_FS_uri_test_equal (uri,
688 ( (filename != NULL) &&
689 (0 == strcmp (cpos->filename,
695 return; /* already exists */
697 if (NULL == filename)
699 fn = GNUNET_FS_meta_data_suggest_filename (meta);
702 us = GNUNET_FS_uri_to_string (uri);
703 fn = GNUNET_strdup (&us [strlen (GNUNET_FS_URI_PREFIX
704 GNUNET_FS_URI_CHK_INFIX)]);
707 else if (fn[0] == '.')
710 us = GNUNET_FS_uri_to_string (uri);
711 GNUNET_asprintf (&fn,
713 &us[strlen (GNUNET_FS_URI_PREFIX
714 GNUNET_FS_URI_CHK_INFIX)], ext);
720 if (dc->filename == NULL)
726 dn = GNUNET_strdup (dc->filename);
727 GNUNET_break ( (strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
729 strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT),
730 GNUNET_FS_DIRECTORY_EXT)) );
731 if ( (strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
733 strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT),
734 GNUNET_FS_DIRECTORY_EXT)) )
735 dn[strlen(dn) - strlen (GNUNET_FS_DIRECTORY_EXT)] = '\0';
736 if ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) &&
737 ( (strlen (filename) < strlen (GNUNET_FS_DIRECTORY_EXT)) ||
739 strstr (filename + strlen(filename) - strlen(GNUNET_FS_DIRECTORY_EXT),
740 GNUNET_FS_DIRECTORY_EXT)) ) )
742 GNUNET_asprintf (&full_name,
747 GNUNET_FS_DIRECTORY_EXT);
751 GNUNET_asprintf (&full_name,
759 if ( (full_name != NULL) &&
761 GNUNET_DISK_directory_create_for_file (full_name)) )
763 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
764 _("Failed to create directory for recursive download of `%s'\n"),
766 GNUNET_free (full_name);
767 GNUNET_free_non_null (fn);
772 if ( (data != NULL) &&
773 (GNUNET_FS_uri_chk_get_file_size (uri) == length) )
775 if (full_name == NULL)
777 temp_name = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
778 real_name = temp_name;
782 real_name = full_name;
784 /* write to disk, then trigger normal download which will instantly progress to completion */
785 fh = GNUNET_DISK_file_open (real_name,
786 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE | GNUNET_DISK_OPEN_CREATE,
787 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
790 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
793 GNUNET_free (full_name);
794 GNUNET_free_non_null (fn);
798 GNUNET_DISK_file_write (fh,
802 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
806 GNUNET_DISK_file_close (fh);
808 GNUNET_FS_download_start (dc->h,
811 full_name, temp_name,
813 GNUNET_FS_uri_chk_get_file_size (uri),
818 GNUNET_free_non_null (full_name);
819 GNUNET_free_non_null (temp_name);
820 GNUNET_free_non_null (fn);
825 * Iterator over entries in the pending requests in the 'active' map for the
826 * reply that we just got.
828 * @param cls closure (our 'struct ProcessResultClosure')
829 * @param key query for the given value / request
830 * @param value value in the hash map (a 'struct DownloadRequest')
831 * @return GNUNET_YES (we should continue to iterate); unless serious error
834 process_result_with_request (void *cls,
835 const GNUNET_HashCode * key,
838 struct ProcessResultClosure *prc = cls;
839 struct DownloadRequest *sm = value;
840 struct DownloadRequest *ppos;
841 struct DownloadRequest *pprev;
842 struct GNUNET_DISK_FileHandle *fh;
843 struct GNUNET_FS_DownloadContext *dc = prc->dc;
844 struct GNUNET_CRYPTO_AesSessionKey skey;
845 struct GNUNET_CRYPTO_AesInitializationVector iv;
847 struct GNUNET_FS_ProgressInfo pi;
852 struct ContentHashKey *chk;
855 bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll (dc->uri->data.chk.file_length),
862 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
863 "Internal error or bogus download URI (expected %u bytes, got %u)\n",
867 dc->emsg = GNUNET_strdup ("Internal error or bogus download URI");
870 GNUNET_assert (GNUNET_YES ==
871 GNUNET_CONTAINER_multihashmap_remove (dc->active,
874 /* if this request is on the pending list, remove it! */
882 dc->pending = ppos->next;
884 pprev->next = ppos->next;
890 GNUNET_CRYPTO_hash_to_aes_key (&sm->chk.key, &skey, &iv);
891 GNUNET_CRYPTO_aes_decrypt (prc->data,
896 off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length),
901 if ( ( GNUNET_YES == prc->do_store) &&
902 ( (dc->filename != NULL) ||
903 (is_recursive_download (dc)) ) &&
904 ( (sm->depth == dc->treedepth) ||
905 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES)) ) )
907 fh = GNUNET_DISK_file_open (dc->filename != NULL
910 GNUNET_DISK_OPEN_READWRITE |
911 GNUNET_DISK_OPEN_CREATE,
912 GNUNET_DISK_PERM_USER_READ |
913 GNUNET_DISK_PERM_USER_WRITE |
914 GNUNET_DISK_PERM_GROUP_READ |
915 GNUNET_DISK_PERM_OTHER_READ);
918 (GNUNET_YES == prc->do_store) &&
919 ( (dc->filename != NULL) ||
920 (is_recursive_download (dc)) ) &&
921 ( (sm->depth == dc->treedepth) ||
922 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES)) ) )
924 GNUNET_asprintf (&dc->emsg,
925 _("Download failed: could not open file `%s': %s\n"),
933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
934 "Saving decrypted block to disk at offset %llu\n",
935 (unsigned long long) off);
938 GNUNET_DISK_file_seek (fh,
940 GNUNET_DISK_SEEK_SET) ) )
942 GNUNET_asprintf (&dc->emsg,
943 _("Failed to seek to offset %llu in file `%s': %s\n"),
944 (unsigned long long) off,
950 GNUNET_DISK_file_write (fh,
954 GNUNET_asprintf (&dc->emsg,
955 _("Failed to write block of %u bytes at offset %llu in file `%s': %s\n"),
956 (unsigned int) prc->size,
957 (unsigned long long) off,
962 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
965 if (sm->depth == dc->treedepth)
968 if (sm->offset < dc->offset)
970 /* starting offset begins in the middle of pt,
971 do not count first bytes as progress */
972 GNUNET_assert (app > (dc->offset - sm->offset));
973 app -= (dc->offset - sm->offset);
975 if (sm->offset + prc->size > dc->offset + dc->length)
977 /* end of block is after relevant range,
978 do not count last bytes as progress */
979 GNUNET_assert (app > (sm->offset + prc->size) - (dc->offset + dc->length));
980 app -= (sm->offset + prc->size) - (dc->offset + dc->length);
982 dc->completed += app;
984 /* do recursive download if option is set and either meta data
985 says it is a directory or if no meta data is given AND filename
986 ends in '.gnd' (top-level case) */
987 if (is_recursive_download (dc))
988 GNUNET_FS_directory_list_contents (prc->size,
991 &trigger_recursive_download,
995 pi.status = GNUNET_FS_STATUS_DOWNLOAD_PROGRESS;
996 pi.value.download.specifics.progress.data = pt;
997 pi.value.download.specifics.progress.offset = sm->offset;
998 pi.value.download.specifics.progress.data_len = prc->size;
999 pi.value.download.specifics.progress.depth = sm->depth;
1000 GNUNET_FS_download_make_status_ (&pi, dc);
1001 GNUNET_assert (dc->completed <= dc->length);
1002 if (dc->completed == dc->length)
1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1006 "Download completed, truncating file to desired length %llu\n",
1007 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.file_length));
1009 /* truncate file to size (since we store IBlocks at the end) */
1010 if (dc->filename != NULL)
1012 if (0 != truncate (dc->filename,
1013 GNUNET_ntohll (dc->uri->data.chk.file_length)))
1014 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
1018 if (dc->job_queue != NULL)
1020 GNUNET_FS_dequeue_ (dc->job_queue);
1021 dc->job_queue = NULL;
1023 if (is_recursive_download (dc))
1024 full_recursive_download (dc);
1025 if (dc->child_head == NULL)
1027 /* signal completion */
1028 pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED;
1029 GNUNET_FS_download_make_status_ (&pi, dc);
1030 if (dc->parent != NULL)
1031 check_completed (dc->parent);
1033 GNUNET_assert (sm->depth == dc->treedepth);
1035 // FIXME: make persistent
1036 if (sm->depth == dc->treedepth)
1042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1043 "Triggering downloads of children (this block was at depth %u and offset %llu)\n",
1045 (unsigned long long) sm->offset);
1047 GNUNET_assert (0 == (prc->size % sizeof(struct ContentHashKey)));
1048 chk = (struct ContentHashKey*) pt;
1049 for (i=(prc->size / sizeof(struct ContentHashKey))-1;i>=0;i--)
1051 off = compute_dblock_offset (sm->offset,
1055 if ( (off + DBLOCK_SIZE >= dc->offset) &&
1056 (off < dc->offset + dc->length) )
1057 schedule_block_download (dc,
1067 GNUNET_DISK_file_close (fh);
1068 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
1069 pi.value.download.specifics.error.message = dc->emsg;
1070 GNUNET_FS_download_make_status_ (&pi, dc);
1071 /* abort all pending requests */
1074 GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
1077 GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
1085 * Process a download result.
1087 * @param dc our download context
1088 * @param type type of the result
1089 * @param data the (encrypted) response
1090 * @param size size of data
1093 process_result (struct GNUNET_FS_DownloadContext *dc,
1094 enum GNUNET_BLOCK_Type type,
1098 struct ProcessResultClosure prc;
1104 prc.do_store = GNUNET_YES;
1105 GNUNET_CRYPTO_hash (data, size, &prc.query);
1107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1108 "Received result for query `%s' from `%s'-service\n",
1109 GNUNET_h2s (&prc.query),
1112 GNUNET_CONTAINER_multihashmap_get_multiple (dc->active,
1114 &process_result_with_request,
1120 * Type of a function to call when we receive a message
1123 * @param cls closure
1124 * @param msg message received, NULL on timeout or fatal error
1127 receive_results (void *cls,
1128 const struct GNUNET_MessageHeader * msg)
1130 struct GNUNET_FS_DownloadContext *dc = cls;
1131 const struct PutMessage *cm;
1134 if ( (NULL == msg) ||
1135 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
1136 (sizeof (struct PutMessage) > ntohs(msg->size)) )
1138 GNUNET_break (msg == NULL);
1142 msize = ntohs(msg->size);
1143 cm = (const struct PutMessage*) msg;
1147 msize - sizeof (struct PutMessage));
1148 if (dc->client == NULL)
1149 return; /* fatal error */
1150 /* continue receiving */
1151 GNUNET_CLIENT_receive (dc->client,
1154 GNUNET_TIME_UNIT_FOREVER_REL);
1160 * We're ready to transmit a search request to the
1161 * file-sharing service. Do it. If there is
1162 * more than one request pending, try to send
1163 * multiple or request another transmission.
1165 * @param cls closure
1166 * @param size number of bytes available in buf
1167 * @param buf where the callee should write the message
1168 * @return number of bytes written to buf
1171 transmit_download_request (void *cls,
1175 struct GNUNET_FS_DownloadContext *dc = cls;
1177 struct SearchMessage *sm;
1185 GNUNET_assert (size >= sizeof (struct SearchMessage));
1188 while ( (dc->pending != NULL) &&
1189 (size > msize + sizeof (struct SearchMessage)) )
1192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1193 "Transmitting download request for `%s' to `%s'-service\n",
1194 GNUNET_h2s (&dc->pending->chk.query),
1197 memset (sm, 0, sizeof (struct SearchMessage));
1198 sm->header.size = htons (sizeof (struct SearchMessage));
1199 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
1200 if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
1201 sm->options = htonl (1);
1203 sm->options = htonl (0);
1204 if (dc->pending->depth == dc->treedepth)
1205 sm->type = htonl (GNUNET_BLOCK_TYPE_DBLOCK);
1207 sm->type = htonl (GNUNET_BLOCK_TYPE_IBLOCK);
1208 sm->anonymity_level = htonl (dc->anonymity);
1209 sm->target = dc->target.hashPubKey;
1210 sm->query = dc->pending->chk.query;
1211 dc->pending->is_pending = GNUNET_NO;
1212 dc->pending = dc->pending->next;
1213 msize += sizeof (struct SearchMessage);
1216 if (dc->pending != NULL)
1217 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client,
1218 sizeof (struct SearchMessage),
1219 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1221 &transmit_download_request,
1228 * Reconnect to the FS service and transmit our queries NOW.
1230 * @param cls our download context
1234 do_reconnect (void *cls,
1235 const struct GNUNET_SCHEDULER_TaskContext *tc)
1237 struct GNUNET_FS_DownloadContext *dc = cls;
1238 struct GNUNET_CLIENT_Connection *client;
1240 dc->task = GNUNET_SCHEDULER_NO_TASK;
1241 client = GNUNET_CLIENT_connect (dc->h->sched,
1246 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1247 "Connecting to `%s'-service failed, will try again.\n",
1252 dc->client = client;
1253 dc->th = GNUNET_CLIENT_notify_transmit_ready (client,
1254 sizeof (struct SearchMessage),
1255 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1257 &transmit_download_request,
1259 GNUNET_CLIENT_receive (client,
1262 GNUNET_TIME_UNIT_FOREVER_REL);
1267 * Add entries that are not yet pending back to the pending list.
1269 * @param cls our download context
1271 * @param entry entry of type "struct DownloadRequest"
1275 retry_entry (void *cls,
1276 const GNUNET_HashCode *key,
1279 struct GNUNET_FS_DownloadContext *dc = cls;
1280 struct DownloadRequest *dr = entry;
1282 if (! dr->is_pending)
1284 dr->next = dc->pending;
1285 dr->is_pending = GNUNET_YES;
1286 dc->pending = entry;
1293 * We've lost our connection with the FS service.
1294 * Re-establish it and re-transmit all of our
1297 * @param dc download context that is having trouble
1300 try_reconnect (struct GNUNET_FS_DownloadContext *dc)
1303 if (NULL != dc->client)
1307 GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
1310 GNUNET_CONTAINER_multihashmap_iterate (dc->active,
1313 GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
1317 = GNUNET_SCHEDULER_add_delayed (dc->h->sched,
1318 GNUNET_TIME_UNIT_SECONDS,
1326 * We're allowed to ask the FS service for our blocks. Start the download.
1328 * @param cls the 'struct GNUNET_FS_DownloadContext'
1329 * @param client handle to use for communcation with FS (we must destroy it!)
1332 activate_fs_download (void *cls,
1333 struct GNUNET_CLIENT_Connection *client)
1335 struct GNUNET_FS_DownloadContext *dc = cls;
1336 struct GNUNET_FS_ProgressInfo pi;
1338 GNUNET_assert (NULL != client);
1339 dc->client = client;
1340 GNUNET_CLIENT_receive (client,
1343 GNUNET_TIME_UNIT_FOREVER_REL);
1344 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ACTIVE;
1345 GNUNET_FS_download_make_status_ (&pi, dc);
1346 GNUNET_CONTAINER_multihashmap_iterate (dc->active,
1349 if ( (dc->th == NULL) &&
1350 (dc->client != NULL) )
1351 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client,
1352 sizeof (struct SearchMessage),
1353 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1355 &transmit_download_request,
1361 * We must stop to ask the FS service for our blocks. Pause the download.
1363 * @param cls the 'struct GNUNET_FS_DownloadContext'
1366 deactivate_fs_download (void *cls)
1368 struct GNUNET_FS_DownloadContext *dc = cls;
1369 struct GNUNET_FS_ProgressInfo pi;
1373 GNUNET_CLIENT_notify_transmit_ready_cancel (dc->th);
1376 if (NULL != dc->client)
1378 GNUNET_CLIENT_disconnect (dc->client, GNUNET_NO);
1381 pi.status = GNUNET_FS_STATUS_DOWNLOAD_INACTIVE;
1382 GNUNET_FS_download_make_status_ (&pi, dc);
1387 * Download parts of a file. Note that this will store
1388 * the blocks at the respective offset in the given file. Also, the
1389 * download is still using the blocking of the underlying FS
1390 * encoding. As a result, the download may *write* outside of the
1391 * given boundaries (if offset and length do not match the 32k FS
1392 * block boundaries). <p>
1394 * This function should be used to focus a download towards a
1395 * particular portion of the file (optimization), not to strictly
1396 * limit the download to exactly those bytes.
1398 * @param h handle to the file sharing subsystem
1399 * @param uri the URI of the file (determines what to download); CHK or LOC URI
1400 * @param meta known metadata for the file (can be NULL)
1401 * @param filename where to store the file, maybe NULL (then no file is
1402 * created on disk and data must be grabbed from the callbacks)
1403 * @param tempname where to store temporary file data, not used if filename is non-NULL;
1404 * can be NULL (in which case we will pick a name if needed); the temporary file
1405 * may already exist, in which case we will try to use the data that is there and
1406 * if it is not what is desired, will overwrite it
1407 * @param offset at what offset should we start the download (typically 0)
1408 * @param length how many bytes should be downloaded starting at offset
1409 * @param anonymity anonymity level to use for the download
1410 * @param options various options
1411 * @param cctx initial value for the client context for this download
1412 * @param parent parent download to associate this download with (use NULL
1413 * for top-level downloads; useful for manually-triggered recursive downloads)
1414 * @return context that can be used to control this download
1416 struct GNUNET_FS_DownloadContext *
1417 GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
1418 const struct GNUNET_FS_Uri *uri,
1419 const struct GNUNET_CONTAINER_MetaData *meta,
1420 const char *filename,
1421 const char *tempname,
1425 enum GNUNET_FS_DownloadOptions options,
1427 struct GNUNET_FS_DownloadContext *parent)
1429 struct GNUNET_FS_ProgressInfo pi;
1430 struct GNUNET_FS_DownloadContext *dc;
1432 GNUNET_assert (GNUNET_FS_uri_test_chk (uri));
1433 if ( (offset + length < offset) ||
1434 (offset + length > uri->data.chk.file_length) )
1440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1441 "Starting download `%s' of %llu bytes\n",
1443 (unsigned long long) length);
1445 dc = GNUNET_malloc (sizeof(struct GNUNET_FS_DownloadContext));
1447 dc->parent = parent;
1450 GNUNET_CONTAINER_DLL_insert (parent->child_head,
1454 dc->uri = GNUNET_FS_uri_dup (uri);
1455 dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
1456 dc->client_info = cctx;
1457 dc->start_time = GNUNET_TIME_absolute_get ();
1458 if (NULL != filename)
1460 dc->filename = GNUNET_strdup (filename);
1461 if (GNUNET_YES == GNUNET_DISK_file_test (filename))
1462 GNUNET_DISK_file_size (filename,
1466 if (GNUNET_FS_uri_test_loc (dc->uri))
1467 GNUNET_assert (GNUNET_OK ==
1468 GNUNET_FS_uri_loc_get_peer_identity (dc->uri,
1470 dc->offset = offset;
1471 dc->length = length;
1472 dc->anonymity = anonymity;
1473 dc->options = options;
1474 dc->active = GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE));
1475 dc->treedepth = GNUNET_FS_compute_depth (GNUNET_ntohll(dc->uri->data.chk.file_length));
1476 if ( (filename == NULL) &&
1477 (is_recursive_download (dc) ) )
1479 if (tempname != NULL)
1480 dc->temp_filename = GNUNET_strdup (tempname);
1482 dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
1486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1487 "Download tree has depth %u\n",
1490 // FIXME: make persistent
1491 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START;
1492 pi.value.download.specifics.start.meta = meta;
1493 GNUNET_FS_download_make_status_ (&pi, dc);
1494 schedule_block_download (dc,
1495 &dc->uri->data.chk.chk,
1497 1 /* 0 == CHK, 1 == top */);
1498 GNUNET_FS_download_start_downloading_ (dc);
1504 * Download parts of a file based on a search result. The download
1505 * will be associated with the search result (and the association
1506 * will be preserved when serializing/deserializing the state).
1507 * If the search is stopped, the download will not be aborted but
1508 * be 'promoted' to a stand-alone download.
1510 * As with the other download function, this will store
1511 * the blocks at the respective offset in the given file. Also, the
1512 * download is still using the blocking of the underlying FS
1513 * encoding. As a result, the download may *write* outside of the
1514 * given boundaries (if offset and length do not match the 32k FS
1515 * block boundaries). <p>
1517 * The given range can be used to focus a download towards a
1518 * particular portion of the file (optimization), not to strictly
1519 * limit the download to exactly those bytes.
1521 * @param h handle to the file sharing subsystem
1522 * @param sr the search result to use for the download (determines uri and
1523 * meta data and associations)
1524 * @param filename where to store the file, maybe NULL (then no file is
1525 * created on disk and data must be grabbed from the callbacks)
1526 * @param tempname where to store temporary file data, not used if filename is non-NULL;
1527 * can be NULL (in which case we will pick a name if needed); the temporary file
1528 * may already exist, in which case we will try to use the data that is there and
1529 * if it is not what is desired, will overwrite it
1530 * @param offset at what offset should we start the download (typically 0)
1531 * @param length how many bytes should be downloaded starting at offset
1532 * @param anonymity anonymity level to use for the download
1533 * @param options various download options
1534 * @param cctx initial value for the client context for this download
1535 * @return context that can be used to control this download
1537 struct GNUNET_FS_DownloadContext *
1538 GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
1539 struct GNUNET_FS_SearchResult *sr,
1540 const char *filename,
1541 const char *tempname,
1545 enum GNUNET_FS_DownloadOptions options,
1548 struct GNUNET_FS_ProgressInfo pi;
1549 struct GNUNET_FS_DownloadContext *dc;
1551 if (sr->download != NULL)
1556 GNUNET_assert (GNUNET_FS_uri_test_chk (sr->uri));
1557 if ( (offset + length < offset) ||
1558 (offset + length > sr->uri->data.chk.file_length) )
1564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1565 "Starting download `%s' of %llu bytes\n",
1567 (unsigned long long) length);
1569 dc = GNUNET_malloc (sizeof(struct GNUNET_FS_DownloadContext));
1573 dc->uri = GNUNET_FS_uri_dup (sr->uri);
1574 dc->meta = GNUNET_CONTAINER_meta_data_duplicate (sr->meta);
1575 dc->client_info = cctx;
1576 dc->start_time = GNUNET_TIME_absolute_get ();
1577 if (NULL != filename)
1579 dc->filename = GNUNET_strdup (filename);
1580 if (GNUNET_YES == GNUNET_DISK_file_test (filename))
1581 GNUNET_DISK_file_size (filename,
1585 if (GNUNET_FS_uri_test_loc (dc->uri))
1586 GNUNET_assert (GNUNET_OK ==
1587 GNUNET_FS_uri_loc_get_peer_identity (dc->uri,
1589 dc->offset = offset;
1590 dc->length = length;
1591 dc->anonymity = anonymity;
1592 dc->options = options;
1593 dc->active = GNUNET_CONTAINER_multihashmap_create (1 + 2 * (length / DBLOCK_SIZE));
1594 dc->treedepth = GNUNET_FS_compute_depth (GNUNET_ntohll(dc->uri->data.chk.file_length));
1595 if ( (filename == NULL) &&
1596 (is_recursive_download (dc) ) )
1598 if (tempname != NULL)
1599 dc->temp_filename = GNUNET_strdup (tempname);
1601 dc->temp_filename = GNUNET_DISK_mktemp ("gnunet-directory-download-tmp");
1605 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1606 "Download tree has depth %u\n",
1609 // FIXME: make persistent
1610 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START;
1611 pi.value.download.specifics.start.meta = dc->meta;
1612 GNUNET_FS_download_make_status_ (&pi, dc);
1613 schedule_block_download (dc,
1614 &dc->uri->data.chk.chk,
1616 1 /* 0 == CHK, 1 == top */);
1617 GNUNET_FS_download_start_downloading_ (dc);
1623 * Start the downloading process (by entering the queue).
1625 * @param dc our download context
1628 GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
1630 dc->job_queue = GNUNET_FS_queue_ (dc->h,
1631 &activate_fs_download,
1632 &deactivate_fs_download,
1634 (dc->length + DBLOCK_SIZE-1) / DBLOCK_SIZE);
1639 * Free entries in the map.
1641 * @param cls unused (NULL)
1643 * @param entry entry of type "struct DownloadRequest" which is freed
1647 free_entry (void *cls,
1648 const GNUNET_HashCode *key,
1651 GNUNET_free (entry);
1657 * Stop a download (aborts if download is incomplete).
1659 * @param dc handle for the download
1660 * @param do_delete delete files of incomplete downloads
1663 GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc,
1666 struct GNUNET_FS_ProgressInfo pi;
1668 if (dc->search != NULL)
1670 dc->search->download = NULL;
1673 if (dc->job_queue != NULL)
1675 GNUNET_FS_dequeue_ (dc->job_queue);
1676 dc->job_queue = NULL;
1678 while (NULL != dc->child_head)
1679 GNUNET_FS_download_stop (dc->child_head,
1681 // FIXME: make unpersistent
1682 if (dc->parent != NULL)
1683 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head,
1684 dc->parent->child_tail,
1687 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
1688 GNUNET_FS_download_make_status_ (&pi, dc);
1689 if (GNUNET_SCHEDULER_NO_TASK != dc->task)
1690 GNUNET_SCHEDULER_cancel (dc->h->sched,
1692 GNUNET_CONTAINER_multihashmap_iterate (dc->active,
1695 GNUNET_CONTAINER_multihashmap_destroy (dc->active);
1696 if (dc->filename != NULL)
1698 if ( (dc->completed != dc->length) &&
1699 (GNUNET_YES == do_delete) )
1701 if (0 != UNLINK (dc->filename))
1702 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
1706 GNUNET_free (dc->filename);
1708 GNUNET_CONTAINER_meta_data_destroy (dc->meta);
1709 GNUNET_FS_uri_destroy (dc->uri);
1710 if (NULL != dc->temp_filename)
1712 if (0 != UNLINK (dc->temp_filename))
1713 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
1716 GNUNET_free (dc->temp_filename);
1718 /* FIXME: clean up serialization file itself! */
1719 GNUNET_free_non_null (dc->serialization);
1723 /* end of fs_download.c */