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 189 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, inet_pton(), LOG, and loopback.

Referenced by GNUNET_RESOLVER_hostname_get(), and GNUNET_RESOLVER_ip_get().

190 {
191  char *hostname;
192  struct sockaddr_in v4;
193  struct sockaddr_in6 v6;
194 
195  if (GNUNET_OK ==
197  "resolver",
198  "UNIXPATH"))
199  return GNUNET_OK;
200  memset (&v4, 0, sizeof (v4));
201  v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
202  v4.sin_family = AF_INET;
203 #if HAVE_SOCKADDR_IN_SIN_LEN
204  v4.sin_len = sizeof (v4);
205 #endif
206  memset (&v6, 0, sizeof (v6));
207  v6.sin6_family = AF_INET6;
208 #if HAVE_SOCKADDR_IN_SIN_LEN
209  v6.sin6_len = sizeof (v6);
210 #endif
211  if (GNUNET_OK !=
213  "resolver",
214  "HOSTNAME",
215  &hostname))
216  {
218  _("Missing `%s' for `%s' in configuration, DNS resolution will be unavailable.\n"),
219  "HOSTNAME",
220  "resolver");
221  return GNUNET_SYSERR;
222  }
223  if ( (1 == inet_pton (AF_INET, hostname, &v4)) ||
224  (1 == inet_pton (AF_INET6, hostname, &v6)) )
225  {
226  GNUNET_free (hostname);
227  return GNUNET_OK;
228  }
229  for (unsigned int i = 0;
230  NULL != loopback[i];
231  i++)
232  if (0 == strcasecmp (loopback[i],
233  hostname))
234  {
235  GNUNET_free (hostname);
236  return GNUNET_OK;
237  }
239  _("Missing `%s' or numeric IP address for `%s' of `%s' in configuration, DNS resolution will be unavailable.\n"),
240  "localhost",
241  "HOSTNAME",
242  "resolver");
243  GNUNET_free (hostname);
244  return GNUNET_SYSERR;
245 }
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:78
#define LOG(kind,...)
Definition: resolver_api.c:32
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
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:79
static char * hostname
Our hostname; we give this to all the peers we start.
static int inet_pton(int af, const char *cp, struct in_addr *buf)
Convert IPv4 address from text to binary form.
#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 302 of file resolver_api.c.

References backoff, GNUNET_RESOLVER_disconnect(), and GNUNET_TIME_UNIT_MILLISECONDS.

Referenced by check_disconnect(), and process_requests().

303 {
304  (void) cls;
305  s_task = NULL;
308 }
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:266
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 315 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().

316 {
317  for (struct GNUNET_RESOLVER_RequestHandle *rh = req_head;
318  NULL != rh;
319  rh = rh->next)
320  if (GNUNET_SYSERR != rh->was_transmitted)
321  return;
322  if (NULL != r_task)
323  {
325  r_task = NULL;
326  }
327  if (NULL != s_task)
328  return;
330  &shutdown_task,
331  NULL);
332 }
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:1246
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_RESOLVER_RequestHandle * next
Next entry in DLL of requests.
Definition: resolver_api.c:106
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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:302
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:965
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 344 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().

347 {
348  char buf[INET6_ADDRSTRLEN];
349 
350  switch (af)
351  {
352  case AF_INET:
353  if (ip_len != sizeof (struct in_addr))
354  return NULL;
355  if (NULL ==
356  inet_ntop (AF_INET,
357  ip,
358  buf,
359  sizeof (buf)))
360  {
362  "inet_ntop");
363  return NULL;
364  }
365  break;
366  case AF_INET6:
367  if (ip_len != sizeof (struct in6_addr))
368  return NULL;
369  if (NULL ==
370  inet_ntop (AF_INET6,
371  ip,
372  buf,
373  sizeof (buf)))
374  {
376  "inet_ntop");
377  return NULL;
378  }
379  break;
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 818 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().

819 {
821 
822  if (NULL != r_task)
823  return;
824  GNUNET_assert (NULL == mq);
825  if (NULL != (rh = req_head))
826  {
827  switch (rh->was_transmitted)
828  {
829  case GNUNET_NO:
830  /* nothing more to do */
831  break;
832  case GNUNET_YES:
833  /* disconnected, transmit again! */
835  break;
836  case GNUNET_SYSERR:
837  /* request was cancelled, remove entirely */
839  req_tail,
840  rh);
841  GNUNET_free (rh);
842  check_disconnect ();
843  break;
844  default:
845  GNUNET_assert (0);
846  break;
847  }
848  }
850  "Will try to connect to DNS service in %s\n",
852  GNUNET_YES));
853  GNUNET_assert (NULL != resolver_cfg);
856  NULL);
858 }
#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:782
#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:81
#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:1246
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:727
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:157
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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:315
#define GNUNET_YES
Definition: gnunet_common.h:80
#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:128
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:818
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:54
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_NO
Definition: gnunet_common.h:81
#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:1246
#define GNUNET_memcpy(dst, src, n)
int af
Desired address family.
Definition: resolver_api.c:144
#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:157
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:302
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:59
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:65
static struct GNUNET_RESOLVER_RequestHandle * req_head
Head of DLL of requests.
Definition: resolver_api.c:66
#define GNUNET_YES
Definition: gnunet_common.h:80
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:353
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:177
Request for the resolver.
Definition: resolver.h:43
uint32_t id
Identifies the request.
Definition: resolver_api.c:149
int direction
Desired direction (IP to name or name to IP)
Definition: resolver_api.c:167
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:818
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:78
void * cls
Closure for the callbacks.
Definition: resolver_api.c:128

