diff options
Diffstat (limited to 'src/block/plugin_block_template.c')
-rw-r--r-- | src/block/plugin_block_template.c | 82 |
1 files changed, 18 insertions, 64 deletions
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 13d9adfda..dcaf1afaa 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2010 GNUnet e.V. | 3 | Copyright (C) 2010, 2021, 2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -92,49 +92,6 @@ block_plugin_template_create_group (void *cls, | |||
92 | 92 | ||
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Function called to validate a reply or a request. For | ||
96 | * request evaluation, simply pass "NULL" for the reply_block. | ||
97 | * | ||
98 | * @param cls closure | ||
99 | * @param ctx context | ||
100 | * @param type block type | ||
101 | * @param group block group to use | ||
102 | * @param eo control flags | ||
103 | * @param query original query (hash) | ||
104 | * @param xquery extrended query data (can be NULL, depending on type) | ||
105 | * @param xquery_size number of bytes in xquery | ||
106 | * @param reply_block response to validate | ||
107 | * @param reply_block_size number of bytes in reply block | ||
108 | * @return characterization of result | ||
109 | */ | ||
110 | static enum GNUNET_BLOCK_EvaluationResult | ||
111 | block_plugin_template_evaluate (void *cls, | ||
112 | struct GNUNET_BLOCK_Context *ctx, | ||
113 | enum GNUNET_BLOCK_Type type, | ||
114 | struct GNUNET_BLOCK_Group *group, | ||
115 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
116 | const struct GNUNET_HashCode *query, | ||
117 | const void *xquery, | ||
118 | size_t xquery_size, | ||
119 | const void *reply_block, | ||
120 | size_t reply_block_size) | ||
121 | { | ||
122 | struct GNUNET_HashCode chash; | ||
123 | |||
124 | if (NULL == reply_block) | ||
125 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
126 | GNUNET_CRYPTO_hash (reply_block, | ||
127 | reply_block_size, | ||
128 | &chash); | ||
129 | if (GNUNET_YES == | ||
130 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | ||
131 | &chash)) | ||
132 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
133 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
134 | } | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Function called to validate a query. | 95 | * Function called to validate a query. |
139 | * | 96 | * |
140 | * @param cls closure | 97 | * @param cls closure |
@@ -143,16 +100,16 @@ block_plugin_template_evaluate (void *cls, | |||
143 | * @param query original query (hash) | 100 | * @param query original query (hash) |
144 | * @param xquery extrended query data (can be NULL, depending on type) | 101 | * @param xquery extrended query data (can be NULL, depending on type) |
145 | * @param xquery_size number of bytes in @a xquery | 102 | * @param xquery_size number of bytes in @a xquery |
146 | * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not | 103 | * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not, #GNUNET_SYSERR if not supported |
147 | */ | 104 | */ |
148 | static enum GNUNET_GenericReturnValue | 105 | static enum GNUNET_GenericReturnValue |
149 | block_plugin_template_check_query (void *cls, | 106 | block_plugin_template_check_query (void *cls, |
150 | enum GNUNET_BLOCK_Type type, | 107 | enum GNUNET_BLOCK_Type type, |
151 | const struct GNUNET_HashCode *query, | 108 | const struct GNUNET_HashCode *query, |
152 | const void *xquery, | 109 | const void *xquery, |
153 | size_t xquery_size) | 110 | size_t xquery_size) |
154 | { | 111 | { |
155 | return GNUNET_OK; | 112 | return GNUNET_SYSERR; |
156 | } | 113 | } |
157 | 114 | ||
158 | 115 | ||
@@ -161,19 +118,17 @@ block_plugin_template_check_query (void *cls, | |||
161 | * | 118 | * |
162 | * @param cls closure | 119 | * @param cls closure |
163 | * @param type block type | 120 | * @param type block type |
164 | * @param query key for the block (hash), must match exactly | ||
165 | * @param block block data to validate | 121 | * @param block block data to validate |
166 | * @param block_size number of bytes in @a block | 122 | * @param block_size number of bytes in @a block |
167 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | 123 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not, #GNUNET_SYSERR if not supported |
168 | */ | 124 | */ |
169 | static enum GNUNET_GenericReturnValue | 125 | static enum GNUNET_GenericReturnValue |
170 | block_plugin_template_check_block (void *cls, | 126 | block_plugin_template_check_block (void *cls, |
171 | enum GNUNET_BLOCK_Type type, | 127 | enum GNUNET_BLOCK_Type type, |
172 | const struct GNUNET_HashCode *query, | ||
173 | const void *block, | 128 | const void *block, |
174 | size_t block_size) | 129 | size_t block_size) |
175 | { | 130 | { |
176 | return GNUNET_OK; | 131 | return GNUNET_SYSERR; |
177 | } | 132 | } |
178 | 133 | ||
179 | 134 | ||
@@ -195,16 +150,16 @@ block_plugin_template_check_block (void *cls, | |||
195 | */ | 150 | */ |
196 | static enum GNUNET_BLOCK_ReplyEvaluationResult | 151 | static enum GNUNET_BLOCK_ReplyEvaluationResult |
197 | block_plugin_template_check_reply ( | 152 | block_plugin_template_check_reply ( |
198 | void *cls, | 153 | void *cls, |
199 | enum GNUNET_BLOCK_Type type, | 154 | enum GNUNET_BLOCK_Type type, |
200 | struct GNUNET_BLOCK_Group *group, | 155 | struct GNUNET_BLOCK_Group *group, |
201 | const struct GNUNET_HashCode *query, | 156 | const struct GNUNET_HashCode *query, |
202 | const void *xquery, | 157 | const void *xquery, |
203 | size_t xquery_size, | 158 | size_t xquery_size, |
204 | const void *reply_block, | 159 | const void *reply_block, |
205 | size_t reply_block_size) | 160 | size_t reply_block_size) |
206 | { | 161 | { |
207 | return GNUNET_BLOCK_REPLY_OK_MORE; | 162 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; |
208 | } | 163 | } |
209 | 164 | ||
210 | 165 | ||
@@ -245,7 +200,6 @@ libgnunet_plugin_block_template_init (void *cls) | |||
245 | struct GNUNET_BLOCK_PluginFunctions *api; | 200 | struct GNUNET_BLOCK_PluginFunctions *api; |
246 | 201 | ||
247 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 202 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
248 | api->evaluate = &block_plugin_template_evaluate; | ||
249 | api->get_key = &block_plugin_template_get_key; | 203 | api->get_key = &block_plugin_template_get_key; |
250 | api->check_query = &block_plugin_template_check_query; | 204 | api->check_query = &block_plugin_template_check_query; |
251 | api->check_block = &block_plugin_template_check_block; | 205 | api->check_block = &block_plugin_template_check_block; |