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 153 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().

156 {
157  struct ProcessContext *pc = cls;
158  struct RecentRequest *rr = value;
160  unsigned int gpl;
161  unsigned int ppl;
162  struct GNUNET_HashCode hc;
163  const struct GNUNET_HashCode *eval_key;
164 
165  if ((rr->type != GNUNET_BLOCK_TYPE_ANY) &&
166  (rr->type != pc->type))
167  return GNUNET_OK; /* type missmatch */
168 
169  if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE))
170  {
171  gpl = pc->get_path_length;
172  ppl = pc->put_path_length;
173  }
174  else
175  {
176  gpl = 0;
177  ppl = 0;
178  }
179  if ((0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) &&
181  {
182  /* key may not match HELLO, which is OK since
183  * the search is approximate. Still, the evaluation
184  * would fail since the match is not exact. So
185  * we fake it by changing the key to the actual PID ... */
188  pc->data,
189  pc->data_size,
190  &hc);
191  eval_key = &hc;
192  }
193  else
194  {
195  eval_key = key;
196  }
197  eval
199  pc->type,
200  rr->bg,
202  eval_key,
203  rr->xquery,
204  rr->xquery_size,
205  pc->data,
206  pc->data_size);
208  "Result for %s of type %d was evaluated as %d\n",
209  GNUNET_h2s(key),
210  pc->type,
211  eval);
212  switch (eval)
213  {
218  ("# Good REPLIES matched against routing table"),
219  1, GNUNET_NO);
221  pc->type,
222  pc->expiration_time,
223  key,
224  ppl, pc->put_path,
225  gpl, pc->get_path,
226  pc->data,
227  pc->data_size);
228  break;
229 
233  ("# Duplicate REPLIES matched against routing table"),
234  1, GNUNET_NO);
235  return GNUNET_OK;
236 
240  ("# Invalid REPLIES matched against routing table"),
241  1, GNUNET_NO);
242  return GNUNET_SYSERR;
243 
247  ("# Irrelevant REPLIES matched against routing table"),
248  1, GNUNET_NO);
249  return GNUNET_OK;
250 
252  GNUNET_break(0);
253  return GNUNET_OK;
254 
256  GNUNET_break(0);
257  return GNUNET_OK;
258 
262  ("# Unsupported REPLIES matched against routing table"),
263  1, GNUNET_NO);
264  return GNUNET_SYSERR;
265 
266  default:
267  GNUNET_break(0);
268  return GNUNET_SYSERR;
269  }
270  return GNUNET_OK;
271 }
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:78
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:75
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:377
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:337
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:76
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 292 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().

301 {
302  struct ProcessContext pc;
303 
304  pc.type = type;
305  pc.expiration_time = expiration_time;
306  pc.put_path_length = put_path_length;
307  pc.put_path = put_path;
308  pc.get_path_length = get_path_length;
309  pc.get_path = get_path;
310  pc.data = data;
311  pc.data_size = data_size;
312  if (NULL == data)
313  {
314  /* Some apps might have an 'empty' reply as a valid reply; however,
315  'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
316  reply as request-validation (but we need response-validation).
317  So we set 'data' to a 0-byte non-NULL value just to be sure */
318  GNUNET_break(0 == data_size);
319  pc.data_size = 0;
320  pc.data = ""; /* something not null */
321  }
323  key,
324  &process,
325  &pc);
326 }
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 335 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().

336 {
337  struct RecentRequest *recent_req;
338 
341  ("# Entries removed from routing table"), 1,
342  GNUNET_NO);
344  GNUNET_assert(recent_req != NULL);
346  GNUNET_BLOCK_group_destroy(recent_req->bg);
349  &recent_req->key,
350  recent_req));
351  GNUNET_free(recent_req);
352 }
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:78
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:77
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:204
#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 366 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().

369 {
370  struct RecentRequest *in = cls;
371  struct RecentRequest *rr = value;
372 
373  if ((0 != GNUNET_memcmp(&in->peer,
374  &rr->peer)) ||
375  (in->type != rr->type) ||
376  (in->xquery_size != rr->xquery_size) ||
377  (0 != memcmp(in->xquery,
378  rr->xquery,
379  in->xquery_size)))
380  return GNUNET_OK;
383  rr->bg));
384  rr->bg = in->bg;
385  GNUNET_free(in);
386  return GNUNET_SYSERR;
387 }
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:75
#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:225
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:76
#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 403 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().

410 {
411  struct RecentRequest *recent_req;
412 
416  gettext_noop("# Entries added to routing table"),
417  1,
418  GNUNET_NO);
419  recent_req = GNUNET_malloc(sizeof(struct RecentRequest) + xquery_size);
420  recent_req->peer = *sender;
421  recent_req->key = *key;
422  recent_req->bg = bg;
423  recent_req->type = type;
424  recent_req->options = options;
425  recent_req->xquery = &recent_req[1];
426  GNUNET_memcpy(&recent_req[1],
427  xquery,
428  xquery_size);
429  recent_req->xquery_size = xquery_size;
430  if (GNUNET_SYSERR ==
432  key,
434  recent_req))
435  {
438  ("# DHT requests combined"),
439  1, GNUNET_NO);
440  return;
441  }
442  recent_req->heap_node
444  recent_req,
445  GNUNET_TIME_absolute_get().abs_value_us);
447  key,
448  recent_req,
450 }
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
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.
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:76
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 457 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().

458 {
461 }
#define GNUNET_NO
Definition: gnunet_common.h:78
#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 468 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().

469 {
474  recent_heap = NULL;
477  recent_map = NULL;
478 }
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 89 of file gnunet-service-dht_routing.c.

◆ recent_map

struct GNUNET_CONTAINER_MultiHashMap* recent_map
static

Recently seen requests by key.

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