GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
resolver_api.c File Reference

resolver for writing a tool More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
#include "resolver.h"
Include dependency graph for resolver_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_RESOLVER_RequestHandle
 Handle to a request given to the resolver. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from(kind, "util-resolver-api", __VA_ARGS__)
 
#define LOG_STRERROR(kind, syscall)   GNUNET_log_from_strerror(kind, "util-resolver-api", syscall)
 
#define MAX_HOSTNAME   1024
 Maximum supported length for a hostname. More...
 

Functions

static int check_config ()
 Check that the resolver service runs on localhost (or equivalent). More...
 
void GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create the connection to the resolver service. More...
 
void GNUNET_RESOLVER_disconnect ()
 Destroy the connection to the resolver service. More...
 
static void shutdown_task (void *cls)
 Task executed on system shutdown. More...
 
static void check_disconnect ()
 Consider disconnecting if we have no further requests pending. More...
 
static char * no_resolve (int af, const void *ip, socklen_t ip_len)
 Convert IP address to string without DNS resolution. More...
 
static void reconnect (void)
 Adjust exponential back-off and reconnect to the service. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void process_requests ()
 Process pending requests to the resolver. More...
 
static int check_response (void *cls, const struct GNUNET_RESOLVER_ResponseMessage *msg)
 Check validity of response with a hostname for a DNS lookup. More...
 
static void handle_response (void *cls, const struct GNUNET_RESOLVER_ResponseMessage *msg)
 Check validity of response with a hostname for a DNS lookup. More...
 
static void numeric_resolution (void *cls)
 We've been asked to lookup the address for a hostname and were given a valid numeric string. More...
 
static void loopback_resolution (void *cls)
 We've been asked to lookup the address for a hostname and were given a variant of "loopback". More...
 
static void reconnect_task (void *cls)
 Now try to reconnect to the resolver service. More...
 
static void handle_lookup_timeout (void *cls)
 A DNS resolution timed out. More...
 
struct GNUNET_RESOLVER_RequestHandleGNUNET_RESOLVER_ip_get (const char *hostname, int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls)
 Convert a string to one or more IP addresses. More...
 
static void numeric_reverse (void *cls)
 We've been asked to convert an address to a string without a reverse lookup, either because the client asked for it or because the DNS lookup hit a timeout. More...
 
struct GNUNET_RESOLVER_RequestHandleGNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, int do_resolve, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_HostnameCallback callback, void *cls)
 Get an IP address as a string. More...
 
char * GNUNET_RESOLVER_local_fqdn_get ()
 Get local fully qualified af name. More...
 
struct GNUNET_RESOLVER_RequestHandleGNUNET_RESOLVER_hostname_resolve (int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *cls)
 Looking our own hostname. More...
 
void GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh)
 Cancel a request that is still pending with the resolver. More...
 

Variables

static const char * loopback []
 Possible hostnames for "loopback". More...
 
static const struct GNUNET_CONFIGURATION_Handleresolver_cfg
 Configuration. More...
 
static struct GNUNET_MQ_Handlemq
 Our connection to the resolver service, created on-demand, but then persists until error or shutdown. More...
 
static struct GNUNET_RESOLVER_RequestHandlereq_head
 Head of DLL of requests. More...
 
static struct GNUNET_RESOLVER_RequestHandlereq_tail
 Tail of DLL of requests. More...
 
static uint32_t last_request_id
 ID of the last request we sent to the service. More...
 
static struct GNUNET_TIME_Relative backoff
 How long should we wait to reconnect? More...
 
static struct GNUNET_SCHEDULER_Taskr_task
 Task for reconnecting. More...
 
static struct GNUNET_SCHEDULER_Tasks_task
 Task ID of shutdown task; only present while we have a connection to the resolver service. More...
 

Detailed Description

resolver for writing a tool

Author
Christian Grothoff

Definition in file resolver_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from(kind, "util-resolver-api", __VA_ARGS__)

◆ LOG_STRERROR

#define LOG_STRERROR (   kind,
  syscall 
)    GNUNET_log_from_strerror(kind, "util-resolver-api", syscall)

◆ MAX_HOSTNAME

#define MAX_HOSTNAME   1024

Maximum supported length for a hostname.

Definition at line 39 of file resolver_api.c.

Function Documentation

◆ check_config()

static int check_config ( )
static

Check that the resolver service runs on localhost (or equivalent).

Returns
GNUNET_OK if the resolver is properly configured, GNUNET_SYSERR otherwise.

Definition at line 187 of file resolver_api.c.

References _, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_OK, GNUNET_SYSERR, hostname, LOG, and loopback.

