GNUnet 0.21.1
fs_tree.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 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
32#ifndef GNUNET_FS_TREE_H
33#define GNUNET_FS_TREE_H
34
35#include "fs_api.h"
36
43unsigned int
44GNUNET_FS_compute_depth (uint64_t flen);
45
46
56uint64_t
57GNUNET_FS_tree_compute_tree_size (unsigned int depth);
58
59
71size_t
72GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
73 unsigned int depth);
74
75
81
82
97typedef void (*GNUNET_FS_TreeBlockProcessor) (void *cls,
98 const struct ContentHashKey *chk,
99 uint64_t offset,
100 unsigned int depth,
102 const void *block,
103 uint16_t block_size);
104
105
116typedef void (*GNUNET_FS_TreeProgressCallback) (void *cls, uint64_t offset,
117 const void *pt_block,
118 size_t pt_size,
119 unsigned int depth);
120
121
146
147
156void
158
159
166struct GNUNET_FS_Uri *
168
169
180void
182 char **emsg);
183
184
185#if 0
186/* the functions below will be needed for persistence
187 but are not yet implemented -- FIXME... */
196void
197GNUNET_FS_tree_encoder_resume_get_data (const struct GNUNET_FS_TreeEncoder *te,
198 void **data, size_t *size);
199
200
209void
210GNUNET_FS_tree_encoder_resume (struct GNUNET_FS_TreeEncoder *te,
211 const void *data, size_t size);
212
213#endif
214
215#endif
216
217/* end of fs_tree.h */
shared definitions for the FS library
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...
Definition: fs_tree.c:320
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
Definition: fs_tree.c:125
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:432
void(* GNUNET_FS_TreeProgressCallback)(void *cls, uint64_t offset, const void *pt_block, size_t pt_size, unsigned int depth)
Function called with information about our progress in computing the tree encoding.
Definition: fs_tree.h:116
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.
Definition: fs_tree.c:258
struct GNUNET_FS_Uri * GNUNET_FS_tree_encoder_get_uri(struct GNUNET_FS_TreeEncoder *te)
Get the resulting URI from the encoding.
Definition: fs_tree.c:413
void(* GNUNET_FS_TreeBlockProcessor)(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.
Definition: fs_tree.h:97
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...
Definition: fs_tree.c:156
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.
Definition: fs_tree.c:211
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static char * data
The data to insert into the dht.
static uint32_t type
Type string converted to DNS type value.
size_t(* GNUNET_FS_DataReader)(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
static unsigned int size
Size of the "table".
Definition: peer.c:68
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
content hash key
Definition: fs.h:55
Master context for most FS operations.
Definition: fs_api.h:1070
Context for an ECRS-based file encoder that computes the Merkle-ish-CHK tree.
Definition: fs_tree.c:36
GNUNET_FS_TreeProgressCallback progress
Function to call with progress information.
Definition: fs_tree.c:55
void * cls
Closure for all callbacks.
Definition: fs_tree.c:45
GNUNET_FS_TreeBlockProcessor proc
Function to call on encrypted blocks.
Definition: fs_tree.c:50
GNUNET_FS_DataReader reader
Function to call to receive input data.
Definition: fs_tree.c:60
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we're done with processing.
Definition: fs_tree.c:65
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167