GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
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...
 
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_PreferenceHandleGDS_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 PilsRequestpils_requests_head
 PILS Operation DLL.
 
static struct PilsRequestpils_requests_tail
 PILS Operation DLL.
 
struct GNUNET_MessageHeaderGDS_my_hello
 Our HELLO.
 
static struct GDS_Underlayu_head
 Handles for the DHT underlays.
 
static struct GDS_Underlayu_tail
 Handles for the DHT underlays.
 
static struct MyAddressa_head
 Head of addresses of this peer.
 
static struct MyAddressa_tail
 Tail of addresses of this peer.
 
static double log_of_network_size_estimate = 0.5
 log of the current network size estimate, used as the point where we switch between random and deterministic routing.
 
static bool serving_clients
 Are we already serving clients? We suspend the service until PILS told us our peer identity, as virtually every DHT operation needs it.
 

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 46 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 198 of file gnunet-service-dht.c.

202{
203 struct GDS_Underlay *u = cls;
204 double sum = 0.0;
205
207 "# Network size estimates received",
208 1,
209 GNUNET_NO);
210 /* do not allow estimates < #MINIMUM_LOG_NSE */
211 u->network_size_estimate = pow (2.0,
213 logestimate));
214 for (struct GDS_Underlay *p = u_head; NULL != p; p = p->next)
215 sum += p->network_size_estimate;
216 if (sum <= 2.0)
218 else
219 log_of_network_size_estimate = log2 (sum);
220}
static mp_limb_t u[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
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.
#define MINIMUM_LOG_NSE
Floor for the log of the network size estimate, and the value we use before the NSE service has told ...
static struct GNUNET_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.

References GDS_stats, GNUNET_MAX, GNUNET_NO, GNUNET_STATISTICS_update(), log_of_network_size_estimate, MINIMUM_LOG_NSE, p, u, and u_head.

Here is the call 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 229 of file gnunet-service-dht.c.

230{
232}

References log_of_network_size_estimate.

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

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 248 of file gnunet-service-dht.c.

252{
253 struct GDS_Underlay *u = cls;
254 struct MyAddress *a;
255
257 "Underlay adds address %s for this peer\n",
258 address);
259 a = GNUNET_new (struct MyAddress);
260 a->source = source;
262 a->u = u;
264 a_tail,
265 a);
266 *ctx = a;
267
268}
static char * address
GNS address for this phone.
static struct GNUNET_FS_Handle * ctx
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#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.
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, 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().

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 277 of file gnunet-service-dht.c.

278{
279 struct MyAddress *a = ctx;
280
282 "Underlay deletes address %s for this peer\n",
283 a->url);
285 a_tail,
286 a);
287 GNUNET_free (a->url);
288 GNUNET_free (a);
289}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.

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().

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 293 of file gnunet-service-dht.c.

295{
296 for (struct GDS_Underlay *u = u_head;
297 NULL != u;
298 u = u->next)
299 u->dhtu->try_connect (u->dhtu->cls,
300 pid,
301 address);
302}
struct GDS_Underlay * next
Kept in a DLL.

References address, GDS_Underlay::next, 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 306 of file gnunet-service-dht.c.

312{
313 u->dhtu->send (u->dhtu->cls,
314 target,
315 msg,
316 msg_size,
318 finished_cb_cls);
319}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
static void finished_cb(void *cls, enum GNUNET_GenericReturnValue rv)

References finished_cb(), msg, and 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 323 of file gnunet-service-dht.c.

325{
326 u->dhtu->drop (ph);
327}

References 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 331 of file gnunet-service-dht.c.

333{
334 return u->dhtu->hold (u->dhtu->cls,
335 target);
336}

References GNUNET_DHTU_PreferenceHandle::target, and u.

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 345 of file gnunet-service-dht.c.