Referenced by GNUNET_RESOLVER_hostname_get(), and GNUNET_RESOLVER_ip_get().

188 {
189  char *hostname;
190  struct sockaddr_in v4;
191  struct sockaddr_in6 v6;
192 
193  if (GNUNET_OK ==
195  "resolver",
196  "UNIXPATH"))
197  return GNUNET_OK;
198  memset(&v4, 0, sizeof(v4));
199  v4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
200  v4.sin_family = AF_INET;
201 #if HAVE_SOCKADDR_IN_SIN_LEN
202  v4.sin_len = sizeof(v4);
203 #endif
204  memset(&v6, 0, sizeof(v6));
205  v6.sin6_family = AF_INET6;
206 #if HAVE_SOCKADDR_IN_SIN_LEN
207  v6.sin6_len = sizeof(v6);
208 #endif
209  if (GNUNET_OK !=
211  "resolver",
212  "HOSTNAME",
213  &hostname))
214  {
216  _("Missing `%s' for `%s' in configuration, DNS resolution will be unavailable.\n"),
217  "HOSTNAME",
218  "resolver");
219  return GNUNET_SYSERR;
220  }
221  if ((1 == inet_pton(AF_INET, hostname, &v4)) ||
222  (1 == inet_pton(AF_INET6, hostname, &v6)))
223  {
224  GNUNET_free(hostname);
225  return GNUNET_OK;
226  }
227  for (unsigned int i = 0;
228  NULL != loopback[i];
229  i++)
230  if (0 == strcasecmp(loopback[i],
231  hostname))
232  {
233  GNUNET_free(hostname);
234  return GNUNET_OK;
235  }
237  _("Missing `%s' or numeric IP address for `%s' of `%s' in configuration, DNS resolution will be unavailable.\n"),
238  "localhost",
239  "HOSTNAME",
240  "resolver");
241  GNUNET_free(hostname);
242  return GNUNET_SYSERR;
243 }
static const struct GNUNET_CONFIGURATION_Handle * resolver_cfg
Configuration.
Definition: resolver_api.c:55
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define LOG(kind,...)
Definition: resolver_api.c:32
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static const char * loopback[]
Possible hostnames for "loopback".
Definition: resolver_api.c:45
int GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static char * hostname
Our hostname; we give this to all the peers we start.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task executed on system shutdown.

Definition at line 300 of file resolver_api.c.

References backoff, GNUNET_RESOLVER_disconnect(), and GNUNET_TIME_UNIT_MILLISECONDS.

Referenced by check_disconnect(), and process_requests().

301 {
302  (void)cls;
303  s_task = NULL;
306 }
static struct GNUNET_TIME_Relative backoff
How long should we wait to reconnect?
Definition: resolver_api.c:81
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static struct GNUNET_SCHEDULER_Task * s_task
Task ID of shutdown task; only present while we have a connection to the resolver service...
Definition: resolver_api.c:92
void GNUNET_RESOLVER_disconnect()
Destroy the connection to the resolver service.
Definition: resolver_api.c:264
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_disconnect()

static void check_disconnect ( )
static

Consider disconnecting if we have no further requests pending.

Definition at line 313 of file resolver_api.c.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_RESOLVER_RequestHandle::next, and shutdown_task().

Referenced by GNUNET_RESOLVER_request_cancel(), and reconnect().

314 {
315  for (struct GNUNET_RESOLVER_RequestHandle *rh = req_head;
316  NULL != rh;
317  rh = rh->next)
318  if (GNUNET_SYSERR != rh->was_transmitted)
319  return;
320  if (NULL != r_task)
321  {
323  r_task = NULL;
324  }
325  if (NULL != s_task)
326  return;
328  &shutdown_task,
329  NULL);
330 }
static struct GNUNET_SCHEDULER_Task * r_task
Task for reconnecting.
Definition: resolver_api.c:86
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_RESOLVER_RequestHandle * next
Next entry in DLL of requests.
Definition: resolver_api.c:104
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Handle to a request given to the resolver.
Definition: resolver_api.c:100
static void shutdown_task(void *cls)
Task executed on system shutdown.
Definition: resolver_api.c:300
static struct GNUNET_SCHEDULER_Task * s_task
Task ID of shutdown task; only present while we have a connection to the resolver service...
Definition: resolver_api.c:92
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ no_resolve()

static char* no_resolve ( int  af,
const void *  ip,
socklen_t  ip_len 
)
static

Convert IP address to string without DNS resolution.

Parameters
afaddress family
ipthe address
ip_lennumber of bytes in ip
Returns
address as a string, NULL on error

Definition at line 342 of file resolver_api.c.

References buf, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_strdup, LOG_STRERROR, and reconnect().

