aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2021-12-28 23:39:36 +0100
committerChristian Grothoff <grothoff@gnunet.org>2021-12-28 23:39:36 +0100
commit8d8976f00329ec326c4642a113e3767d011c396d (patch)
treef171832a44f2d5c5bb3e04ffd80a65ded1ba29e7 /src/include
parent88fb1d89ed483576a7f02060cd72be7761b2be3a (diff)
downloadgnunet-8d8976f00329ec326c4642a113e3767d011c396d.tar.gz
gnunet-8d8976f00329ec326c4642a113e3767d011c396d.zip
revise block plugin design as per discussion with Martin today (only implemented for GNS)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_block_lib.h38
-rw-r--r--src/include/gnunet_block_plugin.h97
2 files changed, 128 insertions, 7 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 341c7bb5c..50306b003 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -221,6 +221,44 @@ enum GNUNET_BLOCK_EvaluationResult
221 221
222 222
223/** 223/**
224 * Possible ways for how a block may relate to a query.
225 */
226enum GNUNET_BLOCK_ReplyEvaluationResult
227{
228 /**
229 * Valid result, but suppressed because it is a duplicate.
230 */
231 GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0,
232
233 /**
234 * Valid result, and there may be more.
235 */
236 GNUNET_BLOCK_REPLY_OK_MORE = 1,
237
238 /**
239 * Last possible valid result.
240 */
241 GNUNET_BLOCK_REPLY_OK_LAST = 2,
242
243 /**
244 * Specified block type not supported by any plugin.
245 */
246 GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1
247
248 /**
249 * Block does not match query (invalid result)
250 */
251 GNUNET_BLOCK_REPLY_INVALID = -2,
252
253 /**
254 * Block does not match xquery (valid result, not relevant for the request)
255 */
256 GNUNET_BLOCK_REPLY_IRRELEVANT = -3,
257
258};
259
260
261/**
224 * Handle to an initialized block library. 262 * Handle to an initialized block library.
225 */ 263 */
226struct GNUNET_BLOCK_Context; 264struct GNUNET_BLOCK_Context;
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h
index ee237ac03..2c9a3839d 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -48,9 +48,9 @@
48 * @param seen_results_count number of entries in @a seen_results 48 * @param seen_results_count number of entries in @a seen_results
49 */ 49 */
50typedef void 50typedef void
51(*GNUNET_BLOCK_GroupMarkSeenFunction)(struct GNUNET_BLOCK_Group *bg, 51(*GNUNET_BLOCK_GroupMarkSeenFunction)(
52 const struct 52 struct GNUNET_BLOCK_Group *bg,
53 GNUNET_HashCode *seen_results, 53 const struct GNUNET_HashCode *seen_results,
54 unsigned int seen_results_count); 54 unsigned int seen_results_count);
55 55
56 56
@@ -63,7 +63,7 @@ typedef void
63 * @return #GNUNET_OK on success, #GNUNET_NO if the nonces were different and thus 63 * @return #GNUNET_OK on success, #GNUNET_NO if the nonces were different and thus
64 * we failed. 64 * we failed.
65 */ 65 */
66typedef int 66typedef enum GNUNET_GenericReturnValue
67(*GNUNET_BLOCK_GroupMergeFunction)(struct GNUNET_BLOCK_Group *bg1, 67(*GNUNET_BLOCK_GroupMergeFunction)(struct GNUNET_BLOCK_Group *bg1,
68 const struct GNUNET_BLOCK_Group *bg2); 68 const struct GNUNET_BLOCK_Group *bg2);
69 69
@@ -78,7 +78,7 @@ typedef int
78 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not 78 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not
79 * supported, #GNUNET_SYSERR on error 79 * supported, #GNUNET_SYSERR on error
80 */ 80 */
81typedef int 81typedef enum GNUNET_GenericReturnValue
82(*GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg, 82(*GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg,
83 uint32_t *nonce, 83 uint32_t *nonce,
84 void **raw_data, 84 void **raw_data,
@@ -180,6 +180,7 @@ typedef struct GNUNET_BLOCK_Group *
180 * @param reply_block response to validate 180 * @param reply_block response to validate
181 * @param reply_block_size number of bytes in @a reply_block 181 * @param reply_block_size number of bytes in @a reply_block
182 * @return characterization of result 182 * @return characterization of result
183 * @deprecated
183 */ 184 */
184typedef enum GNUNET_BLOCK_EvaluationResult 185typedef enum GNUNET_BLOCK_EvaluationResult
185(*GNUNET_BLOCK_EvaluationFunction)(void *cls, 186(*GNUNET_BLOCK_EvaluationFunction)(void *cls,
@@ -195,19 +196,83 @@ typedef enum GNUNET_BLOCK_EvaluationResult
195 196
196 197
197/** 198/**
199 * Function called to validate a query.
200 *
201 * @param cls closure
202 * @param ctx block context
203 * @param type block type
204 * @param query original query (hash)
205 * @param xquery extrended query data (can be NULL, depending on type)
206 * @param xquery_size number of bytes in @a xquery
207 * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not
208 */
209typedef enum GNUNET_GenericReturnValue
210(*GNUNET_BLOCK_QueryEvaluationFunction)(void *cls,
211 enum GNUNET_BLOCK_Type type,
212 const struct GNUNET_HashCode *query,
213 const void *xquery,
214 size_t xquery_size);
215
216
217/**
218 * Function called to validate a block for storage.
219 *
220 * @param cls closure
221 * @param type block type
222 * @param query key for the block (hash), must match exactly
223 * @param block block data to validate
224 * @param block_size number of bytes in @a block
225 * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
226 */
227typedef enum GNUNET_GenericReturnValue
228(*GNUNET_BLOCK_BlockEvaluationFunction)(void *cls,
229 enum GNUNET_BLOCK_Type type,
230 const struct GNUNET_HashCode *query,
231 const void *block,
232 size_t block_size);
233
234
235/**
236 * Function called to validate a reply to a request. Note that it is assumed
237 * that the reply has already been matched to the key (and signatures checked)
238 * as it would be done with the GetKeyFunction and the
239 * BlockEvaluationFunction.
240 *
241 * @param cls closure
242 * @param type block type
243 * @param group which block group to use for evaluation
244 * @param query original query (hash)
245 * @param xquery extrended query data (can be NULL, depending on type)
246 * @param xquery_size number of bytes in @a xquery
247 * @param reply_block response to validate
248 * @param reply_block_size number of bytes in @a reply_block
249 * @return characterization of result
250 */
251typedef enum GNUNET_BLOCK_ReplyEvaluationResult
252(*GNUNET_BLOCK_ReplyEvaluationFunction)(void *cls,
253 enum GNUNET_BLOCK_Type type,
254 struct GNUNET_BLOCK_Group *group,
255 const struct GNUNET_HashCode *query,
256 const void *xquery,
257 size_t xquery_size,
258 const void *reply_block,
259 size_t reply_block_size);
260
261
262/**
198 * Function called to obtain the key for a block. 263 * Function called to obtain the key for a block.
199 * 264 *
200 * @param cls closure 265 * @param cls closure
201 * @param type block type 266 * @param type block type
202 * @param block block to get the key for 267 * @param block block to get the key for
203 * @param block_size number of bytes in @a block 268 * @param block_size number of bytes in @a block
204 * @param key set to the key (query) for the given block 269 * @param[out] key set to the key (query) for the given block
205 * @return #GNUNET_YES on success, 270 * @return #GNUNET_YES on success,
206 * #GNUNET_NO if the block is malformed 271 * #GNUNET_NO if the block is malformed
207 * #GNUNET_SYSERR if type not supported 272 * #GNUNET_SYSERR if type not supported
208 * (or if extracting a key from a block of this type does not work) 273 * (or if extracting a key from a block of this type does not work)
209 */ 274 */
210typedef int 275typedef enum GNUNET_GenericReturnValue
211(*GNUNET_BLOCK_GetKeyFunction) (void *cls, 276(*GNUNET_BLOCK_GetKeyFunction) (void *cls,
212 enum GNUNET_BLOCK_Type type, 277 enum GNUNET_BLOCK_Type type,
213 const void *block, 278 const void *block,
@@ -234,6 +299,8 @@ struct GNUNET_BLOCK_PluginFunctions
234 /** 299 /**
235 * Main function of a block plugin. Allows us to check if a 300 * Main function of a block plugin. Allows us to check if a
236 * block matches a query. 301 * block matches a query.
302 *
303 * @param deprecated
237 */ 304 */
238 GNUNET_BLOCK_EvaluationFunction evaluate; 305 GNUNET_BLOCK_EvaluationFunction evaluate;
239 306
@@ -247,6 +314,22 @@ struct GNUNET_BLOCK_PluginFunctions
247 * context (i.e. to detect duplicates). 314 * context (i.e. to detect duplicates).
248 */ 315 */
249 GNUNET_BLOCK_GroupCreateFunction create_group; 316 GNUNET_BLOCK_GroupCreateFunction create_group;
317
318 /**
319 * Check that a query is well-formed.
320 */
321 GNUNET_BLOCK_QueryEvaluationFunction check_query;
322
323 /**
324 * Check that a block is well-formed.
325 */
326 GNUNET_BLOCK_BlockEvaluationFunction check_block;
327
328 /**
329 * Check that a reply block matches a query.
330 */
331 GNUNET_BLOCK_ReplyEvaluationFunction check_reply;
332
250}; 333};
251 334
252#endif 335#endif