GNUnet 0.21.1
gnunet-service-gns.c File Reference

GNU Name System (main service) More...

Include dependency graph for gnunet-service-gns.c:

Go to the source code of this file.

Data Structures

struct  ClientLookupHandle
 Handle to a lookup operation from client via API. More...
 
struct  GnsClient
 Information we track per connected client. More...
 
struct  GNS_TopLevelDomain
 Representation of a TLD, mapping the respective TLD string (e.g. More...
 

Functions

int GNS_find_tld (const char *tld_str, struct GNUNET_CRYPTO_PublicKey *pkey)
 Find GNS zone belonging to TLD tld. More...
 
const char * GNS_get_tld (const char *name)
 Obtain the TLD of the given name. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Add a client to our list of active clients. More...
 
static void send_lookup_response (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Reply to client with the result from our lookup. More...
 
static int check_lookup (void *cls, const struct LookupMessage *l_msg)
 Checks a GNUNET_MESSAGE_TYPE_GNS_LOOKUP message. More...
 
static void handle_lookup (void *cls, const struct LookupMessage *sh_msg)
 Handle lookup requests from client. More...
 
static void read_service_conf (void *cls, const char *section, const char *option, const char *value)
 Reads the configuration and populates TLDs. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Process GNS requests. More...
 
 GNUNET_SERVICE_MAIN ("gns", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(lookup, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, struct LookupMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct GNUNET_DHT_Handledht_handle
 Our handle to the DHT. More...
 
static struct GNUNET_NAMECACHE_Handlenamecache_handle
 Our handle to the namecache service. More...
 
static int v6_enabled
 GNUNET_YES if ipv6 is supported More...
 
static int v4_enabled
 GNUNET_YES if ipv4 is supported More...
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service. More...
 
static struct GNS_TopLevelDomaintld_head
 Head of DLL of TLDs we map to GNS zones. More...
 
static struct GNS_TopLevelDomaintld_tail
 Tail of DLL of TLDs we map to GNS zones. More...
 

Detailed Description

GNU Name System (main service)

Author
Martin Schanzenbach
Christian Grothoff

Definition in file gnunet-service-gns.c.

Function Documentation

◆ GNS_find_tld()

int GNS_find_tld ( const char *  tld_str,
struct GNUNET_CRYPTO_PublicKey pkey 
)

Find GNS zone belonging to TLD tld.

Parameters
tld_strtop-level domain to look up
[out]pkeypublic key to set
Returns
GNUNET_YES if tld was found GNUNET_NO if not

Definition at line 178 of file gnunet-service-gns.c.

180{
181 if ('\0' == *tld_str)
182 return GNUNET_NO;
183 for (struct GNS_TopLevelDomain *tld = tld_head;
184 NULL != tld;
185 tld = tld->next)
186 {
187 if (0 == strcasecmp (tld_str,
188 tld->tld))
189 {
190 *pkey = tld->pkey;
191 return GNUNET_YES;
192 }
193 }
194 if (GNUNET_OK ==
196 pkey))
197 return GNUNET_YES; /* TLD string *was* the public key */
198 return GNUNET_NO;
199}
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNS_TopLevelDomain * tld_head
Head of DLL of TLDs we map to GNS zones.
int GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey, struct GNUNET_CRYPTO_PublicKey *pkey)
Convert an absolute domain name to the respective public key.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
Representation of a TLD, mapping the respective TLD string (e.g.
struct GNS_TopLevelDomain * next
Kept in a DLL, as there are unlikely enough of these to warrant a hash map.

References GNUNET_GNSRECORD_zkey_to_pkey(), GNUNET_NO, GNUNET_OK, GNUNET_YES, pkey, GNS_TopLevelDomain::tld, and tld_head.

Referenced by handle_dns_request().

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

◆ GNS_get_tld()

const char * GNS_get_tld ( const char *  name)

Obtain the TLD of the given name.

Parameters
namea name
Returns
the part of name after the last ".", or name if name does not contain a "."

Definition at line 210 of file gnunet-service-gns.c.

211{
212 const char *tld;
213
214 tld = strrchr (name,
215 (unsigned char) '.');
216 if (NULL == tld)
217 tld = name;
218 else
219 tld++; /* skip the '.' */
220 return tld;
221}
static char * name
Name (label) of the records to list.

References name, and GNS_TopLevelDomain::tld.

Referenced by handle_dns_request(), handle_gns_redirect_result(), and recursive_gns2dns_resolution().

Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused, NULL

Definition at line 230 of file gnunet-service-gns.c.

231{
232 struct GNS_TopLevelDomain *tld;
233
234 (void) cls;
236 "Shutting down!\n");
239 if (NULL != statistics)
240 {
242 GNUNET_NO);
243 statistics = NULL;
244 }
245 if (NULL != namecache_handle)
246 {
248 namecache_handle = NULL;
249 }
250 if (NULL != dht_handle)
251 {
253 dht_handle = NULL;
254 }
255 while (NULL != (tld = tld_head))
256 {
258 tld_tail,
259 tld);
260 GNUNET_free (tld->tld);
262 }
263}
static struct GNS_TopLevelDomain * tld_tail
Tail of DLL of TLDs we map to GNS zones.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
static struct GNUNET_NAMECACHE_Handle * namecache_handle
Our handle to the namecache service.
void GNS_interceptor_done()
Disconnect from interceptor.
void GNS_resolver_done()
Shutdown resolver.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:1060
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from the namecache service (and free associated resources).
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
char * tld
Top-level domain as a string, including leading ".".