Referenced by handle_lookup_timeout(), handle_response(), and numeric_reverse().

345 {
346  char buf[INET6_ADDRSTRLEN];
347 
348  switch (af)
349  {
350  case AF_INET:
351  if (ip_len != sizeof(struct in_addr))
352  return NULL;
353  if (NULL ==
354  inet_ntop(AF_INET,
355  ip,
356  buf,
357  sizeof(buf)))
358  {
360  "inet_ntop");
361  return NULL;
362  }
363  break;
364 
365  case AF_INET6:
366  if (ip_len != sizeof(struct in6_addr))
367  return NULL;
368  if (NULL ==
369  inet_ntop(AF_INET6,
370  ip,
371  buf,
372  sizeof(buf)))
373  {
375  "inet_ntop");
376  return NULL;
377  }
378  break;
379 
380  default:
381  GNUNET_break(0);
382  return NULL;
383  }
384  return GNUNET_strdup(buf);
385 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define LOG_STRERROR(kind, syscall)
Definition: resolver_api.c:34
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char buf[2048]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reconnect()

static void reconnect ( void  )
static

Adjust exponential back-off and reconnect to the service.

Definition at line 821 of file resolver_api.c.

References backoff, check_disconnect(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_STD_BACKOFF, GNUNET_YES, LOG, reconnect_task(), and GNUNET_RESOLVER_RequestHandle::was_transmitted.

Referenced by handle_response(), mq_error_handler(), no_resolve(), process_requests(), and reconnect_task().

822 {
824 
825  if (NULL != r_task)
826  return;
827  GNUNET_assert(NULL == mq);
828  if (NULL != (rh = req_head))
829  {
830  switch (rh->was_transmitted)
831  {
832  case GNUNET_NO:
833  /* nothing more to do */
834  break;
835 
836  case GNUNET_YES:
837  /* disconnected, transmit again! */
839  break;
840 
841  case GNUNET_SYSERR:
842  /* request was cancelled, remove entirely */
844  req_tail,
845  rh);
846  GNUNET_free(rh);
848  break;
849 
850  default:
851  GNUNET_assert(0);
852  break;
853  }
854  }
856  "Will try to connect to DNS service in %s\n",
858  GNUNET_YES));
859  GNUNET_assert(NULL != resolver_cfg);
862  NULL);
864 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_SCHEDULER_Task * r_task
Task for reconnecting.
Definition: resolver_api.c:86
static struct GNUNET_TIME_Relative backoff
How long should we wait to reconnect?
Definition: resolver_api.c:81
static struct GNUNET_RESOLVER_RequestHandle * req_tail
Tail of DLL of requests.
Definition: resolver_api.c:71
static void reconnect_task(void *cls)
Now try to reconnect to the resolver service.
Definition: resolver_api.c:785
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static const struct GNUNET_CONFIGURATION_Handle * resolver_cfg
Configuration.
Definition: resolver_api.c:55
#define GNUNET_NO
Definition: gnunet_common.h:78
#define LOG(kind,...)
Definition: resolver_api.c:32
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Handle to a request given to the resolver.
Definition: resolver_api.c:100
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown...
Definition: resolver_api.c:61
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
static void check_disconnect()
Consider disconnecting if we have no further requests pending.
Definition: resolver_api.c:313
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsNULL
errorerror code

Definition at line 404 of file resolver_api.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_destroy(), LOG, and reconnect().

Referenced by reconnect_task().

406 {
407  (void)cls;
409  mq = NULL;
411  "MQ error %d, reconnecting\n",
412  error);
413  reconnect();
414 }
#define LOG(kind,...)
Definition: resolver_api.c:32
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown...
Definition: resolver_api.c:61
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:821
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_requests()

static void process_requests ( )
static

Process pending requests to the resolver.

Definition at line 421 of file resolver_api.c.

References GNUNET_RESOLVER_GetMessage::af, GNUNET_RESOLVER_RequestHandle::af, GNUNET_RESOLVER_GetMessage::client_id, GNUNET_RESOLVER_RequestHandle::data_len, GNUNET_RESOLVER_GetMessage::direction, GNUNET_RESOLVER_RequestHandle::direction, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, GNUNET_RESOLVER_RequestHandle::id, LOG, msg, reconnect(), req_head, shutdown_task(), and GNUNET_RESOLVER_RequestHandle::was_transmitted.

Referenced by GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), handle_lookup_timeout(), handle_response(), and reconnect_task().

