GNUnet 0.21.0
Block group library

Library for data group management. More...

Collaboration diagram for Block group library:

Enumerations

enum  GNUNET_BLOCK_ReplyEvaluationResult {
  GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1 , GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0 , GNUNET_BLOCK_REPLY_IRRELEVANT = 1 , GNUNET_BLOCK_REPLY_OK_MORE = 2 ,
  GNUNET_BLOCK_REPLY_OK_LAST = 3
}
 Possible ways for how a block may relate to a query. More...
 

Functions

size_t GNUNET_BLOCK_GROUP_compute_bloomfilter_size (unsigned int entry_count, unsigned int k)
 How many bytes should a bloomfilter be if we have already seen entry_count responses? Sized so that do not have to re-size the filter too often (to keep it cheap). More...
 
struct GNUNET_BLOCK_GroupGNUNET_BLOCK_GROUP_bf_create (void *cls, size_t bf_size, unsigned int bf_k, enum GNUNET_BLOCK_Type type, const void *raw_data, size_t raw_data_size)
 Create a new block group that filters duplicates using a Bloom filter. More...
 
enum GNUNET_GenericReturnValue GNUNET_BLOCK_GROUP_bf_test_and_set (struct GNUNET_BLOCK_Group *bg, const struct GNUNET_HashCode *hc)
 Test if hc is contained in the Bloom filter of bg. 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...
 
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...
 
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_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_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_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_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_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...
 
enum GNUNET_GenericReturnValue GNUNET_BLOCK_group_merge (struct GNUNET_BLOCK_Group *bg1, struct GNUNET_BLOCK_Group *bg2)
 Try merging two block groups. More...
 

Detailed Description

Library for data group management.

Library for data block manipulation.

Enumeration Type Documentation

◆ GNUNET_BLOCK_ReplyEvaluationResult

Possible ways for how a block may relate to a query.

Enumerator
GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED 

Specified block type not supported by any plugin.

GNUNET_BLOCK_REPLY_OK_DUPLICATE 

Valid result, but suppressed because it is a duplicate.

GNUNET_BLOCK_REPLY_IRRELEVANT 

Block does not match xquery (valid result, not relevant for the request)

GNUNET_BLOCK_REPLY_OK_MORE 

Valid result, and there may be more.

GNUNET_BLOCK_REPLY_OK_LAST 

Last possible valid result.

Definition at line 53 of file gnunet_block_lib.h.

54{
55
60
65
70
75
80
81};
@ GNUNET_BLOCK_REPLY_OK_MORE
Valid result, and there may be more.
@ GNUNET_BLOCK_REPLY_OK_DUPLICATE
Valid result, but suppressed because it is a duplicate.
@ GNUNET_BLOCK_REPLY_OK_LAST
Last possible valid result.
@ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED
Specified block type not supported by any plugin.
@ GNUNET_BLOCK_REPLY_IRRELEVANT
Block does not match xquery (valid result, not relevant for the request)

Function Documentation

◆ GNUNET_BLOCK_GROUP_compute_bloomfilter_size()

size_t GNUNET_BLOCK_GROUP_compute_bloomfilter_size ( unsigned int  entry_count,
unsigned int  k 
)

How many bytes should a bloomfilter be if we have already seen entry_count responses? Sized so that do not have to re-size the filter too often (to keep it cheap).

Since other peers will also add entries but not resize the filter, we should generally pick a slightly larger size than what the strict math would suggest.

Parameters
entry_countexpected number of entries in the Bloom filter
knumber of bits set per entry
Returns
must be a power of two and smaller or equal to 2^15.

Definition at line 268 of file bg_bf.c.

270{
271 size_t size;
272 unsigned int ideal = (entry_count * k) / 4;
273 uint16_t max = 1 << 15;
274
275 if (entry_count > max)
276 return max;
277 size = 8;
278 while ((size < max) && (size < ideal))
279 size *= 2;
280 if (size > max)
281 return max;
282 return size;
283}
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:68

References max, and size.

Referenced by block_plugin_dht_create_group(), block_plugin_dns_create_group(), block_plugin_fs_create_group(), block_plugin_gns_create_group(), block_plugin_regex_create_group(), block_plugin_template_create_group(), and block_plugin_test_create_group().

Here is the caller graph for this function:

