GNUnet  0.20.0
gnunet-service-dht.c File Reference

GNUnet DHT service. More...

Include dependency graph for gnunet-service-dht.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...
 

Macros

#define HELLO_FREQUENCY   GNUNET_TIME_UNIT_HOURS
 How often do we broadcast our HELLO to neighbours if nothing special happens? More...
 

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. More...
 
double GDS_NSE_get (void)
 Return the current NSE. More...
 
static void broadcast_hello (void *cls)
 Task run periodically to broadcast our HELLO. More...
 
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. More...
 
static void u_address_del (void *ctx)
 Function to call with expired addresses of this peer. More...
 
void GDS_u_try_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
 Ask all underlays to connect to peer pid at address. More...
 
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. More...
 
void GDS_u_drop (struct GDS_Underlay *u, struct GNUNET_DHTU_PreferenceHandle *ph)
 Drop a hold ph from underlay u. More...
 
struct GNUNET_DHTU_PreferenceHandleGDS_u_hold (struct GDS_Underlay *u, struct GNUNET_DHTU_Target *target)
 Create a hold on target at underlay u. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void load_underlay (void *cls, const char *section)
 Function iterating over all configuration sections. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Process dht requests. More...
 
 GNUNET_SERVICE_MAIN ("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

struct GNUNET_HELLO_BuilderGDS_my_hello
 Our HELLO. More...
 
struct GNUNET_PeerIdentity GDS_my_identity
 Identity of this peer. More...
 
struct GNUNET_HashCode GDS_my_identity_hash
 Hash of the identity of this peer. More...
 
struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key
 Our private key. More...
 
static struct GNUNET_SCHEDULER_Taskhello_task
 Task broadcasting our HELLO. More...
 
static struct GDS_Underlayu_head
 Handles for the DHT underlays. More...
 
static struct GDS_Underlayu_tail
 Handles for the DHT underlays. More...
 
static struct MyAddressa_head
 Head of addresses of this peer. More...
 
static struct MyAddressa_tail
 Tail of addresses of this peer. More...
 
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. More...
 

Detailed Description

GNUnet DHT service.

Author
Christian Grothoff
Nathan Evans

Definition in file gnunet-service-dht.c.

Macro Definition Documentation

◆ HELLO_FREQUENCY

#define HELLO_FREQUENCY   GNUNET_TIME_UNIT_HOURS

How often do we broadcast our HELLO to neighbours if nothing special happens?

Definition at line 43 of file gnunet-service-dht.c.

Function Documentation

◆ update_network_size_estimate()

static void update_network_size_estimate ( void *  cls,
struct GNUNET_TIME_Absolute  timestamp,
double  logestimate,
double  std_dev 
)
static

Callback that is called when network size estimate is updated.

Parameters
clsa struct GDS_Underlay
timestamptime when the estimate was received from the server (or created by the server)
logestimatethe log(Base 2) value of the current network size estimate
std_devstandard deviation for the estimate

Definition at line 183 of file gnunet-service-dht.c.

187 {
188  struct GDS_Underlay *u = cls;
189  double sum = 0.0;
190 
192  "# Network size estimates received",
193  1,
194  GNUNET_NO);
195  /* do not allow estimates < 0.5 */
196  u->network_size_estimate = pow (2.0,
197  GNUNET_MAX (0.5,
198  logestimate));
199  for (struct GDS_Underlay *p = u_head; NULL != p; p = p->next)
200  sum += p->network_size_estimate;
201  if (sum <= 2.0)
203  else
205 }
static struct GDS_Underlay * u_head
Handles for the DHT underlays.
static double log_of_network_size_estimate
log of the current network size estimate, used as the point where we switch between random and determ...
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
#define GNUNET_MAX(a, b)
@ GNUNET_NO
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Information we keep per underlay.
double network_size_estimate
current network size estimate for this underlay.

References GDS_stats, GNUNET_MAX, GNUNET_NO, GNUNET_STATISTICS_update(), log_of_network_size_estimate, GDS_Underlay::network_size_estimate, p, consensus-simulation::sum, and u_head.

Referenced by load_underlay().

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

◆ GDS_NSE_get()

double GDS_NSE_get ( void  )

Return the current NSE.

Returns
the current NSE as a logarithm

