From 7205436569d1b1e0f10485dbdec087f19de865f8 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 28 Dec 2021 22:39:30 +0100 Subject: -lsd0004 draft block API --- src/include/gnunet_block_lib.h | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 73b51252e..341c7bb5c 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h @@ -342,6 +342,93 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, const void *reply_block, size_t reply_block_size); +/** + * WORK IN PROGRESS LSD0004 + */ + +/** + * Function called to validate a reply. + * Also checks the query key against the block contents + * as it would be done with the #GNUNET_BLOCK_get_key() function. + * + * @param ctx block contxt + * @param type block type + * @param group block group to use for evaluation + * @param query original query (hash) + * @param reply_block response to validate + * @param reply_block_size number of bytes in @a reply_block + * @return characterization of result + */ +enum GNUNET_BLOCK_ReplyEvaluationResult +GNUNET_BLOCK_evaluate_reply (struct GNUNET_BLOCK_Context *ctx, + enum GNUNET_BLOCK_Type type, + struct GNUNET_BLOCK_Group *group, + const struct GNUNET_HashCode *query, + const void *reply_block, + size_t reply_block_size); + + + +/** + * Function called to validate a request. + * + * @param ctx block contxt + * @param type block type + * @param eo evaluation options to control evaluation + * @param query original query (hash) + * @param xquery extrended query data (can be NULL, depending on type) + * @param xquery_size number of bytes in @a xquery + * @return characterization of result + */ +enum GNUNET_BLOCK_RequestEvaluationResult +GNUNET_BLOCK_evaluate_get_request (struct GNUNET_BLOCK_Context *ctx, + enum GNUNET_BLOCK_Type type, + const struct GNUNET_HashCode *query, + const void *xquery, + size_t xquery_size); + +/** + * Function called to validate a request. + * + * @param ctx block contxt + * @param type block type + * @param query query key (hash) + * @param block payload to put + * @param block_size number of bytes in @a block + * @return characterization of result + */ +enum GNUNET_BLOCK_RequestEvaluationResult +GNUNET_BLOCK_evaluate_put_request (struct GNUNET_BLOCK_Context *ctx, + enum GNUNET_BLOCK_Type type, + const struct GNUNET_HashCode *query, + const void *block, + size_t block_size); + +/** + * Function called to obtain the key for a block. + * + * @param ctx block context + * @param type block type + * @param key the key to validate @a block against. + * @param block block to validate @a key against. + * @param block_size number of bytes in @a block + * @return #GNUNET_YES if key is valid, + * #GNUNET_NO if the key is invalid for this block, + * #GNUNET_SYSERR if type not supported + * (or if extracting a key from a block of this type does not work) + */ +enum GNUNET_GenericReturnValue +GNUNET_BLOCK_validate_key (struct GNUNET_BLOCK_Context *ctx, + enum GNUNET_BLOCK_Type type, + const struct GNUNET_HashCode *key, + const void *block, + size_t block_size); + + + +/** + * END LSD0004 + */ /** * Function called to obtain the key for a block. -- cgit v1.2.3