422 {
424  struct GNUNET_MQ_Envelope *env;
426 
427  if (NULL == mq)
428  {
429  reconnect();
430  return;
431  }
432  if (NULL == rh)
433  {
434  /* nothing to do, release socket really soon if there is nothing
435  * else happening... */
436  if (NULL == s_task)
437  s_task =
439  &shutdown_task,
440  NULL);
441  return;
442  }
443  if (GNUNET_NO != rh->was_transmitted)
444  return; /* waiting for reply */
445  env = GNUNET_MQ_msg_extra(msg,
446  rh->data_len,
448  msg->direction = htonl(rh->direction);
449  msg->af = htonl(rh->af);
450  msg->client_id = rh->id;
451  GNUNET_memcpy(&msg[1],
452  &rh[1],
453  rh->data_len);
455  "Transmitting DNS resolution request (ID %u) to DNS service\n",
456  rh->id);
458  env);
460 }
int32_t direction
GNUNET_YES to get hostname from IP, GNUNET_NO to get IP from hostname.
Definition: resolver.h:53
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define LOG(kind,...)
Definition: resolver_api.c:32
#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:52
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
int af
Desired address family.
Definition: resolver_api.c:142
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
Handle to a request given to the resolver.
Definition: resolver_api.c:100
static void shutdown_task(void *cls)
Task executed on system shutdown.
Definition: resolver_api.c:300
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_SCHEDULER_Task * s_task
Task ID of shutdown task; only present while we have a connection to the resolver service...
Definition: resolver_api.c:92
int32_t af
Address family to use (AF_INET, AF_INET6 or AF_UNSPEC).
Definition: resolver.h:58
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown...
Definition: resolver_api.c:61
#define GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST
Request DNS resolution.
uint32_t client_id
identifies the request and is contained in the response message.
Definition: resolver.h:64
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:175
Request for the resolver.
Definition: resolver.h:43
uint32_t id
Identifies the request.
Definition: resolver_api.c:147
int direction
Desired direction (IP to name or name to IP)
Definition: resolver_api.c:165
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:821
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_response()

static int check_response ( void *  cls,
const struct GNUNET_RESOLVER_ResponseMessage msg 
)
static

Check validity of response with a hostname for a DNS lookup.

Parameters
clsNULL
msgmessage with the hostname

Definition at line 470 of file resolver_api.c.

References GNUNET_OK.