References dht_handle, GNS_interceptor_done(), GNS_resolver_done(), GNUNET_CONTAINER_DLL_remove, GNUNET_DHT_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMECACHE_disconnect(), GNUNET_NO, GNUNET_STATISTICS_destroy(), namecache_handle, statistics, GNS_TopLevelDomain::tld, tld_head, and tld_tail.

Referenced by run().

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

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Parameters
clsclosure
clientidentification of the client
app_ctxclient

Definition at line 274 of file gnunet-service-gns.c.

277{
278 struct ClientLookupHandle *clh;
279 struct GnsClient *gc = app_ctx;
280
281 (void) cls;
283 "Client %p disconnected\n",
284 client);
285 while (NULL != (clh = gc->clh_head))
286 {
287 if (NULL != clh->lookup)
290 gc->clh_tail,
291 clh);
292 GNUNET_free (clh);
293 }
294 GNUNET_free (gc);
295}
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
Handle to a lookup operation from client via API.
struct GNS_ResolverHandle * lookup
Active handle for the lookup.
Information we track per connected client.
struct ClientLookupHandle * clh_tail
Tail of the DLL.
struct ClientLookupHandle * clh_head
Head of the DLL.
struct GNUNET_SERVICE_Client * client
The client.

References GnsClient::clh_head, GnsClient::clh_tail, GnsClient::client, GNS_resolver_lookup_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and ClientLookupHandle::lookup.

Here is the call graph for this function:

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Add a client to our list of active clients.

Parameters
clsNULL
clientclient to add
mqmessage queue for client
Returns
internal namestore client structure for this client

Definition at line 307 of file gnunet-service-gns.c.

310{
311 struct GnsClient *gc;
312
313 (void) cls;
315 "Client %p connected\n",
316 client);
317 gc = GNUNET_new (struct GnsClient);
318 gc->client = client;
319 gc->mq = mq;
320 return gc;
321}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
The MQ.

References GnsClient::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, and GnsClient::mq.

◆ send_lookup_response()

static void send_lookup_response ( void *  cls,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Reply to client with the result from our lookup.

Parameters
clsthe closure (our client lookup handle)
rd_countthe number of records in rd
rdthe record data

Definition at line 332 of file gnunet-service-gns.c.

335{
336 struct ClientLookupHandle *clh = cls;
337 struct GnsClient *gc = clh->gc;
338 struct GNUNET_MQ_Envelope *env;
339 struct LookupResultMessage *rmsg;
340 ssize_t len;
341
343 "Sending LOOKUP_RESULT message with %u results\n",
344 (unsigned int) rd_count);
346 rd);
347 if (len < 0)
348 {
349 GNUNET_break (0);
351 return;
352 }
353 if (len > UINT16_MAX - sizeof(*rmsg))
354 {
355 GNUNET_break (0);
357 return;
358 }
359 env = GNUNET_MQ_msg_extra (rmsg,
360 len,
362 rmsg->id = clh->request_id;
363 rmsg->rd_count = htonl (rd_count);
364 GNUNET_assert (len ==
366 rd,
367 len,
368 (char *) &rmsg[1]));
370 env);
372 gc->clh_tail,
373 clh);
374 GNUNET_free (clh);
376 "Completed lookups", 1,
377 GNUNET_NO);
379 "Records resolved",
380 rd_count,
381 GNUNET_NO);
382}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT
Service response to name resolution request from client.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2489
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2602
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GnsClient * gc
Client handle.
uint32_t request_id
request id
Message from GNS service to client: new results.
Definition: gns.h:80
uint32_t id
Unique identifier for this request (for key collisions).
Definition: gns.h:89
uint32_t rd_count
The number of records contained in response.
Definition: gns.h:96

References GnsClient::clh_head, GnsClient::clh_tail, GnsClient::client, env, ClientLookupHandle::gc, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_log, GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), LookupResultMessage::id, rd, rd_count, LookupResultMessage::rd_count, ClientLookupHandle::request_id, and statistics.

