aboutsummaryrefslogtreecommitdiff
path: root/src/set/plugin_block_set_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/set/plugin_block_set_test.c')
-rw-r--r--src/set/plugin_block_set_test.c167
1 files changed, 0 insertions, 167 deletions
diff --git a/src/set/plugin_block_set_test.c b/src/set/plugin_block_set_test.c
deleted file mode 100644
index cb5cef5ad..000000000
--- a/src/set/plugin_block_set_test.c
+++ /dev/null
@@ -1,167 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2017 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file set/plugin_block_set_test.c
23 * @brief set test block, recognizes elements with non-zero first byte as invalid
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunet_block_plugin.h"
29#include "gnunet_block_group_lib.h"
30
31
32/**
33 * Function called to validate a query.
34 *
35 * @param cls closure
36 * @param type block type
37 * @param query original query (hash)
38 * @param xquery extrended query data (can be NULL, depending on type)
39 * @param xquery_size number of bytes in @a xquery
40 * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not
41 */
42static enum GNUNET_GenericReturnValue
43block_plugin_set_test_check_query (void *cls,
44 enum GNUNET_BLOCK_Type type,
45 const struct GNUNET_HashCode *query,
46 const void *xquery,
47 size_t xquery_size)
48{
49 return GNUNET_OK;
50}
51
52
53/**
54 * Function called to validate a block for storage.
55 *
56 * @param cls closure
57 * @param type block type
58 * @param block block data to validate
59 * @param block_size number of bytes in @a block
60 * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
61 */
62static enum GNUNET_GenericReturnValue
63block_plugin_set_test_check_block (void *cls,
64 enum GNUNET_BLOCK_Type type,
65 const void *block,
66 size_t block_size)
67{
68 if ((NULL == block) ||
69 (0 == block_size) ||
70 (0 != ((char *) block)[0]))
71 return GNUNET_SYSERR;
72 return GNUNET_OK;
73}
74
75
76/**
77 * Function called to validate a reply to a request. Note that it is assumed
78 * that the reply has already been matched to the key (and signatures checked)
79 * as it would be done with the GetKeyFunction and the
80 * BlockEvaluationFunction.
81 *
82 * @param cls closure
83 * @param type block type
84 * @param group which block group to use for evaluation
85 * @param query original query (hash)
86 * @param xquery extrended query data (can be NULL, depending on type)
87 * @param xquery_size number of bytes in @a xquery
88 * @param reply_block response to validate
89 * @param reply_block_size number of bytes in @a reply_block
90 * @return characterization of result
91 */
92static enum GNUNET_BLOCK_ReplyEvaluationResult
93block_plugin_set_test_check_reply (void *cls,
94 enum GNUNET_BLOCK_Type type,
95 struct GNUNET_BLOCK_Group *group,
96 const struct GNUNET_HashCode *query,
97 const void *xquery,
98 size_t xquery_size,
99 const void *reply_block,
100 size_t reply_block_size)
101{
102 if ((NULL == reply_block) ||
103 (0 == reply_block_size) ||
104 (0 != ((char *) reply_block)[0]))
105 GNUNET_assert (0);
106 return GNUNET_BLOCK_REPLY_OK_MORE;
107}
108
109
110/**
111 * Function called to obtain the key for a block.
112 *
113 * @param cls closure
114 * @param type block type
115 * @param block block to get the key for
116 * @param block_size number of bytes in block
117 * @param key set to the key (query) for the given block
118 * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
119 * (or if extracting a key from a block of this type does not work)
120 */
121static enum GNUNET_GenericReturnValue
122block_plugin_set_test_get_key (void *cls,
123 enum GNUNET_BLOCK_Type type,
124 const void *block,
125 size_t block_size,
126 struct GNUNET_HashCode *key)
127{
128 return GNUNET_NO;
129}
130
131
132/**
133 * Entry point for the plugin.
134 */
135void *
136libgnunet_plugin_block_set_test_init (void *cls)
137{
138 static const enum GNUNET_BLOCK_Type types[] = {
139 GNUNET_BLOCK_TYPE_SET_TEST,
140 GNUNET_BLOCK_TYPE_ANY /* end of list */
141 };
142 struct GNUNET_BLOCK_PluginFunctions *api;
143
144 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
145 api->get_key = &block_plugin_set_test_get_key;
146 api->check_query = &block_plugin_set_test_check_query;
147 api->check_block = &block_plugin_set_test_check_block;
148 api->check_reply = &block_plugin_set_test_check_reply;
149 api->types = types;
150 return api;
151}
152
153
154/**
155 * Exit point from the plugin.
156 */
157void *
158libgnunet_plugin_block_set_test_done (void *cls)
159{
160 struct GNUNET_BLOCK_PluginFunctions *api = cls;
161
162 GNUNET_free (api);
163 return NULL;
164}
165
166
167/* end of plugin_block_set_test.c */