◆ GNUNET_BLOCK_GROUP_bf_create()

struct GNUNET_BLOCK_Group * GNUNET_BLOCK_GROUP_bf_create ( void *  cls,
size_t  bf_size,
unsigned int  bf_k,
enum GNUNET_BLOCK_Type  type,
const void *  raw_data,
size_t  raw_data_size 
)

Create a new block group that filters duplicates using a Bloom filter.

Parameters
ctxblock context in which the block group is created
bf_sizesize of the Bloom filter
bf_kK-value for the Bloom filter
typeblock type
raw_dataoptional serialized prior state of the group, NULL if unavailable/fresh
raw_data_sizenumber of bytes in raw_data, 0 if unavailable/fresh
Returns
block group handle, NULL if block groups are not supported by this type of block (this is not an error)

Definition at line 173 of file bg_bf.c.

179{
180 struct BfGroupInternals *gi;
181 struct GNUNET_BLOCK_Group *bg;
182 uint32_t nonce;
183
184 if ( (NULL != raw_data) &&
185 (raw_data_size < sizeof (nonce)) )
186 {
187 GNUNET_break_op (0);
188 return NULL;
189 }
190 if (NULL != raw_data)
191 {
192 memcpy (&nonce,
193 raw_data,
194 sizeof (nonce));
195 raw_data += sizeof (nonce);
196 raw_data_size -= sizeof (nonce);
197 }
198 else
199 {
201 UINT32_MAX);
202 }
203 gi = GNUNET_new (struct BfGroupInternals);
204 gi->bf = GNUNET_CONTAINER_bloomfilter_init ((bf_size != raw_data_size) ?
205 NULL : raw_data,
206 bf_size,
207 bf_k);
208 gi->bf_mutator = nonce;
209 gi->bf_size = bf_size;
210 bg = GNUNET_new (struct GNUNET_BLOCK_Group);
211 bg->type = type;
216 bg->internal_cls = gi;
217 return bg;
218}
static void bf_group_mark_seen_cb(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.
Definition: bg_bf.c:99
static enum GNUNET_GenericReturnValue bf_group_serialize_cb(struct GNUNET_BLOCK_Group *bg, void **raw_data, size_t *raw_data_size)
Serialize state of a block group.
Definition: bg_bf.c:64
static void bf_group_destroy_cb(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
Definition: bg_bf.c:150
static enum GNUNET_GenericReturnValue bf_group_merge_cb(struct GNUNET_BLOCK_Group *bg1, const struct GNUNET_BLOCK_Group *bg2)
Merge two groups, if possible.
Definition: bg_bf.c:128
static uint32_t type
Type string converted to DNS type value.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Internal data structure for a block group.
Definition: bg_bf.c:36
uint32_t bf_size
Size of bf.
Definition: bg_bf.c:50
uint32_t bf_mutator
Set from the nonce to mingle the hashes before going into the bf.
Definition: bg_bf.c:45
struct GNUNET_CONTAINER_BloomFilter * bf
A Bloom filter to weed out duplicate replies probabilistically.
Definition: bg_bf.c:40
Block group data.
GNUNET_BLOCK_GroupMergeFunction merge_cb
Function to call to merge two groups.
GNUNET_BLOCK_GroupDestroyFunction destroy_cb
Function to call to destroy the block group.
GNUNET_BLOCK_GroupMarkSeenFunction mark_seen_cb
Function to call to mark elements as seen in the group.
void * internal_cls
Internal data structure of the plugin.
GNUNET_BLOCK_GroupSerializeFunction serialize_cb
Serialize the block group data, can be NULL if not supported.
enum GNUNET_BLOCK_Type type
Type for the block group.

References BfGroupInternals::bf, bf_group_destroy_cb(), bf_group_mark_seen_cb(), bf_group_merge_cb(), bf_group_serialize_cb(), BfGroupInternals::bf_mutator, BfGroupInternals::bf_size, GNUNET_BLOCK_Group::destroy_cb, GNUNET_break_op, GNUNET_CONTAINER_bloomfilter_init(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_new, GNUNET_BLOCK_Group::internal_cls, GNUNET_BLOCK_Group::mark_seen_cb, GNUNET_BLOCK_Group::merge_cb, GNUNET_BLOCK_Group::serialize_cb, type, and GNUNET_BLOCK_Group::type.

Referenced by block_plugin_dht_create_group(), block_plugin_dns_create_group(), block_plugin_fs_create_group(), block_plugin_gns_create_group(), block_plugin_regex_create_group(), block_plugin_template_create_group(), and block_plugin_test_create_group().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_GROUP_bf_test_and_set()

enum GNUNET_GenericReturnValue GNUNET_BLOCK_GROUP_bf_test_and_set ( struct GNUNET_BLOCK_Group bg,
const struct GNUNET_HashCode hc 
)

Test if hc is contained in the Bloom filter of bg.

If so, return GNUNET_YES. If not, add hc to the Bloom filter and return GNUNET_NO.

Parameters
bgblock group to use for testing
hchash of element to evaluate
Returns
GNUNET_YES if hc is (likely) a duplicate GNUNET_NO if hc was definitively not in bg (but now is)

Definition at line 232 of file bg_bf.c.

234{
235 struct BfGroupInternals *gi;
236 struct GNUNET_HashCode mhash;
237
238 if (NULL == bg)
239 return GNUNET_NO;
240 gi = bg->internal_cls;
242 gi->bf_mutator,
243 &mhash);
244 if (GNUNET_YES ==
246 &mhash))
247 return GNUNET_YES;
249 &mhash);
250 return GNUNET_NO;
251}
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.
Definition: block.c:96
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
bool GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
@ GNUNET_YES
@ GNUNET_NO
A 512-bit hashcode.

