aboutsummaryrefslogtreecommitdiff
path: root/src/util/resolver_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-07 17:57:19 +0000
committerChristian Grothoff <christian@grothoff.org>2015-06-07 17:57:19 +0000
commit84d6a0db5e92d043dcf0914378e681579cabd682 (patch)
tree91c36f55b18c2c4049d2ec8ca8401265fab276e8 /src/util/resolver_api.c
parent8fc6aab8c74124130c95d58192072a7eba59028c (diff)
downloadgnunet-84d6a0db5e92d043dcf0914378e681579cabd682.tar.gz
gnunet-84d6a0db5e92d043dcf0914378e681579cabd682.zip
-return IP in dotted decimal if reverse lookup fails
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r--src/util/resolver_api.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 493fe046e..3469739e1 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2014 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2009-2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -78,13 +78,13 @@ static struct GNUNET_TIME_Relative backoff;
78/** 78/**
79 * Task for reconnecting. 79 * Task for reconnecting.
80 */ 80 */
81static struct GNUNET_SCHEDULER_Task * r_task; 81static struct GNUNET_SCHEDULER_Task *r_task;
82 82
83/** 83/**
84 * Task ID of shutdown task; only present while we have a 84 * Task ID of shutdown task; only present while we have a
85 * connection to the resolver service. 85 * connection to the resolver service.
86 */ 86 */
87static struct GNUNET_SCHEDULER_Task * s_task; 87static struct GNUNET_SCHEDULER_Task *s_task;
88 88
89 89
90/** 90/**
@@ -401,13 +401,27 @@ handle_response (void *cls,
401 size = ntohs (msg->size); 401 size = ntohs (msg->size);
402 if (size == sizeof (struct GNUNET_MessageHeader)) 402 if (size == sizeof (struct GNUNET_MessageHeader))
403 { 403 {
404 LOG (GNUNET_ERROR_TYPE_DEBUG,
405 "Received empty response from DNS service\n");
404 /* message contains not data, just header; end of replies */ 406 /* message contains not data, just header; end of replies */
405 /* check if request was canceled */ 407 /* check if request was canceled */
406 if (GNUNET_SYSERR != rh->was_transmitted) 408 if (GNUNET_SYSERR != rh->was_transmitted)
407 { 409 {
410 /* no reverse lookup was successful, return IP as string */
408 if (NULL != rh->name_callback) 411 if (NULL != rh->name_callback)
412 {
413 if (GNUNET_NO == rh->received_response)
414 {
415 nret = no_resolve (rh->af,
416 &rh[1],
417 rh->data_len);
418 rh->name_callback (rh->cls, nret);
419 GNUNET_free (nret);
420 }
421 /* finally, make termination call */
409 rh->name_callback (rh->cls, 422 rh->name_callback (rh->cls,
410 NULL); 423 NULL);
424 }
411 if (NULL != rh->addr_callback) 425 if (NULL != rh->addr_callback)
412 rh->addr_callback (rh->cls, 426 rh->addr_callback (rh->cls,
413 NULL, 427 NULL,
@@ -495,6 +509,8 @@ handle_response (void *cls,
495 reconnect (); 509 reconnect ();
496 return; 510 return;
497 } 511 }
512 LOG (GNUNET_ERROR_TYPE_DEBUG,
513 "Received IP from DNS service\n");
498 if (GNUNET_SYSERR != rh->was_transmitted) 514 if (GNUNET_SYSERR != rh->was_transmitted)
499 rh->addr_callback (rh->cls, 515 rh->addr_callback (rh->cls,
500 sa, 516 sa,
@@ -810,7 +826,8 @@ handle_lookup_timeout (void *cls,
810 * @return handle that can be used to cancel the request, NULL on error 826 * @return handle that can be used to cancel the request, NULL on error
811 */ 827 */
812struct GNUNET_RESOLVER_RequestHandle * 828struct GNUNET_RESOLVER_RequestHandle *
813GNUNET_RESOLVER_ip_get (const char *hostname, int af, 829GNUNET_RESOLVER_ip_get (const char *hostname,
830 int af,
814 struct GNUNET_TIME_Relative timeout, 831 struct GNUNET_TIME_Relative timeout,
815 GNUNET_RESOLVER_AddressCallback callback, 832 GNUNET_RESOLVER_AddressCallback callback,
816 void *callback_cls) 833 void *callback_cls)
@@ -938,10 +955,12 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
938 switch (sa->sa_family) 955 switch (sa->sa_family)
939 { 956 {
940 case AF_INET: 957 case AF_INET:
958 GNUNET_assert (salen == sizeof (struct sockaddr_in));
941 ip_len = sizeof (struct in_addr); 959 ip_len = sizeof (struct in_addr);
942 ip = &((const struct sockaddr_in*)sa)->sin_addr; 960 ip = &((const struct sockaddr_in*)sa)->sin_addr;
943 break; 961 break;
944 case AF_INET6: 962 case AF_INET6:
963 GNUNET_assert (salen == sizeof (struct sockaddr_in6));
945 ip_len = sizeof (struct in6_addr); 964 ip_len = sizeof (struct in6_addr);
946 ip = &((const struct sockaddr_in6*)sa)->sin6_addr; 965 ip = &((const struct sockaddr_in6*)sa)->sin6_addr;
947 break; 966 break;