GNUnet  0.10.x
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 
43 unsigned int
44 GNUNET_FS_compute_depth (uint64_t flen);
45 
46 
56 uint64_t
57 GNUNET_FS_tree_compute_tree_size (unsigned int depth);
58 
59 
71 size_t
72 GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
73  unsigned int depth);
74 
75 
81 
82 
97 typedef void (*GNUNET_FS_TreeBlockProcessor) (void *cls,
98  const struct ContentHashKey * chk,
99  uint64_t offset,
100  unsigned int depth,
101  enum GNUNET_BLOCK_Type type,
102  const void *block,
103  uint16_t block_size);
104 
105 
116 typedef 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 
140 struct GNUNET_FS_TreeEncoder *
146 
147 
156 void
158 
159 
166 struct GNUNET_FS_Uri *
168 
169 
180 void
182  char **emsg);
183 
184 
185 #if 0
186 /* the functions below will be needed for persistence
187  but are not yet implemented -- FIXME... */
196 void
197 GNUNET_FS_tree_encoder_resume_get_data (const struct GNUNET_FS_TreeEncoder *te,
198  void **data, size_t * size);
199 
200 
209 void
210 GNUNET_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 */
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:332
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:157
Context for an ECRS-based file encoder that computes the Merkle-ish-CHK tree.
Definition: fs_tree.c:35
GNUNET_FS_DataReader reader
Function to call to receive input data.
Definition: fs_tree.c:61
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:444
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:270
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
content hash key
Definition: fs.h:53
Master context for most FS operations.
Definition: fs_api.h:1087
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
void * cls
Closure for all callbacks.
Definition: fs_tree.c:46
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
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:223
GNUNET_FS_TreeBlockProcessor proc
Function to call on encrypted blocks.
Definition: fs_tree.c:51
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we&#39;re done with processing.
Definition: fs_tree.c:66
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
Definition: fs_tree.c:126
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:425
size_t(* GNUNET_FS_DataReader)(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data.
shared definitions for the FS library
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:168
GNUNET_FS_TreeProgressCallback progress
Function to call with progress information.
Definition: fs_tree.c:56
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.