GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-dht_routing.c File Reference

GNUnet DHT tracking of requests for routing replies. More...

#include "platform.h"
#include "gnunet-service-dht_neighbours.h"
#include "gnunet-service-dht_routing.h"
#include "gnunet-service-dht.h"
Include dependency graph for gnunet-service-dht_routing.c:

Go to the source code of this file.

Data Structures

struct  RecentRequest
 Information we keep about all recent GET requests so that we can route replies. More...
 
struct  ProcessContext
 Closure for the 'process' function. More...
 

Macros

#define DHT_MAX_RECENT   (1024 * 16)
 Number of requests we track at most (for routing replies). More...
 

Functions

static int process (void *cls, const struct GNUNET_HashCode *key, void *value)
 Forward the result to the given peer if it matches the request. More...
 
void GDS_ROUTING_process (enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
 Handle a reply (route to origin). More...
 
static void expire_oldest_entry ()
 Remove the oldest entry from the DHT routing table. More...
 
static int try_combine_recent (void *cls, const struct GNUNET_HashCode *key, void *value)
 Try to combine multiple recent requests for the same value (if they come from the same peer). More...
 
void GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *bg, enum GNUNET_DHT_RouteOption options, const struct GNUNET_HashCode *key, const void *xquery, size_t xquery_size)
 Add a new entry to our routing table. More...
 
void GDS_ROUTING_init ()
 Initialize routing subsystem. More...
 
void GDS_ROUTING_done ()
 Shutdown routing subsystem. More...
 

Variables

static struct GNUNET_CONTAINER_Heaprecent_heap
 Recent requests by time inserted. More...
 
static struct GNUNET_CONTAINER_MultiHashMaprecent_map
 Recently seen requests by key. More...
 

Detailed Description

GNUnet DHT tracking of requests for routing replies.

Author
Christian Grothoff

Definition in file gnunet-service-dht_routing.c.

Macro Definition Documentation

◆ DHT_MAX_RECENT

#define DHT_MAX_RECENT   (1024 * 16)

Number of requests we track at most (for routing replies).

Definition at line 35 of file gnunet-service-dht_routing.c.

Referenced by GDS_ROUTING_add(), and GDS_ROUTING_init().

Function Documentation

◆ process()

static int process ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Forward the result to the given peer if it matches the request.

Parameters
clsthe struct ProcessContext with the result
keythe query
valuethe struct RecentRequest with the request
Returns
GNUNET_OK (continue to iterate), GNUNET_SYSERR if the result is malformed or type unsupported

Definition at line 158 of file gnunet-service-dht_routing.c.

References RecentRequest::bg, ProcessContext::data, ProcessContext::data_size, ProcessContext::expiration_time, GDS_block_context, GDS_NEIGHBOURS_handle_reply(), GDS_stats, ProcessContext::get_path, ProcessContext::get_path_length, gettext_noop, GNUNET_BLOCK_EO_NONE, GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_EVALUATION_OK_DUPLICATE, GNUNET_BLOCK_EVALUATION_OK_LAST, GNUNET_BLOCK_EVALUATION_OK_MORE, GNUNET_BLOCK_EVALUATION_REQUEST_INVALID, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, GNUNET_BLOCK_EVALUATION_RESULT_INVALID, GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT, GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED, GNUNET_BLOCK_get_key(), GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_break, GNUNET_DHT_RO_FIND_PEER, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, RecentRequest::key, RecentRequest::options, pc, RecentRequest::peer, ProcessContext::put_path, ProcessContext::put_path_length, RecentRequest::type, ProcessContext::type, value, RecentRequest::xquery, and RecentRequest::xquery_size.

Referenced by GDS_ROUTING_process().

