aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_block_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-09-12 13:08:54 +0000
committerChristian Grothoff <christian@grothoff.org>2010-09-12 13:08:54 +0000
commita42b4e0ed22b65631caea4bb456f3d8fc21f11b1 (patch)
treea3a1e30a7f8e7f8b30c75c96923249831a7e8b2e /src/include/gnunet_block_lib.h
parentdd253b7f7591f0869f8ea14ee111b7d3b3e480b6 (diff)
downloadgnunet-a42b4e0ed22b65631caea4bb456f3d8fc21f11b1.tar.gz
gnunet-a42b4e0ed22b65631caea4bb456f3d8fc21f11b1.zip
towards pluggable block library
Diffstat (limited to 'src/include/gnunet_block_lib.h')
-rw-r--r--src/include/gnunet_block_lib.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 0bd9848d7..ace4f23bb 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -35,6 +35,7 @@ extern "C"
35#endif 35#endif
36#endif 36#endif
37 37
38
38/** 39/**
39 * Blocks in the datastore and the datacache must have a unique type. 40 * Blocks in the datastore and the datacache must have a unique type.
40 */ 41 */
@@ -82,6 +83,8 @@ enum GNUNET_BLOCK_Type
82 }; 83 };
83 84
84 85
86/* **************** FIXME: move these to block_fs.h or so ***************** */
87
85/** 88/**
86 * @brief keyword block (advertising data under a keyword) 89 * @brief keyword block (advertising data under a keyword)
87 */ 90 */
@@ -216,6 +219,8 @@ struct OnDemandBlock
216}; 219};
217 220
218 221
222/* **************** OLD API ***************** */
223
219/** 224/**
220 * Check if the given block is well-formed (and of the given type). 225 * Check if the given block is well-formed (and of the given type).
221 * 226 *
@@ -234,6 +239,126 @@ GNUNET_BLOCK_check_block (enum GNUNET_BLOCK_Type type,
234 GNUNET_HashCode *query); 239 GNUNET_HashCode *query);
235 240
236 241
242/* **************** NEW API ***************** */
243
244/**
245 * Possible ways for how a block may relate to a query.
246 */
247enum GNUNET_BLOCK_EvaluationResult
248 {
249 /**
250 * Valid result, and there may be more.
251 */
252 GNUNET_BLOCK_EVALUATION_OK_MORE = 0,
253
254 /**
255 * Last possible valid result.
256 */
257 GNUNET_BLOCK_EVALUATION_OK_LAST = 1,
258
259 /**
260 * Valid result, but suppressed because it is a duplicate.
261 */
262 GNUNET_BLOCK_EVALUATION_OK_DUPLICATE = 2,
263
264 /**
265 * Block does not match query (invalid result)
266 */
267 GNUNET_BLOCK_EVALUATION_RESULT_INVALID = 3,
268
269 /**
270 * Query is valid, no reply given.
271 */
272 GNUNET_BLOCK_EVALUATION_REQUEST_VALID = 4,
273
274 /**
275 * Query format does not match block type (invalid query). For
276 * example, xquery not given or xquery_size not appropriate for
277 * type.
278 */
279 GNUNET_BLOCK_EVALUATION_REQUEST_INVALID = 5,
280
281 /**
282 * Specified block type not supported by this plugin.
283 */
284 GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED = 6
285 };
286
287
288/**
289 * Handle to an initialized block library.
290 */
291struct GNUNET_BLOCK_Context;
292
293
294/**
295 * Create a block context. Loads the block plugins.
296 *
297 * @param cfg configuration to use
298 * @return NULL on error
299 */
300struct GNUNET_BLOCK_Context *
301GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg);
302
303
304/**
305 * Destroy the block context.
306 *
307 * @param ctx context to destroy
308 */
309void
310GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx);
311
312
313/**
314 * Function called to validate a reply or a request. For
315 * request evaluation, simply pass "NULL" for the reply_block.
316 * Note that it is assumed that the reply has already been
317 * matched to the key (and signatures checked) as it would
318 * be done with the "get_key" function.
319 *
320 * @param ctx block contxt
321 * @param type block type
322 * @param query original query (hash)
323 * @param bf pointer to bloom filter associated with query; possibly updated (!)
324 * @param bf_mutator mutation value for bf
325 * @param xquery extrended query data (can be NULL, depending on type)
326 * @param xquery_size number of bytes in xquery
327 * @param reply_block response to validate
328 * @param reply_block_size number of bytes in reply block
329 * @return characterization of result
330 */
331enum GNUNET_BLOCK_EvaluationResult
332GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
333 enum GNUNET_BLOCK_Type type,
334 const GNUNET_HashCode *query,
335 struct GNUNET_CONTAINER_BloomFilter **bf,
336 int32_t bf_mutator,
337 const void *xquery,
338 size_t xquery_size,
339 const void *reply_block,
340 size_t reply_block_size);
341
342
343/**
344 * Function called to obtain the key for a block.
345 *
346 * @param ctx block context
347 * @param type block type
348 * @param block block to get the key for
349 * @param block_size number of bytes in block
350 * @param key set to the key (query) for the given block
351 * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported
352 * (or if extracting a key from a block of this type does not work)
353 */
354int
355GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
356 enum GNUNET_BLOCK_Type type,
357 const void *block,
358 size_t block_size,
359 GNUNET_HashCode *key);
360
361
237#if 0 /* keep Emacsens' auto-indent happy */ 362#if 0 /* keep Emacsens' auto-indent happy */
238{ 363{
239#endif 364#endif