346{
347 struct GDS_Underlay *u;
348 struct PilsRequest *pr;
349
350 while (NULL != (u = u_head))
351 {
353 u_tail,
354 u);
355 if (0 == strcmp (u->name, "gnunet"))
356 {
357 DHTU_gnunet_done (u->dhtu);
358 }
359#ifdef LINUX
360 else if (0 == strcmp (u->name, "ip"))
361 {
362 DHTU_ip_done (u->dhtu);
363 }
364#endif
365 else
366 {
367 GNUNET_assert (0);
368 }
369 GNUNET_free (u->name);
370 GNUNET_free (u);
371 }
375 if (NULL != GDS_block_context)
376 {
378 GDS_block_context = NULL;
379 }
381 if (NULL != GDS_stats)
382 {
384 GNUNET_YES);
385 GDS_stats = NULL;
386 }
387 if (NULL != GDS_my_hello)
388 {
390 GDS_my_hello = NULL;
391 }
392 while (NULL != (pr = pils_requests_head))
393 {
396 pr);
397 if (NULL != pr->op)
399 GNUNET_free (pr);
400 }
402 if (NULL != GDS_pils)
403 {
405 GDS_pils = NULL;
406 }
407}
void GDS_helper_cleanup_operations(void)
Definition dht_helper.c:81
struct GNUNET_PILS_Handle * GDS_pils
Handle for the pils service.
struct GNUNET_MessageHeader * GDS_my_hello
Our HELLO.
static struct PilsRequest * pils_requests_head
PILS Operation DLL.
static struct GDS_Underlay * u_tail
Handles for the DHT underlays.
static struct PilsRequest * pils_requests_tail
PILS Operation DLL.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
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_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:647
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
Definition pils_api.c:776
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition block.c:158
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void * DHTU_gnunet_done(struct GNUNET_DHTU_PluginFunctions *api)
Exit point from the plugin.
void * DHTU_ip_done(struct GNUNET_DHTU_PluginFunctions *api)
Exit point from the plugin.
struct GNUNET_PILS_Operation * op
The pils operation.

References DHTU_gnunet_done(), DHTU_ip_done(), GDS_block_context, GDS_CLIENTS_stop(), GDS_DATACACHE_done(), GDS_helper_cleanup_operations(), 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.

Here is the call 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

NOTE: This is not pretty, but it allows us to avoid dynamically loading plugins

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

420{
421 struct GDS_Underlay *u;
422
423 (void) cls;
424 if (0 != strncasecmp (section,
425 "dhtu-",
426 strlen ("dhtu-")))
427 return;
428 if (GNUNET_YES !=
430 section,
431 "ENABLED"))
432 return;
433 section += strlen ("dhtu-");
434 u = GNUNET_new (struct GDS_Underlay);
435 u->env.cls = u;
436 u->env.cfg = GDS_cfg;
437 u->env.address_add_cb = &u_address_add;
438 u->env.address_del_cb = &u_address_del;
439 u->env.network_size_cb = &update_network_size_estimate;
440 u->env.connect_cb = &GDS_u_connect;
441 u->env.disconnect_cb = &GDS_u_disconnect;
442 u->env.receive_cb = &GDS_u_receive;
443
446 if (0 == strcmp (section, "gnunet"))
447 {
448 u->dhtu = DHTU_gnunet_init (&u->env);
449 }
450#ifdef LINUX
451 else if (0 == strcmp (section, "ip"))
452 {
453 u->dhtu = DHTU_ip_init (&u->env);
454 }
455#endif
456 if (NULL == u->dhtu)
457 {
458 GNUNET_free (u);
459 return;
460 }
461 u->name = GNUNET_strdup (section);
463 u_tail,
464 u);
465}
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.
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.
static void update_network_size_estimate()
We've sent on our flood message or one that we received which was validated and closer than ours.
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".
struct GNUNET_DHTU_PluginFunctions * DHTU_gnunet_init(struct GNUNET_DHTU_PluginEnvironment *env)
Entry point for the plugin.
struct GNUNET_DHTU_PluginFunctions * DHTU_ip_init(struct GNUNET_DHTU_PluginEnvironment *env)
Entry point for the plugin.

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 pid_change_cb().

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

◆ pid_change_cb()

static void pid_change_cb ( void *  cls,
const struct GNUNET_HELLO_Parser parser,
const struct GNUNET_HashCode hash 
)
static

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

