GNUnet 0.22.2
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 const struct GNUNET_OS_ProjectData *pd;
144
146 ctx->cfg = cfg;
149 "libgnunet_plugin_block_",
150 (void *) cfg,
151 &add_plugin,
152 ctx);
153 return ctx;
154}
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:108
static struct GNUNET_FS_Handle * ctx
const struct GNUNET_OS_ProjectData * GNUNET_CONFIGURATION_get_project_data(const struct GNUNET_CONFIGURATION_Handle *cfg)
Return the project data associated with this configuration.
void GNUNET_PLUGIN_load_all(const struct GNUNET_OS_ProjectData *pd, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name.
Definition: plugin.c:401
Handle to an initialized block library.
Definition: block.c:55
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1074
Project-specific data used to help the OS subsystem find installation paths.

References add_plugin(), cfg, GNUNET_FS_Handle::cfg, ctx, GNUNET_CONFIGURATION_get_project_data(), GNUNET_new, and GNUNET_PLUGIN_load_all().

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 158 of file block.c.

159{
160 struct Plugin *plugin;
161
162 for (unsigned int i = 0; i < ctx->num_plugins; i++)
163 {
164 plugin = ctx->plugins[i];
165 GNUNET_break (NULL ==
166 GNUNET_PLUGIN_unload (plugin->library_name,
167 plugin->api));
168 GNUNET_free (plugin->library_name);
170 }
171 GNUNET_free (ctx->plugins);
173}
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
#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:277
Handle for a plugin.
Definition: block.c:38

References ctx, GNUNET_break, GNUNET_free, GNUNET_PLUGIN_unload(), 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 249 of file block.c.

254{
256 struct GNUNET_BLOCK_Group *bg;
257 va_list ap;
258
260 type);
261 if (NULL == plugin)
262 return NULL;
263 if (NULL == plugin->create_group)
264 return NULL;
265 va_start (ap,
266 raw_data_size);
267 bg = plugin->create_group (plugin->cls,
268 type,
269 raw_data,
270 raw_data_size,
271 ap);
272 va_end (ap);
273 return bg;
274}
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:233
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure to pass to start_testcase.

References GNUNET_TESTING_PluginFunctions::cls, 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 177 of file block.c.

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

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 194 of file block.c.

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

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 339 of file block.c.

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

References GNUNET_TESTING_PluginFunctions::cls, 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 298 of file block.c.

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

References GNUNET_TESTING_PluginFunctions::cls, 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 321 of file block.c.

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

References GNUNET_TESTING_PluginFunctions::cls, 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 278 of file block.c.

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

References GNUNET_TESTING_PluginFunctions::cls, 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 365 of file block.c.

368{
369 if (NULL == bg)
370 return GNUNET_OK;
371 if (NULL == bg->mark_seen_cb)
372 return GNUNET_SYSERR;
373 bg->mark_seen_cb (bg,
374 seen_results,
375 seen_results_count);
376 return GNUNET_OK;
377}
@ 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 203 of file block.c.

205{
207
208 if (NULL == bg2)
209 return GNUNET_OK;
210 if (NULL == bg1)
211 {
212 bg2->destroy_cb (bg2);
213 return GNUNET_OK;
214 }
215 if (NULL == bg1->merge_cb)
216 return GNUNET_SYSERR;
217 GNUNET_assert (bg1->merge_cb == bg1->merge_cb);
218 ret = bg1->merge_cb (bg1,
219 bg2);
220 bg2->destroy_cb (bg2);
221 return ret;
222}
static int ret
Final status code.
Definition: gnunet-arm.c:93
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: