diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/bandwidth.c | 2 | ||||
-rw-r--r-- | src/util/client.c | 47 | ||||
-rw-r--r-- | src/util/common_logging.c | 13 | ||||
-rw-r--r-- | src/util/connection.c | 66 | ||||
-rw-r--r-- | src/util/network.c | 11 | ||||
-rw-r--r-- | src/util/service.c | 190 | ||||
-rw-r--r-- | src/util/test_resolver_api.c | 2 |
7 files changed, 289 insertions, 42 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 124cede9b..e47df4382 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -211,7 +211,7 @@ int | |||
211 | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | 211 | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, |
212 | ssize_t size) | 212 | ssize_t size) |
213 | { | 213 | { |
214 | uint64_t nc; | 214 | int64_t nc; |
215 | 215 | ||
216 | #if DEBUG_BANDWIDTH | 216 | #if DEBUG_BANDWIDTH |
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/util/client.c b/src/util/client.c index f964b7322..c7853d146 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -250,19 +250,55 @@ struct GNUNET_CLIENT_Connection | |||
250 | * Are we ignoring shutdown signals? | 250 | * Are we ignoring shutdown signals? |
251 | */ | 251 | */ |
252 | int ignore_shutdown; | 252 | int ignore_shutdown; |
253 | |||
254 | /** | ||
255 | * How often have we tried to connect? | ||
256 | */ | ||
257 | unsigned int attempts; | ||
253 | 258 | ||
254 | }; | 259 | }; |
255 | 260 | ||
256 | 261 | ||
262 | /** | ||
263 | * Try to connect to the service. | ||
264 | * | ||
265 | * @param sched scheduler to use | ||
266 | * @param service_name name of service to connect to | ||
267 | * @param cfg configuration to use | ||
268 | * @param attempt counter used to alternate between IP and UNIX domain sockets | ||
269 | * @return NULL on error | ||
270 | */ | ||
257 | static struct GNUNET_CONNECTION_Handle * | 271 | static struct GNUNET_CONNECTION_Handle * |
258 | do_connect (struct GNUNET_SCHEDULER_Handle *sched, | 272 | do_connect (struct GNUNET_SCHEDULER_Handle *sched, |
259 | const char *service_name, | 273 | const char *service_name, |
260 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 274 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
275 | unsigned int attempt) | ||
261 | { | 276 | { |
262 | struct GNUNET_CONNECTION_Handle *sock; | 277 | struct GNUNET_CONNECTION_Handle *sock; |
263 | char *hostname; | 278 | char *hostname; |
279 | char *unixpath; | ||
264 | unsigned long long port; | 280 | unsigned long long port; |
265 | 281 | ||
282 | #if AF_UNIX | ||
283 | if (0 == attempt % 2) | ||
284 | { | ||
285 | /* on even rounds, try UNIX */ | ||
286 | if (GNUNET_OK == | ||
287 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
288 | service_name, | ||
289 | "UNIXPATH", &unixpath)) | ||
290 | { | ||
291 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (sched, | ||
292 | cfg, | ||
293 | unixpath, | ||
294 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
295 | GNUNET_free (unixpath); | ||
296 | if (sock != NULL) | ||
297 | return sock; | ||
298 | } | ||
299 | } | ||
300 | #endif | ||
301 | |||
266 | if ((GNUNET_OK != | 302 | if ((GNUNET_OK != |
267 | GNUNET_CONFIGURATION_get_value_number (cfg, | 303 | GNUNET_CONFIGURATION_get_value_number (cfg, |
268 | service_name, | 304 | service_name, |
@@ -314,10 +350,13 @@ GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
314 | struct GNUNET_CLIENT_Connection *ret; | 350 | struct GNUNET_CLIENT_Connection *ret; |
315 | struct GNUNET_CONNECTION_Handle *sock; | 351 | struct GNUNET_CONNECTION_Handle *sock; |
316 | 352 | ||
317 | sock = do_connect (sched, service_name, cfg); | 353 | sock = do_connect (sched, |
354 | service_name, | ||
355 | cfg, 0); | ||
318 | if (sock == NULL) | 356 | if (sock == NULL) |
319 | return NULL; | 357 | return NULL; |
320 | ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); | 358 | ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); |
359 | ret->attempts = 1; | ||
321 | ret->sock = sock; | 360 | ret->sock = sock; |
322 | ret->sched = sched; | 361 | ret->sched = sched; |
323 | ret->service_name = GNUNET_strdup (service_name); | 362 | ret->service_name = GNUNET_strdup (service_name); |
@@ -770,7 +809,9 @@ client_notify (void *cls, size_t size, void *buf) | |||
770 | /* auto-retry */ | 809 | /* auto-retry */ |
771 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); | 810 | GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); |
772 | th->sock->sock = do_connect (th->sock->sched, | 811 | th->sock->sock = do_connect (th->sock->sched, |
773 | th->sock->service_name, th->sock->cfg); | 812 | th->sock->service_name, |
813 | th->sock->cfg, | ||
814 | th->sock->attempts++); | ||
774 | GNUNET_assert (NULL != th->sock->sock); | 815 | GNUNET_assert (NULL != th->sock->sock); |
775 | GNUNET_CONNECTION_ignore_shutdown (th->sock->sock, | 816 | GNUNET_CONNECTION_ignore_shutdown (th->sock->sock, |
776 | th->sock->ignore_shutdown); | 817 | th->sock->ignore_shutdown); |
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 73a374f46..c06aadc2f 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -510,7 +510,9 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | |||
510 | static char buf[INET6_ADDRSTRLEN + 8]; | 510 | static char buf[INET6_ADDRSTRLEN + 8]; |
511 | static char b2[6]; | 511 | static char b2[6]; |
512 | const struct sockaddr_in *v4; | 512 | const struct sockaddr_in *v4; |
513 | const struct sockaddr_un *un; | ||
513 | const struct sockaddr_in6 *v6; | 514 | const struct sockaddr_in6 *v6; |
515 | unsigned int off; | ||
514 | 516 | ||
515 | if (addr == NULL) | 517 | if (addr == NULL) |
516 | return _("unknown address"); | 518 | return _("unknown address"); |
@@ -535,6 +537,17 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | |||
535 | sprintf (b2, "%u", ntohs (v6->sin6_port)); | 537 | sprintf (b2, "%u", ntohs (v6->sin6_port)); |
536 | strcat (buf, b2); | 538 | strcat (buf, b2); |
537 | return buf; | 539 | return buf; |
540 | case AF_UNIX: | ||
541 | un = (const struct sockaddr_un*) addr; | ||
542 | off = 0; | ||
543 | if (un->sun_path[0] == '\0') off++; | ||
544 | snprintf (buf, | ||
545 | sizeof (buf), | ||
546 | "%s%.*s", | ||
547 | (off == 1) ? "@" : "", | ||
548 | addrlen - sizeof (sa_family_t) - 1 - off, | ||
549 | &un->sun_path[off]); | ||
550 | return buf; | ||
538 | default: | 551 | default: |
539 | return _("invalid address"); | 552 | return _("invalid address"); |
540 | } | 553 | } |
diff --git a/src/util/connection.c b/src/util/connection.c index fdd454105..d218714c0 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -889,6 +889,72 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
889 | 889 | ||
890 | 890 | ||
891 | /** | 891 | /** |
892 | * Create a socket handle by connecting to a UNIX domain service. | ||
893 | * This function returns immediately, even if the connection has not | ||
894 | * yet been established. This function only creates UNIX connections. | ||
895 | * | ||
896 | * @param sched scheduler to use | ||
897 | * @param cfg configuration to use | ||
898 | * @param unixpath path to connect to | ||
899 | * @param maxbuf maximum write buffer size for the socket (use | ||
900 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
901 | * @return the socket handle, NULL on systems without UNIX support | ||
902 | */ | ||
903 | struct GNUNET_CONNECTION_Handle * | ||
904 | GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, | ||
905 | const struct | ||
906 | GNUNET_CONFIGURATION_Handle *cfg, | ||
907 | const char *unixpath, | ||
908 | size_t maxbuf) | ||
909 | { | ||
910 | #ifdef AF_UNIX | ||
911 | struct GNUNET_CONNECTION_Handle *ret; | ||
912 | struct sockaddr_un *un; | ||
913 | size_t slen; | ||
914 | |||
915 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ | ||
916 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); | ||
917 | un->sun_family = AF_UNIX; | ||
918 | slen = strlen (unixpath) + 1; | ||
919 | if (slen >= sizeof (un->sun_path)) | ||
920 | slen = sizeof (un->sun_path) - 1; | ||
921 | memcpy (un->sun_path, | ||
922 | unixpath, | ||
923 | slen); | ||
924 | un->sun_path[slen] = '\0'; | ||
925 | slen += sizeof (sa_family_t); | ||
926 | #if LINUX | ||
927 | un->sun_path[0] = '\0'; | ||
928 | slen = sizeof (struct sockaddr_un); | ||
929 | #endif | ||
930 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle) + maxbuf); | ||
931 | ret->cfg = cfg; | ||
932 | ret->sched = sched; | ||
933 | ret->write_buffer = (char *) &ret[1]; | ||
934 | ret->write_buffer_size = maxbuf; | ||
935 | ret->port = 0; | ||
936 | ret->hostname = NULL; | ||
937 | ret->addr = (struct sockaddr*) un; | ||
938 | ret->addrlen = slen; | ||
939 | ret->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | ||
940 | if (GNUNET_OK != GNUNET_NETWORK_socket_connect (ret->sock, | ||
941 | ret->addr, | ||
942 | ret->addrlen)) | ||
943 | { | ||
944 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); | ||
945 | GNUNET_free (ret->addr); | ||
946 | GNUNET_free (ret); | ||
947 | return NULL; | ||
948 | } | ||
949 | connect_success_continuation (ret); | ||
950 | return ret; | ||
951 | #else | ||
952 | return NULL; | ||
953 | #endif | ||
954 | } | ||
955 | |||
956 | |||
957 | /** | ||
892 | * Create a socket handle by (asynchronously) connecting to a host. | 958 | * Create a socket handle by (asynchronously) connecting to a host. |
893 | * This function returns immediately, even if the connection has not | 959 | * This function returns immediately, even if the connection has not |
894 | * yet been established. This function only creates TCP connections. | 960 | * yet been established. This function only creates TCP connections. |
diff --git a/src/util/network.c b/src/util/network.c index 0b4168034..8ec365269 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -226,7 +226,10 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
226 | #ifdef DARWIN | 226 | #ifdef DARWIN |
227 | socket_set_nosigpipe (ret); | 227 | socket_set_nosigpipe (ret); |
228 | #endif | 228 | #endif |
229 | socket_set_nodelay (ret); | 229 | #ifdef AF_UNIX |
230 | if (address->sa_family != AF_UNIX) | ||
231 | #endif | ||
232 | socket_set_nodelay (ret); | ||
230 | return ret; | 233 | return ret; |
231 | } | 234 | } |
232 | 235 | ||
@@ -590,7 +593,11 @@ GNUNET_NETWORK_socket_create (int domain, int type, int protocol) | |||
590 | #ifdef DARWIN | 593 | #ifdef DARWIN |
591 | socket_set_nosigpipe (ret); | 594 | socket_set_nosigpipe (ret); |
592 | #endif | 595 | #endif |
593 | if (type == SOCK_STREAM) | 596 | if ( (type == SOCK_STREAM) |
597 | #ifdef AF_UNIX | ||
598 | && (domain != AF_UNIX) | ||
599 | #endif | ||
600 | ) | ||
594 | socket_set_nodelay (ret); | 601 | socket_set_nodelay (ret); |
595 | return ret; | 602 | return ret; |
596 | } | 603 | } |
diff --git a/src/util/service.c b/src/util/service.c index 82e7070a1..9ab99de3e 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -612,6 +612,10 @@ check_access (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
612 | && ((sctx->v6_denied == NULL) || | 612 | && ((sctx->v6_denied == NULL) || |
613 | (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); | 613 | (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); |
614 | break; | 614 | break; |
615 | case AF_UNIX: | ||
616 | /* FIXME: support checking UID/GID in the future... */ | ||
617 | ret = GNUNET_OK; /* always OK for now */ | ||
618 | break; | ||
615 | default: | 619 | default: |
616 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 620 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
617 | _("Unknown address family %d\n"), addr->sa_family); | 621 | _("Unknown address family %d\n"), addr->sa_family); |
@@ -702,6 +706,46 @@ process_acl6 (struct IPv6NetworkSet **ret, | |||
702 | return GNUNET_OK; | 706 | return GNUNET_OK; |
703 | } | 707 | } |
704 | 708 | ||
709 | /** | ||
710 | * Add the given UNIX domain path as an address to the | ||
711 | * list (as the first entry). | ||
712 | * | ||
713 | * @param saddrs array to update | ||
714 | * @param saddrlens where to store the address length | ||
715 | * @param unixpath path to add | ||
716 | */ | ||
717 | static void | ||
718 | add_unixpath (struct sockaddr **saddrs, | ||
719 | socklen_t *saddrlens, | ||
720 | const char *unixpath) | ||
721 | { | ||
722 | #ifdef AF_UNIX | ||
723 | struct sockaddr_un *un; | ||
724 | size_t slen; | ||
725 | |||
726 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); | ||
727 | un->sun_family = AF_UNIX; | ||
728 | slen = strlen (unixpath) + 1; | ||
729 | if (slen >= sizeof (un->sun_path)) | ||
730 | slen = sizeof (un->sun_path) - 1; | ||
731 | memcpy (un->sun_path, | ||
732 | unixpath, | ||
733 | slen); | ||
734 | un->sun_path[slen] = '\0'; | ||
735 | slen += sizeof (sa_family_t); | ||
736 | #if LINUX | ||
737 | un->sun_path[0] = '\0'; | ||
738 | slen = sizeof (struct sockaddr_un); | ||
739 | #endif | ||
740 | *saddrs = (struct sockaddr*) un; | ||
741 | *saddrlens = slen; | ||
742 | #else | ||
743 | /* this function should never be called | ||
744 | unless AF_UNIX is defined! */ | ||
745 | GNUNET_assert (0); | ||
746 | #endif | ||
747 | } | ||
748 | |||
705 | 749 | ||
706 | /** | 750 | /** |
707 | * Get the list of addresses that a server for the given service | 751 | * Get the list of addresses that a server for the given service |
@@ -732,6 +776,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
732 | int disablev6; | 776 | int disablev6; |
733 | struct GNUNET_NETWORK_Handle *desc; | 777 | struct GNUNET_NETWORK_Handle *desc; |
734 | unsigned long long port; | 778 | unsigned long long port; |
779 | char *unixpath; | ||
735 | struct addrinfo hints; | 780 | struct addrinfo hints; |
736 | struct addrinfo *res; | 781 | struct addrinfo *res; |
737 | struct addrinfo *pos; | 782 | struct addrinfo *pos; |
@@ -781,19 +826,25 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
781 | } | 826 | } |
782 | } | 827 | } |
783 | 828 | ||
784 | 829 | port = 0; | |
785 | if ((GNUNET_OK != | 830 | if (GNUNET_CONFIGURATION_have_value (cfg, |
786 | GNUNET_CONFIGURATION_get_value_number (cfg, | 831 | serviceName, "PORT")) |
787 | serviceName, | ||
788 | "PORT", | ||
789 | &port)) || (port > 65535)) | ||
790 | { | 832 | { |
791 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 833 | GNUNET_break (GNUNET_OK == |
792 | _ | 834 | GNUNET_CONFIGURATION_get_value_number (cfg, |
793 | ("Require valid port number for service `%s' in configuration!\n"), | 835 | serviceName, |
794 | serviceName); | 836 | "PORT", |
795 | return GNUNET_SYSERR; | 837 | &port)); |
838 | if (port > 65535) | ||
839 | { | ||
840 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
841 | _ | ||
842 | ("Require valid port number for service `%s' in configuration!\n"), | ||
843 | serviceName); | ||
844 | return GNUNET_SYSERR; | ||
845 | } | ||
796 | } | 846 | } |
847 | |||
797 | if (GNUNET_CONFIGURATION_have_value (cfg, | 848 | if (GNUNET_CONFIGURATION_have_value (cfg, |
798 | serviceName, "BINDTO")) | 849 | serviceName, "BINDTO")) |
799 | { | 850 | { |
@@ -806,6 +857,49 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
806 | else | 857 | else |
807 | hostname = NULL; | 858 | hostname = NULL; |
808 | 859 | ||
860 | #ifdef AF_UNIX | ||
861 | if (GNUNET_CONFIGURATION_have_value (cfg, | ||
862 | serviceName, "UNIXPATH")) | ||
863 | { | ||
864 | GNUNET_break (GNUNET_OK == | ||
865 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
866 | serviceName, | ||
867 | "UNIXPATH", | ||
868 | &unixpath)); | ||
869 | |||
870 | /* probe UNIX support */ | ||
871 | desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | ||
872 | if (NULL == desc) | ||
873 | { | ||
874 | if ((errno == ENOBUFS) || | ||
875 | (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) | ||
876 | { | ||
877 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | ||
878 | return GNUNET_SYSERR; | ||
879 | } | ||
880 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
881 | _ | ||
882 | ("Disabling UNIX domainn socket support for service `%s', failed to create UNIX domain socket: %s\n"), | ||
883 | serviceName, STRERROR (errno)); | ||
884 | GNUNET_free (unixpath); | ||
885 | unixpath = NULL; | ||
886 | } | ||
887 | } | ||
888 | else | ||
889 | unixpath = NULL; | ||
890 | #else | ||
891 | unixpath = NULL; | ||
892 | #endif | ||
893 | |||
894 | if ( (port == 0) && | ||
895 | (unixpath == NULL) ) | ||
896 | { | ||
897 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
898 | _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"), | ||
899 | serviceName); | ||
900 | return GNUNET_SYSERR; | ||
901 | } | ||
902 | |||
809 | if (hostname != NULL) | 903 | if (hostname != NULL) |
810 | { | 904 | { |
811 | #if DEBUG_SERVICE | 905 | #if DEBUG_SERVICE |
@@ -845,9 +939,16 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
845 | return GNUNET_SYSERR; | 939 | return GNUNET_SYSERR; |
846 | } | 940 | } |
847 | resi = i; | 941 | resi = i; |
848 | saddrs = GNUNET_malloc ((i+1) * sizeof(struct sockaddr*)); | 942 | if (NULL != unixpath) |
849 | saddrlens = GNUNET_malloc ((i+1) * sizeof (socklen_t)); | 943 | resi++; |
944 | saddrs = GNUNET_malloc ((resi+1) * sizeof(struct sockaddr*)); | ||
945 | saddrlens = GNUNET_malloc ((resi+1) * sizeof (socklen_t)); | ||
850 | i = 0; | 946 | i = 0; |
947 | if (NULL != unixpath) | ||
948 | { | ||
949 | add_unixpath (saddrs, saddrlens, unixpath); | ||
950 | i++; | ||
951 | } | ||
851 | next = res; | 952 | next = res; |
852 | while (NULL != (pos = next)) | 953 | while (NULL != (pos = next)) |
853 | { | 954 | { |
@@ -890,40 +991,56 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
890 | { | 991 | { |
891 | /* V4-only */ | 992 | /* V4-only */ |
892 | resi = 1; | 993 | resi = 1; |
893 | saddrs = GNUNET_malloc (2 * sizeof(struct sockaddr*)); | 994 | if (NULL != unixpath) |
894 | saddrlens = GNUNET_malloc (2 * sizeof (socklen_t)); | 995 | resi++; |
895 | saddrlens[0] = sizeof (struct sockaddr_in); | 996 | i = 0; |
896 | saddrs[0] = GNUNET_malloc (saddrlens[0]); | 997 | saddrs = GNUNET_malloc ((resi+1) * sizeof(struct sockaddr*)); |
998 | saddrlens = GNUNET_malloc ((resi+1) * sizeof (socklen_t)); | ||
999 | if (NULL != unixpath) | ||
1000 | { | ||
1001 | add_unixpath (saddrs, saddrlens, unixpath); | ||
1002 | i++; | ||
1003 | } | ||
1004 | saddrlens[i] = sizeof (struct sockaddr_in); | ||
1005 | saddrs[i] = GNUNET_malloc (saddrlens[i]); | ||
897 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1006 | #if HAVE_SOCKADDR_IN_SIN_LEN |
898 | ((struct sockaddr_in *) saddrs[0])->sin_len = saddrlens[0]; | 1007 | ((struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[i]; |
899 | #endif | 1008 | #endif |
900 | ((struct sockaddr_in *) saddrs[0])->sin_family = AF_INET; | 1009 | ((struct sockaddr_in *) saddrs[i])->sin_family = AF_INET; |
901 | ((struct sockaddr_in *) saddrs[0])->sin_port = htons (port); | 1010 | ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port); |
902 | } | 1011 | } |
903 | else | 1012 | else |
904 | { | 1013 | { |
905 | /* dual stack */ | 1014 | /* dual stack */ |
906 | resi = 2; | 1015 | resi = 2; |
907 | saddrs = GNUNET_malloc (3 * sizeof(struct sockaddr*)); | 1016 | if (NULL != unixpath) |
908 | saddrlens = GNUNET_malloc (3 * sizeof (socklen_t)); | 1017 | resi++; |
909 | 1018 | saddrs = GNUNET_malloc ((resi+1) * sizeof(struct sockaddr*)); | |
910 | saddrlens[0] = sizeof (struct sockaddr_in6); | 1019 | saddrlens = GNUNET_malloc ((resi+1) * sizeof (socklen_t)); |
911 | saddrs[0] = GNUNET_malloc (saddrlens[0]); | 1020 | i = 0; |
1021 | if (NULL != unixpath) | ||
1022 | { | ||
1023 | add_unixpath (saddrs, saddrlens, unixpath); | ||
1024 | i++; | ||
1025 | } | ||
1026 | saddrlens[i] = sizeof (struct sockaddr_in6); | ||
1027 | saddrs[i] = GNUNET_malloc (saddrlens[i]); | ||
912 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1028 | #if HAVE_SOCKADDR_IN_SIN_LEN |
913 | ((struct sockaddr_in6 *) saddrs[0])->sin6_len = saddrlens[0]; | 1029 | ((struct sockaddr_in6 *) saddrs[i])->sin6_len = saddrlens[0]; |
914 | #endif | 1030 | #endif |
915 | ((struct sockaddr_in6 *) saddrs[0])->sin6_family = AF_INET6; | 1031 | ((struct sockaddr_in6 *) saddrs[i])->sin6_family = AF_INET6; |
916 | ((struct sockaddr_in6 *) saddrs[0])->sin6_port = htons (port); | 1032 | ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port); |
917 | 1033 | i++; | |
918 | saddrlens[1] = sizeof (struct sockaddr_in); | 1034 | saddrlens[i] = sizeof (struct sockaddr_in); |
919 | saddrs[1] = GNUNET_malloc (saddrlens[1]); | 1035 | saddrs[i] = GNUNET_malloc (saddrlens[i]); |
920 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1036 | #if HAVE_SOCKADDR_IN_SIN_LEN |
921 | ((struct sockaddr_in *) saddrs[1])->sin_len = saddrlens[1]; | 1037 | ((struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[1]; |
922 | #endif | 1038 | #endif |
923 | ((struct sockaddr_in *) saddrs[1])->sin_family = AF_INET; | 1039 | ((struct sockaddr_in *) saddrs[i])->sin_family = AF_INET; |
924 | ((struct sockaddr_in *) saddrs[1])->sin_port = htons (port); | 1040 | ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port); |
925 | } | 1041 | } |
926 | } | 1042 | } |
1043 | GNUNET_free_non_null (unixpath); | ||
927 | *addrs = saddrs; | 1044 | *addrs = saddrs; |
928 | *addr_lens = saddrlens; | 1045 | *addr_lens = saddrlens; |
929 | return resi; | 1046 | return resi; |
@@ -934,8 +1051,9 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, | |||
934 | * Setup addr, addrlen, maxbuf, idle_timeout | 1051 | * Setup addr, addrlen, maxbuf, idle_timeout |
935 | * based on configuration! | 1052 | * based on configuration! |
936 | * | 1053 | * |
937 | * Configuration must specify a "PORT". It may | 1054 | * Configuration may specify: |
938 | * specify: | 1055 | * - PORT (where to bind to for TCP) |
1056 | * - UNIXPATH (where to bind to for UNIX domain sockets) | ||
939 | * - TIMEOUT (after how many ms does an inactive service timeout); | 1057 | * - TIMEOUT (after how many ms does an inactive service timeout); |
940 | * - MAXBUF (maximum incoming message size supported) | 1058 | * - MAXBUF (maximum incoming message size supported) |
941 | * - DISABLEV6 (disable support for IPv6, otherwise we use dual-stack) | 1059 | * - DISABLEV6 (disable support for IPv6, otherwise we use dual-stack) |
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index e6496e7ac..c24646d07 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -222,6 +222,7 @@ static void | |||
222 | run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | 222 | run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, |
223 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 223 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
224 | { | 224 | { |
225 | int *ok = cls; | ||
225 | struct sockaddr_in sa; | 226 | struct sockaddr_in sa; |
226 | struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply( | 227 | struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply( |
227 | GNUNET_TIME_UNIT_MILLISECONDS, 2500); | 228 | GNUNET_TIME_UNIT_MILLISECONDS, 2500); |
@@ -267,6 +268,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args, | |||
267 | #endif | 268 | #endif |
268 | fprintf (stderr, | 269 | fprintf (stderr, |
269 | "System seems to be off-line, will not run all DNS tests\n"); | 270 | "System seems to be off-line, will not run all DNS tests\n"); |
271 | *ok = 0; /* mark test as passing anyway */ | ||
270 | return; | 272 | return; |
271 | } | 273 | } |
272 | 274 | ||