472{
473 (void) cls;
474
475 if (NULL != GDS_my_hello)
478
479 if (NULL == GDS_my_hello)
480 {
481 GNUNET_break (0);
482 return;
483 }
484
485 if (NULL == u_head)
486 {
489 NULL);
490 if (NULL == u_head)
491 {
493 "No DHT underlays configured!\n");
495 return;
496 }
497 }
498
499 if (! serving_clients)
500 {
501 /* We have an identity now, so we can answer clients. */
502 serving_clients = true;
505 _ ("DHT service of `%s' ready.\n"),
507 }
508
510}
static void load_underlay(void *cls, const char *section)
Function iterating over all configuration sections.
static bool serving_clients
Are we already serving clients? We suspend the service until PILS told us our peer identity,...
struct GNUNET_SERVICE_Handle * GDS_service
Handle for the service.
void GDS_NEIGHBOURS_broadcast(const struct GNUNET_MessageHeader *msg)
Send msg to all peers in our buckets.
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Definition pils_api.c:875
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.
struct GNUNET_MessageHeader * GNUNET_HELLO_parser_to_dht_hello_msg(const struct GNUNET_HELLO_Parser *parser)
Generate DHT HELLO message from a parser.
Definition hello-uri.c:1249
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572
void GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh)
Resume accepting connections from the listen socket.
Definition service.c:2389
#define _(String)
GNU gettext support macro.
Definition platform.h:179

References _, GDS_cfg, GDS_my_hello, GDS_NEIGHBOURS_broadcast(), GDS_pils, GDS_service, GNUNET_break, GNUNET_CONFIGURATION_iterate_sections(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELLO_parser_to_dht_hello_msg(), GNUNET_i2s(), GNUNET_log, GNUNET_PILS_get_identity(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_resume(), load_underlay(), serving_clients, and u_head.

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 521 of file gnunet-service-dht.c.

524{
525 GDS_cfg = c;
527 /* Do not accept clients until PILS gave us our peer identity: without
528 it we can neither store nor route anything (#GDS_am_closest_peer(),
529 #GDS_DATACACHE_handle_put() and #GDS_NEIGHBOURS_handle_put() all
530 need it). #pid_change_cb() resumes us. */
533 GNUNET_assert (NULL != GDS_pils);
534 /* Sign path elements ourselves instead of asking the PILS service:
535 the signature is needed in the middle of building a message, and
536 the asynchronous round-trip forces every caller to keep the
537 half-built message alive across the callback. */
538 if (GNUNET_OK !=
541 _ (
542 "Failed to load our private key, falling back to signing via the PILS service\n"));
543
546 GDS_cfg);
551 NULL);
552 if (GNUNET_OK !=
554 {
556 return;
557 }
558}
struct GNUNET_SCHEDULER_Task * shutdown_task
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
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.
enum GNUNET_GenericReturnValue GNUNET_PILS_enable_private_key(struct GNUNET_PILS_Handle *handle)
Enable local access to the private key of the current peer identity.
Definition pils_api.c:896
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:624
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition block.c:140
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_WARNING
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:1345
void GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh)
Suspend accepting connections from the listen socket temporarily.
Definition service.c:2381
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.

References _, GDS_block_context, GDS_cfg, GDS_CLIENTS_init(), GDS_DATACACHE_init(), GDS_NEIGHBOURS_init(), GDS_pils, GDS_ROUTING_init(), GDS_service, GDS_stats, GNUNET_assert, GNUNET_BLOCK_context_create(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_PILS_connect(), GNUNET_PILS_enable_private_key(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_suspend(), GNUNET_STATISTICS_create(), pid_change_cb(), service, and shutdown_task.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ pils_requests_head

struct PilsRequest* pils_requests_head
static

PILS Operation DLL.

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

Referenced by shutdown_task().

◆ pils_requests_tail

struct PilsRequest* pils_requests_tail
static

PILS Operation DLL.

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

Referenced by shutdown_task().

◆ GDS_my_hello

struct GNUNET_MessageHeader* GDS_my_hello

Our HELLO.

Our HELLO parser.

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

Referenced by handle_dht_local_hello_get(), handle_find_my_hello(), pid_change_cb(), and shutdown_task().

◆ u_head

struct GDS_Underlay* u_head
static

Handles for the DHT underlays.

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

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

◆ u_tail

struct GDS_Underlay* u_tail
static

Handles for the DHT underlays.

Definition at line 163 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 168 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 173 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 = 0.5
static

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

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

Referenced by GDS_NSE_get(), and update_network_size_estimate().

◆ serving_clients

bool serving_clients
static

Are we already serving clients? We suspend the service until PILS told us our peer identity, as virtually every DHT operation needs it.

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

Referenced by pid_change_cb().