Referenced by handle_lookup().

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

◆ check_lookup()

static int check_lookup ( void *  cls,
const struct LookupMessage l_msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_GNS_LOOKUP message.

Parameters
clsclient sending the message
l_msgmessage of type struct LookupMessage
Returns
GNUNET_OK if l_msg is well-formed

Definition at line 393 of file gnunet-service-gns.c.

395{
396 size_t nlen;
397 size_t klen;
398
399 (void) cls;
400 klen = ntohl (l_msg->key_len);
401 nlen = ntohs (l_msg->header.size) - sizeof(struct LookupMessage) - klen;
403 {
404 GNUNET_break (0);
405 return GNUNET_SYSERR;
406 }
407 return GNUNET_OK;
408}
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH
Maximum length of a name in DNS.
@ GNUNET_SYSERR
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Message from client to GNS service to lookup records.
Definition: gns.h:37
uint32_t key_len
Length of the zone key.
Definition: gns.h:69
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_GNS_LOOKUP.
Definition: gns.h:41

References GNUNET_break, GNUNET_DNSPARSER_MAX_NAME_LENGTH, GNUNET_OK, GNUNET_SYSERR, LookupMessage::header, LookupMessage::key_len, and GNUNET_MessageHeader::size.

◆ handle_lookup()

static void handle_lookup ( void *  cls,
const struct LookupMessage sh_msg 
)
static

Handle lookup requests from client.

Parameters
clsthe closure
sh_msgthe message

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

420{
421 struct GnsClient *gc = cls;
422 struct ClientLookupHandle *clh;
423 struct GNUNET_CRYPTO_PublicKey zone;
424 const char *name;
425 size_t key_len;
426 size_t read;
427
429 key_len = ntohl (sh_msg->key_len);
430 clh = GNUNET_new (struct ClientLookupHandle);
432 gc->clh_tail,
433 clh);
434 clh->gc = gc;
435 clh->request_id = sh_msg->id;
436 if ((GNUNET_SYSERR ==
438 key_len,
439 &zone,
440 &read)) ||
441 (read != key_len))
442 {
444 "LOOKUP: Failed to read zone key!");
446 0,
447 NULL);
448 return;
449 }
450 name = (const char *) &sh_msg[1] + key_len;
452 "Received LOOKUP `%s' message\n",
453 name);
454 if ((GNUNET_DNSPARSER_TYPE_A == ntohl (sh_msg->type)) &&
456 {
458 "LOOKUP: Query for A record but AF_INET not supported!");
460 0,
461 NULL);
462 return;
463 }
464 if ((GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) &&
466 {
468 "LOOKUP: Query for AAAA record but AF_INET6 not supported!");
470 0,
471 NULL);
472 return;
473 }
474 clh->lookup = GNS_resolver_lookup (&zone,
475 ntohl (sh_msg->type),
476 name,
477 (enum GNUNET_GNS_LocalOptions) ntohs (
478 sh_msg->options),
479 ntohs (sh_msg->recursion_depth_limit),
482 "Lookup attempts",
483 1, GNUNET_NO);
484}
static void send_lookup_response(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Reply to client with the result from our lookup.
static int v4_enabled
GNUNET_YES if ipv4 is supported
static int v6_enabled
GNUNET_YES if ipv6 is supported
struct GNS_ResolverHandle * GNS_resolver_lookup(const struct GNUNET_CRYPTO_PublicKey *zone, uint32_t record_type, const char *name, enum GNUNET_GNS_LocalOptions options, uint16_t recursion_depth_limit, GNS_ResultProcessor proc, void *proc_cls)
Lookup of a record in a specific zone calls lookup result processor on result.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_DNSPARSER_TYPE_A
#define GNUNET_DNSPARSER_TYPE_AAAA
GNUNET_GNS_LocalOptions
Options for the GNS lookup.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2408
An identity key as per LSD0001.
int16_t options
Local options for where to look for results (an enum GNUNET_GNS_LocalOptions in NBO).
Definition: gns.h:52
uint32_t id
Unique identifier for this request (for key collisions).
Definition: gns.h:46
uint16_t recursion_depth_limit
Recursion depth limit, i.e.
Definition: gns.h:59
int32_t type
the type of record to look up
Definition: gns.h:64

References GnsClient::clh_head, GnsClient::clh_tail, GnsClient::client, ClientLookupHandle::gc, GNS_resolver_lookup(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_DNSPARSER_TYPE_A, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, LookupMessage::id, LookupMessage::key_len, ClientLookupHandle::lookup, name, LookupMessage::options, LookupMessage::recursion_depth_limit, ClientLookupHandle::request_id, send_lookup_response(), statistics, LookupMessage::type, v4_enabled, and v6_enabled.

Here is the call graph for this function:

◆ read_service_conf()

static void read_service_conf ( void *  cls,
const char *  section,
const char *  option,
const char *  value 
)
static

Reads the configuration and populates TLDs.

Parameters
clsunused
sectionname of section in config, always "gns"
optionname of the option, TLDs start with "."
valuevalue for the option, public key for TLDs

Definition at line 496 of file gnunet-service-gns.c.

500{
502 struct GNS_TopLevelDomain *tld;
503
504 (void) cls;
505 (void) section;
506 if (option[0] != '.')
507 return;
508 if (GNUNET_OK !=
510 strlen (value),
511 &pk,
512 sizeof(pk)))
513 {
515 section,
516 option,
517 _ (
518 "Properly base32-encoded public key required"));
519 return;
520 }
522 tld->tld = GNUNET_strdup (&option[1]);
523 tld->pkey = pk;
525 tld_tail,
526 tld);
527}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * value
Value of the record to add/remove.
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.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_invalid(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_string_to_data(), pk, GNS_TopLevelDomain::tld, tld_head, tld_tail, and value.

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 GNS requests.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

Definition at line 538 of file gnunet-service-gns.c.

541{
542 unsigned long long max_parallel_bg_queries = 16;
543
545 "gns",
547 NULL);
551 if (NULL == namecache_handle)
552 {
554 _ ("Failed to connect to the namecache!\n"));
556 return;
557 }
558 if (GNUNET_OK ==
560 "gns",
561 "MAX_PARALLEL_BACKGROUND_QUERIES",
562 &max_parallel_bg_queries))
563 {
565 "Number of allowed parallel background queries: %llu\n",
566 max_parallel_bg_queries);
567 }
569 (unsigned int) max_parallel_bg_queries);
570 if (NULL == dht_handle)
571 {
573 _ ("Could not connect to DHT!\n"));
575 NULL);
576 return;
577 }
580 c,
581 max_parallel_bg_queries);
582 if ((GNUNET_YES ==
584 "gns",
585 "INTERCEPT_DNS")) &&
586 (GNUNET_SYSERR ==
588 {
589 GNUNET_break (0);
591 NULL);
592 return;
593 }
595 c);
597 NULL);
598}
static void shutdown_task(void *cls)
Task run during shutdown.
static void read_service_conf(void *cls, const char *section, const char *option, const char *value)
Reads the configuration and populates TLDs.
int GNS_interceptor_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize DNS interceptor.
void GNS_resolver_init(struct GNUNET_NAMECACHE_Handle *nc, struct GNUNET_DHT_Handle *dht, const struct GNUNET_CONFIGURATION_Handle *c, unsigned long long max_bg_queries)
Initialize the resolver.
enum GNUNET_GenericReturnValue 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.
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".
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
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:1037
struct GNUNET_NAMECACHE_Handle * GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namecache service.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
Definition: network.c:79
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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:1340
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:1305
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.

