127 unsigned int treeDepth;
162 for (i = 0; i < depth; i++)
192 mod = end_offset % bds;
224 if ((offset +
ret > fsize) || (offset +
ret < offset))
225 ret = (size_t) (fsize - offset);
231 if ((epos < offset) || (epos > fsize))
234 chks = (epos - offset + rsize - 1) / rsize;
280 "Created tree encoder for file with %llu bytes and depth %u\n",
281 (
unsigned long long)
size,
307 ret = end_offset / bds;
323 const void *pt_block;
368 "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n",
370 (
unsigned int) pt_size, (
unsigned int) off);
377 "TE calculates query to be `%s', stored at %u\n",
380 if (NULL != te->
proc)
437 (void) te->
reader (te->
cls, UINT64_MAX, 0, 0, NULL);
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
#define CHK_PER_INODE
Pick a multiple of 2 here to achieve 8-byte alignment! We also probably want DBlocks to have (roughly...
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
struct GNUNET_FS_Uri * GNUNET_FS_tree_encoder_get_uri(struct GNUNET_FS_TreeEncoder *te)
Get the resulting URI from the encoding.
static unsigned int compute_chk_offset(unsigned int depth, uint64_t end_offset)
Compute the offset of the CHK for the current block in the IBlock above.
uint64_t GNUNET_FS_tree_compute_tree_size(unsigned int depth)
Calculate how many bytes of payload a block tree of the given depth MAY correspond to at most (this f...
size_t GNUNET_FS_tree_calculate_block_size(uint64_t fsize, uint64_t offset, unsigned int depth)
Compute how many bytes of data should be stored in the specified block.
static uint16_t GNUNET_FS_tree_compute_iblock_size(unsigned int depth, uint64_t end_offset)
Compute the size of the current IBLOCK.
Merkle-tree-ish-CHK file encoding for GNUnet.
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.
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.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
static OpusEncoder * enc
OPUS encoder.
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
size_t(* GNUNET_FS_DataReader)(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function that provides data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
#define GNUNET_log(kind,...)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
static unsigned int size
Size of the "table".
@ GNUNET_BLOCK_TYPE_FS_DBLOCK
Data block (leaf) in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_IBLOCK
Inner block in the CHK tree.
struct GNUNET_HashCode key
Hash of the original content, used for encryption.
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
uint64_t file_length
Total size of the file in bytes.
Master context for most FS operations.
Context for an ECRS-based file encoder that computes the Merkle-ish-CHK tree.
GNUNET_FS_TreeProgressCallback progress
Function to call with progress information.
void * cls
Closure for all callbacks.
GNUNET_FS_TreeBlockProcessor proc
Function to call on encrypted blocks.
struct ContentHashKey * chk_tree
In-memory cache of the current CHK tree.
GNUNET_FS_DataReader reader
Function to call to receive input data.
char * emsg
Set to an error message (if we had an error).
struct GNUNET_FS_Uri * uri
Set to the URI (upon successful completion)
unsigned int chk_tree_depth
How deep is the tree? Always > 0.
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we're done with processing.
uint64_t size
Overall file size.
int in_next
Are we currently in 'GNUNET_FS_tree_encoder_next'? Flag used to prevent recursion.
struct GNUNET_FS_Handle * h
Global FS context.
uint64_t publish_offset
How far are we?
unsigned int current_depth
How deep are we? Depth 0 is for the DBLOCKs.
A Universal Resource Identifier (URI), opaque.
union GNUNET_FS_Uri::@49 data
enum GNUNET_FS_UriType type
Type of the URI.
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).