multicast: removed replay cancellation as responses are limited
[oweals/gnunet.git] / src / include / gnunet_block_plugin.h
1 /*
2      This file is part of GNUnet
3      Copyright (C) 2010,2013 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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file include/gnunet_block_plugin.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  * @defgroup block API to be implemented by applications storing data in the DHT
27  * @{
28  */
29 #ifndef PLUGIN_BLOCK_H
30 #define PLUGIN_BLOCK_H
31
32 #include "gnunet_util_lib.h"
33 #include "gnunet_block_lib.h"
34
35
36 /**
37  * Function called to validate a reply or a request.  For
38  * request evaluation, simply pass "NULL" for the @a 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 eo evaluation options to control evaluation
46  * @param query original query (hash)
47  * @param bf pointer to bloom filter associated with query; possibly updated (!)
48  * @param bf_mutator mutation value for @a bf
49  * @param xquery extrended query data (can be NULL, depending on type)
50  * @param xquery_size number of bytes in @a xquery
51  * @param reply_block response to validate
52  * @param reply_block_size number of bytes in @a reply_block
53  * @return characterization of result
54  */
55 typedef enum GNUNET_BLOCK_EvaluationResult
56 (*GNUNET_BLOCK_EvaluationFunction) (void *cls,
57                                     enum GNUNET_BLOCK_Type type,
58                                     enum GNUNET_BLOCK_EvaluationOptions eo,
59                                     const struct GNUNET_HashCode *query,
60                                     struct GNUNET_CONTAINER_BloomFilter **bf,
61                                     int32_t bf_mutator,
62                                     const void *xquery,
63                                     size_t xquery_size,
64                                     const void *reply_block,
65                                     size_t reply_block_size);
66
67
68 /**
69  * Function called to obtain the key for a block.
70  *
71  * @param cls closure
72  * @param type block type
73  * @param block block to get the key for
74  * @param block_size number of bytes in @a block
75  * @param key set to the key (query) for the given block
76  * @return #GNUNET_YES on success,
77  *         #GNUNET_NO if the block is malformed
78  *         #GNUNET_SYSERR if type not supported
79  *         (or if extracting a key from a block of this type does not work)
80  */
81 typedef int
82 (*GNUNET_BLOCK_GetKeyFunction) (void *cls,
83                                 enum GNUNET_BLOCK_Type type,
84                                 const void *block,
85                                 size_t block_size,
86                                 struct GNUNET_HashCode *key);
87
88
89
90 /**
91  * Each plugin is required to return a pointer to a struct of this
92  * type as the return value from its entry point.
93  */
94 struct GNUNET_BLOCK_PluginFunctions
95 {
96
97   /**
98    * Closure for all of the callbacks.
99    */
100   void *cls;
101
102   /**
103    * 0-terminated array of block types supported by this plugin.
104    */
105   const enum GNUNET_BLOCK_Type *types;
106
107   /**
108    * Main function of a block plugin.  Allows us to check if a
109    * block matches a query.
110    */
111   GNUNET_BLOCK_EvaluationFunction evaluate;
112
113   /**
114    * Obtain the key for a given block (if possible).
115    */
116   GNUNET_BLOCK_GetKeyFunction get_key;
117
118 };
119
120 /** @} */ /* end of group block */
121
122 #endif