2 This file is part of GNUnet
3 Copyright (C) 2017 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file set/plugin_block_set_test.c
23 * @brief set test block, recognizes elements with non-zero first byte as invalid
24 * @author Christian Grothoff
28 #include "gnunet_block_plugin.h"
29 #include "gnunet_block_group_lib.h"
33 * Function called to validate a reply or a request. For
34 * request evaluation, simply pass "NULL" for the reply_block.
37 * @param ctx block context
38 * @param type block type
39 * @param group block group to use
40 * @param eo control flags
41 * @param query original query (hash)
42 * @param xquery extrended query data (can be NULL, depending on type)
43 * @param xquery_size number of bytes in xquery
44 * @param reply_block response to validate
45 * @param reply_block_size number of bytes in reply block
46 * @return characterization of result
48 static enum GNUNET_BLOCK_EvaluationResult
49 block_plugin_set_test_evaluate (void *cls,
50 struct GNUNET_BLOCK_Context *ctx,
51 enum GNUNET_BLOCK_Type type,
52 struct GNUNET_BLOCK_Group *group,
53 enum GNUNET_BLOCK_EvaluationOptions eo,
54 const struct GNUNET_HashCode *query,
57 const void *reply_block,
58 size_t reply_block_size)
60 if ( (NULL == reply_block) ||
61 (reply_block_size == 0) ||
62 (0 != ((char *) reply_block)[0]) )
63 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
64 return GNUNET_BLOCK_EVALUATION_OK_MORE;
69 * Function called to obtain the key for a block.
72 * @param type block type
73 * @param block block to get the key for
74 * @param block_size number of bytes in block
75 * @param key set to the key (query) for the given block
76 * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
77 * (or if extracting a key from a block of this type does not work)
80 block_plugin_set_test_get_key (void *cls,
81 enum GNUNET_BLOCK_Type type,
84 struct GNUNET_HashCode *key)
91 * Entry point for the plugin.
94 libgnunet_plugin_block_set_test_init (void *cls)
96 static enum GNUNET_BLOCK_Type types[] =
98 GNUNET_BLOCK_TYPE_SET_TEST,
99 GNUNET_BLOCK_TYPE_ANY /* end of list */
101 struct GNUNET_BLOCK_PluginFunctions *api;
103 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
104 api->evaluate = &block_plugin_set_test_evaluate;
105 api->get_key = &block_plugin_set_test_get_key;
112 * Exit point from the plugin.
115 libgnunet_plugin_block_set_test_done (void *cls)
117 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
123 /* end of plugin_block_set_test.c */