472 {
473  (void)cls;
474  (void)msg;
475 
476  /* implemented in #handle_response() for now */
477  return GNUNET_OK;
478 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126

◆ handle_response()

static void handle_response ( void *  cls,
const struct GNUNET_RESOLVER_ResponseMessage msg 
)
static

Check validity of response with a hostname for a DNS lookup.

NOTE: right now rather messy, might want to use different message types for different response formats in the future.

Parameters
clsNULL
msgmessage with the response

Definition at line 490 of file resolver_api.c.

References GNUNET_RESOLVER_RequestHandle::addr_callback, GNUNET_RESOLVER_RequestHandle::af, GNUNET_RESOLVER_ResponseMessage::client_id, GNUNET_RESOLVER_RequestHandle::cls, GNUNET_RESOLVER_RequestHandle::data_len, GNUNET_a2s(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_RESOLVER_request_cancel(), GNUNET_SYSERR, GNUNET_YES, GNUNET_RESOLVER_ResponseMessage::header, hostname, GNUNET_RESOLVER_RequestHandle::id, LOG, GNUNET_RESOLVER_RequestHandle::name_callback, GNUNET_RESOLVER_RequestHandle::next, no_resolve(), process_requests(), GNUNET_RESOLVER_RequestHandle::received_response, reconnect(), req_head, size, GNUNET_MessageHeader::size, and GNUNET_RESOLVER_RequestHandle::was_transmitted.

492 {
494  uint16_t size;
495  char *nret;
496  uint32_t client_request_id = msg->client_id;
497 
498  for (; rh != NULL; rh = rh->next)
499  {
500  if (rh->id == client_request_id)
501  break;
502  }
503 
504  (void)cls;
505  if (NULL == rh)
506  {
507  /* Resolver service sent extra replies to query (after terminator)? Bad! */
508  GNUNET_break(0);
510  mq = NULL;
511  reconnect();
512  return;
513  }
514  size = ntohs(msg->header.size);
515  if (size == sizeof(struct GNUNET_RESOLVER_ResponseMessage))
516  {
518  "Received empty response from DNS service\n");
519  /* message contains not data, just header; end of replies */
520  /* check if request was canceled */
521  if (GNUNET_SYSERR != rh->was_transmitted)
522  {
523  /* no reverse lookup was successful, return IP as string */
524  if (NULL != rh->name_callback)
525  {
526  if (GNUNET_NO == rh->received_response)
527  {
528  nret = no_resolve(rh->af,
529  &rh[1],
530  rh->data_len);
531  rh->name_callback(rh->cls, nret);
532  GNUNET_free(nret);
533  }
534  /* finally, make termination call */
535  if (GNUNET_SYSERR != rh->was_transmitted)
536  rh->name_callback(rh->cls,
537  NULL);
538  }
539  if ((NULL != rh->addr_callback) &&
541  rh->addr_callback(rh->cls,
542  NULL,
543  0);
544  }
548  return;
549  }
550  /* return reverse lookup results to caller */
551  if (NULL != rh->name_callback)
552  {
553  const char *hostname;
554 
555  hostname = (const char *)&msg[1];
556  if (hostname[size - sizeof(struct GNUNET_RESOLVER_ResponseMessage) - 1] != '\0')
557  {
558  GNUNET_break(0);
559  if (GNUNET_SYSERR != rh->was_transmitted)
560  rh->name_callback(rh->cls,
561  NULL);
565  mq = NULL;
566  reconnect();
567  return;
568  }
570  "Resolver returns `%s' for IP `%s'.\n",
571  hostname,
572  GNUNET_a2s((const void *)&rh[1],
573  rh->data_len));
574  if (rh->was_transmitted != GNUNET_SYSERR)
575  rh->name_callback(rh->cls,
576  hostname);
578  }
579  /* return lookup results to caller */
580  if (NULL != rh->addr_callback)
581  {
582  struct sockaddr_in v4;
583  struct sockaddr_in6 v6;
584  const struct sockaddr *sa;
585  socklen_t salen;
586  const void *ip;
587  size_t ip_len;
588 
589  ip = &msg[1];
590  ip_len = size - sizeof(struct GNUNET_RESOLVER_ResponseMessage);
591  if (ip_len == sizeof(struct in_addr))
592  {
593  memset(&v4, 0, sizeof(v4));
594  v4.sin_family = AF_INET;
595  v4.sin_addr = *(struct in_addr*)ip;
596 #if HAVE_SOCKADDR_IN_SIN_LEN
597  v4.sin_len = sizeof(v4);
598 #endif
599  salen = sizeof(v4);
600  sa = (const struct sockaddr *)&v4;
601  }
602  else if (ip_len == sizeof(struct in6_addr))
603  {
604  memset(&v6, 0, sizeof(v6));
605  v6.sin6_family = AF_INET6;
606  v6.sin6_addr = *(struct in6_addr*)ip;
607 #if HAVE_SOCKADDR_IN_SIN_LEN
608  v6.sin6_len = sizeof(v6);
609 #endif
610  salen = sizeof(v6);
611  sa = (const struct sockaddr *)&v6;
612  }
613  else
614  {
615  GNUNET_break(0);
616  if (GNUNET_SYSERR != rh->was_transmitted)
617  rh->addr_callback(rh->cls,
618  NULL,
619  0);
623  mq = NULL;
624  reconnect();
625  return;
626  }
628  "Received IP from DNS service\n");
629  if (GNUNET_SYSERR != rh->was_transmitted)
630  rh->addr_callback(rh->cls,
631  sa,
632  salen);
633  }
634 }
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
GNUNET_RESOLVER_AddressCallback addr_callback
Callback if this is an name resolution request, otherwise NULL.
Definition: resolver_api.c:115
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static void process_requests()
Process pending requests to the resolver.
Definition: resolver_api.c:421
uint32_t client_id
identifies the request this message responds to.
Definition: resolver.h:81
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE.
Definition: resolver.h:75
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG(kind,...)
Definition: resolver_api.c:32
GNUNET_RESOLVER_HostnameCallback name_callback
Callback if this is a reverse lookup request, otherwise NULL.
Definition: resolver_api.c:121
int af
Desired address family.
Definition: resolver_api.c:142
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages)...
struct GNUNET_RESOLVER_RequestHandle * next
Next entry in DLL of requests.
Definition: resolver_api.c:104
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
Handle to a request given to the resolver.
Definition: resolver_api.c:100
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown...
Definition: resolver_api.c:61
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_YES
Definition: gnunet_common.h:77
static char * no_resolve(int af, const void *ip, socklen_t ip_len)
Convert IP address to string without DNS resolution.
Definition: resolver_api.c:342
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:175
uint32_t id
Identifies the request.
Definition: resolver_api.c:147
int received_response
GNUNET_YES if a response was received
Definition: resolver_api.c:170
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:821
Here is the call graph for this function:

◆ numeric_resolution()

static void numeric_resolution ( void *  cls)
static

We've been asked to lookup the address for a hostname and were given a valid numeric string.

Perform the callbacks for the numeric addresses.

Parameters
clsstruct GNUNET_RESOLVER_RequestHandle for the request

