GNUnet  0.11.x
gnunet_block_plugin.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2010,2013,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 
35 #ifndef PLUGIN_BLOCK_H
36 #define PLUGIN_BLOCK_H
37 
38 #include "gnunet_util_lib.h"
39 #include "gnunet_block_lib.h"
40 
41 
50 typedef void
52  const struct
53  GNUNET_HashCode *seen_results,
54  unsigned int seen_results_count);
55 
56 
66 typedef int
68  const struct GNUNET_BLOCK_Group *bg2);
69 
70 
81 typedef int
83  uint32_t *nonce,
84  void **raw_data,
85  size_t *raw_data_size);
86 
87 
93 typedef void
95 
96 
102 {
106  struct GNUENT_BLOCK_Context *ctx;
107 
112 
118 
124 
130 
136 
141 };
142 
143 
156 typedef struct GNUNET_BLOCK_Group *
157 (*GNUNET_BLOCK_GroupCreateFunction)(void *cls,
158  enum GNUNET_BLOCK_Type type,
159  uint32_t nonce,
160  const void *raw_data,
161  size_t raw_data_size,
162  va_list va);
163 
164 
186  struct GNUNET_BLOCK_Context *ctx,
187  enum GNUNET_BLOCK_Type type,
188  struct GNUNET_BLOCK_Group *group,
190  const struct GNUNET_HashCode *query,
191  const void *xquery,
192  size_t xquery_size,
193  const void *reply_block,
194  size_t reply_block_size);
195 
196 
210 typedef int
212  enum GNUNET_BLOCK_Type type,
213  const void *block,
214  size_t block_size,
215  struct GNUNET_HashCode *key);
216 
217 
223 {
227  void *cls;
228 
233 
239 
244 
250 };
251 
252 #endif
253  /* end of group */
enum GNUNET_BLOCK_EvaluationResult(* GNUNET_BLOCK_EvaluationFunction)(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.
Handle to an initialized block library.
Definition: block.c:54
void * internal_cls
Internal data structure of the plugin.
void(* GNUNET_BLOCK_GroupDestroyFunction)(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
GNUNET_BLOCK_GroupSerializeFunction serialize_cb
Serialize the block group data, can be NULL if not supported.
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.
struct GNUNET_BLOCK_Group *(* GNUNET_BLOCK_GroupCreateFunction)(void *cls, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size, va_list va)
Create a new block group.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_BLOCK_GroupDestroyFunction destroy_cb
Function to call to destroy the block group.
struct GNUENT_BLOCK_Context * ctx
Context owning the block group.
enum GNUNET_BLOCK_Type type
Type for the block group.
void(* GNUNET_BLOCK_GroupMarkSeenFunction)(struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
Mark elements as "seen" using a hash of the element.
int(* GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
Serialize state of a block group.
A 512-bit hashcode.
int(* GNUNET_BLOCK_GroupMergeFunction)(struct GNUNET_BLOCK_Group *bg1, const struct GNUNET_BLOCK_Group *bg2)
Merge two groups, if possible.
struct GNUNET_HashCode key
The key used in the DHT.
GNUNET_BLOCK_GroupCreateFunction create_group
Create a block group to process a bunch of blocks in a shared context (i.e.
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
GNUNET_BLOCK_GroupMergeFunction merge_cb
Function to call to merge two groups.
Block group data.
void * cls
Closure for all of the callbacks.
GNUNET_BLOCK_EvaluationOptions
Flags that can be set to control the evaluation.
int(* GNUNET_BLOCK_GetKeyFunction)(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_GroupMarkSeenFunction mark_seen_cb
Function to call to mark elements as seen in the group.