References _, dht_handle, GNS_interceptor_init(), GNS_resolver_init(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_iterate_section_values(), GNUNET_DHT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NAMECACHE_connect(), GNUNET_NETWORK_test_pf(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_SYSERR, GNUNET_YES, namecache_handle, read_service_conf(), shutdown_task(), statistics, v4_enabled, and v6_enabled.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "gns"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(lookup, GNUNET_MESSAGE_TYPE_GNS_LOOKUP, struct LookupMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Variable Documentation

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Our handle to the DHT.

Definition at line 137 of file gnunet-service-gns.c.

Referenced by run(), and shutdown_task().

◆ namecache_handle

struct GNUNET_NAMECACHE_Handle* namecache_handle
static

Our handle to the namecache service.

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

Referenced by run(), and shutdown_task().

◆ v6_enabled

int v6_enabled
static

GNUNET_YES if ipv6 is supported

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

Referenced by handle_lookup(), and run().

◆ v4_enabled

int v4_enabled
static

GNUNET_YES if ipv4 is supported

Definition at line 152 of file gnunet-service-gns.c.

Referenced by handle_lookup(), and run().

◆ statistics

struct GNUNET_STATISTICS_Handle* statistics
static

Handle to the statistics service.

Definition at line 157 of file gnunet-service-gns.c.

Referenced by handle_lookup(), run(), send_lookup_response(), and shutdown_task().

◆ tld_head

struct GNS_TopLevelDomain* tld_head
static

Head of DLL of TLDs we map to GNS zones.

Definition at line 162 of file gnunet-service-gns.c.

Referenced by GNS_find_tld(), read_service_conf(), and shutdown_task().

◆ tld_tail

struct GNS_TopLevelDomain* tld_tail
static

Tail of DLL of TLDs we map to GNS zones.

Definition at line 167 of file gnunet-service-gns.c.

Referenced by read_service_conf(), and shutdown_task().