161 {
162  struct ProcessContext *pc = cls;
163  struct RecentRequest *rr = value;
165  unsigned int gpl;
166  unsigned int ppl;
167  struct GNUNET_HashCode hc;
168  const struct GNUNET_HashCode *eval_key;
169 
170  if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) &&
171  (rr->type != pc->type) )
172  return GNUNET_OK; /* type missmatch */
173 
174  if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE))
175  {
176  gpl = pc->get_path_length;
177  ppl = pc->put_path_length;
178  }
179  else
180  {
181  gpl = 0;
182  ppl = 0;
183  }
184  if ( (0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) &&
186  {
187  /* key may not match HELLO, which is OK since
188  * the search is approximate. Still, the evaluation
189  * would fail since the match is not exact. So
190  * we fake it by changing the key to the actual PID ... */
193  pc->data,
194  pc->data_size,
195  &hc);
196  eval_key = &hc;
197  }
198  else
199  {
200  eval_key = key;
201  }
202  eval
204  pc->type,
205  rr->bg,
207  eval_key,
208  rr->xquery,
209  rr->xquery_size,
210  pc->data,
211  pc->data_size);
213  "Result for %s of type %d was evaluated as %d\n",
214  GNUNET_h2s (key),
215  pc->type,
216  eval);
217  switch (eval)
218  {
223  ("# Good REPLIES matched against routing table"),
224  1, GNUNET_NO);
226  pc->type,
227  pc->expiration_time,
228  key,
229  ppl, pc->put_path,
230  gpl, pc->get_path,
231  pc->data,
232  pc->data_size);
233  break;
237  ("# Duplicate REPLIES matched against routing table"),
238  1, GNUNET_NO);
239  return GNUNET_OK;
243  ("# Invalid REPLIES matched against routing table"),
244  1, GNUNET_NO);
245  return GNUNET_SYSERR;
249  ("# Irrelevant REPLIES matched against routing table"),
250  1, GNUNET_NO);
251  return GNUNET_OK;
253  GNUNET_break (0);
254  return GNUNET_OK;
256  GNUNET_break (0);
257  return GNUNET_OK;
261  ("# Unsupported REPLIES matched against routing table"),
262  1, GNUNET_NO);
263  return GNUNET_SYSERR;
264  default:
265  GNUNET_break (0);
266  return GNUNET_SYSERR;
267  }
268  return GNUNET_OK;
269 }
Block does not match query (invalid result)
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
We should keep track of the route that the message took in the P2P network.
Information we keep about all recent GET requests so that we can route replies.
Any type of block, used as a wildcard when searching.
struct GNUNET_TIME_Absolute expiration_time
Expiration time of the result.
const void * data
Payload of the reply.
Block does not match xquery (valid result, not relevant for the request)
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
size_t data_size
Number of bytes in data.
Default behavior.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int 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.
Definition: block.c:379
enum GNUNET_BLOCK_Type type
Type of the requested block.
const struct GNUNET_PeerIdentity * get_path
Path of the reply.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
This is a 'FIND-PEER' request, so approximate results are fine.
enum GNUNET_DHT_RouteOption options
Request options.
static char * value
Value of the record to add/remove.
Valid result, but suppressed because it is a duplicate.
enum GNUNET_BLOCK_EvaluationResult GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, struct GNUNET_BLOCK_Group *group, enum GNUNET_BLOCK_EvaluationOptions eo, 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 or a request.
Definition: block.c:339
unsigned int put_path_length
Number of entries in put_path.
Last possible valid result.
Type of a block that contains a HELLO for a peer (for DHT and CADET find-peer operations).
A 512-bit hashcode.
Valid result, and there may be more.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
unsigned int get_path_length
Number of entries in get_path.
Specified block type not supported by this plugin.
Closure for the 'process' function.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
struct GNUNET_PeerIdentity peer
The peer this request was received from.
Query format does not match block type (invalid query).
#define GNUNET_log(kind,...)
enum GNUNET_BLOCK_Type type
Type of the reply.
const struct GNUNET_PeerIdentity * put_path
Path of the original PUT.
const void * xquery
extended query (see gnunet_block_lib.h).
Query is valid, no reply given.
void GDS_NEIGHBOURS_handle_reply(const struct GNUNET_PeerIdentity *target, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration_time, const struct GNUNET_HashCode *key, unsigned int put_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *get_path, const void *data, size_t data_size)
Handle a reply (route to origin).
#define gettext_noop(String)
Definition: gettext.h:69
size_t xquery_size
Number of bytes in xquery.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_ROUTING_process()

void GDS_ROUTING_process ( enum GNUNET_BLOCK_Type  type,
struct GNUNET_TIME_Absolute  expiration_time,
const struct GNUNET_HashCode key,
unsigned int  put_path_length,
const struct GNUNET_PeerIdentity put_path,
unsigned int  get_path_length,
const struct GNUNET_PeerIdentity get_path,
const void *  data,
size_t  data_size 
)

Handle a reply (route to origin).

Only forwards the reply back to other peers waiting for it. Does not do local caching or forwarding to local clients. Essentially calls GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching request recently.

Parameters
typetype of the block
expiration_timewhen does the content expire
keykey for the content
put_path_lengthnumber of entries in put_path
put_pathpeers the original PUT traversed (if tracked)
get_path_lengthnumber of entries in get_path
get_pathpeers this reply has traversed so far (if tracked)
datapayload of the reply
data_sizenumber of bytes in data

Definition at line 290 of file gnunet-service-dht_routing.c.

