aboutsummaryrefslogtreecommitdiff
path: root/src/block/plugin_block.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/block/plugin_block.h
parentdd253b7f7591f0869f8ea14ee111b7d3b3e480b6 (diff)
downloadgnunet-a42b4e0ed22b65631caea4bb456f3d8fc21f11b1.tar.gz
gnunet-a42b4e0ed22b65631caea4bb456f3d8fc21f11b1.zip
towards pluggable block library
Diffstat (limited to 'src/block/plugin_block.h')
-rw-r--r--src/block/plugin_block.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/block/plugin_block.h b/src/block/plugin_block.h
new file mode 100644
index 000000000..671f83aad
--- /dev/null
+++ b/src/block/plugin_block.h
@@ -0,0 +1,117 @@
1/*
2 This file is part of GNUnet
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file block/plugin_block.h
23 * @brief API for block plugins. Each block plugin must conform to
24 * the API specified by this header.
25 * @author Christian Grothoff
26 */
27#ifndef PLUGIN_BLOCK_H
28#define PLUGIN_BLOCK_H
29
30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32#include "gnunet_block_lib.h"
33
34
35
36/**
37 * Function called to validate a reply or a request. For
38 * request evaluation, simply pass "NULL" for the reply_block.
39 * Note that it is assumed that the reply has already been
40 * matched to the key (and signatures checked) as it would
41 * be done with the "get_key" function.
42 *
43 * @param cls closure
44 * @param type block type
45 * @param query original query (hash)
46 * @param bf pointer to bloom filter associated with query; possibly updated (!)
47 * @param bf_mutator mutation value for bf
48 * @param xquery extrended query data (can be NULL, depending on type)
49 * @param xquery_size number of bytes in xquery
50 * @param reply_block response to validate
51 * @param reply_block_size number of bytes in reply block
52 * @return characterization of result
53 */
54typedef enum GNUNET_BLOCK_EvaluationResult
55 (*GNUNET_BLOCK_EvaluationFunction) (void *cls,
56 enum GNUNET_BLOCK_Type type,
57 const GNUNET_HashCode *query,
58 struct GNUNET_CONTAINER_BloomFilter **bf,
59 int32_t bf_mutator,
60 const void *xquery,
61 size_t xquery_size,
62 const void *reply_block,
63 size_t reply_block_size);
64
65
66/**
67 * Function called to obtain the key for a block.
68 *
69 * @param cls closure
70 * @param type block type
71 * @param block block to get the key for
72 * @param block_size number of bytes in block
73 * @param key set to the key (query) for the given block
74 * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported
75 * (or if extracting a key from a block of this type does not work)
76 */
77typedef int
78 (*GNUNET_BLOCK_GetKeyFunction) (void *cls,
79 enum GNUNET_BLOCK_Type type,
80 const void *block,
81 size_t block_size,
82 GNUNET_HashCode *key);
83
84
85
86/**
87 * Each plugin is required to return a pointer to a struct of this
88 * type as the return value from its entry point.
89 */
90struct GNUNET_BLOCK_PluginFunctions
91{
92
93 /**
94 * Closure for all of the callbacks.
95 */
96 void *cls;
97
98 /**
99 * 0-terminated array of block types supported by this plugin.
100 */
101 const enum GNUNET_BLOCK_Type *types;
102
103 /**
104 * Main function of a block plugin. Allows us to check if a
105 * block matches a query.
106 */
107 GNUNET_BLOCK_EvaluationFunction evaluate;
108
109 /**
110 * Obtain the key for a given block (if possible).
111 */
112 GNUNET_BLOCK_GetKeyFunction get_key;
113
114};
115
116
117#endif