GNUnet 0.22.2
gnunet-service-dht_routing.h File Reference

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

Include dependency graph for gnunet-service-dht_routing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GDS_ROUTING_process (const struct GNUNET_DATACACHE_Block *bd, const struct GNUNET_HashCode *query_hash, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *get_path)
 Handle a reply (route to origin). 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 (void)
 Initialize routing subsystem. More...
 
void GDS_ROUTING_done (void)
 Shutdown routing subsystem. More...
 

Detailed Description

GNUnet DHT tracking of requests for routing replies.

Author
Christian Grothoff

Definition in file gnunet-service-dht_routing.h.

Function Documentation

◆ GDS_ROUTING_process()

void GDS_ROUTING_process ( const struct GNUNET_DATACACHE_Block bd,
const struct GNUNET_HashCode query_hash,
unsigned int  get_path_length,
const struct GNUNET_DHT_PathElement get_path 
)

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
bdblock details
query_hashquery used in the inquiry
get_path_lengthnumber of entries in get_path
get_pathpeers this reply has traversed so far (if tracked)

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

259{
260 struct ProcessContext pc = {
261 .bd = bd,
262 .get_path = get_path,
263 .get_path_length = get_path_length
264 };
265
267 query_hash,
268 &process,
269 &pc);
270}
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static enum GNUNET_GenericReturnValue process(void *cls, const struct GNUNET_HashCode *query_hash, void *value)
Forward the result to the given peer if it matches the request.
static struct GNUNET_CONTAINER_MultiHashMap * recent_map
Recently seen requests by key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
Closure for the process() function.
const struct GNUNET_DHT_PathElement * get_path
Path of the reply.
const struct GNUNET_DATACACHE_Block * bd
Block data.
unsigned int get_path_length
Number of entries in get_path.

References ProcessContext::bd, ProcessContext::get_path, ProcessContext::get_path_length, GNUNET_CONTAINER_multihashmap_get_multiple(), pc, process(), and recent_map.

Referenced by process_reply_with_path().

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
bgblock group to evaluate replies, henceforth owned by routing
optionsoptions for processing
keykey for the content
xqueryextended query
xquery_sizenumber of bytes in xquery
senderpeer that originated the request
typetype of the block
[in]bgblock group for filtering duplicate replies
optionsoptions for processing
keykey for the content
xqueryextended query
xquery_sizenumber of bytes in xquery

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

353{
354 struct RecentRequest *recent_req;
355
359 "# Entries added to routing table",
360 1,
361 GNUNET_NO);
362 recent_req = GNUNET_malloc (sizeof(struct RecentRequest) + xquery_size);
363 recent_req->peer = *sender;
364 recent_req->key = *key;
365 recent_req->bg = bg;
366 recent_req->type = type;
367 recent_req->options = options;
368 recent_req->xquery = &recent_req[1];
369 GNUNET_memcpy (&recent_req[1],
370 xquery,
372 recent_req->xquery_size = xquery_size;
373 if (GNUNET_SYSERR ==
375 key,
377 recent_req))
378 {
380 "# DHT requests combined",
381 1,
382 GNUNET_NO);
383 return;
384 }
385 recent_req->heap_node
388 recent_req,
389 GNUNET_TIME_absolute_get ().abs_value_us);
392 key,
393 recent_req,
395}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_HashCode key
The key used in the DHT.
static uint32_t type
Type string converted to DNS type value.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
static enum GNUNET_GenericReturnValue 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).
#define DHT_MAX_RECENT
Number of requests we track at most (for routing replies).
static void expire_oldest_entry(void)
Remove the oldest entry from the DHT routing table.
static struct GNUNET_CONTAINER_Heap * recent_heap
Recent requests by time inserted.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
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.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
Information we keep about all recent GET requests so that we can route replies.
size_t xquery_size
Number of bytes in xquery.
enum GNUNET_BLOCK_Type type
Type of the requested block.
struct GNUNET_HashCode key
Key of this request.
struct GNUNET_BLOCK_Group * bg
Block group for filtering replies.
struct GNUNET_CONTAINER_HeapNode * heap_node
Position of this node in the min heap.
enum GNUNET_DHT_RouteOption options
Request options.
struct GNUNET_PeerIdentity peer
The peer this request was received from.
const void * xquery
extended query (see gnunet_block_lib.h).

References RecentRequest::bg, DHT_MAX_RECENT, expire_oldest_entry(), GDS_stats, 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, key, RecentRequest::key, options, RecentRequest::options, RecentRequest::peer, recent_heap, recent_map, try_combine_recent(), type, RecentRequest::type, RecentRequest::xquery, and RecentRequest::xquery_size.

Referenced by handle_dht_p2p_get().

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 402 of file gnunet-service-dht_routing.c.

403{
406 GNUNET_NO);
407}
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.

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

Referenced by run().

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 414 of file gnunet-service-dht_routing.c.

415{
418 GNUNET_assert (0 ==
421 recent_heap = NULL;
422 GNUNET_assert (0 ==
425 recent_map = NULL;
426}
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

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

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function: