GNUnet  0.10.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.

Functions

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

Variables

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.

Author
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 
)
static

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

Parameters
clsNULL
messageHELLO message of peer

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

References GNUNET_free_non_null, GNUNET_malloc, GNUNET_memcpy, and GNUNET_MessageHeader::size.

Referenced by run().

71 {
73  GDS_my_hello = GNUNET_malloc(ntohs(message->size));
75  message,
76  ntohs(message->size));
77 }
struct GNUNET_MessageHeader * GDS_my_hello
Our HELLO.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_malloc(size)
Wrapper around malloc.
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 86 of file gnunet-service-dht.c.

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

Referenced by run().

87 {
88  if (NULL != ghh)
89  {
91  ghh = NULL;
92  }
97  GDS_NSE_done();
98  if (NULL != GDS_block_context)
99  {
101  GDS_block_context = NULL;
102  }
103  if (NULL != GDS_stats)
104  {
106  GNUNET_YES);
107  GDS_stats = NULL;
108  }
110  GDS_my_hello = NULL;
112 }
struct GNUNET_MessageHeader * GDS_my_hello
Our HELLO.
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
void GDS_NEIGHBOURS_done()
Shutdown neighbours subsystem.
void GDS_DATACACHE_done()
Shutdown datacache subsystem.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
void GDS_NSE_done()
Shutdown NSE subsystem.
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition: block.c:150
static void GDS_CLIENTS_stop()
Shutdown client subsystem.
static struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Handle to get our current HELLO.
void GDS_HELLO_done()
Shutdown HELLO subsystem.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GDS_ROUTING_done()
Shutdown routing subsystem.
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
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 123 of file gnunet-service-dht.c.

References GDS_block_context, GDS_cfg, GDS_CLIENTS_init(), GDS_DATACACHE_init(), GDS_DHT_SERVICE_INIT, GDS_HELLO_init(), GDS_NEIGHBOURS_init(), GDS_NSE_init(), GDS_ROUTING_init(), GDS_service, GDS_stats, 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().

126 {
127  GDS_cfg = c;
129  if (GNUNET_OK !=
131  "transport",
132  "HELLO_EXPIRATION",
134  {
136  }
139  GDS_cfg);
143  GDS_NSE_init();
145  GDS_HELLO_init();
147  {
148  shutdown_task(NULL);
149  return;
150  }
152  NULL);
155  &process_hello,
156  NULL);
157 }
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition: block.c:130
struct GNUNET_STATISTICS_Handle * GDS_stats
Handle for the statistics service.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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.
void GDS_DATACACHE_init()
Initialize datacache subsystem.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_SERVICE_Handle * GDS_service
Handle for the service.
#define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION
After how long do we expire an address in a HELLO that we just validated? This value is also used for...
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GDS_NSE_init()
Initialize NSE subsystem.
struct GNUNET_BLOCK_Context * GDS_block_context
Our handle to the BLOCK library.
void GDS_ROUTING_init()
Initialize routing subsystem.
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
Addresses that are global and are insensitive (i.e.
static struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Handle to get our current HELLO.
static void process_hello(void *cls, const struct GNUNET_MessageHeader *message)
Receive the HELLO from transport service, free current and replace if necessary.
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.
static void GDS_CLIENTS_init()
Initialize client subsystem.
int GDS_NEIGHBOURS_init()
Initialize neighbours subsystem.
void GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh)
Suspend accepting connections from the listen socket temporarily.
Definition: service.c:2173
const struct GNUNET_CONFIGURATION_Handle * GDS_cfg
Configuration we use.
void GDS_HELLO_init()
Initialize HELLO subsystem.
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Variable Documentation

◆ GDS_my_hello

struct GNUNET_MessageHeader* GDS_my_hello

Our HELLO.

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

Referenced by handle_find_peer().

◆ ghh

struct GNUNET_TRANSPORT_HelloGetHandle* ghh
static

Handle to get our current HELLO.

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

Referenced by GNUNET_TRANSPORT_hello_get(), and handle_hello().

◆ hello_expiration

struct GNUNET_TIME_Relative hello_expiration

Hello address expiration.

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

Referenced by run().