GNUnet  0.10.x
Functions
gnunet-service-cadet_dht.h File Reference

cadet service; dealing with DHT requests and results More...

#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-service-cadet_dht.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GCD_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Initialize the DHT subsystem. More...
 
void GCD_shutdown (void)
 Shut down the DHT subsystem. More...
 
void GCD_hello_update (void)
 Function called by the HELLO subsystem whenever OUR hello changes. More...
 
struct GCD_search_handleGCD_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...
 

Detailed Description

cadet service; dealing with DHT requests and results

Author
Bartlomiej Polot
Christian Grothoff

All functions in this file should use the prefix GCD (Gnunet Cadet Dht)

Definition in file gnunet-service-cadet_dht.h.

Function Documentation

◆ GCD_init()

void GCD_init ( const struct GNUNET_CONFIGURATION_Handle c)

Initialize the DHT subsystem.

Parameters
cConfiguration.

Definition at line 236 of file gnunet-service-cadet_dht.c.

References announce_delay, announce_id(), 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().

237 {
238  if (GNUNET_OK !=
240  "CADET",
241  "DHT_REPLICATION_LEVEL",
243  {
245  "CADET",
246  "DHT_REPLICATION_LEVEL",
247  "USING DEFAULT");
249  }
250 
251  if (GNUNET_OK !=
253  "CADET",
254  "ID_ANNOUNCE_TIME",
256  {
258  "CADET",
259  "ID_ANNOUNCE_TIME",
260  "MISSING");
262  return;
263  }
264 
266  64);
267  GNUNET_break (NULL != dht_handle);
270  &announce_id,
271  NULL);
272 }
static struct GNUNET_SCHEDULER_Task * announce_id_task
Task to periodically announce itself in the network.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
static struct GNUNET_TIME_Relative id_announce_time
How often to PUT own ID in the DHT.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static struct GNUNET_DHT_Handle * dht_handle
Handle to use DHT.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static void announce_id(void *cls)
Periodically announce self id in the DHT.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:895
static struct GNUNET_TIME_Relative announce_delay
Delay for the next ID announce.
static unsigned long long dht_replication_level
DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().
#define STARTUP_DELAY
How long do we wait before first announcing our presence to the DHT.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCD_shutdown()

void GCD_shutdown ( void  )

Shut down the DHT subsystem.

Definition at line 279 of file gnunet-service-cadet_dht.c.

References GNUNET_DHT_disconnect(), and GNUNET_SCHEDULER_cancel().

Referenced by shutdown_rest().

280 {
281  if (NULL != dht_handle)
282  {
284  dht_handle = NULL;
285  }
286  if (NULL != announce_id_task)
287  {
289  announce_id_task = NULL;
290  }
291 }
static struct GNUNET_SCHEDULER_Task * announce_id_task
Task to periodically announce itself in the network.
static struct GNUNET_DHT_Handle * dht_handle
Handle to use DHT.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:923
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCD_hello_update()

void GCD_hello_update ( void  )

Function called by the HELLO subsystem whenever OUR hello changes.

Re-triggers the DHT PUT immediately.

Definition at line 218 of file gnunet-service-cadet_dht.c.

References announce_id(), CHANGE_DELAY, GNUNET_SCHEDULER_add_delayed(), and GNUNET_SCHEDULER_cancel().

Referenced by got_hello().

219 {
220  if (NULL == announce_id_task)
221  return; /* too early */
225  &announce_id,
226  NULL);
227 }
static struct GNUNET_SCHEDULER_Task * announce_id_task
Task to periodically announce itself in the network.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static void announce_id(void *cls)
Periodically announce self id in the DHT.
#define CHANGE_DELAY
How long do we wait after we get an updated HELLO before publishing? Allows for the HELLO to be updat...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCD_search()

struct GCD_search_handle* GCD_search ( const struct GNUNET_PeerIdentity peer_id)

Search DHT for paths to peeR_id.

Parameters
peer_idpeer to search for
Returns
handle to abort search

Definition at line 301 of file gnunet-service-cadet_dht.c.

References dht_get_id_handler(), dht_replication_level, GCD_search_handle::dhtget, 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, and stats.

Referenced by consider_peer_activate(), and GCP_path_entry_remove().

302 {
303  struct GNUNET_HashCode phash;
304  struct GCD_search_handle *h;
305 
307  "# DHT search",
308  1,
309  GNUNET_NO);
310  memset (&phash,
311  0,
312  sizeof (phash));
313  GNUNET_memcpy (&phash,
314  peer_id,
315  sizeof (*peer_id));
316 
317  h = GNUNET_new (struct GCD_search_handle);
318  h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
319  GNUNET_BLOCK_TYPE_DHT_HELLO, /* type */
320  &phash, /* key to search */
321  dht_replication_level, /* replication level */
324  NULL, /* xquery */
325  0, /* xquery bits */
327  h);
329  "Starting DHT GET for peer %s (%p)\n",
330  GNUNET_i2s (peer_id),
331  h);
332  return h;
333 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
We should keep track of the route that the message took in the P2P network.
Handle for DHT searches.
#define LOG(level,...)
static struct GNUNET_DHT_Handle * dht_handle
Handle to use DHT.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define GNUNET_memcpy(dst, src, n)
Type of a block that contains a HELLO for a peer (for DHT and CADET find-peer operations).
A 512-bit hashcode.
static void dht_get_id_handler(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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.
struct GNUNET_DHT_GetHandle * dhtget
DHT_GET handle.
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1072
static unsigned long long dht_replication_level
DHT replication level, see DHT API: GNUNET_DHT_get_start(), GNUNET_DHT_put().
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Each peer along the way should look at 'enc' (otherwise only the k-peers closest to the key should lo...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCD_search_stop()

void GCD_search_stop ( struct GCD_search_handle h)

Stop DHT search started with GCD_search().

Parameters
hhandle to search to stop

Definition at line 342 of file gnunet-service-cadet_dht.c.

References GCD_search_handle::dhtget, GNUNET_DHT_get_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, and LOG.

Referenced by consider_peer_activate(), destroy_peer(), and GCP_path_entry_add().

343 {
345  "Stopping DHT GET %p\n",
346  h);
348  GNUNET_free (h);
349 }
#define LOG(level,...)
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
struct GNUNET_DHT_GetHandle * dhtget
DHT_GET handle.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: