GNUnet  0.11.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 155 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().

158 {
159  struct ProcessContext *pc = cls;
160  struct RecentRequest *rr = value;
162  unsigned int gpl;
163  unsigned int ppl;
164  struct GNUNET_HashCode hc;
165  const struct GNUNET_HashCode *eval_key;
166 
167  if ((rr->type != GNUNET_BLOCK_TYPE_ANY) &&
168  (rr->type != pc->type))
169  return GNUNET_OK; /* type missmatch */
170 
171  if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE))
172  {
173  gpl = pc->get_path_length;
174  ppl = pc->put_path_length;
175  }
176  else
177  {
178  gpl = 0;
179  ppl = 0;
180  }
181  if ((0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) &&
183  {
184  /* key may not match HELLO, which is OK since
185  * the search is approximate. Still, the evaluation
186  * would fail since the match is not exact. So
187  * we fake it by changing the key to the actual PID ... */
190  pc->data,
191  pc->data_size,
192  &hc);
193  eval_key = &hc;
194  }
195  else
196  {
197  eval_key = key;
198  }
199  eval
201  pc->type,
202  rr->bg,
204  eval_key,
205  rr->xquery,
206  rr->xquery_size,
207  pc->data,
208  pc->data_size);
210  "Result for %s of type %d was evaluated as %d\n",
211  GNUNET_h2s (key),
212  pc->type,
213  eval);
214  switch (eval)
215  {
220  ("# Good REPLIES matched against routing table"),
221  1, GNUNET_NO);
223  pc->type,
224  pc->expiration_time,
225  key,
226  ppl, pc->put_path,
227  gpl, pc->get_path,
228  pc->data,
229  pc->data_size);
230  break;
231 
235  (
236  "# Duplicate REPLIES matched against routing table"),
237  1, GNUNET_NO);
238  return GNUNET_OK;
239 
243  (
244  "# Invalid REPLIES matched against routing table"),
245  1, GNUNET_NO);
246  return GNUNET_SYSERR;
247 
251  (
252  "# Irrelevant REPLIES matched against routing table"),
253  1, GNUNET_NO);
254  return GNUNET_OK;
255 
257  GNUNET_break (0);
258  return GNUNET_OK;
259 
261  GNUNET_break (0);
262  return GNUNET_OK;
263 
267  (
268  "# Unsupported REPLIES matched against routing table"),
269  1, GNUNET_NO);
270  return GNUNET_SYSERR;
271 
272  default:
273  GNUNET_break (0);
274  return GNUNET_SYSERR;
275  }
276  return GNUNET_OK;
277 }
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:378
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:338
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 298 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().

307 {
308  struct ProcessContext pc;
309 
310  pc.type = type;
311  pc.expiration_time = expiration_time;
312  pc.put_path_length = put_path_length;
313  pc.put_path = put_path;
314  pc.get_path_length = get_path_length;
315  pc.get_path = get_path;
316  pc.data = data;
317  pc.data_size = data_size;
318  if (NULL == data)
319  {
320  /* Some apps might have an 'empty' reply as a valid reply; however,
321  'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
322  reply as request-validation (but we need response-validation).
323  So we set 'data' to a 0-byte non-NULL value just to be sure */
324  GNUNET_break (0 == data_size);
325  pc.data_size = 0;
326  pc.data = ""; /* something not null */
327  }
329  key,
330  &process,
331  &pc);
332 }
struct GNUNET_TIME_Absolute expiration_time
Expiration time of the result.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
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.
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 341 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().

342 {
343  struct RecentRequest *recent_req;
344 
347  ("# Entries removed from routing table"), 1,
348  GNUNET_NO);
350  GNUNET_assert (recent_req != NULL);
352  GNUNET_BLOCK_group_destroy (recent_req->bg);
355  &recent_req->key,
356  recent_req));
357  GNUNET_free (recent_req);
358 }
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:205
#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 372 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().

375 {
376  struct RecentRequest *in = cls;
377  struct RecentRequest *rr = value;
378 
379  if ((0 != GNUNET_memcmp (&in->peer,
380  &rr->peer)) ||
381  (in->type != rr->type) ||
382  (in->xquery_size != rr->xquery_size) ||
383  (0 != memcmp (in->xquery,
384  rr->xquery,
385  in->xquery_size)))
386  return GNUNET_OK;
389  rr->bg));
390  rr->bg = in->bg;
391  GNUNET_free (in);
392  return GNUNET_SYSERR;
393 }
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:226
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 409 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().

416 {
417  struct RecentRequest *recent_req;
418 
422  gettext_noop ("# Entries added to routing table"),
423  1,
424  GNUNET_NO);
425  recent_req = GNUNET_malloc (sizeof(struct RecentRequest) + xquery_size);
426  recent_req->peer = *sender;
427  recent_req->key = *key;
428  recent_req->bg = bg;
429  recent_req->type = type;
430  recent_req->options = options;
431  recent_req->xquery = &recent_req[1];
432  GNUNET_memcpy (&recent_req[1],
433  xquery,
434  xquery_size);
435  recent_req->xquery_size = xquery_size;
436  if (GNUNET_SYSERR ==
438  key,
440  recent_req))
441  {
444  ("# DHT requests combined"),
445  1, GNUNET_NO);
446  return;
447  }
448  recent_req->heap_node
450  recent_req,
451  GNUNET_TIME_absolute_get ().abs_value_us);
453  key,
454  recent_req,
456 }
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 463 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().

464 {
467  GNUNET_NO);
468 }
#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 475 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().

476 {
481  recent_heap = NULL;
484  recent_map = NULL;
485 }
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 90 of file gnunet-service-dht_routing.c.

◆ recent_map

struct GNUNET_CONTAINER_MultiHashMap* recent_map
static

Recently seen requests by key.

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