Definition at line 214 of file gnunet-service-dht.c.

215 {
217 }

References log_of_network_size_estimate.

Referenced by GDS_am_closest_peer(), handle_find_local_hello(), and select_peer().

Here is the caller graph for this function:

◆ broadcast_hello()

static void broadcast_hello ( void *  cls)
static

Task run periodically to broadcast our HELLO.

Parameters
clsNULL

Definition at line 229 of file gnunet-service-dht.c.

230 {
231  struct GNUNET_MessageHeader *hello;
232 
233  (void) cls;
234  /* TODO: randomize! */
237  NULL);
240  if (NULL == hello)
241  {
242  GNUNET_break (0);
243  return;
244  }
245  GDS_NEIGHBOURS_broadcast (hello);
246  GNUNET_free (hello);
247 }
struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key
Our private key.
#define HELLO_FREQUENCY
How often do we broadcast our HELLO to neighbours if nothing special happens?
static struct GNUNET_SCHEDULER_Task * hello_task
Task broadcasting our HELLO.
struct GNUNET_HELLO_Builder * GDS_my_hello
Our HELLO.
static void broadcast_hello(void *cls)
Task run periodically to broadcast our HELLO.
void GDS_NEIGHBOURS_broadcast(const struct GNUNET_MessageHeader *msg)
Send msg to all peers in our buckets.
struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate DHT HELLO message (without peer ID) from a builder.
Definition: hello-uri.c:586
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
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:1272
Header for all communications.

References GDS_my_hello, GDS_my_private_key, GDS_NEIGHBOURS_broadcast(), GNUNET_break, GNUNET_free, GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_SCHEDULER_add_delayed(), HELLO_FREQUENCY, and hello_task.

Referenced by u_address_add(), and u_address_del().

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

◆ u_address_add()

static void u_address_add ( void *  cls,
const char *  address,
struct GNUNET_DHTU_Source source,
void **  ctx 
)
static

Function to call with new addresses of this peer.

Parameters
clsthe closure
addressaddress 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/"
sourcehandle for sending from this address, NULL if we can only receive
[out]ctxstorage space for DHT to use in association with this address

Definition at line 260 of file gnunet-service-dht.c.

264 {
265  struct GDS_Underlay *u = cls;
266  struct MyAddress *a;
267 
269  "Underlay adds address %s for this peer\n",
270  address);
271  a = GNUNET_new (struct MyAddress);
272  a->source = source;
273  a->url = GNUNET_strdup (address);
274  a->u = u;
276  a_tail,
277  a);
278  *ctx = a;
280  address);
281  if (NULL != hello_task)
284  NULL);
285 }
static char * address
GNS address for this phone.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static struct MyAddress * a_head
Head of addresses of this peer.
static struct MyAddress * a_tail
Tail of addresses of this peer.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
Definition: hello-uri.c:748
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1299
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
An address of this peer.
char * url
Textual representation of the address.
struct GDS_Underlay * u
Underlay of this address.
struct GNUNET_DHTU_Source * source
Underlay handle for the address.

References a_head, a_tail, address, broadcast_hello(), ctx, GDS_my_hello, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_builder_add_address(), GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_strdup, hello_task, source, MyAddress::source, MyAddress::u, and MyAddress::url.

Referenced by load_underlay().

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

◆ u_address_del()

static void u_address_del ( void *  ctx)
static

Function to call with expired addresses of this peer.

Parameters
[in]ctxstorage space used by the DHT in association with this address

Definition at line 294 of file gnunet-service-dht.c.

295 {
296  struct MyAddress *a = ctx;
297 
299  "Underlay deletes address %s for this peer\n",
300  a->url);
302  a->url);
304  a_tail,
305  a);
306  GNUNET_free (a->url);
307  GNUNET_free (a);
308  if (NULL != hello_task)
311  NULL);
312 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Remove individual address from the builder.
Definition: hello-uri.c:798

References a_head, a_tail, broadcast_hello(), ctx, GDS_my_hello, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_builder_del_address(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), hello_task, and MyAddress::url.

Referenced by load_underlay().

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

◆ GDS_u_try_connect()

void GDS_u_try_connect ( const struct GNUNET_PeerIdentity pid,
const char *  address 
)

Ask all underlays to connect to peer pid at address.

