182 if (
'\0' == *tld_str)
188 if (0 == strcasecmp (tld_str,
216 (
unsigned char)
'.');
240 if (NULL != statistics)
246 if (NULL != namecache_handle)
249 namecache_handle = NULL;
251 if (NULL != dht_handle)
256 while (NULL != (tld = tld_head))
284 "Client %p disconnected\n",
286 while (NULL != (clh = gc->
clh_head))
316 "Client %p connected\n",
344 "Sending LOOKUP_RESULT message with %u results\n",
345 (
unsigned int) rd_count);
354 if (len > UINT16_MAX -
sizeof(*rmsg))
377 "Completed lookups", 1,
425 char *nameptr =
name;
429 utf_in = (
const char *) &sh_msg[1];
433 "Received LOOKUP `%s' message\n",
445 "LOOKUP: Query for A record but AF_INET not supported!");
455 "LOOKUP: Query for AAAA record but AF_INET6 not supported!");
462 ntohl (sh_msg->
type),
493 if (option[0] !=
'.')
505 "Properly base32-encoded public key required"));
529 unsigned long long max_parallel_bg_queries = 16;
538 if (NULL == namecache_handle)
541 _ (
"Failed to connect to the namecache!\n"));
548 "MAX_PARALLEL_BACKGROUND_QUERIES",
549 &max_parallel_bg_queries))
552 "Number of allowed parallel background queries: %llu\n",
553 max_parallel_bg_queries);
556 (
unsigned int) max_parallel_bg_queries);
557 if (NULL == dht_handle)
560 _ (
"Could not connect to DHT!\n"));
568 max_parallel_bg_queries);
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Process GNS requests.
Message from client to GNS service to lookup records.
struct GNUNET_NAMECACHE_Handle * GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namecache service.
Message from GNS service to client: new results.
uint32_t id
Unique identifier for this request (for key collisions).
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
GNUNET_NETWORK_STRUCT_END 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.
struct GNS_TopLevelDomain * next
Kept in a DLL, as there are unlikely enough of these to warrant a hash map.
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
struct ClientLookupHandle * prev
We keep these in a DLL.
static struct GNS_TopLevelDomain * tld_head
Head of DLL of TLDs we map to GNS zones.
static char * pkey
Public key of the zone to look in, in ASCII.
uint32_t rd_count
The number of records contained in response.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNS_TopLevelDomain * prev
Kept in a DLL, as there are unlikely enough of these to warrant a hash map.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
int GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey, struct GNUNET_IDENTITY_PublicKey *pkey)
Convert an absolute domain name to the respective public key.
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.
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.
const char * GNS_get_tld(const char *name)
Obtain the TLD of the given name.
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP
Client would like to resolve a name.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT
Service response to name resolution request from client.
GNUNET_GNS_LocalOptions
Options for the GNS lookup.
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.
struct ClientLookupHandle * next
We keep these in a DLL.
int32_t type
the type of record to look up
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
static int v6_enabled
GNUNET_YES if ipv6 is supported
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
IPC messages between GNS API and GNS service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNS_interceptor_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialized the interceptor.
Handle to a currently pending resolution.
Connection to the DHT service.
struct GNUNET_MQ_Handle * mq
The MQ.
static char * section
Name of the section.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
Handle to a client that is connected to a service.
static int check_lookup(void *cls, const struct LookupMessage *l_msg)
Checks a GNUNET_MESSAGE_TYPE_GNS_LOOKUP message.
uint16_t recursion_depth_limit
Recursion depth limit, i.e.
struct GNUNET_SERVICE_Client * client
The client.
uint32_t request_id
request id
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_GNS_LOOKUP.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH
Maximum length of a name in DNS.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
static void shutdown_task(void *cls)
Task run during shutdown.
static char * value
Value of the record to add/remove.
uint32_t id
Unique identifier for this request (for key collisions).
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void handle_lookup(void *cls, const struct LookupMessage *sh_msg)
Handle lookup requests from client.
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.
static struct GNUNET_NAMECACHE_Handle * namecache_handle
Our handle to the namecache service.
static struct GNS_TopLevelDomain * tld_tail
Tail of DLL of TLDs we map to GNS zones.
static char * option
Name of the option.
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.
void GNS_interceptor_done()
Disconnect from interceptor.
struct GnsClient * gc
Client handle.
void GNS_resolver_done()
Shutdown resolver.
static int v4_enabled
GNUNET_YES if ipv4 is supported
struct GNS_ResolverHandle * lookup
Active handle for the lookup.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Handle to a lookup operation from client via API.
int16_t options
Local options for where to look for results (an enum GNUNET_GNS_LocalOptions in NBO).
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
struct GNUNET_MQ_Envelope * env
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.
static void read_service_conf(void *cls, const char *section, const char *option, const char *value)
Reads the configuration and populates TLDs.
Handle to a message queue.
An identity key as per LSD0001.
int GNS_find_tld(const char *tld_str, struct GNUNET_IDENTITY_PublicKey *pkey)
Find GNS zone belonging to TLD tld.
Information we track per connected client.
#define GNUNET_DNSPARSER_TYPE_AAAA
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
Representation of a TLD, mapping the respective TLD string (i.e.
struct ClientLookupHandle * clh_head
Head of the DLL.
Connection to the NAMECACHE service.
struct GNUNET_MQ_Handle * mq
struct GNUNET_IDENTITY_PublicKey pkey
Public key associated with the tld.
#define GNUNET_log(kind,...)
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.
char * tld
Top-level domain as a string, including leading ".".
void GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from the namecache service (and free associated resources).
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_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
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.
struct GNUNET_IDENTITY_PublicKey zone
Zone that is to be used for lookup.
#define GNUNET_DNSPARSER_TYPE_A
struct GNS_ResolverHandle * GNS_resolver_lookup(const struct GNUNET_IDENTITY_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.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
int GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
struct ClientLookupHandle * clh_tail
Tail of the DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...