aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 13:43:36 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 13:43:36 +0000
commit21ef781a9e2bf50ff728af7277b90443779822fa (patch)
treebefdbaa807cd9414a453e2522970f9e46b043825 /src/util
parent0c3e6f7f6b12f21fc2f27f958bd49d513f0207e0 (diff)
downloadgnunet-21ef781a9e2bf50ff728af7277b90443779822fa.tar.gz
gnunet-21ef781a9e2bf50ff728af7277b90443779822fa.zip
use LOG macro in resolver_api.c
Diffstat (limited to 'src/util')
-rw-r--r--src/util/resolver_api.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index a59b9639f..f4e848abb 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -33,6 +33,8 @@
33#include "gnunet_server_lib.h" 33#include "gnunet_server_lib.h"
34#include "resolver.h" 34#include "resolver.h"
35 35
36#define LOG(kind,...) GNUNET_log_from (kind, "resolver-api",__VA_ARGS__)
37
36/** 38/**
37 * Maximum supported length for a hostname 39 * Maximum supported length for a hostname
38 */ 40 */
@@ -194,9 +196,9 @@ check_config ()
194 GNUNET_CONFIGURATION_get_value_string (resolver_cfg, "resolver", 196 GNUNET_CONFIGURATION_get_value_string (resolver_cfg, "resolver",
195 "HOSTNAME", &hostname)) 197 "HOSTNAME", &hostname))
196 { 198 {
197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 199 LOG (GNUNET_ERROR_TYPE_ERROR,
198 _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME", 200 _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME",
199 "resolver"); 201 "resolver");
200 GNUNET_assert (0); 202 GNUNET_assert (0);
201 } 203 }
202 if ((1 != inet_pton (AF_INET, hostname, &v4)) || 204 if ((1 != inet_pton (AF_INET, hostname, &v4)) ||
@@ -212,10 +214,10 @@ check_config ()
212 GNUNET_free (hostname); 214 GNUNET_free (hostname);
213 return; 215 return;
214 } 216 }
215 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 217 LOG (GNUNET_ERROR_TYPE_ERROR,
216 _ 218 _
217 ("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"), 219 ("Must specify `%s' or numeric IP address for `%s' of `%s' in configuration!\n"),
218 "localhost", "HOSTNAME", "resolver"); 220 "localhost", "HOSTNAME", "resolver");
219 GNUNET_free (hostname); 221 GNUNET_free (hostname);
220 GNUNET_assert (0); 222 GNUNET_assert (0);
221} 223}
@@ -247,7 +249,7 @@ GNUNET_RESOLVER_disconnect ()
247 if (NULL != client) 249 if (NULL != client)
248 { 250 {
249#if DEBUG_RESOLVER 251#if DEBUG_RESOLVER
250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n"); 252 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n");
251#endif 253#endif
252 GNUNET_CLIENT_disconnect (client, GNUNET_NO); 254 GNUNET_CLIENT_disconnect (client, GNUNET_NO);
253 client = NULL; 255 client = NULL;
@@ -290,7 +292,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen)
290 inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr, inet4, 292 inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr, inet4,
291 INET_ADDRSTRLEN)) 293 INET_ADDRSTRLEN))
292 { 294 {
293 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); 295 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "resolver-api",
296 "inet_ntop");
294 return NULL; 297 return NULL;
295 } 298 }
296 ret = GNUNET_strdup (inet4); 299 ret = GNUNET_strdup (inet4);
@@ -302,7 +305,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen)
302 inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr, inet6, 305 inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr, inet6,
303 INET6_ADDRSTRLEN)) 306 INET6_ADDRSTRLEN))
304 { 307 {
305 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); 308 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "resolver-api",
309 "inet_ntop");
306 return NULL; 310 return NULL;
307 } 311 }
308 ret = GNUNET_strdup (inet6); 312 ret = GNUNET_strdup (inet6);
@@ -345,18 +349,18 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
345 socklen_t salen; 349 socklen_t salen;
346 350
347#if DEBUG_RESOLVER 351#if DEBUG_RESOLVER
348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n"); 352 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n");
349#endif 353#endif
350 if (msg == NULL) 354 if (msg == NULL)
351 { 355 {
352 if (NULL != rh->name_callback) 356 if (NULL != rh->name_callback)
353 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 357 LOG (GNUNET_ERROR_TYPE_INFO,
354 _("Timeout trying to resolve IP address `%s'.\n"), 358 _("Timeout trying to resolve IP address `%s'.\n"),
355 GNUNET_a2s ((const void *) &rh[1], rh->data_len)); 359 GNUNET_a2s ((const void *) &rh[1], rh->data_len));
356 else 360 else
357 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 361 LOG (GNUNET_ERROR_TYPE_INFO,
358 _("Timeout trying to resolve hostname `%s'.\n"), 362 _("Timeout trying to resolve hostname `%s'.\n"),
359 (const char *) &rh[1]); 363 (const char *) &rh[1]);
360 /* check if request was canceled */ 364 /* check if request was canceled */
361 if (rh->was_transmitted != GNUNET_SYSERR) 365 if (rh->was_transmitted != GNUNET_SYSERR)
362 { 366 {
@@ -423,9 +427,8 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
423 return; 427 return;
424 } 428 }
425#if DEBUG_RESOLVER 429#if DEBUG_RESOLVER
426 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 430 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s' for IP `%s'.\n"),
427 _("Resolver returns `%s' for IP `%s'.\n"), hostname, 431 hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len));
428 GNUNET_a2s ((const void *) &rh[1], rh->data_len));
429#endif 432#endif
430 if (rh->was_transmitted != GNUNET_SYSERR) 433 if (rh->was_transmitted != GNUNET_SYSERR)
431 rh->name_callback (rh->cls, hostname); 434 rh->name_callback (rh->cls, hostname);
@@ -454,8 +457,8 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
454 { 457 {
455 char *ips = no_resolve (sa, salen); 458 char *ips = no_resolve (sa, salen);
456 459
457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for `%s'.\n", 460 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for `%s'.\n", ips,
458 ips, (const char *) &rh[1]); 461 (const char *) &rh[1]);
459 GNUNET_free (ips); 462 GNUNET_free (ips);
460 } 463 }
461#endif 464#endif
@@ -615,8 +618,8 @@ process_requests ()
615 msg->domain = htonl (rh->domain); 618 msg->domain = htonl (rh->domain);
616 memcpy (&msg[1], &rh[1], rh->data_len); 619 memcpy (&msg[1], &rh[1], rh->data_len);
617#if DEBUG_RESOLVER 620#if DEBUG_RESOLVER
618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 621 LOG (GNUNET_ERROR_TYPE_DEBUG,
619 "Transmitting DNS resolution request to DNS service\n"); 622 "Transmitting DNS resolution request to DNS service\n");
620#endif 623#endif
621 if (GNUNET_OK != 624 if (GNUNET_OK !=
622 GNUNET_CLIENT_transmit_and_get_response (client, &msg->header, 625 GNUNET_CLIENT_transmit_and_get_response (client, &msg->header,
@@ -648,13 +651,12 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
648 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 651 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
649 return; 652 return;
650#if DEBUG_RESOLVER 653#if DEBUG_RESOLVER
651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n"); 654 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n");
652#endif 655#endif
653 client = GNUNET_CLIENT_connect ("resolver", resolver_cfg); 656 client = GNUNET_CLIENT_connect ("resolver", resolver_cfg);
654 if (NULL == client) 657 if (NULL == client)
655 { 658 {
656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 659 LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect, will try again later\n");
657 "Failed to connect, will try again later\n");
658 reconnect (); 660 reconnect ();
659 return; 661 return;
660 } 662 }
@@ -695,9 +697,9 @@ reconnect ()
695 } 697 }
696 } 698 }
697#if DEBUG_RESOLVER 699#if DEBUG_RESOLVER
698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 700 LOG (GNUNET_ERROR_TYPE_DEBUG,
699 "Will try to connect to DNS service in %llu ms\n", 701 "Will try to connect to DNS service in %llu ms\n",
700 (unsigned long long) backoff.rel_value); 702 (unsigned long long) backoff.rel_value);
701#endif 703#endif
702 GNUNET_assert (NULL != resolver_cfg); 704 GNUNET_assert (NULL != resolver_cfg);
703 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL); 705 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
@@ -786,7 +788,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
786 788
787 result = no_resolve ((const struct sockaddr *) &rh[1], rh->data_len); 789 result = no_resolve ((const struct sockaddr *) &rh[1], rh->data_len);
788#if DEBUG_RESOLVER 790#if DEBUG_RESOLVER
789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s'.\n"), result); 791 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s'.\n"), result);
790#endif 792#endif
791 if (result != NULL) 793 if (result != NULL)
792 { 794 {
@@ -865,19 +867,18 @@ GNUNET_RESOLVER_local_fqdn_get ()
865 867
866 if (0 != gethostname (hostname, sizeof (hostname) - 1)) 868 if (0 != gethostname (hostname, sizeof (hostname) - 1))
867 { 869 {
868 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 870 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
869 "gethostname"); 871 "resolver-api", "gethostname");
870 return NULL; 872 return NULL;
871 } 873 }
872#if DEBUG_RESOLVER 874#if DEBUG_RESOLVER
873 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), 875 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), hostname);
874 hostname);
875#endif 876#endif
876 host = gethostbyname (hostname); 877 host = gethostbyname (hostname);
877 if (NULL == host) 878 if (NULL == host)
878 { 879 {
879 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not resolve our FQDN : %s\n"), 880 LOG (GNUNET_ERROR_TYPE_ERROR, _("Could not resolve our FQDN : %s\n"),
880 hstrerror (h_errno)); 881 hstrerror (h_errno));
881 return NULL; 882 return NULL;
882 } 883 }
883 return GNUNET_strdup (host->h_name); 884 return GNUNET_strdup (host->h_name);
@@ -903,13 +904,12 @@ GNUNET_RESOLVER_hostname_resolve (int domain,
903 904
904 if (0 != gethostname (hostname, sizeof (hostname) - 1)) 905 if (0 != gethostname (hostname, sizeof (hostname) - 1))
905 { 906 {
906 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 907 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
907 "gethostname"); 908 "resolver-api", "gethostname");
908 return NULL; 909 return NULL;
909 } 910 }
910#if DEBUG_RESOLVER 911#if DEBUG_RESOLVER
911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), 912 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), hostname);
912 hostname);
913#endif 913#endif
914 return GNUNET_RESOLVER_ip_get (hostname, domain, timeout, callback, cls); 914 return GNUNET_RESOLVER_ip_get (hostname, domain, timeout, callback, cls);
915} 915}