GNUnet  0.11.x
Enumerations | Functions
Block group library

Library for data group management. More...

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, uint32_t nonce, 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, uint32_t nonce, 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, 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...
 
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 49 of file gnunet_block_lib.h.

50 {
51 
56 
61 
66 
71 
76 
77 };
@ 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 250 of file bg_bf.c.

252 {
253  size_t size;
254  unsigned int ideal = (entry_count * k) / 4;
255  uint16_t max = 1 << 15;
256 
257  if (entry_count > max)
258  return max;
259  size = 8;
260  while ((size < max) && (size < ideal))
261  size *= 2;
262  if (size > max)
263  return max;
264  return size;
265 }
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:67

References max, and size.

Referenced by block_plugin_dht_check_block(), block_plugin_dns_check_block(), block_plugin_fs_check_block(), block_plugin_gns_check_block(), block_plugin_regex_check_block(), block_plugin_template_check_block(), and block_plugin_test_check_block().

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,
uint32_t  nonce,
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
noncerandom value used to seed the group creation
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 174 of file bg_bf.c.

181 {
182  struct BfGroupInternals *gi;
183  struct GNUNET_BLOCK_Group *bg;
184 
185  gi = GNUNET_new (struct BfGroupInternals);
186  gi->bf = GNUNET_CONTAINER_bloomfilter_init ((bf_size != raw_data_size) ?
187  NULL : raw_data,
188  bf_size,
189  bf_k);
190  gi->bf_mutator = nonce;
191  gi->bf_size = bf_size;
192  bg = GNUNET_new (struct GNUNET_BLOCK_Group);
193  bg->type = type;
198  bg->internal_cls = gi;
199  return bg;
200 }
static enum GNUNET_GenericReturnValue bf_group_serialize_cb(struct GNUNET_BLOCK_Group *bg, uint32_t *nonce, void **raw_data, size_t *raw_data_size)
Serialize state of a block group.
Definition: bg_bf.c:65
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 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
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
#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.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

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_CONTAINER_bloomfilter_init(), GNUNET_new, GNUNET_BLOCK_Group::internal_cls, GNUNET_BLOCK_Group::mark_seen_cb, GNUNET_BLOCK_Group::merge_cb, GNUNET_BLOCK_Group::serialize_cb, GNUNET_BLOCK_Group::type, and type.

Referenced by block_plugin_dht_check_block(), block_plugin_dns_check_block(), block_plugin_fs_check_block(), block_plugin_gns_check_block(), block_plugin_regex_check_block(), block_plugin_template_check_block(), and block_plugin_test_check_block().

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 214 of file bg_bf.c.

216 {
217  struct BfGroupInternals *gi;
218  struct GNUNET_HashCode mhash;
219 
220  if (NULL == bg)
221  return GNUNET_NO;
222  gi = bg->internal_cls;
224  gi->bf_mutator,
225  &mhash);
226  if (GNUNET_YES ==
228  &mhash))
229  return GNUNET_YES;
231  &mhash);
232  return GNUNET_NO;
233 }
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
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:74
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
int GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
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.

Here is the call 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 74 of file block.c.

77 {
78  struct GNUNET_HashCode m;
79 
80  GNUNET_CRYPTO_hash (&mingle_number,
81  sizeof(uint32_t),
82  &m);
84  in,
85  hc);
86 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
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
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:135

References GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_xor(), and m.

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

119 {
120  struct GNUNET_BLOCK_Context *ctx;
121 
123  ctx->cfg = cfg;
125  "libgnunet_plugin_block_",
126  (void *) cfg,
127  &add_plugin,
128  ctx);
129  return ctx;
130 }
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:97
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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:443
Handle to an initialized block library.
Definition: block.c:55

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

Referenced by 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 134 of file block.c.

