GNUnet  0.11.x
Data Structures | Functions
block.c File Reference

library for data block manipulation More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_block_lib.h"
#include "gnunet_block_plugin.h"
Include dependency graph for block.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 
struct  GNUNET_BLOCK_Context
 Handle to an initialized block library. More...
 

Functions

void GNUNET_BLOCK_mingle_hash (const struct GNUNET_HashCode *in, uint32_t mingle_number, struct GNUNET_HashCode *hc)
 Mingle hash with the mingle_number to produce different bits. More...
 
static void add_plugin (void *cls, const char *library_name, void *lib_ret)
 Add a plugin to the list managed by the block library. More...
 
struct GNUNET_BLOCK_ContextGNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create a block context. More...
 
void GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
 Destroy the block context. More...
 
int GNUNET_BLOCK_group_serialize (struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
 Serialize state of a block group. More...
 
void GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg)
 Destroy resources used by a block group. More...
 
int GNUNET_BLOCK_group_merge (struct GNUNET_BLOCK_Group *bg1, struct GNUNET_BLOCK_Group *bg2)
 Try merging two block groups. More...
 
static struct GNUNET_BLOCK_PluginFunctionsfind_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
 Find a plugin for the given type. More...
 
struct GNUNET_BLOCK_GroupGNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, uint32_t nonce, const void *raw_data, size_t raw_data_size,...)
 Create a new block group. More...
 
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate (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. More...
 
int GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, 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. More...
 
int GNUNET_BLOCK_group_set_seen (struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *seen_results, unsigned int seen_results_count)
 Update block group to filter out the given results. More...
 

Detailed Description

library for data block manipulation

Author
Christian Grothoff

Definition in file block.c.

Function Documentation

◆ add_plugin()

static void add_plugin ( void *  cls,
const char *  library_name,
void *  lib_ret 
)
static

Add a plugin to the list managed by the block library.

Parameters
clsthe block context
library_namename of the plugin
lib_retthe plugin API

Definition at line 104 of file block.c.

References Plugin::api, ctx, GNUNET_array_append, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_strdup, Plugin::library_name, GNUNET_BLOCK_Context::num_plugins, plugin, and GNUNET_BLOCK_Context::plugins.

Referenced by GNUNET_BLOCK_context_create().

107 {
108  struct GNUNET_BLOCK_Context *ctx = cls;
109  struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
110  struct Plugin *plugin;
111 
113  "Loading block plugin `%s'\n",
114  library_name);
115  plugin = GNUNET_new (struct Plugin);
116  plugin->api = api;
119  ctx->num_plugins,
120  plugin);
121 }
Handle to an initialized block library.
Definition: block.c:54
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
char * library_name
Name of the shared library.
Definition: block.c:42
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
unsigned int num_plugins
Size of the 'plugins' array.
Definition: block.c:64
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
struct Plugin ** plugins
Array of our plugins.
Definition: block.c:59
Here is the caller graph for this function:

◆ find_plugin()

static struct GNUNET_BLOCK_PluginFunctions* find_plugin ( struct GNUNET_BLOCK_Context ctx,
enum GNUNET_BLOCK_Type  type 
)
static

Find a plugin for the given type.

Parameters
ctxcontext to search
typetype to look for
Returns
NULL if no matching plugin exists

Definition at line 256 of file block.c.

References Plugin::api, GNUNET_BLOCK_Context::num_plugins, plugin, GNUNET_BLOCK_Context::plugins, and GNUNET_BLOCK_PluginFunctions::types.

Referenced by GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_get_key(), and GNUNET_BLOCK_group_create().

258 {
259  struct Plugin *plugin;
260  unsigned int j;
261 
262  for (unsigned i = 0; i < ctx->num_plugins; i++)
263  {
264  plugin = ctx->plugins[i];
265  j = 0;
266  while (0 != (plugin->api->types[j]))
267  {
268  if (type == plugin->api->types[j])
269  return plugin->api;
270  j++;
271  }
272  }
273  return NULL;
274 }
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: block.c:64
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct Plugin ** plugins
Array of our plugins.
Definition: block.c:59
Here is the caller graph for this function: