GNUnet  0.11.x
Functions | Variables
gnunet-service-dht.c File Reference

GNUnet DHT service. More...

#include "platform.h"
#include "gnunet_block_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_hello_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-dht.h"
#include "gnunet-service-dht_datacache.h"
#include "gnunet-service-dht_hello.h"
#include "gnunet-service-dht_neighbours.h"
#include "gnunet-service-dht_nse.h"
#include "gnunet-service-dht_routing.h"
#include "gnunet-service-dht_clients.c"
Include dependency graph for gnunet-service-dht.c:

Go to the source code of this file.


static void process_hello (void *cls, const struct GNUNET_MessageHeader *message)
 Receive the HELLO from transport service, free current and replace if necessary. More...
static void shutdown_task (void *cls)
 Task run during shutdown. 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_handler_end())


struct GNUNET_MessageHeaderGDS_my_hello
 Our HELLO. More...
static struct GNUNET_TRANSPORT_HelloGetHandleghh
 Handle to get our current HELLO. More...
struct GNUNET_TIME_Relative hello_expiration
 Hello address expiration. More...

Detailed Description

GNUnet DHT service.

Christian Grothoff
Nathan Evans

Definition in file gnunet-service-dht.c.

Function Documentation

◆ process_hello()

static void process_hello ( void *  cls,
const struct GNUNET_MessageHeader message 

Receive the HELLO from transport service, free current and replace if necessary.

messageHELLO message of peer

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

71 {
73  GDS_my_hello = GNUNET_malloc (ntohs (message->size));
75  message,
76  ntohs (message->size));
77 }
struct GNUNET_MessageHeader * GDS_my_hello
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References GDS_my_hello, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, and GNUNET_MessageHeader::size.

Referenced by run().

Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)

Task run during shutdown.


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

87 {
88  if (NULL != ghh)
89  {
91  ghh = NULL;
92  }
96  GDS_HELLO_done ();
97  GDS_NSE_done ();
98  if (NULL != GDS_block_context)
99  {
101  GDS_block_context = NULL;
102  }
103  if (NULL != GDS_stats)
104  {
107  GDS_stats = NULL;
108  }
110  GDS_my_hello = NULL;
111  GDS_CLIENTS_stop ();
112 }
static struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Handle to get our current HELLO.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
static void GDS_CLIENTS_stop()
Shutdown client subsystem.
void GDS_DATACACHE_done()
Shutdown datacache subsystem.
void GDS_HELLO_done()
Shutdown HELLO subsystem.
void GDS_NEIGHBOURS_done()
Shutdown neighbours subsystem.
void GDS_NSE_done()
Shutdown NSE subsystem.
void GDS_ROUTING_done()
Shutdown routing subsystem.
Definition: gnunet_common.h:97
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition: block.c:152
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.

References GDS_block_context, GDS_CLIENTS_stop(), GDS_DATACACHE_done(), GDS_HELLO_done(), GDS_my_hello, GDS_NEIGHBOURS_done(), GDS_NSE_done(), GDS_ROUTING_done(), GDS_stats, ghh, GNUNET_BLOCK_context_destroy(), GNUNET_free, GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_hello_get_cancel(), and GNUNET_YES.

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 

Process dht requests.

cconfiguration to use
servicethe initialized service

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

126 {
127  GDS_cfg = c;
129  if (GNUNET_OK !=
131  "transport",
134  {
136  }
139  GDS_cfg);
141  GDS_CLIENTS_init ();
142  GDS_ROUTING_init ();
143  GDS_NSE_init ();
145  GDS_HELLO_init ();
146  if (GNUNET_OK != GDS_NEIGHBOURS_init ())
147  {
148  shutdown_task (NULL);
149  return;
150  }
152  NULL);
155  &process_hello,
156  NULL);
157 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void process_hello(void *cls, const struct GNUNET_MessageHeader *message)
Receive the HELLO from transport service, free current and replace if necessary.
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
struct GNUNET_SERVICE_Handle * GDS_service
Handle for the service.
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
static void GDS_CLIENTS_init()
Initialize client subsystem.
void GDS_DATACACHE_init()
Initialize datacache subsystem.
void GDS_HELLO_init()
Initialize HELLO subsystem.
Initialize neighbours subsystem.
void GDS_NSE_init()
Initialize NSE subsystem.
void GDS_ROUTING_init()
Initialize routing subsystem.
Definition: gnunet_common.h:95
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition: block.c:131
enum GNUNET_GenericReturnValue 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.
After how long do we expire an address in a HELLO that we just validated? This value is also used for...
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:1331
void GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh)
Suspend accepting connections from the listen socket temporarily.
Definition: service.c:2183
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
Addresses that are global and are insensitive (i.e.

References GDS_block_context, GDS_cfg, GDS_CLIENTS_init(), GDS_DATACACHE_init(), GDS_HELLO_init(), GDS_NEIGHBOURS_init(), GDS_NSE_init(), GDS_ROUTING_init(), GDS_service, GDS_stats, ghh, GNUNET_BLOCK_context_create(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SERVICE_suspend(), GNUNET_STATISTICS_create(), GNUNET_TRANSPORT_AC_GLOBAL, GNUNET_TRANSPORT_hello_get(), hello_expiration, process_hello(), service, and shutdown_task().

Here is the call graph for this function:


Variable Documentation

◆ GDS_my_hello

struct GNUNET_MessageHeader* GDS_my_hello


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

Referenced by handle_find_peer(), process_hello(), and shutdown_task().

◆ ghh

struct GNUNET_TRANSPORT_HelloGetHandle* ghh

◆ hello_expiration

struct GNUNET_TIME_Relative hello_expiration

Hello address expiration.

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

Referenced by run().