GNUnet 0.21.1
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...
 
struct  MinglePacker
 Serialization to use in GNUNET_BLOCK_mingle_hash. More...
 

Functions

GNUNET_NETWORK_STRUCT_END 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...
 
enum GNUNET_GenericReturnValue GNUNET_BLOCK_group_serialize (struct GNUNET_BLOCK_Group *bg, 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...
 
enum GNUNET_GenericReturnValue 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, const void *raw_data, size_t raw_data_size,...)
 Create a new block group. More...
 
enum GNUNET_GenericReturnValue 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...
 
enum GNUNET_GenericReturnValue GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
 Function called to validate a request. More...
 
enum GNUNET_GenericReturnValue GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
 Function called to validate a block. More...
 
enum GNUNET_BLOCK_ReplyEvaluationResult GNUNET_BLOCK_check_reply (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, 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 if a reply is good for a particular query. More...
 
enum GNUNET_GenericReturnValue 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 119 of file block.c.

122{
123 struct GNUNET_BLOCK_Context *ctx = cls;
124 struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
125 struct Plugin *plugin;
126
128 "Loading block plugin `%s'\n",
130 plugin = GNUNET_new (struct Plugin);
131 plugin->api = api;
133 GNUNET_array_append (ctx->plugins,
134 ctx->num_plugins,
135 plugin);
136}
struct TestcasePlugin * plugin
The process handle to the testbed service.
static struct GNUNET_FS_Handle * ctx
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#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
char * library_name
Name of the shared library.
Definition: testing.h:98
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: testing.h:103

References Plugin::api, TestcasePlugin::api, ctx, GNUNET_array_append, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_strdup, Plugin::library_name, TestcasePlugin::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 
)
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 231 of file block.c.

233{
234 for (unsigned i = 0; i < ctx->num_plugins; i++)
235 {
236 struct Plugin *plugin = ctx->plugins[i];
237
238 for (unsigned int j = 0; 0 != plugin->api->types[j]; j++)
239 if (type == plugin->api->types[j])
240 return plugin->api;
241 }
242 return NULL;
243}
static uint32_t type
Type string converted to DNS type value.

References TestcasePlugin::api, ctx, plugin, and type.

Referenced by GNUNET_BLOCK_check_block(), GNUNET_BLOCK_check_query(), GNUNET_BLOCK_check_reply(), GNUNET_BLOCK_get_key(), and GNUNET_BLOCK_group_create().

Here is the caller graph for this function: