diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2013-07-22 08:26:16 -0500 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2013-07-22 08:26:16 -0500 |
commit | 7450bd0b6c6c05ee6425e2c63e9b79beb94bfbfa (patch) | |
tree | dfde89b41437def7ce23af24db53a11a9b5f1075 /src/core | |
parent | 740b30688bd745a527f96f9116c19acb3480971a (diff) |
Imported Upstream version 0.9.5aupstream
Diffstat (limited to 'src/core')
28 files changed, 871 insertions, 637 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index e95cbcf..6d073da 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ core.conf @@ -27,11 +29,13 @@ libgnunetcore_la_LIBADD = \ $(GN_LIBINTL) $(XLIB) libgnunetcore_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 0:0:0 + -version-info 0:1:0 + +libexec_PROGRAMS = \ + gnunet-service-core bin_PROGRAMS = \ - gnunet-service-core \ gnunet-core gnunet_service_core_SOURCES = \ @@ -89,12 +93,14 @@ test_core_api_send_to_self_SOURCES = \ test_core_api_send_to_self.c test_core_api_send_to_self_LDADD = \ $(top_builddir)/src/core/libgnunetcore.la \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/util/libgnunetutil.la test_core_api_start_only_SOURCES = \ test_core_api_start_only.c test_core_api_start_only_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/core/Makefile.in b/src/core/Makefile.in index f181a54..c44ac57 100644 --- a/src/core/Makefile.in +++ b/src/core/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -18,6 +18,23 @@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -37,7 +54,8 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -bin_PROGRAMS = gnunet-service-core$(EXEEXT) gnunet-core$(EXEEXT) +libexec_PROGRAMS = gnunet-service-core$(EXEEXT) +bin_PROGRAMS = gnunet-core$(EXEEXT) check_PROGRAMS = test_core_api_start_only$(EXEEXT) \ test_core_api$(EXEEXT) test_core_api_reliability$(EXEEXT) \ test_core_quota_compliance_symmetric$(EXEEXT) \ @@ -50,14 +68,15 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \ $(top_srcdir)/m4/align.m4 $(top_srcdir)/m4/argz.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcurl.m4 \ - $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/libunistring.m4 $(top_srcdir)/m4/ltdl.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glib-2.0.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libgcrypt.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \ + $(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -87,8 +106,14 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(pkgcfgdir)" + "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(pkgcfgdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libgnunetcore_la_DEPENDENCIES = \ @@ -97,14 +122,14 @@ libgnunetcore_la_DEPENDENCIES = \ am_libgnunetcore_la_OBJECTS = core_api.lo core_api_iterate_peers.lo \ core_api_is_connected.lo libgnunetcore_la_OBJECTS = $(am_libgnunetcore_la_OBJECTS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent libgnunetcore_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libgnunetcore_la_LDFLAGS) $(LDFLAGS) \ -o $@ -PROGRAMS = $(bin_PROGRAMS) +PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) am_gnunet_core_OBJECTS = gnunet-core.$(OBJEXT) gnunet_core_OBJECTS = $(am_gnunet_core_OBJECTS) am_gnunet_service_core_OBJECTS = gnunet-service-core.$(OBJEXT) \ @@ -141,6 +166,7 @@ test_core_api_send_to_self_OBJECTS = \ $(am_test_core_api_send_to_self_OBJECTS) test_core_api_send_to_self_DEPENDENCIES = \ $(top_builddir)/src/core/libgnunetcore.la \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/util/libgnunetutil.la am_test_core_api_start_only_OBJECTS = \ @@ -148,6 +174,7 @@ am_test_core_api_start_only_OBJECTS = \ test_core_api_start_only_OBJECTS = \ $(am_test_core_api_start_only_OBJECTS) test_core_api_start_only_DEPENDENCIES = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la am_test_core_quota_compliance_asymmetric_recv_limited_OBJECTS = \ @@ -185,21 +212,21 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libgnunetcore_la_SOURCES) $(gnunet_core_SOURCES) \ $(gnunet_service_core_SOURCES) $(test_core_api_SOURCES) \ @@ -217,6 +244,11 @@ DIST_SOURCES = $(libgnunetcore_la_SOURCES) $(gnunet_core_SOURCES) \ $(test_core_quota_compliance_asymmetric_recv_limited_SOURCES) \ $(test_core_quota_compliance_asymmetric_send_limited_SOURCES) \ $(test_core_quota_compliance_symmetric_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac DATA = $(pkgcfg_DATA) ETAGS = etags CTAGS = ctags @@ -258,6 +290,10 @@ EXEEXT = @EXEEXT@ EXT_LIBS = @EXT_LIBS@ EXT_LIB_PATH = @EXT_LIB_PATH@ FGREP = @FGREP@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNUNETDNS_GROUP = @GNUNETDNS_GROUP@ @@ -268,6 +304,7 @@ GN_LIBINTL = @GN_LIBINTL@ GN_LIB_LDFLAGS = @GN_LIB_LDFLAGS@ GN_PLUGIN_LDFLAGS = @GN_PLUGIN_LDFLAGS@ GN_USER_HOME_DIR = @GN_USER_HOME_DIR@ +GOBJECT_QUERY = @GOBJECT_QUERY@ GREP = @GREP@ HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@ INCLTDL = @INCLTDL@ @@ -290,6 +327,8 @@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBGTOP_CFLAGS = @LIBGTOP_CFLAGS@ +LIBGTOP_LIBS = @LIBGTOP_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBLTDL = @LIBLTDL@ @@ -311,6 +350,7 @@ LT_CONFIG_H = @LT_CONFIG_H@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MONKEYPREFIX = @MONKEYPREFIX@ MSGFMT = @MSGFMT@ @@ -320,6 +360,7 @@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ NM = @NM@ NMEDIT = @NMEDIT@ +NSS_DIR = @NSS_DIR@ OBJC = @OBJC@ OBJCDEPMODE = @OBJCDEPMODE@ OBJCFLAGS = @OBJCFLAGS@ @@ -335,6 +376,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ POSTGRES_CPPFLAGS = @POSTGRES_CPPFLAGS@ POSTGRES_LDFLAGS = @POSTGRES_LDFLAGS@ POSUB = @POSUB@ @@ -366,6 +408,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ @@ -388,6 +431,7 @@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +gitcommand = @gitcommand@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ @@ -398,10 +442,9 @@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ -libexecdir = @libexecdir@ +libexecdir = $(pkglibdir)/libexec/ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ mandir = @mandir@ @@ -419,6 +462,7 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ subdirs = @subdirs@ +svnversioncommand = @svnversioncommand@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ @@ -451,7 +495,7 @@ libgnunetcore_la_LIBADD = \ libgnunetcore_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 0:0:0 + -version-info 0:1:0 gnunet_service_core_SOURCES = \ gnunet-service-core.c gnunet-service-core.h \ @@ -501,6 +545,7 @@ test_core_api_send_to_self_SOURCES = \ test_core_api_send_to_self_LDADD = \ $(top_builddir)/src/core/libgnunetcore.la \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -508,6 +553,7 @@ test_core_api_start_only_SOURCES = \ test_core_api_start_only.c test_core_api_start_only_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -589,7 +635,6 @@ core.conf: $(top_builddir)/config.status $(srcdir)/core.conf.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ @@ -597,6 +642,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) else :; fi; \ done; \ test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } @@ -618,12 +665,15 @@ clean-libLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done -libgnunetcore.la: $(libgnunetcore_la_OBJECTS) $(libgnunetcore_la_DEPENDENCIES) +libgnunetcore.la: $(libgnunetcore_la_OBJECTS) $(libgnunetcore_la_DEPENDENCIES) $(EXTRA_libgnunetcore_la_DEPENDENCIES) $(AM_V_CCLD)$(libgnunetcore_la_LINK) -rpath $(libdir) $(libgnunetcore_la_OBJECTS) $(libgnunetcore_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ @@ -672,31 +722,77 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -gnunet-core$(EXEEXT): $(gnunet_core_OBJECTS) $(gnunet_core_DEPENDENCIES) +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +gnunet-core$(EXEEXT): $(gnunet_core_OBJECTS) $(gnunet_core_DEPENDENCIES) $(EXTRA_gnunet_core_DEPENDENCIES) @rm -f gnunet-core$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gnunet_core_OBJECTS) $(gnunet_core_LDADD) $(LIBS) -gnunet-service-core$(EXEEXT): $(gnunet_service_core_OBJECTS) $(gnunet_service_core_DEPENDENCIES) +gnunet-service-core$(EXEEXT): $(gnunet_service_core_OBJECTS) $(gnunet_service_core_DEPENDENCIES) $(EXTRA_gnunet_service_core_DEPENDENCIES) @rm -f gnunet-service-core$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gnunet_service_core_OBJECTS) $(gnunet_service_core_LDADD) $(LIBS) -test_core_api$(EXEEXT): $(test_core_api_OBJECTS) $(test_core_api_DEPENDENCIES) +test_core_api$(EXEEXT): $(test_core_api_OBJECTS) $(test_core_api_DEPENDENCIES) $(EXTRA_test_core_api_DEPENDENCIES) @rm -f test_core_api$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_api_OBJECTS) $(test_core_api_LDADD) $(LIBS) -test_core_api_reliability$(EXEEXT): $(test_core_api_reliability_OBJECTS) $(test_core_api_reliability_DEPENDENCIES) +test_core_api_reliability$(EXEEXT): $(test_core_api_reliability_OBJECTS) $(test_core_api_reliability_DEPENDENCIES) $(EXTRA_test_core_api_reliability_DEPENDENCIES) @rm -f test_core_api_reliability$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_api_reliability_OBJECTS) $(test_core_api_reliability_LDADD) $(LIBS) -test_core_api_send_to_self$(EXEEXT): $(test_core_api_send_to_self_OBJECTS) $(test_core_api_send_to_self_DEPENDENCIES) +test_core_api_send_to_self$(EXEEXT): $(test_core_api_send_to_self_OBJECTS) $(test_core_api_send_to_self_DEPENDENCIES) $(EXTRA_test_core_api_send_to_self_DEPENDENCIES) @rm -f test_core_api_send_to_self$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_api_send_to_self_OBJECTS) $(test_core_api_send_to_self_LDADD) $(LIBS) -test_core_api_start_only$(EXEEXT): $(test_core_api_start_only_OBJECTS) $(test_core_api_start_only_DEPENDENCIES) +test_core_api_start_only$(EXEEXT): $(test_core_api_start_only_OBJECTS) $(test_core_api_start_only_DEPENDENCIES) $(EXTRA_test_core_api_start_only_DEPENDENCIES) @rm -f test_core_api_start_only$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_api_start_only_OBJECTS) $(test_core_api_start_only_LDADD) $(LIBS) -test_core_quota_compliance_asymmetric_recv_limited$(EXEEXT): $(test_core_quota_compliance_asymmetric_recv_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_recv_limited_DEPENDENCIES) +test_core_quota_compliance_asymmetric_recv_limited$(EXEEXT): $(test_core_quota_compliance_asymmetric_recv_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_recv_limited_DEPENDENCIES) $(EXTRA_test_core_quota_compliance_asymmetric_recv_limited_DEPENDENCIES) @rm -f test_core_quota_compliance_asymmetric_recv_limited$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_quota_compliance_asymmetric_recv_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_recv_limited_LDADD) $(LIBS) -test_core_quota_compliance_asymmetric_send_limited$(EXEEXT): $(test_core_quota_compliance_asymmetric_send_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_send_limited_DEPENDENCIES) +test_core_quota_compliance_asymmetric_send_limited$(EXEEXT): $(test_core_quota_compliance_asymmetric_send_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_send_limited_DEPENDENCIES) $(EXTRA_test_core_quota_compliance_asymmetric_send_limited_DEPENDENCIES) @rm -f test_core_quota_compliance_asymmetric_send_limited$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_quota_compliance_asymmetric_send_limited_OBJECTS) $(test_core_quota_compliance_asymmetric_send_limited_LDADD) $(LIBS) -test_core_quota_compliance_symmetric$(EXEEXT): $(test_core_quota_compliance_symmetric_OBJECTS) $(test_core_quota_compliance_symmetric_DEPENDENCIES) +test_core_quota_compliance_symmetric$(EXEEXT): $(test_core_quota_compliance_symmetric_OBJECTS) $(test_core_quota_compliance_symmetric_DEPENDENCIES) $(EXTRA_test_core_quota_compliance_symmetric_DEPENDENCIES) @rm -f test_core_quota_compliance_symmetric$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_core_quota_compliance_symmetric_OBJECTS) $(test_core_quota_compliance_symmetric_LDADD) $(LIBS) @@ -725,26 +821,23 @@ distclean-compile: .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -753,8 +846,11 @@ clean-libtool: -rm -rf .libs _libs install-pkgcfgDATA: $(pkgcfg_DATA) @$(NORMAL_INSTALL) - test -z "$(pkgcfgdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)" @list='$(pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgcfgdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -768,9 +864,7 @@ uninstall-pkgcfgDATA: @$(NORMAL_UNINSTALL) @list='$(pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgcfgdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgcfgdir)" && rm -f $$files + dir='$(DESTDIR)$(pkgcfgdir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -905,14 +999,15 @@ check-TESTS: $(TESTS) fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ + col="$$grn"; \ else \ - echo "$$red$$dashes"; \ + col="$$red"; \ fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi @@ -954,7 +1049,7 @@ all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) install-binPROGRAMS: install-libLTLIBRARIES installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgcfgdir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(pkgcfgdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -967,10 +1062,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -985,7 +1085,8 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool mostlyclean-am + clean-libLTLIBRARIES clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -1011,7 +1112,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-binPROGRAMS install-libLTLIBRARIES +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES \ + install-libexecPROGRAMS install-html: install-html-am @@ -1052,25 +1154,26 @@ ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ - uninstall-pkgcfgDATA + uninstall-libexecPROGRAMS uninstall-pkgcfgDATA .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-binPROGRAMS install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-libLTLIBRARIES install-man install-pdf \ - install-pdf-am install-pkgcfgDATA install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ + clean-libLTLIBRARIES clean-libexecPROGRAMS clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-libexecPROGRAMS install-man install-pdf install-pdf-am \ + install-pkgcfgDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-libLTLIBRARIES uninstall-libexecPROGRAMS \ uninstall-pkgcfgDATA diff --git a/src/core/core.conf.in b/src/core/core.conf.in index 61ac84e..ad39a8a 100644 --- a/src/core/core.conf.in +++ b/src/core/core.conf.in @@ -3,7 +3,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2092 HOSTNAME = localhost HOME = $SERVICEHOME -CONFIG = $DEFAULTCONFIG BINARY = gnunet-service-core ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -11,7 +10,6 @@ UNIXPATH = /tmp/gnunet-service-core.sock UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES # DISABLE_SOCKET_FORWARDING = NO -# DEBUG = YES # USERNAME = # MAXBUF = # TIMEOUT = diff --git a/src/core/core.h b/src/core/core.h index 03e328c..9b1802f 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -257,9 +257,9 @@ struct SendMessageRequest struct GNUNET_PeerIdentity peer; /** - * How large is the client's message queue for this peer? + * Always zero. */ - uint32_t queue_size GNUNET_PACKED; + uint32_t reserved GNUNET_PACKED; /** * How large is the message? diff --git a/src/core/core_api.c b/src/core/core_api.c index 526dc9f..2b1291d 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -31,6 +31,65 @@ #define LOG(kind,...) GNUNET_log_from (kind, "core-api",__VA_ARGS__) + +/** + * Handle for a transmission request. + */ +struct GNUNET_CORE_TransmitHandle +{ + + /** + * Corresponding peer record. + */ + struct PeerRecord *peer; + + /** + * Corresponding SEND_REQUEST message. Only non-NULL + * while SEND_REQUEST message is pending. + */ + struct ControlMessage *cm; + + /** + * Function that will be called to get the actual request + * (once we are ready to transmit this request to the core). + * The function will be called with a NULL buffer to signal + * timeout. + */ + GNUNET_CONNECTION_TransmitReadyNotify get_message; + + /** + * Closure for get_message. + */ + void *get_message_cls; + + /** + * Timeout for this handle. + */ + struct GNUNET_TIME_Absolute timeout; + + /** + * How important is this message? + */ + uint32_t priority; + + /** + * Size of this request. + */ + uint16_t msize; + + /** + * Send message request ID for this request. + */ + uint16_t smr_id; + + /** + * Is corking allowed? + */ + int cork; + +}; + + /** * Information we track for each peer. */ @@ -62,16 +121,10 @@ struct PeerRecord struct GNUNET_CORE_Handle *ch; /** - * Head of doubly-linked list of pending requests. - * Requests are sorted by deadline *except* for HEAD, - * which is only modified upon transmission to core. - */ - struct GNUNET_CORE_TransmitHandle *pending_head; - - /** - * Tail of doubly-linked list of pending requests. + * Pending request, if any. 'th->peer' is set to NULL if the + * request is not active. */ - struct GNUNET_CORE_TransmitHandle *pending_tail; + struct GNUNET_CORE_TransmitHandle th; /** * ID of timeout task for the 'pending_head' handle @@ -85,11 +138,6 @@ struct PeerRecord GNUNET_SCHEDULER_TaskIdentifier ntr_task; /** - * Current size of the queue of pending requests. - */ - unsigned int queue_size; - - /** * SendMessageRequest ID generator for this peer. */ uint16_t smr_id_gen; @@ -247,11 +295,6 @@ struct GNUNET_CORE_Handle struct GNUNET_TIME_Relative retry_backoff; /** - * Number of messages we are allowed to queue per target. - */ - unsigned int queue_size; - - /** * Number of entries in the handlers array. */ unsigned int hcnt; @@ -278,74 +321,6 @@ struct GNUNET_CORE_Handle /** - * Handle for a transmission request. - */ -struct GNUNET_CORE_TransmitHandle -{ - - /** - * We keep active transmit handles in a doubly-linked list. - */ - struct GNUNET_CORE_TransmitHandle *next; - - /** - * We keep active transmit handles in a doubly-linked list. - */ - struct GNUNET_CORE_TransmitHandle *prev; - - /** - * Corresponding peer record. - */ - struct PeerRecord *peer; - - /** - * Corresponding SEND_REQUEST message. Only non-NULL - * while SEND_REQUEST message is pending. - */ - struct ControlMessage *cm; - - /** - * Function that will be called to get the actual request - * (once we are ready to transmit this request to the core). - * The function will be called with a NULL buffer to signal - * timeout. - */ - GNUNET_CONNECTION_TransmitReadyNotify get_message; - - /** - * Closure for get_message. - */ - void *get_message_cls; - - /** - * Timeout for this handle. - */ - struct GNUNET_TIME_Absolute timeout; - - /** - * How important is this message? - */ - uint32_t priority; - - /** - * Size of this request. - */ - uint16_t msize; - - /** - * Send message request ID for this request. - */ - uint16_t smr_id; - - /** - * Is corking allowed? - */ - int cork; - -}; - - -/** * Our current client connection went down. Clean it up * and try to reconnect! * @@ -382,47 +357,42 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return GNUNET_YES (continue) */ static int -disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key, +disconnect_and_free_peer_entry (void *cls, const struct GNUNET_HashCode * key, void *value) { struct GNUNET_CORE_Handle *h = cls; struct GNUNET_CORE_TransmitHandle *th; struct PeerRecord *pr = value; - if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) + if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task) { GNUNET_SCHEDULER_cancel (pr->timeout_task); pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; } - if (pr->ntr_task != GNUNET_SCHEDULER_NO_TASK) + if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task) { GNUNET_SCHEDULER_cancel (pr->ntr_task); pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; } - if ((pr->prev != NULL) || (pr->next != NULL) || (h->ready_peer_head == pr)) + if ((NULL != pr->prev) || (NULL != pr->next) || (h->ready_peer_head == pr)) GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); - if (h->disconnects != NULL) + if (NULL != h->disconnects) h->disconnects (h->cls, &pr->peer); /* all requests should have been cancelled, clean up anyway, just in case */ - GNUNET_break (pr->queue_size == 0); - while (NULL != (th = pr->pending_head)) + th = &pr->th; + if (NULL != th->peer) { GNUNET_break (0); - GNUNET_CONTAINER_DLL_remove (pr->pending_head, pr->pending_tail, th); - pr->queue_size--; - if (th->cm != NULL) + th->peer = NULL; + if (NULL != th->cm) th->cm->th = NULL; - GNUNET_free (th); } /* done with 'voluntary' cleanups, now on to normal freeing */ GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (h->peers, key, pr)); - GNUNET_assert (pr->pending_head == NULL); - GNUNET_assert (pr->pending_tail == NULL); GNUNET_assert (pr->ch == h); - GNUNET_assert (pr->queue_size == 0); - GNUNET_assert (pr->timeout_task == GNUNET_SCHEDULER_NO_TASK); - GNUNET_assert (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->timeout_task); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task); GNUNET_free (pr); return GNUNET_YES; } @@ -440,13 +410,13 @@ reconnect_later (struct GNUNET_CORE_Handle *h) struct ControlMessage *cm; struct PeerRecord *pr; - GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->reconnect_task); if (NULL != h->cth) { GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); h->cth = NULL; } - if (h->client != NULL) + if (NULL != h->client) { GNUNET_CLIENT_disconnect (h->client); h->client = NULL; @@ -459,9 +429,9 @@ reconnect_later (struct GNUNET_CORE_Handle *h) { GNUNET_CONTAINER_DLL_remove (h->control_pending_head, h->control_pending_tail, cm); - if (cm->th != NULL) + if (NULL != cm->th) cm->th->cm = NULL; - if (cm->cont != NULL) + if (NULL != cm->cont) cm->cont (cm->cont_cls, GNUNET_NO); GNUNET_free (cm); } @@ -470,9 +440,7 @@ reconnect_later (struct GNUNET_CORE_Handle *h) while (NULL != (pr = h->ready_peer_head)) GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); GNUNET_assert (h->control_pending_head == NULL); - h->retry_backoff = - GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->retry_backoff); - h->retry_backoff = GNUNET_TIME_relative_multiply (h->retry_backoff, 2); + h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff); } @@ -517,7 +485,8 @@ request_next_transmission (struct PeerRecord *pr) GNUNET_SCHEDULER_cancel (pr->timeout_task); pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; } - if (NULL == (th = pr->pending_head)) + th = &pr->th; + if (NULL == th->peer) { trigger_next_request (h, GNUNET_NO); return; @@ -539,7 +508,7 @@ request_next_transmission (struct PeerRecord *pr) smr->priority = htonl (th->priority); smr->deadline = GNUNET_TIME_absolute_hton (th->timeout); smr->peer = pr->peer; - smr->queue_size = htonl (pr->queue_size); + smr->reserved = htonl (0); smr->size = htons (th->msize); smr->smr_id = htons (th->smr_id = pr->smr_id_gen++); GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, @@ -566,10 +535,14 @@ transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_CORE_TransmitHandle *th; pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; - th = pr->pending_head; - GNUNET_CONTAINER_DLL_remove (pr->pending_head, pr->pending_tail, th); - pr->queue_size--; - if ((pr->prev != NULL) || (pr->next != NULL) || (pr == h->ready_peer_head)) + if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task) + { + GNUNET_SCHEDULER_cancel (pr->ntr_task); + pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; + } + th = &pr->th; + th->peer = NULL; + if ((NULL != pr->prev) || (NULL != pr->next) || (pr == h->ready_peer_head)) { /* the request that was 'approved' by core was * canceled before it could be transmitted; remove @@ -584,10 +557,11 @@ transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (th->cm); } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Signalling timeout of request for transmission to CORE service\n"); - request_next_transmission (pr); + "Signalling timeout of request for transmission to peer `%s' via CORE\n", + GNUNET_i2s (&pr->peer)); + trigger_next_request (h, GNUNET_NO); + GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL)); - GNUNET_free (th); } @@ -613,7 +587,7 @@ transmit_message (void *cls, size_t size, void *buf) GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); h->cth = NULL; - if (buf == NULL) + if (NULL == buf) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmission failed, initiating reconnect\n"); @@ -636,7 +610,7 @@ transmit_message (void *cls, size_t size, void *buf) memcpy (buf, hdr, msize); GNUNET_CONTAINER_DLL_remove (h->control_pending_head, h->control_pending_tail, cm); - if (cm->th != NULL) + if (NULL != cm->th) cm->th->cm = NULL; if (NULL != cm->cont) cm->cont (cm->cont_cls, GNUNET_OK); @@ -645,67 +619,63 @@ transmit_message (void *cls, size_t size, void *buf) return msize; } /* now check for 'ready' P2P messages */ - if (NULL != (pr = h->ready_peer_head)) + if (NULL == (pr = h->ready_peer_head)) + return 0; + GNUNET_assert (NULL != pr->th.peer); + th = &pr->th; + if (size < th->msize + sizeof (struct SendMessage)) + { + trigger_next_request (h, GNUNET_NO); + return 0; + } + GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); + th->peer = NULL; + if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task) + { + GNUNET_SCHEDULER_cancel (pr->timeout_task); + pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; + } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Transmitting SEND request to `%s' with %u bytes.\n", + GNUNET_i2s (&pr->peer), (unsigned int) th->msize); + sm = (struct SendMessage *) buf; + sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); + sm->priority = htonl (th->priority); + sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); + sm->peer = pr->peer; + sm->cork = htonl ((uint32_t) th->cork); + sm->reserved = htonl (0); + ret = + th->get_message (th->get_message_cls, + size - sizeof (struct SendMessage), &sm[1]); + + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Transmitting SEND request to `%s' yielded %u bytes.\n", + GNUNET_i2s (&pr->peer), ret); + if (0 == ret) { - GNUNET_assert (pr->pending_head != NULL); - th = pr->pending_head; - if (size < th->msize + sizeof (struct SendMessage)) - { - trigger_next_request (h, GNUNET_NO); - return 0; - } - GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); - GNUNET_CONTAINER_DLL_remove (pr->pending_head, pr->pending_tail, th); - pr->queue_size--; - if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (pr->timeout_task); - pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; - } - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting SEND request to `%s' with %u bytes.\n", - GNUNET_i2s (&pr->peer), (unsigned int) th->msize); - sm = (struct SendMessage *) buf; - sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); - sm->priority = htonl (th->priority); - sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); - sm->peer = pr->peer; - sm->cork = htonl ((uint32_t) th->cork); - sm->reserved = htonl (0); - ret = - th->get_message (th->get_message_cls, - size - sizeof (struct SendMessage), &sm[1]); - - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting SEND request to `%s' yielded %u bytes.\n", - GNUNET_i2s (&pr->peer), ret); - GNUNET_free (th); - if (0 == ret) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Size of clients message to peer %s is 0!\n", - GNUNET_i2s (&pr->peer)); - /* client decided to send nothing! */ - request_next_transmission (pr); - return 0; - } LOG (GNUNET_ERROR_TYPE_DEBUG, - "Produced SEND message to core with %u bytes payload\n", - (unsigned int) ret); - GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader)); - if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) - { - GNUNET_break (0); - request_next_transmission (pr); - return 0; - } - ret += sizeof (struct SendMessage); - sm->header.size = htons (ret); - GNUNET_assert (ret <= size); + "Size of clients message to peer %s is 0!\n", + GNUNET_i2s (&pr->peer)); + /* client decided to send nothing! */ request_next_transmission (pr); - return ret; + return 0; } - return 0; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Produced SEND message to core with %u bytes payload\n", + (unsigned int) ret); + GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader)); + if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) + { + GNUNET_break (0); + request_next_transmission (pr); + return 0; + } + ret += sizeof (struct SendMessage); + sm->header.size = htons (ret); + GNUNET_assert (ret <= size); + request_next_transmission (pr); + return ret; } @@ -732,13 +702,13 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down) LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n"); return; } - if (h->control_pending_head != NULL) + if (NULL != h->control_pending_head) msize = ntohs (((struct GNUNET_MessageHeader *) &h-> control_pending_head[1])->size); else if (h->ready_peer_head != NULL) msize = - h->ready_peer_head->pending_head->msize + sizeof (struct SendMessage); + h->ready_peer_head->th.msize + sizeof (struct SendMessage); else { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -782,8 +752,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) if (NULL == msg) { LOG (GNUNET_ERROR_TYPE_INFO, - _ - ("Client was disconnected from core service, trying to reconnect.\n")); + _("Client was disconnected from core service, trying to reconnect.\n")); reconnect_later (h); return; } @@ -951,9 +920,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) continue; if ((mh->expected_size != ntohs (em->size)) && (mh->expected_size != 0)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected message size %u for message of type %u from peer `%4s'\n", - htons (em->size), mh->type, GNUNET_i2s (&ntm->peer)); + LOG (GNUNET_ERROR_TYPE_ERROR, + "Unexpected message size %u for message of type %u from peer `%4s'\n", + htons (em->size), mh->type, GNUNET_i2s (&ntm->peer)); GNUNET_break_op (0); continue; } @@ -1032,14 +1001,14 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) LOG (GNUNET_ERROR_TYPE_DEBUG, "Received notification about transmission readiness to `%s'.\n", GNUNET_i2s (&smr->peer)); - if (NULL == pr->pending_head) + if (NULL == pr->th.peer) { /* request must have been cancelled between the original request * and the response from core, ignore core's readiness */ break; } - th = pr->pending_head; + th = &pr->th; if (ntohs (smr->smr_id) != th->smr_id) { /* READY message is for expired or cancelled message, @@ -1158,7 +1127,6 @@ reconnect (struct GNUNET_CORE_Handle *h) * complete (or fail) asynchronously. * * @param cfg configuration to use - * @param queue_size size of the per-peer message queue * @param cls closure for the various callbacks that follow (including handlers in the handlers array) * @param init callback to call once we have successfully * connected to the core service @@ -1178,7 +1146,7 @@ reconnect (struct GNUNET_CORE_Handle *h) */ struct GNUNET_CORE_Handle * GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - unsigned int queue_size, void *cls, + void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, @@ -1192,7 +1160,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle)); h->cfg = cfg; - h->queue_size = queue_size; h->cls = cls; h->init = init; h->connects = connects; @@ -1204,8 +1171,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h->handlers = handlers; h->hcnt = 0; h->currently_down = GNUNET_YES; - h->peers = GNUNET_CONTAINER_multihashmap_create (128); - h->retry_backoff = GNUNET_TIME_UNIT_MILLISECONDS; + h->peers = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); if (NULL != handlers) while (handlers[h->hcnt].callback != NULL) h->hcnt++; @@ -1285,9 +1251,13 @@ run_request_next_transmission (void *cls, /** * Ask the core to call "notify" once it is ready to transmit the - * given number of bytes to the specified "target". Must only be + * given number of bytes to the specified "target". Must only be * called after a connection to the respective peer has been - * established (and the client has been informed about this). + * established (and the client has been informed about this). You may + * have one request of this type pending for each connected peer at + * any time. If a peer disconnects, the application MUST call + * "GNUNET_CORE_notify_transmit_ready_cancel" on the respective + * transmission request, if one such request is pending. * * @param handle connection to core service * @param cork is corking allowed for this transmission? @@ -1295,11 +1265,14 @@ run_request_next_transmission (void *cls, * @param maxdelay how long can the message wait? * @param target who should receive the message, never NULL (can be this peer's identity for loopback) * @param notify_size how many bytes of buffer space does notify want? - * @param notify function to call when buffer space is available + * @param notify function to call when buffer space is available; + * will be called with NULL on timeout; clients MUST cancel + * all pending transmission requests DURING the disconnect + * handler * @param notify_cls closure for notify * @return non-NULL if the notify callback was queued, - * NULL if we can not even queue the request (insufficient - * memory); if NULL is returned, "notify" will NOT be called. + * NULL if we can not even queue the request (request already pending); + * if NULL is returned, "notify" will NOT be called. */ struct GNUNET_CORE_TransmitHandle * GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, @@ -1312,89 +1285,45 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, { struct PeerRecord *pr; struct GNUNET_CORE_TransmitHandle *th; - struct GNUNET_CORE_TransmitHandle *pos; - struct GNUNET_CORE_TransmitHandle *prev; - struct GNUNET_CORE_TransmitHandle *minp; + if (notify_size > GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) + { + GNUNET_break (0); + return NULL; + } + GNUNET_assert (NULL != notify); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Asking core for transmission of %u bytes to `%s'\n", + (unsigned int) notify_size, + GNUNET_i2s (target)); pr = GNUNET_CONTAINER_multihashmap_get (handle->peers, &target->hashPubKey); if (NULL == pr) { /* attempt to send to peer that is not connected */ - LOG (GNUNET_ERROR_TYPE_WARNING, - "Attempting to send to peer `%s' from peer `%s', but not connected!\n", - GNUNET_i2s (target), GNUNET_h2s (&handle->me.hashPubKey)); + GNUNET_break (0); + return NULL; + } + if (NULL != pr->th.peer) + { + /* attempting to queue a second request for the same destination */ GNUNET_break (0); return NULL; } GNUNET_assert (notify_size + sizeof (struct SendMessage) < GNUNET_SERVER_MAX_MESSAGE_SIZE); - th = GNUNET_malloc (sizeof (struct GNUNET_CORE_TransmitHandle)); + th = &pr->th; + memset (th, 0, sizeof (struct GNUNET_CORE_TransmitHandle)); th->peer = pr; - GNUNET_assert (NULL != notify); th->get_message = notify; th->get_message_cls = notify_cls; th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); th->priority = priority; th->msize = notify_size; th->cork = cork; - /* bound queue size */ - if (pr->queue_size == handle->queue_size) - { - /* find lowest-priority entry, but skip the head of the list */ - minp = pr->pending_head->next; - prev = minp; - while (prev != NULL) - { - if (prev->priority < minp->priority) - minp = prev; - prev = prev->next; - } - if (minp == NULL) - { - GNUNET_break (handle->queue_size != 0); - GNUNET_break (pr->queue_size == 1); - GNUNET_free (th); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Dropping transmission request: cannot drop queue head and limit is one\n"); - return NULL; - } - if (priority <= minp->priority) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Dropping transmission request: priority too low\n"); - GNUNET_free (th); - return NULL; /* priority too low */ - } - GNUNET_CONTAINER_DLL_remove (pr->pending_head, pr->pending_tail, minp); - pr->queue_size--; - GNUNET_assert (0 == minp->get_message (minp->get_message_cls, 0, NULL)); - GNUNET_free (minp); - } - - /* Order entries by deadline, but SKIP 'HEAD' (as we may have transmitted - * that request already or might even already be approved to transmit that - * message to core) */ - pos = pr->pending_head; - if (pos != NULL) - pos = pos->next; /* skip head */ - - /* insertion sort */ - prev = pos; - while ((NULL != pos) && (pos->timeout.abs_value < th->timeout.abs_value)) - { - prev = pos; - pos = pos->next; - } - GNUNET_CONTAINER_DLL_insert_after (pr->pending_head, pr->pending_tail, prev, - th); - pr->queue_size++; - /* was the request queue previously empty? */ + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task); + pr->ntr_task = + GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr); LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n"); - if ((pr->pending_head == th) && (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK) && - (pr->next == NULL) && (pr->prev == NULL) && - (handle->ready_peer_head != pr)) - pr->ntr_task = - GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr); return th; } @@ -1408,33 +1337,61 @@ void GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle *th) { struct PeerRecord *pr = th->peer; - struct GNUNET_CORE_Handle *h = pr->ch; - int was_head; + struct GNUNET_CORE_Handle *h; - was_head = (pr->pending_head == th); - GNUNET_CONTAINER_DLL_remove (pr->pending_head, pr->pending_tail, th); - pr->queue_size--; + GNUNET_assert (NULL != pr); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Aborting transmission request to core for %u bytes to `%s'\n", + (unsigned int) th->msize, + GNUNET_i2s (&pr->peer)); + th->peer = NULL; + h = pr->ch; if (NULL != th->cm) { /* we're currently in the control queue, remove */ GNUNET_CONTAINER_DLL_remove (h->control_pending_head, h->control_pending_tail, th->cm); GNUNET_free (th->cm); + th->cm = NULL; } - GNUNET_free (th); - if (was_head) + if ((NULL != pr->prev) || (NULL != pr->next) || (pr == h->ready_peer_head)) { - if ((NULL != pr->prev) || (NULL != pr->next) || (pr == h->ready_peer_head)) - { - /* the request that was 'approved' by core was - * canceled before it could be transmitted; remove - * us from the 'ready' list */ - GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); - } - if (NULL != h->client) - request_next_transmission (pr); + /* the request that was 'approved' by core was + * canceled before it could be transmitted; remove + * us from the 'ready' list */ + GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); + } + if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task) + { + GNUNET_SCHEDULER_cancel (pr->ntr_task); + pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; } } +/** + * Check if the given peer is currently connected. This function is for special + * cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are + * expected to track which peers are connected based on the connect/disconnect + * callbacks from GNUNET_CORE_connect. This function is NOT part of the + * 'versioned', 'official' API. The difference between this function and the + * function GNUNET_CORE_is_peer_connected() is that this one returns + * synchronously after looking in the CORE API cache. The function + * GNUNET_CORE_is_peer_connected() sends a message to the CORE service and hence + * its response is given asynchronously. + * + * @param h the core handle + * @param pid the identity of the peer to check if it has been connected to us + * @return GNUNET_YES if the peer is connected to us; GNUNET_NO if not + */ +int +GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h, + const struct GNUNET_PeerIdentity *pid) +{ + GNUNET_assert (NULL != h); + GNUNET_assert (NULL != pid); + return GNUNET_CONTAINER_multihashmap_contains (h->peers, &pid->hashPubKey); +} + + /* end of core_api.c */ diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c index 4fe0a4f..17b8404 100644 --- a/src/core/gnunet-core.c +++ b/src/core/gnunet-core.c @@ -32,6 +32,38 @@ #include "gnunet_core_service.h" #include "gnunet_program_lib.h" +/** + * Option -m. + */ +static int monitor_connections; + +/** + * Current number of connections in monitor mode + */ +static int monitor_connections_counter; + +static struct GNUNET_CORE_Handle *ch; + +static struct GNUNET_PeerIdentity my_id; + +/** + * Task run in monitor mode when the user presses CTRL-C to abort. + * Stops monitoring activity. + * + * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *' + * @param tc scheduler context + */ +static void +shutdown_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + if (NULL != ch) + { + GNUNET_CORE_disconnect (ch); + ch = NULL; + } +} + /** * Callback for retrieving a list of connected peers. @@ -54,6 +86,73 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer, printf (_("Peer `%s'\n"), (const char *) &enc); } +void +monitor_notify_startup (void *cls, + struct GNUNET_CORE_Handle * server, + const struct GNUNET_PeerIdentity * + my_identity) +{ + my_id = (*my_identity); +} + + +/** + * Function called to notify core users that another + * peer connected to us. + * + * @param cls closure + * @param peer the peer that connected + * @param ats performance data + * @param ats_count number of entries in ats (excluding 0-termination) + */ +static void +monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_ATS_Information *ats, uint32_t ats_count) +{ + struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); + const char *now_str; + + if (0 != memcmp (&my_id, peer, sizeof (my_id))) + { + monitor_connections_counter ++; + now_str = GNUNET_STRINGS_absolute_time_to_string (now); + FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), + now_str, + _("Connected to"), + GNUNET_i2s (peer), + monitor_connections_counter); + } +} + + +/** + * Function called to notify core users that another + * peer disconnected from us. + * + * @param cls closure + * @param peer the peer that disconnected + */ +static void +monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) +{ + struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); + const char *now_str; + + if (0 != memcmp (&my_id, peer, sizeof (my_id))) + { + now_str = GNUNET_STRINGS_absolute_time_to_string (now); + + GNUNET_assert (monitor_connections_counter > 0); + monitor_connections_counter--; + FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), + now_str, + _("Disconnected from"), + GNUNET_i2s (peer), + monitor_connections_counter); + } +} + + /** * Main function that will be run by the scheduler. @@ -67,12 +166,32 @@ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { + static const struct GNUNET_CORE_MessageHandler handlers[] = { + {NULL, 0, 0} + }; if (args[0] != NULL) { FPRINTF (stderr, _("Invalid command line argument `%s'\n"), args[0]); return; } - GNUNET_CORE_iterate_peers (cfg, &connected_peer_callback, NULL); + if (GNUNET_NO == monitor_connections) + GNUNET_CORE_iterate_peers (cfg, &connected_peer_callback, NULL); + else + { + memset(&my_id, '\0', sizeof (my_id)); + ch = GNUNET_CORE_connect (cfg, NULL, + monitor_notify_startup, + monitor_notify_connect, + monitor_notify_disconnect, + NULL, GNUNET_NO, + NULL, GNUNET_NO, + handlers); + + if (NULL == ch) + GNUNET_SCHEDULER_add_now (shutdown_task, NULL); + else + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, NULL); + } } @@ -86,14 +205,29 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *const *argv) { + int res; static const struct GNUNET_GETOPT_CommandLineOption options[] = { + {'m', "monitor", NULL, + gettext_noop ("provide information about all current connections (continuously)"), + 0, &GNUNET_GETOPT_set_one, &monitor_connections}, GNUNET_GETOPT_OPTION_END }; - return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, argv, "gnunet-core", - gettext_noop - ("Print information about connected peers."), - options, &run, NULL)) ? 0 : 1; + + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + return 2; + + + res = GNUNET_PROGRAM_run (argc, argv, "gnunet-core", + gettext_noop + ("Print information about connected peers."), + options, &run, NULL); + + GNUNET_free ((void *) argv); + + if (GNUNET_OK == res) + return 0; + else + return 1; } /* end of gnunet-core.c */ diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 59d9383..095e124 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -48,21 +48,39 @@ const struct GNUNET_CONFIGURATION_Handle *GSC_cfg; */ struct GNUNET_STATISTICS_Handle *GSC_stats; +/** + * Handle to the server of the core service. + */ +static struct GNUNET_SERVER_Handle *GSC_server; + +/** + * Hostkey generation context + */ +static struct GNUNET_CRYPTO_RsaKeyGenerationContext *keygen; + /** * Last task run during shutdown. Disconnects us from * the transport. + * + * @param cls NULL, unused + * @param tc scheduler context, unused */ static void -cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service shutting down.\n"); + if (NULL != keygen) + { + GNUNET_CRYPTO_rsa_key_create_stop (keygen); + keygen = NULL; + } GSC_CLIENTS_done (); GSC_NEIGHBOURS_done (); GSC_SESSIONS_done (); GSC_KX_done (); GSC_TYPEMAP_done (); - if (GSC_stats != NULL) + if (NULL != GSC_stats) { GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO); GSC_stats = NULL; @@ -71,6 +89,42 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } + +/** + * Callback for hostkey read/generation + * + * @param cls NULL + * @param pk the private key + * @param emsg error message + */ +static void +key_generation_cb (void *cls, + struct GNUNET_CRYPTO_RsaPrivateKey *pk, + const char *emsg) +{ + keygen = NULL; + if (NULL == pk) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Failed to read hostkey: %s\n"), + emsg); + GNUNET_SCHEDULER_shutdown (); + return; + } + if ((GNUNET_OK != GSC_KX_init (pk)) || + (GNUNET_OK != GSC_NEIGHBOURS_init ())) + { + GNUNET_SCHEDULER_shutdown (); + return; + } + GSC_SESSIONS_init (); + GSC_CLIENTS_init (GSC_server); + GNUNET_SERVER_resume (GSC_server); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"), + GNUNET_i2s (&GSC_my_identity)); +} + + /** * Initiate core service. * @@ -82,24 +136,36 @@ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { + char *keyfile; + GSC_cfg = c; + GSC_server = server; + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, "GNUNETD", "HOSTKEY", + &keyfile)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _ + ("Core service is lacking HOSTKEY configuration setting. Exiting.\n")); + GNUNET_SCHEDULER_shutdown (); + return; + } GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); + GNUNET_SERVER_suspend (server); GSC_TYPEMAP_init (); - if ((GNUNET_OK != GSC_KX_init ()) || (GNUNET_OK != GSC_NEIGHBOURS_init ())) + keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, &key_generation_cb, NULL); + GNUNET_free (keyfile); + if (NULL == keygen) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Transport service is unable to access hostkey. Exiting.\n")); GNUNET_SCHEDULER_shutdown (); - return; } - GSC_SESSIONS_init (); - GSC_CLIENTS_init (server); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"), - GNUNET_i2s (&GSC_my_identity)); } - /** * The main function for the transport service. * diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index 1076f34..1d299da 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c @@ -239,7 +239,7 @@ send_to_all_clients (const struct GNUNET_PeerIdentity *partner, if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) && (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)) ) continue; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending %u message with %u bytes to client interested in messages of type %u.\n", options, ntohs (msg->size), @@ -298,7 +298,7 @@ handle_client_init (void *cls, struct GNUNET_SERVER_Client *client, c->options = ntohl (im->options); all_client_options |= c->options; c->types = (const uint16_t *) &c[1]; - c->connectmap = GNUNET_CONTAINER_multihashmap_create (16); + c->connectmap = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (c->connectmap, &GSC_my_identity.hashPubKey, @@ -349,7 +349,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, return; } if (c->requests == NULL) - c->requests = GNUNET_CONTAINER_multihashmap_create (16); + c->requests = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client asked for transmission to `%s'\n", GNUNET_i2s (&req->peer)); @@ -512,7 +512,12 @@ client_tokenizer_callback (void *cls, void *client, { struct TokenizerContext *tc = client; struct GSC_ClientActiveRequest *car = tc->car; + char buf[92]; + GNUNET_snprintf (buf, sizeof (buf), + gettext_noop ("# bytes of messages of type %u received"), + (unsigned int) ntohs (message->type)); + GNUNET_STATISTICS_update (GSC_stats, buf, ntohs (message->size), GNUNET_NO); if (0 == memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity))) @@ -559,7 +564,7 @@ client_tokenizer_callback (void *cls, void *client, * @return GNUNET_YES (continue iteration) */ static int -destroy_active_client_request (void *cls, const GNUNET_HashCode * key, +destroy_active_client_request (void *cls, const struct GNUNET_HashCode * key, void *value) { struct GSC_ClientActiveRequest *car = value; @@ -812,13 +817,6 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender, struct NotifyTrafficMessage *ntm; struct GNUNET_ATS_Information *a; - if (0 == options) - { - GNUNET_snprintf (buf, sizeof (buf), - gettext_noop ("# bytes of messages of type %u received"), - (unsigned int) ntohs (msg->type)); - GNUNET_STATISTICS_update (GSC_stats, buf, msize, GNUNET_NO); - } if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -899,8 +897,11 @@ GSC_CLIENTS_done () GNUNET_SERVER_notification_context_destroy (notifier); notifier = NULL; } - GNUNET_SERVER_mst_destroy (client_mst); - client_mst = NULL; + if (NULL != client_mst) + { + GNUNET_SERVER_mst_destroy (client_mst); + client_mst = NULL; + } } /* end of gnunet-service-core_clients.c */ diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 1fce2e5..b2fc2a9 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c @@ -207,7 +207,7 @@ struct EncryptedMessage * (excluding this value itself) will be encrypted and authenticated. * ENCRYPTED_HEADER_SIZE must be set to the offset of the *next* field. */ - GNUNET_HashCode hmac; + struct GNUNET_HashCode hmac; /** * Sequence number, in network byte order. This field @@ -1357,6 +1357,8 @@ send_key (struct GSC_KeyExchangeInfo *kx) return; /* nothing to do */ if (NULL == kx->public_key) { + if (NULL != kx->pitr) + return; /* lookup public key, then try again */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to obtain public key for `%s'\n", @@ -1513,7 +1515,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, { const struct EncryptedMessage *m; struct EncryptedMessage *pt; /* plaintext */ - GNUNET_HashCode ph; + struct GNUNET_HashCode ph; uint32_t snum; struct GNUNET_TIME_Absolute t; struct GNUNET_CRYPTO_AesInitializationVector iv; @@ -1550,10 +1552,10 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, kx->decrypt_key_created); GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number, size - ENCRYPTED_HEADER_SIZE, &ph); - if (0 != memcmp (&ph, &m->hmac, sizeof (GNUNET_HashCode))) + if (0 != memcmp (&ph, &m->hmac, sizeof (struct GNUNET_HashCode))) { /* checksum failed */ - GNUNET_break_op (0); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed checksum validation for a message from `%s'\n", GNUNET_i2s (&kx->peer)); return; } derive_iv (&iv, &kx->decrypt_key, m->iv_seed, &GSC_my_identity); @@ -1623,8 +1625,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, MAX_MESSAGE_AGE.rel_value) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Message received far too old (%llu ms). Content ignored.\n"), - GNUNET_TIME_absolute_get_duration (t).rel_value); + _("Message received far too old (%s). Content ignored.\n"), + GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (t), GNUNET_YES)); GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# bytes dropped (ancient message)"), size, @@ -1684,30 +1686,13 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m) /** * Initialize KX subsystem. * + * @param pk private key to use for the peer * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GSC_KX_init () +GSC_KX_init (struct GNUNET_CRYPTO_RsaPrivateKey *pk) { - char *keyfile; - - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, "GNUNETD", "HOSTKEY", - &keyfile)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Core service is lacking HOSTKEY configuration setting. Exiting.\n")); - return GNUNET_SYSERR; - } - my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); - GNUNET_free (keyfile); - if (NULL == my_private_key) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Core service could not access hostkey. Exiting.\n")); - return GNUNET_SYSERR; - } + my_private_key = pk; GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &GSC_my_identity.hashPubKey); diff --git a/src/core/gnunet-service-core_kx.h b/src/core/gnunet-service-core_kx.h index 5ecd2c1..fcb561e 100644 --- a/src/core/gnunet-service-core_kx.h +++ b/src/core/gnunet-service-core_kx.h @@ -121,10 +121,11 @@ GSC_KX_stop (struct GSC_KeyExchangeInfo *kx); /** * Initialize KX subsystem. * + * @param pk private key to use for the peer * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GSC_KX_init (void); +GSC_KX_init (struct GNUNET_CRYPTO_RsaPrivateKey *pk); /** diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index 97737a6..aa77fe4 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c @@ -412,6 +412,9 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: GSC_KX_handle_encrypted_message (n->kxinfo, message, atsi, atsi_count); break; + case GNUNET_MESSAGE_TYPE_DUMMY: + /* Dummy messages for testing / benchmarking, just discard */ + break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -461,7 +464,7 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, int GSC_NEIGHBOURS_init () { - neighbours = GNUNET_CONTAINER_multihashmap_create (128); + neighbours = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); transport = GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL, &handle_transport_receive, @@ -486,7 +489,7 @@ GSC_NEIGHBOURS_init () * @return GNUNET_OK (continue to iterate) */ static int -free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value) +free_neighbour_helper (void *cls, const struct GNUNET_HashCode * key, void *value) { struct Neighbour *n = value; @@ -503,14 +506,18 @@ free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value) void GSC_NEIGHBOURS_done () { - if (NULL == transport) - return; - GNUNET_TRANSPORT_disconnect (transport); - transport = NULL; - GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper, - NULL); - GNUNET_CONTAINER_multihashmap_destroy (neighbours); - neighbours = NULL; + if (NULL != transport) + { + GNUNET_TRANSPORT_disconnect (transport); + transport = NULL; + } + if (NULL != neighbours) + { + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper, + NULL); + GNUNET_CONTAINER_multihashmap_destroy (neighbours); + neighbours = NULL; + } } /* end of gnunet-service-core_neighbours.c */ diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 054ad97..3a603bc 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c @@ -283,7 +283,7 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer, * @return GNUNET_OK (continue to iterate) */ static int -notify_client_about_session (void *cls, const GNUNET_HashCode * key, +notify_client_about_session (void *cls, const struct GNUNET_HashCode * key, void *value) { struct GSC_Client *client = cls; @@ -549,7 +549,7 @@ try_transmission (struct Session *session) * @return always GNUNET_OK */ static int -do_send_message (void *cls, const GNUNET_HashCode * key, void *value) +do_send_message (void *cls, const struct GNUNET_HashCode * key, void *value) { const struct GNUNET_MessageHeader *hdr = cls; struct Session *session = value; @@ -642,7 +642,7 @@ GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car, */ #include "core.h" static int -queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value) +queue_connect_message (void *cls, const struct GNUNET_HashCode * key, void *value) { struct GNUNET_SERVER_TransmitContext *tc = cls; struct Session *session = value; @@ -782,7 +782,7 @@ GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer, void GSC_SESSIONS_init () { - sessions = GNUNET_CONTAINER_multihashmap_create (128); + sessions = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); } @@ -795,7 +795,7 @@ GSC_SESSIONS_init () * @return GNUNET_OK (continue to iterate) */ static int -free_session_helper (void *cls, const GNUNET_HashCode * key, void *value) +free_session_helper (void *cls, const struct GNUNET_HashCode * key, void *value) { struct Session *session = value; @@ -810,9 +810,12 @@ free_session_helper (void *cls, const GNUNET_HashCode * key, void *value) void GSC_SESSIONS_done () { - GNUNET_CONTAINER_multihashmap_iterate (sessions, &free_session_helper, NULL); - GNUNET_CONTAINER_multihashmap_destroy (sessions); - sessions = NULL; + if (NULL != sessions) + { + GNUNET_CONTAINER_multihashmap_iterate (sessions, &free_session_helper, NULL); + GNUNET_CONTAINER_multihashmap_destroy (sessions); + sessions = NULL; + } } /* end of gnunet-service-core_sessions.c */ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 37d1669..ab96fb4 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -31,10 +31,6 @@ #include "gnunet_scheduler_lib.h" #include "gnunet_transport_service.h" -#define VERBOSE GNUNET_NO - -#define START_ARM GNUNET_YES - #define MTYPE 12345 struct PeerContext @@ -46,9 +42,7 @@ struct PeerContext struct GNUNET_TRANSPORT_GetHelloHandle *ghh; struct GNUNET_MessageHeader *hello; int connect_status; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; static struct PeerContext p1; @@ -61,11 +55,7 @@ static GNUNET_SCHEDULER_TaskIdentifier con_task; static int ok; -#if VERBOSE #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) -#else -#define OKPP do { ok++; } while (0) -#endif static void @@ -111,9 +101,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - FPRINTF (stderr, "ENDING ANGRILY %u\n", ok); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "ENDING ANGRILY %u\n", ok); GNUNET_break (0); if (NULL != p1.ch) { @@ -278,7 +267,7 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking transport (1) to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); + GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ } @@ -299,7 +288,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -316,20 +305,21 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, + binary, + "gnunet-service-arm", "-c", cfgname, NULL); -#endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } @@ -346,7 +336,7 @@ run (void *cls, char *const *args, const char *cfgfile, (GNUNET_TIME_UNIT_SECONDS, 300), &terminate_task_error, NULL); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -355,7 +345,6 @@ run (void *cls, char *const *args, const char *cfgfile, static void stop_arm (struct PeerContext *p) { -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -364,19 +353,16 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } + static int check () { char *const argv[] = { "test-core-api", "-c", "test_core_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -396,11 +382,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test-core-api", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); diff --git a/src/core/test_core_api_data.conf b/src/core/test_core_api_data.conf index 30eea2d..440dac5 100644 --- a/src/core/test_core_api_data.conf +++ b/src/core/test_core_api_data.conf @@ -1,6 +1,5 @@ @INLINE@ test_core_defaults.conf [PATHS] -DEFAULTCONFIG = test_core_api_data.conf [arm] DEFAULTSERVICES = topology hostlist diff --git a/src/core/test_core_api_peer1.conf b/src/core/test_core_api_peer1.conf index 662318a..119354c 100644 --- a/src/core/test_core_api_peer1.conf +++ b/src/core/test_core_api_peer1.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-peer-1/ -DEFAULTCONFIG = test_core_api_peer1.conf [transport-tcp] PORT = 12468 diff --git a/src/core/test_core_api_peer2.conf b/src/core/test_core_api_peer2.conf index cd29e3f..e66c74c 100644 --- a/src/core/test_core_api_peer2.conf +++ b/src/core/test_core_api_peer2.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-peer-2/ -DEFAULTCONFIG = test_core_api_peer2.conf [arm] PORT = 22460 @@ -38,4 +37,4 @@ PORT = 22467 PORT = 22468 [transport-http] -PORT = 22469
\ No newline at end of file +PORT = 22469 diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index e18d8c4..061158d 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -33,8 +33,6 @@ #include "gnunet_transport_service.h" #include <gauger.h> -#define START_ARM GNUNET_YES - /** * Note that this value must not significantly exceed * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise @@ -73,9 +71,7 @@ struct PeerContext struct GNUNET_MessageHeader *hello; struct GNUNET_TRANSPORT_GetHelloHandle *ghh; int connect_status; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; static struct PeerContext p1; @@ -121,8 +117,10 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); GNUNET_CORE_disconnect (p1.ch); p1.ch = NULL; + GNUNET_free_non_null (p1.hello); GNUNET_CORE_disconnect (p2.ch); p2.ch = NULL; + GNUNET_free_non_null (p2.hello); if (connect_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (connect_task); GNUNET_TRANSPORT_disconnect (p1.th); @@ -176,7 +174,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, NULL); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); + GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ } @@ -384,7 +382,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -409,8 +407,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received (my) `%s' from transport service\n", "HELLO"); GNUNET_assert (message != NULL); - p->hello = GNUNET_malloc (ntohs (message->size)); - memcpy (p->hello, message, ntohs (message->size)); + p->hello = GNUNET_copy_message (message); if ((p == &p1) && (p2.th != NULL)) GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); if ((p == &p2) && (p1.th != NULL)) @@ -426,17 +423,19 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); -#endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } @@ -450,7 +449,7 @@ run (void *cls, char *const *args, const char *cfgfile, setup_peer (&p2, "test_core_api_peer2.conf"); err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -459,7 +458,6 @@ run (void *cls, char *const *args, const char *cfgfile, static void stop_arm (struct PeerContext *p) { -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -468,7 +466,6 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c index b1340dc..c56e227 100644 --- a/src/core/test_core_api_send_to_self.c +++ b/src/core/test_core_api_send_to_self.c @@ -23,12 +23,12 @@ * @brief * @author Philipp Toelke */ -#include <platform.h> -#include <gnunet_common.h> -#include <gnunet_program_lib.h> -#include <gnunet_protocols.h> -#include <gnunet_core_service.h> -#include <gnunet_constants.h> +#include "platform.h" +#include "gnunet_util_lib.h" +#include "gnunet_testing_lib.h" +#include "gnunet_protocols.h" +#include "gnunet_core_service.h" +#include "gnunet_constants.h" /** * Final status code. @@ -40,22 +40,16 @@ static int ret; */ GNUNET_SCHEDULER_TaskIdentifier die_task; -static struct GNUNET_PeerIdentity myself; - /** - * Configuration to load for the new peer. + * Identity of this peer. */ -struct GNUNET_CONFIGURATION_Handle *core_cfg; +static struct GNUNET_PeerIdentity myself; /** * The handle to core */ struct GNUNET_CORE_Handle *core; -/** - * Handle to gnunet-service-arm. - */ -struct GNUNET_OS_Process *arm_proc; /** * Function scheduled as very last function, cleans up after us @@ -71,22 +65,10 @@ cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tskctx) GNUNET_CORE_disconnect (core); core = NULL; } - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer\n"); - if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM)) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - - if (GNUNET_OS_process_wait (arm_proc) != GNUNET_OK) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", - GNUNET_OS_process_get_pid (arm_proc)); - GNUNET_OS_process_destroy (arm_proc); - arm_proc = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n"); } + static int receive (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, @@ -96,11 +78,14 @@ receive (void *cls, const struct GNUNET_PeerIdentity *other, GNUNET_SCHEDULER_cancel (die_task); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message from peer %s\n", GNUNET_i2s (other)); + GNUNET_assert (GNUNET_MESSAGE_TYPE_DUMMY == ntohs (message->type)); + GNUNET_assert (0 == memcmp (other, &myself, sizeof (myself))); GNUNET_SCHEDULER_add_now (&cleanup, NULL); ret = 0; return GNUNET_OK; } + static size_t send_message (void *cls, size_t size, void *buf) { @@ -117,6 +102,7 @@ send_message (void *cls, size_t size, void *buf) return ntohs (hdr->size); } + static void init (void *cls, struct GNUNET_CORE_Handle *core, const struct GNUNET_PeerIdentity *my_identity) @@ -132,6 +118,7 @@ init (void *cls, struct GNUNET_CORE_Handle *core, memcpy (&myself, my_identity, sizeof (struct GNUNET_PeerIdentity)); } + static void connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) @@ -154,71 +141,29 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, * Main function that will be run by the scheduler. * * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void -run (void *cls, char *const *args, const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_TESTING_Peer *peer) { const static struct GNUNET_CORE_MessageHandler handlers[] = { {&receive, GNUNET_MESSAGE_TYPE_DUMMY, 0}, {NULL, 0, 0} }; - - core_cfg = GNUNET_CONFIGURATION_create (); - - arm_proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", "test_core_api_peer1.conf", NULL); - - GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_load (core_cfg, - "test_core_api_peer1.conf")); - core = - GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL, - 0, NULL, 0, handlers); - + GNUNET_CORE_connect (cfg, NULL, &init, &connect_cb, NULL, NULL, + 0, NULL, 0, handlers); die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300), &cleanup, - cls); + NULL); } -static int -check () -{ - char *const argv[] = { "test-core-api-send-to-self", - "-c", - "test_core_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif - NULL - }; - - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - - ret = 1; - - return (GNUNET_OK == - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "test_core_api_send_to_self", - gettext_noop ("help text"), options, &run, - NULL)) ? ret : 1; -} - /** - * The main function to obtain template from gnunetd. + * The main function to test sending a message to the local peer via core * * @param argc number of arguments from the command line * @param argv command line arguments @@ -227,15 +172,10 @@ check () int main (int argc, char *argv[]) { - GNUNET_log_setup ("test-core-api-send-to-self", -#if VERBOSE - "DEBUG", -#else - "WARNING", -#endif - NULL); - ret = check (); - GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); + if (0 != GNUNET_TESTING_peer_run ("test-core-api-send-to-self", + "test_core_api_peer1.conf", + &run, NULL)) + return 1; return ret; } diff --git a/src/core/test_core_api_send_to_self.conf b/src/core/test_core_api_send_to_self.conf index 6737726..704a2b6 100644 --- a/src/core/test_core_api_send_to_self.conf +++ b/src/core/test_core_api_send_to_self.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = ~/.gnunet/ -DEFAULTCONFIG = test_core_api_send_to_self.conf [arm] PORT = 2425 @@ -22,7 +21,6 @@ AUTOSTART = YES PORT = 9252 HOSTNAME = localhost HOME = $SERVICEHOME -CONFIG = $DEFAULTCONFIG BINARY = test_core_api_send_to_self ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 8c81320..d9cb415 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -31,12 +31,8 @@ #include "gnunet_program_lib.h" #include "gnunet_scheduler_lib.h" -#define VERBOSE GNUNET_NO - #define TIMEOUT 5 -#define START_ARM GNUNET_YES - #define MTYPE 12345 struct PeerContext @@ -44,9 +40,7 @@ struct PeerContext struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CORE_Handle *ch; struct GNUNET_PeerIdentity id; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; static struct PeerContext p1; @@ -115,8 +109,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } - - static void init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity) @@ -129,7 +121,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, { /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -145,17 +137,18 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", cfgname, NULL); -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, + binary, + "gnunet-service-arm", + "-c", cfgname, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_free (binary); } @@ -177,7 +170,6 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } - static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -191,7 +183,7 @@ run (void *cls, char *const *args, const char *cfgfile, (GNUNET_TIME_UNIT_MINUTES, TIMEOUT), &timeout_task, NULL); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -201,7 +193,6 @@ static void stop_arm (struct PeerContext *p) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer\n"); -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -210,7 +201,6 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } @@ -221,9 +211,6 @@ check () char *const argv[] = { "test-core-api-start-only", "-c", "test_core_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -241,17 +228,14 @@ check () return ok; } + int main (int argc, char *argv[]) { int ret; GNUNET_log_setup ("test-core-api-start-only", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); diff --git a/src/core/test_core_defaults.conf b/src/core/test_core_defaults.conf index 9525ca2..4110186 100644 --- a/src/core/test_core_defaults.conf +++ b/src/core/test_core_defaults.conf @@ -1,6 +1,5 @@ [PATHS] SERVICEHOME = /tmp/test-gnunet-core/ -DEFAULTCONFIG = test_core_defaults.conf [arm] DEFAULTSERVICES = @@ -63,3 +62,6 @@ AUTOSTART = NO [lockmanager] AUTOSTART = NO + +[consensus] +AUTOSTART = NO diff --git a/src/core/test_core_quota_asymmetric_recv_limited_peer1.conf b/src/core/test_core_quota_asymmetric_recv_limited_peer1.conf index 5501fb8..af5453f 100644 --- a/src/core/test_core_quota_asymmetric_recv_limited_peer1.conf +++ b/src/core/test_core_quota_asymmetric_recv_limited_peer1.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-asym-recv-lim-peer-1/ -DEFAULTCONFIG = test_core_quota_asymmetric_recv_limited_peer1.conf [transport-tcp] PORT = 12488 @@ -29,11 +28,24 @@ UNIXPATH = /tmp/gnunet-core-asym-recv-p1-service-transport.sock [ats] PORT = 12491 UNIXPATH = /tmp/gnunet-core-asym-recv-p1-service-ats.sock +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 1 MB +UNSPECIFIED_QUOTA_OUT = 1 MB +# LOOPBACK +LOOPBACK_QUOTA_IN = 1 MB +LOOPBACK_QUOTA_OUT = 1 MB +# LAN +LAN_QUOTA_IN = 1 MB +LAN_QUOTA_OUT = 1 MB +# WAN WAN_QUOTA_IN = 1 MB WAN_QUOTA_OUT = 1 MB +# WLAN +WLAN_QUOTA_IN = 1 MB +WLAN_QUOTA_OUT = 1 MB + [core] PORT = 12490 UNIXPATH = /tmp/gnunet-core-asym-recv-p1-service-core.sock -DEBUG = NO diff --git a/src/core/test_core_quota_asymmetric_recv_limited_peer2.conf b/src/core/test_core_quota_asymmetric_recv_limited_peer2.conf index 62fc69e..e3ae70e 100644 --- a/src/core/test_core_quota_asymmetric_recv_limited_peer2.conf +++ b/src/core/test_core_quota_asymmetric_recv_limited_peer2.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-asym-recv-lim-peer-2/ -DEFAULTCONFIG = test_core_quota_asymmetric_recv_limited_peer2.conf [arm] @@ -27,13 +26,25 @@ UNIXPATH = /tmp/gnunet-core-asym-recv-p2-service-transport.sock [core] PORT = 22490 UNIXPATH = /tmp/gnunet-core-asym-recv-p2-service-core.sock -DEBUG = NO [ats] PORT = 22491 UNIXPATH = /tmp/gnunet-core-asym-recv-p2-service-ats.sock -WAN_QUOTA_IN = 10 kiB -WAN_QUOTA_OUT = 10 kiB +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 10240 +UNSPECIFIED_QUOTA_OUT = 10240 +# LOOPBACK +LOOPBACK_QUOTA_IN = 10240 +LOOPBACK_QUOTA_OUT = 10240 +# LAN +LAN_QUOTA_IN = 10240 +LAN_QUOTA_OUT = 10240 +# WAN +WAN_QUOTA_IN = 10240 +WAN_QUOTA_OUT = 10240 +# WLAN +WLAN_QUOTA_IN = 10240 +WLAN_QUOTA_OUT = 10240 [transport-tcp] PORT = 22467 @@ -42,4 +53,4 @@ PORT = 22467 PORT = 22468 [transport-http] -PORT = 22469
\ No newline at end of file +PORT = 22469 diff --git a/src/core/test_core_quota_asymmetric_send_limit_peer1.conf b/src/core/test_core_quota_asymmetric_send_limit_peer1.conf index 568cf6b..89cdc15 100644 --- a/src/core/test_core_quota_asymmetric_send_limit_peer1.conf +++ b/src/core/test_core_quota_asymmetric_send_limit_peer1.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-asym-send-lim-peer-1/ -DEFAULTCONFIG = test_core_quota_asymmetric_send_limit_peer1.conf [transport-tcp] PORT = 12488 @@ -27,12 +26,24 @@ PORT = 12485 UNIXPATH = /tmp/gnunet-core-asym-send-p1-service-transport.sock [ats] -WAN_QUOTA_IN = 10240 -WAN_QUOTA_OUT = 10240 PORT = 12491 UNIXPATH = /tmp/gnunet-core-asym-send-p1-service-ats.sock +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 10240 +UNSPECIFIED_QUOTA_OUT = 10240 +# LOOPBACK +LOOPBACK_QUOTA_IN = 10240 +LOOPBACK_QUOTA_OUT = 10240 +# LAN +LAN_QUOTA_IN = 10240 +LAN_QUOTA_OUT = 10240 +# WAN +WAN_QUOTA_IN = 10240 +WAN_QUOTA_OUT = 10240 +# WLAN +WLAN_QUOTA_IN = 10240 +WLAN_QUOTA_OUT = 10240 [core] PORT = 12490 UNIXPATH = /tmp/gnunet-core-asym-send-p1-service-core.sock -DEBUG = NO diff --git a/src/core/test_core_quota_asymmetric_send_limit_peer2.conf b/src/core/test_core_quota_asymmetric_send_limit_peer2.conf index 614358b..0707ac1 100644 --- a/src/core/test_core_quota_asymmetric_send_limit_peer2.conf +++ b/src/core/test_core_quota_asymmetric_send_limit_peer2.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-asym-send-lim-peer-2/ -DEFAULTCONFIG = test_core_quota_asymmetric_send_limit_peer2.conf [arm] PORT = 22486 @@ -26,7 +25,6 @@ UNIXPATH = /tmp/gnunet-core-asym-send-p2-service-transport.sock [core] PORT = 22490 UNIXPATH = /tmp/gnunet-core-asym-send-p2-service-core.sock -DEBUG = NO [ats] PORT = 22491 @@ -34,6 +32,25 @@ UNIXPATH = /tmp/gnunet-core-asym-send-p2-service-ats.sock WAN_QUOTA_IN = 1 MB WAN_QUOTA_OUT = 1 MB +[ats] +PORT = 12471 +UNIXPATH = /tmp/gnunet-core-sym-p1-service-ats.sock +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 1 MB +UNSPECIFIED_QUOTA_OUT = 1 MB +# LOOPBACK +LOOPBACK_QUOTA_IN = 1 MB +LOOPBACK_QUOTA_OUT = 1 MB +# LAN +LAN_QUOTA_IN = 1 MB +LAN_QUOTA_OUT = 1 MB +# WAN +WAN_QUOTA_IN = 1 MB +WAN_QUOTA_OUT = 1 MB +# WLAN +WLAN_QUOTA_IN = 1 MB +WLAN_QUOTA_OUT = 1 MB + [transport-tcp] PORT = 22467 @@ -41,4 +58,4 @@ PORT = 22467 PORT = 22468 [transport-http] -PORT = 22469
\ No newline at end of file +PORT = 22469 diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index df602b3..884d5fa 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -38,8 +38,6 @@ #define ASYMMETRIC_SEND_LIMITED 1 #define ASYMMETRIC_RECV_LIMITED 2 -#define START_ARM GNUNET_YES - /** * Note that this value must not significantly exceed * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise @@ -84,9 +82,7 @@ struct PeerContext struct GNUNET_STATISTICS_Handle *stats; struct GNUNET_TRANSPORT_GetHelloHandle *ghh; int connect_status; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; static struct PeerContext p1; @@ -146,6 +142,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) p1.th = NULL; GNUNET_TRANSPORT_disconnect (p2.th); p2.th = NULL; + GNUNET_free_non_null (p1.hello); + GNUNET_free_non_null (p2.hello); } @@ -191,8 +189,8 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, NULL); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); - GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); + GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ + GNUNET_TRANSPORT_try_connect (p2.th, &p1.id, NULL, NULL); /*FIXME TRY_CONNECT change */ } /** @@ -527,7 +525,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -570,19 +568,21 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); -#endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->stats = GNUNET_STATISTICS_create ("core", p->cfg); GNUNET_assert (p->stats != NULL); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } @@ -629,7 +629,7 @@ run (void *cls, char *const *args, const char *cfgfile, ¤t_quota_p2_out)); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -638,7 +638,6 @@ run (void *cls, char *const *args, const char *cfgfile, static void stop_arm (struct PeerContext *p) { -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -647,7 +646,6 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } diff --git a/src/core/test_core_quota_peer1.conf b/src/core/test_core_quota_peer1.conf index 4ff2ee4..dbe8714 100644 --- a/src/core/test_core_quota_peer1.conf +++ b/src/core/test_core_quota_peer1.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-sym-peer-1/ -DEFAULTCONFIG = test_core_quota_peer1.conf [transport-tcp] PORT = 12468 @@ -27,13 +26,27 @@ PORT = 12475 UNIXPATH = /tmp/gnunet-core-sym-p1-service-transport.sock [ats] +PORT = 12471 +UNIXPATH = /tmp/gnunet-core-sym-p1-service-ats.sock +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 10240 +UNSPECIFIED_QUOTA_OUT = 10240 +# LOOPBACK +LOOPBACK_QUOTA_IN = 10240 +LOOPBACK_QUOTA_OUT = 10240 +# LAN +LAN_QUOTA_IN = 10240 +LAN_QUOTA_OUT = 10240 +# WAN WAN_QUOTA_IN = 10240 WAN_QUOTA_OUT = 10240 +# WLAN +WLAN_QUOTA_IN = 10240 +WLAN_QUOTA_OUT = 10240 [core] PORT = 12480 UNIXPATH = /tmp/gnunet-core-sym-p1-service-core.sock -DEBUG = NO [ats] PORT = 12481 diff --git a/src/core/test_core_quota_peer2.conf b/src/core/test_core_quota_peer2.conf index 1fd4ec8..6dec73a 100644 --- a/src/core/test_core_quota_peer2.conf +++ b/src/core/test_core_quota_peer2.conf @@ -1,7 +1,6 @@ @INLINE@ test_core_defaults.conf [PATHS] SERVICEHOME = /tmp/test-gnunet-core-quota-sym-peer-2/ -DEFAULTCONFIG = test_core_quota_peer2.conf [arm] PORT = 22476 @@ -26,13 +25,25 @@ UNIXPATH = /tmp/gnunet-core-sym-p2-service-transport.sock [core] PORT = 22480 UNIXPATH = /tmp/gnunet-core-sym-p2-service-core.sock -DEBUG = NO [ats] PORT = 22482 UNIXPATH = /tmp/gnunet-core-sym-p2-service-ats.sock -WAN_QUOTA_IN = 10 kiB -WAN_QUOTA_OUT = 10 kiB +# UNSPECIFIED +UNSPECIFIED_QUOTA_IN = 10240 +UNSPECIFIED_QUOTA_OUT = 10240 +# LOOPBACK +LOOPBACK_QUOTA_IN = 10240 +LOOPBACK_QUOTA_OUT = 10240 +# LAN +LAN_QUOTA_IN = 10240 +LAN_QUOTA_OUT = 10240 +# WAN +WAN_QUOTA_IN = 10240 +WAN_QUOTA_OUT = 10240 +# WLAN +WLAN_QUOTA_IN = 10240 +WLAN_QUOTA_OUT = 10240 [transport-tcp] PORT = 22467 @@ -41,4 +52,4 @@ PORT = 22467 PORT = 22468 [transport-http] -PORT = 22469
\ No newline at end of file +PORT = 22469 |