Information we track per peer. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_dht.h"
#include "gnunet-service-cadet_hello.h"
#include "gnunet-service-cadet_peer.h"
#include "gnunet-service-cadet_paths.h"
Go to the source code of this file.
Data Structures | |
struct | GCD_search_handle |
Macros | |
#define | STARTUP_DELAY |
How long do we wait before first announcing our presence to the DHT. More... | |
#define | CHANGE_DELAY |
How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updated again quickly, for example in case multiple addresses changed and we got a partial update. More... | |
#define | LOG(level, ...) GNUNET_log_from (level, "cadet-dht", __VA_ARGS__) |
Functions | |
static void | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *trunc_peer, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
Function to process paths received for a new peer addition. More... | |
static void | announce_id (void *cls) |
Periodically announce self id in the DHT. More... | |
void | GCD_hello_update () |
Function called by the HELLO subsystem whenever OUR hello changes. More... | |
void | GCD_init (const struct GNUNET_CONFIGURATION_Handle *c) |
Initialize the DHT subsystem. More... | |
void | GCD_shutdown (void) |
Shut down the DHT subsystem. More... | |
struct GCD_search_handle * | GCD_search (const struct GNUNET_PeerIdentity *peer_id) |
Search DHT for paths to peeR_id. More... | |
void | GCD_search_stop (struct GCD_search_handle *h) |
Stop DHT search started with GCD_search(). More... | |
Variables | |
static struct GNUNET_DHT_Handle * | dht_handle |
Handle to use DHT. More... | |
static struct GNUNET_TIME_Relative | id_announce_time |
How often to PUT own ID in the DHT. More... | |
static unsigned long long | dht_replication_level |
DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put(). More... | |
static struct GNUNET_SCHEDULER_Task * | announce_id_task |
Task to periodically announce itself in the network. More... | |
static struct GNUNET_TIME_Relative | announce_delay |
Delay for the next ID announce. More... | |
Information we track per peer.
Definition in file gnunet-service-cadet_dht.c.
#define STARTUP_DELAY |
How long do we wait before first announcing our presence to the DHT.
Used to wait for our HELLO to be available. Note that we also get notifications when our HELLO is ready, so this is just the maximum we wait for the first notification.
Definition at line 43 of file gnunet-service-cadet_dht.c.
#define CHANGE_DELAY |
How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updated again quickly, for example in case multiple addresses changed and we got a partial update.
Definition at line 51 of file gnunet-service-cadet_dht.c.
#define LOG | ( | level, | |
... | |||
) | GNUNET_log_from (level, "cadet-dht", __VA_ARGS__) |
Definition at line 55 of file gnunet-service-cadet_dht.c.
|
static |
Function to process paths received for a new peer addition.
The recorded paths form the initial tunnel, which can be optimized later. Called on each result obtained for the DHT search.
cls | closure |
exp | when will this value expire |
key | key of the result |
trunc_peer | peer proceeding with invalid signature, or NULL |
get_path | path of the get request |
get_path_length | length of get_path |
put_path | path of the put request |
put_path_length | length of the put_path |
type | type of the result |
size | number of bytes in data |
data | pointer to the result data |
Definition at line 111 of file gnunet-service-cadet_dht.c.
References data, GCP_2s(), GCP_get(), GCP_set_hello(), GCPP_try_path_from_dht(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, CadetPeer::hello, and LOG.
Referenced by GCD_search().
|
static |
Periodically announce self id in the DHT.
cls | closure |
Definition at line 148 of file gnunet-service-cadet_dht.c.
References announce_delay, announce_id(), announce_id_task, dht_handle, dht_replication_level, expiration, GCH_get_mine(), GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_DHT_put(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_min(), GNUNET_TIME_STD_BACKOFF, GNUNET_TIME_UNIT_SECONDS, id_announce_time, LOG, my_full_id, GNUNET_MessageHeader::size, size, and stats.
Referenced by announce_id(), GCD_hello_update(), and GCD_init().
void GCD_hello_update | ( | void | ) |
Function called by the HELLO subsystem whenever OUR hello changes.
Re-triggers the DHT PUT immediately.
Definition at line 222 of file gnunet-service-cadet_dht.c.
References announce_id(), announce_id_task, CHANGE_DELAY, GNUNET_SCHEDULER_add_delayed(), and GNUNET_SCHEDULER_cancel().
Referenced by got_hello().
void GCD_init | ( | const struct GNUNET_CONFIGURATION_Handle * | c | ) |
Initialize the DHT subsystem.
c | Configuration. |
Definition at line 235 of file gnunet-service-cadet_dht.c.
References announce_delay, announce_id(), announce_id_task, dht_handle, dht_replication_level, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_DHT_connect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_config_invalid(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_SECONDS, id_announce_time, and STARTUP_DELAY.
Referenced by run().
void GCD_shutdown | ( | void | ) |
Shut down the DHT subsystem.
Definition at line 275 of file gnunet-service-cadet_dht.c.
References announce_id_task, dht_handle, GNUNET_DHT_disconnect(), and GNUNET_SCHEDULER_cancel().
Referenced by shutdown_rest().
struct GCD_search_handle * GCD_search | ( | const struct GNUNET_PeerIdentity * | peer_id | ) |
Search DHT for paths to peeR_id.
peer_id | peer to search for |
Definition at line 291 of file gnunet-service-cadet_dht.c.
References dht_get_id_handler(), dht_handle, dht_replication_level, GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_DHT_get_start(), GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), h, LOG, peer_id, and stats.
Referenced by consider_peer_activate(), and GCP_path_entry_remove().
void GCD_search_stop | ( | struct GCD_search_handle * | h | ) |
Stop DHT search started with GCD_search().
h | handle to search to stop |
Definition at line 327 of file gnunet-service-cadet_dht.c.
References GNUNET_DHT_get_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, h, and LOG.
Referenced by consider_peer_activate(), destroy_peer(), and GCP_path_entry_add().
|
static |
Handle to use DHT.
Definition at line 70 of file gnunet-service-cadet_dht.c.
Referenced by announce_id(), GCD_init(), GCD_search(), and GCD_shutdown().
|
static |
How often to PUT own ID in the DHT.
Definition at line 75 of file gnunet-service-cadet_dht.c.
Referenced by announce_id(), and GCD_init().
|
static |
DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().
Definition at line 80 of file gnunet-service-cadet_dht.c.
Referenced by announce_id(), GCD_init(), and GCD_search().
|
static |
Task to periodically announce itself in the network.
Definition at line 85 of file gnunet-service-cadet_dht.c.
Referenced by announce_id(), GCD_hello_update(), GCD_init(), and GCD_shutdown().
|
static |
Delay for the next ID announce.
Definition at line 90 of file gnunet-service-cadet_dht.c.
Referenced by announce_id(), and GCD_init().