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...


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

Christian Grothoff

Definition in file block.c.

Function Documentation

◆ add_plugin()

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

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

clsthe block context
library_namename of the plugin
lib_retthe plugin API

Definition at line 104 of file block.c.

107 {
108  struct GNUNET_BLOCK_Context *ctx = cls;
109  struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
110  struct Plugin *plugin;
113  "Loading block plugin `%s'\n",
114  library_name);
115  plugin = GNUNET_new (struct Plugin);
116  plugin->api = api;
118  GNUNET_array_append (ctx->plugins,
119  ctx->num_plugins,
120  plugin);
121 }
struct Plugin * plugin
The process handle to the testbed service.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_log(kind,...)
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
Handle to an initialized block library.
Definition: block.c:55
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
Handle for a plugin.
Definition: block.c:38
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
char * library_name
Name of the shared library.
Definition: block.c:42

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

Referenced by GNUNET_BLOCK_context_create().

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 

Find a plugin for the given type.

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

Definition at line 257 of file block.c.

259 {
260  struct Plugin *plugin;
261  unsigned int j;
263  for (unsigned i = 0; i < ctx->num_plugins; i++)
264  {
265  plugin = ctx->plugins[i];
266  j = 0;
267  while (0 != (plugin->api->types[j]))
268  {
269  if (type == plugin->api->types[j])
270  return plugin->api;
271  j++;
272  }
273  }
274  return NULL;
275 }
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References Plugin::api, ctx, plugin, type, and GNUNET_BLOCK_PluginFunctions::types.

Referenced by GNUNET_BLOCK_evaluate(), and GNUNET_BLOCK_get_key().

Here is the caller graph for this function: