aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile.am36
-rw-r--r--src/util/Makefile.in90
-rw-r--r--src/util/client.c503
-rw-r--r--src/util/common_logging.c17
-rw-r--r--src/util/configuration.c37
-rw-r--r--src/util/connection.c1184
-rw-r--r--src/util/container_bloomfilter.c31
-rw-r--r--src/util/container_heap.c14
-rw-r--r--src/util/container_slist.c29
-rw-r--r--src/util/crypto_aes.c87
-rw-r--r--src/util/crypto_hash.c235
-rw-r--r--src/util/crypto_hkdf.c1
-rw-r--r--src/util/crypto_ksk.c195
-rw-r--r--src/util/crypto_random.c6
-rw-r--r--src/util/crypto_rsa.c163
-rw-r--r--src/util/disk.c106
-rw-r--r--src/util/getopt.c15
-rw-r--r--src/util/getopt_helpers.c9
-rw-r--r--src/util/gnunet-rsa.c128
-rw-r--r--src/util/gnunet-service-resolver.c8
-rw-r--r--src/util/helper.c142
-rw-r--r--src/util/load.c1
-rw-r--r--src/util/network.c211
-rw-r--r--src/util/os_installation.c2
-rw-r--r--src/util/os_priority.c193
-rw-r--r--src/util/program.c54
-rw-r--r--src/util/pseudonym.c205
-rw-r--r--src/util/resolver.conf.in2
-rw-r--r--src/util/resolver.h2
-rw-r--r--src/util/resolver_api.c40
-rw-r--r--src/util/scheduler.c160
-rw-r--r--src/util/server.c753
-rw-r--r--src/util/server_mst.c13
-rw-r--r--src/util/server_nc.c100
-rw-r--r--src/util/server_tc.c5
-rw-r--r--src/util/service.c408
-rw-r--r--src/util/speedup.c92
-rw-r--r--src/util/strings.c697
-rw-r--r--src/util/test_client.c6
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c2
-rw-r--r--src/util/test_configuration.c7
-rw-r--r--src/util/test_connection.c6
-rw-r--r--src/util/test_connection_addressing.c7
-rw-r--r--src/util/test_connection_receive_cancel.c7
-rw-r--r--src/util/test_connection_timeout.c4
-rw-r--r--src/util/test_connection_transmit_cancel.c2
-rw-r--r--src/util/test_disk.c2
-rw-r--r--src/util/test_os_start_process.c75
-rw-r--r--src/util/test_pseudonym.c30
-rw-r--r--src/util/test_resolver_api.c28
-rw-r--r--src/util/test_scheduler.c44
-rw-r--r--src/util/test_server.c2
-rw-r--r--src/util/test_server_disconnect.c2
-rw-r--r--src/util/test_server_mst_interrupt.c81
-rw-r--r--src/util/test_server_with_client.c2
-rw-r--r--src/util/test_server_with_client_unix.c2
-rw-r--r--src/util/test_service.c63
-rw-r--r--src/util/test_speedup.c120
-rw-r--r--src/util/test_speedup_data.conf3
-rw-r--r--src/util/test_strings.c2
-rw-r--r--src/util/test_time.c24
-rw-r--r--src/util/time.c77
-rw-r--r--src/util/util.conf2
-rw-r--r--src/util/winproc.c3
64 files changed, 3935 insertions, 2642 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index cded34d..8414ef2 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -37,6 +37,7 @@ noinst_PROGRAMS = \
gnunet-config-diff \
test_common_logging_dummy
+
gnunet_config_diff_SOURCES = \
gnunet-config-diff.c
gnunet_config_diff_LDADD = \
@@ -98,23 +99,26 @@ libgnunetutil_la_SOURCES = \
service.c \
signal.c \
strings.c \
- time.c
+ time.c \
+ speedup.c
libgnunetutil_la_LIBADD = \
$(GCLIBADD) $(WINLIB) \
$(LIBGCRYPT_LIBS) \
$(LTLIBICONV) \
- -lltdl -lz $(XLIB)
+ -lltdl -lz -lunistring $(XLIB)
libgnunetutil_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
- -version-info 7:0:0
+ -version-info 8:0:0
bin_PROGRAMS = \
gnunet-service-resolver \
- gnunet-resolver
+ gnunet-resolver \
+ gnunet-rsa
+
gnunet_service_resolver_SOURCES = \
gnunet-service-resolver.c
@@ -133,6 +137,15 @@ gnunet_resolver_LDADD = \
gnunet_resolver_DEPENDENCIES = \
libgnunetutil.la
+
+gnunet_rsa_SOURCES = \
+ gnunet-rsa.c
+gnunet_rsa_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+gnunet_rsa_DEPENDENCIES = \
+ libgnunetutil.la
+
plugin_LTLIBRARIES = \
libgnunet_plugin_test.la
@@ -183,6 +196,7 @@ check_PROGRAMS = \
test_resolver_api \
test_scheduler \
test_scheduler_delay \
+ test_server_mst_interrupt \
test_server \
test_server_disconnect \
test_server_with_client \
@@ -190,6 +204,7 @@ check_PROGRAMS = \
test_service \
test_strings \
test_time \
+ test_speedup \
$(BENCHMARKS) \
test_os_start_process \
test_common_logging_runtime_loglevels
@@ -390,6 +405,11 @@ test_scheduler_delay_SOURCES = \
test_scheduler_delay_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la
+test_server_mst_interrupt_SOURCES = \
+ test_server_mst_interrupt.c
+test_server_mst_interrupt_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_server_SOURCES = \
test_server.c
test_server_LDADD = \
@@ -426,6 +446,11 @@ test_time_SOURCES = \
test_time_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la
+test_speedup_SOURCES = \
+ test_speedup.c
+test_speedup_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
+
perf_crypto_hash_SOURCES = \
perf_crypto_hash.c
perf_crypto_hash_LDADD = \
@@ -437,4 +462,5 @@ EXTRA_DIST = \
test_program_data.conf \
test_pseudonym_data.conf \
test_resolver_api_data.conf \
- test_service_data.conf
+ test_service_data.conf \
+ test_speedup_data.conf
diff --git a/src/util/Makefile.in b/src/util/Makefile.in
index 3c82fbf..5ea0157 100644
--- a/src/util/Makefile.in
+++ b/src/util/Makefile.in
@@ -40,7 +40,7 @@ target_triplet = @target@
noinst_PROGRAMS = gnunet-config-diff$(EXEEXT) \
test_common_logging_dummy$(EXEEXT)
bin_PROGRAMS = gnunet-service-resolver$(EXEEXT) \
- gnunet-resolver$(EXEEXT)
+ gnunet-resolver$(EXEEXT) gnunet-rsa$(EXEEXT)
check_PROGRAMS = test_bio$(EXEEXT) test_client$(EXEEXT) \
test_common_allocation$(EXEEXT) test_common_endian$(EXEEXT) \
test_common_logging$(EXEEXT) test_configuration$(EXEEXT) \
@@ -62,10 +62,12 @@ check_PROGRAMS = test_bio$(EXEEXT) test_client$(EXEEXT) \
test_peer$(EXEEXT) test_plugin$(EXEEXT) test_program$(EXEEXT) \
test_pseudonym$(EXEEXT) test_resolver_api$(EXEEXT) \
test_scheduler$(EXEEXT) test_scheduler_delay$(EXEEXT) \
- test_server$(EXEEXT) test_server_disconnect$(EXEEXT) \
+ test_server_mst_interrupt$(EXEEXT) test_server$(EXEEXT) \
+ test_server_disconnect$(EXEEXT) \
test_server_with_client$(EXEEXT) $(am__EXEEXT_1) \
test_service$(EXEEXT) test_strings$(EXEEXT) test_time$(EXEEXT) \
- $(am__EXEEXT_2) test_os_start_process$(EXEEXT) \
+ test_speedup$(EXEEXT) $(am__EXEEXT_2) \
+ test_os_start_process$(EXEEXT) \
test_common_logging_runtime_loglevels$(EXEEXT)
subdir = src/util
DIST_COMMON = $(dist_pkgcfg_DATA) $(srcdir)/Makefile.am \
@@ -140,7 +142,7 @@ am_libgnunetutil_la_OBJECTS = bandwidth.lo bio.lo client.lo \
os_installation.lo os_network.lo os_priority.lo peer.lo \
plugin.lo program.lo pseudonym.lo resolver_api.lo scheduler.lo \
server.lo server_mst.lo server_nc.lo server_tc.lo service.lo \
- signal.lo strings.lo time.lo
+ signal.lo strings.lo time.lo speedup.lo
libgnunetutil_la_OBJECTS = $(am_libgnunetutil_la_OBJECTS)
libgnunetutil_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
@@ -162,6 +164,8 @@ am_gnunet_config_diff_OBJECTS = gnunet-config-diff.$(OBJEXT)
gnunet_config_diff_OBJECTS = $(am_gnunet_config_diff_OBJECTS)
am_gnunet_resolver_OBJECTS = gnunet-resolver.$(OBJEXT)
gnunet_resolver_OBJECTS = $(am_gnunet_resolver_OBJECTS)
+am_gnunet_rsa_OBJECTS = gnunet-rsa.$(OBJEXT)
+gnunet_rsa_OBJECTS = $(am_gnunet_rsa_OBJECTS)
am_gnunet_service_resolver_OBJECTS = \
gnunet-service-resolver.$(OBJEXT)
gnunet_service_resolver_OBJECTS = \
@@ -345,6 +349,12 @@ am_test_server_disconnect_OBJECTS = test_server_disconnect.$(OBJEXT)
test_server_disconnect_OBJECTS = $(am_test_server_disconnect_OBJECTS)
test_server_disconnect_DEPENDENCIES = \
$(top_builddir)/src/util/libgnunetutil.la
+am_test_server_mst_interrupt_OBJECTS = \
+ test_server_mst_interrupt.$(OBJEXT)
+test_server_mst_interrupt_OBJECTS = \
+ $(am_test_server_mst_interrupt_OBJECTS)
+test_server_mst_interrupt_DEPENDENCIES = \
+ $(top_builddir)/src/util/libgnunetutil.la
am_test_server_with_client_OBJECTS = \
test_server_with_client.$(OBJEXT)
test_server_with_client_OBJECTS = \
@@ -360,6 +370,9 @@ test_server_with_client_unix_DEPENDENCIES = \
am_test_service_OBJECTS = test_service.$(OBJEXT)
test_service_OBJECTS = $(am_test_service_OBJECTS)
test_service_DEPENDENCIES = $(top_builddir)/src/util/libgnunetutil.la
+am_test_speedup_OBJECTS = test_speedup.$(OBJEXT)
+test_speedup_OBJECTS = $(am_test_speedup_OBJECTS)
+test_speedup_DEPENDENCIES = $(top_builddir)/src/util/libgnunetutil.la
am_test_strings_OBJECTS = test_strings.$(OBJEXT)
test_strings_OBJECTS = $(am_test_strings_OBJECTS)
test_strings_DEPENDENCIES = $(top_builddir)/src/util/libgnunetutil.la
@@ -411,9 +424,9 @@ am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libgnunet_plugin_test_la_SOURCES) \
$(libgnunetutil_la_SOURCES) $(libgnunetutilwin_la_SOURCES) \
$(gnunet_config_diff_SOURCES) $(gnunet_resolver_SOURCES) \
- $(gnunet_service_resolver_SOURCES) $(perf_crypto_hash_SOURCES) \
- $(test_bio_SOURCES) $(test_client_SOURCES) \
- $(test_common_allocation_SOURCES) \
+ $(gnunet_rsa_SOURCES) $(gnunet_service_resolver_SOURCES) \
+ $(perf_crypto_hash_SOURCES) $(test_bio_SOURCES) \
+ $(test_client_SOURCES) $(test_common_allocation_SOURCES) \
$(test_common_endian_SOURCES) $(test_common_logging_SOURCES) \
$(test_common_logging_dummy_SOURCES) \
$(test_common_logging_runtime_loglevels_SOURCES) \
@@ -439,17 +452,18 @@ SOURCES = $(libgnunet_plugin_test_la_SOURCES) \
$(test_resolver_api_SOURCES) $(test_scheduler_SOURCES) \
$(test_scheduler_delay_SOURCES) $(test_server_SOURCES) \
$(test_server_disconnect_SOURCES) \
+ $(test_server_mst_interrupt_SOURCES) \
$(test_server_with_client_SOURCES) \
$(test_server_with_client_unix_SOURCES) \
- $(test_service_SOURCES) $(test_strings_SOURCES) \
- $(test_time_SOURCES)
+ $(test_service_SOURCES) $(test_speedup_SOURCES) \
+ $(test_strings_SOURCES) $(test_time_SOURCES)
DIST_SOURCES = $(libgnunet_plugin_test_la_SOURCES) \
$(libgnunetutil_la_SOURCES) \
$(am__libgnunetutilwin_la_SOURCES_DIST) \
$(gnunet_config_diff_SOURCES) $(gnunet_resolver_SOURCES) \
- $(gnunet_service_resolver_SOURCES) $(perf_crypto_hash_SOURCES) \
- $(test_bio_SOURCES) $(test_client_SOURCES) \
- $(test_common_allocation_SOURCES) \
+ $(gnunet_rsa_SOURCES) $(gnunet_service_resolver_SOURCES) \
+ $(perf_crypto_hash_SOURCES) $(test_bio_SOURCES) \
+ $(test_client_SOURCES) $(test_common_allocation_SOURCES) \
$(test_common_endian_SOURCES) $(test_common_logging_SOURCES) \
$(test_common_logging_dummy_SOURCES) \
$(test_common_logging_runtime_loglevels_SOURCES) \
@@ -475,10 +489,11 @@ DIST_SOURCES = $(libgnunet_plugin_test_la_SOURCES) \
$(test_resolver_api_SOURCES) $(test_scheduler_SOURCES) \
$(test_scheduler_delay_SOURCES) $(test_server_SOURCES) \
$(test_server_disconnect_SOURCES) \
+ $(test_server_mst_interrupt_SOURCES) \
$(test_server_with_client_SOURCES) \
$(test_server_with_client_unix_SOURCES) \
- $(test_service_SOURCES) $(test_strings_SOURCES) \
- $(test_time_SOURCES)
+ $(test_service_SOURCES) $(test_speedup_SOURCES) \
+ $(test_strings_SOURCES) $(test_time_SOURCES)
DATA = $(dist_pkgcfg_DATA) $(pkgcfg_DATA)
ETAGS = etags
CTAGS = ctags
@@ -540,6 +555,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+JAVAPORT = @JAVAPORT@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
@@ -573,6 +589,7 @@ LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
+MONKEYPREFIX = @MONKEYPREFIX@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
@@ -780,17 +797,18 @@ libgnunetutil_la_SOURCES = \
service.c \
signal.c \
strings.c \
- time.c
+ time.c \
+ speedup.c
libgnunetutil_la_LIBADD = \
$(GCLIBADD) $(WINLIB) \
$(LIBGCRYPT_LIBS) \
$(LTLIBICONV) \
- -lltdl -lz $(XLIB)
+ -lltdl -lz -lunistring $(XLIB)
libgnunetutil_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
- -version-info 7:0:0
+ -version-info 8:0:0
gnunet_service_resolver_SOURCES = \
gnunet-service-resolver.c
@@ -812,6 +830,16 @@ gnunet_resolver_LDADD = \
gnunet_resolver_DEPENDENCIES = \
libgnunetutil.la
+gnunet_rsa_SOURCES = \
+ gnunet-rsa.c
+
+gnunet_rsa_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+
+gnunet_rsa_DEPENDENCIES = \
+ libgnunetutil.la
+
plugin_LTLIBRARIES = \
libgnunet_plugin_test.la
@@ -1054,6 +1082,12 @@ test_scheduler_delay_SOURCES = \
test_scheduler_delay_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la
+test_server_mst_interrupt_SOURCES = \
+ test_server_mst_interrupt.c
+
+test_server_mst_interrupt_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_server_SOURCES = \
test_server.c
@@ -1096,6 +1130,12 @@ test_time_SOURCES = \
test_time_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la
+test_speedup_SOURCES = \
+ test_speedup.c
+
+test_speedup_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
+
perf_crypto_hash_SOURCES = \
perf_crypto_hash.c
@@ -1107,7 +1147,8 @@ EXTRA_DIST = \
test_program_data.conf \
test_pseudonym_data.conf \
test_resolver_api_data.conf \
- test_service_data.conf
+ test_service_data.conf \
+ test_speedup_data.conf
all: all-am
@@ -1289,6 +1330,9 @@ gnunet-config-diff$(EXEEXT): $(gnunet_config_diff_OBJECTS) $(gnunet_config_diff_
gnunet-resolver$(EXEEXT): $(gnunet_resolver_OBJECTS) $(gnunet_resolver_DEPENDENCIES)
@rm -f gnunet-resolver$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gnunet_resolver_OBJECTS) $(gnunet_resolver_LDADD) $(LIBS)
+gnunet-rsa$(EXEEXT): $(gnunet_rsa_OBJECTS) $(gnunet_rsa_DEPENDENCIES)
+ @rm -f gnunet-rsa$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(gnunet_rsa_OBJECTS) $(gnunet_rsa_LDADD) $(LIBS)
gnunet-service-resolver$(EXEEXT): $(gnunet_service_resolver_OBJECTS) $(gnunet_service_resolver_DEPENDENCIES)
@rm -f gnunet-service-resolver$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gnunet_service_resolver_OBJECTS) $(gnunet_service_resolver_LDADD) $(LIBS)
@@ -1418,6 +1462,9 @@ test_server$(EXEEXT): $(test_server_OBJECTS) $(test_server_DEPENDENCIES)
test_server_disconnect$(EXEEXT): $(test_server_disconnect_OBJECTS) $(test_server_disconnect_DEPENDENCIES)
@rm -f test_server_disconnect$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_server_disconnect_OBJECTS) $(test_server_disconnect_LDADD) $(LIBS)
+test_server_mst_interrupt$(EXEEXT): $(test_server_mst_interrupt_OBJECTS) $(test_server_mst_interrupt_DEPENDENCIES)
+ @rm -f test_server_mst_interrupt$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_server_mst_interrupt_OBJECTS) $(test_server_mst_interrupt_LDADD) $(LIBS)
test_server_with_client$(EXEEXT): $(test_server_with_client_OBJECTS) $(test_server_with_client_DEPENDENCIES)
@rm -f test_server_with_client$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_server_with_client_OBJECTS) $(test_server_with_client_LDADD) $(LIBS)
@@ -1427,6 +1474,9 @@ test_server_with_client_unix$(EXEEXT): $(test_server_with_client_unix_OBJECTS) $
test_service$(EXEEXT): $(test_service_OBJECTS) $(test_service_DEPENDENCIES)
@rm -f test_service$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_service_OBJECTS) $(test_service_LDADD) $(LIBS)
+test_speedup$(EXEEXT): $(test_speedup_OBJECTS) $(test_speedup_DEPENDENCIES)
+ @rm -f test_speedup$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_speedup_OBJECTS) $(test_speedup_LDADD) $(LIBS)
test_strings$(EXEEXT): $(test_strings_OBJECTS) $(test_strings_DEPENDENCIES)
@rm -f test_strings$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_strings_OBJECTS) $(test_strings_LDADD) $(LIBS)
@@ -1466,6 +1516,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt_helpers.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnunet-config-diff.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnunet-resolver.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnunet-rsa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnunet-service-resolver.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load.Plo@am__quote@
@@ -1486,6 +1537,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server_tc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/service.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speedup.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strings.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_bio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_client.Po@am__quote@
@@ -1529,9 +1581,11 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_scheduler_delay.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server_disconnect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server_mst_interrupt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server_with_client.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_server_with_client_unix.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_service.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_speedup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_strings.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@
diff --git a/src/util/client.c b/src/util/client.c
index 2f09a90..c29b48e 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
+ (C) 2001, 2002, 2006, 2008, 2009, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -26,7 +26,6 @@
* Generic TCP code for reliable, record-oriented TCP
* connections between clients and service providers.
*/
-
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_client_lib.h"
@@ -34,7 +33,6 @@
#include "gnunet_server_lib.h"
#include "gnunet_scheduler_lib.h"
-#define DEBUG_CLIENT GNUNET_EXTRA_LOGGING
/**
* How often do we re-try tranmsitting requests before giving up?
@@ -53,7 +51,7 @@ struct GNUNET_CLIENT_TransmitHandle
/**
* Connection state.
*/
- struct GNUNET_CLIENT_Connection *sock;
+ struct GNUNET_CLIENT_Connection *client;
/**
* Function to call to get the data for transmission.
@@ -113,7 +111,7 @@ struct TransmitGetResponseContext
/**
* Client handle.
*/
- struct GNUNET_CLIENT_Connection *sock;
+ struct GNUNET_CLIENT_Connection *client;
/**
* Message to transmit; do not free, allocated
@@ -147,9 +145,9 @@ struct GNUNET_CLIENT_Connection
{
/**
- * the socket handle, NULL if not live
+ * The connection handle, NULL if not live
*/
- struct GNUNET_CONNECTION_Handle *sock;
+ struct GNUNET_CONNECTION_Handle *connection;
/**
* Our configuration.
@@ -250,6 +248,79 @@ struct GNUNET_CLIENT_Connection
/**
+ * Try connecting to the server using UNIX domain sockets.
+ *
+ * @param service_name name of service to connect to
+ * @param cfg configuration to use
+ * @return NULL on error, connection to UNIX otherwise
+ */
+static struct GNUNET_CONNECTION_Handle *
+try_unixpath (const char *service_name,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+#if AF_UNIX
+ struct GNUNET_CONNECTION_Handle *connection;
+ char *unixpath;
+
+ unixpath = NULL;
+ if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) &&
+ (0 < strlen (unixpath)))
+ {
+ /* We have a non-NULL unixpath, need to validate it */
+ connection = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath);
+ if (NULL != connection)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to unixpath `%s'!\n",
+ unixpath);
+ GNUNET_free (unixpath);
+ return connection;
+ }
+ }
+ GNUNET_free_non_null (unixpath);
+#endif
+ return NULL;
+}
+
+
+/**
+ * Try connecting to the server using UNIX domain sockets.
+ *
+ * @param service_name name of service to connect to
+ * @param cfg configuration to use
+ * @return GNUNET_OK if the configuration is valid, GNUNET_SYSERR if not
+ */
+static int
+test_service_configuration (const char *service_name,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ int ret = GNUNET_SYSERR;
+ char *hostname = NULL;
+ unsigned long long port;
+#if AF_UNIX
+ char *unixpath = NULL;
+
+ if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) &&
+ (0 < strlen (unixpath)))
+ ret = GNUNET_OK;
+ GNUNET_free_non_null (unixpath);
+#endif
+
+ if ( (GNUNET_YES ==
+ GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) &&
+ (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port)) &&
+ (port <= 65535) && (0 != port) &&
+ (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME",
+ &hostname)) &&
+ (0 != strlen (hostname)) )
+ ret = GNUNET_OK;
+ GNUNET_free_non_null (hostname);
+ return ret;
+}
+
+
+/**
* Try to connect to the service.
*
* @param service_name name of service to connect to
@@ -261,34 +332,18 @@ static struct GNUNET_CONNECTION_Handle *
do_connect (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int attempt)
{
- struct GNUNET_CONNECTION_Handle *sock;
+ struct GNUNET_CONNECTION_Handle *connection;
char *hostname;
- char *unixpath;
unsigned long long port;
- sock = NULL;
-#if AF_UNIX
+ connection = NULL;
if (0 == (attempt % 2))
{
- /* on even rounds, try UNIX */
- unixpath = NULL;
- if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) && (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */
- {
- sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath);
- if (sock != NULL)
- {
-#if DEBUG_CLIENT
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to unixpath `%s'!\n",
- unixpath);
-#endif
- GNUNET_free (unixpath);
- return sock;
- }
- }
- GNUNET_free_non_null (unixpath);
+ /* on even rounds, try UNIX first */
+ connection = try_unixpath (service_name, cfg);
+ if (NULL != connection)
+ return connection;
}
-#endif
-
if (GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
{
@@ -319,42 +374,21 @@ do_connect (const char *service_name,
port = 0;
hostname = NULL;
}
- if (port == 0)
+ if (0 == port)
{
-#if AF_UNIX
- if (0 != (attempt % 2))
- {
- /* try UNIX */
- unixpath = NULL;
- if ((GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH",
- &unixpath)) &&
- (0 < strlen (unixpath)))
- {
- sock =
- GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath);
- if (sock != NULL)
- {
- GNUNET_free (unixpath);
- GNUNET_free_non_null (hostname);
- return sock;
- }
- }
- GNUNET_free_non_null (unixpath);
- }
-#endif
-#if DEBUG_CLIENT
+ /* if port is 0, try UNIX */
+ connection = try_unixpath (service_name, cfg);
+ if (NULL != connection)
+ return connection;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Port is 0 for service `%s', UNIXPATH did not work, returning NULL!\n",
service_name);
-#endif
GNUNET_free_non_null (hostname);
return NULL;
}
-
- sock = GNUNET_CONNECTION_create_from_connect (cfg, hostname, port);
+ connection = GNUNET_CONNECTION_create_from_connect (cfg, hostname, port);
GNUNET_free (hostname);
- return sock;
+ return connection;
}
@@ -369,17 +403,21 @@ struct GNUNET_CLIENT_Connection *
GNUNET_CLIENT_connect (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- struct GNUNET_CLIENT_Connection *ret;
- struct GNUNET_CONNECTION_Handle *sock;
-
- sock = do_connect (service_name, cfg, 0);
- ret = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection));
- ret->attempts = 1;
- ret->sock = sock;
- ret->service_name = GNUNET_strdup (service_name);
- ret->cfg = cfg;
- ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS;
- return ret;