GNU Name System (main service) More...
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_namecache_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_statistics_service.h"
#include "gns.h"
#include "gnunet-service-gns.h"
#include "gnunet-service-gns_resolver.h"
#include "gnunet-service-gns_interceptor.h"
#include "gnunet_protocols.h"
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 | |
enum GNUNET_GenericReturnValue | 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 (GNUNET_OS_project_data_gnunet(), "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_Handle * | dht_handle |
Our handle to the DHT. More... | |
static struct GNUNET_NAMECACHE_Handle * | namecache_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_Handle * | statistics |
Handle to the statistics service. More... | |
static struct GNS_TopLevelDomain * | tld_head |
Head of DLL of TLDs we map to GNS zones. More... | |
static struct GNS_TopLevelDomain * | tld_tail |
Tail of DLL of TLDs we map to GNS zones. More... | |
GNU Name System (main service)
Definition in file gnunet-service-gns.c.
enum GNUNET_GenericReturnValue GNS_find_tld | ( | const char * | tld_str, |
struct GNUNET_CRYPTO_PublicKey * | pkey | ||
) |
Find GNS zone belonging to TLD tld.
tld_str | top-level domain to look up | |
[out] | pkey | public key to set |
Definition at line 178 of file gnunet-service-gns.c.
References GNUNET_GNSRECORD_zkey_to_pkey(), GNUNET_NO, GNUNET_OK, GNUNET_YES, pkey, GNS_TopLevelDomain::tld, and tld_head.
Referenced by handle_dns_request().
const char * GNS_get_tld | ( | const char * | name | ) |
Obtain the TLD of the given name.
name | a name |
Definition at line 210 of file gnunet-service-gns.c.
References name, and GNS_TopLevelDomain::tld.
Referenced by handle_dns_request(), handle_gns_redirect_result(), and recursive_gns2dns_resolution().
|
static |
Task run during shutdown.
cls | unused, NULL |
Definition at line 230 of file gnunet-service-gns.c.
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().
|
static |
Called whenever a client is disconnected.
cls | closure |
client | identification of the client |
app_ctx | client |
Definition at line 274 of file gnunet-service-gns.c.
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.
|
static |
Add a client to our list of active clients.
cls | NULL |
client | client to add |
mq | message queue for client |
Definition at line 307 of file gnunet-service-gns.c.
References GnsClient::client, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, and GnsClient::mq.
|
static |
Reply to client with the result from our lookup.
cls | the closure (our client lookup handle) |
rd_count | the number of records in rd |
rd | the record data |
Definition at line 332 of file gnunet-service-gns.c.
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().
|
static |
Checks a GNUNET_MESSAGE_TYPE_GNS_LOOKUP message.
cls | client sending the message |
l_msg | message of type struct LookupMessage |
Definition at line 393 of file gnunet-service-gns.c.
References GNUNET_break, GNUNET_DNSPARSER_MAX_NAME_LENGTH, GNUNET_OK, GNUNET_SYSERR, LookupMessage::header, LookupMessage::key_len, and GNUNET_MessageHeader::size.
|
static |
Handle lookup requests from client.
cls | the closure |
sh_msg | the message |
Definition at line 418 of file gnunet-service-gns.c.
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.
|
static |
Reads the configuration and populates TLDs.
cls | unused |
section | name of section in config, always "gns" |
option | name of the option, TLDs start with "." |
value | value for the option, public key for TLDs |
Definition at line 495 of file gnunet-service-gns.c.
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().
|
static |
Process GNS requests.
cls | closure |
server | the initialized server |
c | configuration to use |
Definition at line 538 of file gnunet-service-gns.c.
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.
GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
"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.
|
static |
Our handle to the DHT.
Definition at line 137 of file gnunet-service-gns.c.
Referenced by run(), and shutdown_task().
|
static |
Our handle to the namecache service.
Definition at line 142 of file gnunet-service-gns.c.
Referenced by run(), and shutdown_task().
|
static |
GNUNET_YES if ipv6 is supported
Definition at line 147 of file gnunet-service-gns.c.
Referenced by handle_lookup(), and run().
|
static |
GNUNET_YES if ipv4 is supported
Definition at line 152 of file gnunet-service-gns.c.
Referenced by handle_lookup(), and run().
|
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().
|
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().
|
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().