GNUnet DHT service. More...
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_block_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_pils_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-dht.h"
#include "gnunet-service-dht_datacache.h"
#include "gnunet-service-dht_neighbours.h"
#include "gnunet-service-dht_routing.h"
#include "plugin_dhtu_ip.h"
#include "plugin_dhtu_gnunet.h"
#include "gnunet-service-dht_clients.c"
Go to the source code of this file.
Data Structures | |
struct | GDS_Underlay |
Information we keep per underlay. More... | |
struct | MyAddress |
An address of this peer. More... | |
struct | PilsRequest |
DLL. More... | |
Macros | |
#define | HELLO_FREQUENCY GNUNET_TIME_UNIT_HOURS |
How often do we broadcast our HELLO to neighbours if nothing special happens? | |
Functions | |
static void | update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) |
Callback that is called when network size estimate is updated. | |
double | GDS_NSE_get (void) |
Return the current NSE. | |
static void | u_address_add (void *cls, const char *address, struct GNUNET_DHTU_Source *source, void **ctx) |
Function to call with new addresses of this peer. | |
static void | u_address_del (void *ctx) |
Function to call with expired addresses of this peer. | |
void | GDS_u_try_connect (const struct GNUNET_PeerIdentity *pid, const char *address) |
Ask all underlays to connect to peer pid at address. | |
void | GDS_u_send (struct GDS_Underlay *u, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls) |
Send message to some other participant over the network. | |
void | GDS_u_drop (struct GDS_Underlay *u, struct GNUNET_DHTU_PreferenceHandle *ph) |
Drop a hold ph from underlay u. | |
struct GNUNET_DHTU_PreferenceHandle * | GDS_u_hold (struct GDS_Underlay *u, struct GNUNET_DHTU_Target *target) |
Create a hold on target at underlay u. | |
static void | shutdown_task (void *cls) |
Task run during shutdown. | |
static void | load_underlay (void *cls, const char *section) |
Function iterating over all configuration sections. | |
static void | pid_change_cb (void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash) |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Process dht requests. | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "dht", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(dht_local_put, GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT, struct GNUNET_DHT_ClientPutMessage, NULL), GNUNET_MQ_hd_var_size(dht_local_get, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET, struct GNUNET_DHT_ClientGetMessage, NULL), GNUNET_MQ_hd_fixed_size(dht_local_get_stop, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP, struct GNUNET_DHT_ClientGetStopMessage, NULL), GNUNET_MQ_hd_fixed_size(dht_local_monitor, GNUNET_MESSAGE_TYPE_DHT_MONITOR_START, struct GNUNET_DHT_MonitorStartStopMessage, NULL), GNUNET_MQ_hd_fixed_size(dht_local_monitor_stop, GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP, struct GNUNET_DHT_MonitorStartStopMessage, NULL), GNUNET_MQ_hd_var_size(dht_local_get_result_seen, GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, struct GNUNET_DHT_ClientGetResultSeenMessage, NULL), GNUNET_MQ_hd_fixed_size(dht_local_hello_get, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_GET, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(dht_local_hello_offer, GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end()) | |
Variables | |
static struct PilsRequest * | pils_requests_head |
PILS Operation DLL. | |
static struct PilsRequest * | pils_requests_tail |
PILS Operation DLL. | |
struct GNUNET_MessageHeader * | GDS_my_hello |
Our HELLO. | |
struct GNUNET_PeerIdentity | GDS_my_identity |
Identity of this peer. | |
struct GNUNET_HashCode | GDS_my_identity_hash |
Hash of the identity of this peer. | |
struct GNUNET_CRYPTO_EddsaPrivateKey | GDS_my_private_key |
Our private key. | |
static struct GDS_Underlay * | u_head |
Handles for the DHT underlays. | |
static struct GDS_Underlay * | u_tail |
Handles for the DHT underlays. | |
static struct MyAddress * | a_head |
Head of addresses of this peer. | |
static struct MyAddress * | a_tail |
Tail of addresses of this peer. | |
static double | log_of_network_size_estimate |
log of the current network size estimate, used as the point where we switch between random and deterministic routing. | |
GNUnet DHT service.
Definition in file gnunet-service-dht.c.
#define HELLO_FREQUENCY GNUNET_TIME_UNIT_HOURS |
How often do we broadcast our HELLO to neighbours if nothing special happens?
Definition at line 45 of file gnunet-service-dht.c.
|
static |
Callback that is called when network size estimate is updated.
cls | a struct GDS_Underlay |
timestamp | time when the estimate was received from the server (or created by the server) |
logestimate | the log(Base 2) value of the current network size estimate |
std_dev | standard deviation for the estimate |
Definition at line 206 of file gnunet-service-dht.c.
References GDS_stats, GNUNET_MAX, GNUNET_NO, GNUNET_STATISTICS_update(), log_of_network_size_estimate, p, u, and u_head.
double GDS_NSE_get | ( | void | ) |
Return the current NSE.
Definition at line 237 of file gnunet-service-dht.c.
References log_of_network_size_estimate.
Referenced by get_forward_count(), handle_find_local_hello(), and select_peer().
|
static |
Function to call with new addresses of this peer.
cls | the closure | |
address | address under which we are likely reachable, pointer will remain valid until address_del_cb is called; to be used for HELLOs. Example: "ip+udp://$PID/1.1.1.1:2086/" | |
source | handle for sending from this address, NULL if we can only receive | |
[out] | ctx | storage space for DHT to use in association with this address |
Definition at line 256 of file gnunet-service-dht.c.
References a_head, a_tail, address, ctx, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_strdup, source, MyAddress::source, u, MyAddress::u, and MyAddress::url.
Referenced by load_underlay().
|
static |
Function to call with expired addresses of this peer.
[in] | ctx | storage space used by the DHT in association with this address |
Definition at line 285 of file gnunet-service-dht.c.
References a_head, a_tail, ctx, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, and MyAddress::url.
Referenced by load_underlay().
void GDS_u_try_connect | ( | const struct GNUNET_PeerIdentity * | pid, |
const char * | address | ||
) |
Ask all underlays to connect to peer pid at address.
pid | identity of the peer we would connect to |
address | an address of pid |
Definition at line 301 of file gnunet-service-dht.c.
References address, GDS_Underlay::next, pid, u, and u_head.
Referenced by GDS_try_connect().
void GDS_u_send | ( | struct GDS_Underlay * | u, |
struct GNUNET_DHTU_Target * | target, | ||
const void * | msg, | ||
size_t | msg_size, | ||
GNUNET_SCHEDULER_TaskCallback | finished_cb, | ||
void * | finished_cb_cls | ||
) |
Send message to some other participant over the network.
Note that sending is not guaranteeing that the other peer actually received the message. For any given target, the DHT must wait for the finished_cb to be called before calling send() again.
u | underlay to use for transmission |
target | receiver identification |
msg | message |
msg_size | number of bytes in msg |
finished_cb | function called once transmission is done (not called if target disconnects, then only the disconnect_cb is called). |
finished_cb_cls | closure for finished_cb |
Definition at line 314 of file gnunet-service-dht.c.
References finished_cb(), msg, and u.
Referenced by do_send().
void GDS_u_drop | ( | struct GDS_Underlay * | u, |
struct GNUNET_DHTU_PreferenceHandle * | ph | ||
) |
Drop a hold ph from underlay u.
u | the underlay controlling the hold |
ph | the preference handle |
Definition at line 331 of file gnunet-service-dht.c.
References u.
Referenced by GDS_u_disconnect().
struct GNUNET_DHTU_PreferenceHandle * GDS_u_hold | ( | struct GDS_Underlay * | u, |
struct GNUNET_DHTU_Target * | target | ||
) |
Create a hold on target at underlay u.
u | the underlay controlling the target |
target | the peer to hold the connection to |
Definition at line 339 of file gnunet-service-dht.c.
References GNUNET_DHTU_PreferenceHandle::target, and u.
Referenced by update_hold().
|
static |
Task run during shutdown.
cls | unused |
Definition at line 353 of file gnunet-service-dht.c.
References DHTU_gnunet_done(), DHTU_ip_done(), GDS_block_context, GDS_CLIENTS_stop(), GDS_DATACACHE_done(), GDS_my_hello, GDS_NEIGHBOURS_done(), GDS_pils, GDS_ROUTING_done(), GDS_stats, GNUNET_assert, GNUNET_BLOCK_context_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PILS_cancel(), GNUNET_PILS_disconnect(), GNUNET_STATISTICS_destroy(), GNUNET_YES, PilsRequest::op, pils_requests_head, pils_requests_tail, u, u_head, and u_tail.
|
static |
Function iterating over all configuration sections.
Loads plugins for enabled DHT underlays.
cls | NULL |
section | configuration section to inspect |
NOTE: This is not pretty, but it allows us to avoid dynamically loading plugins
Definition at line 425 of file gnunet-service-dht.c.
References DHTU_gnunet_init(), DHTU_ip_init(), GDS_cfg, GDS_u_connect(), GDS_u_disconnect(), GDS_u_receive(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_new, GNUNET_strdup, GNUNET_YES, u, u_address_add(), u_address_del(), u_head, u_tail, and update_network_size_estimate().
Referenced by run().
|
static |
Definition at line 476 of file gnunet-service-dht.c.
References GDS_my_hello, GDS_my_identity, GDS_my_identity_hash, GDS_NEIGHBOURS_broadcast(), GNUNET_break, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_HELLO_parser_get_id(), and GNUNET_HELLO_parser_to_dht_hello_msg().
Referenced by run().
|
static |
Process dht requests.
cls | closure |
c | configuration to use |
service | the initialized service |
Definition at line 507 of file gnunet-service-dht.c.
References GDS_block_context, GDS_cfg, GDS_CLIENTS_init(), GDS_DATACACHE_init(), GDS_my_identity, GDS_my_identity_hash, GDS_my_private_key, GDS_NEIGHBOURS_init(), GDS_pils, GDS_ROUTING_init(), GDS_service, GDS_stats, GNUNET_assert, GNUNET_BLOCK_context_create(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_PILS_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_SYSERR, GNUNET_YES, load_underlay(), pid_change_cb(), GNUNET_PeerIdentity::public_key, service, shutdown_task, and u_head.
|
static |
PILS Operation DLL.
Definition at line 141 of file gnunet-service-dht.c.
Referenced by shutdown_task().
|
static |
PILS Operation DLL.
Definition at line 146 of file gnunet-service-dht.c.
Referenced by shutdown_task().
struct GNUNET_MessageHeader* GDS_my_hello |
Our HELLO.
Our HELLO parser.
Definition at line 152 of file gnunet-service-dht.c.
Referenced by handle_dht_local_hello_get(), handle_find_my_hello(), pid_change_cb(), and shutdown_task().
struct GNUNET_PeerIdentity GDS_my_identity |
Identity of this peer.
Definition at line 157 of file gnunet-service-dht.c.
Referenced by forward_reply(), GDS_CLIENTS_handle_reply(), GDS_NEIGHBOURS_get_id(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), GDS_try_connect(), GDS_u_connect(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_dht_p2p_result(), pid_change_cb(), and run().
struct GNUNET_HashCode GDS_my_identity_hash |
Hash of the identity of this peer.
Definition at line 162 of file gnunet-service-dht.c.
Referenced by find_bucket(), GDS_am_closest_peer(), GDS_DATACACHE_handle_put(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), handle_find_my_hello(), pid_change_cb(), run(), select_peer(), and send_find_peer_message().
struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key |
Our private key.
Definition at line 167 of file gnunet-service-dht.c.
Referenced by GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), and run().
|
static |
Handles for the DHT underlays.
Definition at line 172 of file gnunet-service-dht.c.
Referenced by GDS_u_try_connect(), load_underlay(), run(), shutdown_task(), and update_network_size_estimate().
|
static |
Handles for the DHT underlays.
Definition at line 177 of file gnunet-service-dht.c.
Referenced by load_underlay(), and shutdown_task().
|
static |
Head of addresses of this peer.
Definition at line 182 of file gnunet-service-dht.c.
Referenced by u_address_add(), and u_address_del().
|
static |
Tail of addresses of this peer.
Definition at line 187 of file gnunet-service-dht.c.
Referenced by u_address_add(), and u_address_del().
|
static |
log of the current network size estimate, used as the point where we switch between random and deterministic routing.
Definition at line 193 of file gnunet-service-dht.c.
Referenced by GDS_NSE_get(), and update_network_size_estimate().