Parameters
pididentity of the peer we would connect to
addressan address of pid

Definition at line 316 of file gnunet-service-dht.c.

318 {
319  for (struct GDS_Underlay *u = u_head;
320  NULL != u;
321  u = u->next)
322  u->dhtu->try_connect (u->dhtu->cls,
323  pid,
324  address);
325 }
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GDS_Underlay * next
Kept in a DLL.

References address, GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, GDS_Underlay::next, pid, GNUNET_DHTU_PluginFunctions::try_connect, MyAddress::u, and u_head.

Referenced by GDS_try_connect().

Here is the caller graph for this function:

◆ GDS_u_send()

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.

Parameters
uunderlay to use for transmission
targetreceiver identification
msgmessage
msg_sizenumber of bytes in msg
finished_cbfunction called once transmission is done (not called if target disconnects, then only the disconnect_cb is called).
finished_cb_clsclosure for finished_cb

Definition at line 329 of file gnunet-service-dht.c.

335 {
336  u->dhtu->send (u->dhtu->cls,
337  target,
338  msg,
339  msg_size,
340  finished_cb,
341  finished_cb_cls);
342 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static void finished_cb(enum GNUNET_GenericReturnValue rv)
struct GNUNET_DHTU_PluginFunctions * dhtu
Underlay API handle.
void * cls
Closure to pass to all plugin functions.
void(* send)(void *cls, 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.

References GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, finished_cb(), msg, GNUNET_DHTU_PluginFunctions::send, and MyAddress::u.

Referenced by do_send().

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

◆ GDS_u_drop()

void GDS_u_drop ( struct GDS_Underlay u,
struct GNUNET_DHTU_PreferenceHandle ph 
)

Drop a hold ph from underlay u.

Parameters
uthe underlay controlling the hold
phthe preference handle

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

348 {
349  u->dhtu->drop (ph);
350 }
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no longer request underlay to keep the connection alive.

References GDS_Underlay::dhtu, GNUNET_DHTU_PluginFunctions::drop, ph, and MyAddress::u.

Referenced by GDS_u_disconnect().

Here is the caller graph for this function:

◆ GDS_u_hold()

struct GNUNET_DHTU_PreferenceHandle* GDS_u_hold ( struct GDS_Underlay u,
struct GNUNET_DHTU_Target target 
)

Create a hold on target at underlay u.

Parameters
uthe underlay controlling the target
targetthe peer to hold the connection to

Definition at line 354 of file gnunet-service-dht.c.

356 {
357  return u->dhtu->hold (u->dhtu->cls,
358  target);
359 }
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.

References GNUNET_DHTU_PluginFunctions::cls, GDS_Underlay::dhtu, GNUNET_DHTU_PluginFunctions::hold, and GNUNET_DHTU_PreferenceHandle::target.

Referenced by update_hold().

Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 368 of file gnunet-service-dht.c.

369 {
370  struct GDS_Underlay *u;
371 
372  while (NULL != (u = u_head))
373  {
375  u->dhtu);
377  u_tail,
378  u);
379  GNUNET_free (u->name);
380  GNUNET_free (u->libname);
381  GNUNET_free (u);
382  }
385  GDS_ROUTING_done ();
386  if (NULL != GDS_block_context)
387  {
389  GDS_block_context = NULL;
390  }
391  GDS_CLIENTS_stop ();
392  if (NULL != GDS_stats)
393  {
395  GNUNET_YES);
396  GDS_stats = NULL;
397  }
398  if (NULL != GDS_my_hello)
399  {
401  GDS_my_hello = NULL;
402  }
403  if (NULL != hello_task)
404  {
406  hello_task = NULL;
407  }
408 }
static struct GDS_Underlay * u_tail
Handles for the DHT underlays.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
static void GDS_CLIENTS_stop(void)
Shutdown client subsystem.
void GDS_DATACACHE_done()
Shutdown datacache subsystem.
void GDS_NEIGHBOURS_done()
Shutdown neighbours subsystem.
void GDS_ROUTING_done()
Shutdown routing subsystem.
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition: block.c:156
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition: hello-uri.c:319
@ GNUNET_YES
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:242
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
char * libname
Name of the library providing the underlay.
char * name
Name of the underlay (i.e.

References GDS_Underlay::dhtu, GDS_block_context, GDS_CLIENTS_stop(), GDS_DATACACHE_done(), GDS_my_hello, GDS_NEIGHBOURS_done(), GDS_ROUTING_done(), GDS_stats, GNUNET_BLOCK_context_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_HELLO_builder_free(), GNUNET_PLUGIN_unload(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_YES, hello_task, GDS_Underlay::libname, GDS_Underlay::name, u_head, and u_tail.

Referenced by run().

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

◆ load_underlay()

static void load_underlay ( void *  cls,
const char *  section 
)
static

Function iterating over all configuration sections.

Loads plugins for enabled DHT underlays.

Parameters
clsNULL
sectionconfiguration section to inspect

Definition at line 419 of file gnunet-service-dht.c.

421 {
422  struct GDS_Underlay *u;
423  char *libname;
424 
425  (void) cls;
426  if (0 != strncasecmp (section,
427  "dhtu-",
428  strlen ("dhtu-")))
429  return;
430  if (GNUNET_YES !=
432  section,
433  "ENABLED"))
434  return;
435  section += strlen ("dhtu-");
436  u = GNUNET_new (struct GDS_Underlay);
437  u->env.cls = u;
438  u->env.cfg = GDS_cfg;
446  "libgnunet_plugin_dhtu_%s",
447  section);
449  &u->env);
450  if (NULL == u->dhtu)
451  {
453  GNUNET_free (u);
454  return;
455  }
456  u->libname = libname;
457  u->name = GNUNET_strdup (section);
459  u_tail,
460  u);
461 }
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.
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.
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
void GDS_u_disconnect(void *ctx)
Function to call when we disconnected from a peer and can henceforth cannot transmit to that peer any...
void GDS_u_connect(void *cls, struct GNUNET_DHTU_Target *target, const struct GNUNET_PeerIdentity *pid, void **ctx)
Function to call when we connect to a peer and can henceforth transmit to that peer.
void GDS_u_receive(void *cls, void **tctx, void **sctx, const void *message, size_t message_size)
Function to call when we receive a message.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:198
struct GNUNET_DHTU_PluginEnvironment env
Environment for this underlay.
void(* address_add_cb)(void *cls, const char *address, struct GNUNET_DHTU_Source *source, void **ctx)
Function to call with new addresses of this peer.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
void(* connect_cb)(void *cls, struct GNUNET_DHTU_Target *target, const struct GNUNET_PeerIdentity *pid, void **ctx)
Function to call when we connect to a peer and can henceforth transmit to that peer.
void * cls
Closure to use for callbacks.
void(* address_del_cb)(void *ctx)
Function to call with expired addresses of this peer.
void(* disconnect_cb)(void *ctx)
Function to call when we disconnected from a peer and can henceforth cannot transmit to that peer any...
void(* network_size_cb)(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
We have a new estimate on the size of the underlay.
void(* receive_cb)(void *cls, void **tctx, void **sctx, const void *message, size_t message_size)
Function to call when we receive a message.

References GNUNET_DHTU_PluginEnvironment::address_add_cb, GNUNET_DHTU_PluginEnvironment::address_del_cb, GNUNET_DHTU_PluginEnvironment::cfg, GNUNET_DHTU_PluginEnvironment::cls, GNUNET_DHTU_PluginEnvironment::connect_cb, GDS_Underlay::dhtu, GNUNET_DHTU_PluginEnvironment::disconnect_cb, GDS_Underlay::env, GDS_cfg, GDS_u_connect(), GDS_u_disconnect(), GDS_u_receive(), GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_new, GNUNET_PLUGIN_load(), GNUNET_strdup, GNUNET_YES, GDS_Underlay::libname, GDS_Underlay::name, GNUNET_DHTU_PluginEnvironment::network_size_cb, GNUNET_DHTU_PluginEnvironment::receive_cb, u_address_add(), u_address_del(), u_head, u_tail, and update_network_size_estimate().

Referenced by run().

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

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Process dht requests.

Parameters
clsclosure
cconfiguration to use
servicethe initialized service

Definition at line 472 of file gnunet-service-dht.c.

475 {
476  GDS_cfg = c;
478  {
479  char *keyfile;
480 
481  if (GNUNET_OK !=
483  "PEER",
484  "PRIVATE_KEY",
485  &keyfile))
486  {
488  "PEER",
489  "PRIVATE_KEY");
491  return;
492  }
493  if (GNUNET_SYSERR ==
495  GNUNET_YES,
497  {
499  "Failed to setup peer's private key\n");
500  GNUNET_free (keyfile);
502  return;
503  }
504  GNUNET_free (keyfile);
505  }
510  sizeof(struct GNUNET_PeerIdentity),
514  GDS_cfg);
515  GDS_CLIENTS_init ();
516  GDS_ROUTING_init ();
519  NULL);
520  if (GNUNET_OK !=
522  {
524  return;
525  }
527  &load_underlay,
528  NULL);
529  if (NULL == u_head)
530  {
532  "No DHT underlays configured!\n");
534  return;
535  }
536 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void load_underlay(void *cls, const char *section)
Function iterating over all configuration sections.
struct GNUNET_PeerIdentity GDS_my_identity
Identity of this peer.
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_HashCode GDS_my_identity_hash
Hash of the identity of this peer.
struct GNUNET_SERVICE_Handle * GDS_service
Handle for the service.
static void GDS_CLIENTS_init(void)
Initialize client subsystem.
void GDS_DATACACHE_init()
Initialize datacache subsystem.
enum GNUNET_GenericReturnValue GDS_NEIGHBOURS_init()
Initialize neighbours subsystem.
void GDS_ROUTING_init()
Initialize routing subsystem.
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition: block.c:140
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:198
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
Definition: hello-uri.c:308
@ GNUNET_OK
@ GNUNET_SYSERR
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key