Definition at line 645 of file resolver_api.c.

References GNUNET_RESOLVER_RequestHandle::addr_callback, GNUNET_RESOLVER_RequestHandle::af, GNUNET_RESOLVER_RequestHandle::cls, GNUNET_assert, GNUNET_free, GNUNET_SYSERR, hostname, GNUNET_RESOLVER_RequestHandle::task, and GNUNET_RESOLVER_RequestHandle::was_transmitted.

Referenced by GNUNET_RESOLVER_ip_get().

646 {
647  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
648  struct sockaddr_in v4;
649  struct sockaddr_in6 v6;
650  const char *hostname;
651 
652  rh->task = NULL;
653  memset(&v4, 0, sizeof(v4));
654  v4.sin_family = AF_INET;
655 #if HAVE_SOCKADDR_IN_SIN_LEN
656  v4.sin_len = sizeof(v4);
657 #endif
658  memset(&v6, 0, sizeof(v6));
659  v6.sin6_family = AF_INET6;
660 #if HAVE_SOCKADDR_IN_SIN_LEN
661  v6.sin6_len = sizeof(v6);
662 #endif
663  hostname = (const char *)&rh[1];
664  if (((rh->af == AF_UNSPEC) ||
665  (rh->af == AF_INET)) &&
666  (1 == inet_pton(AF_INET,
667  hostname,
668  &v4.sin_addr)))
669  {
670  rh->addr_callback(rh->cls,
671  (const struct sockaddr *)&v4,
672  sizeof(v4));
673  if ((rh->af == AF_UNSPEC) &&
674  (GNUNET_SYSERR != rh->was_transmitted) &&
675  (1 == inet_pton(AF_INET6,
676  hostname,
677  &v6.sin6_addr)))
678  {
679  /* this can happen on some systems IF "hostname" is "localhost" */
680  rh->addr_callback(rh->cls,
681  (const struct sockaddr *)&v6,
682  sizeof(v6));
683  }
684  if (GNUNET_SYSERR != rh->was_transmitted)
685  rh->addr_callback(rh->cls,
686  NULL,
687  0);
688  GNUNET_free(rh);
689  return;
690  }
691  if (((rh->af == AF_UNSPEC) ||
692  (rh->af == AF_INET6)) &&
693  (1 == inet_pton(AF_INET6,
694  hostname,
695  &v6.sin6_addr)))
696  {
697  rh->addr_callback(rh->cls,
698  (const struct sockaddr *)&v6,
699  sizeof(v6));
700  if (GNUNET_SYSERR != rh->was_transmitted)
701  rh->addr_callback(rh->cls,
702  NULL,
703  0);
704  GNUNET_free(rh);
705  return;
706  }
707  /* why are we here? this task should not have been scheduled! */
708  GNUNET_assert(0);
709  GNUNET_free(rh);
710 }
GNUNET_RESOLVER_AddressCallback addr_callback
Callback if this is an name resolution request, otherwise NULL.
Definition: resolver_api.c:115
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int af
Desired address family.
Definition: resolver_api.c:142
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:137
Handle to a request given to the resolver.
Definition: resolver_api.c:100
static char * hostname
Our hostname; we give this to all the peers we start.
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ loopback_resolution()

static void loopback_resolution ( void *  cls)
static

We've been asked to lookup the address for a hostname and were given a variant of "loopback".

Perform the callbacks for the respective loopback numeric addresses.

Parameters
clsstruct GNUNET_RESOLVER_RequestHandle for the request

Definition at line 721 of file resolver_api.c.

References GNUNET_RESOLVER_RequestHandle::addr_callback, GNUNET_RESOLVER_RequestHandle::af, GNUNET_RESOLVER_RequestHandle::cls, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SYSERR, LOG, GNUNET_RESOLVER_RequestHandle::task, and GNUNET_RESOLVER_RequestHandle::was_transmitted.

Referenced by GNUNET_RESOLVER_ip_get().

