GNUnet  0.11.x
plugin_block_set_test.c
Go to the documentation of this file.
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 
27 #include "platform.h"
28 #include "gnunet_block_plugin.h"
29 #include "gnunet_block_group_lib.h"
30 
31 
50  struct GNUNET_BLOCK_Context *ctx,
52  struct GNUNET_BLOCK_Group *group,
54  const struct GNUNET_HashCode *query,
55  const void *xquery,
56  size_t xquery_size,
57  const void *reply_block,
58  size_t reply_block_size)
59 {
60  if ((NULL == reply_block) ||
61  (reply_block_size == 0) ||
62  (0 != ((char *) reply_block)[0]))
65 }
66 
67 
79 static int
82  const void *block,
83  size_t block_size,
84  struct GNUNET_HashCode *key)
85 {
86  return GNUNET_SYSERR;
87 }
88 
89 
93 void *
95 {
96  static enum GNUNET_BLOCK_Type types[] = {
98  GNUNET_BLOCK_TYPE_ANY /* end of list */
99  };
100  struct GNUNET_BLOCK_PluginFunctions *api;
101 
105  api->types = types;
106  return api;
107 }
108 
109 
113 void *
115 {
116  struct GNUNET_BLOCK_PluginFunctions *api = cls;
117 
118  GNUNET_free (api);
119  return NULL;
120 }
121 
122 
123 /* end of plugin_block_set_test.c */
Block does not match query (invalid result)
Handle to an initialized block library.
Definition: block.c:54
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
Any type of block, used as a wildcard when searching.
GNUNET_BLOCK_EvaluationFunction evaluate
Main function of a block plugin.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * libgnunet_plugin_block_set_test_done(void *cls)
Exit point from the plugin.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
A 512-bit hashcode.
Valid result, and there may be more.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
static enum GNUNET_BLOCK_EvaluationResult block_plugin_set_test_evaluate(void *cls, struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size, const void *reply_block, size_t reply_block_size)
Function called to validate a reply or a request.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
Block group data.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * libgnunet_plugin_block_set_test_init(void *cls)
Entry point for the plugin.
Block for testing set/consensus.
void * cls
Closure for all of the callbacks.
GNUNET_BLOCK_EvaluationOptions
Flags that can be set to control the evaluation.
#define GNUNET_free(ptr)
Wrapper around free.
static int block_plugin_set_test_get_key(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.