GNUnet  0.17.5
plugin_block_seti_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 
43 static enum GNUNET_GenericReturnValue
46  const struct GNUNET_HashCode *query,
47  const void *xquery,
48  size_t xquery_size)
49 {
51  {
52  GNUNET_break (0);
53  return GNUNET_SYSERR;
54  }
55  if (0 != xquery_size)
56  {
57  GNUNET_break_op (0);
58  return GNUNET_NO;
59  }
60  return GNUNET_OK;
61 }
62 
63 
73 static enum GNUNET_GenericReturnValue
76  const void *block,
77  size_t block_size)
78 {
79  (void) cls;
81  {
82  GNUNET_break (0);
83  return GNUNET_SYSERR;
84  }
85  if ((NULL == block) ||
86  (0 == block_size) ||
87  (0 != ((char *) block)[0]))
88  return GNUNET_SYSERR;
89  return GNUNET_OK;
90 }
91 
92 
111  enum GNUNET_BLOCK_Type type,
112  struct GNUNET_BLOCK_Group *group,
113  const struct GNUNET_HashCode *query,
114  const void *xquery,
115  size_t xquery_size,
116  const void *reply_block,
117  size_t reply_block_size)
118 {
119  (void) cls;
120  (void) xquery;
121  (void) xquery_size;
123  {
124  GNUNET_break (0);
126  }
127  if ( (NULL == reply_block) ||
128  (0 == reply_block_size) ||
129  (0 != ((char *) reply_block)[0]) )
130  GNUNET_assert (0);
132 }
133 
134 
146 static enum GNUNET_GenericReturnValue
148  enum GNUNET_BLOCK_Type type,
149  const void *block,
150  size_t block_size,
151  struct GNUNET_HashCode *key)
152 {
154  {
155  GNUNET_break (0);
156  return GNUNET_SYSERR;
157  }
158  return GNUNET_NO;
159 }
160 
161 
165 void *
167 {
168  static enum GNUNET_BLOCK_Type types[] = {
170  GNUNET_BLOCK_TYPE_ANY /* end of list */
171  };
172  struct GNUNET_BLOCK_PluginFunctions *api;
173 
179  api->types = types;
180  return api;
181 }
182 
183 
187 void *
189 {
190  struct GNUNET_BLOCK_PluginFunctions *api = cls;
191 
192  GNUNET_free (api);
193  return NULL;
194 }
195 
196 
197 /* end of plugin_block_seti_test.c */
struct GNUNET_HashCode key
The key used in the DHT.
API for block plugins.
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
@ GNUNET_BLOCK_TYPE_SETI_TEST
Block for testing set intersection.
GNUNET_BLOCK_ReplyEvaluationResult
Possible ways for how a block may relate to a query.
@ GNUNET_BLOCK_REPLY_OK_MORE
Valid result, and there may be more.
@ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED
Specified block type not supported by any plugin.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_block(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
Function called to validate a block for storage.
static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_query(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
Function called to validate a query.
void * libgnunet_plugin_block_seti_test_init(void *cls)
Entry point for the plugin.
static enum GNUNET_GenericReturnValue block_plugin_seti_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.
void * libgnunet_plugin_block_seti_test_done(void *cls)
Exit point from the plugin.
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_seti_test_check_reply(void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, 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 to a request.
Block group data.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
GNUNET_BLOCK_QueryEvaluationFunction check_query
Check that a query is well-formed.
GNUNET_BLOCK_BlockEvaluationFunction check_block
Check that a block is well-formed.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
GNUNET_BLOCK_ReplyEvaluationFunction check_reply
Check that a reply block matches a query.
void * cls
Closure for all of the callbacks.
A 512-bit hashcode.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model