722 {
723  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
724  struct sockaddr_in v4;
725  struct sockaddr_in6 v6;
726 
727  rh->task = NULL;
728  memset(&v4, 0, sizeof(v4));
729  v4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
730  v4.sin_family = AF_INET;
731 #if HAVE_SOCKADDR_IN_SIN_LEN
732  v4.sin_len = sizeof(v4);
733 #endif
734  memset(&v6, 0, sizeof(v6));
735  v6.sin6_family = AF_INET6;
736 #if HAVE_SOCKADDR_IN_SIN_LEN
737  v6.sin6_len = sizeof(v6);
738 #endif
739  v6.sin6_addr = in6addr_loopback;
740  switch (rh->af)
741  {
742  case AF_INET:
743  rh->addr_callback(rh->cls,
744  (const struct sockaddr *)&v4,
745  sizeof(v4));
746  break;
747 
748  case AF_INET6:
749  rh->addr_callback(rh->cls,
750  (const struct sockaddr *)&v6,
751  sizeof(v6));
752  break;
753 
754  case AF_UNSPEC:
755  rh->addr_callback(rh->cls,
756  (const struct sockaddr *)&v6,
757  sizeof(v6));
758  rh->addr_callback(rh->cls,
759  (const struct sockaddr *)&v4,
760  sizeof(v4));
761 
762  break;
763 
764  default:
765  GNUNET_break(0);
766  break;
767  }
768  if (GNUNET_SYSERR != rh->was_transmitted)
769  rh->addr_callback(rh->cls,
770  NULL,
771  0);
773  "Finished resolving hostname `%s'.\n",
774  (const char *)&rh[1]);
775  GNUNET_free(rh);
776 }
GNUNET_RESOLVER_AddressCallback addr_callback
Callback if this is an name resolution request, otherwise NULL.
Definition: resolver_api.c:115
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG(kind,...)
Definition: resolver_api.c:32
int af
Desired address family.
Definition: resolver_api.c:142
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:137
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ reconnect_task()

static void reconnect_task ( void *  cls)
static

Now try to reconnect to the resolver service.

Parameters
clsNULL

Definition at line 785 of file resolver_api.c.

References GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, LOG, mq_error_handler(), process_requests(), reconnect(), and response.

Referenced by reconnect().

786 {
791  NULL),
793  };
794 
795  (void)cls;
796  r_task = NULL;
797  if (NULL == req_head)
798  return; /* no work pending */
800  "Trying to connect to DNS service\n");
802  "resolver",
803  handlers,
805  NULL);
806  if (NULL == mq)
807  {
809  "Failed to connect, will try again later\n");
810  reconnect();
811  return;
812  }
814 }
static struct GNUNET_SCHEDULER_Task * r_task
Task for reconnecting.
Definition: resolver_api.c:86
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:900
static const struct GNUNET_CONFIGURATION_Handle * resolver_cfg
Configuration.
Definition: resolver_api.c:55
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: resolver_api.c:404
static void process_requests()
Process pending requests to the resolver.
Definition: resolver_api.c:421
#define LOG(kind,...)
Definition: resolver_api.c:32
void * cls
Closure for mv and cb.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE
Response to a DNS resolution request.
Message handler for a specific message type.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown...
Definition: resolver_api.c:61
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
static struct MHD_Response * response
Our canonical response.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:821
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_lookup_timeout()

static void handle_lookup_timeout ( void *  cls)
static

A DNS resolution timed out.

Notify the application.

Parameters
clsthe struct GNUNET_RESOLVER_RequestHandle *

Definition at line 873 of file resolver_api.c.

References _, GNUNET_RESOLVER_RequestHandle::af, buf, GNUNET_RESOLVER_RequestHandle::cls, GNUNET_RESOLVER_RequestHandle::direction, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_NO, GNUNET_RESOLVER_request_cancel(), LOG, no_resolve(), process_requests(), GNUNET_RESOLVER_RequestHandle::task, and GNUNET_RESOLVER_RequestHandle::was_transmitted.

Referenced by GNUNET_RESOLVER_hostname_get(), and GNUNET_RESOLVER_ip_get().

874 {
875  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
876 
877  rh->task = NULL;
878  if (GNUNET_NO == rh->direction)
879  {
881  _("Timeout trying to resolve hostname `%s'.\n"),
882  (const char *)&rh[1]);
883  if (NULL != rh->addr_callback)
884  rh->addr_callback(rh->cls,
885  NULL,
886  0);
887  }
888  else
889  {
890 #if !defined(GNUNET_CULL_LOGGING)
891  char buf[INET6_ADDRSTRLEN];
892 
894  _("Timeout trying to resolve IP address `%s'.\n"),
895  inet_ntop(rh->af,
896  (const void *)&rh[1],
897  buf,
898  sizeof(buf)));
899 #endif
900  if (GNUNET_NO == rh->received_response)
901  {
902  char *nret;
903 
904  nret = no_resolve(rh->af,
905  &rh[1],
906  rh->data_len);
907  if (NULL != rh->name_callback)
908  rh->name_callback(rh->cls, nret);
909  GNUNET_free(nret);
910  }
911  /* finally, make termination call */
912  if (NULL != rh->name_callback)
913  rh->name_callback(rh->cls,
914  NULL);
915  }
919 }
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
GNUNET_RESOLVER_AddressCallback addr_callback
Callback if this is an name resolution request, otherwise NULL.
Definition: resolver_api.c:115
#define GNUNET_NO
Definition: gnunet_common.h:78
static void process_requests()
Process pending requests to the resolver.
Definition: resolver_api.c:421
#define LOG(kind,...)
Definition: resolver_api.c:32
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
GNUNET_RESOLVER_HostnameCallback name_callback
Callback if this is a reverse lookup request, otherwise NULL.
Definition: resolver_api.c:121
int af
Desired address family.
Definition: resolver_api.c:142
static char buf[2048]
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:155
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:137
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
static char * no_resolve(int af, const void *ip, socklen_t ip_len)
Convert IP address to string without DNS resolution.
Definition: resolver_api.c:342
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:175
int direction
Desired direction (IP to name or name to IP)
Definition: resolver_api.c:165
int received_response
GNUNET_YES if a response was received
Definition: resolver_api.c:170
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ numeric_reverse()