References data, ProcessContext::data, ProcessContext::data_size, data_size, ProcessContext::expiration_time, ProcessContext::get_path, ProcessContext::get_path_length, GNUNET_break, GNUNET_CONTAINER_multihashmap_get_multiple(), process(), ProcessContext::put_path, ProcessContext::put_path_length, RecentRequest::type, and ProcessContext::type.

Referenced by process_reply_with_path().

299 {
300  struct ProcessContext pc;
301 
302  pc.type = type;
303  pc.expiration_time = expiration_time;
304  pc.put_path_length = put_path_length;
305  pc.put_path = put_path;
306  pc.get_path_length = get_path_length;
307  pc.get_path = get_path;
308  pc.data = data;
309  pc.data_size = data_size;
310  if (NULL == data)
311  {
312  /* Some apps might have an 'empty' reply as a valid reply; however,
313  'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
314  reply as request-validation (but we need response-validation).
315  So we set 'data' to a 0-byte non-NULL value just to be sure */
316  GNUNET_break (0 == data_size);
317  pc.data_size = 0;
318  pc.data = ""; /* something not null */
319  }
321  key,
322  &process,
323  &pc);
324 }
struct GNUNET_TIME_Absolute expiration_time
Expiration time of the result.
static int process(void *cls, const struct GNUNET_HashCode *key, void *value)
Forward the result to the given peer if it matches the request.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const struct GNUNET_PeerIdentity * get_path
Path of the reply.
unsigned int put_path_length
Number of entries in put_path.
unsigned int get_path_length
Number of entries in get_path.
Closure for the 'process' function.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
const struct GNUNET_PeerIdentity * put_path
Path of the original PUT.
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expire_oldest_entry()

static void expire_oldest_entry ( )
static

Remove the oldest entry from the DHT routing table.

Must only be called if it is known that there is at least one entry in the heap and hashmap.

Definition at line 333 of file gnunet-service-dht_routing.c.

References RecentRequest::bg, GDS_stats, gettext_noop, GNUNET_assert, GNUNET_BLOCK_group_destroy(), GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, RecentRequest::heap_node, and RecentRequest::key.

Referenced by GDS_ROUTING_add(), and GDS_ROUTING_done().

334 {
335  struct RecentRequest *recent_req;
336 
339  ("# Entries removed from routing table"), 1,
340  GNUNET_NO);
342  GNUNET_assert (recent_req != NULL);
344  GNUNET_BLOCK_group_destroy (recent_req->bg);
347  &recent_req->key,
348  recent_req));
349  GNUNET_free (recent_req);
350 }
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
Information we keep about all recent GET requests so that we can route replies.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_HashCode key
Key of this request.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_CONTAINER_Heap * recent_heap
Recent requests by time inserted.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
#define GNUNET_YES
Definition: gnunet_common.h:80
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
struct GNUNET_CONTAINER_HeapNode * heap_node
Position of this node in the min heap.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg)
Destroy resources used by a block group.
Definition: block.c:206
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_combine_recent()

static int try_combine_recent ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Try to combine multiple recent requests for the same value (if they come from the same peer).

Parameters
clsthe new 'struct RecentRequest' (to discard upon successful combination)
keythe query
valuethe existing 'struct RecentRequest' (to update upon successful combination)
Returns
GNUNET_OK (continue to iterate), GNUNET_SYSERR if the request was successfully combined

Definition at line 364 of file gnunet-service-dht_routing.c.

References RecentRequest::bg, GNUNET_BLOCK_group_merge(), GNUNET_break, GNUNET_free, GNUNET_memcmp, GNUNET_OK, GNUNET_SYSERR, RecentRequest::peer, RecentRequest::type, value, RecentRequest::xquery, and RecentRequest::xquery_size.

Referenced by GDS_ROUTING_add().

367 {
368  struct RecentRequest *in = cls;
369  struct RecentRequest *rr = value;
370 
371  if ( (0 != GNUNET_memcmp (&in->peer,
372  &rr->peer)) ||
373  (in->type != rr->type) ||
374  (in->xquery_size != rr->xquery_size) ||
375  (0 != memcmp (in->xquery,
376  rr->xquery,
377  in->xquery_size)) )
378  return GNUNET_OK;
381  rr->bg));
382  rr->bg = in->bg;
383  GNUNET_free (in);
384  return GNUNET_SYSERR;
385 }
Information we keep about all recent GET requests so that we can route replies.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum GNUNET_BLOCK_Type type
Type of the requested block.
int GNUNET_BLOCK_group_merge(struct GNUNET_BLOCK_Group *bg1, struct GNUNET_BLOCK_Group *bg2)
Try merging two block groups.
Definition: block.c:227
static char * value
Value of the record to add/remove.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_PeerIdentity peer
The peer this request was received from.
const void * xquery
extended query (see gnunet_block_lib.h).
#define GNUNET_free(ptr)
Wrapper around free.
size_t xquery_size
Number of bytes in xquery.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_ROUTING_add()