135 {
136  struct Plugin *plugin;
137 
138  for (unsigned int i = 0; i < ctx->num_plugins; i++)
139  {
140  plugin = ctx->plugins[i];
141  GNUNET_break (NULL ==
143  plugin->api));
146  }
147  GNUNET_free (ctx->plugins);
148  GNUNET_free (ctx);
149 }
struct Plugin * 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:269
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_break, GNUNET_free, GNUNET_PLUGIN_unload(), Plugin::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,
uint32_t  nonce,
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
noncerandom value used to seed the group creation
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 228 of file block.c.

234 {
236  struct GNUNET_BLOCK_Group *bg;
237  va_list ap;
238 
240  type);
241  if (NULL == plugin)
242  return NULL;
243  if (NULL == plugin->create_group)
244  return NULL;
245  va_start (ap,
246  raw_data_size);
247  bg = plugin->create_group (plugin->cls,
248  type,
249  nonce,
250  raw_data,
251  raw_data_size,
252  ap);
253  va_end (ap);
254  return bg;
255 }
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:212
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...

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

Here is the caller graph for this function:

◆ GNUNET_BLOCK_group_serialize()

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

Parameters
bggroup to serialize
[out]nonceset to the nonce of the bg
[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 134 of file block.c.

157 {
158  *nonce = 0;
159  *raw_data = NULL;
160  *raw_data_size = 0;
161  if (NULL == bg)
162  return GNUNET_NO;
163  if (NULL == bg->serialize_cb)
164  return GNUNET_NO;
165  return bg->serialize_cb (bg,
166  nonce,
167  raw_data,
168  raw_data_size);
169 }

Referenced by 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 173 of file block.c.

174 {
175  if (NULL == bg)
176  return;
177  bg->destroy_cb (bg);
178 }

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

325 {
327  type);
328 
329  if (NULL == plugin)
331  return plugin->check_reply (plugin->cls,
332  type,
333  group,
334  query,
335  xquery,
336  xquery_size,
337  reply_block,
338  reply_block_size);
339 }

Referenced by handle_find_local_hello(), and handle_find_my_hello().

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

284 {
286  type);
287 
288  if (NULL == plugin)
289  return GNUNET_SYSERR;
290  return plugin->check_query (plugin->cls,
291  type,
292  query,
293  xquery,
294  xquery_size);
295 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93

Referenced by handle_dht_p2p_get().

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

303 {
305  type);
306 
307  if (NULL == plugin)
308  return GNUNET_SYSERR;
309  return plugin->check_block (plugin->cls,
310  type,
311  block,
312  block_size);
313 }

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

Referenced by cadet_reply_proc(), check_dht_p2p_hello(), handle_dht_local_put(), handle_dht_p2p_put(), 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 228 of file block.c.

264 {
266  type);
267 
268  if (NULL == plugin)
269  return GNUNET_SYSERR;
270  return plugin->get_key (plugin->cls,
271  type,
272  block,
273  block_size,
274  key);
275 }
struct GNUNET_HashCode key
The key used in the DHT.

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

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

346 {
347  if (NULL == bg)
348  return GNUNET_OK;
349  if (NULL == bg->mark_seen_cb)
350  return GNUNET_SYSERR;
351  bg->mark_seen_cb (bg,
352  seen_results,
353  seen_results_count);
354  return GNUNET_OK;
355 }
@ GNUNET_OK
Definition: gnunet_common.h:95

Referenced by 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 173 of file block.c.

184 {
186 
187  if (NULL == bg2)
188  return GNUNET_OK;
189  if (NULL == bg1)
190  {
191  bg2->destroy_cb (bg2);
192  return GNUNET_OK;
193  }
194  if (NULL == bg1->merge_cb)
195  return GNUNET_SYSERR;
196  GNUNET_assert (bg1->merge_cb == bg1->merge_cb);
197  ret = bg1->merge_cb (bg1,
198  bg2);
199  bg2->destroy_cb (bg2);
200  return ret;
201 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.