static void numeric_reverse ( void *  cls)
static

We've been asked to convert an address to a string without a reverse lookup, either because the client asked for it or because the DNS lookup hit a timeout.

Do the numeric conversion and invoke the callback.

Parameters
clsstruct GNUNET_RESOLVER_RequestHandle for the request

Definition at line 1023 of file resolver_api.c.

References GNUNET_RESOLVER_RequestHandle::af, GNUNET_RESOLVER_RequestHandle::cls, GNUNET_RESOLVER_RequestHandle::data_len, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), LOG, GNUNET_RESOLVER_RequestHandle::name_callback, no_resolve(), result, and GNUNET_RESOLVER_RequestHandle::task.

Referenced by GNUNET_RESOLVER_hostname_get().

1024 {
1025  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
1026  char *result;
1027 
1028  rh->task = NULL;
1029  result = no_resolve(rh->af,
1030  &rh[1],
1031  rh->data_len);
1033  "Resolver returns `%s'.\n",
1034  result);
1035  if (NULL != result)
1036  {
1037  rh->name_callback(rh->cls,
1038  result);
1039  GNUNET_free(result);
1040  }
1041  rh->name_callback(rh->cls,
1042  NULL);
1043  if (NULL != rh->task)
1044  {
1046  rh->task = NULL;
1047  }
1048  GNUNET_free(rh);
1049 }
#define LOG(kind,...)
Definition: resolver_api.c:32
GNUNET_RESOLVER_HostnameCallback name_callback
Callback if this is a reverse lookup request, otherwise NULL.
Definition: resolver_api.c:121
int af
Desired address family.
Definition: resolver_api.c:142
static int result
Global testing status.
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:137
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:126
static char * no_resolve(int af, const void *ip, socklen_t ip_len)
Convert IP address to string without DNS resolution.
Definition: resolver_api.c:342
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:175
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ loopback

const char* loopback[]
static
Initial value:
= {
"localhost",
"ip6-localnet",
NULL
}

Possible hostnames for "loopback".

Definition at line 45 of file resolver_api.c.

Referenced by check_config(), and GNUNET_RESOLVER_ip_get().

◆ resolver_cfg

const struct GNUNET_CONFIGURATION_Handle* resolver_cfg
static

Configuration.

Definition at line 55 of file resolver_api.c.

◆ mq

struct GNUNET_MQ_Handle* mq
static

Our connection to the resolver service, created on-demand, but then persists until error or shutdown.

Definition at line 61 of file resolver_api.c.

◆ req_head

struct GNUNET_RESOLVER_RequestHandle* req_head
static

Head of DLL of requests.

Definition at line 66 of file resolver_api.c.

Referenced by handle_response(), and process_requests().

◆ req_tail

struct GNUNET_RESOLVER_RequestHandle* req_tail
static

Tail of DLL of requests.

Definition at line 71 of file resolver_api.c.

◆ last_request_id

uint32_t last_request_id
static

ID of the last request we sent to the service.

Definition at line 76 of file resolver_api.c.

Referenced by GNUNET_RESOLVER_hostname_get(), and GNUNET_RESOLVER_ip_get().

◆ backoff

struct GNUNET_TIME_Relative backoff
static

How long should we wait to reconnect?

Definition at line 81 of file resolver_api.c.

Referenced by GNUNET_RESOLVER_connect(), reconnect(), and shutdown_task().

◆ r_task

struct GNUNET_SCHEDULER_Task* r_task
static

Task for reconnecting.

Definition at line 86 of file resolver_api.c.

◆ s_task

struct GNUNET_SCHEDULER_Task* s_task
static

Task ID of shutdown task; only present while we have a connection to the resolver service.

Definition at line 92 of file resolver_api.c.