aboutsummaryrefslogtreecommitdiff
path: root/src/util/resolver_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-07-18 22:55:09 +0200
committerChristian Grothoff <christian@grothoff.org>2017-07-18 22:55:09 +0200
commit29f76b6fe373cd5ca7504be2ffdaad5500406b8b (patch)
tree876288c547157e4e39ea3c6f110babcc4326e44c /src/util/resolver_api.c
parentcd8ffdb973670871d8fae691671fc0eb0f3c7ba3 (diff)
downloadgnunet-29f76b6fe373cd5ca7504be2ffdaad5500406b8b.tar.gz
gnunet-29f76b6fe373cd5ca7504be2ffdaad5500406b8b.zip
simplify installation of nss plugins in build system, require user(s) to move plugins into place manually (#5078)
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r--src/util/resolver_api.c85
1 files changed, 54 insertions, 31 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index e7bba3000..33a340729 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -179,7 +179,6 @@ static int
179check_config () 179check_config ()
180{ 180{
181 char *hostname; 181 char *hostname;
182 unsigned int i;
183 struct sockaddr_in v4; 182 struct sockaddr_in v4;
184 struct sockaddr_in6 v6; 183 struct sockaddr_in6 v6;
185 184
@@ -206,15 +205,16 @@ check_config ()
206 "resolver"); 205 "resolver");
207 return GNUNET_SYSERR; 206 return GNUNET_SYSERR;
208 } 207 }
209 if ((1 == inet_pton (AF_INET, hostname, &v4)) || 208 if ( (1 == inet_pton (AF_INET, hostname, &v4)) ||
210 (1 == inet_pton (AF_INET6, hostname, &v6))) 209 (1 == inet_pton (AF_INET6, hostname, &v6)) )
211 { 210 {
212 GNUNET_free (hostname); 211 GNUNET_free (hostname);
213 return GNUNET_OK; 212 return GNUNET_OK;
214 } 213 }
215 i = 0; 214 for (unsigned int i = 0;
216 while (NULL != loopback[i]) 215 NULL != loopback[i];
217 if (0 == strcasecmp (loopback[i++], hostname)) 216 i++)
217 if (0 == strcasecmp (loopback[i], hostname))
218 { 218 {
219 GNUNET_free (hostname); 219 GNUNET_free (hostname);
220 return GNUNET_OK; 220 return GNUNET_OK;
@@ -297,9 +297,9 @@ shutdown_task (void *cls)
297static void 297static void
298check_disconnect () 298check_disconnect ()
299{ 299{
300 struct GNUNET_RESOLVER_RequestHandle *rh; 300 for (struct GNUNET_RESOLVER_RequestHandle *rh = req_head;
301 301 NULL != rh;
302 for (rh = req_head; NULL != rh; rh = rh->next) 302 rh = rh->next)
303 if (GNUNET_SYSERR != rh->was_transmitted) 303 if (GNUNET_SYSERR != rh->was_transmitted)
304 return; 304 return;
305 if (NULL != r_task) 305 if (NULL != r_task)
@@ -336,7 +336,10 @@ no_resolve (int af,
336 if (ip_len != sizeof (struct in_addr)) 336 if (ip_len != sizeof (struct in_addr))
337 return NULL; 337 return NULL;
338 if (NULL == 338 if (NULL ==
339 inet_ntop (AF_INET, ip, buf, sizeof (buf))) 339 inet_ntop (AF_INET,
340 ip,
341 buf,
342 sizeof (buf)))
340 { 343 {
341 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 344 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
342 "inet_ntop"); 345 "inet_ntop");
@@ -347,7 +350,10 @@ no_resolve (int af,
347 if (ip_len != sizeof (struct in6_addr)) 350 if (ip_len != sizeof (struct in6_addr))
348 return NULL; 351 return NULL;
349 if (NULL == 352 if (NULL ==
350 inet_ntop (AF_INET6, ip, buf, sizeof (buf))) 353 inet_ntop (AF_INET6,
354 ip,
355 buf,
356 sizeof (buf)))
351 { 357 {
352 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 358 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
353 "inet_ntop"); 359 "inet_ntop");
@@ -422,8 +428,8 @@ process_requests ()
422 msg->direction = htonl (rh->direction); 428 msg->direction = htonl (rh->direction);
423 msg->af = htonl (rh->af); 429 msg->af = htonl (rh->af);
424 GNUNET_memcpy (&msg[1], 430 GNUNET_memcpy (&msg[1],
425 &rh[1], 431 &rh[1],
426 rh->data_len); 432 rh->data_len);
427 LOG (GNUNET_ERROR_TYPE_DEBUG, 433 LOG (GNUNET_ERROR_TYPE_DEBUG,
428 "Transmitting DNS resolution request to DNS service\n"); 434 "Transmitting DNS resolution request to DNS service\n");
429 GNUNET_MQ_send (mq, 435 GNUNET_MQ_send (mq,
@@ -611,14 +617,19 @@ numeric_resolution (void *cls)
611 v6.sin6_len = sizeof (v6); 617 v6.sin6_len = sizeof (v6);
612#endif 618#endif
613 hostname = (const char *) &rh[1]; 619 hostname = (const char *) &rh[1];
614 if (((rh->af == AF_UNSPEC) || (rh->af == AF_INET)) && 620 if ( ( (rh->af == AF_UNSPEC) ||
615 (1 == inet_pton (AF_INET, hostname, &v4.sin_addr))) 621 (rh->af == AF_INET) ) &&
622 (1 == inet_pton (AF_INET,
623 hostname,
624 &v4.sin_addr)) )
616 { 625 {
617 rh->addr_callback (rh->cls, 626 rh->addr_callback (rh->cls,
618 (const struct sockaddr *) &v4, 627 (const struct sockaddr *) &v4,
619 sizeof (v4)); 628 sizeof (v4));
620 if ((rh->af == AF_UNSPEC) && 629 if ( (rh->af == AF_UNSPEC) &&
621 (1 == inet_pton (AF_INET6, hostname, &v6.sin6_addr))) 630 (1 == inet_pton (AF_INET6,
631 hostname,
632 &v6.sin6_addr)) )
622 { 633 {
623 /* this can happen on some systems IF "hostname" is "localhost" */ 634 /* this can happen on some systems IF "hostname" is "localhost" */
624 rh->addr_callback (rh->cls, 635 rh->addr_callback (rh->cls,
@@ -872,7 +883,6 @@ GNUNET_RESOLVER_ip_get (const char *hostname,
872{ 883{
873 struct GNUNET_RESOLVER_RequestHandle *rh; 884 struct GNUNET_RESOLVER_RequestHandle *rh;
874 size_t slen; 885 size_t slen;
875 unsigned int i;
876 struct in_addr v4; 886 struct in_addr v4;
877 struct in6_addr v6; 887 struct in6_addr v6;
878 888
@@ -897,19 +907,26 @@ GNUNET_RESOLVER_ip_get (const char *hostname,
897 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); 907 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout);
898 rh->direction = GNUNET_NO; 908 rh->direction = GNUNET_NO;
899 /* first, check if this is a numeric address */ 909 /* first, check if this is a numeric address */
900 if (((1 == inet_pton (AF_INET, hostname, &v4)) && 910 if ( ( (1 == inet_pton (AF_INET,
901 ((af == AF_INET) || (af == AF_UNSPEC))) || 911 hostname,
902 ((1 == inet_pton (AF_INET6, hostname, &v6)) && 912 &v4)) &&
903 ((af == AF_INET6) || (af == AF_UNSPEC)))) 913 ( (af == AF_INET) ||
914 (af == AF_UNSPEC) ) ) ||
915 ( (1 == inet_pton (AF_INET6,
916 hostname,
917 &v6)) &&
918 ( (af == AF_INET6) ||
919 (af == AF_UNSPEC)) ) )
904 { 920 {
905 rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, 921 rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution,
906 rh); 922 rh);
907 return rh; 923 return rh;
908 } 924 }
909 /* then, check if this is a loopback address */ 925 /* then, check if this is a loopback address */
910 i = 0; 926 for (unsigned int i = 0;
911 while (NULL != loopback[i]) 927 NULL != loopback[i];
912 if (0 == strcasecmp (loopback[i++], 928 i++)
929 if (0 == strcasecmp (loopback[i],
913 hostname)) 930 hostname))
914 { 931 {
915 rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution, 932 rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution,
@@ -1029,8 +1046,8 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
1029 rh->af = sa->sa_family; 1046 rh->af = sa->sa_family;
1030 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); 1047 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1031 GNUNET_memcpy (&rh[1], 1048 GNUNET_memcpy (&rh[1],
1032 ip, 1049 ip,
1033 ip_len); 1050 ip_len);
1034 rh->data_len = ip_len; 1051 rh->data_len = ip_len;
1035 rh->direction = GNUNET_YES; 1052 rh->direction = GNUNET_YES;
1036 rh->received_response = GNUNET_NO; 1053 rh->received_response = GNUNET_NO;
@@ -1067,7 +1084,8 @@ GNUNET_RESOLVER_local_fqdn_get ()
1067{ 1084{
1068 char hostname[GNUNET_OS_get_hostname_max_length () + 1]; 1085 char hostname[GNUNET_OS_get_hostname_max_length () + 1];
1069 1086
1070 if (0 != gethostname (hostname, sizeof (hostname) - 1)) 1087 if (0 != gethostname (hostname,
1088 sizeof (hostname) - 1))
1071 { 1089 {
1072 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 1090 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
1073 "gethostname"); 1091 "gethostname");
@@ -1082,7 +1100,10 @@ GNUNET_RESOLVER_local_fqdn_get ()
1082 int ret; 1100 int ret;
1083 char *rval; 1101 char *rval;
1084 1102
1085 if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai))) 1103 if (0 != (ret = getaddrinfo (hostname,
1104 NULL,
1105 NULL,
1106 &ai)))
1086 { 1107 {
1087 LOG (GNUNET_ERROR_TYPE_ERROR, 1108 LOG (GNUNET_ERROR_TYPE_ERROR,
1088 _("Could not resolve our FQDN: %s\n"), 1109 _("Could not resolve our FQDN: %s\n"),
@@ -1100,9 +1121,11 @@ GNUNET_RESOLVER_local_fqdn_get ()
1100 { 1121 {
1101 struct hostent *host; 1122 struct hostent *host;
1102 1123
1103 host = gethostbyname2 (hostname, AF_INET); 1124 host = gethostbyname2 (hostname,
1125 AF_INET);
1104 if (NULL == host) 1126 if (NULL == host)
1105 host = gethostbyname2 (hostname, AF_INET6); 1127 host = gethostbyname2 (hostname,
1128 AF_INET6);
1106 if (NULL == host) 1129 if (NULL == host)
1107 { 1130 {
1108 LOG (GNUNET_ERROR_TYPE_ERROR, 1131 LOG (GNUNET_ERROR_TYPE_ERROR,