GNUnet 0.22.2
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"
30
31
45 const struct GNUNET_HashCode *query,
46 const void *xquery,
47 size_t xquery_size)
48{
49 return GNUNET_OK;
50}
51
52
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
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);
107}
108
109
124 const void *block,
125 size_t block_size,
126 struct GNUNET_HashCode *key)
127{
128 return GNUNET_NO;
129}
130
131void *
133
137void *
139{
140 static const enum GNUNET_BLOCK_Type types[] = {
142 GNUNET_BLOCK_TYPE_ANY /* end of list */
143 };
145
151 api->types = types;
152 return api;
153}
154
155void *
157
161void *
163{
164 struct GNUNET_BLOCK_PluginFunctions *api = cls;
165
166 GNUNET_free (api);
167 return NULL;
168}
169
170
171/* end of plugin_block_set_test.c */
struct GNUNET_HashCode key
The key used in the DHT.
static uint32_t type
Type string converted to DNS type value.
API for block plugins.
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_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#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_set_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.
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_set_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.
void * libgnunet_plugin_block_set_test_init(void *cls)
Entry point for the plugin.
void * libgnunet_plugin_block_set_test_done(void *cls)
Exit point from the plugin.
static enum GNUNET_GenericReturnValue block_plugin_set_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_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.
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_SET_TEST
Block for testing set/consensus.
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.