References BfGroupInternals::bf, BfGroupInternals::bf_mutator, GNUNET_BLOCK_mingle_hash(), GNUNET_CONTAINER_bloomfilter_add(), GNUNET_CONTAINER_bloomfilter_test(), GNUNET_NO, GNUNET_YES, and GNUNET_BLOCK_Group::internal_cls.

Referenced by block_plugin_dht_check_reply(), block_plugin_dns_check_reply(), block_plugin_fs_check_reply(), block_plugin_gns_check_reply(), block_plugin_regex_check_reply(), block_plugin_test_check_reply(), and process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_mingle_hash()

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.

Parameters
inoriginal hash code
mingle_numbernumber for hash permutation
hcwhere to store the result.

Definition at line 96 of file block.c.

99{
100 struct MinglePacker mp = {
101 .in = *in,
102 .mingle = mingle_number
103 };
104
106 sizeof(mp),
107 hc);
108}
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
Serialization to use in GNUNET_BLOCK_mingle_hash.
Definition: block.c:80
struct GNUNET_HashCode in
Original hash.
Definition: block.c:84

References GNUNET_CRYPTO_hash(), and MinglePacker::in.

Referenced by bf_group_mark_seen_cb(), filtered_map_initialization(), GNUNET_BLOCK_GROUP_bf_test_and_set(), iterator_bf_create(), and iterator_bf_reduce().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_context_create()

struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create a block context.

Loads the block plugins.

Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 140 of file block.c.

