![]() |
GNUnet
0.11.x
|
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"
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_Heap * | recent_heap |
Recent requests by time inserted. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | recent_map |
Recently seen requests by key. More... | |
GNUnet DHT tracking of requests for routing replies.
Definition in file gnunet-service-dht_routing.c.
#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().
|
static |
Forward the result to the given peer if it matches the request.
cls | the struct ProcessContext with the result |
key | the query |
value | the struct RecentRequest with the request |
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().
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.
type | type of the block |
expiration_time | when does the content expire |
key | key for the content |
put_path_length | number of entries in put_path |
put_path | peers the original PUT traversed (if tracked) |
get_path_length | number of entries in get_path |
get_path | peers this reply has traversed so far (if tracked) |
data | payload of the reply |
data_size | number 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().
|
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().
|
static |
Try to combine multiple recent requests for the same value (if they come from the same peer).
cls | the new 'struct RecentRequest' (to discard upon successful combination) |
key | the query |
value | the existing 'struct RecentRequest' (to update upon successful combination) |
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().
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.
sender | peer that originated the request |
type | type of the block |
options | options for processing |
key | key for the content |
xquery | extended query |
xquery_size | number of bytes in xquery |
reply_bf | bloomfilter to filter duplicates |
reply_bf_mutator | mutator 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().
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().
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().
|
static |
Recent requests by time inserted.
Definition at line 90 of file gnunet-service-dht_routing.c.
|
static |
Recently seen requests by key.
Definition at line 95 of file gnunet-service-dht_routing.c.