References GDS_block_context, GDS_cfg, GDS_CLIENTS_init(), GDS_DATACACHE_init(), GDS_my_hello, GDS_my_identity, GDS_my_identity_hash, GDS_my_private_key, GDS_NEIGHBOURS_init(), GDS_ROUTING_init(), GDS_service, GDS_stats, 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_HELLO_builder_new(), GNUNET_log, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_SYSERR, GNUNET_YES, load_underlay(), GNUNET_PeerIdentity::public_key, service, shutdown_task(), and u_head.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ GDS_my_hello

struct GNUNET_HELLO_Builder* GDS_my_hello

◆ GDS_my_identity

◆ GDS_my_identity_hash

struct GNUNET_HashCode GDS_my_identity_hash

Hash of the identity of this peer.

Definition at line 124 of file gnunet-service-dht.c.

Referenced by add_known_to_bloom(), datacache_get_iterator(), handle_find_my_hello(), run(), select_peer(), and send_find_peer_message().

◆ GDS_my_private_key

struct GNUNET_CRYPTO_EddsaPrivateKey GDS_my_private_key

Our private key.

Definition at line 124 of file gnunet-service-dht.c.

Referenced by broadcast_hello(), check_dht_local_hello_offer(), handle_find_my_hello(), run(), and sign_path().