void GDS_ROUTING_add ( const struct GNUNET_PeerIdentity sender,
enum GNUNET_BLOCK_Type  type,
struct GNUNET_BLOCK_Group bg,
enum GNUNET_DHT_RouteOption  options,
const struct GNUNET_HashCode key,
const void *  xquery,
size_t  xquery_size 
)

Add a new entry to our routing table.

Parameters
senderpeer that originated the request
typetype of the block
optionsoptions for processing
keykey for the content
xqueryextended query
xquery_sizenumber of bytes in xquery
reply_bfbloomfilter to filter duplicates
reply_bf_mutatormutator for reply_bf

Definition at line 401 of file gnunet-service-dht_routing.c.

References RecentRequest::bg, DHT_MAX_RECENT, expire_oldest_entry(), GDS_stats, gettext_noop, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), RecentRequest::heap_node, RecentRequest::key, RecentRequest::options, RecentRequest::peer, try_combine_recent(), RecentRequest::type, RecentRequest::xquery, and RecentRequest::xquery_size.

Referenced by handle_dht_p2p_get().

408 {
409  struct RecentRequest *recent_req;
410 
414  gettext_noop ("# Entries added to routing table"),
415  1,
416  GNUNET_NO);
417  recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size);
418  recent_req->peer = *sender;
419  recent_req->key = *key;
420  recent_req->bg = bg;
421  recent_req->type = type;
422  recent_req->options = options;
423  recent_req->xquery = &recent_req[1];
424  GNUNET_memcpy (&recent_req[1],
425  xquery,
426  xquery_size);
427  recent_req->xquery_size = xquery_size;
428  if (GNUNET_SYSERR ==
430  key,
432  recent_req))
433  {
436  ("# DHT requests combined"),
437  1, GNUNET_NO);
438  return;
439  }
440  recent_req->heap_node
442  recent_req,
443  GNUNET_TIME_absolute_get ().abs_value_us);
445  key,
446  recent_req,
448 }
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
Information we keep about all recent GET requests so that we can route replies.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_HashCode key
Key of this request.
#define DHT_MAX_RECENT
Number of requests we track at most (for routing replies).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
enum GNUNET_BLOCK_Type type
Type of the requested block.
#define GNUNET_memcpy(dst, src, n)
enum GNUNET_DHT_RouteOption options
Request options.
static struct GNUNET_CONTAINER_Heap * recent_heap
Recent requests by time inserted.
static void expire_oldest_entry()
Remove the oldest entry from the DHT routing table.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Allow multiple values with the same key.
struct GNUNET_PeerIdentity peer
The peer this request was received from.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
const void * xquery
extended query (see gnunet_block_lib.h).
static int try_combine_recent(void *cls, const struct GNUNET_HashCode *key, void *value)
Try to combine multiple recent requests for the same value (if they come from the same peer)...
struct GNUNET_CONTAINER_HeapNode * heap_node
Position of this node in the min heap.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define gettext_noop(String)
Definition: gettext.h:69
size_t xquery_size
Number of bytes in xquery.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_ROUTING_init()

void GDS_ROUTING_init ( void  )

Initialize routing subsystem.

Definition at line 455 of file gnunet-service-dht_routing.c.

References DHT_MAX_RECENT, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), and GNUNET_NO.

Referenced by run().

456 {
459 }
#define GNUNET_NO
Definition: gnunet_common.h:81
#define DHT_MAX_RECENT
Number of requests we track at most (for routing replies).
static struct GNUNET_CONTAINER_Heap * recent_heap
Recent requests by time inserted.
Heap with the minimum cost at the root.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GDS_ROUTING_done()

void GDS_ROUTING_done ( void  )

Shutdown routing subsystem.

Definition at line 466 of file gnunet-service-dht_routing.c.

References expire_oldest_entry(), GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_multihashmap_destroy(), and GNUNET_CONTAINER_multihashmap_size().

Referenced by shutdown_task().

467 {
472  recent_heap = NULL;
475  recent_map = NULL;
476 }
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CONTAINER_Heap * recent_heap
Recent requests by time inserted.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static void expire_oldest_entry()
Remove the oldest entry from the DHT routing table.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ recent_heap

struct GNUNET_CONTAINER_Heap* recent_heap
static

Recent requests by time inserted.

Definition at line 92 of file gnunet-service-dht_routing.c.

◆ recent_map

struct GNUNET_CONTAINER_MultiHashMap* recent_map
static

Recently seen requests by key.

Definition at line 97 of file gnunet-service-dht_routing.c.