GNUnet  0.17.6
Functions
plugin_block_seti_test.c File Reference

set test block, recognizes elements with non-zero first byte as invalid More...

#include "platform.h"
#include "gnunet_block_plugin.h"
#include "gnunet_block_group_lib.h"
Include dependency graph for plugin_block_seti_test.c:

Go to the source code of this file.

Functions

static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_query (void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
 Function called to validate a query. More...
 
static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_block (void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
 Function called to validate a block for storage. More...
 
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_seti_test_check_reply (void *cls, 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 a reply to a request. More...
 
static enum GNUNET_GenericReturnValue block_plugin_seti_test_get_key (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. More...
 
void * libgnunet_plugin_block_seti_test_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_block_seti_test_done (void *cls)
 Exit point from the plugin. More...
 

Detailed Description

set test block, recognizes elements with non-zero first byte as invalid

Author
Christian Grothoff

Definition in file plugin_block_seti_test.c.

Function Documentation

◆ block_plugin_seti_test_check_query()

static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_query ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const struct GNUNET_HashCode query,
const void *  xquery,
size_t  xquery_size 
)
static

Function called to validate a query.

Parameters
clsclosure
ctxblock context
typeblock type
queryoriginal query (hash)
xqueryextrended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
Returns
GNUNET_OK if the query is fine, GNUNET_NO if not

Definition at line 1 of file plugin_block_seti_test.c.

49 {
51  {
52  GNUNET_break (0);
53  return GNUNET_SYSERR;
54  }
55  if (0 != xquery_size)
56  {
57  GNUNET_break_op (0);
58  return GNUNET_NO;
59  }
60  return GNUNET_OK;
61 }
@ GNUNET_BLOCK_TYPE_SETI_TEST
Block for testing set intersection.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

Referenced by libgnunet_plugin_block_seti_test_init().

Here is the caller graph for this function:

◆ block_plugin_seti_test_check_block()

static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_block ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const void *  block,
size_t  block_size 
)
static

Function called to validate a block for storage.

Parameters
clsclosure
typeblock type
blockblock data to validate
block_sizenumber of bytes in block
Returns
GNUNET_OK if the block is fine, GNUNET_NO if not

Definition at line 1 of file plugin_block_seti_test.c.

78 {
79  (void) cls;
81  {
82  GNUNET_break (0);
83  return GNUNET_SYSERR;
84  }
85  if ((NULL == block) ||
86  (0 == block_size) ||
87  (0 != ((char *) block)[0]))
88  return GNUNET_SYSERR;
89  return GNUNET_OK;
90 }

References GNUNET_BLOCK_TYPE_SETI_TEST, GNUNET_break, GNUNET_break_op, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and type.

Referenced by libgnunet_plugin_block_seti_test_init().

Here is the caller graph for this function:

◆ block_plugin_seti_test_check_reply()

static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_seti_test_check_reply ( void *  cls,
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 
)
static

Function called to validate a reply to a request.

Note that it is assumed that the reply has already been matched to the key (and signatures checked) as it would be done with the GetKeyFunction and the BlockEvaluationFunction.

Parameters
clsclosure
typeblock type
groupwhich block group to use for evaluation
queryoriginal query (hash)
xqueryextrended query data (can be NULL, depending on type)
xquery_sizenumber of bytes in xquery
reply_blockresponse to validate
reply_block_sizenumber of bytes in reply_block
Returns
characterization of result

Definition at line 1 of file plugin_block_seti_test.c.

118 {
119  (void) cls;
120  (void) xquery;
121  (void) xquery_size;
123  {
124  GNUNET_break (0);
126  }
127  if ( (NULL == reply_block) ||
128  (0 == reply_block_size) ||
129  (0 != ((char *) reply_block)[0]) )
130  GNUNET_assert (0);
132 }
@ GNUNET_BLOCK_REPLY_OK_MORE
Valid result, and there may be more.
@ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED
Specified block type not supported by any plugin.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

Referenced by libgnunet_plugin_block_seti_test_init().

Here is the caller graph for this function:

◆ block_plugin_seti_test_get_key()

static enum GNUNET_GenericReturnValue block_plugin_seti_test_get_key ( void *  cls,
enum GNUNET_BLOCK_Type  type,
const void *  block,
size_t  block_size,
struct GNUNET_HashCode key 
)
static

Function called to obtain the key for a block.

Parameters
clsclosure
typeblock type
blockblock to get the key for
block_sizenumber of bytes in block
keyset to the key (query) for the given block
Returns
GNUNET_OK on success, GNUNET_SYSERR if type not supported (or if extracting a key from a block of this type does not work)

Definition at line 1 of file plugin_block_seti_test.c.

152 {
154  {
155  GNUNET_break (0);
156  return GNUNET_SYSERR;
157  }
158  return GNUNET_NO;
159 }

Referenced by libgnunet_plugin_block_seti_test_init().

Here is the caller graph for this function:

◆ libgnunet_plugin_block_seti_test_init()

void* libgnunet_plugin_block_seti_test_init ( void *  cls)

Entry point for the plugin.

Definition at line 166 of file plugin_block_seti_test.c.

167 {
168  static enum GNUNET_BLOCK_Type types[] = {
170  GNUNET_BLOCK_TYPE_ANY /* end of list */
171  };
172  struct GNUNET_BLOCK_PluginFunctions *api;
173 
179  api->types = types;
180  return api;
181 }
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_block(void *cls, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size)
Function called to validate a block for storage.
static enum GNUNET_GenericReturnValue block_plugin_seti_test_check_query(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const void *xquery, size_t xquery_size)
Function called to validate a query.
static enum GNUNET_GenericReturnValue block_plugin_seti_test_get_key(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.
static enum GNUNET_BLOCK_ReplyEvaluationResult block_plugin_seti_test_check_reply(void *cls, 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 a reply to a request.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
enum GNUNET_BLOCK_Type * types
0-terminated array of block types supported by this plugin.
GNUNET_BLOCK_QueryEvaluationFunction check_query
Check that a query is well-formed.
GNUNET_BLOCK_BlockEvaluationFunction check_block
Check that a block is well-formed.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
GNUNET_BLOCK_ReplyEvaluationFunction check_reply
Check that a reply block matches a query.

References block_plugin_seti_test_check_block(), block_plugin_seti_test_check_query(), block_plugin_seti_test_check_reply(), block_plugin_seti_test_get_key(), GNUNET_BLOCK_PluginFunctions::check_block, GNUNET_BLOCK_PluginFunctions::check_query, GNUNET_BLOCK_PluginFunctions::check_reply, GNUNET_BLOCK_PluginFunctions::get_key, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_SETI_TEST, GNUNET_new, and GNUNET_BLOCK_PluginFunctions::types.

Here is the call graph for this function:

◆ libgnunet_plugin_block_seti_test_done()

void* libgnunet_plugin_block_seti_test_done ( void *  cls)

Exit point from the plugin.

Definition at line 188 of file plugin_block_seti_test.c.

189 {
190  struct GNUNET_BLOCK_PluginFunctions *api = cls;
191 
192  GNUNET_free (api);
193  return NULL;
194 }
#define GNUNET_free(ptr)
Wrapper around free.
void * cls
Closure for all of the callbacks.

References GNUNET_BLOCK_PluginFunctions::cls, and GNUNET_free.