◆ hello_task

struct GNUNET_SCHEDULER_Task* hello_task
static

Task broadcasting our HELLO.

Definition at line 144 of file gnunet-service-dht.c.

Referenced by broadcast_hello(), shutdown_task(), u_address_add(), and u_address_del().

◆ u_head

struct GDS_Underlay* u_head
static

Handles for the DHT underlays.

Definition at line 149 of file gnunet-service-dht.c.

Referenced by GDS_u_try_connect(), load_underlay(), run(), shutdown_task(), and update_network_size_estimate().

◆ u_tail

struct GDS_Underlay* u_tail
static

Handles for the DHT underlays.

Definition at line 154 of file gnunet-service-dht.c.

Referenced by load_underlay(), and shutdown_task().

◆ a_head

struct MyAddress* a_head
static

Head of addresses of this peer.

Definition at line 159 of file gnunet-service-dht.c.

Referenced by u_address_add(), and u_address_del().

◆ a_tail

struct MyAddress* a_tail
static

Tail of addresses of this peer.

Definition at line 164 of file gnunet-service-dht.c.

Referenced by u_address_add(), and u_address_del().

◆ log_of_network_size_estimate

double log_of_network_size_estimate
static

log of the current network size estimate, used as the point where we switch between random and deterministic routing.

Definition at line 170 of file gnunet-service-dht.c.

Referenced by GDS_NSE_get(), and update_network_size_estimate().