141{
143
145 ctx->cfg = cfg;
147 "libgnunet_plugin_block_",
148 (void *) cfg,
149 &add_plugin,
150 ctx);
151 return ctx;
152}
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin to the list managed by the block library.
Definition: block.c:119
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_FS_Handle * ctx
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_PLUGIN_load_all_in_context(const struct GNUNET_OS_ProjectData *ctx, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name while inside the given context (i....
Definition: plugin.c:386
Handle to an initialized block library.
Definition: block.c:55
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1074

References add_plugin(), cfg, GNUNET_FS_Handle::cfg, ctx, GNUNET_new, GNUNET_OS_project_data_default(), and GNUNET_PLUGIN_load_all_in_context().

Referenced by block_plugin_consensus_check_block(), block_plugin_consensus_check_reply(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_context_destroy()

void GNUNET_BLOCK_context_destroy ( struct GNUNET_BLOCK_Context ctx)

Destroy the block context.

Parameters
ctxcontext to destroy

Definition at line 156 of file block.c.

157{
158 struct Plugin *plugin;
159
160 for (unsigned int i = 0; i < ctx->num_plugins; i++)
161 {
162 plugin = ctx->plugins[i];
163 GNUNET_break (NULL ==
165 plugin->api));
168 }
169 GNUNET_free (ctx->plugins);
171}
struct TestcasePlugin * plugin
The process handle to the testbed service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:242
Handle for a plugin.
Definition: block.c:38
char * library_name
Name of the shared library.
Definition: testing.h:98
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: testing.h:103

References TestcasePlugin::api, ctx, GNUNET_break, GNUNET_free, GNUNET_PLUGIN_unload(), TestcasePlugin::library_name, and plugin.

Referenced by libgnunet_plugin_block_consensus_done(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_create()

struct GNUNET_BLOCK_Group * GNUNET_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.

Parameters
ctxblock context in which the block group is created
typetype of the block for which we are creating the group
raw_dataoptional serialized prior state of the group, NULL if unavailable/fresh
raw_data_sizenumber of bytes in raw_data, 0 if unavailable/fresh
...type-specific additional data, can be empty
Returns
block group handle, NULL if block groups are not supported by this type of block (this is not an error)

Definition at line 247 of file block.c.

252{
254 struct GNUNET_BLOCK_Group *bg;
255 va_list ap;
256
258 type);
259 if (NULL == plugin)
260 return NULL;
261 if (NULL == plugin->create_group)
262 return NULL;
263 va_start (ap,
264 raw_data_size);
265 bg = plugin->create_group (plugin->cls,
266 type,
267 raw_data,
268 raw_data_size,
269 ap);
270 va_end (ap);
271 return bg;
272}
static struct GNUNET_BLOCK_PluginFunctions * find_plugin(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
Find a plugin for the given type.
Definition: block.c:231
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...

References ctx, find_plugin(), plugin, and type.

Referenced by GSF_pending_request_create_(), handle_dht_p2p_get(), refresh_bloomfilter(), send_find_peer_message(), and transmit_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_serialize()

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.

Parameters
bggroup to serialize
[out]raw_dataset to the serialized state
[out]raw_data_sizeset to the number of bytes in raw_data
Returns
GNUNET_OK on success, GNUNET_NO if serialization is not supported, GNUNET_SYSERR on error

Definition at line 175 of file block.c.

178{
179 *raw_data = NULL;
180 *raw_data_size = 0;
181 if (NULL == bg)
182 return GNUNET_NO;
183 if (NULL == bg->serialize_cb)
184 return GNUNET_NO;
185 return bg->serialize_cb (bg,
186 raw_data,
187 raw_data_size);
188}

References GNUNET_NO, and GNUNET_BLOCK_Group::serialize_cb.

Referenced by GDS_NEIGHBOURS_handle_get(), and GSF_pending_request_get_message_().

Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_destroy()

void GNUNET_BLOCK_group_destroy ( struct GNUNET_BLOCK_Group bg)

Destroy resources used by a block group.

Parameters
bggroup to destroy, NULL is allowed

Definition at line 192 of file block.c.

193{
194 if (NULL == bg)
195 return;
196 bg->destroy_cb (bg);
197}

References GNUNET_BLOCK_Group::destroy_cb.

Referenced by clean_request(), expire_oldest_entry(), refresh_bloomfilter(), send_find_peer_message(), and transmit_request().

Here is the caller graph for this function:

◆ GNUNET_BLOCK_check_reply()

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.

Parameters
ctxblock contxt
typeblock type
[in,out]groupblock 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 337 of file block.c.

345{
347 type);
348
349 if (NULL == plugin)
351 return plugin->check_reply (plugin->cls,
352 type,
353 group,
354 query,
355 xquery,
356 xquery_size,
357 reply_block,
358 reply_block_size);
359}

References ctx, find_plugin(), GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED, plugin, and type.

Referenced by block_plugin_consensus_check_reply(), datacache_get_iterator(), forward_reply(), handle_find_local_hello(), handle_find_my_hello(), process(), and process_reply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_check_query()

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.

Parameters
ctxblock contxt
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 block is fine, GNUNET_NO if not, GNUNET_SYSERR if type is not supported

Definition at line 296 of file block.c.

301{
303
305 return GNUNET_SYSERR; /* no checks */
307 type);
308 if (NULL == plugin)
309 return GNUNET_SYSERR;
310 return plugin->check_query (plugin->cls,
311 type,
312 query,
313 xquery,
314 xquery_size);
315}
@ GNUNET_SYSERR
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.

References ctx, find_plugin(), GNUNET_BLOCK_TYPE_ANY, GNUNET_SYSERR, plugin, and type.

Referenced by handle_dht_p2p_get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_check_block()

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.

Parameters
ctxblock contxt
typeblock type
blockpayload to put
block_sizenumber of bytes in block
Returns
GNUNET_OK if the block is fine, GNUNET_NO if not, GNUNET_SYSERR if type is not supported

Definition at line 319 of file block.c.

323{
325 type);
326
327 if (NULL == plugin)
328 return GNUNET_SYSERR;
329 return plugin->check_block (plugin->cls,
330 type,
331 block,
332 block_size);
333}

References ctx, find_plugin(), GNUNET_SYSERR, plugin, and type.

Referenced by block_plugin_consensus_check_block(), cadet_reply_proc(), handle_dht_local_put(), handle_dht_p2p_put(), handle_dht_p2p_result(), and handle_p2p_put().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_get_key()

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.

If the block is malformed, the function should zero-out key and return GNUNET_OK.

Parameters
ctxblock context
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_YES on success, GNUNET_NO if extracting a key from a block of this type does not work GNUNET_SYSERR if type not supported

Definition at line 276 of file block.c.

281{
283 type);
284
285 if (NULL == plugin)
286 return GNUNET_SYSERR;
287 return plugin->get_key (plugin->cls,
288 type,
289 block,
290 block_size,
291 key);
292}
struct GNUNET_HashCode key
The key used in the DHT.

References ctx, find_plugin(), GNUNET_SYSERR, key, plugin, and type.

Referenced by cadet_reply_proc(), handle_dht_p2p_put(), handle_dht_p2p_result(), handle_p2p_put(), handle_reply(), and process_local_reply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_set_seen()

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.

Note that the use of a hash for seen results implies that the caller magically knows how the specific block engine hashes for filtering duplicates, so this API may not always apply.

Parameters
bf_mutatormutation value to use
seen_resultsresults already seen
seen_results_countnumber of entries in seen_results
Returns
GNUNET_SYSERR if not supported, GNUNET_OK on success

Definition at line 363 of file block.c.

366{
367 if (NULL == bg)
368 return GNUNET_OK;
369 if (NULL == bg->mark_seen_cb)
370 return GNUNET_SYSERR;
371 bg->mark_seen_cb (bg,
372 seen_results,
373 seen_results_count);
374 return GNUNET_OK;
375}
@ GNUNET_OK

References GNUNET_OK, GNUNET_SYSERR, and GNUNET_BLOCK_Group::mark_seen_cb.

Referenced by add_known_to_bloom(), GSF_pending_request_update_(), refresh_bloomfilter(), and transmit_request().

Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_merge()

enum GNUNET_GenericReturnValue GNUNET_BLOCK_group_merge ( struct GNUNET_BLOCK_Group bg1,
struct GNUNET_BLOCK_Group bg2 
)

Try merging two block groups.

Afterwards, bg1 should remain valid and contain the rules from both bg1 and bg2, and bg2 should be destroyed (as part of this call). The latter should happen even if merging is not supported.

Parameters
[in,out]bg1first group to merge, is updated
bg2second group to merge, is destroyed
Returns
GNUNET_OK on success, GNUNET_NO if merge failed due to different nonce GNUNET_SYSERR if merging is not supported

Definition at line 201 of file block.c.

203{
205
206 if (NULL == bg2)
207 return GNUNET_OK;
208 if (NULL == bg1)
209 {
210 bg2->destroy_cb (bg2);
211 return GNUNET_OK;
212 }
213 if (NULL == bg1->merge_cb)
214 return GNUNET_SYSERR;
215 GNUNET_assert (bg1->merge_cb == bg1->merge_cb);
216 ret = bg1->merge_cb (bg1,
217 bg2);
218 bg2->destroy_cb (bg2);
219 return ret;
220}
static int ret
Final status code.
Definition: gnunet-arm.c:94
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

References GNUNET_BLOCK_Group::destroy_cb, GNUNET_assert, GNUNET_OK, GNUNET_SYSERR, GNUNET_BLOCK_Group::merge_cb, and ret.

Referenced by try_combine_recent().

Here is the caller graph for this function: