diff options
Diffstat (limited to 'src/include/gnunet_block_lib.h')
-rw-r--r-- | src/include/gnunet_block_lib.h | 144 |
1 files changed, 22 insertions, 122 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 5640209a6..515b8256c 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -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, 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 |
@@ -119,6 +119,12 @@ enum GNUNET_BLOCK_Type | |||
119 | GNUNET_BLOCK_TYPE_REVOCATION = 12, | 119 | GNUNET_BLOCK_TYPE_REVOCATION = 12, |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Type of a block that contains a DHT-NG HELLO for a peer (for | ||
123 | * DHT and CADET find-peer operations). | ||
124 | */ | ||
125 | GNUNET_BLOCK_TYPE_DHT_URL_HELLO = 13, | ||
126 | |||
127 | /** | ||
122 | * Block to store a cadet regex state | 128 | * Block to store a cadet regex state |
123 | */ | 129 | */ |
124 | GNUNET_BLOCK_TYPE_REGEX = 22, | 130 | GNUNET_BLOCK_TYPE_REGEX = 22, |
@@ -156,108 +162,35 @@ enum GNUNET_BLOCK_Type | |||
156 | 162 | ||
157 | 163 | ||
158 | /** | 164 | /** |
159 | * Flags that can be set to control the evaluation. | ||
160 | * @deprecated | ||
161 | */ | ||
162 | enum GNUNET_BLOCK_EvaluationOptions | ||
163 | { | ||
164 | /** | ||
165 | * Default behavior. | ||
166 | */ | ||
167 | GNUNET_BLOCK_EO_NONE = 0, | ||
168 | |||
169 | /** | ||
170 | * The block is obtained from the local database, skip cryptographic | ||
171 | * checks. | ||
172 | */ | ||
173 | GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO = 1 | ||
174 | }; | ||
175 | |||
176 | |||
177 | /** | ||
178 | * Possible ways for how a block may relate to a query. | 165 | * Possible ways for how a block may relate to a query. |
179 | * @deprecated | ||
180 | */ | 166 | */ |
181 | enum GNUNET_BLOCK_EvaluationResult | 167 | enum GNUNET_BLOCK_ReplyEvaluationResult |
182 | { | 168 | { |
183 | /** | ||
184 | * Valid result, and there may be more. | ||
185 | */ | ||
186 | GNUNET_BLOCK_EVALUATION_OK_MORE = 0, | ||
187 | 169 | ||
188 | /** | 170 | /** |
189 | * Last possible valid result. | 171 | * Specified block type not supported by any plugin. |
190 | */ | 172 | */ |
191 | GNUNET_BLOCK_EVALUATION_OK_LAST = 1, | 173 | GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1, |
192 | 174 | ||
193 | /** | 175 | /** |
194 | * Valid result, but suppressed because it is a duplicate. | 176 | * Valid result, but suppressed because it is a duplicate. |
195 | */ | 177 | */ |
196 | GNUNET_BLOCK_EVALUATION_OK_DUPLICATE = 2, | 178 | GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0, |
197 | |||
198 | /** | ||
199 | * Block does not match query (invalid result) | ||
200 | */ | ||
201 | GNUNET_BLOCK_EVALUATION_RESULT_INVALID = 3, | ||
202 | 179 | ||
203 | /** | 180 | /** |
204 | * Block does not match xquery (valid result, not relevant for the request) | 181 | * Block does not match xquery (valid result, not relevant for the request) |
205 | */ | 182 | */ |
206 | GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT = 4, | 183 | GNUNET_BLOCK_REPLY_IRRELEVANT = 1, |
207 | |||
208 | /** | ||
209 | * Query is valid, no reply given. | ||
210 | */ | ||
211 | GNUNET_BLOCK_EVALUATION_REQUEST_VALID = 10, | ||
212 | |||
213 | /** | ||
214 | * Query format does not match block type (invalid query). For | ||
215 | * example, xquery not given or xquery_size not appropriate for | ||
216 | * type. | ||
217 | */ | ||
218 | GNUNET_BLOCK_EVALUATION_REQUEST_INVALID = 11, | ||
219 | |||
220 | /** | ||
221 | * Specified block type not supported by this plugin. | ||
222 | */ | ||
223 | GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED = 20 | ||
224 | }; | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Possible ways for how a block may relate to a query. | ||
229 | */ | ||
230 | enum GNUNET_BLOCK_ReplyEvaluationResult | ||
231 | { | ||
232 | /** | ||
233 | * Valid result, but suppressed because it is a duplicate. | ||
234 | */ | ||
235 | GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0, | ||
236 | 184 | ||
237 | /** | 185 | /** |
238 | * Valid result, and there may be more. | 186 | * Valid result, and there may be more. |
239 | */ | 187 | */ |
240 | GNUNET_BLOCK_REPLY_OK_MORE = 1, | 188 | GNUNET_BLOCK_REPLY_OK_MORE = 2, |
241 | 189 | ||
242 | /** | 190 | /** |
243 | * Last possible valid result. | 191 | * Last possible valid result. |
244 | */ | 192 | */ |
245 | GNUNET_BLOCK_REPLY_OK_LAST = 2, | 193 | GNUNET_BLOCK_REPLY_OK_LAST = 3 |
246 | |||
247 | /** | ||
248 | * Specified block type not supported by any plugin. | ||
249 | */ | ||
250 | GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1, | ||
251 | |||
252 | /** | ||
253 | * Block does not match query (invalid result) | ||
254 | */ | ||
255 | GNUNET_BLOCK_REPLY_INVALID = -2, | ||
256 | |||
257 | /** | ||
258 | * Block does not match xquery (valid result, not relevant for the request) | ||
259 | */ | ||
260 | GNUNET_BLOCK_REPLY_IRRELEVANT = -3, | ||
261 | 194 | ||
262 | }; | 195 | }; |
263 | 196 | ||
@@ -356,44 +289,12 @@ GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg); | |||
356 | 289 | ||
357 | 290 | ||
358 | /** | 291 | /** |
359 | * Function called to validate a reply or a request. For | 292 | * Function called to validate if a reply is good for a |
360 | * request evaluation, simply pass "NULL" for the @a reply_block. | 293 | * particular query. |
361 | * Note that it is assumed that the reply has already been | ||
362 | * matched to the key (and signatures checked) as it would | ||
363 | * be done with the #GNUNET_BLOCK_get_key() function. | ||
364 | * | ||
365 | * @param ctx block contxt | ||
366 | * @param type block type | ||
367 | * @param group block group to use for evaluation | ||
368 | * @param eo evaluation options to control evaluation | ||
369 | * @param query original query (hash) | ||
370 | * @param xquery extrended query data (can be NULL, depending on type) | ||
371 | * @param xquery_size number of bytes in @a xquery | ||
372 | * @param reply_block response to validate | ||
373 | * @param reply_block_size number of bytes in @a reply_block | ||
374 | * @return characterization of result | ||
375 | * @deprecated | ||
376 | */ | ||
377 | enum GNUNET_BLOCK_EvaluationResult | ||
378 | GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, | ||
379 | enum GNUNET_BLOCK_Type type, | ||
380 | struct GNUNET_BLOCK_Group *group, | ||
381 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
382 | const struct GNUNET_HashCode *query, | ||
383 | const void *xquery, | ||
384 | size_t xquery_size, | ||
385 | const void *reply_block, | ||
386 | size_t reply_block_size); | ||
387 | |||
388 | |||
389 | /** | ||
390 | * Function called to validate a reply. | ||
391 | * Also checks the query key against the block contents | ||
392 | * as it would be done with the #GNUNET_BLOCK_get_key() function. | ||
393 | * | 294 | * |
394 | * @param ctx block contxt | 295 | * @param ctx block contxt |
395 | * @param type block type | 296 | * @param type block type |
396 | * @param group block group to use for evaluation | 297 | * @param[in,out] group block group to use for evaluation |
397 | * @param query original query (hash) | 298 | * @param query original query (hash) |
398 | * @param xquery extrended query data (can be NULL, depending on type) | 299 | * @param xquery extrended query data (can be NULL, depending on type) |
399 | * @param xquery_size number of bytes in @a xquery | 300 | * @param xquery_size number of bytes in @a xquery |
@@ -436,7 +337,6 @@ GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx, | |||
436 | * | 337 | * |
437 | * @param ctx block contxt | 338 | * @param ctx block contxt |
438 | * @param type block type | 339 | * @param type block type |
439 | * @param query query key (hash) | ||
440 | * @param block payload to put | 340 | * @param block payload to put |
441 | * @param block_size number of bytes in @a block | 341 | * @param block_size number of bytes in @a block |
442 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not, | 342 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not, |
@@ -445,13 +345,14 @@ GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx, | |||
445 | enum GNUNET_GenericReturnValue | 345 | enum GNUNET_GenericReturnValue |
446 | GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx, | 346 | GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx, |
447 | enum GNUNET_BLOCK_Type type, | 347 | enum GNUNET_BLOCK_Type type, |
448 | const struct GNUNET_HashCode *query, | ||
449 | const void *block, | 348 | const void *block, |
450 | size_t block_size); | 349 | size_t block_size); |
451 | 350 | ||
452 | 351 | ||
453 | /** | 352 | /** |
454 | * Function called to obtain the key for a block. | 353 | * Function called to obtain the @a key for a @a block. |
354 | * If the @a block is malformed, the function should | ||
355 | * zero-out @a key and return #GNUNET_OK. | ||
455 | * | 356 | * |
456 | * @param ctx block context | 357 | * @param ctx block context |
457 | * @param type block type | 358 | * @param type block type |
@@ -459,9 +360,8 @@ GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx, | |||
459 | * @param block_size number of bytes in @a block | 360 | * @param block_size number of bytes in @a block |
460 | * @param key set to the key (query) for the given block | 361 | * @param key set to the key (query) for the given block |
461 | * @return #GNUNET_YES on success, | 362 | * @return #GNUNET_YES on success, |
462 | * #GNUNET_NO if the block is malformed | 363 | * #GNUNET_NO if extracting a key from a block of this @a type does not work |
463 | * #GNUNET_SYSERR if type not supported | 364 | * #GNUNET_SYSERR if @a type not supported |
464 | * (or if extracting a key from a block of this type does not work) | ||
465 | */ | 365 | */ |
466 | enum GNUNET_GenericReturnValue | 366 | enum GNUNET_GenericReturnValue |
467 | GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, | 367 | GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, |