2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file mesh/plugin_block_mesh.c
23 * @brief blocks used for mesh peer discovery
24 * @author Bartlomiej Polot
28 #include "gnunet_block_plugin.h"
30 #define DEBUG_MESH_BLOCK GNUNET_EXTRA_LOGGING
33 * Function called to validate a reply or a request. For
34 * request evaluation, simply pass "NULL" for the reply_block.
35 * Note that it is assumed that the reply has already been
36 * matched to the key (and signatures checked) as it would
37 * be done with the "get_key" function.
40 * @param type block type
41 * @param query original query (hash)
42 * @param bf pointer to bloom filter associated with query; possibly updated (!)
43 * @param bf_mutator mutation value for bf
44 * @param xquery extrended query data (can be NULL, depending on type)
45 * @param xquery_size number of bytes in xquery
46 * @param reply_block response to validate
47 * @param reply_block_size number of bytes in reply block
48 * @return characterization of result
50 static enum GNUNET_BLOCK_EvaluationResult
51 block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
52 const struct GNUNET_HashCode * query,
53 struct GNUNET_CONTAINER_BloomFilter **bf,
54 int32_t bf_mutator, const void *xquery,
55 size_t xquery_size, const void *reply_block,
56 size_t reply_block_size)
58 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Evaluate called\n");
59 if (GNUNET_BLOCK_TYPE_MESH_PEER == type)
61 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Type MESH PEER\n");
65 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Other type\n");
67 return GNUNET_BLOCK_EVALUATION_OK_LAST;
72 * Function called to obtain the key for a block.
75 * @param type block type
76 * @param block block to get the key for
77 * @param block_size number of bytes in block
78 * @param key set to the key (query) for the given block
79 * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported
80 * (or if extracting a key from a block of this type does not work)
83 block_plugin_mesh_get_key (void *cls, enum GNUNET_BLOCK_Type type,
84 const void *block, size_t block_size,
85 struct GNUNET_HashCode * key)
87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get key called\n");
93 * Entry point for the plugin.
96 libgnunet_plugin_block_mesh_init (void *cls)
98 static enum GNUNET_BLOCK_Type types[] =
100 GNUNET_BLOCK_TYPE_MESH_PEER,
101 GNUNET_BLOCK_TYPE_ANY /* end of list */
103 struct GNUNET_BLOCK_PluginFunctions *api;
105 api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions));
106 api->evaluate = &block_plugin_mesh_evaluate;
107 api->get_key = &block_plugin_mesh_get_key;
114 * Exit point from the plugin.
117 libgnunet_plugin_block_mesh_done (void *cls)
119 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
125 /* end of plugin_block_mesh.c */