◆ 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) &&
540  (GNUNET_SYSERR != rh->was_transmitted) )
541  rh->addr_callback (rh->cls,
542  NULL,
543  0);
544  }
547  process_requests ();
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:117
#define GNUNET_NO
Definition: gnunet_common.h:81
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:84
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE.
Definition: resolver.h:78
#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:123
int af
Desired address family.
Definition: resolver_api.c:144
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:106
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:157
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:128
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:80
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:344
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:177
uint32_t id
Identifies the request.
Definition: resolver_api.c:149
int received_response
GNUNET_YES if a response was received
Definition: resolver_api.c:172
#define GNUNET_free(ptr)
Wrapper around free.
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
Definition: resolver_api.c:818
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, inet_pton(), 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:117
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int af
Desired address family.
Definition: resolver_api.c:144
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:157
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:139
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.
static int inet_pton(int af, const char *cp, struct in_addr *buf)
Convert IPv4 address from text to binary form.
void * cls
Closure for the callbacks.
Definition: resolver_api.c:128
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
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  case AF_INET6:
748  rh->addr_callback (rh->cls,
749  (const struct sockaddr *) &v6,
750  sizeof (v6));
751  break;
752  case AF_UNSPEC:
753  rh->addr_callback (rh->cls,
754  (const struct sockaddr *) &v6,
755  sizeof (v6));
756  rh->addr_callback (rh->cls,
757  (const struct sockaddr *) &v4,
758  sizeof (v4));
759 
760  break;
761  default:
762  GNUNET_break (0);
763  break;
764  }
765  if (GNUNET_SYSERR != rh->was_transmitted)
766  rh->addr_callback (rh->cls,
767  NULL,
768  0);
770  "Finished resolving hostname `%s'.\n",
771  (const char *) &rh[1]);
772  GNUNET_free (rh);
773 }
GNUNET_RESOLVER_AddressCallback addr_callback
Callback if this is an name resolution request, otherwise NULL.
Definition: resolver_api.c:117
#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:144
int was_transmitted
Has this request been transmitted to the service? GNUNET_YES if transmitted GNUNET_YES if not transmi...
Definition: resolver_api.c:157
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:139
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:128
#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 782 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().

783 {
788  NULL),
790  };
791 
792  (void) cls;
793  r_task = NULL;
794  if (NULL == req_head)
795  return; /* no work pending */
797  "Trying to connect to DNS service\n");
799  "resolver",
800  handlers,
802  NULL);
803  if (NULL == mq)
804  {
806  "Failed to connect, will try again later\n");
807  reconnect ();
808  return;
809  }
810  process_requests ();
811 }
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:901
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:818
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 867 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().

868 {
869  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
870 
871  rh->task = NULL;
872  if (GNUNET_NO == rh->direction)
873  {
875  _("Timeout trying to resolve hostname `%s'.\n"),
876  (const char *) &rh[1]);
877  if (NULL != rh->addr_callback)
878  rh->addr_callback (rh->cls,
879  NULL,
880  0);
881  }
882  else
883  {
884 #if !defined(GNUNET_CULL_LOGGING)
885  char buf[INET6_ADDRSTRLEN];
886 
888  _("Timeout trying to resolve IP address `%s'.\n"),
889  inet_ntop (rh->af,
890  (const void *) &rh[1],
891  buf,
892  sizeof(buf)));
893 #endif
894  if (GNUNET_NO == rh->received_response)
895  {
896  char *nret;
897 
898  nret = no_resolve (rh->af,
899  &rh[1],
900  rh->data_len);
901  if (NULL != rh->name_callback)
902  rh->name_callback (rh->cls, nret);
903  GNUNET_free (nret);
904  }
905  /* finally, make termination call */
906  if (NULL != rh->name_callback)
907  rh->name_callback (rh->cls,
908  NULL);
909  }
912  process_requests ();
913 }
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:117
#define GNUNET_NO
Definition: gnunet_common.h:81
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:208
GNUNET_RESOLVER_HostnameCallback name_callback
Callback if this is a reverse lookup request, otherwise NULL.
Definition: resolver_api.c:123
int af
Desired address family.
Definition: resolver_api.c:144
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:157
struct GNUNET_SCHEDULER_Task * task
Task handle for making reply callbacks in numeric lookups asynchronous, and for timeout handling...
Definition: resolver_api.c:139
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:128
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:344
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:177
int direction
Desired direction (IP to name or name to IP)
Definition: resolver_api.c:167
int received_response
GNUNET_YES if a response was received
Definition: resolver_api.c:172
#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 1017 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().

1018 {
1019  struct GNUNET_RESOLVER_RequestHandle *rh = cls;
1020  char *result;
1021 
1022  rh->task = NULL;
1023  result = no_resolve (rh->af,
1024  &rh[1],
1025  rh->data_len);
1027  "Resolver returns `%s'.\n",
1028  result);
1029  if (NULL != result)
1030  {
1031  rh->name_callback (rh->cls,
1032  result);
1033  GNUNET_free (result);
1034  }
1035  rh->name_callback (rh->cls,
1036  NULL);
1037  if (NULL != rh->task)
1038  {
1040  rh->task = NULL;
1041  }
1042  GNUNET_free (rh);
1043 }
#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:123
int af
Desired address family.
Definition: resolver_api.c:144
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:139
Handle to a request given to the resolver.
Definition: resolver_api.c:100
void * cls
Closure for the callbacks.
Definition: resolver_api.c:128
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:344
size_t data_len
Length of the data that follows this struct.
Definition: resolver_api.c:177
#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:965
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.