diff options
author | t3sserakt <t3ss@posteo.de> | 2021-10-15 21:02:03 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-10-15 21:02:03 +0200 |
commit | 513f23e74650db9408267e82ef8bcb8f770d1015 (patch) | |
tree | 312db7072dc444e9d1e6a13000b79482eb14de82 | |
parent | d190d23831dae1a77075557f2ff6e0c713d747d5 (diff) | |
parent | d64ac269856744b9bab170964e1d6f36896ecc55 (diff) | |
download | gnunet-513f23e74650db9408267e82ef8bcb8f770d1015.tar.gz gnunet-513f23e74650db9408267e82ef8bcb8f770d1015.zip |
Merge branch 'master' into dev/t3ss/tng
190 files changed, 4443 insertions, 7961 deletions
diff --git a/Makefile.am b/Makefile.am index f072d0cae..9191107d2 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -24,7 +24,8 @@ EXTRA_DIST = \ | |||
24 | ABOUT-NLS \ | 24 | ABOUT-NLS \ |
25 | config.rpath \ | 25 | config.rpath \ |
26 | acinclude.m4 \ | 26 | acinclude.m4 \ |
27 | README.1st | 27 | README.1st \ |
28 | .version | ||
28 | 29 | ||
29 | gnunetincludedir = $(includedir)/gnunet | 30 | gnunetincludedir = $(includedir)/gnunet |
30 | gnunetinclude_HEADERS = gnunet_config.h | 31 | gnunetinclude_HEADERS = gnunet_config.h |
diff --git a/configure.ac b/configure.ac index 770ba499e..8a3574118 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -21,7 +21,7 @@ | |||
21 | # | 21 | # |
22 | AC_PREREQ([2.69]) | 22 | AC_PREREQ([2.69]) |
23 | # Checks for programs. | 23 | # Checks for programs. |
24 | AC_INIT([gnunet],[0.15.4-alpha.0],[bug-gnunet@gnu.org]) | 24 | AC_INIT([gnunet],m4_esyscmd([contrib/get_version.sh]),[bug-gnunet@gnu.org]) |
25 | AC_CONFIG_AUX_DIR([build-aux]) | 25 | AC_CONFIG_AUX_DIR([build-aux]) |
26 | 26 | ||
27 | # check for legacy option that is no longer supported (#5627) and fail hard | 27 | # check for legacy option that is no longer supported (#5627) and fail hard |
@@ -35,7 +35,7 @@ AC_ARG_WITH(nssdir, | |||
35 | 35 | ||
36 | AC_CANONICAL_TARGET | 36 | AC_CANONICAL_TARGET |
37 | AC_CANONICAL_HOST | 37 | AC_CANONICAL_HOST |
38 | AM_INIT_AUTOMAKE | 38 | AM_INIT_AUTOMAKE([1.9 tar-ustar]) |
39 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AM_DEFAULT_VERBOSITY=1 AC_SUBST(AM_DEFAULT_VERBOSITY)]) | 39 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AM_DEFAULT_VERBOSITY=1 AC_SUBST(AM_DEFAULT_VERBOSITY)]) |
40 | AC_CONFIG_HEADERS([gnunet_config.h]) | 40 | AC_CONFIG_HEADERS([gnunet_config.h]) |
41 | AH_TOP([#define _GNU_SOURCE 1]) | 41 | AH_TOP([#define _GNU_SOURCE 1]) |
@@ -1440,8 +1440,7 @@ AC_SUBST(MYSQL_LDFLAGS) | |||
1440 | AC_SUBST(MYSQL_CPPFLAGS) | 1440 | AC_SUBST(MYSQL_CPPFLAGS) |
1441 | 1441 | ||
1442 | # additional version check for mysql | 1442 | # additional version check for mysql |
1443 | AC_ARG_ENABLE(mysql-version-check, [ --disable-mysql-version-check do not check MySQL version],, enable_mysql_version_check=yes) | 1443 | AS_IF([test "$mysql" = "true"], |
1444 | AS_IF([test "$mysql" = "true" -a "x$enable_mysql_version_check" = "xyes"], | ||
1445 | [ | 1444 | [ |
1446 | AC_MSG_CHECKING(mysql version) | 1445 | AC_MSG_CHECKING(mysql version) |
1447 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | 1446 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
@@ -1686,20 +1685,6 @@ AC_DEFINE_UNQUOTED([HAVE_GNUTLS_DANE], $gnutls_dane, [We have GnuTLS with DANE s | |||
1686 | 1685 | ||
1687 | 1686 | ||
1688 | 1687 | ||
1689 | # Test if we are building for superMUC | ||
1690 | AC_MSG_CHECKING(if GNUnet is being configured to run on the SuperMUC) | ||
1691 | AC_ARG_ENABLE([supermuc], | ||
1692 | [AS_HELP_STRING([--enable-supermuc], | ||
1693 | [build GNUnet with support to run on the SuperMUC (default is NO)])], | ||
1694 | [AS_IF([test "x$enable_supermuc" = "xno"], | ||
1695 | [supermuc=0], | ||
1696 | [supermuc=1])], | ||
1697 | [supermuc=0 | ||
1698 | enable_supermuc=no]) | ||
1699 | AC_MSG_RESULT($enable_SUPERMUC) | ||
1700 | AM_CONDITIONAL([ENABLE_SUPERMUC], [test "x$supermuc" = "x1"]) | ||
1701 | AC_DEFINE_UNQUOTED([ENABLE_SUPERMUC], [$supermuc], [Build with support for SuperMUC]) | ||
1702 | |||
1703 | # Check if NSE has to send timestamp information to testbed logger for | 1688 | # Check if NSE has to send timestamp information to testbed logger for |
1704 | # generating histogram of messages received | 1689 | # generating histogram of messages received |
1705 | AC_MSG_CHECKING(if NSE has to send timestamp information to testbed logger) | 1690 | AC_MSG_CHECKING(if NSE has to send timestamp information to testbed logger) |
@@ -1739,15 +1724,6 @@ AS_IF([test "x$enable_benchmark" = "xyes"], | |||
1739 | AM_CONDITIONAL([ENABLE_BENCHMARK], [test "x$enable_benchmark" = "xyes"]) | 1724 | AM_CONDITIONAL([ENABLE_BENCHMARK], [test "x$enable_benchmark" = "xyes"]) |
1740 | 1725 | ||
1741 | 1726 | ||
1742 | # should expensive tests be run? | ||
1743 | AC_MSG_CHECKING(whether to run expensive tests) | ||
1744 | AC_ARG_ENABLE([expensivetests], | ||
1745 | [AS_HELP_STRING([--enable-expensivetests], [enable running expensive testcases])], | ||
1746 | [enable_expensive=${enableval}], | ||
1747 | [enable_expensive=no]) | ||
1748 | AC_MSG_RESULT($enable_expensive) | ||
1749 | AM_CONDITIONAL([HAVE_EXPENSIVE_TESTS], [test "x$enable_expensive" = "xyes"]) | ||
1750 | |||
1751 | # should ports be open for Java services? | 1727 | # should ports be open for Java services? |
1752 | AC_MSG_CHECKING(whether to enable ports for gnunet-java) | 1728 | AC_MSG_CHECKING(whether to enable ports for gnunet-java) |
1753 | AC_ARG_ENABLE([javaports], | 1729 | AC_ARG_ENABLE([javaports], |
@@ -1769,15 +1745,6 @@ AC_ARG_ENABLE([benchmarks], | |||
1769 | AC_MSG_RESULT($enable_benchmarks) | 1745 | AC_MSG_RESULT($enable_benchmarks) |
1770 | AM_CONDITIONAL([HAVE_BENCHMARKS], [test "x$enable_benchmarks" = "xyes"]) | 1746 | AM_CONDITIONAL([HAVE_BENCHMARKS], [test "x$enable_benchmarks" = "xyes"]) |
1771 | 1747 | ||
1772 | # should gnunet-testing be compiled | ||
1773 | AC_MSG_CHECKING(whether to compile gnunet-testing) | ||
1774 | AC_ARG_ENABLE([testing], | ||
1775 | [AS_HELP_STRING([--disable-testing], [do not build gnunet-testing])], | ||
1776 | [enable_testing=${enableval}], | ||
1777 | [enable_testing=yes]) | ||
1778 | AC_MSG_RESULT($enable_testing) | ||
1779 | AM_CONDITIONAL([HAVE_TESTING], [test "x$enable_testing" = "xyes"]) | ||
1780 | |||
1781 | # should experimental code be compiled (code that may not yet compile)? | 1748 | # should experimental code be compiled (code that may not yet compile)? |
1782 | AC_MSG_CHECKING(whether to compile experimental code) | 1749 | AC_MSG_CHECKING(whether to compile experimental code) |
1783 | AC_ARG_ENABLE([experimental], | 1750 | AC_ARG_ENABLE([experimental], |
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 150e47ff0..464016ee8 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -6,69 +6,226 @@ SUBDIRS = scripts hellos services | |||
6 | include Makefile.inc | 6 | include Makefile.inc |
7 | 7 | ||
8 | dist_pkgdata_DATA = \ | 8 | dist_pkgdata_DATA = \ |
9 | gns/gns-bcd.html \ | 9 | gns/gns-form.xslt \ |
10 | gns/gns-bcd.tex \ | 10 | gns/gns-bcd.html \ |
11 | gns/def.tex \ | 11 | gns/def.tex \ |
12 | gns/gns-form-fields.xml \ | 12 | gns/bootstrap.min.css \ |
13 | gns/gns-form.xslt \ | 13 | gns/gns-form-fields.xml \ |
14 | fcfsd/fcfsd-index.html \ | 14 | gns/gns-bcd.tex \ |
15 | fcfsd/fcfsd-notfound.html \ | 15 | fcfsd/fcfsd-index.html \ |
16 | fcfsd/fcfsd-forbidden.html \ | 16 | fcfsd/fcfsd-forbidden.html \ |
17 | branding/logo/gnunet-logo.pdf \ | 17 | fcfsd/fcfsd-notfound.html \ |
18 | branding/logo/gnunet-logo.png \ | 18 | branding/logo/gnunet-logo.png \ |
19 | branding/logo/gnunet-logo-color.png \ | 19 | branding/logo/lynXified-amirouche-v3.svg \ |
20 | testing_hostkeys.ecc \ | 20 | branding/logo/gnunet-logo-dark-text.svg \ |
21 | $(BUILDCOMMON_SHLIB_FILES) | 21 | branding/logo/gnunet-logo-color.png \ |
22 | branding/logo/lynXified-amirouche-anonymous-v3.png \ | ||
23 | branding/logo/gnunet-logo-dark-only-text.svg \ | ||
24 | branding/logo/gnunet-logo-big.png \ | ||
25 | branding/logo/gnunet-logo.pdf \ | ||
26 | testing_hostkeys.ecc \ | ||
27 | $(BUILDCOMMON_SHLIB_FILES) | ||
22 | 28 | ||
23 | INITD_FILES = \ | 29 | INITD_FILES = \ |
24 | services/openrc/gnunet.initd \ | 30 | services/systemd/gnunet-user.service \ |
25 | services/systemd/gnunet.service | 31 | services/systemd/sysusers-gnunet.conf \ |
32 | services/systemd/gnunet.service \ | ||
33 | services/systemd/tmpfiles-gnunet.conf \ | ||
34 | services/openrc/gnunet.initd | ||
26 | 35 | ||
27 | PACKAGES_FILES = \ | 36 | PACKAGES_FILES = \ |
28 | packages/guix/guix-env-py2.scm \ | 37 | packages/guix/guix-env-py2.scm \ |
29 | packages/guix/guix-env-gillmann.scm \ | 38 | packages/guix/guix-env-gillmann.scm \ |
30 | packages/guix/notest-guix-env.scm \ | 39 | packages/guix/notest-guix-env.scm \ |
31 | packages/homebrew/gnunet.rb \ | 40 | packages/alpine/gnunet-gtk/APKBUILD \ |
32 | packages/nix/gnunet-dev.nix \ | 41 | packages/alpine/gnurl/APKBUILD \ |
33 | packages/nix/default.nix \ | 42 | packages/alpine/gnunet/gnunet-user-services.initd \ |
34 | packages/alpine/gnunet-gtk/APKBUILD \ | 43 | packages/alpine/gnunet/gnunet.pre-deinstall \ |
35 | packages/alpine/gnunet/APKBUILD \ | 44 | packages/alpine/gnunet/gnunet-user.conf \ |
36 | packages/alpine/gnunet/gnunet-system-services.initd \ | 45 | packages/alpine/gnunet/gnunet.xsession \ |
37 | packages/alpine/gnunet/gnunet-system.conf \ | 46 | packages/alpine/gnunet/gnunet-system.conf \ |
38 | packages/alpine/gnunet/gnunet-user-services.initd \ | 47 | packages/alpine/gnunet/APKBUILD \ |
39 | packages/alpine/gnunet/gnunet-user.conf \ | 48 | packages/alpine/gnunet/gnunet.post-install \ |
40 | packages/alpine/gnunet/gnunet.post-install \ | 49 | packages/alpine/gnunet/gnunet.pre-install \ |
41 | packages/alpine/gnunet/gnunet.pre-deinstall \ | 50 | packages/alpine/gnunet/gnunet-system-services.initd \ |
42 | packages/alpine/gnunet/gnunet.pre-install \ | 51 | packages/alpine/gnunet/gnunet-gns-proxy.initd \ |
43 | packages/alpine/gnunet/gnunet.xsession \ | 52 | packages/nix/gnunet-dev.nix \ |
44 | packages/alpine/gnurl/APKBUILD | 53 | packages/nix/default.nix \ |
54 | packages/homebrew/gnunet.rb | ||
45 | 55 | ||
46 | EXTRA_DIST = \ | 56 | EXTRA_DIST = \ |
47 | conf/colorit/colorit.conf \ | 57 | sounds/vonlynX-bdbAm-lo.wav \ |
48 | conf/.style.yapf \ | 58 | sounds/vonlynX-bdbG9-lo.wav \ |
49 | conf/editors/eclipse/gnunet_codingstyle.xml \ | 59 | sounds/vonlynX-ringtones.txt \ |
50 | conf/gnunet/no_forcestart.conf \ | 60 | A-Z.ecc \ |
51 | conf/gnunet/no_autostart_above_core.conf \ | 61 | xdg-scheme-handler/gnunet-uri.desktop \ |
52 | conf/gnunet/gnunet-system.conf \ | 62 | xdg-scheme-handler/README.md \ |
53 | conf/gnunet/gnunet-user.conf \ | 63 | apparmor/gnunet-daemon-testbed-blacklist \ |
54 | conf/nss/nssswitch.conf \ | 64 | apparmor/gnunet-service-identity \ |
55 | conf/wireshark/wireshark.lua \ | 65 | apparmor/gnunet-cadet \ |
56 | gnunet.m4 \ | 66 | apparmor/gnunet-service-core \ |
57 | $(PACKAGES_FILES) \ | 67 | apparmor/gnunet-identity \ |
58 | $(INITD_FILES) \ | 68 | apparmor/gnunet-service-cadet \ |
59 | Makefile.inc \ | 69 | apparmor/gnunet-service-dns \ |
60 | $(BUILD_COMMON_FILES) | 70 | apparmor/gnunet-template \ |
71 | apparmor/gnunet-service-peerstore \ | ||
72 | apparmor/gnunet-nse \ | ||
73 | apparmor/gnunet-helper-transport-wlan \ | ||
74 | apparmor/gnunet-service-set \ | ||
75 | apparmor/gnunet-uri \ | ||
76 | apparmor/gnunet-conversation \ | ||
77 | apparmor/usr.bin.gnunet-helper-nat-server \ | ||
78 | apparmor/gnunet-transport \ | ||
79 | apparmor/gnunet-service-nse \ | ||
80 | apparmor/gnunet-transport-certificate-creation \ | ||
81 | apparmor/gnunet-daemon-hostlist \ | ||
82 | apparmor/gnunet-unindex \ | ||
83 | apparmor/gnunet-nat-server \ | ||
84 | apparmor/gnunet-setup \ | ||
85 | apparmor/gnunet-service-testbed \ | ||
86 | apparmor/gnunet-gtk \ | ||
87 | apparmor/gnunet-scalarproduct \ | ||
88 | apparmor/gnunet-statistics \ | ||
89 | apparmor/gnunet-helper-testbed \ | ||
90 | apparmor/gnunet-scrypt \ | ||
91 | apparmor/gnunet-conversation-test \ | ||
92 | apparmor/gnunet-publish \ | ||
93 | apparmor/gnunet-helper-audio-playback \ | ||
94 | apparmor/gnunet-revocation \ | ||
95 | apparmor/gnunet-helper-vpn \ | ||
96 | apparmor/gnunet-auto-share \ | ||
97 | apparmor/gnunet-service-scalarproduct-alice \ | ||
98 | apparmor/gnunet-service-template \ | ||
99 | apparmor/gnunet-arm \ | ||
100 | apparmor/gnunet-search \ | ||
101 | apparmor/gnunet-ecc \ | ||
102 | apparmor/gnunet-download-manager.scm \ | ||
103 | apparmor/gnunet-service-revocation \ | ||
104 | apparmor/gnunet-gns-proxy-setup-ca \ | ||
105 | apparmor/gnunet-service-mesh \ | ||
106 | apparmor/gnunet-helper-transport-wlan-dummy \ | ||
107 | apparmor/gnunet-service-conversation \ | ||
108 | apparmor/gnunet-fs \ | ||
109 | apparmor/gnunet-statistics-gtk \ | ||
110 | apparmor/gnunet-service-regex \ | ||
111 | apparmor/gnunet-helper-transport-bluetooth \ | ||
112 | apparmor/gnunet-service-resolver \ | ||
113 | apparmor/gnunet-service-fs \ | ||
114 | apparmor/gnunet-helper-nat-client \ | ||
115 | apparmor/gnunet-service-arm \ | ||
116 | apparmor/gnunet-peerinfo-gtk \ | ||
117 | apparmor/gnunet-vpn \ | ||
118 | apparmor/gnunet-helper-exit \ | ||
119 | apparmor/gnunet-set-profiler \ | ||
120 | apparmor/gnunet-helper-fs-publish \ | ||
121 | apparmor/gnunet-service-gns \ | ||
122 | apparmor/gnunet-service-datastore \ | ||
123 | apparmor/gnunet-service-namestore \ | ||
124 | apparmor/gnunet-service-dht \ | ||
125 | apparmor/gnunet-config \ | ||
126 | apparmor/gnunet-testbed-profiler \ | ||
127 | apparmor/gnunet-daemon-pt \ | ||
128 | apparmor/gnunet-peerinfo \ | ||
129 | apparmor/gnunet-service-ats \ | ||
130 | apparmor/gnunet-helper-audio-record \ | ||
131 | apparmor/gnunet-directory \ | ||
132 | apparmor/gnunet-download \ | ||
133 | apparmor/gnunet-fs-gtk \ | ||
134 | apparmor/tunables/gnunet \ | ||
135 | apparmor/gnunet-ats \ | ||
136 | apparmor/gnunet-set-ibf-profiler \ | ||
137 | apparmor/gnunet-dns2gns \ | ||
138 | apparmor/gnunet-service-peerinfo \ | ||
139 | apparmor/gnunet-service-namecache \ | ||
140 | apparmor/gnunet-daemon-exit \ | ||
141 | apparmor/gnunet-resolver \ | ||
142 | apparmor/gnunet-bcd \ | ||
143 | apparmor/gnunet-daemon-regexprofiler \ | ||
144 | apparmor/gnunet-namestore \ | ||
145 | apparmor/gnunet-namestore-gtk \ | ||
146 | apparmor/gnunet-service-testbed-logger \ | ||
147 | apparmor/gnunet-peerstore \ | ||
148 | apparmor/gnunet-namestore-fcfsd \ | ||
149 | apparmor/gnunet-core \ | ||
150 | apparmor/gnunet-gns-import.sh \ | ||
151 | apparmor/gnunet-gns-proxy \ | ||
152 | apparmor/gnunet-identity-gtk \ | ||
153 | apparmor/gnunet-service-vpn \ | ||
154 | apparmor/gnunet-daemon-testbed-underlay \ | ||
155 | apparmor/gnunet-qr \ | ||
156 | apparmor/gnunet-datastore \ | ||
157 | apparmor/gnunet-service-statistics \ | ||
158 | apparmor/gnunet-conversation-gtk \ | ||
159 | apparmor/gnunet-daemon-latency-logger \ | ||
160 | apparmor/gnunet-testing \ | ||
161 | apparmor/gnunet-namecache \ | ||
162 | apparmor/gnunet-service-transport \ | ||
163 | apparmor/gnunet-daemon-topology \ | ||
164 | apparmor/gnunet-helper-dns \ | ||
165 | apparmor/gnunet-gns \ | ||
166 | apparmor/gnunet-helper-nat-server \ | ||
167 | apparmor/abstractions/gnunet-test \ | ||
168 | apparmor/abstractions/gnunet-db \ | ||
169 | apparmor/abstractions/gnunet-gtk \ | ||
170 | apparmor/abstractions/gnunet-common \ | ||
171 | apparmor/abstractions/gnunet-suid \ | ||
172 | apparmor/abstractions/gnunet-sgid \ | ||
173 | apparmor/gnunet-service-scalarproduct-bob \ | ||
174 | conf/uncrustify.cfg \ | ||
175 | conf/tox.ini \ | ||
176 | conf/wireshark/wireshark.lua \ | ||
177 | conf/.style.yapf \ | ||
178 | conf/editors/eclipse/gnunet_codingstyle.xml \ | ||
179 | conf/editors/clang-format \ | ||
180 | conf/uncrustify_precommit \ | ||
181 | conf/gnunet/gnunet-user.conf \ | ||
182 | conf/gnunet/no_autostart_above_core.conf \ | ||
183 | conf/gnunet/gnunet-system.conf \ | ||
184 | conf/gnunet/no_forcestart.conf \ | ||
185 | conf/colorit/colorit.conf \ | ||
186 | conf/nss/nssswitch.conf \ | ||
187 | testbed_configs/testbed_cluster.conf \ | ||
188 | testbed_configs/testbed_supermuc.conf \ | ||
189 | guix.README \ | ||
190 | web/log.php \ | ||
191 | ci/docker/docker-entrypoint.sh \ | ||
192 | ci/docker/Dockerfile \ | ||
193 | ci/buildbot/buildbot-update.sh \ | ||
194 | ci/buildbot/ssh-keys \ | ||
195 | ci/buildbot/ssh-config \ | ||
196 | docker/docker-entrypoint.sh \ | ||
197 | docker/Dockerfile \ | ||
198 | docker/README.md \ | ||
199 | docker/gnunet.conf \ | ||
200 | benchmark/collect.awk \ | ||
201 | gnunet_infrastructure/handbook_pull.sh \ | ||
202 | guix.scm \ | ||
203 | indent_pre-commit \ | ||
204 | Makefile.inc \ | ||
205 | gnunet.m4 \ | ||
206 | vagrant/Vagrantfile \ | ||
207 | vagrant/bootstrap.ubuntu.sh \ | ||
208 | privacy-sensitive-symbols.mspec \ | ||
209 | gnunet-arch-full.svg \ | ||
210 | patches/texi2html5-indent.diff \ | ||
211 | patches/transport_ats_years.diff \ | ||
212 | patches/lrn-indent.diff \ | ||
213 | test_gnunet_prefix.c \ | ||
214 | $(PACKAGES_FILES) \ | ||
215 | $(INITD_FILES) \ | ||
216 | $(BUILD_COMMON_FILES) | ||
61 | 217 | ||
62 | check_PROGRAMS = \ | 218 | check_PROGRAMS = \ |
63 | test_gnunet_prefix | 219 | test_gnunet_prefix |
64 | 220 | ||
65 | if ENABLE_TEST_RUN | 221 | if ENABLE_TEST_RUN |
66 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 222 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
67 | TESTS = $(check_PROGRAMS) | 223 | TESTS = \ |
224 | $(check_PROGRAMS) | ||
68 | endif | 225 | endif |
69 | 226 | ||
70 | test_gnunet_prefix_SOURCES = \ | 227 | test_gnunet_prefix_SOURCES = \ |
71 | test_gnunet_prefix.c | 228 | test_gnunet_prefix.c |
72 | 229 | ||
73 | test_gnunet_prefix_CPPFLAGS = \ | 230 | test_gnunet_prefix_CPPFLAGS = \ |
74 | $(LTDLINCL) $(AM_CPPFLAGS) | 231 | $(LTDLINCL) $(AM_CPPFLAGS) |
@@ -80,4 +237,7 @@ test_gnunet_prefix_LDADD = \ | |||
80 | $(LIBLTDL) -lunistring $(XLIB) | 237 | $(LIBLTDL) -lunistring $(XLIB) |
81 | 238 | ||
82 | aclocaldir = $(datadir)/aclocal | 239 | aclocaldir = $(datadir)/aclocal |
83 | aclocal_DATA = gnunet.m4 | 240 | aclocal_DATA = \ |
241 | gnunet.m4 | ||
242 | |||
243 | ## EOF | ||
diff --git a/contrib/get_version.sh b/contrib/get_version.sh new file mode 100755 index 000000000..35eed9f94 --- /dev/null +++ b/contrib/get_version.sh | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/bin/bash | ||
2 | # Gets the version number from git, or from the contents of .version | ||
3 | VERSION= | ||
4 | if test -f ".version" | ||
5 | then | ||
6 | VERSION=$(cat .version) | ||
7 | fi | ||
8 | if test "x$VERSION" = "x" -a -d "./.git" | ||
9 | then | ||
10 | VERSION=$(git describe --tags) | ||
11 | VERSION=${VERSION:1:${#VERSION}} | ||
12 | echo $VERSION > .version | ||
13 | fi | ||
14 | if test "x$VERSION" = "x" | ||
15 | then | ||
16 | VERSION="unknown" | ||
17 | fi | ||
18 | echo -n "$VERSION" | ||
diff --git a/contrib/gnunet.m4 b/contrib/gnunet.m4 index 6d9332db3..e740fa396 100644 --- a/contrib/gnunet.m4 +++ b/contrib/gnunet.m4 | |||
@@ -41,7 +41,7 @@ AC_DEFUN([AM_PATH_GNUNET], | |||
41 | [gnunet_PATH="$prefix/bin${PATH_SEPARATOR}$prefix/usr/bin"]) | 41 | [gnunet_PATH="$prefix/bin${PATH_SEPARATOR}$prefix/usr/bin"]) |
42 | AC_PATH_PROG([GNUNET_CONFIG],[gnunet-config],[no],[$gnunet_PATH]) | 42 | AC_PATH_PROG([GNUNET_CONFIG],[gnunet-config],[no],[$gnunet_PATH]) |
43 | AS_UNSET([gnunet_PATH])], | 43 | AS_UNSET([gnunet_PATH])], |
44 | [GNUNET_CONFIG="pkg-config gnunetutil"])]) | 44 | [GNUNET_CONFIG="gnunet-config"])]) |
45 | AC_MSG_CHECKING([if GNUnet version is >= $min_gnunet_version]) | 45 | AC_MSG_CHECKING([if GNUnet version is >= $min_gnunet_version]) |
46 | gnunet_result=no | 46 | gnunet_result=no |
47 | AS_IF([test "x$GNUNET_CONFIG" != "xno" && test -n "$GNUNET_CONFIG"], | 47 | AS_IF([test "x$GNUNET_CONFIG" != "xno" && test -n "$GNUNET_CONFIG"], |
diff --git a/contrib/scripts/Makefile.am b/contrib/scripts/Makefile.am index bbb9e6d67..756119ada 100644 --- a/contrib/scripts/Makefile.am +++ b/contrib/scripts/Makefile.am | |||
@@ -3,38 +3,57 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include | |||
3 | 3 | ||
4 | SUBDIRS = gnunet-logread | 4 | SUBDIRS = gnunet-logread |
5 | 5 | ||
6 | noinst_SCRIPTS = \ | ||
7 | terminate.py \ | ||
8 | pydiffer.py \ | ||
9 | removetrailingwhitespace.py \ | ||
10 | gnunet_pyexpect.py \ | ||
11 | gnunet_janitor.py \ | ||
12 | gnunet-chk.py \ | ||
13 | $(awkSCRIPTS) | ||
14 | |||
15 | # FIXME: read into AWK_SCRIPTS autotools builtin. | 6 | # FIXME: read into AWK_SCRIPTS autotools builtin. |
16 | if HAVE_AWK | 7 | if HAVE_AWK |
17 | awkSCRIPTS = \ | 8 | awkSCRIPTS = \ |
18 | check-texinfo.awk | 9 | check-texinfo.awk |
19 | else | 10 | else |
20 | awkSCRIPTS = | 11 | awkSCRIPTS = |
21 | endif | 12 | endif |
22 | 13 | ||
14 | noinst_SCRIPTS = \ | ||
15 | terminate.py \ | ||
16 | pydiffer.py \ | ||
17 | removetrailingwhitespace.py \ | ||
18 | gnunet_pyexpect.py \ | ||
19 | gnunet_janitor.py \ | ||
20 | gnunet-chk.py \ | ||
21 | $(awkSCRIPTS) | ||
22 | |||
23 | bin_SCRIPTS = \ | 23 | bin_SCRIPTS = \ |
24 | gnunet-bugreport \ | 24 | gnunet-bugreport \ |
25 | gnunet-suidfix | 25 | gnunet-suidfix |
26 | 26 | ||
27 | EXTRA_DIST = \ | 27 | EXTRA_DIST = \ |
28 | coverage.sh \ | 28 | coverage.sh \ |
29 | terminate.py.in \ | 29 | terminate.py.in \ |
30 | gnunet_pyexpect.py.in \ | 30 | gnunet_pyexpect.py.in \ |
31 | gnunet_janitor.py.in \ | 31 | gnunet_janitor.py.in \ |
32 | gnunet-chk.py.in \ | 32 | gnunet-chk.py.in \ |
33 | $(SCRIPTS) \ | 33 | removetrailingwhitespace.py.in \ |
34 | removetrailingwhitespace.py.in \ | 34 | pydiffer.py.in \ |
35 | pydiffer.py.in \ | 35 | check-texinfo.awk.in \ |
36 | gnunet-suidfix \ | 36 | build-install-gnunet-debian10.sh \ |
37 | check-texinfo.awk.in | 37 | process_log.sh \ |
38 | generate-monkey-db.sh \ | ||
39 | find_typedefs.py \ | ||
40 | pydmesg \ | ||
41 | visualize_stats.sh \ | ||
42 | changelog_delta.sh \ | ||
43 | debug \ | ||
44 | build_cscope.sh \ | ||
45 | lint/lint-man.sh \ | ||
46 | lint/lint-python.sh \ | ||
47 | revisionary.sh \ | ||
48 | netjail/netjail_core.sh \ | ||
49 | netjail/netjail_setup_internet.sh \ | ||
50 | regression.sh \ | ||
51 | doc/texinfo-hacks.el \ | ||
52 | afferify \ | ||
53 | zonewalk-to-types.sh \ | ||
54 | gdb-iterate-dll.py \ | ||
55 | $(SCRIPTS) | ||
56 | |||
38 | 57 | ||
39 | CLEANFILES = \ | 58 | CLEANFILES = \ |
40 | $(noinst_SCRIPTS) | 59 | $(noinst_SCRIPTS) |
diff --git a/contrib/scripts/testbed_cleanup.sh b/contrib/scripts/testbed_cleanup.sh deleted file mode 100755 index ee0200d44..000000000 --- a/contrib/scripts/testbed_cleanup.sh +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ################################################################################### | ||
4 | # Script to clean a previous run of testbed which has crashed. This scripts kills # | ||
5 | # the peers and cleans the temporary files created for those peers # | ||
6 | # # | ||
7 | # Author: Sree Harsha Totakura # | ||
8 | ################################################################################### | ||
9 | |||
10 | for host in `cut -d : -f 1 < infiniband_cluster.hosts | cut -d @ -f 2` | ||
11 | do | ||
12 | echo "ssh --> $host" | ||
13 | ssh $host 'pkill -SIGKILL gnunet; rm -rf /tmp/gnunet-pipe*; rm -rf /tmp/testbed*' | ||
14 | done | ||
diff --git a/contrib/testbed_infiniband_results/30000_connections_90000_peers_30_poc.txt b/contrib/testbed_infiniband_results/30000_connections_90000_peers_30_poc.txt deleted file mode 100644 index 666b00942..000000000 --- a/contrib/testbed_infiniband_results/30000_connections_90000_peers_30_poc.txt +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 90000 peers created successfully in 385.34 seconds | ||
32 | 90000 peers started successfully in 102.31 seconds | ||
33 | Establishing links. Please wait | ||
34 | ......FFFFFFFFFFFFFFFFFFFFFFFF.....F......................................F.....................FFFFFFFF....F...F...........................................................................................................F............................F........................................................................F.....................F...................................F.....F...F........................F.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F.....................................................................................................................................................F..........................................................................................................................................................................................F......................................................................................................................................................................................F....................................................................................................................................................................F............................................................................................................................................................................F............................................................................................................................................................................F.................................................................................................................................................................................F...........................................................................................................................................................F........................................................................................................................................................F.................................................................F...............................................................................................F.....................................................................................................................................................................................F.....................................................................F...............................................................................................F............................................................................................................................................................................F...........................................................................F..............................................................................................F....................................................................................................................................................................................F...................................................................F.............................................................................................F..................................................................................................................................................................................F.....................................................................F................................................................................................F.............................................................................................................................................................................F.....................................................................F..............................................................................................F.............................................................................................................................................................................F.....................................................................F.................................................................................................F....................................................................................................................................................................................F.....................................................................F..............................................................................................F................................................................................................................................................................................F.........................................................................F.................................................................................................F...............................................................................................................................................................................F..................................................................F......................................................................................F........................................................................................................................................................F........................................................F...........................................................................F........................................................................................................................................F..................................................F.........................................................................F.......................................................................................................................................F.........................................................F...............................................................................F...........................................................................................................................................F.....................................................F.........................................................................F...............................................................................................................F...................................................F..............................................................F..........................................................................................................................F.................................................F..............................................................F.................................................................................................................F...............................................F...............................................................F................................................................................................................F........................................F.........................................................F..................................................................................................F........................................F..................................................F........................................................................................................F.........................F................................F..........................F.......................F..................F...............F....................................F....................F.....F................................F..............F..........................................................................F.........................................F.....................................................F......................................................................................................F.........................................F..................................................F..............................................................................................F.....................................F........................................F..................................................................................F...............F...................F..................................................F................................................................................F...............F..................F..........................................F...............................................................................F.................F................F..........................................F........................................................................F................F...............F.........................................F.............................................................................F.............F..............F............................................F...........................................................................F................F................F.........................................F............................................................................F................F...............F........................................F.........................................................................F...............F................F...........................................F..............................................................................F..............F..............F.........................................F............................................................F...........F............F................................F.............F.............................................................F...............F.................F..........................................F...............F.........................................................F................F.................F..........................................F..............F..............................................................F...............F................F...............................F...........F............................................F............F............F................................F..........F.............................................F...........F...........F...............................F...........F...........................................F...........F............F...............................F..........F...............................................F..........F...........F.....................F........F.............................F........F........F.....................F........F...............................F.....F........F....................F.......F..............................F.......F........F....................F........F..............................F.......F........F....................F........F...............................F........F.......F.....................F.......F.............................F........F........F....................F.......F.............................F........F........F.....................F.......F..............................F........F........F....................F........F..............................F........F........F...................F........F..............................F.....F.......F.....................F.......F...........................F........F........F.............F...F...............F....F....F..F................F........F.............................F.......F........F...F..................F........F..............................F........F........F...F.................F.......F..............................F.......F........F....F..................F........F.............................F.......F........F...F..................F.......F.............................F........F........F..F..................F.......F.............................F........F.......F...F.................F.......F...............................F........F.......F..F..................F.......F.............................F.......F.........F..F..................F.......F.............................F........F........F...F..................F.......F.............................F........F.......F....F.................F........F.............................F.......F........F...F.................F.......F.............................F.......F........F....F................F........F..............................F.......F........F..F..................F.......F...............................F......F.......F....F................F........F.............................F........F........F..F..................F........F..............................F........F.......F....F..................F......F..............................F.......F........F....F..................F.......F...............................F........F......F...F.................F...F..............F....F....F.F........F..F.......F.............................F......F.........F...F..............F...F.......F..............................F.......F........F....F................F..F......F..............................F........F.......F...F...............F...F.......F.............................F.......F........F..F...............F...F........F..............................F........F.......F...F...............F...F......F.............................F.......F........F...F..............F....F......F..............................F.......F........F..F................F..F........F............................F.......F........F..F.................F..F........F.............................F........F.......F....F...............F...F.......F..............................F.......F........F...F..............F...F.......F.............................F........F........F..F..............F...F.......F............................F........F........F...F...............F...F......F............................F........F........F..F................F..F........F............................F.......F.......F..F.FFFFFFF.FF...........F..F...F..............F...F....FF.F.F....F....F...F.......F...FFFFFFFFFFF...F..................FFFFFFFFFFFFF.F.F....F.FFFFFFFFFFF.FF..F...F....FF.F.F....F...F.F...F.F..F...........F.F.F.F.F...F.....FF..FF.FFFFFFFFFFFFF...FF.F.FF.......F......F..F......F..F......F...................F...F..F.F.F.FF....FF.F.FF....FFFFFFFFFF.F.F..FF...F.F.FF.F...F.F....F...F...F.F..F..........F.F.FF.FFFFFFFFFFFFFF...F.F..F......FFFFFF.F.F.F....FF.F.FF..FFFFFFFFF....F.F.FF.FF.F..F.F...FF.F.FF..F..F.FFFFFFFFFFFFFFFFFF | ||
35 | Aborting due to very high failure rate | ||
36 | 30000 links established in 3322.23 seconds | ||
37 | Overlay link operations have been retried 703 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_10000_peers_100_poc.txt b/contrib/testbed_infiniband_results/6000_connections_10000_peers_100_poc.txt deleted file mode 100644 index 1ff9f799e..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_10000_peers_100_poc.txt +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 10000 peers created successfully in 35.98 seconds | ||
32 | 10000 peers started successfully in 4.81 seconds | ||
33 | Establishing links. Please wait | ||
34 | ...............................................................................................................................................................................................................................................................................................................F.FFFFFFFFF................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | ||
35 | 6000 links established in 168.63 seconds | ||
36 | Overlay link operations have been retried 10 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_10000_peers_20_poc.txt b/contrib/testbed_infiniband_results/6000_connections_10000_peers_20_poc.txt deleted file mode 100644 index 00504be78..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_10000_peers_20_poc.txt +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 10000 peers created successfully in 35.34 seconds | ||
32 | 10000 peers started successfully in 3.87 seconds | ||
33 | Establishing links. Please wait | ||
34 | ...........................................................................................................................................................................................................................................................................................FFFF..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... | ||
35 | 6000 links established in 203.77 seconds | ||
36 | Overlay link operations have been retried 4 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_10000_peers_30_poc.txt b/contrib/testbed_infiniband_results/6000_connections_10000_peers_30_poc.txt deleted file mode 100644 index daa5d9149..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_10000_peers_30_poc.txt +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 20000 peers created successfully in 79.97 seconds | ||
32 | 20000 peers started successfully in 10.22 seconds | ||
33 | Establishing links. Please wait | ||
34 | ...............................................FFFFFFFFF.FFF | ||
35 | Aborting due to very high failure rate | ||
36 | 12000 links established in 30.08 seconds | ||
37 | Overlay link operations have been retried 12 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_20000_peers.txt b/contrib/testbed_infiniband_results/6000_connections_20000_peers.txt deleted file mode 100644 index b00832e58..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_20000_peers.txt +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | All slaves started successfully | ||
21 | All peers created successfully in 55.53 seconds | ||
22 | All peers started successfully in 26.02 seconds | ||
23 | Establishing links. Please wait | ||
24 | ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F...F.F.FF....................................................................................................F............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... | ||
25 | 6000 links established in 123.49 seconds | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_40000_peers.txt b/contrib/testbed_infiniband_results/6000_connections_40000_peers.txt deleted file mode 100644 index ccd5ec41c..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_40000_peers.txt +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 40000 peers created successfully in 165.12 seconds | ||
32 | 40000 peers started successfully in 179.35 seconds | ||
33 | Establishing links. Please wait | ||
34 | ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | ||
35 | 6000 links established in 101.62 seconds | ||
36 | Overlay link operations have been retried 0 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_60000_peers.txt b/contrib/testbed_infiniband_results/6000_connections_60000_peers.txt deleted file mode 100644 index 88606f99e..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_60000_peers.txt +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 60000 peers created successfully in 253.31 seconds | ||
32 | 60000 peers started successfully in 53.18 seconds | ||
33 | Establishing links. Please wait | ||
34 | ..............FFFFFFFFFFF | ||
35 | Aborting due to very high failure rate | ||
36 | 6000 links established in 30.14 seconds | ||
37 | Overlay link operations have been retried 11 times upon timeouts | ||
38 | F | ||
39 | Aborting due to very high failure rate | ||
40 | 6000 links established in 30.14 seconds | ||
41 | Overlay link operations have been retried 12 times upon timeouts | ||
42 | F | ||
43 | Aborting due to very high failure rate | ||
44 | 6000 links established in 30.14 seconds | ||
45 | Overlay link operations have been retried 13 times upon timeouts | ||
46 | F | ||
47 | Aborting due to very high failure rate | ||
48 | 6000 links established in 30.14 seconds | ||
49 | Overlay link operations have been retried 14 times upon timeouts | ||
50 | F | ||
51 | Aborting due to very high failure rate | ||
52 | 6000 links established in 30.14 seconds | ||
53 | Overlay link operations have been retried 15 times upon timeouts | ||
54 | F | ||
55 | Aborting due to very high failure rate | ||
56 | 6000 links established in 30.14 seconds | ||
57 | Overlay link operations have been retried 16 times upon timeouts | ||
58 | F | ||
59 | Aborting due to very high failure rate | ||
60 | 6000 links established in 30.14 seconds | ||
61 | Overlay link operations have been retried 17 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_60000_peers_5_poc.txt b/contrib/testbed_infiniband_results/6000_connections_60000_peers_5_poc.txt deleted file mode 100644 index 62ed9f842..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_60000_peers_5_poc.txt +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 60000 peers created successfully in 254.00 seconds | ||
32 | 60000 peers started successfully in 50.20 seconds | ||
33 | Establishing links. Please wait | ||
34 | .FFFF.F.................F............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. | ||
35 | 6000 links established in 2305.66 seconds | ||
36 | Overlay link operations have been retried 6 times upon timeouts | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_80000_peers_20_poc.txt b/contrib/testbed_infiniband_results/6000_connections_80000_peers_20_poc.txt deleted file mode 100644 index 502bc72e3..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_80000_peers_20_poc.txt +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
23 | /home/totakura/local/bin/gnunet-helper-testbed | ||
24 | /home/totakura/local/bin/gnunet-helper-testbed | ||
25 | /home/totakura/local/bin/gnunet-helper-testbed | ||
26 | /home/totakura/local/bin/gnunet-helper-testbed | ||
27 | /home/totakura/local/bin/gnunet-helper-testbed | ||
28 | /home/totakura/local/bin/gnunet-helper-testbed | ||
29 | /home/totakura/local/bin/gnunet-helper-testbed | ||
30 | 29 controllers started successfully | ||
31 | 80000 peers created successfully in 360.78 seconds | ||
32 | 80000 peers started successfully in 77.87 seconds | ||
33 | Establishing links. Please wait | ||
34 | ............FFFFFFFFFFFF...F..........FF...F...................FFFFFFF.......FF.F.....F........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | ||
35 | Aborting due to very high failure rate | ||
36 | 6000 links established in 1283.11 seconds | ||
37 | Overlay link operations have been retried 62 times upon timeouts | ||
38 | t | ||
diff --git a/contrib/testbed_infiniband_results/6000_connections_80000_peers_5_poc.txt b/contrib/testbed_infiniband_results/6000_connections_80000_peers_5_poc.txt deleted file mode 100644 index b3f4e6415..000000000 --- a/contrib/testbed_infiniband_results/6000_connections_80000_peers_5_poc.txt +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | /home/totakura/local/bin/gnunet-helper-testbed | ||
2 | /home/totakura/local/bin/gnunet-helper-testbed | ||
3 | /home/totakura/local/bin/gnunet-helper-testbed | ||
4 | /home/totakura/local/bin/gnunet-helper-testbed | ||
5 | /home/totakura/local/bin/gnunet-helper-testbed | ||
6 | /home/totakura/local/bin/gnunet-helper-testbed | ||
7 | /home/totakura/local/bin/gnunet-helper-testbed | ||
8 | /home/totakura/local/bin/gnunet-helper-testbed | ||
9 | /home/totakura/local/bin/gnunet-helper-testbed | ||
10 | /home/totakura/local/bin/gnunet-helper-testbed | ||
11 | /home/totakura/local/bin/gnunet-helper-testbed | ||
12 | /home/totakura/local/bin/gnunet-helper-testbed | ||
13 | /home/totakura/local/bin/gnunet-helper-testbed | ||
14 | /home/totakura/local/bin/gnunet-helper-testbed | ||
15 | /home/totakura/local/bin/gnunet-helper-testbed | ||
16 | /home/totakura/local/bin/gnunet-helper-testbed | ||
17 | /home/totakura/local/bin/gnunet-helper-testbed | ||
18 | /home/totakura/local/bin/gnunet-helper-testbed | ||
19 | /home/totakura/local/bin/gnunet-helper-testbed | ||
20 | /home/totakura/local/bin/gnunet-helper-testbed | ||
21 | /home/totakura/local/bin/gnunet-helper-testbed | ||
22 | /home/totakura/local/bin/gnunet-helper-testbed | ||
diff --git a/doc/handbook/chapters/developer.texi b/doc/handbook/chapters/developer.texi index cf13fd816..a8f9d1ec3 100644 --- a/doc/handbook/chapters/developer.texi +++ b/doc/handbook/chapters/developer.texi | |||
@@ -9470,9 +9470,6 @@ your hosts file). | |||
9470 | @strong{Configuration} | 9470 | @strong{Configuration} |
9471 | 9471 | ||
9472 | Moreover, an appropriate configuration file is needed. | 9472 | Moreover, an appropriate configuration file is needed. |
9473 | Generally you can refer to the | ||
9474 | @file{contrib/regex_profiler_infiniband.conf} file in the sourcecode | ||
9475 | of GNUnet for an example configuration. | ||
9476 | In the following paragraph the important details are highlighted. | 9473 | In the following paragraph the important details are highlighted. |
9477 | 9474 | ||
9478 | Announcing of the regular expressions is done by the | 9475 | Announcing of the regular expressions is done by the |
diff --git a/doc/handbook/chapters/keyconcepts.texi b/doc/handbook/chapters/keyconcepts.texi index 49129acf5..c8dd1599b 100644 --- a/doc/handbook/chapters/keyconcepts.texi +++ b/doc/handbook/chapters/keyconcepts.texi | |||
@@ -290,10 +290,10 @@ An Encoding for Censorship-Resistant Sharing. | |||
290 | 290 | ||
291 | Peer identities are used to identify peers in the network and are unique | 291 | Peer identities are used to identify peers in the network and are unique |
292 | for each peer. The identity for a peer is simply its public key, which is | 292 | for each peer. The identity for a peer is simply its public key, which is |
293 | generated along with a private key the peer is started for the first time. | 293 | generated along with a private key when the peer is started for the first |
294 | While the identity is binary data, it is often expressed as ASCII string. | 294 | time. While the identity is binary data, it is often expressed as an ASCII |
295 | For example, the following is a peer identity as you might see it in | 295 | string. For example, the following is a peer identity as you might see it |
296 | various places: | 296 | in various places: |
297 | 297 | ||
298 | @example | 298 | @example |
299 | UAT1S6PMPITLBKSJ2DGV341JI6KF7B66AC4JVCN9811NNEGQLUN0 | 299 | UAT1S6PMPITLBKSJ2DGV341JI6KF7B66AC4JVCN9811NNEGQLUN0 |
diff --git a/po/POTFILES.in b/po/POTFILES.in index adea4bcf1..e34cb25f4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -110,6 +110,7 @@ src/dht/gnunet_dht_profiler.c | |||
110 | src/dht/plugin_block_dht.c | 110 | src/dht/plugin_block_dht.c |
111 | src/dhtu/plugin_dhtu_gnunet.c | 111 | src/dhtu/plugin_dhtu_gnunet.c |
112 | src/dhtu/plugin_dhtu_ip.c | 112 | src/dhtu/plugin_dhtu_ip.c |
113 | src/dhtu/testing_dhtu_cmd_send.c | ||
113 | src/dns/dns_api.c | 114 | src/dns/dns_api.c |
114 | src/dns/gnunet-dns-monitor.c | 115 | src/dns/gnunet-dns-monitor.c |
115 | src/dns/gnunet-dns-redirector.c | 116 | src/dns/gnunet-dns-redirector.c |
@@ -405,7 +406,6 @@ src/testbed/gnunet-service-testbed_oc.c | |||
405 | src/testbed/gnunet-service-testbed_peers.c | 406 | src/testbed/gnunet-service-testbed_peers.c |
406 | src/testbed/gnunet-testbed-profiler.c | 407 | src/testbed/gnunet-testbed-profiler.c |
407 | src/testbed/gnunet_mpi_test.c | 408 | src/testbed/gnunet_mpi_test.c |
408 | src/testbed/gnunet_testbed_mpi_spawn.c | ||
409 | src/testbed/testbed_api.c | 409 | src/testbed/testbed_api.c |
410 | src/testbed/testbed_api_barriers.c | 410 | src/testbed/testbed_api_barriers.c |
411 | src/testbed/testbed_api_hosts.c | 411 | src/testbed/testbed_api_hosts.c |
@@ -425,6 +425,8 @@ src/testing/testing.c | |||
425 | src/testing/testing_api_cmd_batch.c | 425 | src/testing/testing_api_cmd_batch.c |
426 | src/testing/testing_api_cmd_block_until_all_peers_started.c | 426 | src/testing/testing_api_cmd_block_until_all_peers_started.c |
427 | src/testing/testing_api_cmd_block_until_external_trigger.c | 427 | src/testing/testing_api_cmd_block_until_external_trigger.c |
428 | src/testing/testing_api_cmd_end.c | ||
429 | src/testing/testing_api_cmd_finish.c | ||
428 | src/testing/testing_api_cmd_hello_world.c | 430 | src/testing/testing_api_cmd_hello_world.c |
429 | src/testing/testing_api_cmd_hello_world_birth.c | 431 | src/testing/testing_api_cmd_hello_world_birth.c |
430 | src/testing/testing_api_cmd_local_test_finished.c | 432 | src/testing/testing_api_cmd_local_test_finished.c |
diff --git a/src/Makefile.am b/src/Makefile.am index ef8c5b110..31215c6d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -1,9 +1,7 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | 2 | ||
3 | if HAVE_TESTING | 3 | TESTING = testing |
4 | TESTING = testing | 4 | TESTBED = testbed-logger testbed |
5 | TESTBED = testbed-logger testbed | ||
6 | endif | ||
7 | 5 | ||
8 | if HAVE_EXPERIMENTAL | 6 | if HAVE_EXPERIMENTAL |
9 | EXP_DIR = \ | 7 | EXP_DIR = \ |
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 0b8e7309a..85a2bb555 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am | |||
@@ -65,11 +65,9 @@ gnunet_service_ats_LDADD = \ | |||
65 | libgnunetats.la \ | 65 | libgnunetats.la \ |
66 | $(GN_LIBINTL) | 66 | $(GN_LIBINTL) |
67 | 67 | ||
68 | if HAVE_TESTING | ||
69 | TESTING_TESTS = \ | 68 | TESTING_TESTS = \ |
70 | test_ats_api_proportional \ | 69 | test_ats_api_proportional \ |
71 | test_ats_reservation_api_proportional | 70 | test_ats_reservation_api_proportional |
72 | endif | ||
73 | 71 | ||
74 | check_PROGRAMS = \ | 72 | check_PROGRAMS = \ |
75 | $(TESTING_TESTS) | 73 | $(TESTING_TESTS) |
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index 2289a2d96..d942c6495 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am | |||
@@ -78,12 +78,9 @@ if LINUX | |||
78 | endif | 78 | endif |
79 | 79 | ||
80 | 80 | ||
81 | if HAVE_TESTING | ||
82 | noinst_LTLIBRARIES = libgnunetcadettest.la $(noinst_LIB_EXP) | 81 | noinst_LTLIBRARIES = libgnunetcadettest.la $(noinst_LIB_EXP) |
83 | # noinst_PROGRAMS = gnunet-cadet-profiler | 82 | # noinst_PROGRAMS = gnunet-cadet-profiler |
84 | endif | ||
85 | 83 | ||
86 | if HAVE_TESTING | ||
87 | check_PROGRAMS = \ | 84 | check_PROGRAMS = \ |
88 | test_cadet_local_mq \ | 85 | test_cadet_local_mq \ |
89 | test_cadet_2_forward \ | 86 | test_cadet_2_forward \ |
@@ -106,7 +103,6 @@ check_PROGRAMS = \ | |||
106 | test_cadet_5_speed_reliable_backwards \ | 103 | test_cadet_5_speed_reliable_backwards \ |
107 | test_cadet_5_speed_backwards \ | 104 | test_cadet_5_speed_backwards \ |
108 | test_cadet_5_reopen | 105 | test_cadet_5_reopen |
109 | endif | ||
110 | 106 | ||
111 | 107 | ||
112 | #gnunet_cadet_profiler_SOURCES = \ | 108 | #gnunet_cadet_profiler_SOURCES = \ |
diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am index cf1d32e74..d7b23e7c6 100644 --- a/src/consensus/Makefile.am +++ b/src/consensus/Makefile.am | |||
@@ -89,7 +89,6 @@ libgnunet_plugin_block_consensus_la_LDFLAGS = \ | |||
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | if HAVE_TESTING | ||
93 | bin_PROGRAMS = \ | 92 | bin_PROGRAMS = \ |
94 | gnunet-consensus-profiler | 93 | gnunet-consensus-profiler |
95 | 94 | ||
@@ -100,7 +99,6 @@ if ENABLE_TEST_RUN | |||
100 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 99 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
101 | TESTS = $(check_PROGRAMS) | 100 | TESTS = $(check_PROGRAMS) |
102 | endif | 101 | endif |
103 | endif | ||
104 | 102 | ||
105 | test_consensus_api_SOURCES = \ | 103 | test_consensus_api_SOURCES = \ |
106 | test_consensus_api.c | 104 | test_consensus_api.c |
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index d2d3a2d7f..e51247e18 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am | |||
@@ -54,10 +54,8 @@ gnunet_core_LDADD = \ | |||
54 | gnunet_core_LDFLAGS = \ | 54 | gnunet_core_LDFLAGS = \ |
55 | $(GN_LIBINTL) | 55 | $(GN_LIBINTL) |
56 | 56 | ||
57 | if HAVE_TESTING | 57 | TESTING_TESTS = \ |
58 | TESTING_TESTS = \ | 58 | test_core_api_send_to_self |
59 | test_core_api_send_to_self | ||
60 | endif | ||
61 | 59 | ||
62 | check_PROGRAMS = \ | 60 | check_PROGRAMS = \ |
63 | test_core_api_start_only \ | 61 | test_core_api_start_only \ |
diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am index ecb02d1c3..4789706ff 100644 --- a/src/datacache/Makefile.am +++ b/src/datacache/Makefile.am | |||
@@ -85,7 +85,6 @@ libgnunet_plugin_datacache_template_la_LDFLAGS = \ | |||
85 | $(GN_PLUGIN_LDFLAGS) | 85 | $(GN_PLUGIN_LDFLAGS) |
86 | 86 | ||
87 | 87 | ||
88 | if HAVE_TESTING | ||
89 | if HAVE_SQLITE | 88 | if HAVE_SQLITE |
90 | if HAVE_BENCHMARKS | 89 | if HAVE_BENCHMARKS |
91 | SQLITE_BENCHMARKS = \ | 90 | SQLITE_BENCHMARKS = \ |
@@ -95,7 +94,6 @@ SQLITE_TESTS = \ | |||
95 | test_datacache_sqlite \ | 94 | test_datacache_sqlite \ |
96 | test_datacache_quota_sqlite \ | 95 | test_datacache_quota_sqlite \ |
97 | $(SQLITE_BENCHMARKS) | 96 | $(SQLITE_BENCHMARKS) |
98 | endif | ||
99 | 97 | ||
100 | if HAVE_BENCHMARKS | 98 | if HAVE_BENCHMARKS |
101 | HEAP_BENCHMARKS = \ | 99 | HEAP_BENCHMARKS = \ |
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index cd1df4e5e..07ae004b3 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am | |||
@@ -52,7 +52,6 @@ gnunet_datastore_LDADD = \ | |||
52 | 52 | ||
53 | if HAVE_MYSQL | 53 | if HAVE_MYSQL |
54 | MYSQL_PLUGIN = libgnunet_plugin_datastore_mysql.la | 54 | MYSQL_PLUGIN = libgnunet_plugin_datastore_mysql.la |
55 | if HAVE_TESTING | ||
56 | if HAVE_BENCHMARKS | 55 | if HAVE_BENCHMARKS |
57 | MYSQL_BENCHMARKS = \ | 56 | MYSQL_BENCHMARKS = \ |
58 | perf_datastore_api_mysql \ | 57 | perf_datastore_api_mysql \ |
@@ -64,10 +63,8 @@ endif | |||
64 | test_plugin_datastore_mysql \ | 63 | test_plugin_datastore_mysql \ |
65 | $(MYSQL_BENCHMARKS) | 64 | $(MYSQL_BENCHMARKS) |
66 | endif | 65 | endif |
67 | endif | ||
68 | if HAVE_SQLITE | 66 | if HAVE_SQLITE |
69 | SQLITE_PLUGIN = libgnunet_plugin_datastore_sqlite.la | 67 | SQLITE_PLUGIN = libgnunet_plugin_datastore_sqlite.la |
70 | if HAVE_TESTING | ||
71 | if HAVE_BENCHMARKS | 68 | if HAVE_BENCHMARKS |
72 | SQLITE_BENCHMARKS = \ | 69 | SQLITE_BENCHMARKS = \ |
73 | perf_datastore_api_sqlite \ | 70 | perf_datastore_api_sqlite \ |
@@ -79,10 +76,8 @@ endif | |||
79 | test_plugin_datastore_sqlite \ | 76 | test_plugin_datastore_sqlite \ |
80 | $(SQLITE_BENCHMARKS) | 77 | $(SQLITE_BENCHMARKS) |
81 | endif | 78 | endif |
82 | endif | ||
83 | if HAVE_POSTGRESQL | 79 | if HAVE_POSTGRESQL |
84 | POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la | 80 | POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la |
85 | if HAVE_TESTING | ||
86 | if HAVE_BENCHMARKS | 81 | if HAVE_BENCHMARKS |
87 | POSTGRES_BENCHMARKS = \ | 82 | POSTGRES_BENCHMARKS = \ |
88 | perf_datastore_api_postgres \ | 83 | perf_datastore_api_postgres \ |
@@ -94,7 +89,6 @@ endif | |||
94 | test_plugin_datastore_postgres \ | 89 | test_plugin_datastore_postgres \ |
95 | $(POSTGRES_BENCHMARKS) | 90 | $(POSTGRES_BENCHMARKS) |
96 | endif | 91 | endif |
97 | endif | ||
98 | 92 | ||
99 | plugin_LTLIBRARIES = \ | 93 | plugin_LTLIBRARIES = \ |
100 | $(SQLITE_PLUGIN) \ | 94 | $(SQLITE_PLUGIN) \ |
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 919eca438..69e34000c 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -52,10 +52,8 @@ bin_PROGRAMS = \ | |||
52 | gnunet-dht-get \ | 52 | gnunet-dht-get \ |
53 | gnunet-dht-put | 53 | gnunet-dht-put |
54 | 54 | ||
55 | if HAVE_TESTING | ||
56 | noinst_PROGRAMS = \ | 55 | noinst_PROGRAMS = \ |
57 | gnunet-dht-profiler | 56 | gnunet-dht-profiler |
58 | endif | ||
59 | 57 | ||
60 | gnunet_service_dht_SOURCES = \ | 58 | gnunet_service_dht_SOURCES = \ |
61 | gnunet-service-dht.c gnunet-service-dht.h \ | 59 | gnunet-service-dht.c gnunet-service-dht.h \ |
@@ -117,9 +115,7 @@ gnunet_dht_profiler_LDADD = \ | |||
117 | gnunet_dht_profiler_LDFLAGS = \ | 115 | gnunet_dht_profiler_LDFLAGS = \ |
118 | $(GN_LIBINTL) | 116 | $(GN_LIBINTL) |
119 | 117 | ||
120 | if HAVE_TESTING | ||
121 | noinst_LIBRARIES = libgnunetdhttest.a | 118 | noinst_LIBRARIES = libgnunetdhttest.a |
122 | endif | ||
123 | 119 | ||
124 | libgnunetdhttest_a_SOURCES = \ | 120 | libgnunetdhttest_a_SOURCES = \ |
125 | dht_test_lib.c dht_test_lib.h | 121 | dht_test_lib.c dht_test_lib.h |
@@ -128,7 +124,6 @@ libgnunetdhttest_a_LIBADD = \ | |||
128 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 124 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
129 | libgnunetdht.la | 125 | libgnunetdht.la |
130 | 126 | ||
131 | if HAVE_TESTING | ||
132 | check_PROGRAMS = \ | 127 | check_PROGRAMS = \ |
133 | test_dht_api \ | 128 | test_dht_api \ |
134 | test_dht_twopeer \ | 129 | test_dht_twopeer \ |
@@ -136,7 +131,6 @@ check_PROGRAMS = \ | |||
136 | test_dht_line \ | 131 | test_dht_line \ |
137 | test_dht_2dtorus \ | 132 | test_dht_2dtorus \ |
138 | test_dht_monitor | 133 | test_dht_monitor |
139 | endif | ||
140 | 134 | ||
141 | if HAVE_EXPERIMENTAL | 135 | if HAVE_EXPERIMENTAL |
142 | # These tests still do not work as testbed does | 136 | # These tests still do not work as testbed does |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index ca255310c..6465d8d57 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -844,6 +844,10 @@ get_forward_count (uint32_t hop_count, | |||
844 | uint32_t forward_count; | 844 | uint32_t forward_count; |
845 | float target_value; | 845 | float target_value; |
846 | 846 | ||
847 | if (0 == target_replication) | ||
848 | target_replication = 1; /* 0 is verboten */ | ||
849 | if (target_replication > MAXIMUM_REPLICATION_LEVEL) | ||
850 | target_replication = MAXIMUM_REPLICATION_LEVEL; | ||
847 | if (hop_count > GDS_NSE_get () * 4.0) | 851 | if (hop_count > GDS_NSE_get () * 4.0) |
848 | { | 852 | { |
849 | /* forcefully terminate */ | 853 | /* forcefully terminate */ |
@@ -864,6 +868,8 @@ get_forward_count (uint32_t hop_count, | |||
864 | 1 + (target_replication - 1.0) / (GDS_NSE_get () | 868 | 1 + (target_replication - 1.0) / (GDS_NSE_get () |
865 | + ((float) (target_replication - 1.0) | 869 | + ((float) (target_replication - 1.0) |
866 | * hop_count)); | 870 | * hop_count)); |
871 | |||
872 | |||
867 | /* Set forward count to floor of target_value */ | 873 | /* Set forward count to floor of target_value */ |
868 | forward_count = (uint32_t) target_value; | 874 | forward_count = (uint32_t) target_value; |
869 | /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */ | 875 | /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */ |
@@ -872,7 +878,8 @@ get_forward_count (uint32_t hop_count, | |||
872 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); | 878 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); |
873 | if (random_value < (target_value * UINT32_MAX)) | 879 | if (random_value < (target_value * UINT32_MAX)) |
874 | forward_count++; | 880 | forward_count++; |
875 | return forward_count; | 881 | return GNUNET_MIN (forward_count, |
882 | MAXIMUM_REPLICATION_LEVEL); | ||
876 | } | 883 | } |
877 | 884 | ||
878 | 885 | ||
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am index 67810e8cc..772bee60a 100644 --- a/src/dhtu/Makefile.am +++ b/src/dhtu/Makefile.am | |||
@@ -30,9 +30,43 @@ libgnunet_plugin_dhtu_gnunet_la_SOURCES = \ | |||
30 | libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ | 30 | libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ |
31 | $(top_builddir)/src/ats/libgnunetats.la \ | 31 | $(top_builddir)/src/ats/libgnunetats.la \ |
32 | $(top_builddir)/src/core/libgnunetcore.la \ | 32 | $(top_builddir)/src/core/libgnunetcore.la \ |
33 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | ||
34 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
35 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
33 | $(top_builddir)/src/nse/libgnunetnse.la \ | 36 | $(top_builddir)/src/nse/libgnunetnse.la \ |
34 | $(top_builddir)/src/util/libgnunetutil.la \ | 37 | $(top_builddir)/src/util/libgnunetutil.la \ |
35 | $(XLIBS) \ | 38 | $(XLIBS) \ |
36 | $(LTLIBINTL) | 39 | $(LTLIBINTL) |
37 | libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \ | 40 | libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \ |
38 | $(GN_PLUGIN_LDFLAGS) | 41 | $(GN_PLUGIN_LDFLAGS) |
42 | |||
43 | |||
44 | lib_LTLIBRARIES = \ | ||
45 | libgnunettestingdhtu.la | ||
46 | |||
47 | libgnunettestingdhtu_la_SOURCES = \ | ||
48 | testing_dhtu_cmd_send.c | ||
49 | libgnunettestingdhtu_la_LIBADD = \ | ||
50 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
51 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
52 | $(LTLIBINTL) | ||
53 | libgnunettestingdhtu_la_LDFLAGS = \ | ||
54 | $(GN_LIB_LDFLAGS) \ | ||
55 | -version-info 0:0:0 | ||
56 | |||
57 | |||
58 | |||
59 | test_dhtu_ip_SOURCES = \ | ||
60 | test_dhtu_ip.c | ||
61 | test_dhtu_ip_LDADD = \ | ||
62 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
63 | $(top_builddir)/src/util/libgnunetutil.la | ||
64 | |||
65 | check_PROGRAMS = \ | ||
66 | test_dhtu_ip | ||
67 | |||
68 | if ENABLE_TEST_RUN | ||
69 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | ||
70 | TESTS = \ | ||
71 | $(check_PROGRAMS) | ||
72 | endif | ||
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c index 9cc14361d..ee78858c8 100644 --- a/src/dhtu/plugin_dhtu_gnunet.c +++ b/src/dhtu/plugin_dhtu_gnunet.c | |||
@@ -28,6 +28,9 @@ | |||
28 | #include "gnunet_dhtu_plugin.h" | 28 | #include "gnunet_dhtu_plugin.h" |
29 | #include "gnunet_ats_service.h" | 29 | #include "gnunet_ats_service.h" |
30 | #include "gnunet_core_service.h" | 30 | #include "gnunet_core_service.h" |
31 | #include "gnunet_transport_service.h" | ||
32 | #include "gnunet_hello_lib.h" | ||
33 | #include "gnunet_peerinfo_service.h" | ||
31 | #include "gnunet_nse_service.h" | 34 | #include "gnunet_nse_service.h" |
32 | 35 | ||
33 | 36 | ||
@@ -66,6 +69,35 @@ struct PublicKey | |||
66 | 69 | ||
67 | GNUNET_NETWORK_STRUCT_END | 70 | GNUNET_NETWORK_STRUCT_END |
68 | 71 | ||
72 | |||
73 | /** | ||
74 | * Handle for a HELLO we're offering the transport. | ||
75 | */ | ||
76 | struct HelloHandle | ||
77 | { | ||
78 | /** | ||
79 | * Kept in a DLL. | ||
80 | */ | ||
81 | struct HelloHandle *next; | ||
82 | |||
83 | /** | ||
84 | * Kept in a DLL. | ||
85 | */ | ||
86 | struct HelloHandle *prev; | ||
87 | |||
88 | /** | ||
89 | * Our plugin. | ||
90 | */ | ||
91 | struct Plugin *plugin; | ||
92 | |||
93 | /** | ||
94 | * Offer handle. | ||
95 | */ | ||
96 | struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; | ||
97 | |||
98 | }; | ||
99 | |||
100 | |||
69 | /** | 101 | /** |
70 | * Opaque handle that the underlay offers for our address to be used when | 102 | * Opaque handle that the underlay offers for our address to be used when |
71 | * sending messages to another peer. | 103 | * sending messages to another peer. |
@@ -77,7 +109,7 @@ struct GNUNET_DHTU_Source | |||
77 | * Application context for this source. | 109 | * Application context for this source. |
78 | */ | 110 | */ |
79 | void *app_ctx; | 111 | void *app_ctx; |
80 | 112 | ||
81 | /** | 113 | /** |
82 | * Hash position of this peer in the DHT. | 114 | * Hash position of this peer in the DHT. |
83 | */ | 115 | */ |
@@ -107,7 +139,7 @@ struct GNUNET_DHTU_Target | |||
107 | * Our plugin with its environment. | 139 | * Our plugin with its environment. |
108 | */ | 140 | */ |
109 | struct Plugin *plugin; | 141 | struct Plugin *plugin; |
110 | 142 | ||
111 | /** | 143 | /** |
112 | * CORE MQ to send messages to this peer. | 144 | * CORE MQ to send messages to this peer. |
113 | */ | 145 | */ |
@@ -117,7 +149,7 @@ struct GNUNET_DHTU_Target | |||
117 | * Public key of the peer. | 149 | * Public key of the peer. |
118 | */ | 150 | */ |
119 | struct PublicKey pk; | 151 | struct PublicKey pk; |
120 | 152 | ||
121 | /** | 153 | /** |
122 | * Hash of the @a pk to identify position of the peer | 154 | * Hash of the @a pk to identify position of the peer |
123 | * in the DHT. | 155 | * in the DHT. |
@@ -146,6 +178,7 @@ struct GNUNET_DHTU_Target | |||
146 | 178 | ||
147 | }; | 179 | }; |
148 | 180 | ||
181 | |||
149 | /** | 182 | /** |
150 | * Opaque handle expressing a preference of the DHT to | 183 | * Opaque handle expressing a preference of the DHT to |
151 | * keep a particular target connected. | 184 | * keep a particular target connected. |
@@ -174,6 +207,18 @@ struct GNUNET_DHTU_PreferenceHandle | |||
174 | */ | 207 | */ |
175 | struct Plugin | 208 | struct Plugin |
176 | { | 209 | { |
210 | |||
211 | /** | ||
212 | * Our "source" address. Traditional CORE API does not tell us which source | ||
213 | * it is, so they are all identical. | ||
214 | */ | ||
215 | struct GNUNET_DHTU_Source src; | ||
216 | |||
217 | /** | ||
218 | * My identity. | ||
219 | */ | ||
220 | struct GNUNET_PeerIdentity my_identity; | ||
221 | |||
177 | /** | 222 | /** |
178 | * Callbacks into the DHT. | 223 | * Callbacks into the DHT. |
179 | */ | 224 | */ |
@@ -188,18 +233,26 @@ struct Plugin | |||
188 | * Handle to ATS service. | 233 | * Handle to ATS service. |
189 | */ | 234 | */ |
190 | struct GNUNET_ATS_ConnectivityHandle *ats; | 235 | struct GNUNET_ATS_ConnectivityHandle *ats; |
191 | 236 | ||
192 | /** | ||
193 | * Our "source" address. Traditional CORE API does not tell us which source | ||
194 | * it is, so they are all identical. | ||
195 | */ | ||
196 | struct GNUNET_DHTU_Source src; | ||
197 | |||
198 | /** | 237 | /** |
199 | * Handle to the NSE service. | 238 | * Handle to the NSE service. |
200 | */ | 239 | */ |
201 | struct GNUNET_NSE_Handle *nse; | 240 | struct GNUNET_NSE_Handle *nse; |
202 | 241 | ||
242 | /** | ||
243 | * Watching for our address to change. | ||
244 | */ | ||
245 | struct GNUNET_PEERINFO_NotifyContext *nc; | ||
246 | |||
247 | /** | ||
248 | * Hellos we are offering to transport. | ||
249 | */ | ||
250 | struct HelloHandle *hh_head; | ||
251 | |||
252 | /** | ||
253 | * Hellos we are offering to transport. | ||
254 | */ | ||
255 | struct HelloHandle *hh_tail; | ||
203 | }; | 256 | }; |
204 | 257 | ||
205 | 258 | ||
@@ -273,6 +326,27 @@ ip_verify (void *cls, | |||
273 | 326 | ||
274 | 327 | ||
275 | /** | 328 | /** |
329 | * Function called once a hello offer is completed. | ||
330 | * | ||
331 | * @param cls a `struct HelloHandle` | ||
332 | */ | ||
333 | static void | ||
334 | hello_offered_cb (void *cls) | ||
335 | { | ||
336 | struct HelloHandle *hh = cls; | ||
337 | struct Plugin *plugin = hh->plugin; | ||
338 | |||
339 | GNUNET_CONTAINER_DLL_remove (plugin->hh_head, | ||
340 | plugin->hh_tail, | ||
341 | hh); | ||
342 | GNUNET_free (hh); | ||
343 | } | ||
344 | |||
345 | |||
346 | #include "../peerinfo-tool/gnunet-peerinfo_plugins.c" | ||
347 | |||
348 | |||
349 | /** | ||
276 | * Request creation of a session with a peer at the given @a address. | 350 | * Request creation of a session with a peer at the given @a address. |
277 | * | 351 | * |
278 | * @param cls closure (internal context for the plugin) | 352 | * @param cls closure (internal context for the plugin) |
@@ -283,10 +357,30 @@ ip_try_connect (void *cls, | |||
283 | const char *address) | 357 | const char *address) |
284 | { | 358 | { |
285 | struct Plugin *plugin = cls; | 359 | struct Plugin *plugin = cls; |
360 | struct GNUNET_HELLO_Message *hello = NULL; | ||
361 | struct HelloHandle *hh; | ||
362 | struct GNUNET_CRYPTO_EddsaPublicKey pubkey; | ||
363 | |||
364 | if (GNUNET_OK != | ||
365 | GNUNET_HELLO_parse_uri (address, | ||
366 | &pubkey, | ||
367 | &hello, | ||
368 | &GPI_plugins_find)) | ||
369 | { | ||
370 | GNUNET_break (0); | ||
371 | return; | ||
372 | } | ||
286 | 373 | ||
287 | // FIXME: ask ATS/TRANSPORT to 'connect' | 374 | hh = GNUNET_new (struct HelloHandle); |
288 | // => needs HELLO! | 375 | hh->plugin = plugin; |
289 | GNUNET_break (0); | 376 | GNUNET_CONTAINER_DLL_insert (plugin->hh_head, |
377 | plugin->hh_tail, | ||
378 | hh); | ||
379 | hh->ohh = GNUNET_TRANSPORT_offer_hello (plugin->env->cfg, | ||
380 | &hello->header, | ||
381 | &hello_offered_cb, | ||
382 | hh); | ||
383 | GNUNET_free (hello); | ||
290 | } | 384 | } |
291 | 385 | ||
292 | 386 | ||
@@ -332,7 +426,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) | |||
332 | { | 426 | { |
333 | struct GNUNET_DHTU_Target *target = ph->target; | 427 | struct GNUNET_DHTU_Target *target = ph->target; |
334 | struct Plugin *plugin = target->plugin; | 428 | struct Plugin *plugin = target->plugin; |
335 | 429 | ||
336 | GNUNET_CONTAINER_DLL_remove (target->ph_head, | 430 | GNUNET_CONTAINER_DLL_remove (target->ph_head, |
337 | target->ph_tail, | 431 | target->ph_tail, |
338 | ph); | 432 | ph); |
@@ -390,7 +484,6 @@ ip_send (void *cls, | |||
390 | } | 484 | } |
391 | 485 | ||
392 | 486 | ||
393 | |||
394 | /** | 487 | /** |
395 | * Method called whenever a given peer connects. | 488 | * Method called whenever a given peer connects. |
396 | * | 489 | * |
@@ -448,6 +541,52 @@ core_disconnect_cb (void *cls, | |||
448 | 541 | ||
449 | 542 | ||
450 | /** | 543 | /** |
544 | * Find the @a hello for our identity and then pass | ||
545 | * it to the DHT as a URL. Note that we only | ||
546 | * add addresses, never remove them, due to limitations | ||
547 | * of the current peerinfo/core/transport APIs. | ||
548 | * This will change with TNG. | ||
549 | * | ||
550 | * @param cls a `struct Plugin` | ||
551 | * @param peer id of the peer, NULL for last call | ||
552 | * @param hello hello message for the peer (can be NULL) | ||
553 | * @param error message | ||
554 | */ | ||
555 | static void | ||
556 | peerinfo_cb (void *cls, | ||
557 | const struct GNUNET_PeerIdentity *peer, | ||
558 | const struct GNUNET_HELLO_Message *hello, | ||
559 | const char *err_msg) | ||
560 | { | ||
561 | struct Plugin *plugin = cls; | ||
562 | char *addr; | ||
563 | |||
564 | if (NULL == hello) | ||
565 | return; | ||
566 | if (NULL == peer) | ||
567 | return; | ||
568 | if (0 != | ||
569 | GNUNET_memcmp (peer, | ||
570 | &plugin->my_identity)) | ||
571 | return; | ||
572 | addr = GNUNET_HELLO_compose_uri (hello, | ||
573 | &GPI_plugins_find); | ||
574 | if (NULL == addr) | ||
575 | return; | ||
576 | GNUNET_CRYPTO_hash (&plugin->my_identity, | ||
577 | sizeof (struct GNUNET_PeerIdentity), | ||
578 | &plugin->src.my_id.hc); | ||
579 | plugin->env->address_add_cb (plugin->env->cls, | ||
580 | &plugin->src.my_id, | ||
581 | &plugin->src.pk, | ||
582 | addr, | ||
583 | &plugin->src, | ||
584 | &plugin->src.app_ctx); | ||
585 | GNUNET_free (addr); | ||
586 | } | ||
587 | |||
588 | |||
589 | /** | ||
451 | * Function called after #GNUNET_CORE_connect has succeeded (or failed | 590 | * Function called after #GNUNET_CORE_connect has succeeded (or failed |
452 | * for good). Note that the private key of the peer is intentionally | 591 | * for good). Note that the private key of the peer is intentionally |
453 | * not exposed here; if you need it, your process should try to read | 592 | * not exposed here; if you need it, your process should try to read |
@@ -464,27 +603,12 @@ core_init_cb (void *cls, | |||
464 | const struct GNUNET_PeerIdentity *my_identity) | 603 | const struct GNUNET_PeerIdentity *my_identity) |
465 | { | 604 | { |
466 | struct Plugin *plugin = cls; | 605 | struct Plugin *plugin = cls; |
467 | char *addr; | 606 | |
468 | char *pid; | 607 | plugin->my_identity = *my_identity; |
469 | 608 | plugin->nc = GNUNET_PEERINFO_notify (plugin->env->cfg, | |
470 | // FIXME: to later ask ATS/TRANSPORT to 'connect' we need a HELLO, | 609 | GNUNET_NO, |
471 | // not merely a vanilla PID... | 610 | &peerinfo_cb, |
472 | pid = GNUNET_STRINGS_data_to_string_alloc (my_identity, | 611 | plugin); |
473 | sizeof (struct GNUNET_PeerIdentity)); | ||
474 | GNUNET_asprintf (&addr, | ||
475 | "gnunet-core-v15://%s/", | ||
476 | pid); | ||
477 | GNUNET_free (pid); | ||
478 | GNUNET_CRYPTO_hash (my_identity, | ||
479 | sizeof (struct GNUNET_PeerIdentity), | ||
480 | &plugin->src.my_id.hc); | ||
481 | plugin->env->address_add_cb (plugin->env->cls, | ||
482 | &plugin->src.my_id, | ||
483 | &plugin->src.pk, | ||
484 | addr, | ||
485 | &plugin->src, | ||
486 | &plugin->src.app_ctx); | ||
487 | GNUNET_free (addr); | ||
488 | } | 612 | } |
489 | 613 | ||
490 | 614 | ||
@@ -561,13 +685,25 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls) | |||
561 | { | 685 | { |
562 | struct GNUNET_DHTU_PluginFunctions *api = cls; | 686 | struct GNUNET_DHTU_PluginFunctions *api = cls; |
563 | struct Plugin *plugin = api->cls; | 687 | struct Plugin *plugin = api->cls; |
688 | struct HelloHandle *hh; | ||
564 | 689 | ||
690 | while (NULL != (hh = plugin->hh_head)) | ||
691 | { | ||
692 | GNUNET_CONTAINER_DLL_remove (plugin->hh_head, | ||
693 | plugin->hh_tail, | ||
694 | hh); | ||
695 | GNUNET_TRANSPORT_offer_hello_cancel (hh->ohh); | ||
696 | GNUNET_free (hh); | ||
697 | } | ||
565 | if (NULL != plugin->nse) | 698 | if (NULL != plugin->nse) |
566 | GNUNET_NSE_disconnect (plugin->nse); | 699 | GNUNET_NSE_disconnect (plugin->nse); |
567 | if (NULL != plugin->core) | 700 | if (NULL != plugin->core) |
568 | GNUNET_CORE_disconnect (plugin->core); | 701 | GNUNET_CORE_disconnect (plugin->core); |
569 | if (NULL != plugin->ats) | 702 | if (NULL != plugin->ats) |
570 | GNUNET_ATS_connectivity_done (plugin->ats); | 703 | GNUNET_ATS_connectivity_done (plugin->ats); |
704 | if (NULL != plugin->nc) | ||
705 | GNUNET_PEERINFO_notify_cancel (plugin->nc); | ||
706 | GPI_plugins_unload (); | ||
571 | GNUNET_free (plugin); | 707 | GNUNET_free (plugin); |
572 | GNUNET_free (api); | 708 | GNUNET_free (api); |
573 | return NULL; | 709 | return NULL; |
@@ -594,7 +730,7 @@ libgnunet_plugin_dhtu_ip_init (void *cls) | |||
594 | GNUNET_MQ_handler_end () | 730 | GNUNET_MQ_handler_end () |
595 | }; | 731 | }; |
596 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; | 732 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; |
597 | 733 | ||
598 | pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg); | 734 | pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg); |
599 | if (NULL == pk) | 735 | if (NULL == pk) |
600 | { | 736 | { |
@@ -631,7 +767,6 @@ libgnunet_plugin_dhtu_ip_init (void *cls) | |||
631 | libgnunet_plugin_dhtu_gnunet_done (plugin); | 767 | libgnunet_plugin_dhtu_gnunet_done (plugin); |
632 | return NULL; | 768 | return NULL; |
633 | } | 769 | } |
770 | GPI_plugins_load (env->cfg); | ||
634 | return api; | 771 | return api; |
635 | } | 772 | } |
636 | |||
637 | |||
diff --git a/src/dhtu/test_dhtu_ip.c b/src/dhtu/test_dhtu_ip.c new file mode 100644 index 000000000..c9528053f --- /dev/null +++ b/src/dhtu/test_dhtu_ip.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file dhtu/test_dhtu_ip.c | ||
23 | * @brief Test case for the DHTU implementation for IP | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | ||
31 | |||
32 | #define CONFIG_FILE "test_dhtu_ip.conf" | ||
33 | |||
34 | |||
35 | int | ||
36 | main (int argc, | ||
37 | char *const *argv) | ||
38 | { | ||
39 | struct GNUNET_TESTING_Command commands[] = { | ||
40 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", | ||
41 | CONFIG_FILE), | ||
42 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | ||
43 | CONFIG_FILE), | ||
44 | GNUNET_TESTING_cmd_end () | ||
45 | }; | ||
46 | |||
47 | return GNUNET_TESTING_main (NULL, | ||
48 | commands, | ||
49 | TIMEOUT); | ||
50 | } | ||
diff --git a/src/dhtu/testing_dhtu_cmd_send.c b/src/dhtu/testing_dhtu_cmd_send.c new file mode 100644 index 000000000..e620e329e --- /dev/null +++ b/src/dhtu/testing_dhtu_cmd_send.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_dhtu_cmd_send.c | ||
23 | * @brief use DHTU to send a message | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | |||
29 | |||
30 | /** | ||
31 | * State for the 'send' command. | ||
32 | */ | ||
33 | struct SendState | ||
34 | { | ||
35 | |||
36 | /** | ||
37 | * Mandatory context for async commands. | ||
38 | */ | ||
39 | struct GNUNET_TESTING_AsyncContext ac; | ||
40 | |||
41 | }; | ||
42 | |||
43 | |||
44 | /** | ||
45 | * | ||
46 | * | ||
47 | * @param cls a `struct SendState` | ||
48 | */ | ||
49 | static void | ||
50 | send_cleanup (void *cls) | ||
51 | { | ||
52 | struct SendState *ss = cls; | ||
53 | |||
54 | GNUNET_free (ss); | ||
55 | } | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Return trains of the ``send`` command. | ||
60 | * | ||
61 | * @param cls closure. | ||
62 | * @param[out] ret result | ||
63 | * @param trait name of the trait. | ||
64 | * @param index index number of the object to offer. | ||
65 | * @return #GNUNET_OK on success. | ||
66 | * #GNUNET_NO if no trait was found | ||
67 | */ | ||
68 | static enum GNUNET_GenericReturnValue | ||
69 | send_traits (void *cls, | ||
70 | const void **ret, | ||
71 | const char *trait, | ||
72 | unsigned int index) | ||
73 | { | ||
74 | return GNUNET_NO; | ||
75 | } | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Run the 'send' command. | ||
80 | * | ||
81 | * @param cls closure. | ||
82 | * @param is interpreter state. | ||
83 | */ | ||
84 | static void | ||
85 | send_run (void *cls, | ||
86 | struct GNUNET_TESTING_Interpreter *is) | ||
87 | { | ||
88 | struct SendState *ss = cls; | ||
89 | |||
90 | #if 0 | ||
91 | other_cmd = GNUNET_TESTING_interpreter_lookup_command (ss->other_label); | ||
92 | GNUNET_TESTING_get_trait_XXX (other_cmd, | ||
93 | &data); | ||
94 | #endif | ||
95 | GNUNET_TESTING_async_finish (&ss->ac); | ||
96 | } | ||
97 | |||
98 | |||
99 | struct GNUNET_TESTING_Command | ||
100 | GNUNET_TESTING_DHTU_cmd_send (const char *label) | ||
101 | { | ||
102 | struct SendState *ss; | ||
103 | |||
104 | ss = GNUNET_new (struct SendState); | ||
105 | |||
106 | { | ||
107 | struct GNUNET_TESTING_Command cmd = { | ||
108 | .cls = ss, | ||
109 | .label = label, | ||
110 | .run = &send_run, | ||
111 | .ac = &ss->ac, | ||
112 | .cleanup = &send_cleanup, | ||
113 | .traits = &send_traits | ||
114 | }; | ||
115 | |||
116 | return cmd; | ||
117 | } | ||
118 | } | ||
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 5b6ba2376..3d8ec2bac 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -21,9 +21,7 @@ lib_LTLIBRARIES = libgnunetfs.la | |||
21 | plugin_LTLIBRARIES = \ | 21 | plugin_LTLIBRARIES = \ |
22 | libgnunet_plugin_block_fs.la | 22 | libgnunet_plugin_block_fs.la |
23 | 23 | ||
24 | if HAVE_TESTING | ||
25 | noinst_LIBRARIES = libgnunetfstest.a | 24 | noinst_LIBRARIES = libgnunetfstest.a |
26 | endif | ||
27 | 25 | ||
28 | libgnunetfs_la_SOURCES = \ | 26 | libgnunetfs_la_SOURCES = \ |
29 | fs_api.c fs_api.h fs.h \ | 27 | fs_api.c fs_api.h fs.h \ |
@@ -71,11 +69,9 @@ libexec_PROGRAMS = \ | |||
71 | gnunet-helper-fs-publish \ | 69 | gnunet-helper-fs-publish \ |
72 | gnunet-service-fs | 70 | gnunet-service-fs |
73 | 71 | ||
74 | if HAVE_TESTING | ||
75 | noinst_PROGRAMS = \ | 72 | noinst_PROGRAMS = \ |
76 | gnunet-fs-profiler \ | 73 | gnunet-fs-profiler \ |
77 | gnunet-daemon-fsprofiler | 74 | gnunet-daemon-fsprofiler |
78 | endif | ||
79 | 75 | ||
80 | bin_PROGRAMS = \ | 76 | bin_PROGRAMS = \ |
81 | gnunet-auto-share \ | 77 | gnunet-auto-share \ |
@@ -230,7 +226,6 @@ if HAVE_BENCHMARKS | |||
230 | perf_gnunet_service_fs_p2p_respect | 226 | perf_gnunet_service_fs_p2p_respect |
231 | endif | 227 | endif |
232 | 228 | ||
233 | if HAVE_TESTING | ||
234 | check_PROGRAMS = \ | 229 | check_PROGRAMS = \ |
235 | test_plugin_block_fs \ | 230 | test_plugin_block_fs \ |
236 | test_fs_directory \ | 231 | test_fs_directory \ |
@@ -258,7 +253,6 @@ check_PROGRAMS = \ | |||
258 | test_gnunet_service_fs_p2p \ | 253 | test_gnunet_service_fs_p2p \ |
259 | test_gnunet_service_fs_p2p_cadet \ | 254 | test_gnunet_service_fs_p2p_cadet \ |
260 | $(FS_BENCHMARKS) | 255 | $(FS_BENCHMARKS) |
261 | endif | ||
262 | 256 | ||
263 | test_plugin_block_fs_SOURCES = \ | 257 | test_plugin_block_fs_SOURCES = \ |
264 | test_plugin_block_fs.c | 258 | test_plugin_block_fs.c |
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am index e806f0059..59ace6c41 100644 --- a/src/identity/Makefile.am +++ b/src/identity/Makefile.am | |||
@@ -67,11 +67,9 @@ gnunet_identity_LDADD = \ | |||
67 | $(top_builddir)/src/util/libgnunetutil.la \ | 67 | $(top_builddir)/src/util/libgnunetutil.la \ |
68 | $(GN_LIBINTL) | 68 | $(GN_LIBINTL) |
69 | 69 | ||
70 | if HAVE_TESTING | ||
71 | check_PROGRAMS = \ | 70 | check_PROGRAMS = \ |
72 | test_identity \ | 71 | test_identity \ |
73 | test_identity_defaults | 72 | test_identity_defaults |
74 | endif | ||
75 | 73 | ||
76 | if ENABLE_TEST_RUN | 74 | if ENABLE_TEST_RUN |
77 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 75 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index ae73c9d40..e754756e5 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -821,7 +821,8 @@ GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | |||
821 | * @param cls closure | 821 | * @param cls closure |
822 | * @param res resulting hash, NULL on error | 822 | * @param res resulting hash, NULL on error |
823 | */ | 823 | */ |
824 | typedef void (*GNUNET_CRYPTO_HashCompletedCallback) ( | 824 | typedef void |
825 | (*GNUNET_CRYPTO_HashCompletedCallback) ( | ||
825 | void *cls, | 826 | void *cls, |
826 | const struct GNUNET_HashCode *res); | 827 | const struct GNUNET_HashCode *res); |
827 | 828 | ||
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index 5d7155a3d..b54567aa7 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020 GNUnet e.V. | 3 | Copyright (C) 2020--2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -527,7 +527,8 @@ enum GNUNET_MESSENGER_MessageFlags | |||
527 | * @param[in/out] handle Messenger handle | 527 | * @param[in/out] handle Messenger handle |
528 | */ | 528 | */ |
529 | typedef void | 529 | typedef void |
530 | (*GNUNET_MESSENGER_IdentityCallback) (void *cls, struct GNUNET_MESSENGER_Handle *handle); | 530 | (*GNUNET_MESSENGER_IdentityCallback) (void *cls, |
531 | struct GNUNET_MESSENGER_Handle *handle); | ||
531 | 532 | ||
532 | /** | 533 | /** |
533 | * Method called whenever a message is sent or received from a <i>room</i>. | 534 | * Method called whenever a message is sent or received from a <i>room</i>. |
@@ -543,7 +544,8 @@ typedef void | |||
543 | * @param[in] flags Flags of the message | 544 | * @param[in] flags Flags of the message |
544 | */ | 545 | */ |
545 | typedef void | 546 | typedef void |
546 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, | 547 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, |
548 | struct GNUNET_MESSENGER_Room *room, | ||
547 | const struct GNUNET_MESSENGER_Contact *sender, | 549 | const struct GNUNET_MESSENGER_Contact *sender, |
548 | const struct GNUNET_MESSENGER_Message *message, | 550 | const struct GNUNET_MESSENGER_Message *message, |
549 | const struct GNUNET_HashCode *hash, | 551 | const struct GNUNET_HashCode *hash, |
@@ -558,7 +560,8 @@ typedef void | |||
558 | * @param[in] contact Contact handle | 560 | * @param[in] contact Contact handle |
559 | */ | 561 | */ |
560 | typedef int | 562 | typedef int |
561 | (*GNUNET_MESSENGER_MemberCallback) (void* cls, struct GNUNET_MESSENGER_Room *room, | 563 | (*GNUNET_MESSENGER_MemberCallback) (void* cls, |
564 | struct GNUNET_MESSENGER_Room *room, | ||
562 | const struct GNUNET_MESSENGER_Contact *contact); | 565 | const struct GNUNET_MESSENGER_Contact *contact); |
563 | 566 | ||
564 | /** | 567 | /** |
@@ -574,9 +577,12 @@ typedef int | |||
574 | * @return Messenger handle to use, NULL on error | 577 | * @return Messenger handle to use, NULL on error |
575 | */ | 578 | */ |
576 | struct GNUNET_MESSENGER_Handle* | 579 | struct GNUNET_MESSENGER_Handle* |
577 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, | 580 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
578 | GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, | 581 | const char *name, |
579 | GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls); | 582 | GNUNET_MESSENGER_IdentityCallback identity_callback, |
583 | void *identity_cls, | ||
584 | GNUNET_MESSENGER_MessageCallback msg_callback, | ||
585 | void *msg_cls); | ||
580 | 586 | ||
581 | /** | 587 | /** |
582 | * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All | 588 | * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All |
@@ -619,7 +625,8 @@ GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); | |||
619 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | 625 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL |
620 | */ | 626 | */ |
621 | int | 627 | int |
622 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name); | 628 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, |
629 | const char *name); | ||
623 | 630 | ||
624 | /** | 631 | /** |
625 | * Get the public key used by the messenger or NULL if the anonymous key was used. | 632 | * Get the public key used by the messenger or NULL if the anonymous key was used. |
@@ -647,7 +654,8 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | |||
647 | * @return Room handle, NULL on error | 654 | * @return Room handle, NULL on error |
648 | */ | 655 | */ |
649 | struct GNUNET_MESSENGER_Room* | 656 | struct GNUNET_MESSENGER_Room* |
650 | GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | 657 | GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, |
658 | const struct GNUNET_HashCode *key); | ||
651 | 659 | ||
652 | /** | 660 | /** |
653 | * Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room. | 661 | * Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room. |
@@ -668,7 +676,8 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct | |||
668 | * @return Room handle, NULL on error | 676 | * @return Room handle, NULL on error |
669 | */ | 677 | */ |
670 | struct GNUNET_MESSENGER_Room* | 678 | struct GNUNET_MESSENGER_Room* |
671 | GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, | 679 | GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, |
680 | const struct GNUNET_PeerIdentity *door, | ||
672 | const struct GNUNET_HashCode *key); | 681 | const struct GNUNET_HashCode *key); |
673 | 682 | ||
674 | /** | 683 | /** |
@@ -695,8 +704,10 @@ GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); | |||
695 | * @return Amount of rooms iterated | 704 | * @return Amount of rooms iterated |
696 | */ | 705 | */ |
697 | int | 706 | int |
698 | GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, | 707 | GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, |
699 | GNUNET_MESSENGER_MemberCallback callback, void *cls); | 708 | const struct GNUNET_MESSENGER_Contact *contact, |
709 | GNUNET_MESSENGER_MemberCallback callback, | ||
710 | void *cls); | ||
700 | 711 | ||
701 | /** | 712 | /** |
702 | * Get the key of a given <i>room</i>. | 713 | * Get the key of a given <i>room</i>. |
@@ -717,7 +728,8 @@ GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room); | |||
717 | * @return Contact handle, NULL otherwise | 728 | * @return Contact handle, NULL otherwise |
718 | */ | 729 | */ |
719 | const struct GNUNET_MESSENGER_Contact* | 730 | const struct GNUNET_MESSENGER_Contact* |
720 | GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | 731 | GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, |
732 | const struct GNUNET_HashCode *hash); | ||
721 | 733 | ||
722 | /** | 734 | /** |
723 | * Get the name used by the <i>contact</i>. | 735 | * Get the name used by the <i>contact</i>. |
@@ -756,7 +768,8 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact | |||
756 | * @param[in] contact Contact or NULL | 768 | * @param[in] contact Contact or NULL |
757 | */ | 769 | */ |
758 | void | 770 | void |
759 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, | 771 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, |
772 | const struct GNUNET_MESSENGER_Message *message, | ||
760 | const struct GNUNET_MESSENGER_Contact* contact); | 773 | const struct GNUNET_MESSENGER_Contact* contact); |
761 | 774 | ||
762 | /** | 775 | /** |
@@ -767,7 +780,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct | |||
767 | * @return Message struct or NULL if no message with that hash is known | 780 | * @return Message struct or NULL if no message with that hash is known |
768 | */ | 781 | */ |
769 | const struct GNUNET_MESSENGER_Message* | 782 | const struct GNUNET_MESSENGER_Message* |
770 | GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | 783 | GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, |
784 | const struct GNUNET_HashCode *hash); | ||
771 | 785 | ||
772 | /** | 786 | /** |
773 | * Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i> | 787 | * Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i> |
@@ -780,7 +794,8 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const st | |||
780 | * @return Amount of members iterated | 794 | * @return Amount of members iterated |
781 | */ | 795 | */ |
782 | int | 796 | int |
783 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, | 797 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, |
798 | GNUNET_MESSENGER_MemberCallback callback, | ||
784 | void* cls); | 799 | void* cls); |
785 | 800 | ||
786 | #if 0 /* keep Emacsens' auto-indent happy */ | 801 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index fe3fabbea..6a2227581 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -470,7 +470,8 @@ GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, | |||
470 | * @return array entry for the result specification to use | 470 | * @return array entry for the result specification to use |
471 | */ | 471 | */ |
472 | struct GNUNET_PQ_ResultSpec | 472 | struct GNUNET_PQ_ResultSpec |
473 | GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16); | 473 | GNUNET_PQ_result_spec_uint16 (const char *name, |
474 | uint16_t *u16); | ||
474 | 475 | ||
475 | 476 | ||
476 | /** | 477 | /** |
@@ -481,7 +482,8 @@ GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16); | |||
481 | * @return array entry for the result specification to use | 482 | * @return array entry for the result specification to use |
482 | */ | 483 | */ |
483 | struct GNUNET_PQ_ResultSpec | 484 | struct GNUNET_PQ_ResultSpec |
484 | GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32); | 485 | GNUNET_PQ_result_spec_uint32 (const char *name, |
486 | uint32_t *u32); | ||
485 | 487 | ||
486 | 488 | ||
487 | /** | 489 | /** |
@@ -492,7 +494,8 @@ GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32); | |||
492 | * @return array entry for the result specification to use | 494 | * @return array entry for the result specification to use |
493 | */ | 495 | */ |
494 | struct GNUNET_PQ_ResultSpec | 496 | struct GNUNET_PQ_ResultSpec |
495 | GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64); | 497 | GNUNET_PQ_result_spec_uint64 (const char *name, |
498 | uint64_t *u64); | ||
496 | 499 | ||
497 | 500 | ||
498 | /* ************************* pq.c functions ************************ */ | 501 | /* ************************* pq.c functions ************************ */ |
@@ -641,11 +644,11 @@ GNUNET_PQ_eval_prepared_multi_select (struct GNUNET_PQ_Context *db, | |||
641 | * codes to `enum GNUNET_DB_QueryStatus`. | 644 | * codes to `enum GNUNET_DB_QueryStatus`. |
642 | */ | 645 | */ |
643 | enum GNUNET_DB_QueryStatus | 646 | enum GNUNET_DB_QueryStatus |
644 | GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db, | 647 | GNUNET_PQ_eval_prepared_singleton_select ( |
645 | const char *statement_name, | 648 | struct GNUNET_PQ_Context *db, |
646 | const struct | 649 | const char *statement_name, |
647 | GNUNET_PQ_QueryParam *params, | 650 | const struct GNUNET_PQ_QueryParam *params, |
648 | struct GNUNET_PQ_ResultSpec *rs); | 651 | struct GNUNET_PQ_ResultSpec *rs); |
649 | 652 | ||
650 | 653 | ||
651 | /* ******************** pq_prepare.c functions ************** */ | 654 | /* ******************** pq_prepare.c functions ************** */ |
@@ -772,7 +775,7 @@ GNUNET_PQ_make_try_execute (const char *sql); | |||
772 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) | 775 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) |
773 | * #GNUNET_SYSERR on error | 776 | * #GNUNET_SYSERR on error |
774 | */ | 777 | */ |
775 | int | 778 | enum GNUNET_GenericReturnValue |
776 | GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, | 779 | GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, |
777 | const struct GNUNET_PQ_ExecuteStatement *es); | 780 | const struct GNUNET_PQ_ExecuteStatement *es); |
778 | 781 | ||
@@ -781,6 +784,29 @@ GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, | |||
781 | 784 | ||
782 | 785 | ||
783 | /** | 786 | /** |
787 | * Flags to control PQ operation. | ||
788 | */ | ||
789 | enum GNUNET_PQ_Options | ||
790 | { | ||
791 | /** | ||
792 | * Traditional default. Do nothing special. | ||
793 | */ | ||
794 | GNUNET_PQ_FLAG_NONE = 0, | ||
795 | |||
796 | /** | ||
797 | * Dropping database. Do not attempt to initialize | ||
798 | * versioning schema if not present. | ||
799 | */ | ||
800 | GNUNET_PQ_FLAG_DROP = 1, | ||
801 | |||
802 | /** | ||
803 | * Check database version is current. Fail to connect if it is not. | ||
804 | */ | ||
805 | GNUNET_PQ_FLAG_CHECK_CURRENT = 2 | ||
806 | }; | ||
807 | |||
808 | |||
809 | /** | ||
784 | * Create a connection to the Postgres database using @a config_str for the | 810 | * Create a connection to the Postgres database using @a config_str for the |
785 | * configuration. Initialize logging via GNUnet's log routines and disable | 811 | * configuration. Initialize logging via GNUnet's log routines and disable |
786 | * Postgres's logger. Also ensures that the statements in @a load_path and @a | 812 | * Postgres's logger. Also ensures that the statements in @a load_path and @a |
@@ -810,6 +836,37 @@ GNUNET_PQ_connect (const char *config_str, | |||
810 | 836 | ||
811 | 837 | ||
812 | /** | 838 | /** |
839 | * Create a connection to the Postgres database using @a config_str for the | ||
840 | * configuration. Initialize logging via GNUnet's log routines and disable | ||
841 | * Postgres's logger. Also ensures that the statements in @a load_path and @a | ||
842 | * es are executed whenever we (re)connect to the database, and that the | ||
843 | * prepared statements in @a ps are "ready". If statements in @es fail that | ||
844 | * were created with #GNUNET_PQ_make_execute(), then the entire operation | ||
845 | * fails. | ||
846 | * | ||
847 | * In @a load_path, a list of "$XXXX.sql" files is expected where $XXXX | ||
848 | * must be a sequence of contiguous integer values starting at 0000. | ||
849 | * These files are then loaded in sequence using "psql $config_str" before | ||
850 | * running statements from @e es. The directory is inspected again on | ||
851 | * reconnect. | ||
852 | * | ||
853 | * @param config_str configuration to use | ||
854 | * @param load_path path to directory with SQL transactions to run, can be NULL | ||
855 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated | ||
856 | * array of statements to execute upon EACH connection, can be NULL | ||
857 | * @param ps array of prepared statements to prepare, can be NULL | ||
858 | * @param flags connection flags | ||
859 | * @return NULL on error | ||
860 | */ | ||
861 | struct GNUNET_PQ_Context * | ||
862 | GNUNET_PQ_connect2 (const char *config_str, | ||
863 | const char *load_path, | ||
864 | const struct GNUNET_PQ_ExecuteStatement *es, | ||
865 | const struct GNUNET_PQ_PreparedStatement *ps, | ||
866 | enum GNUNET_PQ_Options flags); | ||
867 | |||
868 | |||
869 | /** | ||
813 | * Connect to a postgres database using the configuration | 870 | * Connect to a postgres database using the configuration |
814 | * option "CONFIG" in @a section. Also ensures that the | 871 | * option "CONFIG" in @a section. Also ensures that the |
815 | * statements in @a es are executed whenever we (re)connect to the | 872 | * statements in @a es are executed whenever we (re)connect to the |
@@ -835,6 +892,33 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
835 | 892 | ||
836 | 893 | ||
837 | /** | 894 | /** |
895 | * Connect to a postgres database using the configuration | ||
896 | * option "CONFIG" in @a section. Also ensures that the | ||
897 | * statements in @a es are executed whenever we (re)connect to the | ||
898 | * database, and that the prepared statements in @a ps are "ready". | ||
899 | * | ||
900 | * The caller does not have to ensure that @a es and @a ps remain allocated | ||
901 | * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made. | ||
902 | * | ||
903 | * @param cfg configuration | ||
904 | * @param section configuration section to use to get Postgres configuration options | ||
905 | * @param load_path_suffix suffix to append to the SQL_DIR in the configuration | ||
906 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated | ||
907 | * array of statements to execute upon EACH connection, can be NULL | ||
908 | * @param ps array of prepared statements to prepare, can be NULL | ||
909 | * @param flags connection flags | ||
910 | * @return the postgres handle, NULL on error | ||
911 | */ | ||
912 | struct GNUNET_PQ_Context * | ||
913 | GNUNET_PQ_connect_with_cfg2 (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
914 | const char *section, | ||
915 | const char *load_path_suffix, | ||
916 | const struct GNUNET_PQ_ExecuteStatement *es, | ||
917 | const struct GNUNET_PQ_PreparedStatement *ps, | ||
918 | enum GNUNET_PQ_Options flags); | ||
919 | |||
920 | |||
921 | /** | ||
838 | * Reinitialize the database @a db if the connection is down. | 922 | * Reinitialize the database @a db if the connection is down. |
839 | * | 923 | * |
840 | * @param db database connection to reinitialize | 924 | * @param db database connection to reinitialize |
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h index acb444de4..888c6e391 100644 --- a/src/include/gnunet_testbed_service.h +++ b/src/include/gnunet_testbed_service.h | |||
@@ -139,24 +139,6 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
139 | 139 | ||
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Loads the set of host allocated by the LoadLeveler Job Scheduler. This | ||
143 | * function is only available when compiled with support for LoadLeveler and is | ||
144 | * used for running on the SuperMUC | ||
145 | * | ||
146 | * @param cfg the configuration to use as a template while starting a controller | ||
147 | * on any of the loaded hosts. Operation queue sizes specific to a host | ||
148 | * are also read from this configuration handle | ||
149 | * @param hosts set to the hosts found in the file; caller must free this if | ||
150 | * number of hosts returned is greater than 0 | ||
151 | * @return number of hosts returned in 'hosts', 0 on error | ||
152 | */ | ||
153 | unsigned int | ||
154 | GNUNET_TESTBED_hosts_load_from_loadleveler (const struct | ||
155 | GNUNET_CONFIGURATION_Handle *cfg, | ||
156 | struct GNUNET_TESTBED_Host | ||
157 | ***hosts); | ||
158 | |||
159 | /** | ||
160 | * Destroy a host handle. Must only be called once everything | 142 | * Destroy a host handle. Must only be called once everything |
161 | * running on that host has been stopped. | 143 | * running on that host has been stopped. |
162 | * | 144 | * |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 6138f567b..96e9af252 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -49,6 +49,7 @@ | |||
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Router of a network namespace. | 51 | * Router of a network namespace. |
52 | * // FIXME: this does not belong here! | ||
52 | */ | 53 | */ |
53 | struct GNUNET_TESTING_NetjailRouter | 54 | struct GNUNET_TESTING_NetjailRouter |
54 | { | 55 | { |
@@ -63,8 +64,10 @@ struct GNUNET_TESTING_NetjailRouter | |||
63 | unsigned int udp_port; | 64 | unsigned int udp_port; |
64 | }; | 65 | }; |
65 | 66 | ||
67 | |||
66 | /** | 68 | /** |
67 | * Enum for the different types of nodes. | 69 | * Enum for the different types of nodes. |
70 | * // FIXME: this does not belong here! | ||
68 | */ | 71 | */ |
69 | enum GNUNET_TESTING_NODE_TYPE | 72 | enum GNUNET_TESTING_NODE_TYPE |
70 | { | 73 | { |
@@ -79,6 +82,8 @@ enum GNUNET_TESTING_NODE_TYPE | |||
79 | GNUNET_TESTING_GLOBAL_NODE | 82 | GNUNET_TESTING_GLOBAL_NODE |
80 | }; | 83 | }; |
81 | 84 | ||
85 | |||
86 | // FIXME: this does not belong here! | ||
82 | struct GNUNET_TESTING_AddressPrefix | 87 | struct GNUNET_TESTING_AddressPrefix |
83 | { | 88 | { |
84 | /** | 89 | /** |
@@ -97,10 +102,13 @@ struct GNUNET_TESTING_AddressPrefix | |||
97 | char *address_prefix; | 102 | char *address_prefix; |
98 | }; | 103 | }; |
99 | 104 | ||
105 | |||
106 | // FIXME: this does not belong here! | ||
100 | struct GNUNET_TESTING_NetjailNode; | 107 | struct GNUNET_TESTING_NetjailNode; |
101 | 108 | ||
102 | /** | 109 | /** |
103 | * Connection to another node. | 110 | * Connection to another node. |
111 | * // FIXME: this does not belong here! | ||
104 | */ | 112 | */ |
105 | struct GNUNET_TESTING_NodeConnection | 113 | struct GNUNET_TESTING_NodeConnection |
106 | { | 114 | { |
@@ -148,6 +156,7 @@ struct GNUNET_TESTING_NodeConnection | |||
148 | 156 | ||
149 | /** | 157 | /** |
150 | * Node in the netjail topology. | 158 | * Node in the netjail topology. |
159 | * // FIXME: this does not belong here! | ||
151 | */ | 160 | */ |
152 | struct GNUNET_TESTING_NetjailNode | 161 | struct GNUNET_TESTING_NetjailNode |
153 | { | 162 | { |
@@ -185,6 +194,7 @@ struct GNUNET_TESTING_NetjailNode | |||
185 | 194 | ||
186 | /** | 195 | /** |
187 | * Namespace in a topology. | 196 | * Namespace in a topology. |
197 | * // FIXME: this does not belong here! | ||
188 | */ | 198 | */ |
189 | struct GNUNET_TESTING_NetjailNamespace | 199 | struct GNUNET_TESTING_NetjailNamespace |
190 | { | 200 | { |
@@ -206,6 +216,7 @@ struct GNUNET_TESTING_NetjailNamespace | |||
206 | 216 | ||
207 | /** | 217 | /** |
208 | * Toplogy of our netjail setup. | 218 | * Toplogy of our netjail setup. |
219 | * // FIXME: this does not belong here! | ||
209 | */ | 220 | */ |
210 | struct GNUNET_TESTING_NetjailTopology | 221 | struct GNUNET_TESTING_NetjailTopology |
211 | { | 222 | { |
@@ -251,6 +262,36 @@ struct GNUNET_TESTING_NetjailTopology | |||
251 | struct GNUNET_TESTING_Interpreter; | 262 | struct GNUNET_TESTING_Interpreter; |
252 | 263 | ||
253 | /** | 264 | /** |
265 | * State each asynchronous command must have in its closure. | ||
266 | */ | ||
267 | struct GNUNET_TESTING_AsyncContext | ||
268 | { | ||
269 | |||
270 | /** | ||
271 | * Interpreter we are part of. | ||
272 | */ | ||
273 | struct GNUNET_TESTING_Interpreter *is; | ||
274 | |||
275 | /** | ||
276 | * Function to call when done. | ||
277 | */ | ||
278 | GNUNET_SCHEDULER_TaskCallback cont; | ||
279 | |||
280 | /** | ||
281 | * Closure for @e cont. | ||
282 | */ | ||
283 | void *cont_cls; | ||
284 | |||
285 | /** | ||
286 | * Indication if the command finished (#GNUNET_OK). | ||
287 | * #GNUNET_NO if it is still running, | ||
288 | * #GNUNET_SYSERR if it failed. | ||
289 | */ | ||
290 | enum GNUNET_GenericReturnValue finished; | ||
291 | }; | ||
292 | |||
293 | |||
294 | /** | ||
254 | * A command to be run by the interpreter. | 295 | * A command to be run by the interpreter. |
255 | */ | 296 | */ |
256 | struct GNUNET_TESTING_Command | 297 | struct GNUNET_TESTING_Command |
@@ -279,57 +320,43 @@ struct GNUNET_TESTING_Command | |||
279 | * the asynchronous activity to terminate. | 320 | * the asynchronous activity to terminate. |
280 | * | 321 | * |
281 | * @param cls closure | 322 | * @param cls closure |
282 | * @param cmd command being run | 323 | * @param is interpreter state |
283 | * @param i interpreter state | ||
284 | */ | 324 | */ |
285 | void | 325 | void |
286 | (*run)(void *cls, | 326 | (*run)(void *cls, |
287 | const struct GNUNET_TESTING_Command *cmd, | 327 | struct GNUNET_TESTING_Interpreter *is); |
288 | struct GNUNET_TESTING_Interpreter *i); | ||
289 | 328 | ||
290 | /** | 329 | /** |
291 | * Wait for any asynchronous execution of @e run to conclude, | 330 | * Pointer to the asynchronous context in the command's |
292 | * then call finish_cont. Finish may only be called once per command. | 331 | * closure. Used by the |
293 | * | 332 | * #GNUNET_TESTING_async_finish() and |
294 | * This member may be NULL if this command is a synchronous command, | 333 | * #GNUNET_TESTING_async_fail() functions. |
295 | * and also should be set to NULL once the command has finished. | ||
296 | * | 334 | * |
297 | * @param cls closure | 335 | * Must be NULL if a command is synchronous. |
298 | * @param cont function to call upon completion, can be NULL | ||
299 | * @param cont_cls closure for @a cont | ||
300 | */ | ||
301 | int | ||
302 | (*finish)(void *cls, | ||
303 | GNUNET_SCHEDULER_TaskCallback cont, | ||
304 | void *cont_cls); | ||
305 | |||
306 | /** | ||
307 | * Task for running the finish function. | ||
308 | */ | 336 | */ |
309 | struct GNUNET_SCHEDULER_Task *finish_task; | 337 | struct GNUNET_TESTING_AsyncContext *ac; |
310 | 338 | ||
311 | /** | 339 | /** |
312 | * Clean up after the command. Run during forced termination | 340 | * Clean up after the command. Run during forced termination |
313 | * (CTRL-C) or test failure or test success. | 341 | * (CTRL-C) or test failure or test success. |
314 | * | 342 | * |
315 | * @param cls closure | 343 | * @param cls closure |
316 | * @param cmd command being cleaned up | ||
317 | */ | 344 | */ |
318 | void | 345 | void |
319 | (*cleanup)(void *cls, | 346 | (*cleanup)(void *cls); |
320 | const struct GNUNET_TESTING_Command *cmd); | ||
321 | 347 | ||
322 | /** | 348 | /** |
323 | * Extract information from a command that is useful for other | 349 | * Extract information from a command that is useful for other |
324 | * commands. | 350 | * commands. Can be NULL if a command has no traits. |
325 | * | 351 | * |
326 | * @param cls closure | 352 | * @param cls closure |
327 | * @param[out] ret result (could be anything) | 353 | * @param[out] ret result (could be anything) |
328 | * @param trait name of the trait | 354 | * @param trait name of the trait |
329 | * @param index index number of the object to extract. | 355 | * @param index index number of the object to extract. |
330 | * @return #GNUNET_OK on success | 356 | * @return #GNUNET_OK on success, |
357 | * #GNUNET_NO if no trait was found | ||
331 | */ | 358 | */ |
332 | int | 359 | enum GNUNET_GenericReturnValue |
333 | (*traits)(void *cls, | 360 | (*traits)(void *cls, |
334 | const void **ret, | 361 | const void **ret, |
335 | const char *trait, | 362 | const char *trait, |
@@ -357,13 +384,6 @@ struct GNUNET_TESTING_Command | |||
357 | struct GNUNET_TIME_Absolute last_req_time; | 384 | struct GNUNET_TIME_Absolute last_req_time; |
358 | 385 | ||
359 | /** | 386 | /** |
360 | * How often did we try to execute this command? (In case it is a request | ||
361 | * that is repated.) Note that a command must have some built-in retry | ||
362 | * mechanism for this value to be useful. | ||
363 | */ | ||
364 | unsigned int num_tries; | ||
365 | |||
366 | /** | ||
367 | * In case @e asynchronous_finish is true, how long should we wait for this | 387 | * In case @e asynchronous_finish is true, how long should we wait for this |
368 | * command to complete? If @e finish did not complete after this amount of | 388 | * command to complete? If @e finish did not complete after this amount of |
369 | * time, the interpreter will fail. Should be set generously to ensure | 389 | * time, the interpreter will fail. Should be set generously to ensure |
@@ -372,6 +392,13 @@ struct GNUNET_TESTING_Command | |||
372 | struct GNUNET_TIME_Relative default_timeout; | 392 | struct GNUNET_TIME_Relative default_timeout; |
373 | 393 | ||
374 | /** | 394 | /** |
395 | * How often did we try to execute this command? (In case it is a request | ||
396 | * that is repated.) Note that a command must have some built-in retry | ||
397 | * mechanism for this value to be useful. | ||
398 | */ | ||
399 | unsigned int num_tries; | ||
400 | |||
401 | /** | ||
375 | * If "true", the interpreter should not immediately call | 402 | * If "true", the interpreter should not immediately call |
376 | * @e finish, even if @e finish is non-NULL. Otherwise, | 403 | * @e finish, even if @e finish is non-NULL. Otherwise, |
377 | * #TALER_TESTING_cmd_finish() must be used | 404 | * #TALER_TESTING_cmd_finish() must be used |
@@ -379,49 +406,19 @@ struct GNUNET_TESTING_Command | |||
379 | */ | 406 | */ |
380 | bool asynchronous_finish; | 407 | bool asynchronous_finish; |
381 | 408 | ||
382 | /** | ||
383 | * Shall the scheduler shutdown, when end cmd is reach? | ||
384 | */ | ||
385 | bool shutdown_on_end; | ||
386 | |||
387 | }; | 409 | }; |
388 | 410 | ||
389 | 411 | ||
390 | /** | 412 | /** |
391 | * Struct to use for command-specific context information closure of a command waiting | ||
392 | * for another command. | ||
393 | */ | ||
394 | struct SyncState | ||
395 | { | ||
396 | /** | ||
397 | * Closure for all commands with command-specific context information. | ||
398 | */ | ||
399 | void *cls; | ||
400 | |||
401 | /** | ||
402 | * The asynchronous command the synchronous command of this closure waits for. | ||
403 | */ | ||
404 | const struct GNUNET_TESTING_Command *async_cmd; | ||
405 | |||
406 | /** | ||
407 | * Task for running the finish method of the asynchronous task the command is waiting for. | ||
408 | */ | ||
409 | struct GNUNET_SCHEDULER_Task *finish_task; | ||
410 | |||
411 | /** | ||
412 | * When did the execution of this commands finish function start? | ||
413 | */ | ||
414 | struct GNUNET_TIME_Absolute start_finish_time; | ||
415 | }; | ||
416 | |||
417 | /** | ||
418 | * Lookup command by label. | 413 | * Lookup command by label. |
419 | * | 414 | * |
415 | * @param is interpreter to lookup command in | ||
420 | * @param label label of the command to lookup. | 416 | * @param label label of the command to lookup. |
421 | * @return the command, if it is found, or NULL. | 417 | * @return the command, if it is found, or NULL. |
422 | */ | 418 | */ |
423 | const struct GNUNET_TESTING_Command * | 419 | const struct GNUNET_TESTING_Command * |
424 | GNUNET_TESTING_interpreter_lookup_command ( | 420 | GNUNET_TESTING_interpreter_lookup_command ( |
421 | struct GNUNET_TESTING_Interpreter *is, | ||
425 | const char *label); | 422 | const char *label); |
426 | 423 | ||
427 | 424 | ||
@@ -442,25 +439,34 @@ GNUNET_TESTING_interpreter_get_current_label ( | |||
442 | * @param is interpreter state. | 439 | * @param is interpreter state. |
443 | */ | 440 | */ |
444 | void | 441 | void |
445 | GNUNET_TESTING_interpreter_fail (); | 442 | GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is); |
446 | 443 | ||
447 | 444 | ||
448 | /** | 445 | /** |
449 | * Create command array terminator. | 446 | * The asynchronous command of @a ac has failed. |
450 | * | 447 | * |
451 | * @return a end-command. | 448 | * @param ac command-specific context |
452 | */ | 449 | */ |
453 | struct GNUNET_TESTING_Command | 450 | void |
454 | GNUNET_TESTING_cmd_end (void); | 451 | GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac); |
455 | 452 | ||
456 | 453 | ||
457 | /** | 454 | /** |
458 | * Create command array terminator without shutdown. | 455 | * The asynchronous command of @a ac has finished. |
456 | * | ||
457 | * @param ac command-specific context | ||
458 | */ | ||
459 | void | ||
460 | GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac); | ||
461 | |||
462 | |||
463 | /** | ||
464 | * Create command array terminator. | ||
459 | * | 465 | * |
460 | * @return a end-command. | 466 | * @return a end-command. |
461 | */ | 467 | */ |
462 | struct GNUNET_TESTING_Command | 468 | struct GNUNET_TESTING_Command |
463 | GNUNET_TESTING_cmd_end_without_shutdown (void); | 469 | GNUNET_TESTING_cmd_end (void); |
464 | 470 | ||
465 | 471 | ||
466 | /** | 472 | /** |
@@ -469,8 +475,8 @@ GNUNET_TESTING_cmd_end_without_shutdown (void); | |||
469 | * @param cmd command to make synchronous. | 475 | * @param cmd command to make synchronous. |
470 | * @return a finish-command. | 476 | * @return a finish-command. |
471 | */ | 477 | */ |
472 | const struct GNUNET_TESTING_Command | 478 | struct GNUNET_TESTING_Command |
473 | GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd); | 479 | GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd); |
474 | 480 | ||
475 | 481 | ||
476 | /** | 482 | /** |
@@ -506,31 +512,46 @@ GNUNET_TESTING_cmd_rewind_ip (const char *label, | |||
506 | 512 | ||
507 | 513 | ||
508 | /** | 514 | /** |
509 | * Wait until we receive SIGCHLD signal. Then obtain the process trait of the | 515 | * Function called with the final result of the test. |
510 | * current command, wait on the the zombie and continue with the next command. | ||
511 | * | 516 | * |
512 | * @param is interpreter state. | 517 | * @param cls closure |
518 | * @param rv #GNUNET_OK if the test passed | ||
519 | */ | ||
520 | typedef void | ||
521 | (*GNUNET_TESTING_ResultCallback)(void *cls, | ||
522 | enum GNUNET_GenericReturnValue rv); | ||
523 | |||
524 | |||
525 | /** | ||
526 | * Run the testsuite. Note, CMDs are copied into | ||
527 | * the interpreter state because they are _usually_ | ||
528 | * defined into the "run" method that returns after | ||
529 | * having scheduled the test interpreter. | ||
530 | * | ||
531 | * @param commands the list of command to execute | ||
532 | * @param timeout how long to wait for each command to execute | ||
533 | * @param rc function to call with the final result | ||
534 | * @param rc_cls closure for @a rc | ||
513 | */ | 535 | */ |
514 | // void | 536 | void |
515 | // GNUNET_TESTING_wait_for_sigchld (struct GNUNET_TESTING_Interpreter *is); | 537 | GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, |
516 | // => replace with child_management.c | 538 | struct GNUNET_TIME_Relative timeout, |
539 | GNUNET_TESTING_ResultCallback rc, | ||
540 | void *rc_cls); | ||
517 | 541 | ||
518 | 542 | ||
519 | /** | 543 | /** |
520 | * Start scheduling loop with signal handlers and run the | 544 | * Start a GNUnet scheduler event loop and |
521 | * test suite with the @a commands. | 545 | * run the testsuite. Return 0 upon success. |
546 | * Expected to be called directly from main(). | ||
522 | * | 547 | * |
523 | * @param cfg_name name of configuration file to use | ||
524 | * @param commands the list of command to execute | 548 | * @param commands the list of command to execute |
525 | * @param timeout how long to wait for each command to execute | 549 | * @param timeout how long to wait for each command to execute |
526 | * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. | 550 | * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure |
527 | * non-GNUNET_OK codes are #GNUNET_SYSERR most of the | ||
528 | * times. | ||
529 | */ | 551 | */ |
530 | int | 552 | int |
531 | GNUNET_TESTING_run (const char *cfg_filename, | 553 | GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, |
532 | struct GNUNET_TESTING_Command *commands, | 554 | struct GNUNET_TIME_Relative timeout); |
533 | struct GNUNET_TIME_Relative timeout); | ||
534 | 555 | ||
535 | 556 | ||
536 | /** | 557 | /** |
@@ -538,6 +559,8 @@ GNUNET_TESTING_run (const char *cfg_filename, | |||
538 | * | 559 | * |
539 | * @param prog program's name to look into | 560 | * @param prog program's name to look into |
540 | * @param marker chunk to find in @a prog | 561 | * @param marker chunk to find in @a prog |
562 | * // FIXME: this does not belong here! => libgnunetutil, maybe? | ||
563 | * // FIXME: return bool? document return value! | ||
541 | */ | 564 | */ |
542 | int | 565 | int |
543 | GNUNET_TESTING_has_in_name (const char *prog, | 566 | GNUNET_TESTING_has_in_name (const char *prog, |
@@ -551,7 +574,7 @@ GNUNET_TESTING_has_in_name (const char *prog, | |||
551 | * | 574 | * |
552 | * @param label command label. | 575 | * @param label command label. |
553 | * @param process_label label of a command that has a process trait | 576 | * @param process_label label of a command that has a process trait |
554 | * @param process_index index of the process trait at @a process_label | 577 | * @param process_index index of the process trait at @a process_label // FIXME: enum? needed? |
555 | * @param signal signal to send to @a process. | 578 | * @param signal signal to send to @a process. |
556 | * @return the command. | 579 | * @return the command. |
557 | */ | 580 | */ |
@@ -590,49 +613,8 @@ GNUNET_TESTING_cmd_batch (const char *label, | |||
590 | 613 | ||
591 | 614 | ||
592 | /** | 615 | /** |
593 | * Test if this command is a batch command. | ||
594 | * | ||
595 | * @return false if not, true if it is a batch command | ||
596 | */ | ||
597 | // TODO: figure out if this needs to be exposed in the public API. | ||
598 | int | ||
599 | GNUNET_TESTING_cmd_is_batch (const struct GNUNET_TESTING_Command *cmd); | ||
600 | |||
601 | |||
602 | /** | ||
603 | * Advance internal pointer to next command. | ||
604 | * | ||
605 | * @param is interpreter state. | ||
606 | */ | ||
607 | // TODO: figure out if this needs to be exposed in the public API. | ||
608 | void | ||
609 | GNUNET_TESTING_cmd_batch_next (struct GNUNET_TESTING_Interpreter *is); | ||
610 | |||
611 | |||
612 | /** | ||
613 | * Obtain what command the batch is at. | ||
614 | * | ||
615 | * @return cmd current batch command | ||
616 | */ | ||
617 | // TODO: figure out if this needs to be exposed in the public API. | ||
618 | struct GNUNET_TESTING_Command * | ||
619 | GNUNET_TESTING_cmd_batch_get_current (const struct GNUNET_TESTING_Command *cmd); | ||
620 | |||
621 | |||
622 | /** | ||
623 | * Set what command the batch should be at. | ||
624 | * | ||
625 | * @param cmd current batch command | ||
626 | * @param new_ip where to move the IP | ||
627 | */ | ||
628 | // TODO: figure out if this needs to be exposed in the public API. | ||
629 | void | ||
630 | GNUNET_TESTING_cmd_batch_set_current (const struct GNUNET_TESTING_Command *cmd, | ||
631 | unsigned int new_ip); | ||
632 | |||
633 | |||
634 | /** | ||
635 | * Performance counter. | 616 | * Performance counter. |
617 | * // FIXME: this might not belong here! | ||
636 | */ | 618 | */ |
637 | struct GNUNET_TESTING_Timer | 619 | struct GNUNET_TESTING_Timer |
638 | { | 620 | { |
@@ -777,7 +759,7 @@ GNUNET_TESTING_trait_end (void); | |||
777 | * @param index index number of the trait to extract. | 759 | * @param index index number of the trait to extract. |
778 | * @return #GNUNET_OK when the trait is found. | 760 | * @return #GNUNET_OK when the trait is found. |
779 | */ | 761 | */ |
780 | int | 762 | enum GNUNET_GenericReturnValue |
781 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, | 763 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, |
782 | const void **ret, | 764 | const void **ret, |
783 | const char *trait, | 765 | const char *trait, |
@@ -791,12 +773,12 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, | |||
791 | * | 773 | * |
792 | * @param cmd command to extract trait from. | 774 | * @param cmd command to extract trait from. |
793 | * @param index which process to pick if @a cmd | 775 | * @param index which process to pick if @a cmd |
794 | * has multiple on offer. | 776 | * has multiple on offer. -- FIXME: remove? |
795 | * @param[out] processp set to the address of the pointer to the | 777 | * @param[out] processp set to the address of the pointer to the |
796 | * process. | 778 | * process. |
797 | * @return #GNUNET_OK on success. | 779 | * @return #GNUNET_OK on success. |
798 | */ | 780 | */ |
799 | int | 781 | enum GNUNET_GenericReturnValue |
800 | GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, | 782 | GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, |
801 | unsigned int index, | 783 | unsigned int index, |
802 | struct GNUNET_OS_Process ***processp); | 784 | struct GNUNET_OS_Process ***processp); |
@@ -806,7 +788,7 @@ GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, | |||
806 | * Offer location where a command stores a pointer to a process. | 788 | * Offer location where a command stores a pointer to a process. |
807 | * | 789 | * |
808 | * @param index offered location index number, in case there are | 790 | * @param index offered location index number, in case there are |
809 | * multiple on offer. | 791 | * multiple on offer. // FIXME: remove? |
810 | * @param processp process location to offer. | 792 | * @param processp process location to offer. |
811 | * @return the trait. | 793 | * @return the trait. |
812 | */ | 794 | */ |
@@ -818,7 +800,7 @@ GNUNET_TESTING_make_trait_process (unsigned int index, | |||
818 | /** | 800 | /** |
819 | * Offer number trait, 32-bit version. | 801 | * Offer number trait, 32-bit version. |
820 | * | 802 | * |
821 | * @param index the number's index number. | 803 | * @param index the number's index number. // FIXME: introduce enum? |
822 | * @param n number to offer. | 804 | * @param n number to offer. |
823 | */ | 805 | */ |
824 | struct GNUNET_TESTING_Trait | 806 | struct GNUNET_TESTING_Trait |
@@ -830,11 +812,11 @@ GNUNET_TESTING_make_trait_uint32 (unsigned int index, | |||
830 | * Obtain a "number" value from @a cmd, 32-bit version. | 812 | * Obtain a "number" value from @a cmd, 32-bit version. |
831 | * | 813 | * |
832 | * @param cmd command to extract the number from. | 814 | * @param cmd command to extract the number from. |
833 | * @param index the number's index number. | 815 | * @param index the number's index number. // FIXME: introduce enum? |
834 | * @param[out] n set to the number coming from @a cmd. | 816 | * @param[out] n set to the number coming from @a cmd. |
835 | * @return #GNUNET_OK on success. | 817 | * @return #GNUNET_OK on success. |
836 | */ | 818 | */ |
837 | int | 819 | enum GNUNET_GenericReturnValue |
838 | GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd, | 820 | GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd, |
839 | unsigned int index, | 821 | unsigned int index, |
840 | const uint32_t **n); | 822 | const uint32_t **n); |
@@ -843,7 +825,7 @@ GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd, | |||
843 | /** | 825 | /** |
844 | * Offer number trait, 64-bit version. | 826 | * Offer number trait, 64-bit version. |
845 | * | 827 | * |
846 | * @param index the number's index number. | 828 | * @param index the number's index number. // FIXME: introduce enum? |
847 | * @param n number to offer. | 829 | * @param n number to offer. |
848 | */ | 830 | */ |
849 | struct GNUNET_TESTING_Trait | 831 | struct GNUNET_TESTING_Trait |
@@ -855,11 +837,11 @@ GNUNET_TESTING_make_trait_uint64 (unsigned int index, | |||
855 | * Obtain a "number" value from @a cmd, 64-bit version. | 837 | * Obtain a "number" value from @a cmd, 64-bit version. |
856 | * | 838 | * |
857 | * @param cmd command to extract the number from. | 839 | * @param cmd command to extract the number from. |
858 | * @param index the number's index number. | 840 | * @param index the number's index number. // FIXME: introduce enum? |
859 | * @param[out] n set to the number coming from @a cmd. | 841 | * @param[out] n set to the number coming from @a cmd. |
860 | * @return #GNUNET_OK on success. | 842 | * @return #GNUNET_OK on success. |
861 | */ | 843 | */ |
862 | int | 844 | enum GNUNET_GenericReturnValue |
863 | GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd, | 845 | GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd, |
864 | unsigned int index, | 846 | unsigned int index, |
865 | const uint64_t **n); | 847 | const uint64_t **n); |
@@ -868,7 +850,7 @@ GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd, | |||
868 | /** | 850 | /** |
869 | * Offer number trait, 64-bit signed version. | 851 | * Offer number trait, 64-bit signed version. |
870 | * | 852 | * |
871 | * @param index the number's index number. | 853 | * @param index the number's index number. // FIXME: introduce enum? |
872 | * @param n number to offer. | 854 | * @param n number to offer. |
873 | */ | 855 | */ |
874 | struct GNUNET_TESTING_Trait | 856 | struct GNUNET_TESTING_Trait |
@@ -880,11 +862,11 @@ GNUNET_TESTING_make_trait_int64 (unsigned int index, | |||
880 | * Obtain a "number" value from @a cmd, 64-bit signed version. | 862 | * Obtain a "number" value from @a cmd, 64-bit signed version. |
881 | * | 863 | * |
882 | * @param cmd command to extract the number from. | 864 | * @param cmd command to extract the number from. |
883 | * @param index the number's index number. | 865 | * @param index the number's index number. // FIXME: introduce enum? |
884 | * @param[out] n set to the number coming from @a cmd. | 866 | * @param[out] n set to the number coming from @a cmd. |
885 | * @return #GNUNET_OK on success. | 867 | * @return #GNUNET_OK on success. |
886 | */ | 868 | */ |
887 | int | 869 | enum GNUNET_GenericReturnValue |
888 | GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd, | 870 | GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd, |
889 | unsigned int index, | 871 | unsigned int index, |
890 | const int64_t **n); | 872 | const int64_t **n); |
@@ -894,7 +876,7 @@ GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd, | |||
894 | * Offer a number. | 876 | * Offer a number. |
895 | * | 877 | * |
896 | * @param index the number's index number. | 878 | * @param index the number's index number. |
897 | * @param n the number to offer. | 879 | * @param n the number to offer. // FIXME: introduce enum? |
898 | * @return #GNUNET_OK on success. | 880 | * @return #GNUNET_OK on success. |
899 | */ | 881 | */ |
900 | struct GNUNET_TESTING_Trait | 882 | struct GNUNET_TESTING_Trait |
@@ -906,11 +888,11 @@ GNUNET_TESTING_make_trait_uint (unsigned int index, | |||
906 | * Obtain a number from @a cmd. | 888 | * Obtain a number from @a cmd. |
907 | * | 889 | * |
908 | * @param cmd command to extract the number from. | 890 | * @param cmd command to extract the number from. |
909 | * @param index the number's index number. | 891 | * @param index the number's index number. // FIXME: introduce enum? |
910 | * @param[out] n set to the number coming from @a cmd. | 892 | * @param[out] n set to the number coming from @a cmd. |
911 | * @return #GNUNET_OK on success. | 893 | * @return #GNUNET_OK on success. |
912 | */ | 894 | */ |
913 | int | 895 | enum GNUNET_GenericReturnValue |
914 | GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd, | 896 | GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd, |
915 | unsigned int index, | 897 | unsigned int index, |
916 | const unsigned int **n); | 898 | const unsigned int **n); |
@@ -920,12 +902,12 @@ GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd, | |||
920 | * | 902 | * |
921 | * @param cmd command to extract the subject from. | 903 | * @param cmd command to extract the subject from. |
922 | * @param index index number associated with the transfer | 904 | * @param index index number associated with the transfer |
923 | * subject to offer. | 905 | * subject to offer. // FIXME: introduce enum? |
924 | * @param[out] s where to write the offered | 906 | * @param[out] s where to write the offered |
925 | * string. | 907 | * string. |
926 | * @return #GNUNET_OK on success. | 908 | * @return #GNUNET_OK on success. |
927 | */ | 909 | */ |
928 | int | 910 | enum GNUNET_GenericReturnValue |
929 | GNUNET_TESTING_get_trait_string ( | 911 | GNUNET_TESTING_get_trait_string ( |
930 | const struct GNUNET_TESTING_Command *cmd, | 912 | const struct GNUNET_TESTING_Command *cmd, |
931 | unsigned int index, | 913 | unsigned int index, |
@@ -936,7 +918,7 @@ GNUNET_TESTING_get_trait_string ( | |||
936 | * Offer string subject. | 918 | * Offer string subject. |
937 | * | 919 | * |
938 | * @param index index number associated with the transfer | 920 | * @param index index number associated with the transfer |
939 | * subject being offered. | 921 | * subject being offered. // FIXME: introduce enum? |
940 | * @param s string to offer. | 922 | * @param s string to offer. |
941 | * @return the trait. | 923 | * @return the trait. |
942 | */ | 924 | */ |
@@ -950,9 +932,8 @@ GNUNET_TESTING_make_trait_string (unsigned int index, | |||
950 | * @param index always zero. Commands offering this | 932 | * @param index always zero. Commands offering this |
951 | * kind of traits do not need this index. For | 933 | * kind of traits do not need this index. For |
952 | * example, a "meta" CMD returns always the | 934 | * example, a "meta" CMD returns always the |
953 | * CMD currently being executed. | 935 | * CMD currently being executed. FIXME: remove! |
954 | * @param cmd wire details to offer. | 936 | * @param cmd wire details to offer. |
955 | * | ||
956 | * @return the trait. | 937 | * @return the trait. |
957 | */ | 938 | */ |
958 | struct GNUNET_TESTING_Trait | 939 | struct GNUNET_TESTING_Trait |
@@ -967,11 +948,11 @@ GNUNET_TESTING_make_trait_cmd (unsigned int index, | |||
967 | * @param index always zero. Commands offering this | 948 | * @param index always zero. Commands offering this |
968 | * kind of traits do not need this index. For | 949 | * kind of traits do not need this index. For |
969 | * example, a "meta" CMD returns always the | 950 | * example, a "meta" CMD returns always the |
970 | * CMD currently being executed. | 951 | * CMD currently being executed. FIXME: remove! |
971 | * @param[out] _cmd where to write the wire details. | 952 | * @param[out] _cmd where to write the wire details. |
972 | * @return #GNUNET_OK on success. | 953 | * @return #GNUNET_OK on success. |
973 | */ | 954 | */ |
974 | int | 955 | enum GNUNET_GenericReturnValue |
975 | GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, | 956 | GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, |
976 | unsigned int index, | 957 | unsigned int index, |
977 | struct GNUNET_TESTING_Command **_cmd); | 958 | struct GNUNET_TESTING_Command **_cmd); |
@@ -982,11 +963,11 @@ GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, | |||
982 | * | 963 | * |
983 | * @param cmd command to extract the uuid from. | 964 | * @param cmd command to extract the uuid from. |
984 | * @param index which amount to pick if @a cmd has multiple | 965 | * @param index which amount to pick if @a cmd has multiple |
985 | * on offer | 966 | * on offer // FIXME: introduce enum? |
986 | * @param[out] uuid where to write the uuid. | 967 | * @param[out] uuid where to write the uuid. |
987 | * @return #GNUNET_OK on success. | 968 | * @return #GNUNET_OK on success. |
988 | */ | 969 | */ |
989 | int | 970 | enum GNUNET_GenericReturnValue |
990 | GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd, | 971 | GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd, |
991 | unsigned int index, | 972 | unsigned int index, |
992 | struct GNUNET_Uuid **uuid); | 973 | struct GNUNET_Uuid **uuid); |
@@ -996,9 +977,8 @@ GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd, | |||
996 | * Offer a uuid in a trait. | 977 | * Offer a uuid in a trait. |
997 | * | 978 | * |
998 | * @param index which uuid to offer, in case there are | 979 | * @param index which uuid to offer, in case there are |
999 | * multiple available. | 980 | * multiple available. // FIXME: introduce enum? |
1000 | * @param uuid the uuid to offer. | 981 | * @param uuid the uuid to offer. |
1001 | * | ||
1002 | * @return the trait. | 982 | * @return the trait. |
1003 | */ | 983 | */ |
1004 | struct GNUNET_TESTING_Trait | 984 | struct GNUNET_TESTING_Trait |
@@ -1011,11 +991,11 @@ GNUNET_TESTING_make_trait_uuid (unsigned int index, | |||
1011 | * | 991 | * |
1012 | * @param cmd command to extract trait from | 992 | * @param cmd command to extract trait from |
1013 | * @param index which time stamp to pick if | 993 | * @param index which time stamp to pick if |
1014 | * @a cmd has multiple on offer. | 994 | * @a cmd has multiple on offer // FIXME: introduce enum? |
1015 | * @param[out] time set to the wanted WTID. | 995 | * @param[out] time set to the wanted WTID. |
1016 | * @return #GNUNET_OK on success | 996 | * @return #GNUNET_OK on success |
1017 | */ | 997 | */ |
1018 | int | 998 | enum GNUNET_GenericReturnValue |
1019 | GNUNET_TESTING_get_trait_absolute_time ( | 999 | GNUNET_TESTING_get_trait_absolute_time ( |
1020 | const struct GNUNET_TESTING_Command *cmd, | 1000 | const struct GNUNET_TESTING_Command *cmd, |
1021 | unsigned int index, | 1001 | unsigned int index, |
@@ -1064,6 +1044,9 @@ GNUNET_TESTING_make_trait_relative_time ( | |||
1064 | const struct GNUNET_TIME_Relative *time); | 1044 | const struct GNUNET_TIME_Relative *time); |
1065 | 1045 | ||
1066 | 1046 | ||
1047 | // FIXME: move these commands into a separate libgnunetestingnetjail lib or so! | ||
1048 | |||
1049 | |||
1067 | /** | 1050 | /** |
1068 | * Create command. | 1051 | * Create command. |
1069 | * | 1052 | * |
@@ -1121,40 +1104,12 @@ GNUNET_TESTING_cmd_system_destroy (const char *label, | |||
1121 | * Create command. | 1104 | * Create command. |
1122 | * | 1105 | * |
1123 | * @param label name for command. | 1106 | * @param label name for command. |
1124 | * @param local_m Number of local nodes in each namespace. | ||
1125 | * @param global_n The number of namespaces. | ||
1126 | * @return command. | ||
1127 | */ | ||
1128 | struct GNUNET_TESTING_Command | ||
1129 | GNUNET_TESTING_cmd_netjail_start (const char *label, | ||
1130 | char *local_m, | ||
1131 | char *global_n); | ||
1132 | |||
1133 | /** | ||
1134 | * Create command. | ||
1135 | * | ||
1136 | * @param label name for command. | ||
1137 | * @param topology_config Configuration file for the test topology. | 1107 | * @param topology_config Configuration file for the test topology. |
1138 | * @return command. | 1108 | * @return command. |
1139 | */ | 1109 | */ |
1140 | struct GNUNET_TESTING_Command | 1110 | struct GNUNET_TESTING_Command |
1141 | GNUNET_TESTING_cmd_netjail_start_v2 (const char *label, | 1111 | GNUNET_TESTING_cmd_netjail_start (const char *label, |
1142 | char *topology_config); | 1112 | char *topology_config); |
1143 | |||
1144 | |||
1145 | /** | ||
1146 | * Create command. | ||
1147 | * | ||
1148 | * @param label name for command. | ||
1149 | * @param binaryname to exec. | ||
1150 | * @return command. | ||
1151 | */ | ||
1152 | struct GNUNET_TESTING_Command | ||
1153 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | ||
1154 | char *local_m, | ||
1155 | char *global_n, | ||
1156 | char *plugin_name, | ||
1157 | unsigned int *rv); | ||
1158 | 1113 | ||
1159 | 1114 | ||
1160 | /** | 1115 | /** |
@@ -1166,22 +1121,20 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | |||
1166 | * @return command. | 1121 | * @return command. |
1167 | */ | 1122 | */ |
1168 | struct GNUNET_TESTING_Command | 1123 | struct GNUNET_TESTING_Command |
1169 | GNUNET_TESTING_cmd_netjail_start_testing_system_v2 (const char *label, | 1124 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, |
1170 | const char *topology_config, | 1125 | const char *topology_config); |
1171 | unsigned int *rv); | ||
1172 | 1126 | ||
1173 | 1127 | ||
1174 | /** | 1128 | /** |
1175 | * Create command. | 1129 | * Create command. |
1176 | * | 1130 | * |
1177 | * @param label name for command. | 1131 | * @param label name for command. |
1178 | * @param binaryname to stop. | 1132 | * @param topology_config Configuration file for the test topology. |
1179 | * @return command. | 1133 | * @return command. |
1180 | */ | 1134 | */ |
1181 | struct GNUNET_TESTING_Command | 1135 | struct GNUNET_TESTING_Command |
1182 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | 1136 | GNUNET_TESTING_cmd_netjail_stop (const char *label, |
1183 | char *local_m, | 1137 | char *topology_config); |
1184 | char *global_n); | ||
1185 | 1138 | ||
1186 | 1139 | ||
1187 | /** | 1140 | /** |
@@ -1192,33 +1145,31 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
1192 | * @return command. | 1145 | * @return command. |
1193 | */ | 1146 | */ |
1194 | struct GNUNET_TESTING_Command | 1147 | struct GNUNET_TESTING_Command |
1195 | GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label, | ||
1196 | char *topology_config); | ||
1197 | |||
1198 | |||
1199 | struct GNUNET_TESTING_Command | ||
1200 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | 1148 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, |
1201 | const char *helper_start_label, | 1149 | const char *helper_start_label, |
1202 | char *local_m, | 1150 | const char *topology_config); |
1203 | char *global_n); | 1151 | |
1204 | 1152 | ||
1205 | /** | 1153 | /** |
1206 | * Create command. | 1154 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. |
1207 | * | 1155 | * |
1208 | * @param label name for command. | 1156 | * @param rv The result of the local test as GNUNET_GenericReturnValue. |
1209 | * @param topology_config Configuration file for the test topology. | 1157 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. |
1210 | * @return command. | 1158 | */ |
1211 | */ | 1159 | struct GNUNET_MessageHeader * |
1212 | struct GNUNET_TESTING_Command | 1160 | GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv); |
1213 | GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label, | ||
1214 | const char *helper_start_label, | ||
1215 | const char *topology_config); | ||
1216 | 1161 | ||
1217 | 1162 | ||
1163 | /** | ||
1164 | * Function to get the trait with the async context. | ||
1165 | * | ||
1166 | * @param[out] ac GNUNET_TESTING_AsyncContext. | ||
1167 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
1168 | */ | ||
1218 | int | 1169 | int |
1219 | GNUNET_TESTING_get_trait_helper_handles (const struct | 1170 | GNUNET_TESTING_get_trait_async_context ( |
1220 | GNUNET_TESTING_Command *cmd, | 1171 | const struct GNUNET_TESTING_Command *cmd, |
1221 | struct GNUNET_HELPER_Handle ***helper); | 1172 | struct GNUNET_TESTING_AsyncContext **ac); |
1222 | 1173 | ||
1223 | 1174 | ||
1224 | /** | 1175 | /** |
@@ -1228,24 +1179,21 @@ GNUNET_TESTING_get_trait_helper_handles (const struct | |||
1228 | * @param pt pointer to message. | 1179 | * @param pt pointer to message. |
1229 | * @return #GNUNET_OK on success. | 1180 | * @return #GNUNET_OK on success. |
1230 | */ | 1181 | */ |
1231 | int | 1182 | enum GNUNET_GenericReturnValue |
1232 | GNUNET_TESTING_get_trait_helper_handles_v2 (const struct | 1183 | GNUNET_TESTING_get_trait_helper_handles ( |
1233 | GNUNET_TESTING_Command *cmd, | 1184 | const struct GNUNET_TESTING_Command *cmd, |
1234 | struct GNUNET_HELPER_Handle *** | 1185 | struct GNUNET_HELPER_Handle ***helper); |
1235 | helper); | ||
1236 | 1186 | ||
1237 | 1187 | ||
1238 | struct GNUNET_TESTING_Command | 1188 | struct GNUNET_TESTING_Command |
1239 | GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | 1189 | GNUNET_TESTING_cmd_block_until_all_peers_started ( |
1240 | unsigned int * | 1190 | const char *label, |
1241 | all_peers_started); | 1191 | unsigned int *all_peers_started); |
1242 | 1192 | ||
1243 | 1193 | ||
1244 | struct GNUNET_TESTING_Command | 1194 | struct GNUNET_TESTING_Command |
1245 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label, | 1195 | GNUNET_TESTING_cmd_block_until_external_trigger ( |
1246 | unsigned int * | 1196 | const char *label); |
1247 | stop_blocking); | ||
1248 | |||
1249 | 1197 | ||
1250 | struct GNUNET_TESTING_Command | 1198 | struct GNUNET_TESTING_Command |
1251 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 1199 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
@@ -1260,9 +1208,9 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label, | |||
1260 | * @return command. | 1208 | * @return command. |
1261 | */ | 1209 | */ |
1262 | struct GNUNET_TESTING_Command | 1210 | struct GNUNET_TESTING_Command |
1263 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | 1211 | GNUNET_TESTING_cmd_local_test_finished ( |
1264 | TESTING_CMD_HELPER_write_cb | 1212 | const char *label, |
1265 | write_message); | 1213 | TESTING_CMD_HELPER_write_cb write_message); |
1266 | 1214 | ||
1267 | /** | 1215 | /** |
1268 | * Create command. | 1216 | * Create command. |
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c index 28fa4b147..e2d106be8 100644 --- a/src/messenger/gnunet-messenger.c +++ b/src/messenger/gnunet-messenger.c | |||
@@ -42,8 +42,11 @@ struct GNUNET_MESSENGER_Handle *messenger; | |||
42 | * @param[in] flags Flags of message | 42 | * @param[in] flags Flags of message |
43 | */ | 43 | */ |
44 | void | 44 | void |
45 | on_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, | 45 | on_message (void *cls, |
46 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, | 46 | struct GNUNET_MESSENGER_Room *room, |
47 | const struct GNUNET_MESSENGER_Contact *sender, | ||
48 | const struct GNUNET_MESSENGER_Message *message, | ||
49 | const struct GNUNET_HashCode *hash, | ||
47 | enum GNUNET_MESSENGER_MessageFlags flags) | 50 | enum GNUNET_MESSENGER_MessageFlags flags) |
48 | { | 51 | { |
49 | const char *sender_name = GNUNET_MESSENGER_contact_get_name (sender); | 52 | const char *sender_name = GNUNET_MESSENGER_contact_get_name (sender); |
@@ -124,7 +127,8 @@ listen_stdio (void *cls); | |||
124 | #define MAX_BUFFER_SIZE 60000 | 127 | #define MAX_BUFFER_SIZE 60000 |
125 | 128 | ||
126 | static int | 129 | static int |
127 | iterate_send_private_message (void *cls, struct GNUNET_MESSENGER_Room *room, | 130 | iterate_send_private_message (void *cls, |
131 | struct GNUNET_MESSENGER_Room *room, | ||
128 | const struct GNUNET_MESSENGER_Contact *contact) | 132 | const struct GNUNET_MESSENGER_Contact *contact) |
129 | { | 133 | { |
130 | struct GNUNET_MESSENGER_Message *message = cls; | 134 | struct GNUNET_MESSENGER_Message *message = cls; |
@@ -226,7 +230,8 @@ struct GNUNET_SCHEDULER_Task *shutdown_task; | |||
226 | * @param[in/out] handle Handle of messenger service | 230 | * @param[in/out] handle Handle of messenger service |
227 | */ | 231 | */ |
228 | static void | 232 | static void |
229 | on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | 233 | on_identity (void *cls, |
234 | struct GNUNET_MESSENGER_Handle *handle) | ||
230 | { | 235 | { |
231 | struct GNUNET_HashCode key; | 236 | struct GNUNET_HashCode key; |
232 | memset (&key, 0, sizeof(key)); | 237 | memset (&key, 0, sizeof(key)); |
@@ -292,7 +297,10 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | |||
292 | * @param[in] cfg configuration | 297 | * @param[in] cfg configuration |
293 | */ | 298 | */ |
294 | static void | 299 | static void |
295 | run (void *cls, char *const*args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 300 | run (void *cls, |
301 | char *const*args, | ||
302 | const char *cfgfile, | ||
303 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
296 | { | 304 | { |
297 | messenger = GNUNET_MESSENGER_connect (cfg, ego_name, &on_identity, NULL, &on_message, NULL); | 305 | messenger = GNUNET_MESSENGER_connect (cfg, ego_name, &on_identity, NULL, &on_message, NULL); |
298 | 306 | ||
@@ -307,7 +315,8 @@ run (void *cls, char *const*args, const char *cfgfile, const struct GNUNET_CONFI | |||
307 | * @return #EXIT_SUCCESS ok, #EXIT_FAILURE on error | 315 | * @return #EXIT_SUCCESS ok, #EXIT_FAILURE on error |
308 | */ | 316 | */ |
309 | int | 317 | int |
310 | main (int argc, char **argv) | 318 | main (int argc, |
319 | char **argv) | ||
311 | { | 320 | { |
312 | const char *description = "Open and connect to rooms using the MESSENGER to chat."; | 321 | const char *description = "Open and connect to rooms using the MESSENGER to chat."; |
313 | 322 | ||
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index 7edd76d32..989157ceb 100644 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -39,14 +39,16 @@ struct GNUNET_MESSENGER_Client | |||
39 | struct GNUNET_MESSENGER_Service *messenger; | 39 | struct GNUNET_MESSENGER_Service *messenger; |
40 | 40 | ||
41 | static int | 41 | static int |
42 | check_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | 42 | check_create (void *cls, |
43 | const struct GNUNET_MESSENGER_CreateMessage *msg) | ||
43 | { | 44 | { |
44 | GNUNET_MQ_check_zero_termination(msg); | 45 | GNUNET_MQ_check_zero_termination(msg); |
45 | return GNUNET_OK; | 46 | return GNUNET_OK; |
46 | } | 47 | } |
47 | 48 | ||
48 | static void | 49 | static void |
49 | handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | 50 | handle_create (void *cls, |
51 | const struct GNUNET_MESSENGER_CreateMessage *msg) | ||
50 | { | 52 | { |
51 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 53 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
52 | 54 | ||
@@ -60,7 +62,8 @@ handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | |||
60 | } | 62 | } |
61 | 63 | ||
62 | static void | 64 | static void |
63 | handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg) | 65 | handle_update (void *cls, |
66 | const struct GNUNET_MESSENGER_UpdateMessage *msg) | ||
64 | { | 67 | { |
65 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 68 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
66 | 69 | ||
@@ -70,7 +73,8 @@ handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg) | |||
70 | } | 73 | } |
71 | 74 | ||
72 | static void | 75 | static void |
73 | handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg) | 76 | handle_destroy (void *cls, |
77 | const struct GNUNET_MESSENGER_DestroyMessage *msg) | ||
74 | { | 78 | { |
75 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 79 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
76 | 80 | ||
@@ -78,14 +82,16 @@ handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg) | |||
78 | } | 82 | } |
79 | 83 | ||
80 | static int | 84 | static int |
81 | check_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 85 | check_set_name (void *cls, |
86 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
82 | { | 87 | { |
83 | GNUNET_MQ_check_zero_termination(msg); | 88 | GNUNET_MQ_check_zero_termination(msg); |
84 | return GNUNET_OK; | 89 | return GNUNET_OK; |
85 | } | 90 | } |
86 | 91 | ||
87 | static void | 92 | static void |
88 | handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 93 | handle_set_name (void *cls, |
94 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
89 | { | 95 | { |
90 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 96 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
91 | 97 | ||
@@ -99,7 +105,8 @@ handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | |||
99 | } | 105 | } |
100 | 106 | ||
101 | static void | 107 | static void |
102 | handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 108 | handle_room_open (void *cls, |
109 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
103 | { | 110 | { |
104 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 111 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
105 | 112 | ||
@@ -125,7 +132,8 @@ handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
125 | } | 132 | } |
126 | 133 | ||
127 | static void | 134 | static void |
128 | handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 135 | handle_room_entry (void *cls, |
136 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
129 | { | 137 | { |
130 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 138 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
131 | 139 | ||
@@ -153,7 +161,8 @@ handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
153 | } | 161 | } |
154 | 162 | ||
155 | static void | 163 | static void |
156 | handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 164 | handle_room_close (void *cls, |
165 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
157 | { | 166 | { |
158 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 167 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
159 | 168 | ||
@@ -179,7 +188,8 @@ handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
179 | } | 188 | } |
180 | 189 | ||
181 | static int | 190 | static int |
182 | check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | 191 | check_send_message (void *cls, |
192 | const struct GNUNET_MESSENGER_SendMessage *msg) | ||
183 | { | 193 | { |
184 | const uint16_t full_length = ntohs (msg->header.size); | 194 | const uint16_t full_length = ntohs (msg->header.size); |
185 | 195 | ||
@@ -224,7 +234,8 @@ check_for_message: | |||
224 | } | 234 | } |
225 | 235 | ||
226 | static void | 236 | static void |
227 | handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | 237 | handle_send_message (void *cls, |
238 | const struct GNUNET_MESSENGER_SendMessage *msg) | ||
228 | { | 239 | { |
229 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 240 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
230 | 241 | ||
@@ -271,7 +282,8 @@ end_handling: | |||
271 | } | 282 | } |
272 | 283 | ||
273 | static void | 284 | static void |
274 | callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | 285 | callback_found_message (void *cls, |
286 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
275 | const struct GNUNET_MESSENGER_Message *message, | 287 | const struct GNUNET_MESSENGER_Message *message, |
276 | const struct GNUNET_HashCode *hash) | 288 | const struct GNUNET_HashCode *hash) |
277 | { | 289 | { |
@@ -300,7 +312,8 @@ callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | |||
300 | } | 312 | } |
301 | 313 | ||
302 | static void | 314 | static void |
303 | handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg) | 315 | handle_get_message (void *cls, |
316 | const struct GNUNET_MESSENGER_GetMessage *msg) | ||
304 | { | 317 | { |
305 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 318 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
306 | 319 | ||
@@ -341,7 +354,9 @@ end_handling: | |||
341 | } | 354 | } |
342 | 355 | ||
343 | static void* | 356 | static void* |
344 | callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) | 357 | callback_client_connect (void *cls, |
358 | struct GNUNET_SERVICE_Client *client, | ||
359 | struct GNUNET_MQ_Handle *mq) | ||
345 | { | 360 | { |
346 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); | 361 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); |
347 | 362 | ||
@@ -352,7 +367,9 @@ callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct | |||
352 | } | 367 | } |
353 | 368 | ||
354 | static void | 369 | static void |
355 | callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) | 370 | callback_client_disconnect (void *cls, |
371 | struct GNUNET_SERVICE_Client *client, | ||
372 | void *internal_cls) | ||
356 | { | 373 | { |
357 | struct GNUNET_MESSENGER_Client *msg_client = internal_cls; | 374 | struct GNUNET_MESSENGER_Client *msg_client = internal_cls; |
358 | 375 | ||
@@ -369,7 +386,9 @@ callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, voi | |||
369 | * @param[in/out] service the initialized service | 386 | * @param[in/out] service the initialized service |
370 | */ | 387 | */ |
371 | static void | 388 | static void |
372 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service) | 389 | run (void *cls, |
390 | const struct GNUNET_CONFIGURATION_Handle *config, | ||
391 | struct GNUNET_SERVICE_Handle *service) | ||
373 | { | 392 | { |
374 | messenger = create_service (config, service); | 393 | messenger = create_service (config, service); |
375 | 394 | ||
diff --git a/src/messenger/gnunet-service-messenger_basement.c b/src/messenger/gnunet-service-messenger_basement.c index f302c8d66..89aa103ee 100644 --- a/src/messenger/gnunet-service-messenger_basement.c +++ b/src/messenger/gnunet-service-messenger_basement.c | |||
@@ -40,7 +40,9 @@ count_of_tunnels (const struct GNUNET_MESSENGER_ListTunnels *tunnels) | |||
40 | } | 40 | } |
41 | 41 | ||
42 | int | 42 | int |
43 | should_connect_tunnel_to (size_t count, size_t src, size_t dst) | 43 | should_connect_tunnel_to (size_t count, |
44 | size_t src, | ||
45 | size_t dst) | ||
44 | { | 46 | { |
45 | if ((src + 1) % count == dst % count) | 47 | if ((src + 1) % count == dst % count) |
46 | return GNUNET_YES; | 48 | return GNUNET_YES; |
@@ -49,7 +51,9 @@ should_connect_tunnel_to (size_t count, size_t src, size_t dst) | |||
49 | } | 51 | } |
50 | 52 | ||
51 | int | 53 | int |
52 | required_connection_between (size_t count, size_t src, size_t dst) | 54 | required_connection_between (size_t count, |
55 | size_t src, | ||
56 | size_t dst) | ||
53 | { | 57 | { |
54 | if (GNUNET_YES == should_connect_tunnel_to (count, src, dst)) | 58 | if (GNUNET_YES == should_connect_tunnel_to (count, src, dst)) |
55 | return GNUNET_YES; | 59 | return GNUNET_YES; |
diff --git a/src/messenger/gnunet-service-messenger_basement.h b/src/messenger/gnunet-service-messenger_basement.h index b19aec405..a097b482f 100644 --- a/src/messenger/gnunet-service-messenger_basement.h +++ b/src/messenger/gnunet-service-messenger_basement.h | |||
@@ -48,7 +48,9 @@ count_of_tunnels (const struct GNUNET_MESSENGER_ListTunnels *tunnels); | |||
48 | * @return #GNUNET_YES or #GNUNET_NO based on topologic requirement | 48 | * @return #GNUNET_YES or #GNUNET_NO based on topologic requirement |
49 | */ | 49 | */ |
50 | int | 50 | int |
51 | should_connect_tunnel_to (size_t count, size_t src, size_t dst); | 51 | should_connect_tunnel_to (size_t count, |
52 | size_t src, | ||
53 | size_t dst); | ||
52 | 54 | ||
53 | /** | 55 | /** |
54 | * Returns #GNUNET_YES or #GNUNET_NO to determine if the peers of index <i>src</i> and | 56 | * Returns #GNUNET_YES or #GNUNET_NO to determine if the peers of index <i>src</i> and |
@@ -61,6 +63,8 @@ should_connect_tunnel_to (size_t count, size_t src, size_t dst); | |||
61 | * @return #GNUNET_YES or #GNUNET_NO based on topologic requirement | 63 | * @return #GNUNET_YES or #GNUNET_NO based on topologic requirement |
62 | */ | 64 | */ |
63 | int | 65 | int |
64 | required_connection_between (size_t count, size_t src, size_t dst); | 66 | required_connection_between (size_t count, |
67 | size_t src, | ||
68 | size_t dst); | ||
65 | 69 | ||
66 | #endif //GNUNET_SERVICE_MESSENGER_BASEMENT_H | 70 | #endif //GNUNET_SERVICE_MESSENGER_BASEMENT_H |
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c b/src/messenger/gnunet-service-messenger_ego_store.c index 3b069fcf5..c460ac1c7 100644 --- a/src/messenger/gnunet-service-messenger_ego_store.c +++ b/src/messenger/gnunet-service-messenger_ego_store.c | |||
@@ -28,7 +28,10 @@ | |||
28 | #include "gnunet-service-messenger_handle.h" | 28 | #include "gnunet-service-messenger_handle.h" |
29 | 29 | ||
30 | static void | 30 | static void |
31 | callback_update_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier) | 31 | callback_update_ego (void *cls, |
32 | struct GNUNET_IDENTITY_Ego *ego, | ||
33 | void **ctx, | ||
34 | const char *identifier) | ||
32 | { | 35 | { |
33 | if ((!ego) || (!identifier)) | 36 | if ((!ego) || (!identifier)) |
34 | return; | 37 | return; |
@@ -41,7 +44,8 @@ callback_update_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, con | |||
41 | } | 44 | } |
42 | 45 | ||
43 | void | 46 | void |
44 | init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONFIGURATION_Handle *config) | 47 | init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, |
48 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
45 | { | 49 | { |
46 | GNUNET_assert ((store) && (config)); | 50 | GNUNET_assert ((store) && (config)); |
47 | 51 | ||
@@ -58,7 +62,9 @@ init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONF | |||
58 | 62 | ||
59 | 63 | ||
60 | static int | 64 | static int |
61 | iterate_destroy_egos (void *cls, const struct GNUNET_HashCode *key, void *value) | 65 | iterate_destroy_egos (void *cls, |
66 | const struct GNUNET_HashCode *key, | ||
67 | void *value) | ||
62 | { | 68 | { |
63 | struct GNUNET_MESSENGER_Ego *ego = value; | 69 | struct GNUNET_MESSENGER_Ego *ego = value; |
64 | GNUNET_free(ego); | 70 | GNUNET_free(ego); |
@@ -112,7 +118,9 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store) | |||
112 | } | 118 | } |
113 | 119 | ||
114 | static void | 120 | static void |
115 | callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *emsg) | 121 | callback_ego_create (void *cls, |
122 | const struct GNUNET_IDENTITY_PrivateKey *key, | ||
123 | const char *emsg) | ||
116 | { | 124 | { |
117 | struct GNUNET_MESSENGER_EgoOperation *element = cls; | 125 | struct GNUNET_MESSENGER_EgoOperation *element = cls; |
118 | struct GNUNET_MESSENGER_EgoStore *store = element->store; | 126 | struct GNUNET_MESSENGER_EgoStore *store = element->store; |
@@ -139,7 +147,8 @@ callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, co | |||
139 | } | 147 | } |
140 | 148 | ||
141 | void | 149 | void |
142 | create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 150 | create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
151 | const char *identifier, | ||
143 | void *handle) | 152 | void *handle) |
144 | { | 153 | { |
145 | GNUNET_assert ((store) && (identifier)); | 154 | GNUNET_assert ((store) && (identifier)); |
@@ -158,7 +167,8 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie | |||
158 | } | 167 | } |
159 | 168 | ||
160 | static void | 169 | static void |
161 | callback_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego) | 170 | callback_ego_lookup (void *cls, |
171 | struct GNUNET_IDENTITY_Ego *ego) | ||
162 | { | 172 | { |
163 | struct GNUNET_MESSENGER_EgoLookup *element = cls; | 173 | struct GNUNET_MESSENGER_EgoLookup *element = cls; |
164 | struct GNUNET_MESSENGER_EgoStore *store = element->store; | 174 | struct GNUNET_MESSENGER_EgoStore *store = element->store; |
@@ -183,8 +193,10 @@ callback_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
183 | } | 193 | } |
184 | 194 | ||
185 | void | 195 | void |
186 | lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 196 | lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, |
187 | GNUNET_MESSENGER_EgoLookupCallback lookup, void *cls) | 197 | const char *identifier, |
198 | GNUNET_MESSENGER_EgoLookupCallback lookup, | ||
199 | void *cls) | ||
188 | { | 200 | { |
189 | GNUNET_assert (store); | 201 | GNUNET_assert (store); |
190 | 202 | ||
@@ -219,7 +231,8 @@ lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier | |||
219 | } | 231 | } |
220 | 232 | ||
221 | struct GNUNET_MESSENGER_Ego* | 233 | struct GNUNET_MESSENGER_Ego* |
222 | update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 234 | update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, |
235 | const char *identifier, | ||
223 | const struct GNUNET_IDENTITY_PrivateKey *key) | 236 | const struct GNUNET_IDENTITY_PrivateKey *key) |
224 | { | 237 | { |
225 | GNUNET_assert ((store) && (identifier) && (key)); | 238 | GNUNET_assert ((store) && (identifier) && (key)); |
@@ -244,7 +257,8 @@ update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier | |||
244 | } | 257 | } |
245 | 258 | ||
246 | static void | 259 | static void |
247 | callback_ego_rename (void *cls, const char *emsg) | 260 | callback_ego_rename (void *cls, |
261 | const char *emsg) | ||
248 | { | 262 | { |
249 | struct GNUNET_MESSENGER_EgoOperation *element = cls; | 263 | struct GNUNET_MESSENGER_EgoOperation *element = cls; |
250 | struct GNUNET_MESSENGER_EgoStore *store = element->store; | 264 | struct GNUNET_MESSENGER_EgoStore *store = element->store; |
@@ -277,7 +291,8 @@ callback_ego_rename (void *cls, const char *emsg) | |||
277 | } | 291 | } |
278 | 292 | ||
279 | void | 293 | void |
280 | rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *old_identifier, | 294 | rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
295 | const char *old_identifier, | ||
281 | const char *new_identifier) | 296 | const char *new_identifier) |
282 | { | 297 | { |
283 | GNUNET_assert ((store) && (old_identifier) && (new_identifier)); | 298 | GNUNET_assert ((store) && (old_identifier) && (new_identifier)); |
diff --git a/src/messenger/gnunet-service-messenger_ego_store.h b/src/messenger/gnunet-service-messenger_ego_store.h index 41f14fff2..4222a4e91 100644 --- a/src/messenger/gnunet-service-messenger_ego_store.h +++ b/src/messenger/gnunet-service-messenger_ego_store.h | |||
@@ -35,7 +35,8 @@ struct GNUNET_MESSENGER_Ego; | |||
35 | struct GNUNET_MESSENGER_EgoStore; | 35 | struct GNUNET_MESSENGER_EgoStore; |
36 | 36 | ||
37 | typedef void | 37 | typedef void |
38 | (*GNUNET_MESSENGER_EgoLookupCallback) (void *cls, const char *identifier, | 38 | (*GNUNET_MESSENGER_EgoLookupCallback) (void *cls, |
39 | const char *identifier, | ||
39 | const struct GNUNET_MESSENGER_Ego *ego); | 40 | const struct GNUNET_MESSENGER_Ego *ego); |
40 | 41 | ||
41 | struct GNUNET_MESSENGER_EgoLookup | 42 | struct GNUNET_MESSENGER_EgoLookup |
@@ -87,7 +88,8 @@ struct GNUNET_MESSENGER_EgoStore | |||
87 | * @param[in] config Configuration handle | 88 | * @param[in] config Configuration handle |
88 | */ | 89 | */ |
89 | void | 90 | void |
90 | init_ego_store (struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONFIGURATION_Handle *config); | 91 | init_ego_store (struct GNUNET_MESSENGER_EgoStore *store, |
92 | const struct GNUNET_CONFIGURATION_Handle *config); | ||
91 | 93 | ||
92 | /** | 94 | /** |
93 | * Clears an EGO-store, wipes its content and deallocates its memory. | 95 | * Clears an EGO-store, wipes its content and deallocates its memory. |
@@ -107,7 +109,8 @@ clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store); | |||
107 | * @param[in/out] handle Handle or NULL | 109 | * @param[in/out] handle Handle or NULL |
108 | */ | 110 | */ |
109 | void | 111 | void |
110 | create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 112 | create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
113 | const char *identifier, | ||
111 | void *handle); | 114 | void *handle); |
112 | 115 | ||
113 | /** | 116 | /** |
@@ -120,8 +123,10 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie | |||
120 | * @param[in] cls Closure | 123 | * @param[in] cls Closure |
121 | */ | 124 | */ |
122 | void | 125 | void |
123 | lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 126 | lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
124 | GNUNET_MESSENGER_EgoLookupCallback lookup, void *cls); | 127 | const char *identifier, |
128 | GNUNET_MESSENGER_EgoLookupCallback lookup, | ||
129 | void *cls); | ||
125 | 130 | ||
126 | /** | 131 | /** |
127 | * Updates the registration of an EGO to a <i>store</i> under | 132 | * Updates the registration of an EGO to a <i>store</i> under |
@@ -133,7 +138,8 @@ lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie | |||
133 | * @return Updated EGO | 138 | * @return Updated EGO |
134 | */ | 139 | */ |
135 | struct GNUNET_MESSENGER_Ego* | 140 | struct GNUNET_MESSENGER_Ego* |
136 | update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier, | 141 | update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
142 | const char *identifier, | ||
137 | const struct GNUNET_IDENTITY_PrivateKey *key); | 143 | const struct GNUNET_IDENTITY_PrivateKey *key); |
138 | 144 | ||
139 | /** | 145 | /** |
@@ -146,7 +152,8 @@ update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie | |||
146 | * @param[in] new_identifier New identifier string | 152 | * @param[in] new_identifier New identifier string |
147 | */ | 153 | */ |
148 | void | 154 | void |
149 | rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *old_identifier, | 155 | rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, |
156 | const char *old_identifier, | ||
150 | const char *new_identifier); | 157 | const char *new_identifier); |
151 | 158 | ||
152 | #endif //GNUNET_SERVICE_MESSENGER_EGO_STORE_H | 159 | #endif //GNUNET_SERVICE_MESSENGER_EGO_STORE_H |
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c index d7007dbf6..2095f8b29 100644 --- a/src/messenger/gnunet-service-messenger_handle.c +++ b/src/messenger/gnunet-service-messenger_handle.c | |||
@@ -31,7 +31,8 @@ | |||
31 | #include "messenger_api_util.h" | 31 | #include "messenger_api_util.h" |
32 | 32 | ||
33 | struct GNUNET_MESSENGER_SrvHandle* | 33 | struct GNUNET_MESSENGER_SrvHandle* |
34 | create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq) | 34 | create_handle (struct GNUNET_MESSENGER_Service *service, |
35 | struct GNUNET_MQ_Handle *mq) | ||
35 | { | 36 | { |
36 | GNUNET_assert((service) && (mq)); | 37 | GNUNET_assert((service) && (mq)); |
37 | 38 | ||
@@ -49,7 +50,9 @@ create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle | |||
49 | } | 50 | } |
50 | 51 | ||
51 | int | 52 | int |
52 | iterate_free_member_ids (void *cls, const struct GNUNET_HashCode *key, void *value) | 53 | iterate_free_member_ids (void *cls, |
54 | const struct GNUNET_HashCode *key, | ||
55 | void *value) | ||
53 | { | 56 | { |
54 | GNUNET_free(value); | 57 | GNUNET_free(value); |
55 | 58 | ||
@@ -74,7 +77,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
74 | } | 77 | } |
75 | 78 | ||
76 | void | 79 | void |
77 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir) | 80 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, |
81 | const char *name, | ||
82 | char **dir) | ||
78 | { | 83 | { |
79 | GNUNET_assert((handle) && (dir)); | 84 | GNUNET_assert((handle) && (dir)); |
80 | 85 | ||
@@ -87,7 +92,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const c | |||
87 | } | 92 | } |
88 | 93 | ||
89 | static int | 94 | static int |
90 | create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 95 | create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, |
96 | const struct GNUNET_HashCode *key) | ||
91 | { | 97 | { |
92 | GNUNET_assert((handle) && (key)); | 98 | GNUNET_assert((handle) && (key)); |
93 | 99 | ||
@@ -112,7 +118,8 @@ create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const | |||
112 | } | 118 | } |
113 | 119 | ||
114 | const struct GNUNET_ShortHashCode* | 120 | const struct GNUNET_ShortHashCode* |
115 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 121 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, |
122 | const struct GNUNET_HashCode *key) | ||
116 | { | 123 | { |
117 | GNUNET_assert((handle) && (key)); | 124 | GNUNET_assert((handle) && (key)); |
118 | 125 | ||
@@ -120,7 +127,8 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const str | |||
120 | } | 127 | } |
121 | 128 | ||
122 | int | 129 | int |
123 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 130 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, |
131 | const struct GNUNET_HashCode *key, | ||
124 | const struct GNUNET_ShortHashCode *unique_id) | 132 | const struct GNUNET_ShortHashCode *unique_id) |
125 | { | 133 | { |
126 | GNUNET_assert((handle) && (key) && (unique_id)); | 134 | GNUNET_assert((handle) && (key) && (unique_id)); |
@@ -165,7 +173,8 @@ send_message_to_client: | |||
165 | } | 173 | } |
166 | 174 | ||
167 | static void | 175 | static void |
168 | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 176 | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
177 | const char *name) | ||
169 | { | 178 | { |
170 | GNUNET_assert(handle); | 179 | GNUNET_assert(handle); |
171 | 180 | ||
@@ -192,7 +201,8 @@ change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
192 | } | 201 | } |
193 | 202 | ||
194 | static void | 203 | static void |
195 | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) | 204 | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, |
205 | const struct GNUNET_MESSENGER_Ego *ego) | ||
196 | { | 206 | { |
197 | GNUNET_assert(handle); | 207 | GNUNET_assert(handle); |
198 | 208 | ||
@@ -222,7 +232,9 @@ struct GNUNET_MESSENGER_MessageHandle | |||
222 | }; | 232 | }; |
223 | 233 | ||
224 | static int | 234 | static int |
225 | iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) | 235 | iterate_send_message (void *cls, |
236 | const struct GNUNET_HashCode *key, | ||
237 | void *value) | ||
226 | { | 238 | { |
227 | struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls; | 239 | struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls; |
228 | 240 | ||
@@ -232,7 +244,8 @@ iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
232 | } | 244 | } |
233 | 245 | ||
234 | void | 246 | void |
235 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) | 247 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, |
248 | const struct GNUNET_MESSENGER_Ego *ego) | ||
236 | { | 249 | { |
237 | GNUNET_assert((handle) && (ego)); | 250 | GNUNET_assert((handle) && (ego)); |
238 | 251 | ||
@@ -271,7 +284,9 @@ get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle) | |||
271 | } | 284 | } |
272 | 285 | ||
273 | static void | 286 | static void |
274 | callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 287 | callback_setup_handle_name (void *cls, |
288 | const char *name, | ||
289 | const struct GNUNET_MESSENGER_Ego *ego) | ||
275 | { | 290 | { |
276 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 291 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
277 | 292 | ||
@@ -285,7 +300,8 @@ callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MES | |||
285 | } | 300 | } |
286 | 301 | ||
287 | void | 302 | void |
288 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 303 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
304 | const char *name) | ||
289 | { | 305 | { |
290 | GNUNET_assert(handle); | 306 | GNUNET_assert(handle); |
291 | 307 | ||
@@ -295,7 +311,9 @@ setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
295 | } | 311 | } |
296 | 312 | ||
297 | static void | 313 | static void |
298 | callback_update_handle (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 314 | callback_update_handle (void *cls, |
315 | const char *name, | ||
316 | const struct GNUNET_MESSENGER_Ego *ego) | ||
299 | { | 317 | { |
300 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 318 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
301 | 319 | ||
@@ -326,7 +344,9 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
326 | } | 344 | } |
327 | 345 | ||
328 | static void | 346 | static void |
329 | callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 347 | callback_set_handle_name (void *cls, |
348 | const char *name, | ||
349 | const struct GNUNET_MESSENGER_Ego *ego) | ||
330 | { | 350 | { |
331 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 351 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
332 | 352 | ||
@@ -383,7 +403,8 @@ callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSE | |||
383 | } | 403 | } |
384 | 404 | ||
385 | void | 405 | void |
386 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 406 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
407 | const char *name) | ||
387 | { | 408 | { |
388 | GNUNET_assert(handle); | 409 | GNUNET_assert(handle); |
389 | 410 | ||
@@ -403,7 +424,8 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
403 | } | 424 | } |
404 | 425 | ||
405 | int | 426 | int |
406 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 427 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
428 | const struct GNUNET_HashCode *key) | ||
407 | { | 429 | { |
408 | GNUNET_assert((handle) && (key)); | 430 | GNUNET_assert((handle) && (key)); |
409 | 431 | ||
@@ -414,7 +436,8 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET | |||
414 | } | 436 | } |
415 | 437 | ||
416 | int | 438 | int |
417 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, | 439 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
440 | const struct GNUNET_PeerIdentity *door, | ||
418 | const struct GNUNET_HashCode *key) | 441 | const struct GNUNET_HashCode *key) |
419 | { | 442 | { |
420 | GNUNET_assert((handle) && (door) && (key)); | 443 | GNUNET_assert((handle) && (door) && (key)); |
@@ -426,7 +449,8 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
426 | } | 449 | } |
427 | 450 | ||
428 | int | 451 | int |
429 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 452 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
453 | const struct GNUNET_HashCode *key) | ||
430 | { | 454 | { |
431 | GNUNET_assert((handle) && (key)); | 455 | GNUNET_assert((handle) && (key)); |
432 | 456 | ||
@@ -437,7 +461,8 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
437 | } | 461 | } |
438 | 462 | ||
439 | int | 463 | int |
440 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 464 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
465 | const struct GNUNET_HashCode *key, | ||
441 | const struct GNUNET_MESSENGER_Message *message) | 466 | const struct GNUNET_MESSENGER_Message *message) |
442 | { | 467 | { |
443 | GNUNET_assert((handle) && (key) && (message)); | 468 | GNUNET_assert((handle) && (key) && (message)); |
@@ -475,7 +500,8 @@ get_next_member_session_contect(const struct GNUNET_MESSENGER_MemberSession *ses | |||
475 | } | 500 | } |
476 | 501 | ||
477 | static const struct GNUNET_MESSENGER_MemberSession* | 502 | static const struct GNUNET_MESSENGER_MemberSession* |
478 | get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 503 | get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, |
504 | const struct GNUNET_HashCode *key) | ||
479 | { | 505 | { |
480 | GNUNET_assert((handle) && (key) && (handle->service)); | 506 | GNUNET_assert((handle) && (key) && (handle->service)); |
481 | 507 | ||
@@ -497,9 +523,11 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const stru | |||
497 | } | 523 | } |
498 | 524 | ||
499 | void | 525 | void |
500 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 526 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
527 | const struct GNUNET_HashCode *key, | ||
501 | const struct GNUNET_MESSENGER_MemberSession *session, | 528 | const struct GNUNET_MESSENGER_MemberSession *session, |
502 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 529 | const struct GNUNET_MESSENGER_Message *message, |
530 | const struct GNUNET_HashCode *hash) | ||
503 | { | 531 | { |
504 | GNUNET_assert((handle) && (key) && (session) && (message) && (hash)); | 532 | GNUNET_assert((handle) && (key) && (session) && (message) && (hash)); |
505 | 533 | ||
@@ -563,7 +591,8 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct G | |||
563 | } | 591 | } |
564 | 592 | ||
565 | static int | 593 | static int |
566 | callback_scan_for_rooms (void *cls, const char *filename) | 594 | callback_scan_for_rooms (void *cls, |
595 | const char *filename) | ||
567 | { | 596 | { |
568 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 597 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
569 | 598 | ||
@@ -606,7 +635,9 @@ load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
606 | } | 635 | } |
607 | 636 | ||
608 | static int | 637 | static int |
609 | iterate_save_rooms (void *cls, const struct GNUNET_HashCode *key, void *value) | 638 | iterate_save_rooms (void *cls, |
639 | const struct GNUNET_HashCode *key, | ||
640 | void *value) | ||
610 | { | 641 | { |
611 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 642 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
612 | struct GNUNET_ShortHashCode *member_id = value; | 643 | struct GNUNET_ShortHashCode *member_id = value; |
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h index d8ff3aaa8..97a984721 100644 --- a/src/messenger/gnunet-service-messenger_handle.h +++ b/src/messenger/gnunet-service-messenger_handle.h | |||
@@ -60,7 +60,8 @@ struct GNUNET_MESSENGER_SrvHandle | |||
60 | * @return New handle | 60 | * @return New handle |
61 | */ | 61 | */ |
62 | struct GNUNET_MESSENGER_SrvHandle* | 62 | struct GNUNET_MESSENGER_SrvHandle* |
63 | create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq); | 63 | create_handle (struct GNUNET_MESSENGER_Service *service, |
64 | struct GNUNET_MQ_Handle *mq); | ||
64 | 65 | ||
65 | /** | 66 | /** |
66 | * Destroys a handle and frees its memory fully. | 67 | * Destroys a handle and frees its memory fully. |
@@ -79,7 +80,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle); | |||
79 | * @param[out] dir Path to store data | 80 | * @param[out] dir Path to store data |
80 | */ | 81 | */ |
81 | void | 82 | void |
82 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir); | 83 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, |
84 | const char *name, | ||
85 | char **dir); | ||
83 | 86 | ||
84 | /** | 87 | /** |
85 | * Returns the member id of a given <i>handle</i> in a specific <i>room</i>. | 88 | * Returns the member id of a given <i>handle</i> in a specific <i>room</i>. |
@@ -91,7 +94,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const c | |||
91 | * @return Member id or NULL | 94 | * @return Member id or NULL |
92 | */ | 95 | */ |
93 | const struct GNUNET_ShortHashCode* | 96 | const struct GNUNET_ShortHashCode* |
94 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | 97 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, |
98 | const struct GNUNET_HashCode *key); | ||
95 | 99 | ||
96 | /** | 100 | /** |
97 | * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i> | 101 | * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i> |
@@ -105,7 +109,8 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const str | |||
105 | * @return GNUNET_OK on success, otherwise GNUNET_SYSERR | 109 | * @return GNUNET_OK on success, otherwise GNUNET_SYSERR |
106 | */ | 110 | */ |
107 | int | 111 | int |
108 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 112 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, |
113 | const struct GNUNET_HashCode *key, | ||
109 | const struct GNUNET_ShortHashCode *unique_id); | 114 | const struct GNUNET_ShortHashCode *unique_id); |
110 | 115 | ||
111 | /** | 116 | /** |
@@ -115,7 +120,8 @@ change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct | |||
115 | * @param[in] ego EGO key pair | 120 | * @param[in] ego EGO key pair |
116 | */ | 121 | */ |
117 | void | 122 | void |
118 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego); | 123 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, |
124 | const struct GNUNET_MESSENGER_Ego *ego); | ||
119 | 125 | ||
120 | /** | 126 | /** |
121 | * Returns the EGO used by a given <i>handle</i>. | 127 | * Returns the EGO used by a given <i>handle</i>. |
@@ -133,7 +139,8 @@ get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle); | |||
133 | * @param[in] name Name (optionally: valid EGO name) | 139 | * @param[in] name Name (optionally: valid EGO name) |
134 | */ | 140 | */ |
135 | void | 141 | void |
136 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); | 142 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
143 | const char *name); | ||
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms | 146 | * Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms |
@@ -154,7 +161,8 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle); | |||
154 | * @param[in] name New name | 161 | * @param[in] name New name |
155 | */ | 162 | */ |
156 | void | 163 | void |
157 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); | 164 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
165 | const char *name); | ||
158 | 166 | ||
159 | /** | 167 | /** |
160 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the | 168 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the |
@@ -165,7 +173,8 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); | |||
165 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 173 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
166 | */ | 174 | */ |
167 | int | 175 | int |
168 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | 176 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
177 | const struct GNUNET_HashCode *key); | ||
169 | 178 | ||
170 | /** | 179 | /** |
171 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room | 180 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room |
@@ -177,7 +186,8 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET | |||
177 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 186 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
178 | */ | 187 | */ |
179 | int | 188 | int |
180 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, | 189 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
190 | const struct GNUNET_PeerIdentity *door, | ||
181 | const struct GNUNET_HashCode *key); | 191 | const struct GNUNET_HashCode *key); |
182 | 192 | ||
183 | /** | 193 | /** |
@@ -189,7 +199,8 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
189 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 199 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
190 | */ | 200 | */ |
191 | int | 201 | int |
192 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | 202 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
203 | const struct GNUNET_HashCode *key); | ||
193 | 204 | ||
194 | /** | 205 | /** |
195 | * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>. | 206 | * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>. |
@@ -200,7 +211,8 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
200 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. | 211 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. |
201 | */ | 212 | */ |
202 | int | 213 | int |
203 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 214 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
215 | const struct GNUNET_HashCode *key, | ||
204 | const struct GNUNET_MESSENGER_Message *message); | 216 | const struct GNUNET_MESSENGER_Message *message); |
205 | 217 | ||
206 | /** | 218 | /** |
@@ -213,9 +225,11 @@ send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNU | |||
213 | * @param[in] hash Hash of message | 225 | * @param[in] hash Hash of message |
214 | */ | 226 | */ |
215 | void | 227 | void |
216 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 228 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
229 | const struct GNUNET_HashCode *key, | ||
217 | const struct GNUNET_MESSENGER_MemberSession *session, | 230 | const struct GNUNET_MESSENGER_MemberSession *session, |
218 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 231 | const struct GNUNET_MESSENGER_Message *message, |
232 | const struct GNUNET_HashCode *hash); | ||
219 | 233 | ||
220 | /** | 234 | /** |
221 | * Loads member ids and other potential configuration from a given <i>handle</i> which | 235 | * Loads member ids and other potential configuration from a given <i>handle</i> which |
diff --git a/src/messenger/gnunet-service-messenger_list_handles.c b/src/messenger/gnunet-service-messenger_list_handles.c index adcbf6a42..c0ae18716 100644 --- a/src/messenger/gnunet-service-messenger_list_handles.c +++ b/src/messenger/gnunet-service-messenger_list_handles.c | |||
@@ -55,7 +55,8 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | void | 57 | void |
58 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle) | 58 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
59 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
59 | { | 60 | { |
60 | GNUNET_assert((handles) && (handle)); | 61 | GNUNET_assert((handles) && (handle)); |
61 | 62 | ||
@@ -67,7 +68,8 @@ add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MES | |||
67 | } | 68 | } |
68 | 69 | ||
69 | int | 70 | int |
70 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle) | 71 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
72 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
71 | { | 73 | { |
72 | GNUNET_assert((handles) && (handle)); | 74 | GNUNET_assert((handles) && (handle)); |
73 | 75 | ||
@@ -87,7 +89,8 @@ remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_ | |||
87 | } | 89 | } |
88 | 90 | ||
89 | struct GNUNET_MESSENGER_SrvHandle* | 91 | struct GNUNET_MESSENGER_SrvHandle* |
90 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key) | 92 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, |
93 | const struct GNUNET_HashCode *key) | ||
91 | { | 94 | { |
92 | GNUNET_assert((handles) && (key)); | 95 | GNUNET_assert((handles) && (key)); |
93 | 96 | ||
diff --git a/src/messenger/gnunet-service-messenger_list_handles.h b/src/messenger/gnunet-service-messenger_list_handles.h index 9f7ca725f..f4d7ca5c0 100644 --- a/src/messenger/gnunet-service-messenger_list_handles.h +++ b/src/messenger/gnunet-service-messenger_list_handles.h | |||
@@ -69,7 +69,8 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles); | |||
69 | * @param[in/out] handle Handle | 69 | * @param[in/out] handle Handle |
70 | */ | 70 | */ |
71 | void | 71 | void |
72 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle); | 72 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
73 | struct GNUNET_MESSENGER_SrvHandle *handle); | ||
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Removes the first entry matching with a specific <i>handle</i> from the list of | 76 | * Removes the first entry matching with a specific <i>handle</i> from the list of |
@@ -80,7 +81,8 @@ add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MES | |||
80 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 81 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
81 | */ | 82 | */ |
82 | int | 83 | int |
83 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle); | 84 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
85 | struct GNUNET_MESSENGER_SrvHandle *handle); | ||
84 | 86 | ||
85 | /** | 87 | /** |
86 | * Searches linearly through the list of <i>handles</i> for members of a specific room | 88 | * Searches linearly through the list of <i>handles</i> for members of a specific room |
@@ -93,6 +95,7 @@ remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_ | |||
93 | * @return First handle which is a current member | 95 | * @return First handle which is a current member |
94 | */ | 96 | */ |
95 | struct GNUNET_MESSENGER_SrvHandle* | 97 | struct GNUNET_MESSENGER_SrvHandle* |
96 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key); | 98 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, |
99 | const struct GNUNET_HashCode *key); | ||
97 | 100 | ||
98 | #endif //GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H | 101 | #endif //GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H |
diff --git a/src/messenger/gnunet-service-messenger_list_messages.c b/src/messenger/gnunet-service-messenger_list_messages.c index 2666ccdab..7092dc76f 100644 --- a/src/messenger/gnunet-service-messenger_list_messages.c +++ b/src/messenger/gnunet-service-messenger_list_messages.c | |||
@@ -52,7 +52,8 @@ clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages) | |||
52 | } | 52 | } |
53 | 53 | ||
54 | void | 54 | void |
55 | add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash) | 55 | add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
56 | const struct GNUNET_HashCode *hash) | ||
56 | { | 57 | { |
57 | GNUNET_assert((messages) && (hash)); | 58 | GNUNET_assert((messages) && (hash)); |
58 | 59 | ||
@@ -64,7 +65,8 @@ add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const stru | |||
64 | } | 65 | } |
65 | 66 | ||
66 | void | 67 | void |
67 | copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_MESSENGER_ListMessages *origin) | 68 | copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
69 | const struct GNUNET_MESSENGER_ListMessages *origin) | ||
68 | { | 70 | { |
69 | GNUNET_assert((messages) && (origin)); | 71 | GNUNET_assert((messages) && (origin)); |
70 | 72 | ||
@@ -75,7 +77,8 @@ copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct | |||
75 | } | 77 | } |
76 | 78 | ||
77 | void | 79 | void |
78 | remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash) | 80 | remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
81 | const struct GNUNET_HashCode *hash) | ||
79 | { | 82 | { |
80 | GNUNET_assert((messages) && (hash)); | 83 | GNUNET_assert((messages) && (hash)); |
81 | 84 | ||
@@ -91,7 +94,8 @@ remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const | |||
91 | } | 94 | } |
92 | 95 | ||
93 | void | 96 | void |
94 | load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *path) | 97 | load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
98 | const char *path) | ||
95 | { | 99 | { |
96 | GNUNET_assert((messages) && (path)); | 100 | GNUNET_assert((messages) && (path)); |
97 | 101 | ||
@@ -125,7 +129,8 @@ load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char * | |||
125 | } | 129 | } |
126 | 130 | ||
127 | void | 131 | void |
128 | save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, const char *path) | 132 | save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, |
133 | const char *path) | ||
129 | { | 134 | { |
130 | GNUNET_assert((messages) && (path)); | 135 | GNUNET_assert((messages) && (path)); |
131 | 136 | ||
diff --git a/src/messenger/gnunet-service-messenger_list_messages.h b/src/messenger/gnunet-service-messenger_list_messages.h index 93ec203ea..7abc8c00f 100644 --- a/src/messenger/gnunet-service-messenger_list_messages.h +++ b/src/messenger/gnunet-service-messenger_list_messages.h | |||
@@ -68,7 +68,8 @@ clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages); | |||
68 | * @param[in] hash Hash of message | 68 | * @param[in] hash Hash of message |
69 | */ | 69 | */ |
70 | void | 70 | void |
71 | add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash); | 71 | add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
72 | const struct GNUNET_HashCode *hash); | ||
72 | 73 | ||
73 | /** | 74 | /** |
74 | * Copies all message hashes from an <i>origin</i> to another list. | 75 | * Copies all message hashes from an <i>origin</i> to another list. |
@@ -77,7 +78,8 @@ add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const stru | |||
77 | * @param[in] origin Source list of hashes | 78 | * @param[in] origin Source list of hashes |
78 | */ | 79 | */ |
79 | void | 80 | void |
80 | copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_MESSENGER_ListMessages *origin); | 81 | copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
82 | const struct GNUNET_MESSENGER_ListMessages *origin); | ||
81 | 83 | ||
82 | /** | 84 | /** |
83 | * Removes the first entry with a matching <i>hash</i> from the list. | 85 | * Removes the first entry with a matching <i>hash</i> from the list. |
@@ -86,7 +88,8 @@ copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct | |||
86 | * @param[in] hash Hash of message | 88 | * @param[in] hash Hash of message |
87 | */ | 89 | */ |
88 | void | 90 | void |
89 | remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash); | 91 | remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
92 | const struct GNUNET_HashCode *hash); | ||
90 | 93 | ||
91 | /** | 94 | /** |
92 | * Loads the list of message hashes from a file under a given <i>path</i>. | 95 | * Loads the list of message hashes from a file under a given <i>path</i>. |
@@ -95,7 +98,8 @@ remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const | |||
95 | * @param[in] path Path of file | 98 | * @param[in] path Path of file |
96 | */ | 99 | */ |
97 | void | 100 | void |
98 | load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *path); | 101 | load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, |
102 | const char *path); | ||
99 | 103 | ||
100 | /** | 104 | /** |
101 | * Saves the list of message hashes to a file under a given <i>path</i>. | 105 | * Saves the list of message hashes to a file under a given <i>path</i>. |
@@ -104,6 +108,7 @@ load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char * | |||
104 | * @param[in] path Path of file | 108 | * @param[in] path Path of file |
105 | */ | 109 | */ |
106 | void | 110 | void |
107 | save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, const char *path); | 111 | save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, |
112 | const char *path); | ||
108 | 113 | ||
109 | #endif //GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H | 114 | #endif //GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H |
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c index b0a735dbe..def57aef9 100644 --- a/src/messenger/gnunet-service-messenger_member.c +++ b/src/messenger/gnunet-service-messenger_member.c | |||
@@ -28,7 +28,8 @@ | |||
28 | #include "gnunet-service-messenger_member_session.h" | 28 | #include "gnunet-service-messenger_member_session.h" |
29 | 29 | ||
30 | struct GNUNET_MESSENGER_Member* | 30 | struct GNUNET_MESSENGER_Member* |
31 | create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id) | 31 | create_member (struct GNUNET_MESSENGER_MemberStore *store, |
32 | const struct GNUNET_ShortHashCode *id) | ||
32 | { | 33 | { |
33 | GNUNET_assert (store); | 34 | GNUNET_assert (store); |
34 | 35 | ||
@@ -50,7 +51,9 @@ create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_S | |||
50 | } | 51 | } |
51 | 52 | ||
52 | static int | 53 | static int |
53 | iterate_destroy_session (void *cls, const struct GNUNET_HashCode *key, void *value) | 54 | iterate_destroy_session (void *cls, |
55 | const struct GNUNET_HashCode *key, | ||
56 | void *value) | ||
54 | { | 57 | { |
55 | struct GNUNET_MESSENGER_MemberSession *session = value; | 58 | struct GNUNET_MESSENGER_MemberSession *session = value; |
56 | destroy_member_session(session); | 59 | destroy_member_session(session); |
@@ -77,7 +80,8 @@ get_member_id (const struct GNUNET_MESSENGER_Member *member) | |||
77 | } | 80 | } |
78 | 81 | ||
79 | static int | 82 | static int |
80 | callback_scan_for_sessions (void *cls, const char *filename) | 83 | callback_scan_for_sessions (void *cls, |
84 | const char *filename) | ||
81 | { | 85 | { |
82 | struct GNUNET_MESSENGER_Member *member = cls; | 86 | struct GNUNET_MESSENGER_Member *member = cls; |
83 | 87 | ||
@@ -95,7 +99,8 @@ callback_scan_for_sessions (void *cls, const char *filename) | |||
95 | } | 99 | } |
96 | 100 | ||
97 | void | 101 | void |
98 | load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory) | 102 | load_member (struct GNUNET_MESSENGER_MemberStore *store, |
103 | const char *directory) | ||
99 | { | 104 | { |
100 | GNUNET_assert ((store) && (directory)); | 105 | GNUNET_assert ((store) && (directory)); |
101 | 106 | ||
@@ -139,7 +144,9 @@ free_config: | |||
139 | } | 144 | } |
140 | 145 | ||
141 | static int | 146 | static int |
142 | iterate_load_next_session (void *cls, const struct GNUNET_HashCode *key, void *value) | 147 | iterate_load_next_session (void *cls, |
148 | const struct GNUNET_HashCode *key, | ||
149 | void *value) | ||
143 | { | 150 | { |
144 | const char* sessions_directory = cls; | 151 | const char* sessions_directory = cls; |
145 | 152 | ||
@@ -156,7 +163,8 @@ iterate_load_next_session (void *cls, const struct GNUNET_HashCode *key, void *v | |||
156 | } | 163 | } |
157 | 164 | ||
158 | void | 165 | void |
159 | load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory) | 166 | load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, |
167 | const char *directory) | ||
160 | { | 168 | { |
161 | GNUNET_assert ((member) && (directory)); | 169 | GNUNET_assert ((member) && (directory)); |
162 | 170 | ||
@@ -169,7 +177,9 @@ load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const c | |||
169 | } | 177 | } |
170 | 178 | ||
171 | static int | 179 | static int |
172 | iterate_save_session (void *cls, const struct GNUNET_HashCode *key, void *value) | 180 | iterate_save_session (void *cls, |
181 | const struct GNUNET_HashCode *key, | ||
182 | void *value) | ||
173 | { | 183 | { |
174 | const char* sessions_directory = cls; | 184 | const char* sessions_directory = cls; |
175 | 185 | ||
@@ -187,7 +197,8 @@ iterate_save_session (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
187 | } | 197 | } |
188 | 198 | ||
189 | void | 199 | void |
190 | save_member (struct GNUNET_MESSENGER_Member *member, const char *directory) | 200 | save_member (struct GNUNET_MESSENGER_Member *member, |
201 | const char *directory) | ||
191 | { | 202 | { |
192 | GNUNET_assert ((member) && (directory)); | 203 | GNUNET_assert ((member) && (directory)); |
193 | 204 | ||
@@ -221,7 +232,8 @@ save_member (struct GNUNET_MESSENGER_Member *member, const char *directory) | |||
221 | } | 232 | } |
222 | 233 | ||
223 | static void | 234 | static void |
224 | sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next) | 235 | sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session, |
236 | struct GNUNET_MESSENGER_MemberSession *next) | ||
225 | { | 237 | { |
226 | GNUNET_assert((session) && (next)); | 238 | GNUNET_assert((session) && (next)); |
227 | 239 | ||
@@ -235,7 +247,9 @@ sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session, | |||
235 | } | 247 | } |
236 | 248 | ||
237 | static int | 249 | static int |
238 | iterate_sync_session_contact (void *cls, const struct GNUNET_HashCode *key, void *value) | 250 | iterate_sync_session_contact (void *cls, |
251 | const struct GNUNET_HashCode *key, | ||
252 | void *value) | ||
239 | { | 253 | { |
240 | struct GNUNET_MESSENGER_MemberSession *session = value; | 254 | struct GNUNET_MESSENGER_MemberSession *session = value; |
241 | 255 | ||
@@ -254,7 +268,8 @@ sync_member_contacts (struct GNUNET_MESSENGER_Member *member) | |||
254 | } | 268 | } |
255 | 269 | ||
256 | struct GNUNET_MESSENGER_MemberSession* | 270 | struct GNUNET_MESSENGER_MemberSession* |
257 | get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key) | 271 | get_member_session (const struct GNUNET_MESSENGER_Member *member, |
272 | const struct GNUNET_IDENTITY_PublicKey *public_key) | ||
258 | { | 273 | { |
259 | GNUNET_assert ((member) && (public_key)); | 274 | GNUNET_assert ((member) && (public_key)); |
260 | 275 | ||
@@ -272,7 +287,9 @@ struct GNUNET_MESSENGER_ClosureSearchSession { | |||
272 | }; | 287 | }; |
273 | 288 | ||
274 | static int | 289 | static int |
275 | iterate_search_session (void *cls, const struct GNUNET_HashCode *key, void *value) | 290 | iterate_search_session (void *cls, |
291 | const struct GNUNET_HashCode *key, | ||
292 | void *value) | ||
276 | { | 293 | { |
277 | struct GNUNET_MESSENGER_ClosureSearchSession* search = cls; | 294 | struct GNUNET_MESSENGER_ClosureSearchSession* search = cls; |
278 | struct GNUNET_MESSENGER_MemberSession *session = value; | 295 | struct GNUNET_MESSENGER_MemberSession *session = value; |
@@ -285,7 +302,8 @@ iterate_search_session (void *cls, const struct GNUNET_HashCode *key, void *valu | |||
285 | } | 302 | } |
286 | 303 | ||
287 | static struct GNUNET_MESSENGER_MemberSession* | 304 | static struct GNUNET_MESSENGER_MemberSession* |
288 | try_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key) | 305 | try_member_session (struct GNUNET_MESSENGER_Member *member, |
306 | const struct GNUNET_IDENTITY_PublicKey *public_key) | ||
289 | { | 307 | { |
290 | struct GNUNET_MESSENGER_MemberSession* session = get_member_session(member, public_key); | 308 | struct GNUNET_MESSENGER_MemberSession* session = get_member_session(member, public_key); |
291 | 309 | ||
@@ -301,7 +319,8 @@ try_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ | |||
301 | } | 319 | } |
302 | 320 | ||
303 | struct GNUNET_MESSENGER_MemberSession* | 321 | struct GNUNET_MESSENGER_MemberSession* |
304 | get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, | 322 | get_member_session_of (struct GNUNET_MESSENGER_Member *member, |
323 | const struct GNUNET_MESSENGER_Message *message, | ||
305 | const struct GNUNET_HashCode *hash) | 324 | const struct GNUNET_HashCode *hash) |
306 | { | 325 | { |
307 | GNUNET_assert ((member) && (message) && (hash) && | 326 | GNUNET_assert ((member) && (message) && (hash) && |
@@ -324,7 +343,8 @@ get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUN | |||
324 | } | 343 | } |
325 | 344 | ||
326 | void | 345 | void |
327 | add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session) | 346 | add_member_session (struct GNUNET_MESSENGER_Member *member, |
347 | struct GNUNET_MESSENGER_MemberSession *session) | ||
328 | { | 348 | { |
329 | if (!session) | 349 | if (!session) |
330 | return; | 350 | return; |
@@ -344,7 +364,8 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN | |||
344 | } | 364 | } |
345 | 365 | ||
346 | void | 366 | void |
347 | remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session) | 367 | remove_member_session (struct GNUNET_MESSENGER_Member *member, |
368 | struct GNUNET_MESSENGER_MemberSession *session) | ||
348 | { | 369 | { |
349 | GNUNET_assert ((member) && (session) && (session->member == member)); | 370 | GNUNET_assert ((member) && (session) && (session->member == member)); |
350 | 371 | ||
@@ -364,7 +385,9 @@ struct GNUNET_MESSENGER_ClosureIterateSessions { | |||
364 | }; | 385 | }; |
365 | 386 | ||
366 | static int | 387 | static int |
367 | iterate_member_sessions_it (void *cls, const struct GNUNET_HashCode *key, void *value) | 388 | iterate_member_sessions_it (void *cls, |
389 | const struct GNUNET_HashCode *key, | ||
390 | void *value) | ||
368 | { | 391 | { |
369 | struct GNUNET_MESSENGER_ClosureIterateSessions *iterate = cls; | 392 | struct GNUNET_MESSENGER_ClosureIterateSessions *iterate = cls; |
370 | struct GNUNET_MESSENGER_MemberSession *session = value; | 393 | struct GNUNET_MESSENGER_MemberSession *session = value; |
@@ -373,7 +396,9 @@ iterate_member_sessions_it (void *cls, const struct GNUNET_HashCode *key, void * | |||
373 | } | 396 | } |
374 | 397 | ||
375 | int | 398 | int |
376 | iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls) | 399 | iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, |
400 | GNUNET_MESSENGER_MemberIteratorCallback it, | ||
401 | void *cls) | ||
377 | { | 402 | { |
378 | GNUNET_assert ((member) && (member->sessions) && (it)); | 403 | GNUNET_assert ((member) && (member->sessions) && (it)); |
379 | 404 | ||
diff --git a/src/messenger/gnunet-service-messenger_member.h b/src/messenger/gnunet-service-messenger_member.h index fb2e57cfb..46269315a 100644 --- a/src/messenger/gnunet-service-messenger_member.h +++ b/src/messenger/gnunet-service-messenger_member.h | |||
@@ -52,7 +52,8 @@ struct GNUNET_MESSENGER_Member | |||
52 | * @return New member or NULL | 52 | * @return New member or NULL |
53 | */ | 53 | */ |
54 | struct GNUNET_MESSENGER_Member* | 54 | struct GNUNET_MESSENGER_Member* |
55 | create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id); | 55 | create_member (struct GNUNET_MESSENGER_MemberStore *store, |
56 | const struct GNUNET_ShortHashCode *id); | ||
56 | 57 | ||
57 | /** | 58 | /** |
58 | * Destroys a member and frees its memory fully. | 59 | * Destroys a member and frees its memory fully. |
@@ -80,7 +81,8 @@ get_member_id (const struct GNUNET_MESSENGER_Member *member); | |||
80 | * @param[in] directory Path to a directory | 81 | * @param[in] directory Path to a directory |
81 | */ | 82 | */ |
82 | void | 83 | void |
83 | load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory); | 84 | load_member (struct GNUNET_MESSENGER_MemberStore *store, |
85 | const char *directory); | ||
84 | 86 | ||
85 | /** | 87 | /** |
86 | * Loads data about next sessions from a <i>directory</i> into an empty loaded | 88 | * Loads data about next sessions from a <i>directory</i> into an empty loaded |
@@ -90,7 +92,8 @@ load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory); | |||
90 | * @param[in] directory Path to a directory | 92 | * @param[in] directory Path to a directory |
91 | */ | 93 | */ |
92 | void | 94 | void |
93 | load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory); | 95 | load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, |
96 | const char *directory); | ||
94 | 97 | ||
95 | /** | 98 | /** |
96 | * Saves data from a <i>member</i> into a directory which | 99 | * Saves data from a <i>member</i> into a directory which |
@@ -100,7 +103,8 @@ load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const c | |||
100 | * @param[in] directory Path to a directory | 103 | * @param[in] directory Path to a directory |
101 | */ | 104 | */ |
102 | void | 105 | void |
103 | save_member (struct GNUNET_MESSENGER_Member *member, const char *directory); | 106 | save_member (struct GNUNET_MESSENGER_Member *member, |
107 | const char *directory); | ||
104 | 108 | ||
105 | /** | 109 | /** |
106 | * Synchronizes contacts between all sessions from a given <i>member</i> | 110 | * Synchronizes contacts between all sessions from a given <i>member</i> |
@@ -120,7 +124,8 @@ sync_member_contacts (struct GNUNET_MESSENGER_Member *member); | |||
120 | * @return Member session | 124 | * @return Member session |
121 | */ | 125 | */ |
122 | struct GNUNET_MESSENGER_MemberSession* | 126 | struct GNUNET_MESSENGER_MemberSession* |
123 | get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key); | 127 | get_member_session (const struct GNUNET_MESSENGER_Member *member, |
128 | const struct GNUNET_IDENTITY_PublicKey *public_key); | ||
124 | 129 | ||
125 | /** | 130 | /** |
126 | * Returns the member session of a <i>member</i> using a public key which can verify | 131 | * Returns the member session of a <i>member</i> using a public key which can verify |
@@ -133,7 +138,8 @@ get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct G | |||
133 | * @return Member session | 138 | * @return Member session |
134 | */ | 139 | */ |
135 | struct GNUNET_MESSENGER_MemberSession* | 140 | struct GNUNET_MESSENGER_MemberSession* |
136 | get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, | 141 | get_member_session_of (struct GNUNET_MESSENGER_Member *member, |
142 | const struct GNUNET_MESSENGER_Message *message, | ||
137 | const struct GNUNET_HashCode *hash); | 143 | const struct GNUNET_HashCode *hash); |
138 | 144 | ||
139 | /** | 145 | /** |
@@ -143,7 +149,8 @@ get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUN | |||
143 | * @param[in/out] session Member session | 149 | * @param[in/out] session Member session |
144 | */ | 150 | */ |
145 | void | 151 | void |
146 | add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session); | 152 | add_member_session (struct GNUNET_MESSENGER_Member *member, |
153 | struct GNUNET_MESSENGER_MemberSession *session); | ||
147 | 154 | ||
148 | /** | 155 | /** |
149 | * Removes a given member <i>session</i> from its <i>member</i>. | 156 | * Removes a given member <i>session</i> from its <i>member</i>. |
@@ -152,7 +159,8 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN | |||
152 | * @param[in/out] session Member session | 159 | * @param[in/out] session Member session |
153 | */ | 160 | */ |
154 | void | 161 | void |
155 | remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session); | 162 | remove_member_session (struct GNUNET_MESSENGER_Member *member, |
163 | struct GNUNET_MESSENGER_MemberSession *session); | ||
156 | 164 | ||
157 | /** | 165 | /** |
158 | * Iterate through all member sessions currently connected to a given <i>member</i> | 166 | * Iterate through all member sessions currently connected to a given <i>member</i> |
@@ -165,6 +173,8 @@ remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MES | |||
165 | * @return Amount of sessions iterated through | 173 | * @return Amount of sessions iterated through |
166 | */ | 174 | */ |
167 | int | 175 | int |
168 | iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void* cls); | 176 | iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, |
177 | GNUNET_MESSENGER_MemberIteratorCallback it, | ||
178 | void* cls); | ||
169 | 179 | ||
170 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_H | 180 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_H |
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c index 690c703b2..03736941f 100644 --- a/src/messenger/gnunet-service-messenger_member_session.c +++ b/src/messenger/gnunet-service-messenger_member_session.c | |||
@@ -158,7 +158,9 @@ completion: | |||
158 | } | 158 | } |
159 | 159 | ||
160 | static int | 160 | static int |
161 | iterate_copy_history (void *cls, const struct GNUNET_HashCode *key, void *value) | 161 | iterate_copy_history (void *cls, |
162 | const struct GNUNET_HashCode *key, | ||
163 | void *value) | ||
162 | { | 164 | { |
163 | struct GNUNET_MESSENGER_MemberSession *next = cls; | 165 | struct GNUNET_MESSENGER_MemberSession *next = cls; |
164 | 166 | ||
@@ -460,7 +462,8 @@ struct GNUNET_MESSENGER_MemberSessionHistoryEntry | |||
460 | }; | 462 | }; |
461 | 463 | ||
462 | static void | 464 | static void |
463 | load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const char *path) | 465 | load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, |
466 | const char *path) | ||
464 | { | 467 | { |
465 | GNUNET_assert((session) && (path)); | 468 | GNUNET_assert((session) && (path)); |
466 | 469 | ||
@@ -502,7 +505,8 @@ load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, con | |||
502 | } | 505 | } |
503 | 506 | ||
504 | void | 507 | void |
505 | load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directory) | 508 | load_member_session (struct GNUNET_MESSENGER_Member *member, |
509 | const char *directory) | ||
506 | { | 510 | { |
507 | GNUNET_assert ((member) && (directory)); | 511 | GNUNET_assert ((member) && (directory)); |
508 | 512 | ||
@@ -571,7 +575,8 @@ free_config: | |||
571 | } | 575 | } |
572 | 576 | ||
573 | static struct GNUNET_MESSENGER_MemberSession* | 577 | static struct GNUNET_MESSENGER_MemberSession* |
574 | get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next) | 578 | get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session, |
579 | struct GNUNET_MESSENGER_MemberSession *next) | ||
575 | { | 580 | { |
576 | if (!next) | 581 | if (!next) |
577 | return NULL; | 582 | return NULL; |
@@ -589,7 +594,8 @@ get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session, str | |||
589 | } | 594 | } |
590 | 595 | ||
591 | void | 596 | void |
592 | load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const char *directory) | 597 | load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, |
598 | const char *directory) | ||
593 | { | 599 | { |
594 | GNUNET_assert ((session) && (directory)); | 600 | GNUNET_assert ((session) && (directory)); |
595 | 601 | ||
@@ -640,7 +646,9 @@ free_config: | |||
640 | } | 646 | } |
641 | 647 | ||
642 | static int | 648 | static int |
643 | iterate_save_member_session_history_hentries (void *cls, const struct GNUNET_HashCode *key, void *value) | 649 | iterate_save_member_session_history_hentries (void *cls, |
650 | const struct GNUNET_HashCode *key, | ||
651 | void *value) | ||
644 | { | 652 | { |
645 | struct GNUNET_DISK_FileHandle *handle = cls; | 653 | struct GNUNET_DISK_FileHandle *handle = cls; |
646 | unsigned char ownership = value? GNUNET_YES : GNUNET_NO; | 654 | unsigned char ownership = value? GNUNET_YES : GNUNET_NO; |
@@ -652,7 +660,8 @@ iterate_save_member_session_history_hentries (void *cls, const struct GNUNET_Has | |||
652 | } | 660 | } |
653 | 661 | ||
654 | static void | 662 | static void |
655 | save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const char *path) | 663 | save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, |
664 | const char *path) | ||
656 | { | 665 | { |
657 | GNUNET_assert((session) && (path)); | 666 | GNUNET_assert((session) && (path)); |
658 | 667 | ||
@@ -678,7 +687,8 @@ save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, con | |||
678 | } | 687 | } |
679 | 688 | ||
680 | void | 689 | void |
681 | save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char *directory) | 690 | save_member_session (struct GNUNET_MESSENGER_MemberSession *session, |
691 | const char *directory) | ||
682 | { | 692 | { |
683 | GNUNET_assert ((session) && (directory)); | 693 | GNUNET_assert ((session) && (directory)); |
684 | 694 | ||
diff --git a/src/messenger/gnunet-service-messenger_member_session.h b/src/messenger/gnunet-service-messenger_member_session.h index bf4d10f67..9ba801776 100644 --- a/src/messenger/gnunet-service-messenger_member_session.h +++ b/src/messenger/gnunet-service-messenger_member_session.h | |||
@@ -225,7 +225,8 @@ verify_member_session_as_sender (const struct GNUNET_MESSENGER_MemberSession *se | |||
225 | */ | 225 | */ |
226 | int | 226 | int |
227 | check_member_session_history (const struct GNUNET_MESSENGER_MemberSession *session, | 227 | check_member_session_history (const struct GNUNET_MESSENGER_MemberSession *session, |
228 | const struct GNUNET_HashCode *hash, int ownership); | 228 | const struct GNUNET_HashCode *hash, |
229 | int ownership); | ||
229 | 230 | ||
230 | /** | 231 | /** |
231 | * Adds a given <i>message</i> to the history of a <i>session</i> using the messages | 232 | * Adds a given <i>message</i> to the history of a <i>session</i> using the messages |
@@ -262,7 +263,8 @@ clear_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, | |||
262 | * @param[in] directory Path to a directory | 263 | * @param[in] directory Path to a directory |
263 | */ | 264 | */ |
264 | void | 265 | void |
265 | load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directory); | 266 | load_member_session (struct GNUNET_MESSENGER_Member *member, |
267 | const char *directory); | ||
266 | 268 | ||
267 | /** | 269 | /** |
268 | * Loads the connection from one <i>session</i> to another through the | 270 | * Loads the connection from one <i>session</i> to another through the |
@@ -273,7 +275,8 @@ load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directo | |||
273 | * @param[in] directory Path to a directory | 275 | * @param[in] directory Path to a directory |
274 | */ | 276 | */ |
275 | void | 277 | void |
276 | load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const char *directory); | 278 | load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, |
279 | const char *directory); | ||
277 | 280 | ||
278 | /** | 281 | /** |
279 | * Saves data from a member <i>session</i> into a <i>directory</i> which can be | 282 | * Saves data from a member <i>session</i> into a <i>directory</i> which can be |
@@ -283,6 +286,7 @@ load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const | |||
283 | * @param[in] directory Path to a directory | 286 | * @param[in] directory Path to a directory |
284 | */ | 287 | */ |
285 | void | 288 | void |
286 | save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char *directory); | 289 | save_member_session (struct GNUNET_MESSENGER_MemberSession *session, |
290 | const char *directory); | ||
287 | 291 | ||
288 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H | 292 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H |
diff --git a/src/messenger/gnunet-service-messenger_member_store.c b/src/messenger/gnunet-service-messenger_member_store.c index 2925965d4..e96ee3883 100644 --- a/src/messenger/gnunet-service-messenger_member_store.c +++ b/src/messenger/gnunet-service-messenger_member_store.c | |||
@@ -30,7 +30,8 @@ | |||
30 | #include "gnunet-service-messenger_room.h" | 30 | #include "gnunet-service-messenger_room.h" |
31 | 31 | ||
32 | void | 32 | void |
33 | init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room) | 33 | init_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
34 | struct GNUNET_MESSENGER_SrvRoom *room) | ||
34 | { | 35 | { |
35 | GNUNET_assert ((store) && (room)); | 36 | GNUNET_assert ((store) && (room)); |
36 | 37 | ||
@@ -39,7 +40,9 @@ init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MES | |||
39 | } | 40 | } |
40 | 41 | ||
41 | static int | 42 | static int |
42 | iterate_destroy_members (void *cls, const struct GNUNET_ShortHashCode *key, void *value) | 43 | iterate_destroy_members (void *cls, |
44 | const struct GNUNET_ShortHashCode *key, | ||
45 | void *value) | ||
43 | { | 46 | { |
44 | struct GNUNET_MESSENGER_Member *member = value; | 47 | struct GNUNET_MESSENGER_Member *member = value; |
45 | destroy_member(member); | 48 | destroy_member(member); |
@@ -75,7 +78,8 @@ get_member_store_key (const struct GNUNET_MESSENGER_MemberStore *store) | |||
75 | } | 78 | } |
76 | 79 | ||
77 | static int | 80 | static int |
78 | callback_scan_for_members (void *cls, const char *filename) | 81 | callback_scan_for_members (void *cls, |
82 | const char *filename) | ||
79 | { | 83 | { |
80 | struct GNUNET_MESSENGER_MemberStore *store = cls; | 84 | struct GNUNET_MESSENGER_MemberStore *store = cls; |
81 | 85 | ||
@@ -94,7 +98,9 @@ callback_scan_for_members (void *cls, const char *filename) | |||
94 | } | 98 | } |
95 | 99 | ||
96 | static int | 100 | static int |
97 | iterate_load_next_member_sessions (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 101 | iterate_load_next_member_sessions (void *cls, |
102 | const struct GNUNET_ShortHashCode *id, | ||
103 | void *value) | ||
98 | { | 104 | { |
99 | const char *sync_dir = cls; | 105 | const char *sync_dir = cls; |
100 | 106 | ||
@@ -114,7 +120,9 @@ iterate_load_next_member_sessions (void *cls, const struct GNUNET_ShortHashCode | |||
114 | } | 120 | } |
115 | 121 | ||
116 | static int | 122 | static int |
117 | iterate_sync_member_contacts (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 123 | iterate_sync_member_contacts (void *cls, |
124 | const struct GNUNET_ShortHashCode *id, | ||
125 | void *value) | ||
118 | { | 126 | { |
119 | struct GNUNET_MESSENGER_Member *member = value; | 127 | struct GNUNET_MESSENGER_Member *member = value; |
120 | 128 | ||
@@ -126,7 +134,8 @@ iterate_sync_member_contacts (void *cls, const struct GNUNET_ShortHashCode *id, | |||
126 | } | 134 | } |
127 | 135 | ||
128 | void | 136 | void |
129 | load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory) | 137 | load_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
138 | const char *directory) | ||
130 | { | 139 | { |
131 | GNUNET_assert ((store) && (directory)); | 140 | GNUNET_assert ((store) && (directory)); |
132 | 141 | ||
@@ -143,7 +152,9 @@ load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc | |||
143 | } | 152 | } |
144 | 153 | ||
145 | static int | 154 | static int |
146 | iterate_save_members (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 155 | iterate_save_members (void *cls, |
156 | const struct GNUNET_ShortHashCode *id, | ||
157 | void *value) | ||
147 | { | 158 | { |
148 | const char *save_dir = cls; | 159 | const char *save_dir = cls; |
149 | 160 | ||
@@ -164,7 +175,8 @@ iterate_save_members (void *cls, const struct GNUNET_ShortHashCode *id, void *va | |||
164 | } | 175 | } |
165 | 176 | ||
166 | void | 177 | void |
167 | save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory) | 178 | save_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
179 | const char *directory) | ||
168 | { | 180 | { |
169 | GNUNET_assert ((store) && (directory)); | 181 | GNUNET_assert ((store) && (directory)); |
170 | 182 | ||
@@ -179,7 +191,8 @@ save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc | |||
179 | } | 191 | } |
180 | 192 | ||
181 | struct GNUNET_MESSENGER_Member* | 193 | struct GNUNET_MESSENGER_Member* |
182 | get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id) | 194 | get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, |
195 | const struct GNUNET_ShortHashCode *id) | ||
183 | { | 196 | { |
184 | GNUNET_assert ((store) && (store->members) && (id)); | 197 | GNUNET_assert ((store) && (store->members) && (id)); |
185 | 198 | ||
@@ -187,7 +200,8 @@ get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct | |||
187 | } | 200 | } |
188 | 201 | ||
189 | struct GNUNET_MESSENGER_Member* | 202 | struct GNUNET_MESSENGER_Member* |
190 | get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message) | 203 | get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, |
204 | const struct GNUNET_MESSENGER_Message *message) | ||
191 | { | 205 | { |
192 | if ((GNUNET_MESSENGER_KIND_INFO == message->header.kind) || | 206 | if ((GNUNET_MESSENGER_KIND_INFO == message->header.kind) || |
193 | (GNUNET_MESSENGER_KIND_JOIN == message->header.kind)) | 207 | (GNUNET_MESSENGER_KIND_JOIN == message->header.kind)) |
@@ -197,7 +211,8 @@ get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GN | |||
197 | } | 211 | } |
198 | 212 | ||
199 | struct GNUNET_MESSENGER_Member* | 213 | struct GNUNET_MESSENGER_Member* |
200 | add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id) | 214 | add_store_member (struct GNUNET_MESSENGER_MemberStore *store, |
215 | const struct GNUNET_ShortHashCode *id) | ||
201 | { | 216 | { |
202 | GNUNET_assert ((store) && (store->members)); | 217 | GNUNET_assert ((store) && (store->members)); |
203 | 218 | ||
@@ -227,7 +242,9 @@ struct GNUNET_MESSENGER_ClosureIterateMembers { | |||
227 | }; | 242 | }; |
228 | 243 | ||
229 | static int | 244 | static int |
230 | iterate_store_members_it (void *cls, const struct GNUNET_ShortHashCode *key, void *value) | 245 | iterate_store_members_it (void *cls, |
246 | const struct GNUNET_ShortHashCode *key, | ||
247 | void *value) | ||
231 | { | 248 | { |
232 | struct GNUNET_MESSENGER_ClosureIterateMembers *iterate = cls; | 249 | struct GNUNET_MESSENGER_ClosureIterateMembers *iterate = cls; |
233 | struct GNUNET_MESSENGER_Member *member = value; | 250 | struct GNUNET_MESSENGER_Member *member = value; |
@@ -236,7 +253,8 @@ iterate_store_members_it (void *cls, const struct GNUNET_ShortHashCode *key, voi | |||
236 | } | 253 | } |
237 | 254 | ||
238 | int | 255 | int |
239 | iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, | 256 | iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, |
257 | GNUNET_MESSENGER_MemberIteratorCallback it, | ||
240 | void* cls) | 258 | void* cls) |
241 | { | 259 | { |
242 | GNUNET_assert ((store) && (store->members) && (it)); | 260 | GNUNET_assert ((store) && (store->members) && (it)); |
diff --git a/src/messenger/gnunet-service-messenger_member_store.h b/src/messenger/gnunet-service-messenger_member_store.h index 859e4683d..af50f0d36 100644 --- a/src/messenger/gnunet-service-messenger_member_store.h +++ b/src/messenger/gnunet-service-messenger_member_store.h | |||
@@ -56,7 +56,8 @@ typedef int (*GNUNET_MESSENGER_MemberIteratorCallback) ( | |||
56 | * @param room Room | 56 | * @param room Room |
57 | */ | 57 | */ |
58 | void | 58 | void |
59 | init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room); | 59 | init_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
60 | struct GNUNET_MESSENGER_SrvRoom *room); | ||
60 | 61 | ||
61 | /** | 62 | /** |
62 | * Clears a member <i>store</i>, wipes its content and deallocates its memory. | 63 | * Clears a member <i>store</i>, wipes its content and deallocates its memory. |
@@ -91,7 +92,8 @@ get_member_store_key (const struct GNUNET_MESSENGER_MemberStore *store); | |||
91 | * @param[in] directory Path to a directory | 92 | * @param[in] directory Path to a directory |
92 | */ | 93 | */ |
93 | void | 94 | void |
94 | load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory); | 95 | load_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
96 | const char *directory); | ||
95 | 97 | ||
96 | /** | 98 | /** |
97 | * Saves members from a member <i>store</i> into a directory. | 99 | * Saves members from a member <i>store</i> into a directory. |
@@ -100,7 +102,8 @@ load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc | |||
100 | * @param[in] directory Path to a directory | 102 | * @param[in] directory Path to a directory |
101 | */ | 103 | */ |
102 | void | 104 | void |
103 | save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory); | 105 | save_member_store (struct GNUNET_MESSENGER_MemberStore *store, |
106 | const char *directory); | ||
104 | 107 | ||
105 | /** | 108 | /** |
106 | * Returns the member in a <i>store</i> identified by a given <i>id</i>. If the <i>store</i> | 109 | * Returns the member in a <i>store</i> identified by a given <i>id</i>. If the <i>store</i> |
@@ -111,7 +114,8 @@ save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc | |||
111 | * @return Member or NULL | 114 | * @return Member or NULL |
112 | */ | 115 | */ |
113 | struct GNUNET_MESSENGER_Member* | 116 | struct GNUNET_MESSENGER_Member* |
114 | get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id); | 117 | get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, |
118 | const struct GNUNET_ShortHashCode *id); | ||
115 | 119 | ||
116 | /** | 120 | /** |
117 | * Returns the member of a <i>store</i> using a sender id of a given <i>message</i>. | 121 | * Returns the member of a <i>store</i> using a sender id of a given <i>message</i>. |
@@ -122,7 +126,8 @@ get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct | |||
122 | * @return Member or NULL | 126 | * @return Member or NULL |
123 | */ | 127 | */ |
124 | struct GNUNET_MESSENGER_Member* | 128 | struct GNUNET_MESSENGER_Member* |
125 | get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message); | 129 | get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, |
130 | const struct GNUNET_MESSENGER_Message *message); | ||
126 | 131 | ||
127 | /** | 132 | /** |
128 | * Adds a member to a <i>store</i> under a specific <i>id</i> and returns it on success. | 133 | * Adds a member to a <i>store</i> under a specific <i>id</i> and returns it on success. |
@@ -132,7 +137,8 @@ get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GN | |||
132 | * @return Member or NULL | 137 | * @return Member or NULL |
133 | */ | 138 | */ |
134 | struct GNUNET_MESSENGER_Member* | 139 | struct GNUNET_MESSENGER_Member* |
135 | add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id); | 140 | add_store_member (struct GNUNET_MESSENGER_MemberStore *store, |
141 | const struct GNUNET_ShortHashCode *id); | ||
136 | 142 | ||
137 | /** | 143 | /** |
138 | * Iterate through all member sessions currently connected to the members of the given | 144 | * Iterate through all member sessions currently connected to the members of the given |
@@ -145,7 +151,8 @@ add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNE | |||
145 | * @return Amount of members iterated through | 151 | * @return Amount of members iterated through |
146 | */ | 152 | */ |
147 | int | 153 | int |
148 | iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, | 154 | iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, |
155 | GNUNET_MESSENGER_MemberIteratorCallback it, | ||
149 | void* cls); | 156 | void* cls); |
150 | 157 | ||
151 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H | 158 | #endif //GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H |
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c index 86f2b901a..701d78c89 100644 --- a/src/messenger/gnunet-service-messenger_message_handle.c +++ b/src/messenger/gnunet-service-messenger_message_handle.c | |||
@@ -27,7 +27,8 @@ | |||
27 | 27 | ||
28 | static void | 28 | static void |
29 | handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session, | 29 | handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session, |
30 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 30 | const struct GNUNET_MESSENGER_Message *message, |
31 | const struct GNUNET_HashCode *hash) | ||
31 | { | 32 | { |
32 | struct GNUNET_MESSENGER_MemberSession *next = switch_member_session(session, message, hash); | 33 | struct GNUNET_MESSENGER_MemberSession *next = switch_member_session(session, message, hash); |
33 | 34 | ||
@@ -36,8 +37,10 @@ handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session, | |||
36 | } | 37 | } |
37 | 38 | ||
38 | void | 39 | void |
39 | handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 40 | handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, |
40 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 41 | struct GNUNET_MESSENGER_MemberSession *session, |
42 | const struct GNUNET_MESSENGER_Message *message, | ||
43 | const struct GNUNET_HashCode *hash) | ||
41 | { | 44 | { |
42 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n", | 45 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n", |
43 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); | 46 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); |
@@ -54,8 +57,10 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
54 | } | 57 | } |
55 | 58 | ||
56 | void | 59 | void |
57 | handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 60 | handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, |
58 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 61 | struct GNUNET_MESSENGER_MemberSession *session, |
62 | const struct GNUNET_MESSENGER_Message *message, | ||
63 | const struct GNUNET_HashCode *hash) | ||
59 | { | 64 | { |
60 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n", | 65 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n", |
61 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); | 66 | GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room))); |
@@ -64,8 +69,10 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE | |||
64 | } | 69 | } |
65 | 70 | ||
66 | void | 71 | void |
67 | handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 72 | handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, |
68 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 73 | struct GNUNET_MESSENGER_MemberSession *session, |
74 | const struct GNUNET_MESSENGER_Message *message, | ||
75 | const struct GNUNET_HashCode *hash) | ||
69 | { | 76 | { |
70 | struct GNUNET_MESSENGER_Contact *contact = get_member_session_contact(session); | 77 | struct GNUNET_MESSENGER_Contact *contact = get_member_session_contact(session); |
71 | 78 | ||
@@ -76,15 +83,19 @@ handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
76 | } | 83 | } |
77 | 84 | ||
78 | void | 85 | void |
79 | handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 86 | handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, |
80 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 87 | struct GNUNET_MESSENGER_MemberSession *session, |
88 | const struct GNUNET_MESSENGER_Message *message, | ||
89 | const struct GNUNET_HashCode *hash) | ||
81 | { | 90 | { |
82 | handle_session_switch (session, message, hash); | 91 | handle_session_switch (session, message, hash); |
83 | } | 92 | } |
84 | 93 | ||
85 | void | 94 | void |
86 | handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 95 | handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
87 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 96 | struct GNUNET_MESSENGER_MemberSession *session, |
97 | const struct GNUNET_MESSENGER_Message *message, | ||
98 | const struct GNUNET_HashCode *hash) | ||
88 | { | 99 | { |
89 | if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer))) | 100 | if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer))) |
90 | add_to_list_tunnels (&(room->basement), &(message->body.peer.peer)); | 101 | add_to_list_tunnels (&(room->basement), &(message->body.peer.peer)); |
@@ -94,8 +105,10 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
94 | } | 105 | } |
95 | 106 | ||
96 | void | 107 | void |
97 | handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 108 | handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, |
98 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 109 | struct GNUNET_MESSENGER_MemberSession *session, |
110 | const struct GNUNET_MESSENGER_Message *message, | ||
111 | const struct GNUNET_HashCode *hash) | ||
99 | { | 112 | { |
100 | handle_session_switch (session, message, hash); | 113 | handle_session_switch (session, message, hash); |
101 | 114 | ||
@@ -108,8 +121,10 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
108 | } | 121 | } |
109 | 122 | ||
110 | void | 123 | void |
111 | handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 124 | handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, |
112 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 125 | struct GNUNET_MESSENGER_MemberSession *session, |
126 | const struct GNUNET_MESSENGER_Message *message, | ||
127 | const struct GNUNET_HashCode *hash) | ||
113 | { | 128 | { |
114 | struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL); | 129 | struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL); |
115 | 130 | ||
@@ -123,8 +138,10 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
123 | } | 138 | } |
124 | 139 | ||
125 | void | 140 | void |
126 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 141 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, |
127 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 142 | struct GNUNET_MESSENGER_MemberSession *session, |
143 | const struct GNUNET_MESSENGER_Message *message, | ||
144 | const struct GNUNET_HashCode *hash) | ||
128 | { | 145 | { |
129 | struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.deletion.delay); | 146 | struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.deletion.delay); |
130 | struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp); | 147 | struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp); |
diff --git a/src/messenger/gnunet-service-messenger_message_handle.h b/src/messenger/gnunet-service-messenger_message_handle.h index 844142b77..0e5be3408 100644 --- a/src/messenger/gnunet-service-messenger_message_handle.h +++ b/src/messenger/gnunet-service-messenger_message_handle.h | |||
@@ -45,8 +45,10 @@ | |||
45 | * @param[in] hash Hash of the message | 45 | * @param[in] hash Hash of the message |
46 | */ | 46 | */ |
47 | void | 47 | void |
48 | handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 48 | handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, |
49 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 49 | struct GNUNET_MESSENGER_MemberSession *session, |
50 | const struct GNUNET_MESSENGER_Message *message, | ||
51 | const struct GNUNET_HashCode *hash); | ||
50 | 52 | ||
51 | /** | 53 | /** |
52 | * Handles a received or sent leave message to make changes of current member information. | 54 | * Handles a received or sent leave message to make changes of current member information. |
@@ -58,8 +60,10 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
58 | * @param[in] hash Hash of the message | 60 | * @param[in] hash Hash of the message |
59 | */ | 61 | */ |
60 | void | 62 | void |
61 | handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 63 | handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, |
62 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 64 | struct GNUNET_MESSENGER_MemberSession *session, |
65 | const struct GNUNET_MESSENGER_Message *message, | ||
66 | const struct GNUNET_HashCode *hash); | ||
63 | 67 | ||
64 | /** | 68 | /** |
65 | * Handles a received or sent name message to rename a current member. | 69 | * Handles a received or sent name message to rename a current member. |
@@ -71,8 +75,10 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE | |||
71 | * @param[in] hash Hash of the message | 75 | * @param[in] hash Hash of the message |
72 | */ | 76 | */ |
73 | void | 77 | void |
74 | handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 78 | handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, |
75 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 79 | struct GNUNET_MESSENGER_MemberSession *session, |
80 | const struct GNUNET_MESSENGER_Message *message, | ||
81 | const struct GNUNET_HashCode *hash); | ||
76 | 82 | ||
77 | /** | 83 | /** |
78 | * Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly. | 84 | * Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly. |
@@ -84,8 +90,10 @@ handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
84 | * @param[in] hash Hash of the message | 90 | * @param[in] hash Hash of the message |
85 | */ | 91 | */ |
86 | void | 92 | void |
87 | handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 93 | handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, |
88 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 94 | struct GNUNET_MESSENGER_MemberSession *session, |
95 | const struct GNUNET_MESSENGER_Message *message, | ||
96 | const struct GNUNET_HashCode *hash); | ||
89 | 97 | ||
90 | /** | 98 | /** |
91 | * Handles a received or sent peer message to make changes of the basement in the room. | 99 | * Handles a received or sent peer message to make changes of the basement in the room. |
@@ -97,8 +105,10 @@ handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENG | |||
97 | * @param[in] hash Hash of the message | 105 | * @param[in] hash Hash of the message |
98 | */ | 106 | */ |
99 | void | 107 | void |
100 | handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 108 | handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
101 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 109 | struct GNUNET_MESSENGER_MemberSession *session, |
110 | const struct GNUNET_MESSENGER_Message *message, | ||
111 | const struct GNUNET_HashCode *hash); | ||
102 | 112 | ||
103 | /** | 113 | /** |
104 | * Handles a received or sent id message to change a members id. | 114 | * Handles a received or sent id message to change a members id. |
@@ -110,8 +120,10 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
110 | * @param[in] hash Hash of the message | 120 | * @param[in] hash Hash of the message |
111 | */ | 121 | */ |
112 | void | 122 | void |
113 | handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 123 | handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, |
114 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 124 | struct GNUNET_MESSENGER_MemberSession *session, |
125 | const struct GNUNET_MESSENGER_Message *message, | ||
126 | const struct GNUNET_HashCode *hash); | ||
115 | 127 | ||
116 | /** | 128 | /** |
117 | * Handles a received or sent miss message to drop a peer from the basement in the room. | 129 | * Handles a received or sent miss message to drop a peer from the basement in the room. |
@@ -123,8 +135,10 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
123 | * @param[in] hash Hash of the message | 135 | * @param[in] hash Hash of the message |
124 | */ | 136 | */ |
125 | void | 137 | void |
126 | handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 138 | handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, |
127 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 139 | struct GNUNET_MESSENGER_MemberSession *session, |
140 | const struct GNUNET_MESSENGER_Message *message, | ||
141 | const struct GNUNET_HashCode *hash); | ||
128 | 142 | ||
129 | /** | 143 | /** |
130 | * Handles a received or sent delete message to delete a specific message from the store. | 144 | * Handles a received or sent delete message to delete a specific message from the store. |
@@ -136,7 +150,9 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN | |||
136 | * @param[in] hash Hash of the message | 150 | * @param[in] hash Hash of the message |
137 | */ | 151 | */ |
138 | void | 152 | void |
139 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 153 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, |
140 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 154 | struct GNUNET_MESSENGER_MemberSession *session, |
155 | const struct GNUNET_MESSENGER_Message *message, | ||
156 | const struct GNUNET_HashCode *hash); | ||
141 | 157 | ||
142 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H | 158 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H |
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c index 3edcade91..2449b9230 100644 --- a/src/messenger/gnunet-service-messenger_message_kind.c +++ b/src/messenger/gnunet-service-messenger_message_kind.c | |||
@@ -190,7 +190,8 @@ create_message_request (const struct GNUNET_HashCode *hash) | |||
190 | } | 190 | } |
191 | 191 | ||
192 | struct GNUNET_MESSENGER_Message* | 192 | struct GNUNET_MESSENGER_Message* |
193 | create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key) | 193 | create_message_invite (const struct GNUNET_PeerIdentity *door, |
194 | const struct GNUNET_HashCode *key) | ||
194 | { | 195 | { |
195 | if ((!door) || (!key)) | 196 | if ((!door) || (!key)) |
196 | return NULL; | 197 | return NULL; |
@@ -222,7 +223,8 @@ create_message_text (const char *text) | |||
222 | } | 223 | } |
223 | 224 | ||
224 | struct GNUNET_MESSENGER_Message* | 225 | struct GNUNET_MESSENGER_Message* |
225 | create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay) | 226 | create_message_delete (const struct GNUNET_HashCode *hash, |
227 | const struct GNUNET_TIME_Relative delay) | ||
226 | { | 228 | { |
227 | if (!hash) | 229 | if (!hash) |
228 | return NULL; | 230 | return NULL; |
diff --git a/src/messenger/gnunet-service-messenger_message_kind.h b/src/messenger/gnunet-service-messenger_message_kind.h index c098868c0..508f19074 100644 --- a/src/messenger/gnunet-service-messenger_message_kind.h +++ b/src/messenger/gnunet-service-messenger_message_kind.h | |||
@@ -146,7 +146,8 @@ create_message_request (const struct GNUNET_HashCode *hash); | |||
146 | * @return New message | 146 | * @return New message |
147 | */ | 147 | */ |
148 | struct GNUNET_MESSENGER_Message* | 148 | struct GNUNET_MESSENGER_Message* |
149 | create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key); | 149 | create_message_invite (const struct GNUNET_PeerIdentity *door, |
150 | const struct GNUNET_HashCode *key); | ||
150 | 151 | ||
151 | /** | 152 | /** |
152 | * Creates and allocates a new <i>text message containing a string representing text. | 153 | * Creates and allocates a new <i>text message containing a string representing text. |
@@ -167,6 +168,7 @@ create_message_text (const char *text); | |||
167 | * @return New message | 168 | * @return New message |
168 | */ | 169 | */ |
169 | struct GNUNET_MESSENGER_Message* | 170 | struct GNUNET_MESSENGER_Message* |
170 | create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay); | 171 | create_message_delete (const struct GNUNET_HashCode *hash, |
172 | const struct GNUNET_TIME_Relative delay); | ||
171 | 173 | ||
172 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H | 174 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H |
diff --git a/src/messenger/gnunet-service-messenger_message_recv.c b/src/messenger/gnunet-service-messenger_message_recv.c index b2a5052d2..bb6ee6f17 100644 --- a/src/messenger/gnunet-service-messenger_message_recv.c +++ b/src/messenger/gnunet-service-messenger_message_recv.c | |||
@@ -28,8 +28,10 @@ | |||
28 | #include "gnunet-service-messenger_operation.h" | 28 | #include "gnunet-service-messenger_operation.h" |
29 | 29 | ||
30 | static void | 30 | static void |
31 | forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 31 | forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room, |
32 | struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map) | 32 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
33 | struct GNUNET_MESSENGER_MemberSession *session, | ||
34 | struct GNUNET_CONTAINER_MultiHashMap *map) | ||
33 | { | 35 | { |
34 | if (session->prev) | 36 | if (session->prev) |
35 | forward_about_members (room, tunnel, session->prev, map); | 37 | forward_about_members (room, tunnel, session->prev, map); |
@@ -54,8 +56,9 @@ forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESS | |||
54 | } | 56 | } |
55 | 57 | ||
56 | static int | 58 | static int |
57 | iterate_forward_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, | 59 | iterate_forward_members (void *cls, |
58 | struct GNUNET_MESSENGER_MemberSession *session) | 60 | const struct GNUNET_IDENTITY_PublicKey *public_key, |
61 | struct GNUNET_MESSENGER_MemberSession *session) | ||
59 | { | 62 | { |
60 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; | 63 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; |
61 | 64 | ||
@@ -71,8 +74,10 @@ iterate_forward_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *publ | |||
71 | } | 74 | } |
72 | 75 | ||
73 | int | 76 | int |
74 | recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 77 | recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, |
75 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 78 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
79 | const struct GNUNET_MESSENGER_Message *message, | ||
80 | const struct GNUNET_HashCode *hash) | ||
76 | { | 81 | { |
77 | const uint32_t version = get_tunnel_messenger_version(tunnel); | 82 | const uint32_t version = get_tunnel_messenger_version(tunnel); |
78 | 83 | ||
@@ -108,8 +113,10 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
108 | } | 113 | } |
109 | 114 | ||
110 | int | 115 | int |
111 | recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 116 | recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
112 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 117 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
118 | const struct GNUNET_MESSENGER_Message *message, | ||
119 | const struct GNUNET_HashCode *hash) | ||
113 | { | 120 | { |
114 | struct GNUNET_PeerIdentity peer; | 121 | struct GNUNET_PeerIdentity peer; |
115 | GNUNET_PEER_resolve (tunnel->peer, &peer); | 122 | GNUNET_PEER_resolve (tunnel->peer, &peer); |
@@ -126,7 +133,8 @@ recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
126 | } | 133 | } |
127 | 134 | ||
128 | static void | 135 | static void |
129 | callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | 136 | callback_found_message (void *cls, |
137 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
130 | const struct GNUNET_MESSENGER_Message *message, | 138 | const struct GNUNET_MESSENGER_Message *message, |
131 | const struct GNUNET_HashCode *hash) | 139 | const struct GNUNET_HashCode *hash) |
132 | { | 140 | { |
@@ -152,8 +160,10 @@ callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | |||
152 | * It will only be forwarded if it can't be answered! | 160 | * It will only be forwarded if it can't be answered! |
153 | */ | 161 | */ |
154 | int | 162 | int |
155 | recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 163 | recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, |
156 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 164 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
165 | const struct GNUNET_MESSENGER_Message *message, | ||
166 | const struct GNUNET_HashCode *hash) | ||
157 | { | 167 | { |
158 | struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); | 168 | struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); |
159 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message); | 169 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message); |
diff --git a/src/messenger/gnunet-service-messenger_message_recv.h b/src/messenger/gnunet-service-messenger_message_recv.h index 9cb36c466..400c10245 100644 --- a/src/messenger/gnunet-service-messenger_message_recv.h +++ b/src/messenger/gnunet-service-messenger_message_recv.h | |||
@@ -46,8 +46,10 @@ | |||
46 | * @return #GNUNET_NO to not forward the message | 46 | * @return #GNUNET_NO to not forward the message |
47 | */ | 47 | */ |
48 | int | 48 | int |
49 | recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 49 | recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, |
50 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 50 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
51 | const struct GNUNET_MESSENGER_Message *message, | ||
52 | const struct GNUNET_HashCode *hash); | ||
51 | 53 | ||
52 | /** | 54 | /** |
53 | * Handles a received peer message to link it to its origin tunnel if the peer identity matches. | 55 | * Handles a received peer message to link it to its origin tunnel if the peer identity matches. |
@@ -60,8 +62,10 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
60 | * @return #GNUNET_YES to forward the message | 62 | * @return #GNUNET_YES to forward the message |
61 | */ | 63 | */ |
62 | int | 64 | int |
63 | recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 65 | recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
64 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 66 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
67 | const struct GNUNET_MESSENGER_Message *message, | ||
68 | const struct GNUNET_HashCode *hash); | ||
65 | 69 | ||
66 | /** | 70 | /** |
67 | * Handles a received request message by checking for the requested message and forwarding it back | 71 | * Handles a received request message by checking for the requested message and forwarding it back |
@@ -75,7 +79,9 @@ recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
75 | * @return #GNUNET_YES or #GNUNET_NO depending on required forwarding | 79 | * @return #GNUNET_YES or #GNUNET_NO depending on required forwarding |
76 | */ | 80 | */ |
77 | int | 81 | int |
78 | recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 82 | recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, |
79 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 83 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
84 | const struct GNUNET_MESSENGER_Message *message, | ||
85 | const struct GNUNET_HashCode *hash); | ||
80 | 86 | ||
81 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H | 87 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H |
diff --git a/src/messenger/gnunet-service-messenger_message_send.c b/src/messenger/gnunet-service-messenger_message_send.c index a59a178cc..8cc2466d7 100644 --- a/src/messenger/gnunet-service-messenger_message_send.c +++ b/src/messenger/gnunet-service-messenger_message_send.c | |||
@@ -30,15 +30,19 @@ | |||
30 | #include "gnunet-service-messenger_operation.h" | 30 | #include "gnunet-service-messenger_operation.h" |
31 | 31 | ||
32 | void | 32 | void |
33 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 33 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, |
34 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 34 | struct GNUNET_MESSENGER_SrvHandle *handle, |
35 | const struct GNUNET_MESSENGER_Message *message, | ||
36 | const struct GNUNET_HashCode *hash) | ||
35 | { | 37 | { |
36 | check_room_peer_status(room, NULL); | 38 | check_room_peer_status(room, NULL); |
37 | } | 39 | } |
38 | 40 | ||
39 | void | 41 | void |
40 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 42 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
41 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 43 | struct GNUNET_MESSENGER_SrvHandle *handle, |
44 | const struct GNUNET_MESSENGER_Message *message, | ||
45 | const struct GNUNET_HashCode *hash) | ||
42 | { | 46 | { |
43 | if (!room->peer_message) | 47 | if (!room->peer_message) |
44 | room->peer_message = GNUNET_new(struct GNUNET_HashCode); | 48 | room->peer_message = GNUNET_new(struct GNUNET_HashCode); |
@@ -47,15 +51,19 @@ send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
47 | } | 51 | } |
48 | 52 | ||
49 | void | 53 | void |
50 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 54 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, |
51 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 55 | struct GNUNET_MESSENGER_SrvHandle *handle, |
56 | const struct GNUNET_MESSENGER_Message *message, | ||
57 | const struct GNUNET_HashCode *hash) | ||
52 | { | 58 | { |
53 | change_handle_member_id (handle, get_room_key(room), &(message->body.id.id)); | 59 | change_handle_member_id (handle, get_room_key(room), &(message->body.id.id)); |
54 | } | 60 | } |
55 | 61 | ||
56 | void | 62 | void |
57 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 63 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, |
58 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 64 | struct GNUNET_MESSENGER_SrvHandle *handle, |
65 | const struct GNUNET_MESSENGER_Message *message, | ||
66 | const struct GNUNET_HashCode *hash) | ||
59 | { | 67 | { |
60 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room); | 68 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room); |
61 | 69 | ||
diff --git a/src/messenger/gnunet-service-messenger_message_send.h b/src/messenger/gnunet-service-messenger_message_send.h index 63320ab17..232355c41 100644 --- a/src/messenger/gnunet-service-messenger_message_send.h +++ b/src/messenger/gnunet-service-messenger_message_send.h | |||
@@ -44,8 +44,10 @@ | |||
44 | * @param[in] hash Hash of the message | 44 | * @param[in] hash Hash of the message |
45 | */ | 45 | */ |
46 | void | 46 | void |
47 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 47 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, |
48 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 48 | struct GNUNET_MESSENGER_SrvHandle *handle, |
49 | const struct GNUNET_MESSENGER_Message *message, | ||
50 | const struct GNUNET_HashCode *hash); | ||
49 | 51 | ||
50 | /** | 52 | /** |
51 | * Handles a sent peer message to update the rooms peer message of this service. | 53 | * Handles a sent peer message to update the rooms peer message of this service. |
@@ -57,8 +59,10 @@ send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
57 | * @param[in] hash Hash of the message | 59 | * @param[in] hash Hash of the message |
58 | */ | 60 | */ |
59 | void | 61 | void |
60 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 62 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
61 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 63 | struct GNUNET_MESSENGER_SrvHandle *handle, |
64 | const struct GNUNET_MESSENGER_Message *message, | ||
65 | const struct GNUNET_HashCode *hash); | ||
62 | 66 | ||
63 | /** | 67 | /** |
64 | * Handles a sent id message to update the handles member id in the room. | 68 | * Handles a sent id message to update the handles member id in the room. |
@@ -70,8 +74,10 @@ send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
70 | * @param[in] hash Hash of the message | 74 | * @param[in] hash Hash of the message |
71 | */ | 75 | */ |
72 | void | 76 | void |
73 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 77 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, |
74 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 78 | struct GNUNET_MESSENGER_SrvHandle *handle, |
79 | const struct GNUNET_MESSENGER_Message *message, | ||
80 | const struct GNUNET_HashCode *hash); | ||
75 | 81 | ||
76 | /** | 82 | /** |
77 | * Handles a sent request message to trigger the request operation for this service. | 83 | * Handles a sent request message to trigger the request operation for this service. |
@@ -83,7 +89,9 @@ send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_ | |||
83 | * @param[in] hash Hash of the message | 89 | * @param[in] hash Hash of the message |
84 | */ | 90 | */ |
85 | void | 91 | void |
86 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 92 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, |
87 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 93 | struct GNUNET_MESSENGER_SrvHandle *handle, |
94 | const struct GNUNET_MESSENGER_Message *message, | ||
95 | const struct GNUNET_HashCode *hash); | ||
88 | 96 | ||
89 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H | 97 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H |
diff --git a/src/messenger/gnunet-service-messenger_message_state.c b/src/messenger/gnunet-service-messenger_message_state.c index cdd2d9712..344962d11 100644 --- a/src/messenger/gnunet-service-messenger_message_state.c +++ b/src/messenger/gnunet-service-messenger_message_state.c | |||
@@ -65,8 +65,10 @@ get_message_state_merge_hash (const struct GNUNET_MESSENGER_MessageState *state) | |||
65 | } | 65 | } |
66 | 66 | ||
67 | void | 67 | void |
68 | update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested, | 68 | update_message_state (struct GNUNET_MESSENGER_MessageState *state, |
69 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 69 | int requested, |
70 | const struct GNUNET_MESSENGER_Message *message, | ||
71 | const struct GNUNET_HashCode *hash) | ||
70 | { | 72 | { |
71 | GNUNET_assert((state) && (message) && (hash)); | 73 | GNUNET_assert((state) && (message) && (hash)); |
72 | 74 | ||
@@ -83,7 +85,8 @@ update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested | |||
83 | } | 85 | } |
84 | 86 | ||
85 | void | 87 | void |
86 | load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *path) | 88 | load_message_state (struct GNUNET_MESSENGER_MessageState *state, |
89 | const char *path) | ||
87 | { | 90 | { |
88 | GNUNET_assert((state) && (path)); | 91 | GNUNET_assert((state) && (path)); |
89 | 92 | ||
@@ -95,7 +98,8 @@ load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *pat | |||
95 | } | 98 | } |
96 | 99 | ||
97 | void | 100 | void |
98 | save_message_state (const struct GNUNET_MESSENGER_MessageState *state, const char *path) | 101 | save_message_state (const struct GNUNET_MESSENGER_MessageState *state, |
102 | const char *path) | ||
99 | { | 103 | { |
100 | GNUNET_assert((state) && (path)); | 104 | GNUNET_assert((state) && (path)); |
101 | 105 | ||
diff --git a/src/messenger/gnunet-service-messenger_message_state.h b/src/messenger/gnunet-service-messenger_message_state.h index dc8671df4..af52b26b6 100644 --- a/src/messenger/gnunet-service-messenger_message_state.h +++ b/src/messenger/gnunet-service-messenger_message_state.h | |||
@@ -51,13 +51,17 @@ const struct GNUNET_HashCode* | |||
51 | get_message_state_merge_hash (const struct GNUNET_MESSENGER_MessageState *state); | 51 | get_message_state_merge_hash (const struct GNUNET_MESSENGER_MessageState *state); |
52 | 52 | ||
53 | void | 53 | void |
54 | update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested, | 54 | update_message_state (struct GNUNET_MESSENGER_MessageState *state, |
55 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 55 | int requested, |
56 | const struct GNUNET_MESSENGER_Message *message, | ||
57 | const struct GNUNET_HashCode *hash); | ||
56 | 58 | ||
57 | void | 59 | void |
58 | load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *path); | 60 | load_message_state (struct GNUNET_MESSENGER_MessageState *state, |
61 | const char *path); | ||
59 | 62 | ||
60 | void | 63 | void |
61 | save_message_state (const struct GNUNET_MESSENGER_MessageState *state, const char *path); | 64 | save_message_state (const struct GNUNET_MESSENGER_MessageState *state, |
65 | const char *path); | ||
62 | 66 | ||
63 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H | 67 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H |
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c index 1984eba21..56448997a 100644 --- a/src/messenger/gnunet-service-messenger_message_store.c +++ b/src/messenger/gnunet-service-messenger_message_store.c | |||
@@ -42,7 +42,9 @@ init_message_store (struct GNUNET_MESSENGER_MessageStore *store) | |||
42 | } | 42 | } |
43 | 43 | ||
44 | static int | 44 | static int |
45 | iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | 45 | iterate_destroy_entries (void *cls, |
46 | const struct GNUNET_HashCode *key, | ||
47 | void *value) | ||
46 | { | 48 | { |
47 | struct GNUNET_MESSENGER_MessageEntry *entry = value; | 49 | struct GNUNET_MESSENGER_MessageEntry *entry = value; |
48 | 50 | ||
@@ -52,7 +54,9 @@ iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *val | |||
52 | } | 54 | } |
53 | 55 | ||
54 | static int | 56 | static int |
55 | iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *value) | 57 | iterate_destroy_messages (void *cls, |
58 | const struct GNUNET_HashCode *key, | ||
59 | void *value) | ||
56 | { | 60 | { |
57 | struct GNUNET_MESSENGER_Message *message = value; | 61 | struct GNUNET_MESSENGER_Message *message = value; |
58 | 62 | ||
@@ -62,7 +66,9 @@ iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *va | |||
62 | } | 66 | } |
63 | 67 | ||
64 | static int | 68 | static int |
65 | iterate_destroy_links (void *cls, const struct GNUNET_HashCode *key, void *value) | 69 | iterate_destroy_links (void *cls, |
70 | const struct GNUNET_HashCode *key, | ||
71 | void *value) | ||
66 | { | 72 | { |
67 | struct GNUNET_HashCode *previous = value; | 73 | struct GNUNET_HashCode *previous = value; |
68 | 74 | ||
@@ -99,7 +105,8 @@ struct GNUNET_MESSENGER_MessageEntryStorage | |||
99 | }; | 105 | }; |
100 | 106 | ||
101 | static void | 107 | static void |
102 | load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, const char *filename) | 108 | load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, |
109 | const char *filename) | ||
103 | { | 110 | { |
104 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); | 111 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); |
105 | 112 | ||
@@ -146,7 +153,8 @@ struct GNUNET_MESSENGER_MessageLinkStorage | |||
146 | }; | 153 | }; |
147 | 154 | ||
148 | static void | 155 | static void |
149 | load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const char *filename) | 156 | load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, |
157 | const char *filename) | ||
150 | { | 158 | { |
151 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); | 159 | enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ); |
152 | 160 | ||
@@ -187,7 +195,8 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha | |||
187 | } | 195 | } |
188 | 196 | ||
189 | void | 197 | void |
190 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) | 198 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
199 | const char *directory) | ||
191 | { | 200 | { |
192 | GNUNET_assert((store) && (directory)); | 201 | GNUNET_assert((store) && (directory)); |
193 | 202 | ||
@@ -232,7 +241,9 @@ struct GNUNET_MESSENGER_ClosureMessageSave | |||
232 | }; | 241 | }; |
233 | 242 | ||
234 | static int | 243 | static int |
235 | iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | 244 | iterate_save_entries (void *cls, |
245 | const struct GNUNET_HashCode *key, | ||
246 | void *value) | ||
236 | { | 247 | { |
237 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 248 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
238 | struct GNUNET_MESSENGER_MessageEntry *entry = value; | 249 | struct GNUNET_MESSENGER_MessageEntry *entry = value; |
@@ -248,7 +259,9 @@ iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
248 | } | 259 | } |
249 | 260 | ||
250 | static int | 261 | static int |
251 | iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value) | 262 | iterate_save_messages (void *cls, |
263 | const struct GNUNET_HashCode *key, | ||
264 | void *value) | ||
252 | { | 265 | { |
253 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 266 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
254 | 267 | ||
@@ -279,7 +292,9 @@ iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value | |||
279 | } | 292 | } |
280 | 293 | ||
281 | static int | 294 | static int |
282 | iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value) | 295 | iterate_save_links (void *cls, |
296 | const struct GNUNET_HashCode *key, | ||
297 | void *value) | ||
283 | { | 298 | { |
284 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; | 299 | struct GNUNET_MESSENGER_ClosureMessageSave *save = cls; |
285 | struct GNUNET_MESSENGER_MessageLink *link = value; | 300 | struct GNUNET_MESSENGER_MessageLink *link = value; |
@@ -295,7 +310,8 @@ iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
295 | } | 310 | } |
296 | 311 | ||
297 | void | 312 | void |
298 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory) | 313 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
314 | const char *directory) | ||
299 | { | 315 | { |
300 | GNUNET_assert((store) && (directory)); | 316 | GNUNET_assert((store) && (directory)); |
301 | 317 | ||
@@ -372,7 +388,8 @@ close_entries: | |||
372 | } | 388 | } |
373 | 389 | ||
374 | int | 390 | int |
375 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 391 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, |
392 | const struct GNUNET_HashCode *hash) | ||
376 | { | 393 | { |
377 | GNUNET_assert((store) && (hash)); | 394 | GNUNET_assert((store) && (hash)); |
378 | 395 | ||
@@ -383,7 +400,8 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const | |||
383 | } | 400 | } |
384 | 401 | ||
385 | const struct GNUNET_MESSENGER_Message* | 402 | const struct GNUNET_MESSENGER_Message* |
386 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 403 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
404 | const struct GNUNET_HashCode *hash) | ||
387 | { | 405 | { |
388 | GNUNET_assert((store) && (hash)); | 406 | GNUNET_assert((store) && (hash)); |
389 | 407 | ||
@@ -444,7 +462,8 @@ free_buffer: | |||
444 | } | 462 | } |
445 | 463 | ||
446 | const struct GNUNET_MESSENGER_MessageLink* | 464 | const struct GNUNET_MESSENGER_MessageLink* |
447 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 465 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, |
466 | const struct GNUNET_HashCode *hash, | ||
448 | int deleted_only) | 467 | int deleted_only) |
449 | { | 468 | { |
450 | if (deleted_only) | 469 | if (deleted_only) |
@@ -473,7 +492,8 @@ get_link: | |||
473 | } | 492 | } |
474 | 493 | ||
475 | int | 494 | int |
476 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 495 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
496 | const struct GNUNET_HashCode *hash, | ||
477 | struct GNUNET_MESSENGER_Message *message) | 497 | struct GNUNET_MESSENGER_Message *message) |
478 | { | 498 | { |
479 | GNUNET_assert((store) && (hash) && (message)); | 499 | GNUNET_assert((store) && (hash) && (message)); |
@@ -483,7 +503,8 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU | |||
483 | } | 503 | } |
484 | 504 | ||
485 | static void | 505 | static void |
486 | add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 506 | add_link (struct GNUNET_MESSENGER_MessageStore *store, |
507 | const struct GNUNET_HashCode *hash, | ||
487 | const struct GNUNET_MESSENGER_Message *message) | 508 | const struct GNUNET_MESSENGER_Message *message) |
488 | { | 509 | { |
489 | struct GNUNET_MESSENGER_MessageLink *link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink); | 510 | struct GNUNET_MESSENGER_MessageLink *link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink); |
@@ -503,7 +524,8 @@ add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashC | |||
503 | } | 524 | } |
504 | 525 | ||
505 | int | 526 | int |
506 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash) | 527 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
528 | const struct GNUNET_HashCode *hash) | ||
507 | { | 529 | { |
508 | GNUNET_assert((store) && (hash)); | 530 | GNUNET_assert((store) && (hash)); |
509 | 531 | ||
diff --git a/src/messenger/gnunet-service-messenger_message_store.h b/src/messenger/gnunet-service-messenger_message_store.h index 87305826a..476d98dd5 100644 --- a/src/messenger/gnunet-service-messenger_message_store.h +++ b/src/messenger/gnunet-service-messenger_message_store.h | |||
@@ -81,7 +81,8 @@ clear_message_store (struct GNUNET_MESSENGER_MessageStore *store); | |||
81 | * @param[in] directory Path to a directory | 81 | * @param[in] directory Path to a directory |
82 | */ | 82 | */ |
83 | void | 83 | void |
84 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory); | 84 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
85 | const char *directory); | ||
85 | 86 | ||
86 | /** | 87 | /** |
87 | * Saves messages from a message <i>store</i> into a <i>directory</i>. | 88 | * Saves messages from a message <i>store</i> into a <i>directory</i>. |
@@ -90,7 +91,8 @@ load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir | |||
90 | * @param[in] directory Path to a directory | 91 | * @param[in] directory Path to a directory |
91 | */ | 92 | */ |
92 | void | 93 | void |
93 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory); | 94 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, |
95 | const char *directory); | ||
94 | 96 | ||
95 | /** | 97 | /** |
96 | * Checks if a message matching a given <i>hash</i> is stored in a message <i>store</i>. | 98 | * Checks if a message matching a given <i>hash</i> is stored in a message <i>store</i>. |
@@ -103,7 +105,8 @@ save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir | |||
103 | * @return #GNUNET_YES on match, otherwise #GNUNET_NO | 105 | * @return #GNUNET_YES on match, otherwise #GNUNET_NO |
104 | */ | 106 | */ |
105 | int | 107 | int |
106 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | 108 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, |
109 | const struct GNUNET_HashCode *hash); | ||
107 | 110 | ||
108 | /** | 111 | /** |
109 | * Returns the message from a message <i>store</i> matching a given <i>hash</i>. If no matching | 112 | * Returns the message from a message <i>store</i> matching a given <i>hash</i>. If no matching |
@@ -117,7 +120,8 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const | |||
117 | * @return Message or NULL | 120 | * @return Message or NULL |
118 | */ | 121 | */ |
119 | const struct GNUNET_MESSENGER_Message* | 122 | const struct GNUNET_MESSENGER_Message* |
120 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | 123 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
124 | const struct GNUNET_HashCode *hash); | ||
121 | 125 | ||
122 | /** | 126 | /** |
123 | * Returns the message link from a message <i>store</i> matching a given <i>hash</i>. If the | 127 | * Returns the message link from a message <i>store</i> matching a given <i>hash</i>. If the |
@@ -133,7 +137,8 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU | |||
133 | * @return Message link or NULL | 137 | * @return Message link or NULL |
134 | */ | 138 | */ |
135 | const struct GNUNET_MESSENGER_MessageLink* | 139 | const struct GNUNET_MESSENGER_MessageLink* |
136 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 140 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, |
141 | const struct GNUNET_HashCode *hash, | ||
137 | int deleted_only); | 142 | int deleted_only); |
138 | 143 | ||
139 | /** | 144 | /** |
@@ -145,7 +150,8 @@ get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struc | |||
145 | * @return #GNUNET_OK on success, otherwise #GNUNET_NO | 150 | * @return #GNUNET_OK on success, otherwise #GNUNET_NO |
146 | */ | 151 | */ |
147 | int | 152 | int |
148 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | 153 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
154 | const struct GNUNET_HashCode *hash, | ||
149 | struct GNUNET_MESSENGER_Message *message); | 155 | struct GNUNET_MESSENGER_Message *message); |
150 | 156 | ||
151 | /** | 157 | /** |
@@ -157,6 +163,7 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU | |||
157 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 163 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
158 | */ | 164 | */ |
159 | int | 165 | int |
160 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | 166 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, |
167 | const struct GNUNET_HashCode *hash); | ||
161 | 168 | ||
162 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H | 169 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H |
diff --git a/src/messenger/gnunet-service-messenger_operation.c b/src/messenger/gnunet-service-messenger_operation.c index d0c378699..a8744e577 100644 --- a/src/messenger/gnunet-service-messenger_operation.c +++ b/src/messenger/gnunet-service-messenger_operation.c | |||
@@ -58,7 +58,8 @@ static void | |||
58 | callback_operation (void *cls); | 58 | callback_operation (void *cls); |
59 | 59 | ||
60 | struct GNUNET_MESSENGER_Operation* | 60 | struct GNUNET_MESSENGER_Operation* |
61 | load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path) | 61 | load_operation (struct GNUNET_MESSENGER_OperationStore *store, |
62 | const char *path) | ||
62 | { | 63 | { |
63 | GNUNET_assert((store) && (path)); | 64 | GNUNET_assert((store) && (path)); |
64 | 65 | ||
@@ -118,7 +119,8 @@ destroy_config: | |||
118 | } | 119 | } |
119 | 120 | ||
120 | void | 121 | void |
121 | save_operation (const struct GNUNET_MESSENGER_Operation *op, const char *path) | 122 | save_operation (const struct GNUNET_MESSENGER_Operation *op, |
123 | const char *path) | ||
122 | { | 124 | { |
123 | GNUNET_assert((path) && (op)); | 125 | GNUNET_assert((path) && (op)); |
124 | 126 | ||
diff --git a/src/messenger/gnunet-service-messenger_operation.h b/src/messenger/gnunet-service-messenger_operation.h index f1e06f4a7..485668548 100644 --- a/src/messenger/gnunet-service-messenger_operation.h +++ b/src/messenger/gnunet-service-messenger_operation.h | |||
@@ -86,7 +86,8 @@ destroy_operation (struct GNUNET_MESSENGER_Operation *op); | |||
86 | * @param[in] path Path of a configuration file | 86 | * @param[in] path Path of a configuration file |
87 | */ | 87 | */ |
88 | struct GNUNET_MESSENGER_Operation* | 88 | struct GNUNET_MESSENGER_Operation* |
89 | load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path); | 89 | load_operation (struct GNUNET_MESSENGER_OperationStore *store, |
90 | const char *path); | ||
90 | 91 | ||
91 | /** | 92 | /** |
92 | * Saves data from an <i>operation</i> into a configuration file at a | 93 | * Saves data from an <i>operation</i> into a configuration file at a |
@@ -97,7 +98,8 @@ load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path) | |||
97 | * @param[in] path Path of a configuration file | 98 | * @param[in] path Path of a configuration file |
98 | */ | 99 | */ |
99 | void | 100 | void |
100 | save_operation (const struct GNUNET_MESSENGER_Operation *op, const char *path); | 101 | save_operation (const struct GNUNET_MESSENGER_Operation *op, |
102 | const char *path); | ||
101 | 103 | ||
102 | /** | 104 | /** |
103 | * Starts an inactive operation with a given <i>delay</i> in a | 105 | * Starts an inactive operation with a given <i>delay</i> in a |
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c index a32fbad2c..4f8419daa 100644 --- a/src/messenger/gnunet-service-messenger_operation_store.c +++ b/src/messenger/gnunet-service-messenger_operation_store.c | |||
@@ -29,7 +29,8 @@ | |||
29 | #include "gnunet-service-messenger_room.h" | 29 | #include "gnunet-service-messenger_room.h" |
30 | 30 | ||
31 | void | 31 | void |
32 | init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room) | 32 | init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, |
33 | struct GNUNET_MESSENGER_SrvRoom *room) | ||
33 | { | 34 | { |
34 | GNUNET_assert((store) && (room)); | 35 | GNUNET_assert((store) && (room)); |
35 | 36 | ||
@@ -38,7 +39,9 @@ init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUN | |||
38 | } | 39 | } |
39 | 40 | ||
40 | static int | 41 | static int |
41 | iterate_destroy_operations (void *cls, const struct GNUNET_HashCode *key, void *value) | 42 | iterate_destroy_operations (void *cls, |
43 | const struct GNUNET_HashCode *key, | ||
44 | void *value) | ||
42 | { | 45 | { |
43 | struct GNUNET_MESSENGER_Operation *op = value; | 46 | struct GNUNET_MESSENGER_Operation *op = value; |
44 | 47 | ||
@@ -57,7 +60,8 @@ clear_operation_store (struct GNUNET_MESSENGER_OperationStore *store) | |||
57 | } | 60 | } |
58 | 61 | ||
59 | static int | 62 | static int |
60 | callback_scan_for_operations (void *cls, const char *filename) | 63 | callback_scan_for_operations (void *cls, |
64 | const char *filename) | ||
61 | { | 65 | { |
62 | struct GNUNET_MESSENGER_OperationStore *store = cls; | 66 | struct GNUNET_MESSENGER_OperationStore *store = cls; |
63 | 67 | ||
@@ -94,7 +98,9 @@ load_operation_store (struct GNUNET_MESSENGER_OperationStore *store, | |||
94 | } | 98 | } |
95 | 99 | ||
96 | static int | 100 | static int |
97 | iterate_save_operations (void *cls, const struct GNUNET_HashCode *key, void *value) | 101 | iterate_save_operations (void *cls, |
102 | const struct GNUNET_HashCode *key, | ||
103 | void *value) | ||
98 | { | 104 | { |
99 | const char *save_dir = cls; | 105 | const char *save_dir = cls; |
100 | 106 | ||
@@ -192,10 +198,12 @@ cancel_store_operation (struct GNUNET_MESSENGER_OperationStore *store, | |||
192 | } | 198 | } |
193 | 199 | ||
194 | extern void | 200 | extern void |
195 | callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash); | 201 | callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, |
202 | const struct GNUNET_HashCode *hash); | ||
196 | 203 | ||
197 | extern void | 204 | extern void |
198 | callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash); | 205 | callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, |
206 | const struct GNUNET_HashCode *hash); | ||
199 | 207 | ||
200 | void | 208 | void |
201 | callback_store_operation (struct GNUNET_MESSENGER_OperationStore *store, | 209 | callback_store_operation (struct GNUNET_MESSENGER_OperationStore *store, |
diff --git a/src/messenger/gnunet-service-messenger_operation_store.h b/src/messenger/gnunet-service-messenger_operation_store.h index 4c613437c..18eb7f8a1 100644 --- a/src/messenger/gnunet-service-messenger_operation_store.h +++ b/src/messenger/gnunet-service-messenger_operation_store.h | |||
@@ -48,7 +48,8 @@ struct GNUNET_MESSENGER_OperationStore | |||
48 | * @param[in/out] room Room | 48 | * @param[in/out] room Room |
49 | */ | 49 | */ |
50 | void | 50 | void |
51 | init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room); | 51 | init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, |
52 | struct GNUNET_MESSENGER_SrvRoom *room); | ||
52 | 53 | ||
53 | /** | 54 | /** |
54 | * Clears an operation <i>store</i>, stops all operations and deallocates its memory. | 55 | * Clears an operation <i>store</i>, stops all operations and deallocates its memory. |
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c index 73e94908f..920abb10e 100644 --- a/src/messenger/gnunet-service-messenger_room.c +++ b/src/messenger/gnunet-service-messenger_room.c | |||
@@ -43,7 +43,8 @@ static void | |||
43 | idle_request_room_messages (void *cls); | 43 | idle_request_room_messages (void *cls); |
44 | 44 | ||
45 | struct GNUNET_MESSENGER_SrvRoom* | 45 | struct GNUNET_MESSENGER_SrvRoom* |
46 | create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 46 | create_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
47 | const struct GNUNET_HashCode *key) | ||
47 | { | 48 | { |
48 | GNUNET_assert((handle) && (key)); | 49 | GNUNET_assert((handle) && (key)); |
49 | 50 | ||
@@ -78,7 +79,9 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_Hash | |||
78 | } | 79 | } |
79 | 80 | ||
80 | static int | 81 | static int |
81 | iterate_destroy_tunnels (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 82 | iterate_destroy_tunnels (void *cls, |
83 | const struct GNUNET_PeerIdentity *key, | ||
84 | void *value) | ||
82 | { | 85 | { |
83 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = value; | 86 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = value; |
84 | destroy_tunnel (tunnel); | 87 | destroy_tunnel (tunnel); |
@@ -150,7 +153,8 @@ get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room) | |||
150 | } | 153 | } |
151 | 154 | ||
152 | static int | 155 | static int |
153 | send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 156 | send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, |
157 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
154 | struct GNUNET_MESSENGER_SrvTunnel *tunnel) | 158 | struct GNUNET_MESSENGER_SrvTunnel *tunnel) |
155 | { | 159 | { |
156 | if ((!handle) || (!is_tunnel_connected (tunnel))) | 160 | if ((!handle) || (!is_tunnel_connected (tunnel))) |
@@ -160,7 +164,9 @@ send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_S | |||
160 | } | 164 | } |
161 | 165 | ||
162 | static void* | 166 | static void* |
163 | callback_room_connect (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source) | 167 | callback_room_connect (void *cls, |
168 | struct GNUNET_CADET_Channel *channel, | ||
169 | const struct GNUNET_PeerIdentity *source) | ||
164 | { | 170 | { |
165 | struct GNUNET_MESSENGER_SrvRoom *room = cls; | 171 | struct GNUNET_MESSENGER_SrvRoom *room = cls; |
166 | 172 | ||
@@ -197,7 +203,8 @@ callback_room_connect (void *cls, struct GNUNET_CADET_Channel *channel, const st | |||
197 | } | 203 | } |
198 | 204 | ||
199 | static int | 205 | static int |
200 | join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 206 | join_room (struct GNUNET_MESSENGER_SrvRoom *room, |
207 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
201 | struct GNUNET_MESSENGER_Member *member) | 208 | struct GNUNET_MESSENGER_Member *member) |
202 | { | 209 | { |
203 | GNUNET_assert((room) && (handle) && (member)); | 210 | GNUNET_assert((room) && (handle) && (member)); |
@@ -228,8 +235,10 @@ struct GNUNET_MESSENGER_MemberNotify | |||
228 | }; | 235 | }; |
229 | 236 | ||
230 | static void | 237 | static void |
231 | notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, | 238 | notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, |
232 | struct GNUNET_CONTAINER_MultiHashMap *map, int check_permission) | 239 | struct GNUNET_MESSENGER_MemberSession *session, |
240 | struct GNUNET_CONTAINER_MultiHashMap *map, | ||
241 | int check_permission) | ||
233 | { | 242 | { |
234 | if (session->prev) | 243 | if (session->prev) |
235 | notify_about_members (notify, session->prev, map, GNUNET_YES); | 244 | notify_about_members (notify, session->prev, map, GNUNET_YES); |
@@ -258,7 +267,8 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNE | |||
258 | } | 267 | } |
259 | 268 | ||
260 | static int | 269 | static int |
261 | iterate_notify_about_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, | 270 | iterate_notify_about_members (void *cls, |
271 | const struct GNUNET_IDENTITY_PublicKey *public_key, | ||
262 | struct GNUNET_MESSENGER_MemberSession *session) | 272 | struct GNUNET_MESSENGER_MemberSession *session) |
263 | { | 273 | { |
264 | struct GNUNET_MESSENGER_MemberNotify *notify = cls; | 274 | struct GNUNET_MESSENGER_MemberNotify *notify = cls; |
@@ -275,7 +285,8 @@ iterate_notify_about_members (void *cls, const struct GNUNET_IDENTITY_PublicKey | |||
275 | } | 285 | } |
276 | 286 | ||
277 | static int | 287 | static int |
278 | join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle) | 288 | join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, |
289 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
279 | { | 290 | { |
280 | const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room)); | 291 | const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room)); |
281 | 292 | ||
@@ -306,16 +317,20 @@ join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
306 | } | 317 | } |
307 | 318 | ||
308 | extern int | 319 | extern int |
309 | check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header); | 320 | check_tunnel_message (void *cls, |
321 | const struct GNUNET_MessageHeader *header); | ||
310 | 322 | ||
311 | extern void | 323 | extern void |
312 | handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header); | 324 | handle_tunnel_message (void *cls, |
325 | const struct GNUNET_MessageHeader *header); | ||
313 | 326 | ||
314 | extern void | 327 | extern void |
315 | callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel); | 328 | callback_tunnel_disconnect (void *cls, |
329 | const struct GNUNET_CADET_Channel *channel); | ||
316 | 330 | ||
317 | int | 331 | int |
318 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle) | 332 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, |
333 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
319 | { | 334 | { |
320 | GNUNET_assert((room) && (handle)); | 335 | GNUNET_assert((room) && (handle)); |
321 | 336 | ||
@@ -366,7 +381,8 @@ exit_open_room: | |||
366 | } | 381 | } |
367 | 382 | ||
368 | int | 383 | int |
369 | enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 384 | enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, |
385 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
370 | const struct GNUNET_PeerIdentity *door) | 386 | const struct GNUNET_PeerIdentity *door) |
371 | { | 387 | { |
372 | GNUNET_assert((room) && (handle) && (door)); | 388 | GNUNET_assert((room) && (handle) && (door)); |
@@ -404,8 +420,11 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Sr | |||
404 | } | 420 | } |
405 | 421 | ||
406 | struct GNUNET_MQ_Envelope* | 422 | struct GNUNET_MQ_Envelope* |
407 | pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, | 423 | pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, |
408 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode) | 424 | const struct GNUNET_MESSENGER_SrvHandle *handle, |
425 | struct GNUNET_MESSENGER_Message *message, | ||
426 | struct GNUNET_HashCode *hash, | ||
427 | int mode) | ||
409 | { | 428 | { |
410 | GNUNET_assert((room) && (handle) && (message) && (hash)); | 429 | GNUNET_assert((room) && (handle) && (message) && (hash)); |
411 | 430 | ||
@@ -432,7 +451,9 @@ struct GNUNET_MESSENGER_ClosureSendRoom | |||
432 | }; | 451 | }; |
433 | 452 | ||
434 | static int | 453 | static int |
435 | iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 454 | iterate_send_room_message (void *cls, |
455 | const struct GNUNET_PeerIdentity *key, | ||
456 | void *value) | ||
436 | { | 457 | { |
437 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = value; | 458 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = value; |
438 | 459 | ||
@@ -466,14 +487,18 @@ iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, voi | |||
466 | 487 | ||
467 | int | 488 | int |
468 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, | 489 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
469 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 490 | struct GNUNET_MESSENGER_Message *message, |
491 | const struct GNUNET_HashCode *hash); | ||
470 | 492 | ||
471 | void | 493 | void |
472 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 494 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, |
473 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 495 | struct GNUNET_MESSENGER_SrvHandle *handle, |
496 | const struct GNUNET_MESSENGER_Message *message, | ||
497 | const struct GNUNET_HashCode *hash); | ||
474 | 498 | ||
475 | int | 499 | int |
476 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 500 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
501 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
477 | struct GNUNET_MESSENGER_Message *message) | 502 | struct GNUNET_MESSENGER_Message *message) |
478 | { | 503 | { |
479 | GNUNET_assert((room) && (handle)); | 504 | GNUNET_assert((room) && (handle)); |
@@ -530,8 +555,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
530 | } | 555 | } |
531 | 556 | ||
532 | void | 557 | void |
533 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 558 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
534 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 559 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
560 | struct GNUNET_MESSENGER_Message *message, | ||
561 | const struct GNUNET_HashCode *hash) | ||
535 | { | 562 | { |
536 | GNUNET_assert((room) && (tunnel)); | 563 | GNUNET_assert((room) && (tunnel)); |
537 | 564 | ||
@@ -554,7 +581,8 @@ forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE | |||
554 | } | 581 | } |
555 | 582 | ||
556 | void | 583 | void |
557 | check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel) | 584 | check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, |
585 | struct GNUNET_MESSENGER_SrvTunnel *tunnel) | ||
558 | { | 586 | { |
559 | if (!room->peer_message) | 587 | if (!room->peer_message) |
560 | return; | 588 | return; |
@@ -592,7 +620,8 @@ resend_peer_message: | |||
592 | } | 620 | } |
593 | 621 | ||
594 | void | 622 | void |
595 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle) | 623 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, |
624 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
596 | { | 625 | { |
597 | GNUNET_assert(room); | 626 | GNUNET_assert(room); |
598 | 627 | ||
@@ -612,7 +641,8 @@ merge_next: | |||
612 | } | 641 | } |
613 | 642 | ||
614 | void | 643 | void |
615 | callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash) | 644 | callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, |
645 | const struct GNUNET_HashCode *hash) | ||
616 | { | 646 | { |
617 | if (GNUNET_OK != delete_store_message (get_room_message_store(room), hash)) | 647 | if (GNUNET_OK != delete_store_message (get_room_message_store(room), hash)) |
618 | { | 648 | { |
@@ -622,7 +652,8 @@ callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUN | |||
622 | } | 652 | } |
623 | 653 | ||
624 | void | 654 | void |
625 | callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash) | 655 | callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, |
656 | const struct GNUNET_HashCode *hash) | ||
626 | { | 657 | { |
627 | if (!room->host) | 658 | if (!room->host) |
628 | return; | 659 | return; |
@@ -631,8 +662,10 @@ callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ | |||
631 | } | 662 | } |
632 | 663 | ||
633 | int | 664 | int |
634 | delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 665 | delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
635 | const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay) | 666 | struct GNUNET_MESSENGER_MemberSession *session, |
667 | const struct GNUNET_HashCode *hash, | ||
668 | const struct GNUNET_TIME_Relative delay) | ||
636 | { | 669 | { |
637 | GNUNET_assert((room) && (session) && (hash)); | 670 | GNUNET_assert((room) && (session) && (hash)); |
638 | 671 | ||
@@ -687,7 +720,8 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room) | |||
687 | } | 720 | } |
688 | 721 | ||
689 | const struct GNUNET_MESSENGER_SrvTunnel* | 722 | const struct GNUNET_MESSENGER_SrvTunnel* |
690 | get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer) | 723 | get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, |
724 | const struct GNUNET_PeerIdentity *peer) | ||
691 | { | 725 | { |
692 | GNUNET_assert((room) && (peer)); | 726 | GNUNET_assert((room) && (peer)); |
693 | 727 | ||
@@ -695,9 +729,11 @@ get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNE | |||
695 | } | 729 | } |
696 | 730 | ||
697 | static int | 731 | static int |
698 | request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, | 732 | request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room, |
733 | const struct GNUNET_HashCode *hash, | ||
699 | const struct GNUNET_MESSENGER_MemberSession *session, | 734 | const struct GNUNET_MESSENGER_MemberSession *session, |
700 | GNUNET_MESSENGER_MessageRequestCallback callback, void* cls) | 735 | GNUNET_MESSENGER_MessageRequestCallback callback, |
736 | void* cls) | ||
701 | { | 737 | { |
702 | struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room); | 738 | struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room); |
703 | 739 | ||
@@ -732,9 +768,11 @@ forward: | |||
732 | } | 768 | } |
733 | 769 | ||
734 | int | 770 | int |
735 | request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, | 771 | request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
772 | const struct GNUNET_HashCode *hash, | ||
736 | const struct GNUNET_MESSENGER_MemberSession *session, | 773 | const struct GNUNET_MESSENGER_MemberSession *session, |
737 | GNUNET_MESSENGER_MessageRequestCallback callback, void* cls) | 774 | GNUNET_MESSENGER_MessageRequestCallback callback, |
775 | void* cls) | ||
738 | { | 776 | { |
739 | GNUNET_assert((room) && (hash)); | 777 | GNUNET_assert((room) && (hash)); |
740 | 778 | ||
@@ -747,7 +785,8 @@ request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET | |||
747 | } | 785 | } |
748 | 786 | ||
749 | void | 787 | void |
750 | callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls) | 788 | callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, |
789 | void *cls) | ||
751 | { | 790 | { |
752 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; | 791 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; |
753 | 792 | ||
@@ -766,8 +805,10 @@ callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls) | |||
766 | } | 805 | } |
767 | 806 | ||
768 | int | 807 | int |
769 | callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, | 808 | callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
770 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash) | 809 | void *cls, |
810 | struct GNUNET_MESSENGER_Message *message, | ||
811 | struct GNUNET_HashCode *hash) | ||
771 | { | 812 | { |
772 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind) | 813 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind) |
773 | { | 814 | { |
@@ -826,8 +867,10 @@ idle_request_room_messages (void *cls) | |||
826 | } | 867 | } |
827 | 868 | ||
828 | void | 869 | void |
829 | solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_PublicKey *public_key, | 870 | solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, |
830 | const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp) | 871 | const struct GNUNET_IDENTITY_PublicKey *public_key, |
872 | const struct GNUNET_ShortHashCode *member_id, | ||
873 | struct GNUNET_TIME_Absolute timestamp) | ||
831 | { | 874 | { |
832 | GNUNET_assert ((room) && (public_key) && (member_id)); | 875 | GNUNET_assert ((room) && (public_key) && (member_id)); |
833 | 876 | ||
@@ -945,7 +988,8 @@ finish_handling: | |||
945 | 988 | ||
946 | int | 989 | int |
947 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, | 990 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
948 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 991 | struct GNUNET_MESSENGER_Message *message, |
992 | const struct GNUNET_HashCode *hash) | ||
949 | { | 993 | { |
950 | GNUNET_assert((room) && (message) && (hash)); | 994 | GNUNET_assert((room) && (message) && (hash)); |
951 | 995 | ||
@@ -1008,7 +1052,8 @@ struct GNUNET_MESSENGER_MemberUpdate | |||
1008 | }; | 1052 | }; |
1009 | 1053 | ||
1010 | static int | 1054 | static int |
1011 | iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, | 1055 | iterate_update_member_sessions (void *cls, |
1056 | const struct GNUNET_IDENTITY_PublicKey *public_key, | ||
1012 | struct GNUNET_MESSENGER_MemberSession *session) | 1057 | struct GNUNET_MESSENGER_MemberSession *session) |
1013 | { | 1058 | { |
1014 | struct GNUNET_MESSENGER_MemberUpdate *update = cls; | 1059 | struct GNUNET_MESSENGER_MemberUpdate *update = cls; |
@@ -1030,11 +1075,14 @@ iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_PublicKe | |||
1030 | } | 1075 | } |
1031 | 1076 | ||
1032 | static void | 1077 | static void |
1033 | remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session); | 1078 | remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, |
1079 | struct GNUNET_MESSENGER_MemberSession *session); | ||
1034 | 1080 | ||
1035 | void | 1081 | void |
1036 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 1082 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, |
1037 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 1083 | struct GNUNET_MESSENGER_SrvHandle *handle, |
1084 | const struct GNUNET_MESSENGER_Message *message, | ||
1085 | const struct GNUNET_HashCode *hash) | ||
1038 | { | 1086 | { |
1039 | struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); | 1087 | struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); |
1040 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message); | 1088 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message); |
@@ -1113,7 +1161,8 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUN | |||
1113 | } | 1161 | } |
1114 | 1162 | ||
1115 | static void | 1163 | static void |
1116 | get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room, char **dir) | 1164 | get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room, |
1165 | char **dir) | ||
1117 | { | 1166 | { |
1118 | GNUNET_assert((room) && (dir)); | 1167 | GNUNET_assert((room) && (dir)); |
1119 | 1168 | ||
@@ -1178,7 +1227,8 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room) | |||
1178 | } | 1227 | } |
1179 | 1228 | ||
1180 | static void | 1229 | static void |
1181 | remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session) | 1230 | remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, |
1231 | struct GNUNET_MESSENGER_MemberSession *session) | ||
1182 | { | 1232 | { |
1183 | GNUNET_assert ((room) && (session)); | 1233 | GNUNET_assert ((room) && (session)); |
1184 | 1234 | ||
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h index 31ec877af..4b3811104 100644 --- a/src/messenger/gnunet-service-messenger_room.h +++ b/src/messenger/gnunet-service-messenger_room.h | |||
@@ -89,7 +89,8 @@ struct GNUNET_MESSENGER_SrvRoom | |||
89 | * @return New room | 89 | * @return New room |
90 | */ | 90 | */ |
91 | struct GNUNET_MESSENGER_SrvRoom* | 91 | struct GNUNET_MESSENGER_SrvRoom* |
92 | create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | 92 | create_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
93 | const struct GNUNET_HashCode *key); | ||
93 | 94 | ||
94 | /** | 95 | /** |
95 | * Destroys a room and frees its memory fully. | 96 | * Destroys a room and frees its memory fully. |
@@ -139,7 +140,8 @@ get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room); | |||
139 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. | 140 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
140 | */ | 141 | */ |
141 | int | 142 | int |
142 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); | 143 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, |
144 | struct GNUNET_MESSENGER_SrvHandle *handle); | ||
143 | 145 | ||
144 | /** | 146 | /** |
145 | * Connects a tunnel to a hosting peer of a <i>room</i> through a so called <i>door</i> which is represented by | 147 | * Connects a tunnel to a hosting peer of a <i>room</i> through a so called <i>door</i> which is represented by |
@@ -152,7 +154,8 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan | |||
152 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. | 154 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
153 | */ | 155 | */ |
154 | int | 156 | int |
155 | enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 157 | enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, |
158 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
156 | const struct GNUNET_PeerIdentity *door); | 159 | const struct GNUNET_PeerIdentity *door); |
157 | 160 | ||
158 | /** | 161 | /** |
@@ -173,8 +176,11 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Sr | |||
173 | * @return New envelope or NULL | 176 | * @return New envelope or NULL |
174 | */ | 177 | */ |
175 | struct GNUNET_MQ_Envelope* | 178 | struct GNUNET_MQ_Envelope* |
176 | pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, | 179 | pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, |
177 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode); | 180 | const struct GNUNET_MESSENGER_SrvHandle *handle, |
181 | struct GNUNET_MESSENGER_Message *message, | ||
182 | struct GNUNET_HashCode *hash, | ||
183 | int mode); | ||
178 | 184 | ||
179 | /** | 185 | /** |
180 | * Sends a <i>message</i> from a given <i>handle</i> into a <i>room</i>. The <i>hash</i> parameter will be | 186 | * Sends a <i>message</i> from a given <i>handle</i> into a <i>room</i>. The <i>hash</i> parameter will be |
@@ -192,7 +198,8 @@ pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNU | |||
192 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. | 198 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. |
193 | */ | 199 | */ |
194 | int | 200 | int |
195 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 201 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
202 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
196 | struct GNUNET_MESSENGER_Message *message); | 203 | struct GNUNET_MESSENGER_Message *message); |
197 | 204 | ||
198 | /** | 205 | /** |
@@ -204,8 +211,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
204 | * @param[in] hash Hash of message | 211 | * @param[in] hash Hash of message |
205 | */ | 212 | */ |
206 | void | 213 | void |
207 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 214 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
208 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 215 | struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
216 | struct GNUNET_MESSENGER_Message *message, | ||
217 | const struct GNUNET_HashCode *hash); | ||
209 | 218 | ||
210 | /** | 219 | /** |
211 | * Checks the current state of opening a given <i>room</i> from this peer and re-publishes it | 220 | * Checks the current state of opening a given <i>room</i> from this peer and re-publishes it |
@@ -216,7 +225,8 @@ forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE | |||
216 | * @param[in/out] tunnel Tunnel | 225 | * @param[in/out] tunnel Tunnel |
217 | */ | 226 | */ |
218 | void | 227 | void |
219 | check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel); | 228 | check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, |
229 | struct GNUNET_MESSENGER_SrvTunnel *tunnel); | ||
220 | 230 | ||
221 | /** | 231 | /** |
222 | * Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message | 232 | * Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message |
@@ -226,7 +236,8 @@ check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MES | |||
226 | * @param[in/out] handle Handle | 236 | * @param[in/out] handle Handle |
227 | */ | 237 | */ |
228 | void | 238 | void |
229 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); | 239 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, |
240 | struct GNUNET_MESSENGER_SrvHandle *handle); | ||
230 | 241 | ||
231 | /** | 242 | /** |
232 | * Deletes a message from the <i>room</i> with a given <i>hash</i> in a specific <i>delay</i> if | 243 | * Deletes a message from the <i>room</i> with a given <i>hash</i> in a specific <i>delay</i> if |
@@ -239,8 +250,10 @@ merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_M | |||
239 | * @return #GNUNET_YES on success, #GNUNET_NO if permission gets denied, #GNUNET_SYSERR on operation failure | 250 | * @return #GNUNET_YES on success, #GNUNET_NO if permission gets denied, #GNUNET_SYSERR on operation failure |
240 | */ | 251 | */ |
241 | int | 252 | int |
242 | delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 253 | delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
243 | const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay); | 254 | struct GNUNET_MESSENGER_MemberSession *session, |
255 | const struct GNUNET_HashCode *hash, | ||
256 | const struct GNUNET_TIME_Relative delay); | ||
244 | 257 | ||
245 | /** | 258 | /** |
246 | * Returns the CADET handle from a rooms service. | 259 | * Returns the CADET handle from a rooms service. |
@@ -269,7 +282,8 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room); | |||
269 | * @return Tunnel or NULL | 282 | * @return Tunnel or NULL |
270 | */ | 283 | */ |
271 | const struct GNUNET_MESSENGER_SrvTunnel* | 284 | const struct GNUNET_MESSENGER_SrvTunnel* |
272 | get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer); | 285 | get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, |
286 | const struct GNUNET_PeerIdentity *peer); | ||
273 | 287 | ||
274 | /** | 288 | /** |
275 | * Method called whenever a <i>message</i> is found during a request in a <i>room</i>. | 289 | * Method called whenever a <i>message</i> is found during a request in a <i>room</i>. |
@@ -280,7 +294,8 @@ get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNE | |||
280 | * @param[in] hash Hash of message | 294 | * @param[in] hash Hash of message |
281 | */ | 295 | */ |
282 | typedef void (GNUNET_MESSENGER_MessageRequestCallback) ( | 296 | typedef void (GNUNET_MESSENGER_MessageRequestCallback) ( |
283 | void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | 297 | void *cls, |
298 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
284 | const struct GNUNET_MESSENGER_Message *message, | 299 | const struct GNUNET_MESSENGER_Message *message, |
285 | const struct GNUNET_HashCode *hash | 300 | const struct GNUNET_HashCode *hash |
286 | ); | 301 | ); |
@@ -301,9 +316,11 @@ typedef void (GNUNET_MESSENGER_MessageRequestCallback) ( | |||
301 | * @return #GNUNET_YES if the request could be processed, otherwise #GNUNET_NO | 316 | * @return #GNUNET_YES if the request could be processed, otherwise #GNUNET_NO |
302 | */ | 317 | */ |
303 | int | 318 | int |
304 | request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, | 319 | request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
320 | const struct GNUNET_HashCode *hash, | ||
305 | const struct GNUNET_MESSENGER_MemberSession *session, | 321 | const struct GNUNET_MESSENGER_MemberSession *session, |
306 | GNUNET_MESSENGER_MessageRequestCallback callback, void* cls); | 322 | GNUNET_MESSENGER_MessageRequestCallback callback, |
323 | void* cls); | ||
307 | 324 | ||
308 | /** | 325 | /** |
309 | * Checks for potential collisions with member ids and solves them changing active handles ids if they | 326 | * Checks for potential collisions with member ids and solves them changing active handles ids if they |
@@ -315,8 +332,10 @@ request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET | |||
315 | * @param[in] timestamp Timestamp | 332 | * @param[in] timestamp Timestamp |
316 | */ | 333 | */ |
317 | void | 334 | void |
318 | solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_PublicKey *public_key, | 335 | solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, |
319 | const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp); | 336 | const struct GNUNET_IDENTITY_PublicKey *public_key, |
337 | const struct GNUNET_ShortHashCode *member_id, | ||
338 | struct GNUNET_TIME_Absolute timestamp); | ||
320 | 339 | ||
321 | /** | 340 | /** |
322 | * Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made | 341 | * Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made |
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c index 8c63e9bf4..91165cf63 100644 --- a/src/messenger/gnunet-service-messenger_service.c +++ b/src/messenger/gnunet-service-messenger_service.c | |||
@@ -41,7 +41,8 @@ callback_shutdown_service (void *cls) | |||
41 | } | 41 | } |
42 | 42 | ||
43 | struct GNUNET_MESSENGER_Service* | 43 | struct GNUNET_MESSENGER_Service* |
44 | create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle) | 44 | create_service (const struct GNUNET_CONFIGURATION_Handle *config, |
45 | struct GNUNET_SERVICE_Handle *service_handle) | ||
45 | { | 46 | { |
46 | GNUNET_assert((config) && (service_handle)); | 47 | GNUNET_assert((config) && (service_handle)); |
47 | 48 | ||
@@ -88,7 +89,9 @@ create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_ | |||
88 | } | 89 | } |
89 | 90 | ||
90 | static int | 91 | static int |
91 | iterate_destroy_rooms (void *cls, const struct GNUNET_HashCode *key, void *value) | 92 | iterate_destroy_rooms (void *cls, |
93 | const struct GNUNET_HashCode *key, | ||
94 | void *value) | ||
92 | { | 95 | { |
93 | struct GNUNET_MESSENGER_SrvRoom *room = value; | 96 | struct GNUNET_MESSENGER_SrvRoom *room = value; |
94 | destroy_room (room); | 97 | destroy_room (room); |
@@ -151,7 +154,8 @@ get_service_contact_store (struct GNUNET_MESSENGER_Service *service) | |||
151 | } | 154 | } |
152 | 155 | ||
153 | struct GNUNET_MESSENGER_SrvHandle* | 156 | struct GNUNET_MESSENGER_SrvHandle* |
154 | add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq) | 157 | add_service_handle (struct GNUNET_MESSENGER_Service *service, |
158 | struct GNUNET_MQ_Handle *mq) | ||
155 | { | 159 | { |
156 | GNUNET_assert((service) && (mq)); | 160 | GNUNET_assert((service) && (mq)); |
157 | 161 | ||
@@ -166,7 +170,8 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_H | |||
166 | } | 170 | } |
167 | 171 | ||
168 | void | 172 | void |
169 | remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle) | 173 | remove_service_handle (struct GNUNET_MESSENGER_Service *service, |
174 | struct GNUNET_MESSENGER_SrvHandle *handle) | ||
170 | { | 175 | { |
171 | GNUNET_assert((service) && (handle)); | 176 | GNUNET_assert((service) && (handle)); |
172 | 177 | ||
@@ -178,7 +183,8 @@ remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_M | |||
178 | } | 183 | } |
179 | 184 | ||
180 | int | 185 | int |
181 | get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer) | 186 | get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, |
187 | struct GNUNET_PeerIdentity *peer) | ||
182 | { | 188 | { |
183 | GNUNET_assert((service) && (peer)); | 189 | GNUNET_assert((service) && (peer)); |
184 | 190 | ||
@@ -186,7 +192,8 @@ get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struc | |||
186 | } | 192 | } |
187 | 193 | ||
188 | struct GNUNET_MESSENGER_SrvRoom* | 194 | struct GNUNET_MESSENGER_SrvRoom* |
189 | get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key) | 195 | get_service_room (const struct GNUNET_MESSENGER_Service *service, |
196 | const struct GNUNET_HashCode *key) | ||
190 | { | 197 | { |
191 | GNUNET_assert((service) && (key)); | 198 | GNUNET_assert((service) && (key)); |
192 | 199 | ||
@@ -194,7 +201,8 @@ get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct G | |||
194 | } | 201 | } |
195 | 202 | ||
196 | int | 203 | int |
197 | open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 204 | open_service_room (struct GNUNET_MESSENGER_Service *service, |
205 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
198 | const struct GNUNET_HashCode *key) | 206 | const struct GNUNET_HashCode *key) |
199 | { | 207 | { |
200 | GNUNET_assert((service) && (handle) && (key)); | 208 | GNUNET_assert((service) && (handle) && (key)); |
@@ -217,8 +225,10 @@ open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSE | |||
217 | } | 225 | } |
218 | 226 | ||
219 | int | 227 | int |
220 | entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 228 | entry_service_room (struct GNUNET_MESSENGER_Service *service, |
221 | const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key) | 229 | struct GNUNET_MESSENGER_SrvHandle *handle, |
230 | const struct GNUNET_PeerIdentity *door, | ||
231 | const struct GNUNET_HashCode *key) | ||
222 | { | 232 | { |
223 | GNUNET_assert((service) && (handle) && (door) && (key)); | 233 | GNUNET_assert((service) && (handle) && (door) && (key)); |
224 | 234 | ||
@@ -250,7 +260,8 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS | |||
250 | } | 260 | } |
251 | 261 | ||
252 | int | 262 | int |
253 | close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 263 | close_service_room (struct GNUNET_MESSENGER_Service *service, |
264 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
254 | const struct GNUNET_HashCode *key) | 265 | const struct GNUNET_HashCode *key) |
255 | { | 266 | { |
256 | GNUNET_assert((service) && (handle) && (key)); | 267 | GNUNET_assert((service) && (handle) && (key)); |
@@ -290,9 +301,11 @@ close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS | |||
290 | } | 301 | } |
291 | 302 | ||
292 | void | 303 | void |
293 | handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, | 304 | handle_service_message (struct GNUNET_MESSENGER_Service *service, |
305 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
294 | const struct GNUNET_MESSENGER_MemberSession *session, | 306 | const struct GNUNET_MESSENGER_MemberSession *session, |
295 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 307 | const struct GNUNET_MESSENGER_Message *message, |
308 | const struct GNUNET_HashCode *hash) | ||
296 | { | 309 | { |
297 | GNUNET_assert((service) && (room) && (session) && (message) && (hash)); | 310 | GNUNET_assert((service) && (room) && (session) && (message) && (hash)); |
298 | 311 | ||
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h index aa43fa457..d364a93c0 100644 --- a/src/messenger/gnunet-service-messenger_service.h +++ b/src/messenger/gnunet-service-messenger_service.h | |||
@@ -68,7 +68,8 @@ struct GNUNET_MESSENGER_Service | |||
68 | * @return New service | 68 | * @return New service |
69 | */ | 69 | */ |
70 | struct GNUNET_MESSENGER_Service* | 70 | struct GNUNET_MESSENGER_Service* |
71 | create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle); | 71 | create_service (const struct GNUNET_CONFIGURATION_Handle *config, |
72 | struct GNUNET_SERVICE_Handle *service_handle); | ||
72 | 73 | ||
73 | /** | 74 | /** |
74 | * Destroys a <i>service</i> and frees its memory fully. | 75 | * Destroys a <i>service</i> and frees its memory fully. |
@@ -104,7 +105,8 @@ get_service_contact_store (struct GNUNET_MESSENGER_Service *service); | |||
104 | * @return New handle | 105 | * @return New handle |
105 | */ | 106 | */ |
106 | struct GNUNET_MESSENGER_SrvHandle* | 107 | struct GNUNET_MESSENGER_SrvHandle* |
107 | add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq); | 108 | add_service_handle (struct GNUNET_MESSENGER_Service *service, |
109 | struct GNUNET_MQ_Handle *mq); | ||
108 | 110 | ||
109 | /** | 111 | /** |
110 | * Removes a <i>handle</i> from a <i>service</i> and destroys it. | 112 | * Removes a <i>handle</i> from a <i>service</i> and destroys it. |
@@ -113,7 +115,8 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_H | |||
113 | * @param[in/out] handle Handle | 115 | * @param[in/out] handle Handle |
114 | */ | 116 | */ |
115 | void | 117 | void |
116 | remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle); | 118 | remove_service_handle (struct GNUNET_MESSENGER_Service *service, |
119 | struct GNUNET_MESSENGER_SrvHandle *handle); | ||
117 | 120 | ||
118 | /** | 121 | /** |
119 | * Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i> | 122 | * Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i> |
@@ -124,7 +127,8 @@ remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_M | |||
124 | * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR | 127 | * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR |
125 | */ | 128 | */ |
126 | int | 129 | int |
127 | get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer); | 130 | get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, |
131 | struct GNUNET_PeerIdentity *peer); | ||
128 | 132 | ||
129 | /** | 133 | /** |
130 | * Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room | 134 | * Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room |
@@ -135,7 +139,8 @@ get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struc | |||
135 | * @return Room or NULL | 139 | * @return Room or NULL |
136 | */ | 140 | */ |
137 | struct GNUNET_MESSENGER_SrvRoom* | 141 | struct GNUNET_MESSENGER_SrvRoom* |
138 | get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key); | 142 | get_service_room (const struct GNUNET_MESSENGER_Service *service, |
143 | const struct GNUNET_HashCode *key); | ||
139 | 144 | ||
140 | /** | 145 | /** |
141 | * Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be | 146 | * Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be |
@@ -147,7 +152,8 @@ get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct G | |||
147 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 152 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
148 | */ | 153 | */ |
149 | int | 154 | int |
150 | open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 155 | open_service_room (struct GNUNET_MESSENGER_Service *service, |
156 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
151 | const struct GNUNET_HashCode *key); | 157 | const struct GNUNET_HashCode *key); |
152 | 158 | ||
153 | /** | 159 | /** |
@@ -164,8 +170,10 @@ open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSE | |||
164 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 170 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
165 | */ | 171 | */ |
166 | int | 172 | int |
167 | entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 173 | entry_service_room (struct GNUNET_MESSENGER_Service *service, |
168 | const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key); | 174 | struct GNUNET_MESSENGER_SrvHandle *handle, |
175 | const struct GNUNET_PeerIdentity *door, | ||
176 | const struct GNUNET_HashCode *key); | ||
169 | 177 | ||
170 | /** | 178 | /** |
171 | * Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will | 179 | * Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will |
@@ -180,7 +188,8 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS | |||
180 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 188 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
181 | */ | 189 | */ |
182 | int | 190 | int |
183 | close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, | 191 | close_service_room (struct GNUNET_MESSENGER_Service *service, |
192 | struct GNUNET_MESSENGER_SrvHandle *handle, | ||
184 | const struct GNUNET_HashCode *key); | 193 | const struct GNUNET_HashCode *key); |
185 | 194 | ||
186 | /** | 195 | /** |
@@ -194,8 +203,10 @@ close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS | |||
194 | * @param[in] hash Hash of message | 203 | * @param[in] hash Hash of message |
195 | */ | 204 | */ |
196 | void | 205 | void |
197 | handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, | 206 | handle_service_message (struct GNUNET_MESSENGER_Service *service, |
207 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
198 | const struct GNUNET_MESSENGER_MemberSession *session, | 208 | const struct GNUNET_MESSENGER_MemberSession *session, |
199 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 209 | const struct GNUNET_MESSENGER_Message *message, |
210 | const struct GNUNET_HashCode *hash); | ||
200 | 211 | ||
201 | #endif //GNUNET_SERVICE_MESSENGER_SERVICE_H | 212 | #endif //GNUNET_SERVICE_MESSENGER_SERVICE_H |
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c index b9d063813..fdd6429e6 100644 --- a/src/messenger/gnunet-service-messenger_tunnel.c +++ b/src/messenger/gnunet-service-messenger_tunnel.c | |||
@@ -33,7 +33,8 @@ | |||
33 | #include "messenger_api_util.h" | 33 | #include "messenger_api_util.h" |
34 | 34 | ||
35 | struct GNUNET_MESSENGER_SrvTunnel* | 35 | struct GNUNET_MESSENGER_SrvTunnel* |
36 | create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door) | 36 | create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, |
37 | const struct GNUNET_PeerIdentity *door) | ||
37 | { | 38 | { |
38 | GNUNET_assert((room) && (door)); | 39 | GNUNET_assert((room) && (door)); |
39 | 40 | ||
@@ -72,7 +73,8 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel) | |||
72 | } | 73 | } |
73 | 74 | ||
74 | void | 75 | void |
75 | bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel) | 76 | bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
77 | struct GNUNET_CADET_Channel *channel) | ||
76 | { | 78 | { |
77 | GNUNET_assert(tunnel); | 79 | GNUNET_assert(tunnel); |
78 | 80 | ||
@@ -83,10 +85,12 @@ bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Chan | |||
83 | } | 85 | } |
84 | 86 | ||
85 | extern void | 87 | extern void |
86 | callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls); | 88 | callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, |
89 | void *cls); | ||
87 | 90 | ||
88 | void | 91 | void |
89 | callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel) | 92 | callback_tunnel_disconnect (void *cls, |
93 | const struct GNUNET_CADET_Channel *channel) | ||
90 | { | 94 | { |
91 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; | 95 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; |
92 | 96 | ||
@@ -99,11 +103,14 @@ callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channe | |||
99 | } | 103 | } |
100 | 104 | ||
101 | extern int | 105 | extern int |
102 | callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, | 106 | callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
103 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash); | 107 | void *cls, |
108 | struct GNUNET_MESSENGER_Message *message, | ||
109 | struct GNUNET_HashCode *hash); | ||
104 | 110 | ||
105 | int | 111 | int |
106 | check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header) | 112 | check_tunnel_message (void *cls, |
113 | const struct GNUNET_MessageHeader *header) | ||
107 | { | 114 | { |
108 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; | 115 | struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls; |
109 | 116 | ||
@@ -137,14 +144,18 @@ check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header) | |||
137 | 144 | ||
138 | extern int | 145 | extern int |
139 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, | 146 | update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, |
140 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 147 | struct GNUNET_MESSENGER_Message *message, |
148 | const struct GNUNET_HashCode *hash); | ||
141 | 149 | ||
142 | extern void | 150 | extern void |
143 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 151 | callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, |
144 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 152 | struct GNUNET_MESSENGER_SrvHandle *handle, |
153 | const struct GNUNET_MESSENGER_Message *message, | ||
154 | const struct GNUNET_HashCode *hash); | ||
145 | 155 | ||
146 | static void | 156 | static void |
147 | update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash) | 157 | update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
158 | const struct GNUNET_HashCode *hash) | ||
148 | { | 159 | { |
149 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(tunnel->room); | 160 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(tunnel->room); |
150 | 161 | ||
@@ -281,7 +292,8 @@ callback_tunnel_sent (void *cls) | |||
281 | } | 292 | } |
282 | 293 | ||
283 | void | 294 | void |
284 | send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env, | 295 | send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
296 | struct GNUNET_MQ_Envelope *env, | ||
285 | const struct GNUNET_HashCode *hash) | 297 | const struct GNUNET_HashCode *hash) |
286 | { | 298 | { |
287 | GNUNET_assert((tunnel) && (env) && (hash)); | 299 | GNUNET_assert((tunnel) && (env) && (hash)); |
@@ -299,7 +311,9 @@ send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_M | |||
299 | } | 311 | } |
300 | 312 | ||
301 | int | 313 | int |
302 | send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message) | 314 | send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
315 | void *handle, | ||
316 | struct GNUNET_MESSENGER_Message *message) | ||
303 | { | 317 | { |
304 | GNUNET_assert((tunnel) && (handle)); | 318 | GNUNET_assert((tunnel) && (handle)); |
305 | 319 | ||
@@ -325,7 +339,8 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, st | |||
325 | } | 339 | } |
326 | 340 | ||
327 | void | 341 | void |
328 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, | 342 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
343 | const struct GNUNET_MESSENGER_Message *message, | ||
329 | const struct GNUNET_HashCode *hash) | 344 | const struct GNUNET_HashCode *hash) |
330 | { | 345 | { |
331 | GNUNET_assert((tunnel) && (message) && (hash)); | 346 | GNUNET_assert((tunnel) && (message) && (hash)); |
@@ -353,7 +368,8 @@ get_tunnel_peer_message (const struct GNUNET_MESSENGER_SrvTunnel *tunnel) | |||
353 | } | 368 | } |
354 | 369 | ||
355 | void | 370 | void |
356 | get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer) | 371 | get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
372 | struct GNUNET_PeerIdentity *peer) | ||
357 | { | 373 | { |
358 | GNUNET_assert(tunnel); | 374 | GNUNET_assert(tunnel); |
359 | 375 | ||
@@ -369,7 +385,8 @@ get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel) | |||
369 | } | 385 | } |
370 | 386 | ||
371 | int | 387 | int |
372 | update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, uint32_t version) | 388 | update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
389 | uint32_t version) | ||
373 | { | 390 | { |
374 | GNUNET_assert(tunnel); | 391 | GNUNET_assert(tunnel); |
375 | 392 | ||
diff --git a/src/messenger/gnunet-service-messenger_tunnel.h b/src/messenger/gnunet-service-messenger_tunnel.h index 96d98546d..7bd749281 100644 --- a/src/messenger/gnunet-service-messenger_tunnel.h +++ b/src/messenger/gnunet-service-messenger_tunnel.h | |||
@@ -55,7 +55,8 @@ struct GNUNET_MESSENGER_SrvTunnel | |||
55 | * @return New tunnel | 55 | * @return New tunnel |
56 | */ | 56 | */ |
57 | struct GNUNET_MESSENGER_SrvTunnel* | 57 | struct GNUNET_MESSENGER_SrvTunnel* |
58 | create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door); | 58 | create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, |
59 | const struct GNUNET_PeerIdentity *door); | ||
59 | 60 | ||
60 | /** | 61 | /** |
61 | * Destroys a <i>tunnel</i> and frees its memory fully. | 62 | * Destroys a <i>tunnel</i> and frees its memory fully. |
@@ -73,7 +74,8 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel); | |||
73 | * @param[in/out] channel CADET channel | 74 | * @param[in/out] channel CADET channel |
74 | */ | 75 | */ |
75 | void | 76 | void |
76 | bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel); | 77 | bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
78 | struct GNUNET_CADET_Channel *channel); | ||
77 | 79 | ||
78 | /** | 80 | /** |
79 | * Tries to connect a <i>tunnel</i> by creating a new CADET channel and binding it. | 81 | * Tries to connect a <i>tunnel</i> by creating a new CADET channel and binding it. |
@@ -112,7 +114,8 @@ is_tunnel_connected (const struct GNUNET_MESSENGER_SrvTunnel *tunnel); | |||
112 | * @param[in] hash Hash of message | 114 | * @param[in] hash Hash of message |
113 | */ | 115 | */ |
114 | void | 116 | void |
115 | send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env, | 117 | send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
118 | struct GNUNET_MQ_Envelope *env, | ||
116 | const struct GNUNET_HashCode *hash); | 119 | const struct GNUNET_HashCode *hash); |
117 | 120 | ||
118 | /** | 121 | /** |
@@ -126,7 +129,9 @@ send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_M | |||
126 | * @return #GNUNET_YES on success, GNUNET_NO otherwise | 129 | * @return #GNUNET_YES on success, GNUNET_NO otherwise |
127 | */ | 130 | */ |
128 | int | 131 | int |
129 | send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message); | 132 | send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
133 | void *handle, | ||
134 | struct GNUNET_MESSENGER_Message *message); | ||
130 | 135 | ||
131 | /** | 136 | /** |
132 | * Forwards a given <i>message</i> with a known <i>hash</i> through a <i>tunnel</i>. | 137 | * Forwards a given <i>message</i> with a known <i>hash</i> through a <i>tunnel</i>. |
@@ -136,7 +141,8 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, st | |||
136 | * @param[in] hash Hash of message | 141 | * @param[in] hash Hash of message |
137 | */ | 142 | */ |
138 | void | 143 | void |
139 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, | 144 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
145 | const struct GNUNET_MESSENGER_Message *message, | ||
140 | const struct GNUNET_HashCode *hash); | 146 | const struct GNUNET_HashCode *hash); |
141 | 147 | ||
142 | /** | 148 | /** |
@@ -158,7 +164,8 @@ get_tunnel_peer_message (const struct GNUNET_MESSENGER_SrvTunnel *tunnel); | |||
158 | * @param[out] peer Peer identity | 164 | * @param[out] peer Peer identity |
159 | */ | 165 | */ |
160 | void | 166 | void |
161 | get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer); | 167 | get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
168 | struct GNUNET_PeerIdentity *peer); | ||
162 | 169 | ||
163 | /** | 170 | /** |
164 | * Returns the current messenger version the peer connected via a given <i>tunnel</i> | 171 | * Returns the current messenger version the peer connected via a given <i>tunnel</i> |
@@ -181,6 +188,7 @@ get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel); | |||
181 | * @param[in] version Version of messenger | 188 | * @param[in] version Version of messenger |
182 | */ | 189 | */ |
183 | int | 190 | int |
184 | update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, uint32_t version); | 191 | update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
192 | uint32_t version); | ||
185 | 193 | ||
186 | #endif //GNUNET_SERVICE_MESSENGER_TUNNEL_H | 194 | #endif //GNUNET_SERVICE_MESSENGER_TUNNEL_H |
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c index f7c73f769..ef6244e19 100644 --- a/src/messenger/messenger_api.c +++ b/src/messenger/messenger_api.c | |||
@@ -70,14 +70,16 @@ GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | static int | 72 | static int |
73 | check_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 73 | check_get_name (void *cls, |
74 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
74 | { | 75 | { |
75 | GNUNET_MQ_check_zero_termination(msg); | 76 | GNUNET_MQ_check_zero_termination(msg); |
76 | return GNUNET_OK; | 77 | return GNUNET_OK; |
77 | } | 78 | } |
78 | 79 | ||
79 | static void | 80 | static void |
80 | handle_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 81 | handle_get_name (void *cls, |
82 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
81 | { | 83 | { |
82 | struct GNUNET_MESSENGER_Handle *handle = cls; | 84 | struct GNUNET_MESSENGER_Handle *handle = cls; |
83 | 85 | ||
@@ -89,7 +91,8 @@ handle_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | |||
89 | } | 91 | } |
90 | 92 | ||
91 | static int | 93 | static int |
92 | check_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg) | 94 | check_get_key (void *cls, |
95 | const struct GNUNET_MESSENGER_KeyMessage *msg) | ||
93 | { | 96 | { |
94 | const uint16_t full_length = ntohs (msg->header.size); | 97 | const uint16_t full_length = ntohs (msg->header.size); |
95 | 98 | ||
@@ -107,7 +110,8 @@ check_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg) | |||
107 | } | 110 | } |
108 | 111 | ||
109 | static void | 112 | static void |
110 | handle_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg) | 113 | handle_get_key (void *cls, |
114 | const struct GNUNET_MESSENGER_KeyMessage *msg) | ||
111 | { | 115 | { |
112 | struct GNUNET_MESSENGER_Handle *handle = cls; | 116 | struct GNUNET_MESSENGER_Handle *handle = cls; |
113 | 117 | ||
@@ -129,7 +133,8 @@ handle_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg) | |||
129 | } | 133 | } |
130 | 134 | ||
131 | static void | 135 | static void |
132 | handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg) | 136 | handle_member_id (void *cls, |
137 | const struct GNUNET_MESSENGER_MemberMessage *msg) | ||
133 | { | 138 | { |
134 | struct GNUNET_MESSENGER_Handle *handle = cls; | 139 | struct GNUNET_MESSENGER_Handle *handle = cls; |
135 | 140 | ||
@@ -150,7 +155,8 @@ handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg) | |||
150 | } | 155 | } |
151 | 156 | ||
152 | static void | 157 | static void |
153 | handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 158 | handle_room_open (void *cls, |
159 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
154 | { | 160 | { |
155 | struct GNUNET_MESSENGER_Handle *handle = cls; | 161 | struct GNUNET_MESSENGER_Handle *handle = cls; |
156 | 162 | ||
@@ -162,7 +168,8 @@ handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
162 | } | 168 | } |
163 | 169 | ||
164 | static void | 170 | static void |
165 | handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 171 | handle_room_entry (void *cls, |
172 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
166 | { | 173 | { |
167 | struct GNUNET_MESSENGER_Handle *handle = cls; | 174 | struct GNUNET_MESSENGER_Handle *handle = cls; |
168 | 175 | ||
@@ -175,7 +182,8 @@ handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
175 | } | 182 | } |
176 | 183 | ||
177 | static void | 184 | static void |
178 | handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 185 | handle_room_close (void *cls, |
186 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
179 | { | 187 | { |
180 | struct GNUNET_MESSENGER_Handle *handle = cls; | 188 | struct GNUNET_MESSENGER_Handle *handle = cls; |
181 | 189 | ||
@@ -187,7 +195,8 @@ handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
187 | } | 195 | } |
188 | 196 | ||
189 | static int | 197 | static int |
190 | check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg) | 198 | check_recv_message (void *cls, |
199 | const struct GNUNET_MESSENGER_RecvMessage *msg) | ||
191 | { | 200 | { |
192 | const uint16_t full_length = ntohs (msg->header.size); | 201 | const uint16_t full_length = ntohs (msg->header.size); |
193 | 202 | ||
@@ -209,7 +218,8 @@ check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg) | |||
209 | } | 218 | } |
210 | 219 | ||
211 | static void | 220 | static void |
212 | handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg) | 221 | handle_recv_message (void *cls, |
222 | const struct GNUNET_MESSENGER_RecvMessage *msg) | ||
213 | { | 223 | { |
214 | struct GNUNET_MESSENGER_Handle *handle = cls; | 224 | struct GNUNET_MESSENGER_Handle *handle = cls; |
215 | 225 | ||
@@ -255,7 +265,8 @@ static void | |||
255 | reconnect (struct GNUNET_MESSENGER_Handle *handle); | 265 | reconnect (struct GNUNET_MESSENGER_Handle *handle); |
256 | 266 | ||
257 | static void | 267 | static void |
258 | send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room) | 268 | send_open_room (struct GNUNET_MESSENGER_Handle *handle, |
269 | struct GNUNET_MESSENGER_Room *room) | ||
259 | { | 270 | { |
260 | struct GNUNET_MESSENGER_RoomMessage *msg; | 271 | struct GNUNET_MESSENGER_RoomMessage *msg; |
261 | struct GNUNET_MQ_Envelope *env; | 272 | struct GNUNET_MQ_Envelope *env; |
@@ -266,7 +277,8 @@ send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_ | |||
266 | } | 277 | } |
267 | 278 | ||
268 | static void | 279 | static void |
269 | send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, | 280 | send_enter_room (struct GNUNET_MESSENGER_Handle *handle, |
281 | struct GNUNET_MESSENGER_Room *room, | ||
270 | const struct GNUNET_PeerIdentity *door) | 282 | const struct GNUNET_PeerIdentity *door) |
271 | { | 283 | { |
272 | struct GNUNET_MESSENGER_RoomMessage *msg; | 284 | struct GNUNET_MESSENGER_RoomMessage *msg; |
@@ -279,7 +291,8 @@ send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER | |||
279 | } | 291 | } |
280 | 292 | ||
281 | static void | 293 | static void |
282 | send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room) | 294 | send_close_room (struct GNUNET_MESSENGER_Handle *handle, |
295 | struct GNUNET_MESSENGER_Room *room) | ||
283 | { | 296 | { |
284 | struct GNUNET_MESSENGER_RoomMessage *msg; | 297 | struct GNUNET_MESSENGER_RoomMessage *msg; |
285 | struct GNUNET_MQ_Envelope *env; | 298 | struct GNUNET_MQ_Envelope *env; |
@@ -290,7 +303,9 @@ send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER | |||
290 | } | 303 | } |
291 | 304 | ||
292 | static int | 305 | static int |
293 | iterate_reset_room (void *cls, const struct GNUNET_HashCode *key, void *value) | 306 | iterate_reset_room (void *cls, |
307 | const struct GNUNET_HashCode *key, | ||
308 | void *value) | ||
294 | { | 309 | { |
295 | struct GNUNET_MESSENGER_Handle *handle = cls; | 310 | struct GNUNET_MESSENGER_Handle *handle = cls; |
296 | struct GNUNET_MESSENGER_Room *room = value; | 311 | struct GNUNET_MESSENGER_Room *room = value; |
@@ -329,7 +344,9 @@ callback_reconnect (void *cls) | |||
329 | } | 344 | } |
330 | 345 | ||
331 | static int | 346 | static int |
332 | iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value) | 347 | iterate_close_room (void *cls, |
348 | const struct GNUNET_HashCode *key, | ||
349 | void *value) | ||
333 | { | 350 | { |
334 | struct GNUNET_MESSENGER_Handle *handle = cls; | 351 | struct GNUNET_MESSENGER_Handle *handle = cls; |
335 | struct GNUNET_MESSENGER_Room *room = value; | 352 | struct GNUNET_MESSENGER_Room *room = value; |
@@ -340,7 +357,8 @@ iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
340 | } | 357 | } |
341 | 358 | ||
342 | static void | 359 | static void |
343 | callback_mq_error (void *cls, enum GNUNET_MQ_Error error) | 360 | callback_mq_error (void *cls, |
361 | enum GNUNET_MQ_Error error) | ||
344 | { | 362 | { |
345 | struct GNUNET_MESSENGER_Handle *handle = cls; | 363 | struct GNUNET_MESSENGER_Handle *handle = cls; |
346 | 364 | ||
@@ -402,9 +420,12 @@ reconnect (struct GNUNET_MESSENGER_Handle *handle) | |||
402 | } | 420 | } |
403 | 421 | ||
404 | struct GNUNET_MESSENGER_Handle* | 422 | struct GNUNET_MESSENGER_Handle* |
405 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, | 423 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
406 | GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, | 424 | const char *name, |
407 | GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls) | 425 | GNUNET_MESSENGER_IdentityCallback identity_callback, |
426 | void *identity_cls, | ||
427 | GNUNET_MESSENGER_MessageCallback msg_callback, | ||
428 | void *msg_cls) | ||
408 | { | 429 | { |
409 | struct GNUNET_MESSENGER_Handle *handle = create_handle (cfg, identity_callback, identity_cls, msg_callback, msg_cls); | 430 | struct GNUNET_MESSENGER_Handle *handle = create_handle (cfg, identity_callback, identity_cls, msg_callback, msg_cls); |
410 | 431 | ||
@@ -475,7 +496,8 @@ GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle) | |||
475 | } | 496 | } |
476 | 497 | ||
477 | int | 498 | int |
478 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name) | 499 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, |
500 | const char *name) | ||
479 | { | 501 | { |
480 | if (!handle) | 502 | if (!handle) |
481 | return GNUNET_SYSERR; | 503 | return GNUNET_SYSERR; |
@@ -517,7 +539,8 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle) | |||
517 | } | 539 | } |
518 | 540 | ||
519 | struct GNUNET_MESSENGER_Room* | 541 | struct GNUNET_MESSENGER_Room* |
520 | GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) | 542 | GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, |
543 | const struct GNUNET_HashCode *key) | ||
521 | { | 544 | { |
522 | if ((!handle) || (!key)) | 545 | if ((!handle) || (!key)) |
523 | return NULL; | 546 | return NULL; |
@@ -541,7 +564,8 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct | |||
541 | } | 564 | } |
542 | 565 | ||
543 | struct GNUNET_MESSENGER_Room* | 566 | struct GNUNET_MESSENGER_Room* |
544 | GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, | 567 | GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, |
568 | const struct GNUNET_PeerIdentity *door, | ||
545 | const struct GNUNET_HashCode *key) | 569 | const struct GNUNET_HashCode *key) |
546 | { | 570 | { |
547 | if ((!handle) || (!door) || (!key)) | 571 | if ((!handle) || (!door) || (!key)) |
@@ -583,7 +607,9 @@ struct GNUNET_MESSENGER_RoomFind | |||
583 | }; | 607 | }; |
584 | 608 | ||
585 | static int | 609 | static int |
586 | iterate_find_room (void* cls, const struct GNUNET_HashCode *key, void *value) | 610 | iterate_find_room (void* cls, |
611 | const struct GNUNET_HashCode *key, | ||
612 | void *value) | ||
587 | { | 613 | { |
588 | struct GNUNET_MESSENGER_RoomFind *find = cls; | 614 | struct GNUNET_MESSENGER_RoomFind *find = cls; |
589 | struct GNUNET_MESSENGER_Room *room = value; | 615 | struct GNUNET_MESSENGER_Room *room = value; |
@@ -602,8 +628,10 @@ iterate_find_room (void* cls, const struct GNUNET_HashCode *key, void *value) | |||
602 | } | 628 | } |
603 | 629 | ||
604 | int | 630 | int |
605 | GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, | 631 | GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, |
606 | GNUNET_MESSENGER_MemberCallback callback, void *cls) | 632 | const struct GNUNET_MESSENGER_Contact *contact, |
633 | GNUNET_MESSENGER_MemberCallback callback, | ||
634 | void *cls) | ||
607 | { | 635 | { |
608 | if (!handle) | 636 | if (!handle) |
609 | return GNUNET_SYSERR; | 637 | return GNUNET_SYSERR; |
@@ -628,7 +656,8 @@ GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room) | |||
628 | } | 656 | } |
629 | 657 | ||
630 | const struct GNUNET_MESSENGER_Contact* | 658 | const struct GNUNET_MESSENGER_Contact* |
631 | GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) | 659 | GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, |
660 | const struct GNUNET_HashCode *hash) | ||
632 | { | 661 | { |
633 | if ((!room) || (!hash)) | 662 | if ((!room) || (!hash)) |
634 | return NULL; | 663 | return NULL; |
@@ -655,7 +684,8 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact | |||
655 | } | 684 | } |
656 | 685 | ||
657 | void | 686 | void |
658 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, | 687 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, |
688 | const struct GNUNET_MESSENGER_Message *message, | ||
659 | const struct GNUNET_MESSENGER_Contact *contact) | 689 | const struct GNUNET_MESSENGER_Contact *contact) |
660 | { | 690 | { |
661 | if ((!room) || (!message)) | 691 | if ((!room) || (!message)) |
@@ -723,7 +753,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct | |||
723 | } | 753 | } |
724 | 754 | ||
725 | const struct GNUNET_MESSENGER_Message* | 755 | const struct GNUNET_MESSENGER_Message* |
726 | GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) | 756 | GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, |
757 | const struct GNUNET_HashCode *hash) | ||
727 | { | 758 | { |
728 | if ((!room) || (!hash)) | 759 | if ((!room) || (!hash)) |
729 | return NULL; | 760 | return NULL; |
@@ -745,7 +776,8 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const st | |||
745 | } | 776 | } |
746 | 777 | ||
747 | int | 778 | int |
748 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, | 779 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, |
780 | GNUNET_MESSENGER_MemberCallback callback, | ||
749 | void *cls) | 781 | void *cls) |
750 | { | 782 | { |
751 | if (!room) | 783 | if (!room) |
diff --git a/src/messenger/messenger_api_contact.c b/src/messenger/messenger_api_contact.c index 04e1f60c1..cbca17640 100644 --- a/src/messenger/messenger_api_contact.c +++ b/src/messenger/messenger_api_contact.c | |||
@@ -60,7 +60,8 @@ get_contact_name (const struct GNUNET_MESSENGER_Contact *contact) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | void | 62 | void |
63 | set_contact_name (struct GNUNET_MESSENGER_Contact *contact, const char *name) | 63 | set_contact_name (struct GNUNET_MESSENGER_Contact *contact, |
64 | const char *name) | ||
64 | { | 65 | { |
65 | GNUNET_assert(contact); | 66 | GNUNET_assert(contact); |
66 | 67 | ||
@@ -98,7 +99,8 @@ decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact) | |||
98 | } | 99 | } |
99 | 100 | ||
100 | void | 101 | void |
101 | get_context_from_member (const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, | 102 | get_context_from_member (const struct GNUNET_HashCode *key, |
103 | const struct GNUNET_ShortHashCode *id, | ||
102 | struct GNUNET_HashCode *context) | 104 | struct GNUNET_HashCode *context) |
103 | { | 105 | { |
104 | GNUNET_assert((key) && (id) && (context)); | 106 | GNUNET_assert((key) && (id) && (context)); |
diff --git a/src/messenger/messenger_api_contact.h b/src/messenger/messenger_api_contact.h index e94d1fcd0..b5410f998 100644 --- a/src/messenger/messenger_api_contact.h +++ b/src/messenger/messenger_api_contact.h | |||
@@ -71,7 +71,8 @@ get_contact_name (const struct GNUNET_MESSENGER_Contact *contact); | |||
71 | * @param[in] name Name | 71 | * @param[in] name Name |
72 | */ | 72 | */ |
73 | void | 73 | void |
74 | set_contact_name (struct GNUNET_MESSENGER_Contact *contact, const char *name); | 74 | set_contact_name (struct GNUNET_MESSENGER_Contact *contact, |
75 | const char *name); | ||
75 | 76 | ||
76 | /** | 77 | /** |
77 | * Returns the public key of a given <i>contact</i>. | 78 | * Returns the public key of a given <i>contact</i>. |
@@ -108,7 +109,8 @@ decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact); | |||
108 | * @param[out] hash Member context | 109 | * @param[out] hash Member context |
109 | */ | 110 | */ |
110 | void | 111 | void |
111 | get_context_from_member (const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, | 112 | get_context_from_member (const struct GNUNET_HashCode *key, |
113 | const struct GNUNET_ShortHashCode *id, | ||
112 | struct GNUNET_HashCode *context); | 114 | struct GNUNET_HashCode *context); |
113 | 115 | ||
114 | #endif //GNUNET_MESSENGER_API_CONTACT_H | 116 | #endif //GNUNET_MESSENGER_API_CONTACT_H |
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c index 6a517c2e0..1c10a8fbf 100644 --- a/src/messenger/messenger_api_contact_store.c +++ b/src/messenger/messenger_api_contact_store.c | |||
@@ -38,7 +38,9 @@ init_contact_store (struct GNUNET_MESSENGER_ContactStore *store) | |||
38 | } | 38 | } |
39 | 39 | ||
40 | static int | 40 | static int |
41 | iterate_destroy_contacts (void *cls, const struct GNUNET_HashCode *key, void *value) | 41 | iterate_destroy_contacts (void *cls, |
42 | const struct GNUNET_HashCode *key, | ||
43 | void *value) | ||
42 | { | 44 | { |
43 | struct GNUNET_MESSENGER_Contact *contact = value; | 45 | struct GNUNET_MESSENGER_Contact *contact = value; |
44 | destroy_contact (contact); | 46 | destroy_contact (contact); |
@@ -58,7 +60,8 @@ clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store) | |||
58 | } | 60 | } |
59 | 61 | ||
60 | static struct GNUNET_CONTAINER_MultiHashMap* | 62 | static struct GNUNET_CONTAINER_MultiHashMap* |
61 | select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, | 63 | select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, |
64 | const struct GNUNET_HashCode *context, | ||
62 | struct GNUNET_HashCode *hash) | 65 | struct GNUNET_HashCode *hash) |
63 | { | 66 | { |
64 | const struct GNUNET_IDENTITY_PublicKey *anonymous = get_anonymous_public_key (); | 67 | const struct GNUNET_IDENTITY_PublicKey *anonymous = get_anonymous_public_key (); |
@@ -76,7 +79,8 @@ select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, const str | |||
76 | } | 79 | } |
77 | 80 | ||
78 | struct GNUNET_MESSENGER_Contact* | 81 | struct GNUNET_MESSENGER_Contact* |
79 | get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, | 82 | get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, |
83 | const struct GNUNET_HashCode *context, | ||
80 | const struct GNUNET_HashCode *key_hash) | 84 | const struct GNUNET_HashCode *key_hash) |
81 | { | 85 | { |
82 | GNUNET_assert ((store) && (store->contacts) && (context) && (key_hash)); | 86 | GNUNET_assert ((store) && (store->contacts) && (context) && (key_hash)); |
@@ -92,7 +96,8 @@ get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct | |||
92 | } | 96 | } |
93 | 97 | ||
94 | struct GNUNET_MESSENGER_Contact* | 98 | struct GNUNET_MESSENGER_Contact* |
95 | get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, | 99 | get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
100 | const struct GNUNET_HashCode *context, | ||
96 | const struct GNUNET_IDENTITY_PublicKey *pubkey) | 101 | const struct GNUNET_IDENTITY_PublicKey *pubkey) |
97 | { | 102 | { |
98 | GNUNET_assert ((store) && (store->contacts) && (context) && (pubkey)); | 103 | GNUNET_assert ((store) && (store->contacts) && (context) && (pubkey)); |
@@ -130,8 +135,10 @@ get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNU | |||
130 | } | 135 | } |
131 | 136 | ||
132 | void | 137 | void |
133 | update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact, | 138 | update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
134 | const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, | 139 | struct GNUNET_MESSENGER_Contact* contact, |
140 | const struct GNUNET_HashCode *context, | ||
141 | const struct GNUNET_HashCode *next_context, | ||
135 | const struct GNUNET_IDENTITY_PublicKey *pubkey) | 142 | const struct GNUNET_IDENTITY_PublicKey *pubkey) |
136 | { | 143 | { |
137 | GNUNET_assert ((store) && (store->contacts) && (contact) && (pubkey)); | 144 | GNUNET_assert ((store) && (store->contacts) && (contact) && (pubkey)); |
@@ -163,7 +170,8 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET | |||
163 | } | 170 | } |
164 | 171 | ||
165 | void | 172 | void |
166 | remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact, | 173 | remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
174 | struct GNUNET_MESSENGER_Contact* contact, | ||
167 | const struct GNUNET_HashCode *context) | 175 | const struct GNUNET_HashCode *context) |
168 | { | 176 | { |
169 | GNUNET_assert ((store) && (store->contacts) && (contact)); | 177 | GNUNET_assert ((store) && (store->contacts) && (contact)); |
diff --git a/src/messenger/messenger_api_contact_store.h b/src/messenger/messenger_api_contact_store.h index f2dad9f84..bdab2ceeb 100644 --- a/src/messenger/messenger_api_contact_store.h +++ b/src/messenger/messenger_api_contact_store.h | |||
@@ -68,7 +68,8 @@ clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store); | |||
68 | * @param[in] key_hash Hash of public key | 68 | * @param[in] key_hash Hash of public key |
69 | */ | 69 | */ |
70 | struct GNUNET_MESSENGER_Contact* | 70 | struct GNUNET_MESSENGER_Contact* |
71 | get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, | 71 | get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, |
72 | const struct GNUNET_HashCode *context, | ||
72 | const struct GNUNET_HashCode *key_hash); | 73 | const struct GNUNET_HashCode *key_hash); |
73 | 74 | ||
74 | /** | 75 | /** |
@@ -87,7 +88,8 @@ get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct | |||
87 | * @param[in] pubkey Public key of EGO | 88 | * @param[in] pubkey Public key of EGO |
88 | */ | 89 | */ |
89 | struct GNUNET_MESSENGER_Contact* | 90 | struct GNUNET_MESSENGER_Contact* |
90 | get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, | 91 | get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
92 | const struct GNUNET_HashCode *context, | ||
91 | const struct GNUNET_IDENTITY_PublicKey *pubkey); | 93 | const struct GNUNET_IDENTITY_PublicKey *pubkey); |
92 | 94 | ||
93 | /** | 95 | /** |
@@ -103,8 +105,10 @@ get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNU | |||
103 | * @param[in] pubkey Public key of EGO | 105 | * @param[in] pubkey Public key of EGO |
104 | */ | 106 | */ |
105 | void | 107 | void |
106 | update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact, | 108 | update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
107 | const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, | 109 | struct GNUNET_MESSENGER_Contact* contact, |
110 | const struct GNUNET_HashCode *context, | ||
111 | const struct GNUNET_HashCode *next_context, | ||
108 | const struct GNUNET_IDENTITY_PublicKey *pubkey); | 112 | const struct GNUNET_IDENTITY_PublicKey *pubkey); |
109 | 113 | ||
110 | /** | 114 | /** |
@@ -116,7 +120,8 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET | |||
116 | * @param[in] context Member context | 120 | * @param[in] context Member context |
117 | */ | 121 | */ |
118 | void | 122 | void |
119 | remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact, | 123 | remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, |
124 | struct GNUNET_MESSENGER_Contact* contact, | ||
120 | const struct GNUNET_HashCode *context); | 125 | const struct GNUNET_HashCode *context); |
121 | 126 | ||
122 | #endif //GNUNET_MESSENGER_API_CONTACT_STORE_H | 127 | #endif //GNUNET_MESSENGER_API_CONTACT_STORE_H |
diff --git a/src/messenger/messenger_api_handle.c b/src/messenger/messenger_api_handle.c index ab57f82cc..516807e13 100644 --- a/src/messenger/messenger_api_handle.c +++ b/src/messenger/messenger_api_handle.c | |||
@@ -28,8 +28,11 @@ | |||
28 | #include "messenger_api_util.h" | 28 | #include "messenger_api_util.h" |
29 | 29 | ||
30 | struct GNUNET_MESSENGER_Handle* | 30 | struct GNUNET_MESSENGER_Handle* |
31 | create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_IdentityCallback identity_callback, | 31 | create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, |
32 | void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls) | 32 | GNUNET_MESSENGER_IdentityCallback identity_callback, |
33 | void *identity_cls, | ||
34 | GNUNET_MESSENGER_MessageCallback msg_callback, | ||
35 | void *msg_cls) | ||
33 | { | 36 | { |
34 | GNUNET_assert(cfg); | 37 | GNUNET_assert(cfg); |
35 | 38 | ||
@@ -58,7 +61,9 @@ create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_I | |||
58 | } | 61 | } |
59 | 62 | ||
60 | static int | 63 | static int |
61 | iterate_destroy_room (void *cls, const struct GNUNET_HashCode *key, void *value) | 64 | iterate_destroy_room (void *cls, |
65 | const struct GNUNET_HashCode *key, | ||
66 | void *value) | ||
62 | { | 67 | { |
63 | struct GNUNET_MESSENGER_Room *room = value; | 68 | struct GNUNET_MESSENGER_Room *room = value; |
64 | 69 | ||
@@ -97,7 +102,8 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle) | |||
97 | } | 102 | } |
98 | 103 | ||
99 | void | 104 | void |
100 | set_handle_name (struct GNUNET_MESSENGER_Handle *handle, const char *name) | 105 | set_handle_name (struct GNUNET_MESSENGER_Handle *handle, |
106 | const char *name) | ||
101 | { | 107 | { |
102 | GNUNET_assert(handle); | 108 | GNUNET_assert(handle); |
103 | 109 | ||
@@ -116,7 +122,8 @@ get_handle_name (const struct GNUNET_MESSENGER_Handle *handle) | |||
116 | } | 122 | } |
117 | 123 | ||
118 | void | 124 | void |
119 | set_handle_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *pubkey) | 125 | set_handle_key (struct GNUNET_MESSENGER_Handle *handle, |
126 | const struct GNUNET_IDENTITY_PublicKey *pubkey) | ||
120 | { | 127 | { |
121 | GNUNET_assert(handle); | 128 | GNUNET_assert(handle); |
122 | 129 | ||
@@ -146,7 +153,8 @@ get_handle_contact_store (struct GNUNET_MESSENGER_Handle *handle) | |||
146 | } | 153 | } |
147 | 154 | ||
148 | struct GNUNET_MESSENGER_Contact* | 155 | struct GNUNET_MESSENGER_Contact* |
149 | get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) | 156 | get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, |
157 | const struct GNUNET_HashCode *key) | ||
150 | { | 158 | { |
151 | GNUNET_assert((handle) && (key)); | 159 | GNUNET_assert((handle) && (key)); |
152 | 160 | ||
@@ -162,7 +170,8 @@ get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_ | |||
162 | } | 170 | } |
163 | 171 | ||
164 | void | 172 | void |
165 | open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) | 173 | open_handle_room (struct GNUNET_MESSENGER_Handle *handle, |
174 | const struct GNUNET_HashCode *key) | ||
166 | { | 175 | { |
167 | GNUNET_assert((handle) && (key)); | 176 | GNUNET_assert((handle) && (key)); |
168 | 177 | ||
@@ -173,7 +182,8 @@ open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_Ha | |||
173 | } | 182 | } |
174 | 183 | ||
175 | void | 184 | void |
176 | entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, | 185 | entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, |
186 | const struct GNUNET_PeerIdentity *door, | ||
177 | const struct GNUNET_HashCode *key) | 187 | const struct GNUNET_HashCode *key) |
178 | { | 188 | { |
179 | GNUNET_assert((handle) && (door) && (key)); | 189 | GNUNET_assert((handle) && (door) && (key)); |
@@ -185,7 +195,8 @@ entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNE | |||
185 | } | 195 | } |
186 | 196 | ||
187 | void | 197 | void |
188 | close_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) | 198 | close_handle_room (struct GNUNET_MESSENGER_Handle *handle, |
199 | const struct GNUNET_HashCode *key) | ||
189 | { | 200 | { |
190 | GNUNET_assert((handle) && (key)); | 201 | GNUNET_assert((handle) && (key)); |
191 | 202 | ||
diff --git a/src/messenger/messenger_api_handle.h b/src/messenger/messenger_api_handle.h index e6ca474f2..6a43f13a6 100644 --- a/src/messenger/messenger_api_handle.h +++ b/src/messenger/messenger_api_handle.h | |||
@@ -71,8 +71,11 @@ struct GNUNET_MESSENGER_Handle | |||
71 | * @return New handle | 71 | * @return New handle |
72 | */ | 72 | */ |
73 | struct GNUNET_MESSENGER_Handle* | 73 | struct GNUNET_MESSENGER_Handle* |
74 | create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_IdentityCallback identity_callback, | 74 | create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, |
75 | void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls); | 75 | GNUNET_MESSENGER_IdentityCallback identity_callback, |
76 | void *identity_cls, | ||
77 | GNUNET_MESSENGER_MessageCallback msg_callback, | ||
78 | void *msg_cls); | ||
76 | 79 | ||
77 | /** | 80 | /** |
78 | * Destroys a <i>handle</i> and frees its memory fully from the client API. | 81 | * Destroys a <i>handle</i> and frees its memory fully from the client API. |
@@ -89,7 +92,8 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle); | |||
89 | * @param[in] name New name | 92 | * @param[in] name New name |
90 | */ | 93 | */ |
91 | void | 94 | void |
92 | set_handle_name (struct GNUNET_MESSENGER_Handle *handle, const char *name); | 95 | set_handle_name (struct GNUNET_MESSENGER_Handle *handle, |
96 | const char *name); | ||
93 | 97 | ||
94 | /** | 98 | /** |
95 | * Returns the current name of a given <i>handle</i> or NULL if no valid name was assigned yet. | 99 | * Returns the current name of a given <i>handle</i> or NULL if no valid name was assigned yet. |
@@ -107,7 +111,8 @@ get_handle_name (const struct GNUNET_MESSENGER_Handle *handle); | |||
107 | * @param[in] pubkey Public key | 111 | * @param[in] pubkey Public key |
108 | */ | 112 | */ |
109 | void | 113 | void |
110 | set_handle_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *pubkey); | 114 | set_handle_key (struct GNUNET_MESSENGER_Handle *handle, |
115 | const struct GNUNET_IDENTITY_PublicKey *pubkey); | ||
111 | 116 | ||
112 | /** | 117 | /** |
113 | * Returns the public key of a given <i>handle</i>. | 118 | * Returns the public key of a given <i>handle</i>. |
@@ -136,7 +141,8 @@ get_handle_contact_store (struct GNUNET_MESSENGER_Handle *handle); | |||
136 | * @return Contact | 141 | * @return Contact |
137 | */ | 142 | */ |
138 | struct GNUNET_MESSENGER_Contact* | 143 | struct GNUNET_MESSENGER_Contact* |
139 | get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | 144 | get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, |
145 | const struct GNUNET_HashCode *key); | ||
140 | 146 | ||
141 | /** | 147 | /** |
142 | * Marks a room known to a <i>handle</i> identified by a given <i>key</i> as open. | 148 | * Marks a room known to a <i>handle</i> identified by a given <i>key</i> as open. |
@@ -145,7 +151,8 @@ get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_ | |||
145 | * @param[in] key Key of room | 151 | * @param[in] key Key of room |
146 | */ | 152 | */ |
147 | void | 153 | void |
148 | open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | 154 | open_handle_room (struct GNUNET_MESSENGER_Handle *handle, |
155 | const struct GNUNET_HashCode *key); | ||
149 | 156 | ||
150 | /** | 157 | /** |
151 | * Adds a tunnel for a room known to a <i>handle</i> identified by a given <i>key</i> to a | 158 | * Adds a tunnel for a room known to a <i>handle</i> identified by a given <i>key</i> to a |
@@ -156,7 +163,8 @@ open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_Ha | |||
156 | * @param[in] key Key of room | 163 | * @param[in] key Key of room |
157 | */ | 164 | */ |
158 | void | 165 | void |
159 | entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, | 166 | entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, |
167 | const struct GNUNET_PeerIdentity *door, | ||
160 | const struct GNUNET_HashCode *key); | 168 | const struct GNUNET_HashCode *key); |
161 | 169 | ||
162 | /** | 170 | /** |
@@ -166,6 +174,7 @@ entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNE | |||
166 | * @param[in] key Key of room | 174 | * @param[in] key Key of room |
167 | */ | 175 | */ |
168 | void | 176 | void |
169 | close_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | 177 | close_handle_room (struct GNUNET_MESSENGER_Handle *handle, |
178 | const struct GNUNET_HashCode *key); | ||
170 | 179 | ||
171 | #endif //GNUNET_MESSENGER_API_HANDLE_H | 180 | #endif //GNUNET_MESSENGER_API_HANDLE_H |
diff --git a/src/messenger/messenger_api_list_tunnels.c b/src/messenger/messenger_api_list_tunnels.c index 990e36878..7e77d8f2f 100644 --- a/src/messenger/messenger_api_list_tunnels.c +++ b/src/messenger/messenger_api_list_tunnels.c | |||
@@ -53,14 +53,16 @@ clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | static int | 55 | static int |
56 | compare_list_tunnels (void *cls, struct GNUNET_MESSENGER_ListTunnel *element0, | 56 | compare_list_tunnels (void *cls, |
57 | struct GNUNET_MESSENGER_ListTunnel *element0, | ||
57 | struct GNUNET_MESSENGER_ListTunnel *element1) | 58 | struct GNUNET_MESSENGER_ListTunnel *element1) |
58 | { | 59 | { |
59 | return ((int) element0->peer) - ((int) element1->peer); | 60 | return ((int) element0->peer) - ((int) element1->peer); |
60 | } | 61 | } |
61 | 62 | ||
62 | void | 63 | void |
63 | add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer) | 64 | add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
65 | const struct GNUNET_PeerIdentity *peer) | ||
64 | { | 66 | { |
65 | GNUNET_assert((tunnels) && (peer)); | 67 | GNUNET_assert((tunnels) && (peer)); |
66 | 68 | ||
@@ -73,7 +75,9 @@ add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct | |||
73 | } | 75 | } |
74 | 76 | ||
75 | struct GNUNET_MESSENGER_ListTunnel* | 77 | struct GNUNET_MESSENGER_ListTunnel* |
76 | find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index) | 78 | find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
79 | const struct GNUNET_PeerIdentity *peer, | ||
80 | size_t *index) | ||
77 | { | 81 | { |
78 | GNUNET_assert((tunnels) && (peer)); | 82 | GNUNET_assert((tunnels) && (peer)); |
79 | 83 | ||
@@ -98,7 +102,8 @@ find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GN | |||
98 | } | 102 | } |
99 | 103 | ||
100 | int | 104 | int |
101 | contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer) | 105 | contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
106 | const struct GNUNET_PeerIdentity *peer) | ||
102 | { | 107 | { |
103 | GNUNET_assert((tunnels) && (peer)); | 108 | GNUNET_assert((tunnels) && (peer)); |
104 | 109 | ||
@@ -106,7 +111,8 @@ contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struc | |||
106 | } | 111 | } |
107 | 112 | ||
108 | struct GNUNET_MESSENGER_ListTunnel* | 113 | struct GNUNET_MESSENGER_ListTunnel* |
109 | remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element) | 114 | remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
115 | struct GNUNET_MESSENGER_ListTunnel *element) | ||
110 | { | 116 | { |
111 | GNUNET_assert((tunnels) && (element)); | 117 | GNUNET_assert((tunnels) && (element)); |
112 | 118 | ||
@@ -120,7 +126,8 @@ remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct G | |||
120 | } | 126 | } |
121 | 127 | ||
122 | void | 128 | void |
123 | load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path) | 129 | load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
130 | const char *path) | ||
124 | { | 131 | { |
125 | GNUNET_assert((tunnels) && (path)); | 132 | GNUNET_assert((tunnels) && (path)); |
126 | 133 | ||
@@ -154,7 +161,8 @@ load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *pat | |||
154 | } | 161 | } |
155 | 162 | ||
156 | void | 163 | void |
157 | save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path) | 164 | save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
165 | const char *path) | ||
158 | { | 166 | { |
159 | GNUNET_assert((tunnels) && (path)); | 167 | GNUNET_assert((tunnels) && (path)); |
160 | 168 | ||
diff --git a/src/messenger/messenger_api_list_tunnels.h b/src/messenger/messenger_api_list_tunnels.h index c952da3c2..0e086ee5e 100644 --- a/src/messenger/messenger_api_list_tunnels.h +++ b/src/messenger/messenger_api_list_tunnels.h | |||
@@ -67,7 +67,8 @@ clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels); | |||
67 | * @param[in] peer Peer identity of tunnel | 67 | * @param[in] peer Peer identity of tunnel |
68 | */ | 68 | */ |
69 | void | 69 | void |
70 | add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer); | 70 | add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
71 | const struct GNUNET_PeerIdentity *peer); | ||
71 | 72 | ||
72 | /** | 73 | /** |
73 | * Searches linearly through the list of tunnels peer identities for matching a | 74 | * Searches linearly through the list of tunnels peer identities for matching a |
@@ -85,7 +86,9 @@ add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct | |||
85 | * @return Element in the list with matching peer identity | 86 | * @return Element in the list with matching peer identity |
86 | */ | 87 | */ |
87 | struct GNUNET_MESSENGER_ListTunnel* | 88 | struct GNUNET_MESSENGER_ListTunnel* |
88 | find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index); | 89 | find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
90 | const struct GNUNET_PeerIdentity *peer, | ||
91 | size_t *index); | ||
89 | 92 | ||
90 | /** | 93 | /** |
91 | * Tests linearly if the list of tunnels peer identities contains a specific | 94 | * Tests linearly if the list of tunnels peer identities contains a specific |
@@ -96,7 +99,8 @@ find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GN | |||
96 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 99 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
97 | */ | 100 | */ |
98 | int | 101 | int |
99 | contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer); | 102 | contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
103 | const struct GNUNET_PeerIdentity *peer); | ||
100 | 104 | ||
101 | /** | 105 | /** |
102 | * Removes a specific <i>element</i> from the list of tunnels peer identities and returns | 106 | * Removes a specific <i>element</i> from the list of tunnels peer identities and returns |
@@ -107,7 +111,8 @@ contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struc | |||
107 | * @return Next element in the list | 111 | * @return Next element in the list |
108 | */ | 112 | */ |
109 | struct GNUNET_MESSENGER_ListTunnel* | 113 | struct GNUNET_MESSENGER_ListTunnel* |
110 | remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element); | 114 | remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
115 | struct GNUNET_MESSENGER_ListTunnel *element); | ||
111 | 116 | ||
112 | /** | 117 | /** |
113 | * Loads the list of tunnels peer identities from a file under a given <i>path</i>. | 118 | * Loads the list of tunnels peer identities from a file under a given <i>path</i>. |
@@ -116,7 +121,8 @@ remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct G | |||
116 | * @param[in] path Path of file | 121 | * @param[in] path Path of file |
117 | */ | 122 | */ |
118 | void | 123 | void |
119 | load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path); | 124 | load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
125 | const char *path); | ||
120 | 126 | ||
121 | /** | 127 | /** |
122 | * Saves the list of tunnels peer identities to a file under a given <i>path</i>. | 128 | * Saves the list of tunnels peer identities to a file under a given <i>path</i>. |
@@ -125,6 +131,7 @@ load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *pat | |||
125 | * @param[in] path Path of file | 131 | * @param[in] path Path of file |
126 | */ | 132 | */ |
127 | void | 133 | void |
128 | save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path); | 134 | save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, |
135 | const char *path); | ||
129 | 136 | ||
130 | #endif //GNUNET_MESSENGER_API_LIST_TUNNELS_H | 137 | #endif //GNUNET_MESSENGER_API_LIST_TUNNELS_H |
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index c7364d51c..05bf654fb 100644 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -103,7 +103,8 @@ copy_message (const struct GNUNET_MESSENGER_Message *message) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | static void | 105 | static void |
106 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body) | 106 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, |
107 | struct GNUNET_MESSENGER_MessageBody *body) | ||
107 | { | 108 | { |
108 | switch (kind) | 109 | switch (kind) |
109 | { | 110 | { |
@@ -150,7 +151,8 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) | |||
150 | } | 151 | } |
151 | 152 | ||
152 | static void | 153 | static void |
153 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened) | 154 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, |
155 | struct GNUNET_MESSENGER_ShortMessage *shortened) | ||
154 | { | 156 | { |
155 | shortened->kind = message->header.kind; | 157 | shortened->kind = message->header.kind; |
156 | 158 | ||
@@ -158,7 +160,8 @@ fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNE | |||
158 | } | 160 | } |
159 | 161 | ||
160 | static void | 162 | static void |
161 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message) | 163 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, |
164 | struct GNUNET_MESSENGER_Message *message) | ||
162 | { | 165 | { |
163 | destroy_message_body (message->header.kind, &(message->body)); | 166 | destroy_message_body (message->header.kind, &(message->body)); |
164 | 167 | ||
@@ -231,7 +234,8 @@ get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
231 | } | 234 | } |
232 | 235 | ||
233 | static uint16_t | 236 | static uint16_t |
234 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body) | 237 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, |
238 | const struct GNUNET_MESSENGER_MessageBody *body) | ||
235 | { | 239 | { |
236 | uint16_t length = 0; | 240 | uint16_t length = 0; |
237 | 241 | ||
@@ -283,7 +287,8 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message, | |||
283 | } | 287 | } |
284 | 288 | ||
285 | static uint16_t | 289 | static uint16_t |
286 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, int include_body) | 290 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, |
291 | int include_body) | ||
287 | { | 292 | { |
288 | const uint16_t minimum_size = sizeof(struct GNUNET_HashCode) + sizeof(kind_t); | 293 | const uint16_t minimum_size = sizeof(struct GNUNET_HashCode) + sizeof(kind_t); |
289 | 294 | ||
@@ -370,8 +375,11 @@ calc_padded_length (uint16_t length) | |||
370 | } while (0) | 375 | } while (0) |
371 | 376 | ||
372 | static void | 377 | static void |
373 | encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body, | 378 | encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, |
374 | uint16_t length, char *buffer, uint16_t offset) | 379 | const struct GNUNET_MESSENGER_MessageBody *body, |
380 | uint16_t length, | ||
381 | char *buffer, | ||
382 | uint16_t offset) | ||
375 | { | 383 | { |
376 | uint32_t version; | 384 | uint32_t version; |
377 | switch (kind) | 385 | switch (kind) |
@@ -445,7 +453,9 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET | |||
445 | } | 453 | } |
446 | 454 | ||
447 | void | 455 | void |
448 | encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, | 456 | encode_message (const struct GNUNET_MESSENGER_Message *message, |
457 | uint16_t length, | ||
458 | char *buffer, | ||
449 | int include_signature) | 459 | int include_signature) |
450 | { | 460 | { |
451 | GNUNET_assert((message) && (buffer)); | 461 | GNUNET_assert((message) && (buffer)); |
@@ -466,7 +476,9 @@ encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, | |||
466 | } | 476 | } |
467 | 477 | ||
468 | static void | 478 | static void |
469 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer) | 479 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, |
480 | uint16_t length, | ||
481 | char *buffer) | ||
470 | { | 482 | { |
471 | struct GNUNET_HashCode hash; | 483 | struct GNUNET_HashCode hash; |
472 | uint16_t offset = sizeof(hash); | 484 | uint16_t offset = sizeof(hash); |
@@ -512,8 +524,11 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint1 | |||
512 | } while (0) | 524 | } while (0) |
513 | 525 | ||
514 | static uint16_t | 526 | static uint16_t |
515 | decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body, | 527 | decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, |
516 | uint16_t length, const char *buffer, uint16_t offset) | 528 | struct GNUNET_MESSENGER_MessageBody *body, |
529 | uint16_t length, | ||
530 | const char *buffer, | ||
531 | uint16_t offset) | ||
517 | { | 532 | { |
518 | uint16_t padding = 0; | 533 | uint16_t padding = 0; |
519 | 534 | ||
@@ -593,8 +608,11 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESS | |||
593 | } | 608 | } |
594 | 609 | ||
595 | int | 610 | int |
596 | decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, | 611 | decode_message (struct GNUNET_MESSENGER_Message *message, |
597 | int include_signature, uint16_t *padding) | 612 | uint16_t length, |
613 | const char *buffer, | ||
614 | int include_signature, | ||
615 | uint16_t *padding) | ||
598 | { | 616 | { |
599 | GNUNET_assert((message) && (buffer) && (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))); | 617 | GNUNET_assert((message) && (buffer) && (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))); |
600 | 618 | ||
@@ -638,7 +656,9 @@ decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const | |||
638 | } | 656 | } |
639 | 657 | ||
640 | static int | 658 | static int |
641 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer) | 659 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, |
660 | uint16_t length, | ||
661 | const char *buffer) | ||
642 | { | 662 | { |
643 | struct GNUNET_HashCode expected, hash; | 663 | struct GNUNET_HashCode expected, hash; |
644 | uint16_t offset = sizeof(hash); | 664 | uint16_t offset = sizeof(hash); |
@@ -675,7 +695,9 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t le | |||
675 | } | 695 | } |
676 | 696 | ||
677 | void | 697 | void |
678 | hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, | 698 | hash_message (const struct GNUNET_MESSENGER_Message *message, |
699 | uint16_t length, | ||
700 | const char *buffer, | ||
679 | struct GNUNET_HashCode *hash) | 701 | struct GNUNET_HashCode *hash) |
680 | { | 702 | { |
681 | GNUNET_assert((message) && (buffer) && (hash)); | 703 | GNUNET_assert((message) && (buffer) && (hash)); |
@@ -688,8 +710,11 @@ hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, c | |||
688 | } | 710 | } |
689 | 711 | ||
690 | void | 712 | void |
691 | sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, | 713 | sign_message (struct GNUNET_MESSENGER_Message *message, |
692 | const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego) | 714 | uint16_t length, |
715 | char *buffer, | ||
716 | const struct GNUNET_HashCode *hash, | ||
717 | const struct GNUNET_MESSENGER_Ego *ego) | ||
693 | { | 718 | { |
694 | GNUNET_assert((message) && (buffer) && (hash) && (ego)); | 719 | GNUNET_assert((message) && (buffer) && (hash) && (ego)); |
695 | 720 | ||
@@ -706,7 +731,8 @@ sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *b | |||
706 | } | 731 | } |
707 | 732 | ||
708 | int | 733 | int |
709 | verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, | 734 | verify_message (const struct GNUNET_MESSENGER_Message *message, |
735 | const struct GNUNET_HashCode *hash, | ||
710 | const struct GNUNET_IDENTITY_PublicKey *key) | 736 | const struct GNUNET_IDENTITY_PublicKey *key) |
711 | { | 737 | { |
712 | GNUNET_assert((message) && (hash) && (key)); | 738 | GNUNET_assert((message) && (hash) && (key)); |
@@ -726,7 +752,8 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNU | |||
726 | } | 752 | } |
727 | 753 | ||
728 | int | 754 | int |
729 | encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PublicKey *key) | 755 | encrypt_message (struct GNUNET_MESSENGER_Message *message, |
756 | const struct GNUNET_IDENTITY_PublicKey *key) | ||
730 | { | 757 | { |
731 | GNUNET_assert((message) && (key)); | 758 | GNUNET_assert((message) && (key)); |
732 | 759 | ||
@@ -760,7 +787,8 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
760 | } | 787 | } |
761 | 788 | ||
762 | int | 789 | int |
763 | decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PrivateKey *key) | 790 | decrypt_message (struct GNUNET_MESSENGER_Message *message, |
791 | const struct GNUNET_IDENTITY_PrivateKey *key) | ||
764 | { | 792 | { |
765 | GNUNET_assert((message) && (key)); | 793 | GNUNET_assert((message) && (key)); |
766 | 794 | ||
@@ -788,8 +816,10 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
788 | } | 816 | } |
789 | 817 | ||
790 | struct GNUNET_MQ_Envelope* | 818 | struct GNUNET_MQ_Envelope* |
791 | pack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, | 819 | pack_message (struct GNUNET_MESSENGER_Message *message, |
792 | const struct GNUNET_MESSENGER_Ego *ego, int mode) | 820 | struct GNUNET_HashCode *hash, |
821 | const struct GNUNET_MESSENGER_Ego *ego, | ||
822 | int mode) | ||
793 | { | 823 | { |
794 | GNUNET_assert(message); | 824 | GNUNET_assert(message); |
795 | 825 | ||
diff --git a/src/messenger/messenger_api_message.h b/src/messenger/messenger_api_message.h index 7ce30dc92..6aebf4014 100644 --- a/src/messenger/messenger_api_message.h +++ b/src/messenger/messenger_api_message.h | |||
@@ -107,7 +107,9 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message, | |||
107 | * @param[in] encode_signature Flag to include signature | 107 | * @param[in] encode_signature Flag to include signature |
108 | */ | 108 | */ |
109 | void | 109 | void |
110 | encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, | 110 | encode_message (const struct GNUNET_MESSENGER_Message *message, |
111 | uint16_t length, | ||
112 | char *buffer, | ||
111 | int include_signature); | 113 | int include_signature); |
112 | 114 | ||
113 | /** | 115 | /** |
@@ -125,8 +127,11 @@ encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, | |||
125 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 127 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
126 | */ | 128 | */ |
127 | int | 129 | int |
128 | decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, | 130 | decode_message (struct GNUNET_MESSENGER_Message *message, |
129 | int include_signature, uint16_t *padding); | 131 | uint16_t length, |
132 | const char *buffer, | ||
133 | int include_signature, | ||
134 | uint16_t *padding); | ||
130 | 135 | ||
131 | /** | 136 | /** |
132 | * Calculates a <i>hash</i> of a given <i>buffer</i> with a <i>length</i> in bytes | 137 | * Calculates a <i>hash</i> of a given <i>buffer</i> with a <i>length</i> in bytes |
@@ -138,7 +143,9 @@ decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const | |||
138 | * @param[out] hash Hash | 143 | * @param[out] hash Hash |
139 | */ | 144 | */ |
140 | void | 145 | void |
141 | hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, | 146 | hash_message (const struct GNUNET_MESSENGER_Message *message, |
147 | uint16_t length, | ||
148 | const char *buffer, | ||
142 | struct GNUNET_HashCode *hash); | 149 | struct GNUNET_HashCode *hash); |
143 | 150 | ||
144 | /** | 151 | /** |
@@ -152,8 +159,11 @@ hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, c | |||
152 | * @param[in] ego EGO | 159 | * @param[in] ego EGO |
153 | */ | 160 | */ |
154 | void | 161 | void |
155 | sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, | 162 | sign_message (struct GNUNET_MESSENGER_Message *message, |
156 | const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego); | 163 | uint16_t length, |
164 | char *buffer, | ||
165 | const struct GNUNET_HashCode *hash, | ||
166 | const struct GNUNET_MESSENGER_Ego *ego); | ||
157 | 167 | ||
158 | /** | 168 | /** |
159 | * Verifies the signature of a given <i>message</i> and its <i>hash</i> with a specific | 169 | * Verifies the signature of a given <i>message</i> and its <i>hash</i> with a specific |
@@ -166,7 +176,8 @@ sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *b | |||
166 | * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR | 176 | * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR |
167 | */ | 177 | */ |
168 | int | 178 | int |
169 | verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, | 179 | verify_message (const struct GNUNET_MESSENGER_Message *message, |
180 | const struct GNUNET_HashCode *hash, | ||
170 | const struct GNUNET_IDENTITY_PublicKey *key); | 181 | const struct GNUNET_IDENTITY_PublicKey *key); |
171 | 182 | ||
172 | /** | 183 | /** |
@@ -179,7 +190,8 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNU | |||
179 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 190 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
180 | */ | 191 | */ |
181 | int | 192 | int |
182 | encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PublicKey *key); | 193 | encrypt_message (struct GNUNET_MESSENGER_Message *message, |
194 | const struct GNUNET_IDENTITY_PublicKey *key); | ||
183 | 195 | ||
184 | /** | 196 | /** |
185 | * Decrypts a private <i>message</i> using a given private <i>key</i> and replaces its body | 197 | * Decrypts a private <i>message</i> using a given private <i>key</i> and replaces its body |
@@ -191,7 +203,8 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
191 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | 203 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO |
192 | */ | 204 | */ |
193 | int | 205 | int |
194 | decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PrivateKey *key); | 206 | decrypt_message (struct GNUNET_MESSENGER_Message *message, |
207 | const struct GNUNET_IDENTITY_PrivateKey *key); | ||
195 | 208 | ||
196 | #define GNUNET_MESSENGER_PACK_MODE_ENVELOPE 0x1 | 209 | #define GNUNET_MESSENGER_PACK_MODE_ENVELOPE 0x1 |
197 | #define GNUNET_MESSENGER_PACK_MODE_UNKNOWN 0x0 | 210 | #define GNUNET_MESSENGER_PACK_MODE_UNKNOWN 0x0 |
@@ -209,8 +222,10 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
209 | * @return Envelope or NULL | 222 | * @return Envelope or NULL |
210 | */ | 223 | */ |
211 | struct GNUNET_MQ_Envelope* | 224 | struct GNUNET_MQ_Envelope* |
212 | pack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, | 225 | pack_message (struct GNUNET_MESSENGER_Message *message, |
213 | const struct GNUNET_MESSENGER_Ego *ego, int mode); | 226 | struct GNUNET_HashCode *hash, |
227 | const struct GNUNET_MESSENGER_Ego *ego, | ||
228 | int mode); | ||
214 | 229 | ||
215 | /** | 230 | /** |
216 | * Returns if a specific kind of message should be sent by a client. The function returns | 231 | * Returns if a specific kind of message should be sent by a client. The function returns |
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c index 0d9237a2e..6e2d33f48 100644 --- a/src/messenger/messenger_api_room.c +++ b/src/messenger/messenger_api_room.c | |||
@@ -28,7 +28,8 @@ | |||
28 | #include "messenger_api_handle.h" | 28 | #include "messenger_api_handle.h" |
29 | 29 | ||
30 | struct GNUNET_MESSENGER_Room* | 30 | struct GNUNET_MESSENGER_Room* |
31 | create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) | 31 | create_room (struct GNUNET_MESSENGER_Handle *handle, |
32 | const struct GNUNET_HashCode *key) | ||
32 | { | 33 | { |
33 | GNUNET_assert((handle) && (key)); | 34 | GNUNET_assert((handle) && (key)); |
34 | 35 | ||
@@ -49,7 +50,9 @@ create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCod | |||
49 | } | 50 | } |
50 | 51 | ||
51 | static int | 52 | static int |
52 | iterate_destroy_message (void *cls, const struct GNUNET_HashCode *key, void *value) | 53 | iterate_destroy_message (void *cls, |
54 | const struct GNUNET_HashCode *key, | ||
55 | void *value) | ||
53 | { | 56 | { |
54 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = value; | 57 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = value; |
55 | 58 | ||
@@ -83,7 +86,8 @@ destroy_room (struct GNUNET_MESSENGER_Room *room) | |||
83 | } | 86 | } |
84 | 87 | ||
85 | const struct GNUNET_MESSENGER_Message* | 88 | const struct GNUNET_MESSENGER_Message* |
86 | get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) | 89 | get_room_message (const struct GNUNET_MESSENGER_Room *room, |
90 | const struct GNUNET_HashCode *hash) | ||
87 | { | 91 | { |
88 | GNUNET_assert((room) && (hash)); | 92 | GNUNET_assert((room) && (hash)); |
89 | 93 | ||
@@ -95,7 +99,8 @@ get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ | |||
95 | } | 99 | } |
96 | 100 | ||
97 | struct GNUNET_MESSENGER_Contact* | 101 | struct GNUNET_MESSENGER_Contact* |
98 | get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) | 102 | get_room_sender (const struct GNUNET_MESSENGER_Room *room, |
103 | const struct GNUNET_HashCode *hash) | ||
99 | { | 104 | { |
100 | GNUNET_assert((room) && (hash)); | 105 | GNUNET_assert((room) && (hash)); |
101 | 106 | ||
@@ -107,8 +112,10 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H | |||
107 | } | 112 | } |
108 | 113 | ||
109 | static struct GNUNET_MESSENGER_Contact* | 114 | static struct GNUNET_MESSENGER_Contact* |
110 | handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 115 | handle_join_message (struct GNUNET_MESSENGER_Room *room, |
111 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 116 | struct GNUNET_MESSENGER_Contact *sender, |
117 | const struct GNUNET_MESSENGER_Message *message, | ||
118 | const struct GNUNET_HashCode *hash) | ||
112 | { | 119 | { |
113 | if (!sender) | 120 | if (!sender) |
114 | { | 121 | { |
@@ -129,8 +136,10 @@ handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
129 | } | 136 | } |
130 | 137 | ||
131 | static void | 138 | static void |
132 | handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 139 | handle_leave_message (struct GNUNET_MESSENGER_Room *room, |
133 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 140 | struct GNUNET_MESSENGER_Contact *sender, |
141 | const struct GNUNET_MESSENGER_Message *message, | ||
142 | const struct GNUNET_HashCode *hash) | ||
134 | { | 143 | { |
135 | if ((!sender) || | 144 | if ((!sender) || |
136 | (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender))) | 145 | (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender))) |
@@ -144,8 +153,10 @@ handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGE | |||
144 | } | 153 | } |
145 | 154 | ||
146 | static void | 155 | static void |
147 | handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 156 | handle_name_message (struct GNUNET_MESSENGER_Room *room, |
148 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 157 | struct GNUNET_MESSENGER_Contact *sender, |
158 | const struct GNUNET_MESSENGER_Message *message, | ||
159 | const struct GNUNET_HashCode *hash) | ||
149 | { | 160 | { |
150 | if (!sender) | 161 | if (!sender) |
151 | return; | 162 | return; |
@@ -154,8 +165,10 @@ handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
154 | } | 165 | } |
155 | 166 | ||
156 | static void | 167 | static void |
157 | handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 168 | handle_key_message (struct GNUNET_MESSENGER_Room *room, |
158 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 169 | struct GNUNET_MESSENGER_Contact *sender, |
170 | const struct GNUNET_MESSENGER_Message *message, | ||
171 | const struct GNUNET_HashCode *hash) | ||
159 | { | 172 | { |
160 | if (!sender) | 173 | if (!sender) |
161 | return; | 174 | return; |
@@ -169,8 +182,10 @@ handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_ | |||
169 | } | 182 | } |
170 | 183 | ||
171 | static void | 184 | static void |
172 | handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 185 | handle_id_message (struct GNUNET_MESSENGER_Room *room, |
173 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 186 | struct GNUNET_MESSENGER_Contact *sender, |
187 | const struct GNUNET_MESSENGER_Message *message, | ||
188 | const struct GNUNET_HashCode *hash) | ||
174 | { | 189 | { |
175 | if ((!sender) || | 190 | if ((!sender) || |
176 | (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)) || | 191 | (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)) || |
@@ -188,8 +203,10 @@ handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_C | |||
188 | } | 203 | } |
189 | 204 | ||
190 | static void | 205 | static void |
191 | handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 206 | handle_miss_message (struct GNUNET_MESSENGER_Room *room, |
192 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 207 | struct GNUNET_MESSENGER_Contact *sender, |
208 | const struct GNUNET_MESSENGER_Message *message, | ||
209 | const struct GNUNET_HashCode *hash) | ||
193 | { | 210 | { |
194 | if ((room->contact_id) && (0 == GNUNET_memcmp(&(message->header.sender_id), room->contact_id))) | 211 | if ((room->contact_id) && (0 == GNUNET_memcmp(&(message->header.sender_id), room->contact_id))) |
195 | { | 212 | { |
@@ -201,8 +218,10 @@ handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
201 | } | 218 | } |
202 | 219 | ||
203 | static void | 220 | static void |
204 | handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 221 | handle_delete_message (struct GNUNET_MESSENGER_Room *room, |
205 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 222 | struct GNUNET_MESSENGER_Contact *sender, |
223 | const struct GNUNET_MESSENGER_Message *message, | ||
224 | const struct GNUNET_HashCode *hash) | ||
206 | { | 225 | { |
207 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get ( | 226 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get ( |
208 | room->messages, &(message->body.deletion.hash) | 227 | room->messages, &(message->body.deletion.hash) |
@@ -217,8 +236,10 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG | |||
217 | } | 236 | } |
218 | 237 | ||
219 | struct GNUNET_MESSENGER_Contact* | 238 | struct GNUNET_MESSENGER_Contact* |
220 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 239 | handle_room_message (struct GNUNET_MESSENGER_Room *room, |
221 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 240 | struct GNUNET_MESSENGER_Contact *sender, |
241 | const struct GNUNET_MESSENGER_Message *message, | ||
242 | const struct GNUNET_HashCode *hash) | ||
222 | { | 243 | { |
223 | if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) | 244 | if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) |
224 | return sender; | 245 | return sender; |
@@ -276,7 +297,9 @@ struct GNUNET_MESSENGER_MemberCall | |||
276 | }; | 297 | }; |
277 | 298 | ||
278 | static int | 299 | static int |
279 | iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void *value) | 300 | iterate_local_members (void* cls, |
301 | const struct GNUNET_ShortHashCode *key, | ||
302 | void *value) | ||
280 | { | 303 | { |
281 | struct GNUNET_MESSENGER_MemberCall *call = cls; | 304 | struct GNUNET_MESSENGER_MemberCall *call = cls; |
282 | struct GNUNET_MESSENGER_Contact *contact = value; | 305 | struct GNUNET_MESSENGER_Contact *contact = value; |
@@ -285,7 +308,8 @@ iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void * | |||
285 | } | 308 | } |
286 | 309 | ||
287 | int | 310 | int |
288 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, | 311 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, |
312 | GNUNET_MESSENGER_MemberCallback callback, | ||
289 | void* cls) | 313 | void* cls) |
290 | { | 314 | { |
291 | GNUNET_assert(room); | 315 | GNUNET_assert(room); |
@@ -311,7 +335,9 @@ struct GNUNET_MESSENGER_MemberFind | |||
311 | }; | 335 | }; |
312 | 336 | ||
313 | static int | 337 | static int |
314 | iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *value) | 338 | iterate_find_member (void* cls, |
339 | const struct GNUNET_ShortHashCode *key, | ||
340 | void *value) | ||
315 | { | 341 | { |
316 | struct GNUNET_MESSENGER_MemberFind *find = cls; | 342 | struct GNUNET_MESSENGER_MemberFind *find = cls; |
317 | struct GNUNET_MESSENGER_Contact *contact = value; | 343 | struct GNUNET_MESSENGER_Contact *contact = value; |
@@ -326,7 +352,8 @@ iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *va | |||
326 | } | 352 | } |
327 | 353 | ||
328 | int | 354 | int |
329 | find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact) | 355 | find_room_member (const struct GNUNET_MESSENGER_Room *room, |
356 | const struct GNUNET_MESSENGER_Contact *contact) | ||
330 | { | 357 | { |
331 | GNUNET_assert(room); | 358 | GNUNET_assert(room); |
332 | 359 | ||
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h index 634052272..320312f0c 100644 --- a/src/messenger/messenger_api_room.h +++ b/src/messenger/messenger_api_room.h | |||
@@ -64,7 +64,8 @@ struct GNUNET_MESSENGER_Room | |||
64 | * @return New room | 64 | * @return New room |
65 | */ | 65 | */ |
66 | struct GNUNET_MESSENGER_Room* | 66 | struct GNUNET_MESSENGER_Room* |
67 | create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | 67 | create_room (struct GNUNET_MESSENGER_Handle *handle, |
68 | const struct GNUNET_HashCode *key); | ||
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Destroys a room and frees its memory fully from the client API. | 71 | * Destroys a room and frees its memory fully from the client API. |
@@ -83,7 +84,8 @@ destroy_room (struct GNUNET_MESSENGER_Room *room); | |||
83 | * @return Message or NULL | 84 | * @return Message or NULL |
84 | */ | 85 | */ |
85 | const struct GNUNET_MESSENGER_Message* | 86 | const struct GNUNET_MESSENGER_Message* |
86 | get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | 87 | get_room_message (const struct GNUNET_MESSENGER_Room *room, |
88 | const struct GNUNET_HashCode *hash); | ||
87 | 89 | ||
88 | /** | 90 | /** |
89 | * Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no | 91 | * Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no |
@@ -94,7 +96,8 @@ get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ | |||
94 | * @return Contact of sender or NULL | 96 | * @return Contact of sender or NULL |
95 | */ | 97 | */ |
96 | struct GNUNET_MESSENGER_Contact* | 98 | struct GNUNET_MESSENGER_Contact* |
97 | get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | 99 | get_room_sender (const struct GNUNET_MESSENGER_Room *room, |
100 | const struct GNUNET_HashCode *hash); | ||
98 | 101 | ||
99 | /** | 102 | /** |
100 | * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update | 103 | * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update |
@@ -110,8 +113,10 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H | |||
110 | * @return Contact of sender | 113 | * @return Contact of sender |
111 | */ | 114 | */ |
112 | struct GNUNET_MESSENGER_Contact* | 115 | struct GNUNET_MESSENGER_Contact* |
113 | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, | 116 | handle_room_message (struct GNUNET_MESSENGER_Room *room, |
114 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | 117 | struct GNUNET_MESSENGER_Contact *sender, |
118 | const struct GNUNET_MESSENGER_Message *message, | ||
119 | const struct GNUNET_HashCode *hash); | ||
115 | 120 | ||
116 | /** | 121 | /** |
117 | * Iterates through all members of a given <i>room</i> to forward each of them to a selected | 122 | * Iterates through all members of a given <i>room</i> to forward each of them to a selected |
@@ -123,7 +128,8 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER | |||
123 | * @return Amount of members iterated | 128 | * @return Amount of members iterated |
124 | */ | 129 | */ |
125 | int | 130 | int |
126 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, | 131 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, |
132 | GNUNET_MESSENGER_MemberCallback callback, | ||
127 | void* cls); | 133 | void* cls); |
128 | 134 | ||
129 | /** | 135 | /** |
@@ -135,6 +141,7 @@ iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_Membe | |||
135 | * @return #GNUNET_YES if found, otherwise #GNUNET_NO | 141 | * @return #GNUNET_YES if found, otherwise #GNUNET_NO |
136 | */ | 142 | */ |
137 | int | 143 | int |
138 | find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact); | 144 | find_room_member (const struct GNUNET_MESSENGER_Room *room, |
145 | const struct GNUNET_MESSENGER_Contact *contact); | ||
139 | 146 | ||
140 | #endif //GNUNET_MESSENGER_API_ROOM_H | 147 | #endif //GNUNET_MESSENGER_API_ROOM_H |
diff --git a/src/messenger/messenger_api_util.c b/src/messenger/messenger_api_util.c index 4ad00c45e..52b4e934a 100644 --- a/src/messenger/messenger_api_util.c +++ b/src/messenger/messenger_api_util.c | |||
@@ -45,7 +45,8 @@ delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | int | 47 | int |
48 | generate_free_member_id (struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members) | 48 | generate_free_member_id (struct GNUNET_ShortHashCode *id, |
49 | const struct GNUNET_CONTAINER_MultiShortmap *members) | ||
49 | { | 50 | { |
50 | GNUNET_assert(id); | 51 | GNUNET_assert(id); |
51 | 52 | ||
@@ -84,7 +85,8 @@ get_anonymous_public_key () | |||
84 | } | 85 | } |
85 | 86 | ||
86 | void | 87 | void |
87 | convert_messenger_key_to_port(const struct GNUNET_HashCode *key, struct GNUNET_HashCode *port) | 88 | convert_messenger_key_to_port(const struct GNUNET_HashCode *key, |
89 | struct GNUNET_HashCode *port) | ||
88 | { | 90 | { |
89 | static uint32_t version_value = 0; | 91 | static uint32_t version_value = 0; |
90 | static struct GNUNET_HashCode version; | 92 | static struct GNUNET_HashCode version; |
diff --git a/src/messenger/messenger_api_util.h b/src/messenger/messenger_api_util.h index af562a1e8..af64790b6 100644 --- a/src/messenger/messenger_api_util.h +++ b/src/messenger/messenger_api_util.h | |||
@@ -51,7 +51,8 @@ delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel); | |||
51 | * @return #GNUNET_YES on success, #GNUNET_NO on failure | 51 | * @return #GNUNET_YES on success, #GNUNET_NO on failure |
52 | */ | 52 | */ |
53 | int | 53 | int |
54 | generate_free_member_id (struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members); | 54 | generate_free_member_id (struct GNUNET_ShortHashCode *id, |
55 | const struct GNUNET_CONTAINER_MultiShortmap *members); | ||
55 | 56 | ||
56 | /** | 57 | /** |
57 | * Returns the public identity key of #GNUNET_IDENTITY_ego_get_anonymous() without | 58 | * Returns the public identity key of #GNUNET_IDENTITY_ego_get_anonymous() without |
@@ -73,6 +74,7 @@ get_anonymous_public_key (); | |||
73 | * @param[out] port CADET service port | 74 | * @param[out] port CADET service port |
74 | */ | 75 | */ |
75 | void | 76 | void |
76 | convert_messenger_key_to_port(const struct GNUNET_HashCode *key, struct GNUNET_HashCode *port); | 77 | convert_messenger_key_to_port(const struct GNUNET_HashCode *key, |
78 | struct GNUNET_HashCode *port); | ||
77 | 79 | ||
78 | #endif //GNUNET_SERVICE_MESSENGER_UTIL_H | 80 | #endif //GNUNET_SERVICE_MESSENGER_UTIL_H |
diff --git a/src/messenger/test_messenger.c b/src/messenger/test_messenger.c index fb3e3e1bc..5784dfd82 100644 --- a/src/messenger/test_messenger.c +++ b/src/messenger/test_messenger.c | |||
@@ -100,7 +100,8 @@ static int identity_counter = 0; | |||
100 | * @param handle Handle of messenger service | 100 | * @param handle Handle of messenger service |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | 103 | on_identity (void *cls, |
104 | struct GNUNET_MESSENGER_Handle *handle) | ||
104 | { | 105 | { |
105 | if (op_task) | 106 | if (op_task) |
106 | { | 107 | { |
@@ -150,7 +151,9 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | |||
150 | * @param peer Peer for testing | 151 | * @param peer Peer for testing |
151 | */ | 152 | */ |
152 | static void | 153 | static void |
153 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) | 154 | run (void *cls, |
155 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
156 | struct GNUNET_TESTING_Peer *peer) | ||
154 | { | 157 | { |
155 | die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL); | 158 | die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL); |
156 | 159 | ||
@@ -168,7 +171,8 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TES | |||
168 | * @return 0 ok, 1 on error | 171 | * @return 0 ok, 1 on error |
169 | */ | 172 | */ |
170 | int | 173 | int |
171 | main (int argc, char **argv) | 174 | main (int argc, |
175 | char **argv) | ||
172 | { | 176 | { |
173 | if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL)) | 177 | if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL)) |
174 | return 1; | 178 | return 1; |
diff --git a/src/messenger/test_messenger_adapt.c b/src/messenger/test_messenger_adapt.c index 90e8ac28d..3230af6b7 100644 --- a/src/messenger/test_messenger_adapt.c +++ b/src/messenger/test_messenger_adapt.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 5, 1, 2, 3, 6, 7, 8, 4 }; | 39 | unsigned int doors [] = { 5, 1, 2, 3, 6, 7, 8, 4 }; |
39 | unsigned int stages [] = { 0x21, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x21 }; | 40 | unsigned int stages [] = { 0x21, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x21 }; |
diff --git a/src/messenger/test_messenger_anonymous.c b/src/messenger/test_messenger_anonymous.c index a70121a30..8cb339f0e 100644 --- a/src/messenger/test_messenger_anonymous.c +++ b/src/messenger/test_messenger_anonymous.c | |||
@@ -96,7 +96,8 @@ end_operation (void *cls) | |||
96 | * @param handle Handle of messenger service | 96 | * @param handle Handle of messenger service |
97 | */ | 97 | */ |
98 | static void | 98 | static void |
99 | on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | 99 | on_identity (void *cls, |
100 | struct GNUNET_MESSENGER_Handle *handle) | ||
100 | { | 101 | { |
101 | if (op_task) | 102 | if (op_task) |
102 | { | 103 | { |
@@ -144,7 +145,9 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) | |||
144 | * @param peer Peer for testing | 145 | * @param peer Peer for testing |
145 | */ | 146 | */ |
146 | static void | 147 | static void |
147 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) | 148 | run (void *cls, |
149 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
150 | struct GNUNET_TESTING_Peer *peer) | ||
148 | { | 151 | { |
149 | die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL); | 152 | die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL); |
150 | 153 | ||
@@ -160,7 +163,8 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TES | |||
160 | * @return 0 ok, 1 on error | 163 | * @return 0 ok, 1 on error |
161 | */ | 164 | */ |
162 | int | 165 | int |
163 | main (int argc, char **argv) | 166 | main (int argc, |
167 | char **argv) | ||
164 | { | 168 | { |
165 | if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL)) | 169 | if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL)) |
166 | return 1; | 170 | return 1; |
diff --git a/src/messenger/test_messenger_async_client.c b/src/messenger/test_messenger_async_client.c index 1067b9a6d..8404195dc 100644 --- a/src/messenger/test_messenger_async_client.c +++ b/src/messenger/test_messenger_async_client.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 0, 1 }; | 39 | unsigned int doors [] = { 0, 1 }; |
39 | unsigned int stages [] = { 0x10, 0x20 }; | 40 | unsigned int stages [] = { 0x10, 0x20 }; |
diff --git a/src/messenger/test_messenger_async_p2p.c b/src/messenger/test_messenger_async_p2p.c index d827aae16..25746f7ff 100644 --- a/src/messenger/test_messenger_async_p2p.c +++ b/src/messenger/test_messenger_async_p2p.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 2, 1 }; | 39 | unsigned int doors [] = { 2, 1 }; |
39 | unsigned int stages [] = { 0x30, 0x30 }; | 40 | unsigned int stages [] = { 0x30, 0x30 }; |
diff --git a/src/messenger/test_messenger_growth.c b/src/messenger/test_messenger_growth.c index 3781f3ee5..c3f243cbf 100644 --- a/src/messenger/test_messenger_growth.c +++ b/src/messenger/test_messenger_growth.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 }; | 39 | unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 }; |
39 | unsigned int stages [] = { 0x01, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 }; | 40 | unsigned int stages [] = { 0x01, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 }; |
diff --git a/src/messenger/test_messenger_ring.c b/src/messenger/test_messenger_ring.c index 07cfd0c47..777d79eb8 100644 --- a/src/messenger/test_messenger_ring.c +++ b/src/messenger/test_messenger_ring.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 8, 1, 2, 3, 4, 5, 6, 7 }; | 39 | unsigned int doors [] = { 8, 1, 2, 3, 4, 5, 6, 7 }; |
39 | unsigned int stages [] = { 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 }; | 40 | unsigned int stages [] = { 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 }; |
diff --git a/src/messenger/test_messenger_server.c b/src/messenger/test_messenger_server.c index 1cf2fcc27..61e96e879 100644 --- a/src/messenger/test_messenger_server.c +++ b/src/messenger/test_messenger_server.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 }; | 39 | unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 }; |
39 | unsigned int stages [] = { 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; | 40 | unsigned int stages [] = { 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; |
diff --git a/src/messenger/test_messenger_sync_client.c b/src/messenger/test_messenger_sync_client.c index 99f26b018..02d90a61d 100644 --- a/src/messenger/test_messenger_sync_client.c +++ b/src/messenger/test_messenger_sync_client.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 0, 1 }; | 39 | unsigned int doors [] = { 0, 1 }; |
39 | unsigned int stages [] = { 0x01, 0x20 }; | 40 | unsigned int stages [] = { 0x01, 0x20 }; |
diff --git a/src/messenger/test_messenger_sync_p2p.c b/src/messenger/test_messenger_sync_p2p.c index 77ce280a1..0a900a39e 100644 --- a/src/messenger/test_messenger_sync_p2p.c +++ b/src/messenger/test_messenger_sync_p2p.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 2, 1 }; | 39 | unsigned int doors [] = { 2, 1 }; |
39 | unsigned int stages [] = { 0x21, 0x21 }; | 40 | unsigned int stages [] = { 0x21, 0x21 }; |
diff --git a/src/messenger/test_messenger_worst_client.c b/src/messenger/test_messenger_worst_client.c index 63826631c..a3d5aafec 100644 --- a/src/messenger/test_messenger_worst_client.c +++ b/src/messenger/test_messenger_worst_client.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 0, 1 }; | 39 | unsigned int doors [] = { 0, 1 }; |
39 | unsigned int stages [] = { 0x10, 0x02 }; | 40 | unsigned int stages [] = { 0x10, 0x02 }; |
diff --git a/src/messenger/test_messenger_worst_p2p.c b/src/messenger/test_messenger_worst_p2p.c index c89288eea..89e54cfbd 100644 --- a/src/messenger/test_messenger_worst_p2p.c +++ b/src/messenger/test_messenger_worst_p2p.c | |||
@@ -33,7 +33,8 @@ | |||
33 | * @return 0 ok, 1 on error | 33 | * @return 0 ok, 1 on error |
34 | */ | 34 | */ |
35 | int | 35 | int |
36 | main (int argc, char **argv) | 36 | main (int argc, |
37 | char **argv) | ||
37 | { | 38 | { |
38 | unsigned int doors [] = { 2, 1 }; | 39 | unsigned int doors [] = { 2, 1 }; |
39 | unsigned int stages [] = { 0x12, 0x12 }; | 40 | unsigned int stages [] = { 0x12, 0x12 }; |
diff --git a/src/messenger/testing_messenger_barrier.c b/src/messenger/testing_messenger_barrier.c index 618d255b7..a95ea9ef1 100644 --- a/src/messenger/testing_messenger_barrier.c +++ b/src/messenger/testing_messenger_barrier.c | |||
@@ -61,7 +61,8 @@ GNUNET_init_barrier (unsigned int requirement, | |||
61 | } | 61 | } |
62 | 62 | ||
63 | static void | 63 | static void |
64 | exit_status (struct GNUNET_BarrierHandle *barrier, int status); | 64 | exit_status (struct GNUNET_BarrierHandle *barrier, |
65 | int status); | ||
65 | 66 | ||
66 | static void | 67 | static void |
67 | cancel_barrier (void *cls) | 68 | cancel_barrier (void *cls) |
@@ -96,7 +97,8 @@ struct GNUNET_BarrierWaitHandle | |||
96 | }; | 97 | }; |
97 | 98 | ||
98 | static void | 99 | static void |
99 | exit_status (struct GNUNET_BarrierHandle *barrier, int status) | 100 | exit_status (struct GNUNET_BarrierHandle *barrier, |
101 | int status) | ||
100 | { | 102 | { |
101 | struct GNUNET_BarrierWaitHandle *waiting = barrier->head; | 103 | struct GNUNET_BarrierWaitHandle *waiting = barrier->head; |
102 | while (waiting) | 104 | while (waiting) |
diff --git a/src/messenger/testing_messenger_setup.c b/src/messenger/testing_messenger_setup.c index 98241fa08..3cde8c9bb 100644 --- a/src/messenger/testing_messenger_setup.c +++ b/src/messenger/testing_messenger_setup.c | |||
@@ -204,7 +204,9 @@ end_error_cb (void *cls) | |||
204 | } | 204 | } |
205 | 205 | ||
206 | static void | 206 | static void |
207 | barrier2_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status) | 207 | barrier2_wait_cb (void *cls, |
208 | struct GNUNET_BarrierWaitHandle *waiting, | ||
209 | int status) | ||
208 | { | 210 | { |
209 | struct test_peer *peer = cls; | 211 | struct test_peer *peer = cls; |
210 | 212 | ||
@@ -215,7 +217,9 @@ barrier2_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int statu | |||
215 | } | 217 | } |
216 | 218 | ||
217 | static void | 219 | static void |
218 | barrier_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status) | 220 | barrier_wait_cb (void *cls, |
221 | struct GNUNET_BarrierWaitHandle *waiting, | ||
222 | int status) | ||
219 | { | 223 | { |
220 | struct test_peer *peer = cls; | 224 | struct test_peer *peer = cls; |
221 | 225 | ||
@@ -259,8 +263,11 @@ barrier_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status | |||
259 | * @param flags Flags of message | 263 | * @param flags Flags of message |
260 | */ | 264 | */ |
261 | static void | 265 | static void |
262 | on_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, | 266 | on_message (void *cls, |
263 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, | 267 | struct GNUNET_MESSENGER_Room *room, |
268 | const struct GNUNET_MESSENGER_Contact *sender, | ||
269 | const struct GNUNET_MESSENGER_Message *message, | ||
270 | const struct GNUNET_HashCode *hash, | ||
264 | enum GNUNET_MESSENGER_MessageFlags flags) | 271 | enum GNUNET_MESSENGER_MessageFlags flags) |
265 | { | 272 | { |
266 | struct test_peer *peer = cls; | 273 | struct test_peer *peer = cls; |
@@ -340,7 +347,9 @@ second_stage (void *cls) | |||
340 | } | 347 | } |
341 | 348 | ||
342 | static void | 349 | static void |
343 | on_peer (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, | 350 | on_peer (void *cb_cls, |
351 | struct GNUNET_TESTBED_Operation *op, | ||
352 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
344 | const char *emsg) | 353 | const char *emsg) |
345 | { | 354 | { |
346 | struct test_peer *peer = cb_cls; | 355 | struct test_peer *peer = cb_cls; |
@@ -396,7 +405,8 @@ on_peer (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_ | |||
396 | * @param event Information about the event | 405 | * @param event Information about the event |
397 | */ | 406 | */ |
398 | static void | 407 | static void |
399 | run (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 408 | run (void *cls, |
409 | const struct GNUNET_TESTBED_EventInformation *event) | ||
400 | { | 410 | { |
401 | struct test_properties *properties = cls; | 411 | struct test_properties *properties = cls; |
402 | 412 | ||
@@ -420,7 +430,9 @@ run (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
420 | } | 430 | } |
421 | 431 | ||
422 | static void | 432 | static void |
423 | barrier2_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status) | 433 | barrier2_cb (void *cls, |
434 | struct GNUNET_BarrierHandle *barrier, | ||
435 | int status) | ||
424 | { | 436 | { |
425 | struct test_properties *properties = cls; | 437 | struct test_properties *properties = cls; |
426 | 438 | ||
@@ -449,7 +461,9 @@ barrier2_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status) | |||
449 | } | 461 | } |
450 | 462 | ||
451 | static void | 463 | static void |
452 | barrier_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status) | 464 | barrier_cb (void *cls, |
465 | struct GNUNET_BarrierHandle *barrier, | ||
466 | int status) | ||
453 | { | 467 | { |
454 | struct test_properties *properties = cls; | 468 | struct test_properties *properties = cls; |
455 | 469 | ||
@@ -485,8 +499,12 @@ barrier_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status) | |||
485 | } | 499 | } |
486 | 500 | ||
487 | static void | 501 | static void |
488 | init (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, | 502 | init (void *cls, |
489 | unsigned int links_succeeded, unsigned int links_failed) | 503 | struct GNUNET_TESTBED_RunHandle *h, |
504 | unsigned int num_peers, | ||
505 | struct GNUNET_TESTBED_Peer **peers, | ||
506 | unsigned int links_succeeded, | ||
507 | unsigned int links_failed) | ||
490 | { | 508 | { |
491 | struct test_properties *properties = cls; | 509 | struct test_properties *properties = cls; |
492 | 510 | ||
@@ -500,7 +518,8 @@ init (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, str | |||
500 | } | 518 | } |
501 | 519 | ||
502 | int | 520 | int |
503 | GNUNET_run_messenger_setup (const char* test_name, const struct test_configuration *cfg) | 521 | GNUNET_run_messenger_setup (const char* test_name, |
522 | const struct test_configuration *cfg) | ||
504 | { | 523 | { |
505 | struct test_properties properties; | 524 | struct test_properties properties; |
506 | memset(&properties, 0, sizeof(properties)); | 525 | memset(&properties, 0, sizeof(properties)); |
diff --git a/src/messenger/testing_messenger_setup.h b/src/messenger/testing_messenger_setup.h index 5e6b5d461..e5ae0c151 100644 --- a/src/messenger/testing_messenger_setup.h +++ b/src/messenger/testing_messenger_setup.h | |||
@@ -34,6 +34,7 @@ struct test_configuration | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | int | 36 | int |
37 | GNUNET_run_messenger_setup (const char* test_name, const struct test_configuration *cfg); | 37 | GNUNET_run_messenger_setup (const char* test_name, |
38 | const struct test_configuration *cfg); | ||
38 | 39 | ||
39 | #endif /* GNUNET_TESTING_MESSENGER_SETUP_H_ */ | 40 | #endif /* GNUNET_TESTING_MESSENGER_SETUP_H_ */ |
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am index 8ffa85ddb..272f16b77 100644 --- a/src/namecache/Makefile.am +++ b/src/namecache/Makefile.am | |||
@@ -17,30 +17,22 @@ endif | |||
17 | 17 | ||
18 | if HAVE_EXPERIMENTAL | 18 | if HAVE_EXPERIMENTAL |
19 | FLAT_PLUGIN = libgnunet_plugin_namecache_flat.la | 19 | FLAT_PLUGIN = libgnunet_plugin_namecache_flat.la |
20 | if HAVE_TESTING | ||
21 | FLAT_TESTS = test_plugin_namecache_flat | 20 | FLAT_TESTS = test_plugin_namecache_flat |
22 | endif | 21 | endif |
23 | endif | ||
24 | 22 | ||
25 | if HAVE_SQLITE | 23 | if HAVE_SQLITE |
26 | SQLITE_PLUGIN = libgnunet_plugin_namecache_sqlite.la | 24 | SQLITE_PLUGIN = libgnunet_plugin_namecache_sqlite.la |
27 | if HAVE_TESTING | ||
28 | SQLITE_TESTS = test_plugin_namecache_sqlite | 25 | SQLITE_TESTS = test_plugin_namecache_sqlite |
29 | endif | 26 | endif |
30 | endif | ||
31 | 27 | ||
32 | if HAVE_POSTGRESQL | 28 | if HAVE_POSTGRESQL |
33 | POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la | 29 | POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la |
34 | if HAVE_TESTING | ||
35 | POSTGRES_TESTS = test_plugin_namecache_postgres | 30 | POSTGRES_TESTS = test_plugin_namecache_postgres |
36 | endif | 31 | endif |
37 | endif | ||
38 | 32 | ||
39 | # testcases do not even build yet; thus: experimental! | 33 | # testcases do not even build yet; thus: experimental! |
40 | if HAVE_TESTING | ||
41 | TESTING_TESTS = \ | 34 | TESTING_TESTS = \ |
42 | test_namecache_api_cache_block | 35 | test_namecache_api_cache_block |
43 | endif | ||
44 | 36 | ||
45 | if HAVE_SQLITE | 37 | if HAVE_SQLITE |
46 | check_PROGRAMS = \ | 38 | check_PROGRAMS = \ |
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 18e6a196b..51708dd67 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -16,7 +16,6 @@ if USE_COVERAGE | |||
16 | endif | 16 | endif |
17 | 17 | ||
18 | HEAP_PLUGIN = libgnunet_plugin_namestore_flat.la | 18 | HEAP_PLUGIN = libgnunet_plugin_namestore_flat.la |
19 | if HAVE_TESTING | ||
20 | HEAP_TESTS = test_plugin_namestore_flat \ | 19 | HEAP_TESTS = test_plugin_namestore_flat \ |
21 | test_namestore_api_store_flat \ | 20 | test_namestore_api_store_flat \ |
22 | test_namestore_api_store_update_flat \ | 21 | test_namestore_api_store_update_flat \ |
@@ -35,11 +34,9 @@ HEAP_TESTS = test_plugin_namestore_flat \ | |||
35 | test_namestore_api_monitoring_existing_flat \ | 34 | test_namestore_api_monitoring_existing_flat \ |
36 | test_namestore_api_zone_to_name_flat \ | 35 | test_namestore_api_zone_to_name_flat \ |
37 | perf_namestore_api_zone_iteration_flat | 36 | perf_namestore_api_zone_iteration_flat |
38 | endif | ||
39 | 37 | ||
40 | if HAVE_SQLITE | 38 | if HAVE_SQLITE |
41 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la | 39 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la |
42 | if HAVE_TESTING | ||
43 | SQLITE_TESTS = test_plugin_namestore_sqlite \ | 40 | SQLITE_TESTS = test_plugin_namestore_sqlite \ |
44 | test_namestore_api_store_sqlite \ | 41 | test_namestore_api_store_sqlite \ |
45 | test_namestore_api_store_update_sqlite \ | 42 | test_namestore_api_store_update_sqlite \ |
@@ -59,11 +56,9 @@ SQLITE_TESTS = test_plugin_namestore_sqlite \ | |||
59 | test_namestore_api_zone_to_name_sqlite \ | 56 | test_namestore_api_zone_to_name_sqlite \ |
60 | perf_namestore_api_zone_iteration_sqlite | 57 | perf_namestore_api_zone_iteration_sqlite |
61 | endif | 58 | endif |
62 | endif | ||
63 | 59 | ||
64 | if HAVE_POSTGRESQL | 60 | if HAVE_POSTGRESQL |
65 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la | 61 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la |
66 | if HAVE_TESTING | ||
67 | POSTGRES_TESTS = test_plugin_namestore_postgres \ | 62 | POSTGRES_TESTS = test_plugin_namestore_postgres \ |
68 | test_namestore_api_store_postgres \ | 63 | test_namestore_api_store_postgres \ |
69 | test_namestore_api_store_update_postgres \ | 64 | test_namestore_api_store_update_postgres \ |
@@ -83,7 +78,6 @@ POSTGRES_TESTS = test_plugin_namestore_postgres \ | |||
83 | test_namestore_api_zone_to_name_postgres \ | 78 | test_namestore_api_zone_to_name_postgres \ |
84 | perf_namestore_api_zone_iteration_postgres | 79 | perf_namestore_api_zone_iteration_postgres |
85 | endif | 80 | endif |
86 | endif | ||
87 | 81 | ||
88 | if HAVE_SQLITE | 82 | if HAVE_SQLITE |
89 | check_PROGRAMS = \ | 83 | check_PROGRAMS = \ |
diff --git a/src/nse/Makefile.am b/src/nse/Makefile.am index 824aa10d4..0c6182e61 100644 --- a/src/nse/Makefile.am +++ b/src/nse/Makefile.am | |||
@@ -36,10 +36,8 @@ libgnunetnse_la_LDFLAGS = \ | |||
36 | libexec_PROGRAMS = \ | 36 | libexec_PROGRAMS = \ |
37 | gnunet-service-nse | 37 | gnunet-service-nse |
38 | 38 | ||
39 | if HAVE_TESTING | ||
40 | noinst_PROGRAMS = \ | 39 | noinst_PROGRAMS = \ |
41 | gnunet-nse-profiler | 40 | gnunet-nse-profiler |
42 | endif | ||
43 | 41 | ||
44 | gnunet_nse_profiler_SOURCES = \ | 42 | gnunet_nse_profiler_SOURCES = \ |
45 | gnunet-nse-profiler.c | 43 | gnunet-nse-profiler.c |
@@ -71,12 +69,10 @@ if HAVE_BENCHMARKS | |||
71 | MULTIPEER_TEST = test_nse_multipeer | 69 | MULTIPEER_TEST = test_nse_multipeer |
72 | endif | 70 | endif |
73 | 71 | ||
74 | if HAVE_TESTING | ||
75 | check_PROGRAMS = \ | 72 | check_PROGRAMS = \ |
76 | test_nse_api \ | 73 | test_nse_api \ |
77 | perf_kdf \ | 74 | perf_kdf \ |
78 | $(MULTIPEER_TEST) | 75 | $(MULTIPEER_TEST) |
79 | endif | ||
80 | 76 | ||
81 | if ENABLE_TEST_RUN | 77 | if ENABLE_TEST_RUN |
82 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 78 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 8e9cd0c9d..972b3a79d 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -390,7 +390,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
390 | if (variance >= 0) | 390 | if (variance >= 0) |
391 | std_dev = sqrt (variance); | 391 | std_dev = sqrt (variance); |
392 | else | 392 | else |
393 | std_dev = variance; /* must be infinity due to estimate_count == 0 */ | 393 | std_dev = variance; /* return NaN (due to estimate_count == 0 causing 0.0/0.0) */ |
394 | current_std_dev = std_dev; | 394 | current_std_dev = std_dev; |
395 | current_size_estimate = mean; | 395 | current_size_estimate = mean; |
396 | 396 | ||
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am index e61e5a13d..cdab22a9d 100644 --- a/src/peerinfo/Makefile.am +++ b/src/peerinfo/Makefile.am | |||
@@ -48,14 +48,12 @@ if HAVE_BENCHMARKS | |||
48 | perf_peerinfo_api | 48 | perf_peerinfo_api |
49 | endif | 49 | endif |
50 | 50 | ||
51 | if HAVE_TESTING | ||
52 | check_PROGRAMS = \ | 51 | check_PROGRAMS = \ |
53 | test_peerinfo_shipped_hellos \ | 52 | test_peerinfo_shipped_hellos \ |
54 | test_peerinfo_api \ | 53 | test_peerinfo_api \ |
55 | test_peerinfo_api_friend_only \ | 54 | test_peerinfo_api_friend_only \ |
56 | test_peerinfo_api_notify_friend_only \ | 55 | test_peerinfo_api_notify_friend_only \ |
57 | $(PEERINFO_BENCHMARKS) | 56 | $(PEERINFO_BENCHMARKS) |
58 | endif | ||
59 | 57 | ||
60 | 58 | ||
61 | if ENABLE_TEST_RUN | 59 | if ENABLE_TEST_RUN |
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am index babf40654..d9904e59d 100644 --- a/src/peerstore/Makefile.am +++ b/src/peerstore/Makefile.am | |||
@@ -63,9 +63,7 @@ endif | |||
63 | 63 | ||
64 | if HAVE_SQLITE | 64 | if HAVE_SQLITE |
65 | SQLITE_PLUGIN = libgnunet_plugin_peerstore_sqlite.la | 65 | SQLITE_PLUGIN = libgnunet_plugin_peerstore_sqlite.la |
66 | if HAVE_TESTING | ||
67 | SQLITE_TESTS = test_plugin_peerstore_sqlite | 66 | SQLITE_TESTS = test_plugin_peerstore_sqlite |
68 | endif | ||
69 | libgnunet_plugin_peerstore_sqlite_la_SOURCES = \ | 67 | libgnunet_plugin_peerstore_sqlite_la_SOURCES = \ |
70 | plugin_peerstore_sqlite.c | 68 | plugin_peerstore_sqlite.c |
71 | libgnunet_plugin_peerstore_sqlite_la_LIBADD = \ | 69 | libgnunet_plugin_peerstore_sqlite_la_LIBADD = \ |
diff --git a/src/pq/pq.h b/src/pq/pq.h index d10931d99..354d85a9f 100644 --- a/src/pq/pq.h +++ b/src/pq/pq.h | |||
@@ -73,6 +73,11 @@ struct GNUNET_PQ_Context | |||
73 | * File descriptor wrapper for @e event_task. | 73 | * File descriptor wrapper for @e event_task. |
74 | */ | 74 | */ |
75 | struct GNUNET_NETWORK_Handle *rfd; | 75 | struct GNUNET_NETWORK_Handle *rfd; |
76 | |||
77 | /** | ||
78 | * Flags controlling the connection. | ||
79 | */ | ||
80 | enum GNUNET_PQ_Options flags; | ||
76 | }; | 81 | }; |
77 | 82 | ||
78 | 83 | ||
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index a2dce3fb0..a63d5f14e 100644 --- a/src/pq/pq_connect.c +++ b/src/pq/pq_connect.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2017, 2019, 2020 GNUnet e.V. | 3 | Copyright (C) 2017, 2019, 2020, 2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -70,6 +70,21 @@ GNUNET_PQ_connect (const char *config_str, | |||
70 | const struct GNUNET_PQ_ExecuteStatement *es, | 70 | const struct GNUNET_PQ_ExecuteStatement *es, |
71 | const struct GNUNET_PQ_PreparedStatement *ps) | 71 | const struct GNUNET_PQ_PreparedStatement *ps) |
72 | { | 72 | { |
73 | return GNUNET_PQ_connect2 (config_str, | ||
74 | load_path, | ||
75 | es, | ||
76 | ps, | ||
77 | GNUNET_PQ_FLAG_NONE); | ||
78 | } | ||
79 | |||
80 | |||
81 | struct GNUNET_PQ_Context * | ||
82 | GNUNET_PQ_connect2 (const char *config_str, | ||
83 | const char *load_path, | ||
84 | const struct GNUNET_PQ_ExecuteStatement *es, | ||
85 | const struct GNUNET_PQ_PreparedStatement *ps, | ||
86 | enum GNUNET_PQ_Options flags) | ||
87 | { | ||
73 | struct GNUNET_PQ_Context *db; | 88 | struct GNUNET_PQ_Context *db; |
74 | unsigned int elen = 0; | 89 | unsigned int elen = 0; |
75 | unsigned int plen = 0; | 90 | unsigned int plen = 0; |
@@ -82,6 +97,7 @@ GNUNET_PQ_connect (const char *config_str, | |||
82 | plen++; | 97 | plen++; |
83 | 98 | ||
84 | db = GNUNET_new (struct GNUNET_PQ_Context); | 99 | db = GNUNET_new (struct GNUNET_PQ_Context); |
100 | db->flags = flags; | ||
85 | db->config_str = GNUNET_strdup (config_str); | 101 | db->config_str = GNUNET_strdup (config_str); |
86 | if (NULL != load_path) | 102 | if (NULL != load_path) |
87 | db->load_path = GNUNET_strdup (load_path); | 103 | db->load_path = GNUNET_strdup (load_path); |
@@ -200,68 +216,72 @@ GNUNET_PQ_run_sql (struct GNUNET_PQ_Context *db, | |||
200 | load_path); | 216 | load_path); |
201 | for (unsigned int i = 1; i<10000; i++) | 217 | for (unsigned int i = 1; i<10000; i++) |
202 | { | 218 | { |
219 | char patch_name[slen]; | ||
220 | char buf[slen]; | ||
203 | enum GNUNET_DB_QueryStatus qs; | 221 | enum GNUNET_DB_QueryStatus qs; |
204 | { | 222 | |
205 | char buf[slen]; | 223 | /* First, check patch actually exists */ |
206 | 224 | GNUNET_snprintf (buf, | |
207 | /* First, check patch actually exists */ | 225 | sizeof (buf), |
208 | GNUNET_snprintf (buf, | 226 | "%s%04u.sql", |
209 | sizeof (buf), | 227 | load_path, |
210 | "%s%04u.sql", | 228 | i); |
211 | load_path, | 229 | if (GNUNET_YES != |
212 | i); | 230 | GNUNET_DISK_file_test (buf)) |
213 | if (GNUNET_YES != | 231 | return GNUNET_OK; /* We are done */ |
214 | GNUNET_DISK_file_test (buf)) | ||
215 | return GNUNET_OK; /* We are done */ | ||
216 | } | ||
217 | 232 | ||
218 | /* Second, check with DB versioning schema if this patch was already applied, | 233 | /* Second, check with DB versioning schema if this patch was already applied, |
219 | if so, skip it. */ | 234 | if so, skip it. */ |
235 | GNUNET_snprintf (patch_name, | ||
236 | sizeof (patch_name), | ||
237 | "%s%04u", | ||
238 | load_path_suffix, | ||
239 | i); | ||
220 | { | 240 | { |
221 | char patch_name[slen]; | 241 | char *applied_by; |
222 | 242 | struct GNUNET_PQ_QueryParam params[] = { | |
223 | GNUNET_snprintf (patch_name, | 243 | GNUNET_PQ_query_param_string (patch_name), |
224 | sizeof (patch_name), | 244 | GNUNET_PQ_query_param_end |
225 | "%s%04u", | 245 | }; |
226 | load_path_suffix, | 246 | struct GNUNET_PQ_ResultSpec rs[] = { |
227 | i); | 247 | GNUNET_PQ_result_spec_string ("applied_by", |
248 | &applied_by), | ||
249 | GNUNET_PQ_result_spec_end | ||
250 | }; | ||
251 | |||
252 | qs = GNUNET_PQ_eval_prepared_singleton_select (db, | ||
253 | "gnunet_pq_check_patch", | ||
254 | params, | ||
255 | rs); | ||
256 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) | ||
257 | { | ||
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
259 | "Database version %s already applied by %s, skipping\n", | ||
260 | patch_name, | ||
261 | applied_by); | ||
262 | GNUNET_PQ_cleanup_result (rs); | ||
263 | } | ||
264 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | ||
228 | { | 265 | { |
229 | char *applied_by; | 266 | GNUNET_break (0); |
230 | struct GNUNET_PQ_QueryParam params[] = { | 267 | return GNUNET_SYSERR; |
231 | GNUNET_PQ_query_param_string (patch_name), | ||
232 | GNUNET_PQ_query_param_end | ||
233 | }; | ||
234 | struct GNUNET_PQ_ResultSpec rs[] = { | ||
235 | GNUNET_PQ_result_spec_string ("applied_by", | ||
236 | &applied_by), | ||
237 | GNUNET_PQ_result_spec_end | ||
238 | }; | ||
239 | |||
240 | qs = GNUNET_PQ_eval_prepared_singleton_select (db, | ||
241 | "gnunet_pq_check_patch", | ||
242 | params, | ||
243 | rs); | ||
244 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) | ||
245 | { | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
247 | "Database version %s already applied by %s, skipping\n", | ||
248 | patch_name, | ||
249 | applied_by); | ||
250 | GNUNET_PQ_cleanup_result (rs); | ||
251 | } | ||
252 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | ||
253 | { | ||
254 | GNUNET_break (0); | ||
255 | return GNUNET_SYSERR; | ||
256 | } | ||
257 | } | 268 | } |
258 | } | 269 | } |
259 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) | 270 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) |
260 | continue; /* patch already applied, skip it */ | 271 | continue; /* patch already applied, skip it */ |
261 | 272 | ||
262 | /* patch not yet applied, run it! */ | 273 | if (0 != (GNUNET_PQ_FLAG_CHECK_CURRENT & db->flags)) |
263 | { | 274 | { |
264 | int ret; | 275 | /* We are only checking, found unapplied patch, bad! */ |
276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
277 | "Database outdated, patch %s missing. Aborting!\n", | ||
278 | patch_name); | ||
279 | return GNUNET_SYSERR; | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | /* patch not yet applied, run it! */ | ||
284 | enum GNUNET_GenericReturnValue ret; | ||
265 | 285 | ||
266 | ret = apply_patch (db, | 286 | ret = apply_patch (db, |
267 | load_path, | 287 | load_path, |
@@ -334,9 +354,17 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
334 | NULL); | 354 | NULL); |
335 | if (PGRES_COMMAND_OK != PQresultStatus (res)) | 355 | if (PGRES_COMMAND_OK != PQresultStatus (res)) |
336 | { | 356 | { |
337 | int ret; | 357 | enum GNUNET_GenericReturnValue ret; |
338 | 358 | ||
339 | PQclear (res); | 359 | PQclear (res); |
360 | if (0 != (db->flags & GNUNET_PQ_FLAG_DROP)) | ||
361 | { | ||
362 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
363 | "Failed to prepare statement to check patch level. Likely versioning schema does not exist yet. Not attempting drop!\n"); | ||
364 | PQfinish (db->conn); | ||
365 | db->conn = NULL; | ||
366 | return; | ||
367 | } | ||
340 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 368 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
341 | "Failed to prepare statement to check patch level. Likely versioning schema does not exist yet, loading patch level 0000!\n"); | 369 | "Failed to prepare statement to check patch level. Likely versioning schema does not exist yet, loading patch level 0000!\n"); |
342 | ret = apply_patch (db, | 370 | ret = apply_patch (db, |
@@ -424,6 +452,23 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
424 | const struct GNUNET_PQ_ExecuteStatement *es, | 452 | const struct GNUNET_PQ_ExecuteStatement *es, |
425 | const struct GNUNET_PQ_PreparedStatement *ps) | 453 | const struct GNUNET_PQ_PreparedStatement *ps) |
426 | { | 454 | { |
455 | return GNUNET_PQ_connect_with_cfg2 (cfg, | ||
456 | section, | ||
457 | load_path_suffix, | ||
458 | es, | ||
459 | ps, | ||
460 | GNUNET_PQ_FLAG_NONE); | ||
461 | } | ||
462 | |||
463 | |||
464 | struct GNUNET_PQ_Context * | ||
465 | GNUNET_PQ_connect_with_cfg2 (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
466 | const char *section, | ||
467 | const char *load_path_suffix, | ||
468 | const struct GNUNET_PQ_ExecuteStatement *es, | ||
469 | const struct GNUNET_PQ_PreparedStatement *ps, | ||
470 | enum GNUNET_PQ_Options flags) | ||
471 | { | ||
427 | struct GNUNET_PQ_Context *db; | 472 | struct GNUNET_PQ_Context *db; |
428 | char *conninfo; | 473 | char *conninfo; |
429 | char *load_path; | 474 | char *load_path; |
@@ -447,10 +492,11 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
447 | "%s%s", | 492 | "%s%s", |
448 | sp, | 493 | sp, |
449 | load_path_suffix); | 494 | load_path_suffix); |
450 | db = GNUNET_PQ_connect (conninfo == NULL ? "" : conninfo, | 495 | db = GNUNET_PQ_connect2 (conninfo == NULL ? "" : conninfo, |
451 | load_path, | 496 | load_path, |
452 | es, | 497 | es, |
453 | ps); | 498 | ps, |
499 | flags); | ||
454 | GNUNET_free (load_path); | 500 | GNUNET_free (load_path); |
455 | GNUNET_free (sp); | 501 | GNUNET_free (sp); |
456 | GNUNET_free (conninfo); | 502 | GNUNET_free (conninfo); |
diff --git a/src/pq/pq_exec.c b/src/pq/pq_exec.c index fd4feae53..464fff4b4 100644 --- a/src/pq/pq_exec.c +++ b/src/pq/pq_exec.c | |||
@@ -72,7 +72,7 @@ GNUNET_PQ_make_try_execute (const char *sql) | |||
72 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) | 72 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) |
73 | * #GNUNET_SYSERR on error | 73 | * #GNUNET_SYSERR on error |
74 | */ | 74 | */ |
75 | int | 75 | enum GNUNET_GenericReturnValue |
76 | GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, | 76 | GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, |
77 | const struct GNUNET_PQ_ExecuteStatement *es) | 77 | const struct GNUNET_PQ_ExecuteStatement *es) |
78 | { | 78 | { |
diff --git a/src/pt/Makefile.am b/src/pt/Makefile.am index 10ae04931..fc2cb592c 100644 --- a/src/pt/Makefile.am +++ b/src/pt/Makefile.am | |||
@@ -28,8 +28,6 @@ gnunet_daemon_pt_LDADD = \ | |||
28 | $(top_builddir)/src/util/libgnunetutil.la \ | 28 | $(top_builddir)/src/util/libgnunetutil.la \ |
29 | $(GN_LIBINTL) | 29 | $(GN_LIBINTL) |
30 | 30 | ||
31 | if HAVE_TESTING | ||
32 | |||
33 | if HAVE_LIBGNURL | 31 | if HAVE_LIBGNURL |
34 | LIB_GNURL=@LIBGNURL@ | 32 | LIB_GNURL=@LIBGNURL@ |
35 | CPP_GNURL=@LIBGNURL_CPPFLAGS@ | 33 | CPP_GNURL=@LIBGNURL_CPPFLAGS@ |
@@ -56,8 +54,6 @@ endif | |||
56 | endif | 54 | endif |
57 | endif | 55 | endif |
58 | 56 | ||
59 | endif | ||
60 | |||
61 | check_PROGRAMS = $(VPN_TEST) | 57 | check_PROGRAMS = $(VPN_TEST) |
62 | 58 | ||
63 | if ENABLE_TEST_RUN | 59 | if ENABLE_TEST_RUN |
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 9a7466cb2..2dbf3a3f9 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -102,11 +102,9 @@ libgnunetregextest_a_LIBADD = \ | |||
102 | $(top_builddir)/src/util/libgnunetutil.la \ | 102 | $(top_builddir)/src/util/libgnunetutil.la \ |
103 | libgnunetregex_internal.a | 103 | libgnunetregex_internal.a |
104 | 104 | ||
105 | if HAVE_TESTING | ||
106 | noinst_PROGRAMS = $(noinst_mysql_progs) \ | 105 | noinst_PROGRAMS = $(noinst_mysql_progs) \ |
107 | perf-regex \ | 106 | perf-regex \ |
108 | gnunet-regex-profiler | 107 | gnunet-regex-profiler |
109 | endif | ||
110 | 108 | ||
111 | perf_regex_SOURCES = \ | 109 | perf_regex_SOURCES = \ |
112 | perf-regex.c | 110 | perf-regex.c |
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am index b9de6b5e3..b5e8c0617 100644 --- a/src/rps/Makefile.am +++ b/src/rps/Makefile.am | |||
@@ -45,10 +45,8 @@ libgnunetrps_la_CFLAGS = $(AM_CFLAGS) | |||
45 | libexec_PROGRAMS = \ | 45 | libexec_PROGRAMS = \ |
46 | gnunet-service-rps | 46 | gnunet-service-rps |
47 | 47 | ||
48 | if HAVE_TESTING | ||
49 | noinst_PROGRAMS = \ | 48 | noinst_PROGRAMS = \ |
50 | gnunet-rps-profiler | 49 | gnunet-rps-profiler |
51 | endif | ||
52 | 50 | ||
53 | 51 | ||
54 | gnunet_service_rps_SOURCES = \ | 52 | gnunet_service_rps_SOURCES = \ |
@@ -74,7 +72,6 @@ gnunet_service_rps_LDADD = \ | |||
74 | $(GN_LIBINTL) | 72 | $(GN_LIBINTL) |
75 | 73 | ||
76 | 74 | ||
77 | if HAVE_TESTING | ||
78 | check_PROGRAMS = \ | 75 | check_PROGRAMS = \ |
79 | test_service_rps_view \ | 76 | test_service_rps_view \ |
80 | test_service_rps_custommap \ | 77 | test_service_rps_custommap \ |
@@ -91,7 +88,6 @@ check_PROGRAMS += \ | |||
91 | test_rps_malicious_2 \ | 88 | test_rps_malicious_2 \ |
92 | test_rps_malicious_3 | 89 | test_rps_malicious_3 |
93 | endif | 90 | endif |
94 | endif | ||
95 | 91 | ||
96 | rps_test_src = \ | 92 | rps_test_src = \ |
97 | test_rps.c \ | 93 | test_rps.c \ |
diff --git a/src/secretsharing/Makefile.am b/src/secretsharing/Makefile.am index 9ae6e7892..13dd0bd8d 100644 --- a/src/secretsharing/Makefile.am +++ b/src/secretsharing/Makefile.am | |||
@@ -51,7 +51,6 @@ libgnunetsecretsharing_la_LIBADD = \ | |||
51 | libgnunetsecretsharing_la_LDFLAGS = \ | 51 | libgnunetsecretsharing_la_LDFLAGS = \ |
52 | $(GN_LIB_LDFLAGS) | 52 | $(GN_LIB_LDFLAGS) |
53 | 53 | ||
54 | if HAVE_TESTING | ||
55 | bin_PROGRAMS = \ | 54 | bin_PROGRAMS = \ |
56 | gnunet-secretsharing-profiler | 55 | gnunet-secretsharing-profiler |
57 | 56 | ||
@@ -62,7 +61,6 @@ if ENABLE_TEST_RUN | |||
62 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 61 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
63 | TESTS = $(check_PROGRAMS) | 62 | TESTS = $(check_PROGRAMS) |
64 | endif | 63 | endif |
65 | endif | ||
66 | 64 | ||
67 | test_secretsharing_api_SOURCES = \ | 65 | test_secretsharing_api_SOURCES = \ |
68 | test_secretsharing_api.c | 66 | test_secretsharing_api.c |
diff --git a/src/set/Makefile.am b/src/set/Makefile.am index d6b10a1f8..837d42ff5 100644 --- a/src/set/Makefile.am +++ b/src/set/Makefile.am | |||
@@ -14,13 +14,11 @@ if USE_COVERAGE | |||
14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage | 14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage |
15 | endif | 15 | endif |
16 | 16 | ||
17 | if HAVE_TESTING | ||
18 | bin_PROGRAMS = \ | 17 | bin_PROGRAMS = \ |
19 | gnunet-set-profiler | 18 | gnunet-set-profiler |
20 | 19 | ||
21 | noinst_PROGRAMS = \ | 20 | noinst_PROGRAMS = \ |
22 | gnunet-set-ibf-profiler | 21 | gnunet-set-ibf-profiler |
23 | endif | ||
24 | 22 | ||
25 | libexec_PROGRAMS = \ | 23 | libexec_PROGRAMS = \ |
26 | gnunet-service-set | 24 | gnunet-service-set |
@@ -69,13 +67,11 @@ libgnunetset_la_LIBADD = \ | |||
69 | libgnunetset_la_LDFLAGS = \ | 67 | libgnunetset_la_LDFLAGS = \ |
70 | $(GN_LIB_LDFLAGS) | 68 | $(GN_LIB_LDFLAGS) |
71 | 69 | ||
72 | if HAVE_TESTING | ||
73 | check_PROGRAMS = \ | 70 | check_PROGRAMS = \ |
74 | test_set_api \ | 71 | test_set_api \ |
75 | test_set_union_result_symmetric \ | 72 | test_set_union_result_symmetric \ |
76 | test_set_intersection_result_full \ | 73 | test_set_intersection_result_full \ |
77 | test_set_union_copy | 74 | test_set_union_copy |
78 | endif | ||
79 | 75 | ||
80 | if ENABLE_TEST_RUN | 76 | if ENABLE_TEST_RUN |
81 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 77 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/seti/Makefile.am b/src/seti/Makefile.am index 522f33ece..8441c5060 100644 --- a/src/seti/Makefile.am +++ b/src/seti/Makefile.am | |||
@@ -14,10 +14,8 @@ if USE_COVERAGE | |||
14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage | 14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage |
15 | endif | 15 | endif |
16 | 16 | ||
17 | if HAVE_TESTING | ||
18 | bin_PROGRAMS = \ | 17 | bin_PROGRAMS = \ |
19 | gnunet-seti-profiler | 18 | gnunet-seti-profiler |
20 | endif | ||
21 | 19 | ||
22 | libexec_PROGRAMS = \ | 20 | libexec_PROGRAMS = \ |
23 | gnunet-service-seti | 21 | gnunet-service-seti |
@@ -55,10 +53,8 @@ libgnunetseti_la_LIBADD = \ | |||
55 | libgnunetseti_la_LDFLAGS = \ | 53 | libgnunetseti_la_LDFLAGS = \ |
56 | $(GN_LIB_LDFLAGS) | 54 | $(GN_LIB_LDFLAGS) |
57 | 55 | ||
58 | if HAVE_TESTING | ||
59 | check_PROGRAMS = \ | 56 | check_PROGRAMS = \ |
60 | test_seti_api | 57 | test_seti_api |
61 | endif | ||
62 | 58 | ||
63 | if ENABLE_TEST_RUN | 59 | if ENABLE_TEST_RUN |
64 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 60 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/setu/Makefile.am b/src/setu/Makefile.am index 77d048add..897bf3f86 100644 --- a/src/setu/Makefile.am +++ b/src/setu/Makefile.am | |||
@@ -14,13 +14,11 @@ if USE_COVERAGE | |||
14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage | 14 | AM_CFLAGS = -fprofile-arcs -ftest-coverage |
15 | endif | 15 | endif |
16 | 16 | ||
17 | if HAVE_TESTING | ||
18 | bin_PROGRAMS = \ | 17 | bin_PROGRAMS = \ |
19 | gnunet-setu-profiler | 18 | gnunet-setu-profiler |
20 | 19 | ||
21 | noinst_PROGRAMS = \ | 20 | noinst_PROGRAMS = \ |
22 | gnunet-setu-ibf-profiler | 21 | gnunet-setu-ibf-profiler |
23 | endif | ||
24 | 22 | ||
25 | libexec_PROGRAMS = \ | 23 | libexec_PROGRAMS = \ |
26 | gnunet-service-setu | 24 | gnunet-service-setu |
@@ -67,11 +65,9 @@ libgnunetsetu_la_LIBADD = \ | |||
67 | libgnunetsetu_la_LDFLAGS = \ | 65 | libgnunetsetu_la_LDFLAGS = \ |
68 | $(GN_LIB_LDFLAGS) | 66 | $(GN_LIB_LDFLAGS) |
69 | 67 | ||
70 | if HAVE_TESTING | ||
71 | check_PROGRAMS = \ | 68 | check_PROGRAMS = \ |
72 | test_setu_api \ | 69 | test_setu_api \ |
73 | perf_setu_api | 70 | perf_setu_api |
74 | endif | ||
75 | 71 | ||
76 | if ENABLE_TEST_RUN | 72 | if ENABLE_TEST_RUN |
77 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 73 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index b07c725a3..49d975119 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -227,11 +227,9 @@ test_run (void *cls, | |||
227 | abort_task = NULL; | 227 | abort_task = NULL; |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | #if (! ENABLE_SUPERMUC) | ||
231 | fprintf (stdout, "Testbed running, waiting for keystroke to shut down\n"); | 230 | fprintf (stdout, "Testbed running, waiting for keystroke to shut down\n"); |
232 | fflush (stdout); | 231 | fflush (stdout); |
233 | (void) getc (stdin); | 232 | (void) getc (stdin); |
234 | #endif | ||
235 | fprintf (stdout, "Shutting down. Please wait\n"); | 233 | fprintf (stdout, "Shutting down. Please wait\n"); |
236 | fflush (stdout); | 234 | fflush (stdout); |
237 | GNUNET_SCHEDULER_shutdown (); | 235 | GNUNET_SCHEDULER_shutdown (); |
@@ -297,14 +295,12 @@ main (int argc, char *const *argv) | |||
297 | "keystroke but continues to run until a termination " | 295 | "keystroke but continues to run until a termination " |
298 | "signal is received"), | 296 | "signal is received"), |
299 | &noninteractive), | 297 | &noninteractive), |
300 | #if ! ENABLE_SUPERMUC | ||
301 | GNUNET_GETOPT_option_string ('H', | 298 | GNUNET_GETOPT_option_string ('H', |
302 | "hosts", | 299 | "hosts", |
303 | "FILENAME", | 300 | "FILENAME", |
304 | gettext_noop ( | 301 | gettext_noop ( |
305 | "name of the file with the login information for the testbed"), | 302 | "name of the file with the login information for the testbed"), |
306 | &hosts_file), | 303 | &hosts_file), |
307 | #endif | ||
308 | GNUNET_GETOPT_OPTION_END | 304 | GNUNET_GETOPT_OPTION_END |
309 | }; | 305 | }; |
310 | const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]"; | 306 | const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]"; |
diff --git a/src/testbed/gnunet_testbed_mpi_spawn.c b/src/testbed/gnunet_testbed_mpi_spawn.c deleted file mode 100644 index 577ffbeba..000000000 --- a/src/testbed/gnunet_testbed_mpi_spawn.c +++ /dev/null | |||
@@ -1,327 +0,0 @@ | |||
1 | #include "platform.h" | ||
2 | #include "gnunet_util_lib.h" | ||
3 | #include "gnunet_testbed_service.h" | ||
4 | |||
5 | |||
6 | /** | ||
7 | * Generic logging shorthand | ||
8 | */ | ||
9 | #define LOG(kind, ...) \ | ||
10 | GNUNET_log (kind, __VA_ARGS__) | ||
11 | |||
12 | /** | ||
13 | * Debug logging shorthand | ||
14 | */ | ||
15 | #define LOG_DEBUG(...) \ | ||
16 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | ||
17 | |||
18 | /** | ||
19 | * Global result | ||
20 | */ | ||
21 | static int ret; | ||
22 | |||
23 | /** | ||
24 | * The child process we spawn | ||
25 | */ | ||
26 | static struct GNUNET_OS_Process *child; | ||
27 | |||
28 | /** | ||
29 | * The arguments including the binary to spawn | ||
30 | */ | ||
31 | static char **argv2; | ||
32 | |||
33 | /** | ||
34 | * Pipe used to communicate shutdown via signal. | ||
35 | */ | ||
36 | static struct GNUNET_DISK_PipeHandle *sigpipe; | ||
37 | |||
38 | /** | ||
39 | * Filename of the unique file | ||
40 | */ | ||
41 | static char *fn; | ||
42 | |||
43 | /** | ||
44 | * Handle to the unique file | ||
45 | */ | ||
46 | static int fh; | ||
47 | |||
48 | /** | ||
49 | * The return code of the binary | ||
50 | */ | ||
51 | static unsigned long child_exit_code; | ||
52 | |||
53 | /** | ||
54 | * The process status of the child | ||
55 | */ | ||
56 | static enum GNUNET_OS_ProcessStatusType child_status; | ||
57 | |||
58 | /** | ||
59 | * Task to kill the child | ||
60 | */ | ||
61 | static struct GNUNET_SCHEDULER_Task *terminate_task_id; | ||
62 | |||
63 | /** | ||
64 | * Task to kill the child | ||
65 | */ | ||
66 | static struct GNUNET_SCHEDULER_Task *child_death_task_id; | ||
67 | |||
68 | /** | ||
69 | * The shutdown task | ||
70 | */ | ||
71 | static void | ||
72 | shutdown_task (void *cls) | ||
73 | { | ||
74 | if (0 != child_exit_code) | ||
75 | { | ||
76 | LOG (GNUNET_ERROR_TYPE_WARNING, "Child exited with error code: %lu\n", | ||
77 | child_exit_code); | ||
78 | ret = 128 + (int) child_exit_code; | ||
79 | } | ||
80 | if (0 != fh) | ||
81 | { | ||
82 | close (fh); | ||
83 | } | ||
84 | if ((NULL != fn) && (0 != unlink (fn))) | ||
85 | { | ||
86 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "open"); | ||
87 | ret = GNUNET_SYSERR; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | |||
92 | static void | ||
93 | terminate_task (void *cls) | ||
94 | { | ||
95 | static int hard_kill; | ||
96 | |||
97 | GNUNET_assert (NULL != child); | ||
98 | terminate_task_id = | ||
99 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL); | ||
100 | if (0 != hard_kill) | ||
101 | { | ||
102 | switch (hard_kill) | ||
103 | { | ||
104 | case 1: | ||
105 | case 2: | ||
106 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
107 | "%d more interrupts needed to send SIGKILL to the child\n", | ||
108 | 3 - hard_kill); | ||
109 | hard_kill++; | ||
110 | return; | ||
111 | |||
112 | case 3: | ||
113 | GNUNET_break (0 == GNUNET_OS_process_kill (child, SIGKILL)); | ||
114 | return; | ||
115 | } | ||
116 | } | ||
117 | hard_kill++; | ||
118 | GNUNET_break (0 == GNUNET_OS_process_kill (child, GNUNET_TERM_SIG)); | ||
119 | LOG (GNUNET_ERROR_TYPE_INFO, _ ("Waiting for child to exit.\n")); | ||
120 | } | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Task triggered whenever we receive a SIGCHLD (child | ||
125 | * process died). | ||
126 | * | ||
127 | * @param cls closure, NULL if we need to self-restart | ||
128 | */ | ||
129 | static void | ||
130 | child_death_task (void *cls) | ||
131 | { | ||
132 | const struct GNUNET_DISK_FileHandle *pr; | ||
133 | char c[16]; | ||
134 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
135 | |||
136 | |||
137 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | ||
138 | child_death_task_id = NULL; | ||
139 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
140 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | ||
141 | { | ||
142 | child_death_task_id = | ||
143 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
144 | pr, &child_death_task, NULL); | ||
145 | return; | ||
146 | } | ||
147 | /* consume the signal */ | ||
148 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c))); | ||
149 | LOG_DEBUG ("Child died\n"); | ||
150 | GNUNET_SCHEDULER_cancel (terminate_task_id); | ||
151 | terminate_task_id = NULL; | ||
152 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_status (child, &child_status, | ||
153 | &child_exit_code)); | ||
154 | GNUNET_OS_process_destroy (child); | ||
155 | child = NULL; | ||
156 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
157 | } | ||
158 | |||
159 | |||
160 | static void | ||
161 | destroy_hosts (struct GNUNET_TESTBED_Host **hosts, unsigned int nhosts) | ||
162 | { | ||
163 | unsigned int host; | ||
164 | |||
165 | GNUNET_assert (NULL != hosts); | ||
166 | for (host = 0; host < nhosts; host++) | ||
167 | if (NULL != hosts[host]) | ||
168 | GNUNET_TESTBED_host_destroy (hosts[host]); | ||
169 | GNUNET_free (hosts); | ||
170 | hosts = NULL; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * The main scheduler run task | ||
176 | * | ||
177 | * @param cls NULL | ||
178 | */ | ||
179 | static void | ||
180 | run (void *cls) | ||
181 | { | ||
182 | struct GNUNET_TESTBED_Host **hosts; | ||
183 | const struct GNUNET_CONFIGURATION_Handle *null_cfg; | ||
184 | char *tmpdir; | ||
185 | char *hostname; | ||
186 | size_t hostname_len; | ||
187 | unsigned int nhosts; | ||
188 | |||
189 | null_cfg = GNUNET_CONFIGURATION_create (); | ||
190 | nhosts = GNUNET_TESTBED_hosts_load_from_loadleveler (null_cfg, &hosts); | ||
191 | if (0 == nhosts) | ||
192 | { | ||
193 | GNUNET_break (0); | ||
194 | ret = GNUNET_SYSERR; | ||
195 | return; | ||
196 | } | ||
197 | hostname_len = GNUNET_OS_get_hostname_max_length (); | ||
198 | hostname = GNUNET_malloc (hostname_len); | ||
199 | if (0 != gethostname (hostname, hostname_len)) | ||
200 | { | ||
201 | LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot get hostname. Exiting\n"); | ||
202 | GNUNET_free (hostname); | ||
203 | destroy_hosts (hosts, nhosts); | ||
204 | ret = GNUNET_SYSERR; | ||
205 | return; | ||
206 | } | ||
207 | if (NULL == strstr (GNUNET_TESTBED_host_get_hostname (hosts[0]), hostname)) | ||
208 | { | ||
209 | LOG_DEBUG ("Exiting as `%s' is not the lowest host\n", hostname); | ||
210 | GNUNET_free (hostname); | ||
211 | ret = GNUNET_OK; | ||
212 | return; | ||
213 | } | ||
214 | LOG_DEBUG ("Will be executing `%s' on host `%s'\n", argv2[0], hostname); | ||
215 | GNUNET_free (hostname); | ||
216 | destroy_hosts (hosts, nhosts); | ||
217 | tmpdir = getenv ("TMPDIR"); | ||
218 | if (NULL == tmpdir) | ||
219 | tmpdir = getenv ("TMP"); | ||
220 | if (NULL == tmpdir) | ||
221 | tmpdir = getenv ("TEMP"); | ||
222 | if (NULL == tmpdir) | ||
223 | tmpdir = "/tmp"; | ||
224 | (void) GNUNET_asprintf (&fn, "%s/gnunet-testbed-spawn.lock", tmpdir); | ||
225 | /* Open the unique file; we can create it then we can spawn the child process | ||
226 | else we exit */ | ||
227 | fh = open (fn, O_CREAT | O_EXCL | O_CLOEXEC, | ||
228 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); | ||
229 | if (-1 == fh) | ||
230 | { | ||
231 | if (EEXIST == errno) | ||
232 | { | ||
233 | LOG_DEBUG ("Lock file already created by other process. Exiting\n"); | ||
234 | ret = GNUNET_OK; | ||
235 | return; | ||
236 | } | ||
237 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "open"); | ||
238 | ret = GNUNET_SYSERR; | ||
239 | return; | ||
240 | } | ||
241 | /* Spawn the new process here */ | ||
242 | LOG (GNUNET_ERROR_TYPE_INFO, _ ("Spawning process `%s'\n"), argv2[0]); | ||
243 | child = GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, | ||
244 | NULL, | ||
245 | NULL, NULL, | ||
246 | argv2[0], argv2); | ||
247 | if (NULL == child) | ||
248 | { | ||
249 | GNUNET_break (0); | ||
250 | ret = GNUNET_SYSERR; | ||
251 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
252 | return; | ||
253 | } | ||
254 | ret = GNUNET_OK; | ||
255 | terminate_task_id = | ||
256 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL); | ||
257 | child_death_task_id = | ||
258 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
259 | GNUNET_DISK_pipe_handle (sigpipe, | ||
260 | GNUNET_DISK_PIPE_END_READ), | ||
261 | &child_death_task, NULL); | ||
262 | } | ||
263 | |||
264 | |||
265 | /** | ||
266 | * Signal handler called for SIGCHLD. | ||
267 | */ | ||
268 | static void | ||
269 | sighandler_child_death () | ||
270 | { | ||
271 | static char c; | ||
272 | int old_errno = errno; /* back-up errno */ | ||
273 | |||
274 | GNUNET_break (1 == | ||
275 | GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle | ||
276 | (sigpipe, GNUNET_DISK_PIPE_END_WRITE), | ||
277 | &c, sizeof(c))); | ||
278 | errno = old_errno; /* restore errno */ | ||
279 | } | ||
280 | |||
281 | |||
282 | /** | ||
283 | * Execution start point | ||
284 | */ | ||
285 | int | ||
286 | main (int argc, char *argv[]) | ||
287 | { | ||
288 | struct GNUNET_SIGNAL_Context *shc_chld; | ||
289 | unsigned int cnt; | ||
290 | |||
291 | ret = -1; | ||
292 | if (argc < 2) | ||
293 | { | ||
294 | printf ("Need arguments: gnunet-testbed-mpi-spawn <cmd> <cmd_args>"); | ||
295 | return 1; | ||
296 | } | ||
297 | if (GNUNET_OK != GNUNET_log_setup ("gnunet-testbed-spawn", NULL, NULL)) | ||
298 | { | ||
299 | GNUNET_break (0); | ||
300 | return 1; | ||
301 | } | ||
302 | if (NULL == (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE))) | ||
303 | { | ||
304 | GNUNET_break (0); | ||
305 | ret = GNUNET_SYSERR; | ||
306 | return 1; | ||
307 | } | ||
308 | shc_chld = | ||
309 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | ||
310 | if (NULL == shc_chld) | ||
311 | { | ||
312 | LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot install a signal handler\n"); | ||
313 | return 1; | ||
314 | } | ||
315 | argv2 = GNUNET_malloc (sizeof(char *) * argc); | ||
316 | for (cnt = 1; cnt < argc; cnt++) | ||
317 | argv2[cnt - 1] = argv[cnt]; | ||
318 | GNUNET_SCHEDULER_run (run, NULL); | ||
319 | GNUNET_free (argv2); | ||
320 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | ||
321 | shc_chld = NULL; | ||
322 | GNUNET_DISK_pipe_close (sigpipe); | ||
323 | GNUNET_free (fn); | ||
324 | if (GNUNET_OK != ret) | ||
325 | return ret; | ||
326 | return 0; | ||
327 | } | ||
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 1a8d9976d..8dd0a4893 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -568,41 +568,6 @@ simple_resolve (const char *host) | |||
568 | 568 | ||
569 | 569 | ||
570 | /** | 570 | /** |
571 | * Loads the set of host allocated by the LoadLeveler Job Scheduler. This | ||
572 | * function is only available when compiled with support for LoadLeveler and is | ||
573 | * used for running on the SuperMUC | ||
574 | * | ||
575 | * @param cfg the configuration to use as a template while starting a controller | ||
576 | * on any of the loaded hosts. Operation queue sizes specific to a host | ||
577 | * are also read from this configuration handle | ||
578 | * @param hosts set to the hosts found in the file; caller must free this if | ||
579 | * number of hosts returned is greater than 0 | ||
580 | * @return number of hosts returned in 'hosts', 0 on error | ||
581 | */ | ||
582 | unsigned int | ||
583 | GNUNET_TESTBED_hosts_load_from_loadleveler ( | ||
584 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
585 | struct GNUNET_TESTBED_Host ***hosts) | ||
586 | { | ||
587 | #if ! ENABLE_SUPERMUC | ||
588 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
589 | _ ("The function %s is only available when compiled with (--with-ll)\n"), | ||
590 | __func__); | ||
591 | GNUNET_assert (0); | ||
592 | #else | ||
593 | const char *hostfile; | ||
594 | |||
595 | if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE"))) | ||
596 | { | ||
597 | GNUNET_break (0); | ||
598 | return 0; | ||
599 | } | ||
600 | return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts); | ||
601 | #endif | ||
602 | } | ||
603 | |||
604 | |||
605 | /** | ||
606 | * Destroy a host handle. Must only be called once everything | 571 | * Destroy a host handle. Must only be called once everything |
607 | * running on that host has been stopped. | 572 | * running on that host has been stopped. |
608 | * | 573 | * |
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index e9b9979ce..e0b76ad78 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -1265,16 +1265,6 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1265 | GNUNET_assert (num_peers > 0); | 1265 | GNUNET_assert (num_peers > 0); |
1266 | rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle); | 1266 | rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle); |
1267 | rc->cfg = GNUNET_CONFIGURATION_dup (cfg); | 1267 | rc->cfg = GNUNET_CONFIGURATION_dup (cfg); |
1268 | #if ENABLE_SUPERMUC | ||
1269 | rc->num_hosts = GNUNET_TESTBED_hosts_load_from_loadleveler (rc->cfg, | ||
1270 | &rc->hosts); | ||
1271 | if (0 == rc->num_hosts) | ||
1272 | { | ||
1273 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1274 | _ ("No hosts loaded from LoadLeveler. Need at least one host\n")); | ||
1275 | goto error_cleanup; | ||
1276 | } | ||
1277 | #else | ||
1278 | if (NULL != host_filename) | 1268 | if (NULL != host_filename) |
1279 | { | 1269 | { |
1280 | rc->num_hosts = | 1270 | rc->num_hosts = |
@@ -1289,7 +1279,6 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1289 | } | 1279 | } |
1290 | else | 1280 | else |
1291 | rc->h = GNUNET_TESTBED_host_create (NULL, NULL, rc->cfg, 0); | 1281 | rc->h = GNUNET_TESTBED_host_create (NULL, NULL, rc->cfg, 0); |
1292 | #endif | ||
1293 | rc->num_peers = num_peers; | 1282 | rc->num_peers = num_peers; |
1294 | rc->event_mask = event_mask; | 1283 | rc->event_mask = event_mask; |
1295 | rc->cc = cc; | 1284 | rc->cc = cc; |
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 07caeb44e..3daa29e1e 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -42,20 +42,19 @@ libgnunet_test_testing_plugin_testcmd_la_LIBADD = \ | |||
42 | libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \ | 42 | libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \ |
43 | $(GN_PLUGIN_LDFLAGS) | 43 | $(GN_PLUGIN_LDFLAGS) |
44 | 44 | ||
45 | |||
45 | libgnunettesting_la_SOURCES = \ | 46 | libgnunettesting_la_SOURCES = \ |
47 | testing_api_cmd_end.c \ | ||
48 | testing_api_cmd_finish.c \ | ||
46 | testing_api_cmd_local_test_finished.c \ | 49 | testing_api_cmd_local_test_finished.c \ |
47 | testing_api_cmd_local_test_prepared.c \ | 50 | testing_api_cmd_local_test_prepared.c \ |
48 | testing_api_cmd_send_peer_ready.c \ | 51 | testing_api_cmd_send_peer_ready.c \ |
49 | testing_api_cmd_block_until_all_peers_started.c \ | 52 | testing_api_cmd_block_until_all_peers_started.c \ |
50 | testing_api_cmd_block_until_external_trigger.c \ | 53 | testing_api_cmd_block_until_external_trigger.c \ |
51 | testing_api_cmd_netjail_start.c \ | 54 | testing_api_cmd_netjail_start.c \ |
52 | testing_api_cmd_netjail_start_v2.c \ | ||
53 | testing_api_cmd_netjail_start_testsystem.c \ | 55 | testing_api_cmd_netjail_start_testsystem.c \ |
54 | testing_api_cmd_netjail_start_testsystem_v2.c \ | ||
55 | testing_api_cmd_netjail_stop_testsystem.c \ | 56 | testing_api_cmd_netjail_stop_testsystem.c \ |
56 | testing_api_cmd_netjail_stop_testsystem_v2.c \ | ||
57 | testing_api_cmd_netjail_stop.c \ | 57 | testing_api_cmd_netjail_stop.c \ |
58 | testing_api_cmd_netjail_stop_v2.c \ | ||
59 | testing.c testing.h \ | 58 | testing.c testing.h \ |
60 | testing_api_cmd_system_create.c \ | 59 | testing_api_cmd_system_create.c \ |
61 | testing_api_cmd_system_destroy.c \ | 60 | testing_api_cmd_system_destroy.c \ |
@@ -95,7 +94,6 @@ list_keys_LDADD = \ | |||
95 | 94 | ||
96 | 95 | ||
97 | check_PROGRAMS = \ | 96 | check_PROGRAMS = \ |
98 | test_testing_topology \ | ||
99 | test_testing_api_cmd_netjail \ | 97 | test_testing_api_cmd_netjail \ |
100 | test_testing_hello_world \ | 98 | test_testing_hello_world \ |
101 | test_testing_portreservation \ | 99 | test_testing_portreservation \ |
@@ -107,7 +105,6 @@ check_PROGRAMS = \ | |||
107 | if ENABLE_TEST_RUN | 105 | if ENABLE_TEST_RUN |
108 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 106 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
109 | TESTS = \ | 107 | TESTS = \ |
110 | test_testing_topology \ | ||
111 | test_testing_api_cmd_netjail \ | 108 | test_testing_api_cmd_netjail \ |
112 | test_testing_hello_world \ | 109 | test_testing_hello_world \ |
113 | test_testing_portreservation \ | 110 | test_testing_portreservation \ |
@@ -116,11 +113,11 @@ TESTS = \ | |||
116 | test_testing_servicestartup | 113 | test_testing_servicestartup |
117 | endif | 114 | endif |
118 | 115 | ||
119 | test_testing_topology_SOURCES = \ | 116 | #test_testing_topology_SOURCES = \ |
120 | test_testing_topology.c | 117 | # test_testing_topology.c |
121 | test_testing_topology_LDADD = \ | 118 | #test_testing_topology_LDADD = \ |
122 | libgnunettesting.la \ | 119 | # libgnunettesting.la \ |
123 | $(top_builddir)/src/util/libgnunetutil.la | 120 | # $(top_builddir)/src/util/libgnunetutil.la |
124 | 121 | ||
125 | test_testing_api_cmd_netjail_SOURCES = \ | 122 | test_testing_api_cmd_netjail_SOURCES = \ |
126 | test_testing_api_cmd_netjail.c | 123 | test_testing_api_cmd_netjail.c |
diff --git a/src/testing/netjail_core.sh b/src/testing/netjail_core.sh index cf350d3fa..ef0a54a5e 100755 --- a/src/testing/netjail_core.sh +++ b/src/testing/netjail_core.sh | |||
@@ -2,6 +2,7 @@ | |||
2 | # | 2 | # |
3 | 3 | ||
4 | 4 | ||
5 | PREFIX=${PPID:?must run from a parent process} | ||
5 | 6 | ||
6 | # running with `sudo` is required to be | 7 | # running with `sudo` is required to be |
7 | # able running the actual commands as the | 8 | # able running the actual commands as the |
@@ -9,10 +10,61 @@ | |||
9 | 10 | ||
10 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | 11 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
11 | 12 | ||
12 | netjail_check() { | 13 | export RESULT= |
13 | NODE_COUNT=$1 | 14 | export NAMESPACE_NUM=0 |
15 | export INTERFACE_NUM=0 | ||
16 | |||
17 | netjail_next_namespace() { | ||
18 | local NUM=$NAMESPACE_NUM | ||
19 | NAMESPACE_NUM=$(($NAMESPACE_NUM + 1)) | ||
20 | RESULT=$NUM | ||
21 | } | ||
22 | |||
23 | netjail_next_interface() { | ||
24 | local NUM=$INTERFACE_NUM | ||
25 | INTERFACE_NUM=$(($INTERFACE_NUM + 1)) | ||
26 | RESULT=$NUM | ||
27 | } | ||
28 | |||
29 | netjail_opt() { | ||
30 | local OPT=$1 | ||
31 | shift 1 | ||
32 | |||
33 | INDEX=1 | ||
34 | |||
35 | while [ $# -gt 0 ]; do | ||
36 | if [ "$1" = "$OPT" ]; then | ||
37 | RESULT=$INDEX | ||
38 | return | ||
39 | fi | ||
40 | |||
41 | INDEX=$(($INDEX + 1)) | ||
42 | shift 1 | ||
43 | done | ||
44 | |||
45 | RESULT=0 | ||
46 | } | ||
47 | |||
48 | netjail_opts() { | ||
49 | local OPT=$1 | ||
50 | local DEF=$2 | ||
51 | shift 2 | ||
52 | |||
53 | while [ $# -gt 0 ]; do | ||
54 | if [ "$1" = "$OPT" ]; then | ||
55 | printf "$2" | ||
56 | return | ||
57 | fi | ||
58 | |||
59 | shift 1 | ||
60 | done | ||
61 | |||
62 | RESULT="$DEF" | ||
63 | } | ||
14 | 64 | ||
15 | FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4)) | 65 | netjail_check() { |
66 | local NODE_COUNT=$1 | ||
67 | local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4)) | ||
16 | 68 | ||
17 | # quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`: | 69 | # quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`: |
18 | # the script also requires `sudo -C ($FD_COUNT + 4)` | 70 | # the script also requires `sudo -C ($FD_COUNT + 4)` |
@@ -25,43 +77,81 @@ netjail_check() { | |||
25 | fi | 77 | fi |
26 | } | 78 | } |
27 | 79 | ||
28 | netjail_print_name() { | 80 | netjail_check_bin() { |
29 | printf "%s%02x%02x" $1 $2 ${3:-0} | 81 | local PROGRAM=$1 |
82 | local MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }') | ||
83 | |||
84 | # quit if the required binary $PROGRAM can not be | ||
85 | # found in the used $PATH. | ||
86 | |||
87 | if [ "$MATCH" != "$PROGRAM" ]; then | ||
88 | echo "Required binary not found: $PROGRAM" >&2 | ||
89 | exit 1 | ||
90 | fi | ||
30 | } | 91 | } |
31 | 92 | ||
32 | netjail_bridge() { | 93 | netjail_bridge() { |
33 | BRIDGE=$1 | 94 | netjail_next_interface |
95 | local NUM=$RESULT | ||
96 | local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
34 | 97 | ||
35 | ip link add $BRIDGE type bridge | 98 | ip link add $BRIDGE type bridge |
36 | ip link set dev $BRIDGE up | 99 | ip link set dev $BRIDGE up |
100 | |||
101 | RESULT=$BRIDGE | ||
102 | } | ||
103 | |||
104 | netjail_bridge_name() { | ||
105 | netjail_next_interface | ||
106 | local NUM=$RESULT | ||
107 | local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
108 | |||
109 | RESULT=$BRIDGE | ||
37 | } | 110 | } |
38 | 111 | ||
39 | netjail_bridge_clear() { | 112 | netjail_bridge_clear() { |
40 | BRIDGE=$1 | 113 | local BRIDGE=$1 |
41 | 114 | ||
42 | ip link delete $BRIDGE | 115 | ip link delete $BRIDGE |
43 | } | 116 | } |
44 | 117 | ||
45 | netjail_node() { | 118 | netjail_node() { |
46 | NODE=$1 | 119 | netjail_next_namespace |
120 | local NUM=$RESULT | ||
121 | local NODE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
47 | 122 | ||
48 | ip netns add $NODE | 123 | ip netns add $NODE |
124 | |||
125 | RESULT=$NODE | ||
126 | } | ||
127 | |||
128 | netjail_node_name() { | ||
129 | netjail_next_namespace | ||
130 | local NUM=$RESULT | ||
131 | local NODE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
132 | |||
133 | RESULT=$NODE | ||
49 | } | 134 | } |
50 | 135 | ||
51 | netjail_node_clear() { | 136 | netjail_node_clear() { |
52 | NODE=$1 | 137 | local NODE=$1 |
53 | 138 | ||
54 | ip netns delete $NODE | 139 | ip netns delete $NODE |
55 | } | 140 | } |
56 | 141 | ||
57 | netjail_node_link_bridge() { | 142 | netjail_node_link_bridge() { |
58 | NODE=$1 | 143 | local NODE=$1 |
59 | BRIDGE=$2 | 144 | local BRIDGE=$2 |
60 | ADDRESS=$3 | 145 | local ADDRESS=$3 |
61 | MASK=$4 | 146 | local MASK=$4 |
62 | 147 | ||
63 | LINK_IF="$NODE-$BRIDGE-0" | 148 | netjail_next_interface |
64 | LINK_BR="$NODE-$BRIDGE-1" | 149 | local NUM_IF=$RESULT |
150 | netjail_next_interface | ||
151 | local NUM_BR=$RESULT | ||
152 | |||
153 | local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF) | ||
154 | local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) | ||
65 | 155 | ||
66 | ip link add $LINK_IF type veth peer name $LINK_BR | 156 | ip link add $LINK_IF type veth peer name $LINK_BR |
67 | ip link set $LINK_IF netns $NODE | 157 | ip link set $LINK_IF netns $NODE |
@@ -72,28 +162,47 @@ netjail_node_link_bridge() { | |||
72 | ip -n $NODE link set up dev lo | 162 | ip -n $NODE link set up dev lo |
73 | 163 | ||
74 | ip link set $LINK_BR up | 164 | ip link set $LINK_BR up |
165 | |||
166 | RESULT=$LINK_BR | ||
167 | } | ||
168 | |||
169 | netjail_node_link_bridge_name() { | ||
170 | |||
171 | netjail_next_interface | ||
172 | netjail_next_interface | ||
173 | local NUM_BR=$RESULT | ||
174 | |||
175 | local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) | ||
176 | |||
177 | RESULT=$LINK_BR | ||
178 | } | ||
179 | |||
180 | netjail_node_unlink_bridge() { | ||
181 | local LINK_BR=$1 | ||
182 | |||
183 | ip link delete $LINK_BR | ||
75 | } | 184 | } |
76 | 185 | ||
77 | netjail_node_add_nat() { | 186 | netjail_node_add_nat() { |
78 | NODE=$1 | 187 | local NODE=$1 |
79 | ADDRESS=$2 | 188 | local ADDRESS=$2 |
80 | MASK=$3 | 189 | local MASK=$3 |
81 | 190 | ||
82 | ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE | 191 | ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE |
83 | } | 192 | } |
84 | 193 | ||
85 | netjail_node_add_default() { | 194 | netjail_node_add_default() { |
86 | NODE=$1 | 195 | local NODE=$1 |
87 | ADDRESS=$2 | 196 | local ADDRESS=$2 |
88 | 197 | ||
89 | ip -n $NODE route add default via $ADDRESS | 198 | ip -n $NODE route add default via $ADDRESS |
90 | } | 199 | } |
91 | 200 | ||
92 | netjail_node_exec() { | 201 | netjail_node_exec() { |
93 | JAILOR=${SUDO_USER:?must run in sudo} | 202 | JAILOR=${SUDO_USER:?must run in sudo} |
94 | NODE=$1 | 203 | local NODE=$1 |
95 | FD_IN=$2 | 204 | local FD_IN=$2 |
96 | FD_OUT=$3 | 205 | local FD_OUT=$3 |
97 | shift 3 | 206 | shift 3 |
98 | 207 | ||
99 | ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN | 208 | ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN |
@@ -114,3 +223,38 @@ netjail_node_exec_without_fds_and_sudo() { | |||
114 | ip netns exec $NODE $@ | 223 | ip netns exec $NODE $@ |
115 | } | 224 | } |
116 | 225 | ||
226 | netjail_kill() { | ||
227 | local PID=$1 | ||
228 | local MATCH=$(ps --pid $PID | awk "{ if ( \$1 == $PID ) { print \$1 } }" | wc -l) | ||
229 | |||
230 | if [ $MATCH -gt 0 ]; then | ||
231 | kill -n 19 $PID | ||
232 | |||
233 | for CHILD in $(ps -o pid,ppid -ax | awk "{ if ( \$2 == $PID ) { print \$1 } }"); do | ||
234 | netjail_kill $CHILD | ||
235 | done | ||
236 | |||
237 | kill $PID | ||
238 | fi | ||
239 | } | ||
240 | |||
241 | netjail_killall() { | ||
242 | if [ $# -gt 0 ]; then | ||
243 | local PIDS=$1 | ||
244 | |||
245 | for PID in $PIDS; do | ||
246 | netjail_kill $PID | ||
247 | done | ||
248 | fi | ||
249 | } | ||
250 | |||
251 | netjail_waitall() { | ||
252 | if [ $# -gt 0 ]; then | ||
253 | local PIDS=$1 | ||
254 | |||
255 | for PID in $PIDS; do | ||
256 | wait $PID | ||
257 | done | ||
258 | fi | ||
259 | } | ||
260 | |||
diff --git a/src/testing/netjail_core_v2.sh b/src/testing/netjail_core_v2.sh deleted file mode 100755 index ef0a54a5e..000000000 --- a/src/testing/netjail_core_v2.sh +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | |||
4 | |||
5 | PREFIX=${PPID:?must run from a parent process} | ||
6 | |||
7 | # running with `sudo` is required to be | ||
8 | # able running the actual commands as the | ||
9 | # original user. | ||
10 | |||
11 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
12 | |||
13 | export RESULT= | ||
14 | export NAMESPACE_NUM=0 | ||
15 | export INTERFACE_NUM=0 | ||
16 | |||
17 | netjail_next_namespace() { | ||
18 | local NUM=$NAMESPACE_NUM | ||
19 | NAMESPACE_NUM=$(($NAMESPACE_NUM + 1)) | ||
20 | RESULT=$NUM | ||
21 | } | ||
22 | |||
23 | netjail_next_interface() { | ||
24 | local NUM=$INTERFACE_NUM | ||
25 | INTERFACE_NUM=$(($INTERFACE_NUM + 1)) | ||
26 | RESULT=$NUM | ||
27 | } | ||
28 | |||
29 | netjail_opt() { | ||
30 | local OPT=$1 | ||
31 | shift 1 | ||
32 | |||
33 | INDEX=1 | ||
34 | |||
35 | while [ $# -gt 0 ]; do | ||
36 | if [ "$1" = "$OPT" ]; then | ||
37 | RESULT=$INDEX | ||
38 | return | ||
39 | fi | ||
40 | |||
41 | INDEX=$(($INDEX + 1)) | ||
42 | shift 1 | ||
43 | done | ||
44 | |||
45 | RESULT=0 | ||
46 | } | ||
47 | |||
48 | netjail_opts() { | ||
49 | local OPT=$1 | ||
50 | local DEF=$2 | ||
51 | shift 2 | ||
52 | |||
53 | while [ $# -gt 0 ]; do | ||
54 | if [ "$1" = "$OPT" ]; then | ||
55 | printf "$2" | ||
56 | return | ||
57 | fi | ||
58 | |||
59 | shift 1 | ||
60 | done | ||
61 | |||
62 | RESULT="$DEF" | ||
63 | } | ||
64 | |||
65 | netjail_check() { | ||
66 | local NODE_COUNT=$1 | ||
67 | local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4)) | ||
68 | |||
69 | # quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`: | ||
70 | # the script also requires `sudo -C ($FD_COUNT + 4)` | ||
71 | # so you need 'Defaults closefrom_override' in the | ||
72 | # sudoers file. | ||
73 | |||
74 | if [ $FD_COUNT -lt $(($NODE_COUNT * 2)) ]; then | ||
75 | echo "File descriptors do not match requirements!" >&2 | ||
76 | exit 1 | ||
77 | fi | ||
78 | } | ||
79 | |||
80 | netjail_check_bin() { | ||
81 | local PROGRAM=$1 | ||
82 | local MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }') | ||
83 | |||
84 | # quit if the required binary $PROGRAM can not be | ||
85 | # found in the used $PATH. | ||
86 | |||
87 | if [ "$MATCH" != "$PROGRAM" ]; then | ||
88 | echo "Required binary not found: $PROGRAM" >&2 | ||
89 | exit 1 | ||
90 | fi | ||
91 | } | ||
92 | |||
93 | netjail_bridge() { | ||
94 | netjail_next_interface | ||
95 | local NUM=$RESULT | ||
96 | local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
97 | |||
98 | ip link add $BRIDGE type bridge | ||
99 | ip link set dev $BRIDGE up | ||
100 | |||
101 | RESULT=$BRIDGE | ||
102 | } | ||
103 | |||
104 | netjail_bridge_name() { | ||
105 | netjail_next_interface | ||
106 | local NUM=$RESULT | ||
107 | local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
108 | |||
109 | RESULT=$BRIDGE | ||
110 | } | ||
111 | |||
112 | netjail_bridge_clear() { | ||
113 | local BRIDGE=$1 | ||
114 | |||
115 | ip link delete $BRIDGE | ||
116 | } | ||
117 | |||
118 | netjail_node() { | ||
119 | netjail_next_namespace | ||
120 | local NUM=$RESULT | ||
121 | local NODE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
122 | |||
123 | ip netns add $NODE | ||
124 | |||
125 | RESULT=$NODE | ||
126 | } | ||
127 | |||
128 | netjail_node_name() { | ||
129 | netjail_next_namespace | ||
130 | local NUM=$RESULT | ||
131 | local NODE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
132 | |||
133 | RESULT=$NODE | ||
134 | } | ||
135 | |||
136 | netjail_node_clear() { | ||
137 | local NODE=$1 | ||
138 | |||
139 | ip netns delete $NODE | ||
140 | } | ||
141 | |||
142 | netjail_node_link_bridge() { | ||
143 | local NODE=$1 | ||
144 | local BRIDGE=$2 | ||
145 | local ADDRESS=$3 | ||
146 | local MASK=$4 | ||
147 | |||
148 | netjail_next_interface | ||
149 | local NUM_IF=$RESULT | ||
150 | netjail_next_interface | ||
151 | local NUM_BR=$RESULT | ||
152 | |||
153 | local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF) | ||
154 | local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) | ||
155 | |||
156 | ip link add $LINK_IF type veth peer name $LINK_BR | ||
157 | ip link set $LINK_IF netns $NODE | ||
158 | ip link set $LINK_BR master $BRIDGE | ||
159 | |||
160 | ip -n $NODE addr add "$ADDRESS/$MASK" dev $LINK_IF | ||
161 | ip -n $NODE link set $LINK_IF up | ||
162 | ip -n $NODE link set up dev lo | ||
163 | |||
164 | ip link set $LINK_BR up | ||
165 | |||
166 | RESULT=$LINK_BR | ||
167 | } | ||
168 | |||
169 | netjail_node_link_bridge_name() { | ||
170 | |||
171 | netjail_next_interface | ||
172 | netjail_next_interface | ||
173 | local NUM_BR=$RESULT | ||
174 | |||
175 | local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) | ||
176 | |||
177 | RESULT=$LINK_BR | ||
178 | } | ||
179 | |||
180 | netjail_node_unlink_bridge() { | ||
181 | local LINK_BR=$1 | ||
182 | |||
183 | ip link delete $LINK_BR | ||
184 | } | ||
185 | |||
186 | netjail_node_add_nat() { | ||
187 | local NODE=$1 | ||
188 | local ADDRESS=$2 | ||
189 | local MASK=$3 | ||
190 | |||
191 | ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE | ||
192 | } | ||
193 | |||
194 | netjail_node_add_default() { | ||
195 | local NODE=$1 | ||
196 | local ADDRESS=$2 | ||
197 | |||
198 | ip -n $NODE route add default via $ADDRESS | ||
199 | } | ||
200 | |||
201 | netjail_node_exec() { | ||
202 | JAILOR=${SUDO_USER:?must run in sudo} | ||
203 | local NODE=$1 | ||
204 | local FD_IN=$2 | ||
205 | local FD_OUT=$3 | ||
206 | shift 3 | ||
207 | |||
208 | ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN | ||
209 | } | ||
210 | |||
211 | netjail_node_exec_without_fds() { | ||
212 | JAILOR=${SUDO_USER:?must run in sudo} | ||
213 | NODE=$1 | ||
214 | shift 1 | ||
215 | |||
216 | ip netns exec $NODE sudo -u $JAILOR -- $@ | ||
217 | } | ||
218 | |||
219 | netjail_node_exec_without_fds_and_sudo() { | ||
220 | NODE=$1 | ||
221 | shift 1 | ||
222 | |||
223 | ip netns exec $NODE $@ | ||
224 | } | ||
225 | |||
226 | netjail_kill() { | ||
227 | local PID=$1 | ||
228 | local MATCH=$(ps --pid $PID | awk "{ if ( \$1 == $PID ) { print \$1 } }" | wc -l) | ||
229 | |||
230 | if [ $MATCH -gt 0 ]; then | ||
231 | kill -n 19 $PID | ||
232 | |||
233 | for CHILD in $(ps -o pid,ppid -ax | awk "{ if ( \$2 == $PID ) { print \$1 } }"); do | ||
234 | netjail_kill $CHILD | ||
235 | done | ||
236 | |||
237 | kill $PID | ||
238 | fi | ||
239 | } | ||
240 | |||
241 | netjail_killall() { | ||
242 | if [ $# -gt 0 ]; then | ||
243 | local PIDS=$1 | ||
244 | |||
245 | for PID in $PIDS; do | ||
246 | netjail_kill $PID | ||
247 | done | ||
248 | fi | ||
249 | } | ||
250 | |||
251 | netjail_waitall() { | ||
252 | if [ $# -gt 0 ]; then | ||
253 | local PIDS=$1 | ||
254 | |||
255 | for PID in $PIDS; do | ||
256 | wait $PID | ||
257 | done | ||
258 | fi | ||
259 | } | ||
260 | |||
diff --git a/src/testing/netjail_exec.sh b/src/testing/netjail_exec.sh index 17a7caaac..cd993a39b 100755 --- a/src/testing/netjail_exec.sh +++ b/src/testing/netjail_exec.sh | |||
@@ -9,8 +9,6 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |||
9 | M=$1 | 9 | M=$1 |
10 | N=$2 | 10 | N=$2 |
11 | 11 | ||
12 | NODE=$(netjail_print_name "N" $N $M) | 12 | NODE=$6 |
13 | 13 | ||
14 | 14 | netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 | |
15 | |||
16 | netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 | ||
diff --git a/src/testing/netjail_exec_v2.sh b/src/testing/netjail_exec_v2.sh deleted file mode 100755 index 597baad20..000000000 --- a/src/testing/netjail_exec_v2.sh +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | . "./../testing/netjail_core_v2.sh" | ||
3 | |||
4 | set -eu | ||
5 | set -x | ||
6 | |||
7 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
8 | |||
9 | M=$1 | ||
10 | N=$2 | ||
11 | |||
12 | NODE=$6 | ||
13 | |||
14 | netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 | ||
diff --git a/src/testing/netjail_start.sh b/src/testing/netjail_start.sh index 0984a3c42..1dfe1dfdf 100755 --- a/src/testing/netjail_start.sh +++ b/src/testing/netjail_start.sh | |||
@@ -1,52 +1,74 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | . "./../testing/netjail_core.sh" | 2 | . "./../testing/netjail_core.sh" |
3 | . "./../testing/topo.sh" | ||
3 | 4 | ||
4 | set -eu | 5 | set -eu |
5 | set -x | 6 | set -x |
6 | 7 | ||
7 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | 8 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
8 | 9 | ||
9 | LOCAL_M=$1 | 10 | filename=$1 |
10 | GLOBAL_N=$2 | 11 | PREFIX=$2 |
11 | 12 | ||
12 | # TODO: stunserver? ..and globally known peer? | 13 | read_topology $filename |
13 | 14 | ||
14 | shift 2 | 15 | shift 2 |
15 | 16 | ||
16 | LOCAL_GROUP="192.168.15" | 17 | LOCAL_GROUP="192.168.15" |
17 | GLOBAL_GROUP="92.68.150" | 18 | GLOBAL_GROUP="92.68.150" |
19 | KNOWN_GROUP="92.68.151" | ||
18 | 20 | ||
19 | NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M) | ||
20 | 21 | ||
21 | netjail_bridge $NETWORK_NET | 22 | echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16]" |
22 | 23 | ||
23 | for N in $(seq $GLOBAL_N); do | 24 | netjail_bridge |
24 | ROUTER=$(netjail_print_name "R" $N) | 25 | NETWORK_NET=$RESULT |
25 | 26 | ||
26 | netjail_node $ROUTER | 27 | for X in $(seq $KNOWN); do |
27 | netjail_node_link_bridge $ROUTER $NETWORK_NET "$GLOBAL_GROUP.$N" 24 | 28 | netjail_node |
29 | KNOWN_NODES[$X]=$RESULT | ||
30 | netjail_node_link_bridge ${KNOWN_NODES[$X]} $NETWORK_NET "$KNOWN_GROUP.$X" 16 | ||
31 | KNOWN_LINKS[$X]=$RESULT | ||
32 | done | ||
28 | 33 | ||
29 | ROUTER_NET=$(netjail_print_name "r" $N) | 34 | declare -A NODES |
35 | declare -A NODE_LINKS | ||
30 | 36 | ||
31 | netjail_bridge $ROUTER_NET | 37 | for N in $(seq $GLOBAL_N); do |
38 | netjail_node | ||
39 | ROUTERS[$N]=$RESULT | ||
40 | netjail_node_link_bridge ${ROUTERS[$N]} $NETWORK_NET "$GLOBAL_GROUP.$N" 16 | ||
41 | NETWORK_LINKS[$N]=$RESULT | ||
42 | netjail_bridge | ||
43 | ROUTER_NETS[$N]=$RESULT | ||
32 | 44 | ||
33 | for M in $(seq $LOCAL_M); do | 45 | for M in $(seq $LOCAL_M); do |
34 | NODE=$(netjail_print_name "N" $N $M) | 46 | netjail_node |
35 | 47 | NODES[$N,$M]=$RESULT | |
36 | netjail_node $NODE | 48 | netjail_node_link_bridge ${NODES[$N,$M]} ${ROUTER_NETS[$N]} "$LOCAL_GROUP.$M" 24 |
37 | netjail_node_link_bridge $NODE $ROUTER_NET "$LOCAL_GROUP.$M" 24 | 49 | NODE_LINKS[$N,$M]=$RESULT |
38 | done | 50 | done |
39 | 51 | ||
40 | ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))" | 52 | ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))" |
41 | 53 | netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR 24 | |
42 | netjail_node_link_bridge $ROUTER $ROUTER_NET $ROUTER_ADDR 24 | 54 | ROUTER_LINKS[$N]=$RESULT |
43 | netjail_node_add_nat $ROUTER $ROUTER_ADDR 24 | 55 | |
56 | netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24 | ||
44 | 57 | ||
45 | for M in $(seq $LOCAL_M); do | 58 | for M in $(seq $LOCAL_M); do |
46 | NODE=$(netjail_print_name "N" $N $M) | 59 | netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR |
47 | |||
48 | netjail_node_add_default $NODE $ROUTER_ADDR | ||
49 | done | 60 | done |
50 | done | ||
51 | |||
52 | 61 | ||
62 | # TODO Topology configuration must be enhanced to configure forwarding to more than one subnet node via different ports. | ||
63 | |||
64 | if [ "1" == "${R_TCP[$N]}" ] | ||
65 | then | ||
66 | ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p tcp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1 | ||
67 | ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
68 | fi | ||
69 | if [ "1" == "${R_UDP[$N]}" ] | ||
70 | then | ||
71 | ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p udp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1 | ||
72 | ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
73 | fi | ||
74 | done | ||
diff --git a/src/testing/netjail_start_v2.sh b/src/testing/netjail_start_v2.sh deleted file mode 100755 index 81196d53d..000000000 --- a/src/testing/netjail_start_v2.sh +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | . "./../testing/netjail_core_v2.sh" | ||
3 | . "./../testing/topo.sh" | ||
4 | |||
5 | set -eu | ||
6 | set -x | ||
7 | |||
8 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
9 | |||
10 | filename=$1 | ||
11 | PREFIX=$2 | ||
12 | |||
13 | read_topology $filename | ||
14 | |||
15 | shift 2 | ||
16 | |||
17 | LOCAL_GROUP="192.168.15" | ||
18 | GLOBAL_GROUP="92.68.150" | ||
19 | KNOWN_GROUP="92.68.151" | ||
20 | |||
21 | |||
22 | echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16]" | ||
23 | |||
24 | netjail_bridge | ||
25 | NETWORK_NET=$RESULT | ||
26 | |||
27 | for X in $(seq $KNOWN); do | ||
28 | netjail_node | ||
29 | KNOWN_NODES[$X]=$RESULT | ||
30 | netjail_node_link_bridge ${KNOWN_NODES[$X]} $NETWORK_NET "$KNOWN_GROUP.$X" 16 | ||
31 | KNOWN_LINKS[$X]=$RESULT | ||
32 | done | ||
33 | |||
34 | declare -A NODES | ||
35 | declare -A NODE_LINKS | ||
36 | |||
37 | for N in $(seq $GLOBAL_N); do | ||
38 | netjail_node | ||
39 | ROUTERS[$N]=$RESULT | ||
40 | netjail_node_link_bridge ${ROUTERS[$N]} $NETWORK_NET "$GLOBAL_GROUP.$N" 16 | ||
41 | NETWORK_LINKS[$N]=$RESULT | ||
42 | netjail_bridge | ||
43 | ROUTER_NETS[$N]=$RESULT | ||
44 | |||
45 | for M in $(seq $LOCAL_M); do | ||
46 | netjail_node | ||
47 | NODES[$N,$M]=$RESULT | ||
48 | netjail_node_link_bridge ${NODES[$N,$M]} ${ROUTER_NETS[$N]} "$LOCAL_GROUP.$M" 24 | ||
49 | NODE_LINKS[$N,$M]=$RESULT | ||
50 | done | ||
51 | |||
52 | ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))" | ||
53 | netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR 24 | ||
54 | ROUTER_LINKS[$N]=$RESULT | ||
55 | |||
56 | netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24 | ||
57 | |||
58 | for M in $(seq $LOCAL_M); do | ||
59 | netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR | ||
60 | done | ||
61 | |||
62 | # TODO Topology configuration must be enhanced to configure forwarding to more than one subnet node via different ports. | ||
63 | |||
64 | if [ -z "${R_TCP[$N]}" -a "1" == "${R_TCP[$N]}" ] | ||
65 | then | ||
66 | ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p tcp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1 | ||
67 | ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
68 | fi | ||
69 | if [ -z "${R_UDP[$N]}" -a "1" == "${R_UDP[$N]}" ] | ||
70 | then | ||
71 | ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p udp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1 | ||
72 | ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT | ||
73 | fi | ||
74 | done | ||
diff --git a/src/testing/netjail_stop.sh b/src/testing/netjail_stop.sh index 08f68cf7f..abfaf3acf 100755 --- a/src/testing/netjail_stop.sh +++ b/src/testing/netjail_stop.sh | |||
@@ -1,24 +1,57 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | . "./../testing/netjail_core.sh" | 2 | . "./../testing/netjail_core.sh" |
3 | . "./../testing/topo.sh" | ||
3 | 4 | ||
4 | set -eu | 5 | set -eu |
5 | set -x | 6 | set -x |
6 | 7 | ||
7 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | 8 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
8 | 9 | ||
9 | LOCAL_M=$1 | 10 | filename=$1 |
10 | GLOBAL_N=$2 | 11 | PREFIX=$2 |
11 | NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M) | ||
12 | 12 | ||
13 | shift 2 | 13 | read_topology $filename |
14 | |||
15 | declare -A NODES | ||
16 | declare -A NODE_LINKS | ||
17 | |||
18 | netjail_bridge_name | ||
19 | NETWORK_NET=$RESULT | ||
20 | |||
21 | for X in $(seq $KNOWN); do | ||
22 | netjail_node_name | ||
23 | KNOWN_NODES[$X]=$RESULT | ||
24 | netjail_node_link_bridge_name | ||
25 | KNOWN_LINKS[$X]=$RESULT | ||
26 | netjail_node_unlink_bridge ${KNOWN_LINKS[$X]} | ||
27 | netjail_node_clear ${KNOWN_NODES[$X]} | ||
28 | done | ||
14 | 29 | ||
15 | for N in $(seq $GLOBAL_N); do | 30 | for N in $(seq $GLOBAL_N); do |
31 | netjail_node_name | ||
32 | ROUTERS[$N]=$RESULT | ||
33 | netjail_node_link_bridge_name | ||
34 | NETWORK_LINKS[$N]=$RESULT | ||
35 | netjail_bridge_name | ||
36 | ROUTER_NETS[$N]=$RESULT | ||
37 | netjail_node_link_bridge_name | ||
38 | ROUTER_LINKS[$N]=$RESULT | ||
39 | |||
40 | netjail_node_unlink_bridge ${ROUTER_LINKS[$N]} | ||
41 | |||
16 | for M in $(seq $LOCAL_M); do | 42 | for M in $(seq $LOCAL_M); do |
17 | netjail_node_clear $(netjail_print_name "N" $N $M) | 43 | netjail_node_name |
44 | NODES[$N,$M]=$RESULT | ||
45 | netjail_node_link_bridge_name | ||
46 | NODE_LINKS[$N,$M]=$RESULT | ||
47 | netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]} | ||
48 | netjail_node_clear ${NODES[$N,$M]} | ||
18 | done | 49 | done |
50 | |||
19 | 51 | ||
20 | netjail_bridge_clear $(netjail_print_name "r" $N) | 52 | netjail_bridge_clear ${ROUTER_NETS[$N]} |
21 | netjail_node_clear $(netjail_print_name "R" $N) | 53 | netjail_node_unlink_bridge ${NETWORK_LINKS[$N]} |
54 | netjail_node_clear ${ROUTERS[$N]} | ||
22 | done | 55 | done |
23 | 56 | ||
24 | netjail_bridge_clear $NETWORK_NET | 57 | netjail_bridge_clear $NETWORK_NET |
diff --git a/src/testing/netjail_stop_v2.sh b/src/testing/netjail_stop_v2.sh deleted file mode 100755 index 6e9fd1ccc..000000000 --- a/src/testing/netjail_stop_v2.sh +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | . "./../testing/netjail_core_v2.sh" | ||
3 | . "./../testing/topo.sh" | ||
4 | |||
5 | set -eu | ||
6 | set -x | ||
7 | |||
8 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
9 | |||
10 | filename=$1 | ||
11 | PREFIX=$2 | ||
12 | |||
13 | read_topology $filename | ||
14 | |||
15 | declare -A NODES | ||
16 | declare -A NODE_LINKS | ||
17 | |||
18 | netjail_bridge_name | ||
19 | NETWORK_NET=$RESULT | ||
20 | |||
21 | for X in $(seq $KNOWN); do | ||
22 | netjail_node_name | ||
23 | KNOWN_NODES[$X]=$RESULT | ||
24 | netjail_node_link_bridge_name | ||
25 | KNOWN_LINKS[$X]=$RESULT | ||
26 | netjail_node_unlink_bridge ${KNOWN_LINKS[$X]} | ||
27 | netjail_node_clear ${KNOWN_NODES[$X]} | ||
28 | done | ||
29 | |||
30 | for N in $(seq $GLOBAL_N); do | ||
31 | netjail_node_name | ||
32 | ROUTERS[$N]=$RESULT | ||
33 | netjail_node_link_bridge_name | ||
34 | NETWORK_LINKS[$N]=$RESULT | ||
35 | netjail_bridge_name | ||
36 | ROUTER_NETS[$N]=$RESULT | ||
37 | netjail_node_link_bridge_name | ||
38 | ROUTER_LINKS[$N]=$RESULT | ||
39 | |||
40 | netjail_node_unlink_bridge ${ROUTER_LINKS[$N]} | ||
41 | |||
42 | for M in $(seq $LOCAL_M); do | ||
43 | netjail_node_name | ||
44 | NODES[$N,$M]=$RESULT | ||
45 | netjail_node_link_bridge_name | ||
46 | NODE_LINKS[$N,$M]=$RESULT | ||
47 | netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]} | ||
48 | netjail_node_clear ${NODES[$N,$M]} | ||
49 | done | ||
50 | |||
51 | |||
52 | netjail_bridge_clear ${ROUTER_NETS[$N]} | ||
53 | netjail_node_unlink_bridge ${NETWORK_LINKS[$N]} | ||
54 | netjail_node_clear ${ROUTERS[$N]} | ||
55 | done | ||
56 | |||
57 | netjail_bridge_clear $NETWORK_NET | ||
58 | |||
59 | echo "Done" | ||
diff --git a/src/testing/test_testing_plugin_testcmd.c b/src/testing/test_testing_plugin_testcmd.c index 444272fcd..32e2b38a7 100644 --- a/src/testing/test_testing_plugin_testcmd.c +++ b/src/testing/test_testing_plugin_testcmd.c | |||
@@ -17,11 +17,12 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file testbed/plugin_testcmd.c | 21 | * @file testbed/plugin_testcmd.c |
23 | * @brief a plugin to provide the API for running test cases. | 22 | * @brief a plugin to provide the API for running test cases. |
24 | * @author t3sserakt | 23 | * @author t3sserakt |
24 | * | ||
25 | * // FIXME: too verbose, no logic to return final status, will segv! | ||
25 | */ | 26 | */ |
26 | #include "platform.h" | 27 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
@@ -33,8 +34,11 @@ | |||
33 | */ | 34 | */ |
34 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 35 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
35 | 36 | ||
37 | |||
38 | // FIXME: bad global! | ||
36 | unsigned int are_all_peers_started; | 39 | unsigned int are_all_peers_started; |
37 | 40 | ||
41 | |||
38 | static void | 42 | static void |
39 | all_peers_started () | 43 | all_peers_started () |
40 | { | 44 | { |
@@ -44,8 +48,10 @@ all_peers_started () | |||
44 | are_all_peers_started); | 48 | are_all_peers_started); |
45 | } | 49 | } |
46 | 50 | ||
51 | |||
47 | static void | 52 | static void |
48 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | 53 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, |
54 | char *router_ip, | ||
49 | char *node_ip, | 55 | char *node_ip, |
50 | char *n, | 56 | char *n, |
51 | char *m, | 57 | char *m, |
@@ -70,9 +76,10 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
70 | write_message) | 76 | write_message) |
71 | }; | 77 | }; |
72 | 78 | ||
73 | GNUNET_TESTING_run (NULL, | 79 | GNUNET_TESTING_run (commands, |
74 | commands, | 80 | GNUNET_TIME_UNIT_FOREVER_REL, |
75 | GNUNET_TIME_UNIT_FOREVER_REL); | 81 | NULL, /* FIXME: pass continuation! */ |
82 | NULL); | ||
76 | LOG (GNUNET_ERROR_TYPE_ERROR, | 83 | LOG (GNUNET_ERROR_TYPE_ERROR, |
77 | "We got here 7!\n"); | 84 | "We got here 7!\n"); |
78 | 85 | ||
@@ -113,4 +120,4 @@ libgnunet_plugin_testcmd_done (void *cls) | |||
113 | } | 120 | } |
114 | 121 | ||
115 | 122 | ||
116 | /* end of plugin_testcmd.c */ | 123 | |
diff --git a/src/testing/testing.c b/src/testing/testing.c index d3acd4689..4d9b7c0cb 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "gnunet_arm_service.h" | 34 | #include "gnunet_arm_service.h" |
35 | #include "gnunet_testing_lib.h" | 35 | #include "gnunet_testing_lib.h" |
36 | #include "gnunet_testing_ng_lib.h" | 36 | #include "gnunet_testing_ng_lib.h" |
37 | #include "testing_cmds.h" | ||
37 | 38 | ||
38 | #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) | 39 | #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
39 | 40 | ||
@@ -2259,6 +2260,31 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | |||
2259 | 2260 | ||
2260 | 2261 | ||
2261 | /** | 2262 | /** |
2263 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | ||
2264 | * | ||
2265 | * @param rv The result of the local test as GNUNET_GenericReturnValue. | ||
2266 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. | ||
2267 | */ | ||
2268 | struct GNUNET_MessageHeader * | ||
2269 | GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv) | ||
2270 | { | ||
2271 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
2272 | size_t msg_length; | ||
2273 | |||
2274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2275 | "Local test exits with status %d\n", | ||
2276 | rv); | ||
2277 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | ||
2278 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | ||
2279 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
2280 | reply->header.size = htons ((uint16_t) msg_length); | ||
2281 | reply->result = htons (rv); | ||
2282 | |||
2283 | return (struct GNUNET_MessageHeader *) reply; | ||
2284 | } | ||
2285 | |||
2286 | |||
2287 | /** | ||
2262 | * Getting the topology from file. | 2288 | * Getting the topology from file. |
2263 | * | 2289 | * |
2264 | * @param filename The name of the topology file. | 2290 | * @param filename The name of the topology file. |
diff --git a/src/testing/testing.h b/src/testing/testing.h index b12466530..8aba09e4b 100644 --- a/src/testing/testing.h +++ b/src/testing/testing.h | |||
@@ -21,54 +21,54 @@ | |||
21 | /** | 21 | /** |
22 | * @author t3sserakt | 22 | * @author t3sserakt |
23 | */ | 23 | */ |
24 | 24 | #ifndef TESTING_H | |
25 | #define TESTING_H | ||
25 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
26 | 27 | ||
28 | |||
29 | /** | ||
30 | * Advance internal pointer to next command. | ||
31 | * | ||
32 | * @param cls batch internal state | ||
33 | * @return true if we could advance, false if the batch | ||
34 | * has completed and cannot advance anymore | ||
35 | */ | ||
36 | bool | ||
37 | GNUNET_TESTING_cmd_batch_next_ (void *cls); | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Test if this command is a batch command. | ||
42 | * | ||
43 | * @return false if not, true if it is a batch command | ||
44 | */ | ||
45 | bool | ||
46 | GNUNET_TESTING_cmd_is_batch_ (const struct GNUNET_TESTING_Command *cmd); | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Obtain what command the batch is at. | ||
51 | * | ||
52 | * @return cmd current batch command | ||
53 | */ | ||
54 | struct GNUNET_TESTING_Command * | ||
55 | GNUNET_TESTING_cmd_batch_get_current_ (const struct GNUNET_TESTING_Command *cmd); | ||
56 | |||
57 | |||
27 | /** | 58 | /** |
28 | * Global state of the interpreter, used by a command | 59 | * Set what command the batch should be at. Needed for |
29 | * to access information about other commands. | 60 | * loops. We may want to change this to take a label |
61 | * and/or expose it in the public API in the future. | ||
62 | * Not used for now. | ||
63 | * | ||
64 | * @param cmd current batch command | ||
65 | * @param new_ip where to move the IP | ||
30 | */ | 66 | */ |
31 | // SUGGESTION: consider making this struct opaque (only known inside of libgnunettesting, | 67 | void |
32 | // say main loop and a few select commands, like next/fail/batch); + helper | 68 | GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd, |
33 | // function to access 'cfg'? | 69 | unsigned int new_ip); |
34 | struct GNUNET_TESTING_Interpreter | 70 | |
35 | { | 71 | |
36 | 72 | ||
37 | /** | 73 | |
38 | * Commands the interpreter will run. | 74 | #endif |
39 | */ | ||
40 | struct GNUNET_TESTING_Command *commands; | ||
41 | |||
42 | /** | ||
43 | * Interpreter task (if one is scheduled). | ||
44 | */ | ||
45 | struct GNUNET_SCHEDULER_Task *task; | ||
46 | |||
47 | /** | ||
48 | * Finish task of a blocking call to a commands finish method. | ||
49 | */ | ||
50 | struct GNUNET_SCHEDULER_Task *finish_task; | ||
51 | |||
52 | /** | ||
53 | * Our configuration. | ||
54 | */ | ||
55 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
56 | |||
57 | /** | ||
58 | * Task run on timeout. | ||
59 | */ | ||
60 | struct GNUNET_SCHEDULER_Task *timeout_task; | ||
61 | |||
62 | /** | ||
63 | * Instruction pointer. Tells #interpreter_run() which instruction to run | ||
64 | * next. Need (signed) int because it gets -1 when rewinding the | ||
65 | * interpreter to the first CMD. | ||
66 | */ | ||
67 | int ip; | ||
68 | |||
69 | /** | ||
70 | * Result of the testcases, #GNUNET_OK on success | ||
71 | */ | ||
72 | int result; | ||
73 | |||
74 | }; | ||
diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c index af260f80d..080a4880d 100644 --- a/src/testing/testing_api_cmd_batch.c +++ b/src/testing/testing_api_cmd_batch.c | |||
@@ -39,6 +39,11 @@ struct BatchState | |||
39 | struct GNUNET_TESTING_Command *batch; | 39 | struct GNUNET_TESTING_Command *batch; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Our label. | ||
43 | */ | ||
44 | const char *label; | ||
45 | |||
46 | /** | ||
42 | * Internal command pointer. | 47 | * Internal command pointer. |
43 | */ | 48 | */ |
44 | unsigned int batch_ip; | 49 | unsigned int batch_ip; |
@@ -49,12 +54,10 @@ struct BatchState | |||
49 | * Run the command. | 54 | * Run the command. |
50 | * | 55 | * |
51 | * @param cls closure. | 56 | * @param cls closure. |
52 | * @param cmd the command being executed. | ||
53 | * @param is the interpreter state. | 57 | * @param is the interpreter state. |
54 | */ | 58 | */ |
55 | static void | 59 | static void |
56 | batch_run (void *cls, | 60 | batch_run (void *cls, |
57 | const struct GNUNET_TESTING_Command *cmd, | ||
58 | struct GNUNET_TESTING_Interpreter *is) | 61 | struct GNUNET_TESTING_Interpreter *is) |
59 | { | 62 | { |
60 | struct BatchState *bs = cls; | 63 | struct BatchState *bs = cls; |
@@ -69,7 +72,7 @@ batch_run (void *cls, | |||
69 | { | 72 | { |
70 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 73 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
71 | "Exiting from batch: %s\n", | 74 | "Exiting from batch: %s\n", |
72 | cmd->label); | 75 | bs->label); |
73 | return; | 76 | return; |
74 | } | 77 | } |
75 | bs->batch[bs->batch_ip].start_time | 78 | bs->batch[bs->batch_ip].start_time |
@@ -77,7 +80,6 @@ batch_run (void *cls, | |||
77 | = GNUNET_TIME_absolute_get (); | 80 | = GNUNET_TIME_absolute_get (); |
78 | bs->batch[bs->batch_ip].num_tries = 1; | 81 | bs->batch[bs->batch_ip].num_tries = 1; |
79 | bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls, | 82 | bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls, |
80 | &bs->batch[bs->batch_ip], | ||
81 | is); | 83 | is); |
82 | } | 84 | } |
83 | 85 | ||
@@ -87,20 +89,16 @@ batch_run (void *cls, | |||
87 | * cancel a pending operation thereof. | 89 | * cancel a pending operation thereof. |
88 | * | 90 | * |
89 | * @param cls closure. | 91 | * @param cls closure. |
90 | * @param cmd the command which is being cleaned up. | ||
91 | */ | 92 | */ |
92 | static void | 93 | static void |
93 | batch_cleanup (void *cls, | 94 | batch_cleanup (void *cls) |
94 | const struct GNUNET_TESTING_Command *cmd) | ||
95 | { | 95 | { |
96 | struct BatchState *bs = cls; | 96 | struct BatchState *bs = cls; |
97 | 97 | ||
98 | (void) cmd; | ||
99 | for (unsigned int i = 0; | 98 | for (unsigned int i = 0; |
100 | NULL != bs->batch[i].label; | 99 | NULL != bs->batch[i].label; |
101 | i++) | 100 | i++) |
102 | bs->batch[i].cleanup (bs->batch[i].cls, | 101 | bs->batch[i].cleanup (bs->batch[i].cls); |
103 | &bs->batch[i]); | ||
104 | GNUNET_free (bs->batch); | 102 | GNUNET_free (bs->batch); |
105 | GNUNET_free (bs); | 103 | GNUNET_free (bs); |
106 | } | 104 | } |
@@ -115,22 +113,21 @@ batch_cleanup (void *cls, | |||
115 | * @param index index number of the object to offer. | 113 | * @param index index number of the object to offer. |
116 | * @return #GNUNET_OK on success. | 114 | * @return #GNUNET_OK on success. |
117 | */ | 115 | */ |
118 | static int | 116 | static enum GNUNET_GenericReturnValue |
119 | batch_traits (void *cls, | 117 | batch_traits (void *cls, |
120 | const void **ret, | 118 | const void **ret, |
121 | const char *trait, | 119 | const char *trait, |
122 | unsigned int index) | 120 | unsigned int index) |
123 | { | 121 | { |
122 | struct BatchState *bs = cls; | ||
123 | // FIXME: these constants should be more global! | ||
124 | #define CURRENT_CMD_INDEX 0 | 124 | #define CURRENT_CMD_INDEX 0 |
125 | #define BATCH_INDEX 1 | 125 | #define BATCH_INDEX 1 |
126 | |||
127 | struct BatchState *bs = cls; | ||
128 | |||
129 | struct GNUNET_TESTING_Trait traits[] = { | 126 | struct GNUNET_TESTING_Trait traits[] = { |
130 | GNUNET_TESTING_make_trait_cmd | 127 | GNUNET_TESTING_make_trait_cmd (CURRENT_CMD_INDEX, |
131 | (CURRENT_CMD_INDEX, &bs->batch[bs->batch_ip]), | 128 | &bs->batch[bs->batch_ip]), |
132 | GNUNET_TESTING_make_trait_cmd | 129 | GNUNET_TESTING_make_trait_cmd (BATCH_INDEX, |
133 | (BATCH_INDEX, bs->batch), | 130 | bs->batch), |
134 | GNUNET_TESTING_trait_end () | 131 | GNUNET_TESTING_trait_end () |
135 | }; | 132 | }; |
136 | 133 | ||
@@ -162,7 +159,7 @@ GNUNET_TESTING_cmd_batch (const char *label, | |||
162 | unsigned int i; | 159 | unsigned int i; |
163 | 160 | ||
164 | bs = GNUNET_new (struct BatchState); | 161 | bs = GNUNET_new (struct BatchState); |
165 | 162 | bs->label = label; | |
166 | /* Get number of commands. */ | 163 | /* Get number of commands. */ |
167 | for (i = 0; NULL != batch[i].label; i++) | 164 | for (i = 0; NULL != batch[i].label; i++) |
168 | /* noop */ | 165 | /* noop */ |
@@ -187,68 +184,45 @@ GNUNET_TESTING_cmd_batch (const char *label, | |||
187 | } | 184 | } |
188 | 185 | ||
189 | 186 | ||
190 | /** | 187 | bool |
191 | * Advance internal pointer to next command. | 188 | GNUNET_TESTING_cmd_batch_next_ (void *cls) |
192 | * | ||
193 | * @param is interpreter state. | ||
194 | */ | ||
195 | void | ||
196 | GNUNET_TESTING_cmd_batch_next (struct GNUNET_TESTING_Interpreter *is) | ||
197 | { | 189 | { |
198 | struct BatchState *bs = is->commands[is->ip].cls; | 190 | struct BatchState *bs = cls; |
199 | 191 | ||
200 | if (NULL == bs->batch[bs->batch_ip].label) | 192 | if (NULL == bs->batch[bs->batch_ip].label) |
201 | { | 193 | return false; |
202 | is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get (); | 194 | bs->batch[bs->batch_ip].finish_time |
203 | is->ip++; | 195 | = GNUNET_TIME_absolute_get (); |
204 | return; | ||
205 | } | ||
206 | bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get (); | ||
207 | bs->batch_ip++; | 196 | bs->batch_ip++; |
197 | return true; | ||
208 | } | 198 | } |
209 | 199 | ||
210 | 200 | ||
211 | /** | 201 | bool |
212 | * Test if this command is a batch command. | 202 | GNUNET_TESTING_cmd_is_batch_ (const struct GNUNET_TESTING_Command *cmd) |
213 | * | ||
214 | * @return false if not, true if it is a batch command | ||
215 | */ | ||
216 | int | ||
217 | GNUNET_TESTING_cmd_is_batch (const struct GNUNET_TESTING_Command *cmd) | ||
218 | { | 203 | { |
219 | return cmd->run == &batch_run; | 204 | return cmd->run == &batch_run; |
220 | } | 205 | } |
221 | 206 | ||
222 | 207 | ||
223 | /** | ||
224 | * Obtain what command the batch is at. | ||
225 | * | ||
226 | * @return cmd current batch command | ||
227 | */ | ||
228 | struct GNUNET_TESTING_Command * | 208 | struct GNUNET_TESTING_Command * |
229 | GNUNET_TESTING_cmd_batch_get_current (const struct GNUNET_TESTING_Command *cmd) | 209 | GNUNET_TESTING_cmd_batch_get_current_ (const struct GNUNET_TESTING_Command *cmd) |
230 | { | 210 | { |
231 | struct BatchState *bs = cmd->cls; | 211 | struct BatchState *bs = cmd->cls; |
232 | 212 | ||
233 | GNUNET_assert (cmd->run == &batch_run); | 213 | GNUNET_assert (GNUNET_TESTING_cmd_is_batch_ (cmd)); |
234 | return &bs->batch[bs->batch_ip]; | 214 | return &bs->batch[bs->batch_ip]; |
235 | } | 215 | } |
236 | 216 | ||
237 | 217 | ||
238 | /** | ||
239 | * Set what command the batch should be at. | ||
240 | * | ||
241 | * @param cmd current batch command | ||
242 | * @param new_ip where to move the IP | ||
243 | */ | ||
244 | void | 218 | void |
245 | GNUNET_TESTING_cmd_batch_set_current (const struct GNUNET_TESTING_Command *cmd, | 219 | GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd, |
246 | unsigned int new_ip) | 220 | unsigned int new_ip) |
247 | { | 221 | { |
248 | struct BatchState *bs = cmd->cls; | 222 | struct BatchState *bs = cmd->cls; |
249 | 223 | ||
250 | /* sanity checks */ | 224 | /* sanity checks */ |
251 | GNUNET_assert (cmd->run == &batch_run); | 225 | GNUNET_assert (GNUNET_TESTING_cmd_is_batch_ (cmd)); |
252 | for (unsigned int i = 0; i < new_ip; i++) | 226 | for (unsigned int i = 0; i < new_ip; i++) |
253 | GNUNET_assert (NULL != bs->batch[i].label); | 227 | GNUNET_assert (NULL != bs->batch[i].label); |
254 | /* actual logic */ | 228 | /* actual logic */ |
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c index e9d3f0ed3..763713e15 100644 --- a/src/testing/testing_api_cmd_block_until_all_peers_started.c +++ b/src/testing/testing_api_cmd_block_until_all_peers_started.c | |||
@@ -39,6 +39,11 @@ | |||
39 | struct BlockState | 39 | struct BlockState |
40 | { | 40 | { |
41 | /** | 41 | /** |
42 | * Context for our asynchronous completion. | ||
43 | */ | ||
44 | struct GNUNET_TESTING_AsyncContext ac; | ||
45 | |||
46 | /** | ||
42 | * Flag to indicate if all peers have started. | 47 | * Flag to indicate if all peers have started. |
43 | * | 48 | * |
44 | */ | 49 | */ |
@@ -47,26 +52,11 @@ struct BlockState | |||
47 | 52 | ||
48 | 53 | ||
49 | /** | 54 | /** |
50 | * Trait function of this cmd does nothing. | ||
51 | * | ||
52 | */ | ||
53 | static int | ||
54 | block_until_all_peers_started_traits (void *cls, | ||
55 | const void **ret, | ||
56 | const char *trait, | ||
57 | unsigned int index) | ||
58 | { | ||
59 | return GNUNET_OK; | ||
60 | } | ||
61 | |||
62 | |||
63 | /** | ||
64 | * The cleanup function of this cmd frees resources the cmd allocated. | 55 | * The cleanup function of this cmd frees resources the cmd allocated. |
65 | * | 56 | * |
66 | */ | 57 | */ |
67 | static void | 58 | static void |
68 | block_until_all_peers_started_cleanup (void *cls, | 59 | block_until_all_peers_started_cleanup (void *cls) |
69 | const struct GNUNET_TESTING_Command *cmd) | ||
70 | { | 60 | { |
71 | struct BlockState *bs = cls; | 61 | struct BlockState *bs = cls; |
72 | 62 | ||
@@ -80,7 +70,6 @@ block_until_all_peers_started_cleanup (void *cls, | |||
80 | */ | 70 | */ |
81 | static void | 71 | static void |
82 | block_until_all_peers_started_run (void *cls, | 72 | block_until_all_peers_started_run (void *cls, |
83 | const struct GNUNET_TESTING_Command *cmd, | ||
84 | struct GNUNET_TESTING_Interpreter *is) | 73 | struct GNUNET_TESTING_Interpreter *is) |
85 | { | 74 | { |
86 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 75 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -89,27 +78,6 @@ block_until_all_peers_started_run (void *cls, | |||
89 | 78 | ||
90 | 79 | ||
91 | /** | 80 | /** |
92 | * Function to check if BlockState#all_peers_started is GNUNET_YES. In that case interpreter_next will be called. | ||
93 | * | ||
94 | */ | ||
95 | static int | ||
96 | block_until_all_peers_started_finish (void *cls, | ||
97 | GNUNET_SCHEDULER_TaskCallback cont, | ||
98 | void *cont_cls) | ||
99 | { | ||
100 | struct BlockState *bs = cls; | ||
101 | unsigned int *ret = bs->all_peers_started; | ||
102 | |||
103 | if (GNUNET_YES == *ret) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return *ret; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Create command. | 81 | * Create command. |
114 | * | 82 | * |
115 | * @param label name for command. | 83 | * @param label name for command. |
@@ -125,15 +93,15 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | |||
125 | 93 | ||
126 | bs = GNUNET_new (struct BlockState); | 94 | bs = GNUNET_new (struct BlockState); |
127 | bs->all_peers_started = all_peers_started; | 95 | bs->all_peers_started = all_peers_started; |
128 | 96 | { | |
129 | struct GNUNET_TESTING_Command cmd = { | 97 | struct GNUNET_TESTING_Command cmd = { |
130 | .cls = bs, | 98 | .cls = bs, |
131 | .label = label, | 99 | .label = label, |
132 | .run = &block_until_all_peers_started_run, | 100 | .run = &block_until_all_peers_started_run, |
133 | .finish = &block_until_all_peers_started_finish, | 101 | .ac = &bs->ac, |
134 | .cleanup = &block_until_all_peers_started_cleanup, | 102 | .cleanup = &block_until_all_peers_started_cleanup |
135 | .traits = &block_until_all_peers_started_traits | 103 | }; |
136 | }; | 104 | |
137 | 105 | return cmd; | |
138 | return cmd; | 106 | } |
139 | } | 107 | } |
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c index 2439afeaf..aeb9ffda3 100644 --- a/src/testing/testing_api_cmd_block_until_external_trigger.c +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c | |||
@@ -39,25 +39,15 @@ | |||
39 | struct BlockState | 39 | struct BlockState |
40 | { | 40 | { |
41 | /** | 41 | /** |
42 | * Flag to indicate if all peers have started. | 42 | * Context for our asynchronous completion. |
43 | * | ||
44 | */ | 43 | */ |
45 | unsigned int *stop_blocking; | 44 | struct GNUNET_TESTING_AsyncContext ac; |
46 | }; | ||
47 | |||
48 | 45 | ||
49 | /** | 46 | /** |
50 | * Trait function of this cmd does nothing. | 47 | * The label of this command. |
51 | * | 48 | */ |
52 | */ | 49 | const char *label; |
53 | static int | 50 | }; |
54 | block_until_all_peers_started_traits (void *cls, | ||
55 | const void **ret, | ||
56 | const char *trait, | ||
57 | unsigned int index) | ||
58 | { | ||
59 | return GNUNET_OK; | ||
60 | } | ||
61 | 51 | ||
62 | 52 | ||
63 | /** | 53 | /** |
@@ -65,47 +55,68 @@ block_until_all_peers_started_traits (void *cls, | |||
65 | * | 55 | * |
66 | */ | 56 | */ |
67 | static void | 57 | static void |
68 | block_until_all_peers_started_cleanup (void *cls, | 58 | block_until_all_peers_started_cleanup (void *cls) |
69 | const struct GNUNET_TESTING_Command *cmd) | ||
70 | { | 59 | { |
71 | struct BlockState *bs = cls; | 60 | struct BlockState *bs = cls; |
72 | 61 | ||
73 | GNUNET_free (bs); | 62 | GNUNET_free (bs); |
74 | } | 63 | } |
75 | 64 | ||
65 | static int | ||
66 | block_until_external_trigger_traits (void *cls, | ||
67 | const void **ret, | ||
68 | const char *trait, | ||
69 | unsigned int index) | ||
70 | { | ||
71 | struct BlockState *bs = cls; | ||
72 | struct GNUNET_TESTING_AsyncContext *ac = &bs->ac; | ||
73 | struct GNUNET_TESTING_Trait traits[] = { | ||
74 | { | ||
75 | .index = 0, | ||
76 | .trait_name = "async_context", | ||
77 | .ptr = (const void *) ac, | ||
78 | }, | ||
79 | GNUNET_TESTING_trait_end () | ||
80 | }; | ||
81 | |||
82 | return GNUNET_TESTING_get_trait (traits, | ||
83 | ret, | ||
84 | trait, | ||
85 | index); | ||
86 | } | ||
87 | |||
76 | 88 | ||
77 | /** | 89 | /** |
78 | * This function does nothing but to start the cmd. | 90 | * Function to get the trait with the async context. |
79 | * | 91 | * |
92 | * @param[out] ac GNUNET_TESTING_AsyncContext. | ||
93 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
80 | */ | 94 | */ |
81 | static void | 95 | int |
82 | block_until_all_peers_started_run (void *cls, | 96 | GNUNET_TESTING_get_trait_async_context ( |
83 | const struct GNUNET_TESTING_Command *cmd, | 97 | const struct GNUNET_TESTING_Command *cmd, |
84 | struct GNUNET_TESTING_Interpreter *is) | 98 | struct GNUNET_TESTING_AsyncContext **ac) |
85 | { | 99 | { |
86 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 100 | return cmd->traits (cmd->cls, |
87 | "block_until_all_peers_started_run!\n"); | 101 | (const void **) ac, |
102 | "async_context", | ||
103 | (unsigned int) 0); | ||
88 | } | 104 | } |
89 | 105 | ||
90 | 106 | ||
91 | /** | 107 | /** |
92 | * Function to check if BlockState#all_peers_started is GNUNET_YES. In that case interpreter_next will be called. | 108 | * This function does nothing but to start the cmd. |
93 | * | 109 | * |
94 | */ | 110 | */ |
95 | static int | 111 | static void |
96 | block_until_all_peers_started_finish (void *cls, | 112 | block_until_all_peers_started_run (void *cls, |
97 | GNUNET_SCHEDULER_TaskCallback cont, | 113 | struct GNUNET_TESTING_Interpreter *is) |
98 | void *cont_cls) | ||
99 | { | 114 | { |
100 | struct BlockState *bs = cls; | 115 | struct BlockState *bs = cls; |
101 | unsigned int *ret = bs->stop_blocking; | ||
102 | 116 | ||
103 | if (GNUNET_YES == *ret) | 117 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
104 | { | 118 | "block %s running!\n", |
105 | cont (cont_cls); | 119 | bs->label); |
106 | } | ||
107 | |||
108 | return *ret; | ||
109 | } | 120 | } |
110 | 121 | ||
111 | 122 | ||
@@ -117,23 +128,22 @@ block_until_all_peers_started_finish (void *cls, | |||
117 | * @return command. | 128 | * @return command. |
118 | */ | 129 | */ |
119 | struct GNUNET_TESTING_Command | 130 | struct GNUNET_TESTING_Command |
120 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label, | 131 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label) |
121 | unsigned int * | ||
122 | stop_blocking) | ||
123 | { | 132 | { |
124 | struct BlockState *bs; | 133 | struct BlockState *bs; |
125 | 134 | ||
126 | bs = GNUNET_new (struct BlockState); | 135 | bs = GNUNET_new (struct BlockState); |
127 | bs->stop_blocking = stop_blocking; | 136 | bs->label = label; |
128 | 137 | { | |
129 | struct GNUNET_TESTING_Command cmd = { | 138 | struct GNUNET_TESTING_Command cmd = { |
130 | .cls = bs, | 139 | .cls = bs, |
131 | .label = label, | 140 | .label = label, |
132 | .run = &block_until_all_peers_started_run, | 141 | .run = &block_until_all_peers_started_run, |
133 | .finish = &block_until_all_peers_started_finish, | 142 | .ac = &bs->ac, |
134 | .cleanup = &block_until_all_peers_started_cleanup, | 143 | .cleanup = &block_until_all_peers_started_cleanup, |
135 | .traits = &block_until_all_peers_started_traits | 144 | .traits = block_until_external_trigger_traits |
136 | }; | 145 | }; |
137 | 146 | ||
138 | return cmd; | 147 | return cmd; |
148 | } | ||
139 | } | 149 | } |
diff --git a/src/testing/testing_api_cmd_end.c b/src/testing/testing_api_cmd_end.c new file mode 100644 index 000000000..f0f036429 --- /dev/null +++ b/src/testing/testing_api_cmd_end.c | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file testing/testing_api_cmd_end.c | ||
22 | * @brief command to end a command array | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_util_lib.h" | ||
26 | #include "gnunet_testing_ng_lib.h" | ||
27 | |||
28 | |||
29 | struct GNUNET_TESTING_Command | ||
30 | GNUNET_TESTING_cmd_end (void) | ||
31 | { | ||
32 | static struct GNUNET_TESTING_Command cmd = { | ||
33 | .label = NULL | ||
34 | }; | ||
35 | |||
36 | return cmd; | ||
37 | } | ||
38 | |||
39 | |||
diff --git a/src/testing/testing_api_cmd_finish.c b/src/testing/testing_api_cmd_finish.c new file mode 100644 index 000000000..3ac0871a5 --- /dev/null +++ b/src/testing/testing_api_cmd_finish.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file testing/testing_api_cmd_finish.c | ||
22 | * @brief command to wait for completion of async command | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_util_lib.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | |||
29 | /** | ||
30 | * Struct to use for command-specific context information closure of a command waiting | ||
31 | * for another command. | ||
32 | */ | ||
33 | struct FinishState | ||
34 | { | ||
35 | /** | ||
36 | * Closure for all commands with command-specific context information. | ||
37 | */ | ||
38 | void *cls; | ||
39 | |||
40 | /** | ||
41 | * Label of the asynchronous command the synchronous command of this closure waits for. | ||
42 | */ | ||
43 | const char *async_label; | ||
44 | |||
45 | /** | ||
46 | * Task for running the finish method of the asynchronous task the command is waiting for. | ||
47 | */ | ||
48 | struct GNUNET_SCHEDULER_Task *finish_task; | ||
49 | |||
50 | /** | ||
51 | * Function to call when done. | ||
52 | */ | ||
53 | struct GNUNET_TESTING_AsyncContext ac; | ||
54 | |||
55 | /** | ||
56 | * How long to wait until finish fails hard? | ||
57 | */ | ||
58 | struct GNUNET_TIME_Relative timeout; | ||
59 | |||
60 | }; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Function called when the command we are waiting on | ||
65 | * is finished. Hence we are finished, too. | ||
66 | * | ||
67 | * @param cls a `struct FinishState` being notified | ||
68 | */ | ||
69 | static void | ||
70 | done_finish (void *cls) | ||
71 | { | ||
72 | struct FinishState *finish_state = cls; | ||
73 | |||
74 | GNUNET_SCHEDULER_cancel (finish_state->finish_task); | ||
75 | finish_state->finish_task = NULL; | ||
76 | GNUNET_TESTING_async_finish (&finish_state->ac); | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Function triggered if the command we are waiting | ||
82 | * for did not complete on time. | ||
83 | * | ||
84 | * @param cls our `struct FinishState` | ||
85 | */ | ||
86 | static void | ||
87 | timeout_finish (void *cls) | ||
88 | { | ||
89 | struct FinishState *finish_state = cls; | ||
90 | |||
91 | finish_state->finish_task = NULL; | ||
92 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
93 | "Timeout waiting for command `%s' to finish\n", | ||
94 | finish_state->async_label); | ||
95 | GNUNET_TESTING_async_fail (&finish_state->ac); | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Run method of the command created by the interpreter to wait for another | ||
101 | * command to finish. | ||
102 | * | ||
103 | */ | ||
104 | static void | ||
105 | run_finish (void *cls, | ||
106 | struct GNUNET_TESTING_Interpreter *is) | ||
107 | { | ||
108 | struct FinishState *finish_state = cls; | ||
109 | const struct GNUNET_TESTING_Command *async_cmd; | ||
110 | struct GNUNET_TESTING_AsyncContext *aac; | ||
111 | |||
112 | async_cmd | ||
113 | = GNUNET_TESTING_interpreter_lookup_command (is, | ||
114 | finish_state->async_label); | ||
115 | if (NULL == async_cmd) | ||
116 | { | ||
117 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
118 | "Did not find command `%s'\n", | ||
119 | finish_state->async_label); | ||
120 | GNUNET_TESTING_interpreter_fail (is); | ||
121 | return; | ||
122 | } | ||
123 | if ( (NULL == (aac = async_cmd->ac)) || | ||
124 | (! async_cmd->asynchronous_finish) ) | ||
125 | { | ||
126 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
127 | "Cannot finish `%s': not asynchronous\n", | ||
128 | finish_state->async_label); | ||
129 | GNUNET_TESTING_interpreter_fail (is); | ||
130 | return; | ||
131 | } | ||
132 | if (GNUNET_NO != aac->finished) | ||
133 | { | ||
134 | /* Command is already finished, so are we! */ | ||
135 | GNUNET_TESTING_async_finish (&finish_state->ac); | ||
136 | return; | ||
137 | } | ||
138 | finish_state->finish_task | ||
139 | = GNUNET_SCHEDULER_add_delayed (finish_state->timeout, | ||
140 | &timeout_finish, | ||
141 | finish_state); | ||
142 | aac->cont = &done_finish; | ||
143 | aac->cont_cls = finish_state; | ||
144 | } | ||
145 | |||
146 | |||
147 | /** | ||
148 | * Cleanup state of a finish command. | ||
149 | * | ||
150 | * @param cls a `struct FinishState` to clean up | ||
151 | */ | ||
152 | static void | ||
153 | cleanup_finish (void *cls) | ||
154 | { | ||
155 | struct FinishState *finish_state = cls; | ||
156 | |||
157 | if (NULL != finish_state->finish_task) | ||
158 | { | ||
159 | GNUNET_SCHEDULER_cancel (finish_state->finish_task); | ||
160 | finish_state->finish_task = NULL; | ||
161 | } | ||
162 | GNUNET_free (finish_state); | ||
163 | } | ||
164 | |||
165 | |||
166 | const struct GNUNET_TESTING_Command | ||
167 | GNUNET_TESTING_cmd_finish (const char *finish_label, | ||
168 | const char *cmd_ref, | ||
169 | struct GNUNET_TIME_Relative timeout) | ||
170 | { | ||
171 | struct FinishState *finish_state; | ||
172 | |||
173 | finish_state = GNUNET_new (struct FinishState); | ||
174 | finish_state->async_label = cmd_ref; | ||
175 | finish_state->timeout = timeout; | ||
176 | { | ||
177 | struct GNUNET_TESTING_Command cmd = { | ||
178 | .cls = finish_state, | ||
179 | .label = finish_label, | ||
180 | .run = &run_finish, | ||
181 | .ac = &finish_state->ac, | ||
182 | .cleanup = &cleanup_finish | ||
183 | }; | ||
184 | |||
185 | return cmd; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | |||
190 | struct GNUNET_TESTING_Command | ||
191 | GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd) | ||
192 | { | ||
193 | /* do not permit this function to be used on | ||
194 | a finish command! */ | ||
195 | GNUNET_assert (cmd.run != &run_finish); | ||
196 | cmd.asynchronous_finish = true; | ||
197 | return cmd; | ||
198 | } | ||
diff --git a/src/testing/testing_api_cmd_hello_world.c b/src/testing/testing_api_cmd_hello_world.c index 4347ac818..73dcd6dff 100644 --- a/src/testing/testing_api_cmd_hello_world.c +++ b/src/testing/testing_api_cmd_hello_world.c | |||
@@ -32,50 +32,51 @@ struct HelloWorldState | |||
32 | const char *birthLabel; | 32 | const char *birthLabel; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | |||
35 | /** | 36 | /** |
36 | * | 37 | * |
37 | * | 38 | * |
38 | * @param cls closure | 39 | * @param cls closure |
39 | * @param cmd current CMD being cleaned up. | 40 | */ |
40 | */ | ||
41 | static void | 41 | static void |
42 | hello_world_cleanup (void *cls, | 42 | hello_world_cleanup (void *cls) |
43 | const struct GNUNET_TESTING_Command *cmd) | ||
44 | { | 43 | { |
45 | struct HelloWorldState *hs = cls; | 44 | struct HelloWorldState *hs = cls; |
45 | |||
46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
47 | "Cleaning up message %s\n", | 47 | "Cleaning up message %s\n", |
48 | hs->message); | 48 | hs->message); |
49 | GNUNET_free (hs); | ||
49 | } | 50 | } |
50 | 51 | ||
52 | |||
51 | /** | 53 | /** |
52 | * | 54 | * |
53 | * | 55 | * |
54 | * @param cls closure. | 56 | * @param cls closure. |
55 | * @param[out] ret result | 57 | * @param[out] ret result |
56 | * @param trait name of the trait. | 58 | * @param trait name of the trait. |
57 | * @param index index number of the object to offer. | 59 | * @param index index number of the object to offer. |
58 | * @return #GNUNET_OK on success. | 60 | * @return #GNUNET_OK on success. |
59 | */ | 61 | */ |
60 | static int | 62 | static enum GNUNET_GenericReturnValue |
61 | hello_world_traits (void *cls, | 63 | hello_world_traits (void *cls, |
62 | const void **ret, | 64 | const void **ret, |
63 | const char *trait, | 65 | const char *trait, |
64 | unsigned int index) | 66 | unsigned int index) |
65 | { | 67 | { |
66 | return GNUNET_OK; | 68 | return GNUNET_NO; |
67 | } | 69 | } |
68 | 70 | ||
71 | |||
69 | /** | 72 | /** |
70 | * Run the "hello world" CMD. | 73 | * Run the "hello world" CMD. |
71 | * | 74 | * |
72 | * @param cls closure. | 75 | * @param cls closure. |
73 | * @param cmd CMD being run. | ||
74 | * @param is interpreter state. | 76 | * @param is interpreter state. |
75 | */ | 77 | */ |
76 | static void | 78 | static void |
77 | hello_world_run (void *cls, | 79 | hello_world_run (void *cls, |
78 | const struct GNUNET_TESTING_Command *cmd, | ||
79 | struct GNUNET_TESTING_Interpreter *is) | 80 | struct GNUNET_TESTING_Interpreter *is) |
80 | { | 81 | { |
81 | struct HelloWorldState *hs = cls; | 82 | struct HelloWorldState *hs = cls; |
@@ -84,13 +85,16 @@ hello_world_run (void *cls, | |||
84 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 85 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
85 | "%s\n", | 86 | "%s\n", |
86 | hs->message); | 87 | hs->message); |
87 | birth_cmd = GNUNET_TESTING_interpreter_lookup_command (hs->birthLabel); | 88 | birth_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
88 | GNUNET_TESTING_get_trait_what_am_i (birth_cmd, &hs->message); | 89 | hs->birthLabel); |
90 | GNUNET_TESTING_get_trait_what_am_i (birth_cmd, | ||
91 | &hs->message); | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 92 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
90 | "Now I am a %s\n", | 93 | "Now I am a %s\n", |
91 | hs->message); | 94 | hs->message); |
92 | } | 95 | } |
93 | 96 | ||
97 | |||
94 | /** | 98 | /** |
95 | * Create command. | 99 | * Create command. |
96 | * | 100 | * |
@@ -108,14 +112,15 @@ GNUNET_TESTING_cmd_hello_world (const char *label, | |||
108 | hs = GNUNET_new (struct HelloWorldState); | 112 | hs = GNUNET_new (struct HelloWorldState); |
109 | hs->message = "Hello World, I was nobody!"; | 113 | hs->message = "Hello World, I was nobody!"; |
110 | hs->birthLabel = birthLabel; | 114 | hs->birthLabel = birthLabel; |
115 | { | ||
116 | struct GNUNET_TESTING_Command cmd = { | ||
117 | .cls = hs, | ||
118 | .label = label, | ||
119 | .run = &hello_world_run, | ||
120 | .cleanup = &hello_world_cleanup, | ||
121 | .traits = &hello_world_traits | ||
122 | }; | ||
111 | 123 | ||
112 | struct GNUNET_TESTING_Command cmd = { | 124 | return cmd; |
113 | .cls = hs, | 125 | } |
114 | .label = label, | ||
115 | .run = &hello_world_run, | ||
116 | .cleanup = &hello_world_cleanup, | ||
117 | .traits = &hello_world_traits | ||
118 | }; | ||
119 | |||
120 | return cmd; | ||
121 | } | 126 | } |
diff --git a/src/testing/testing_api_cmd_hello_world_birth.c b/src/testing/testing_api_cmd_hello_world_birth.c index 9d60059a5..8415b99f0 100644 --- a/src/testing/testing_api_cmd_hello_world_birth.c +++ b/src/testing/testing_api_cmd_hello_world_birth.c | |||
@@ -40,8 +40,7 @@ struct HelloWorldBirthState | |||
40 | * @param cmd current CMD being cleaned up. | 40 | * @param cmd current CMD being cleaned up. |
41 | */ | 41 | */ |
42 | static void | 42 | static void |
43 | hello_world_birth_cleanup (void *cls, | 43 | hello_world_birth_cleanup (void *cls) |
44 | const struct GNUNET_TESTING_Command *cmd) | ||
45 | { | 44 | { |
46 | struct HelloWorldBirthState *hbs = cls; | 45 | struct HelloWorldBirthState *hbs = cls; |
47 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 46 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -49,6 +48,7 @@ hello_world_birth_cleanup (void *cls, | |||
49 | hbs->what_am_i); | 48 | hbs->what_am_i); |
50 | } | 49 | } |
51 | 50 | ||
51 | |||
52 | /** | 52 | /** |
53 | * | 53 | * |
54 | * | 54 | * |
@@ -82,6 +82,7 @@ hello_world_birth_traits (void *cls, | |||
82 | index); | 82 | index); |
83 | } | 83 | } |
84 | 84 | ||
85 | |||
85 | /** | 86 | /** |
86 | * Run the "hello world" CMD. | 87 | * Run the "hello world" CMD. |
87 | * | 88 | * |
@@ -91,14 +92,13 @@ hello_world_birth_traits (void *cls, | |||
91 | */ | 92 | */ |
92 | static void | 93 | static void |
93 | hello_world_birth_run (void *cls, | 94 | hello_world_birth_run (void *cls, |
94 | const struct GNUNET_TESTING_Command *cmd, | ||
95 | struct GNUNET_TESTING_Interpreter *is) | 95 | struct GNUNET_TESTING_Interpreter *is) |
96 | { | 96 | { |
97 | struct HelloWorldBirthState *hbs = cls; | 97 | struct HelloWorldBirthState *hbs = cls; |
98 | struct GNUNET_TIME_Relative relative; | 98 | struct GNUNET_TIME_Relative relative; |
99 | 99 | ||
100 | relative = GNUNET_TIME_absolute_get_difference (*hbs->date, | 100 | relative = GNUNET_TIME_absolute_get_difference (*hbs->date, |
101 | GNUNET_TIME_absolute_get ()); | 101 | GNUNET_TIME_absolute_get ()); |
102 | 102 | ||
103 | if (0 == relative.rel_value_us % 10) | 103 | if (0 == relative.rel_value_us % 10) |
104 | { | 104 | { |
@@ -114,6 +114,7 @@ hello_world_birth_run (void *cls, | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | |||
117 | /** | 118 | /** |
118 | * Offer data from trait | 119 | * Offer data from trait |
119 | * | 120 | * |
@@ -131,6 +132,7 @@ GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd, | |||
131 | (unsigned int) 0); | 132 | (unsigned int) 0); |
132 | } | 133 | } |
133 | 134 | ||
135 | |||
134 | /** | 136 | /** |
135 | * Create command. | 137 | * Create command. |
136 | * | 138 | * |
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c index b50e471e9..0e7e214dc 100644 --- a/src/testing/testing_api_cmd_local_test_finished.c +++ b/src/testing/testing_api_cmd_local_test_finished.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testing_api_cmd_block_until_all_peers_started.c | 22 | * @file testing_api_cmd_local_test_finished.c |
23 | * @brief cmd to block the interpreter loop until all peers started. | 23 | * @brief cmd to block the interpreter loop until all peers started. |
24 | * @author t3sserakt | 24 | * @author t3sserakt |
25 | */ | 25 | */ |
@@ -40,6 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | struct LocalFinishedState | 41 | struct LocalFinishedState |
42 | { | 42 | { |
43 | |||
43 | /** | 44 | /** |
44 | * Callback to write messages to the master loop. | 45 | * Callback to write messages to the master loop. |
45 | * | 46 | * |
@@ -55,26 +56,11 @@ struct LocalFinishedState | |||
55 | 56 | ||
56 | 57 | ||
57 | /** | 58 | /** |
58 | * Trait function of this cmd does nothing. | ||
59 | * | ||
60 | */ | ||
61 | static int | ||
62 | local_test_finished_traits (void *cls, | ||
63 | const void **ret, | ||
64 | const char *trait, | ||
65 | unsigned int index) | ||
66 | { | ||
67 | return GNUNET_OK; | ||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * The cleanup function of this cmd frees resources the cmd allocated. | 59 | * The cleanup function of this cmd frees resources the cmd allocated. |
73 | * | 60 | * |
74 | */ | 61 | */ |
75 | static void | 62 | static void |
76 | local_test_finished_cleanup (void *cls, | 63 | local_test_finished_cleanup (void *cls) |
77 | const struct GNUNET_TESTING_Command *cmd) | ||
78 | { | 64 | { |
79 | struct LocalFinishedState *lfs = cls; | 65 | struct LocalFinishedState *lfs = cls; |
80 | 66 | ||
@@ -89,11 +75,9 @@ local_test_finished_cleanup (void *cls, | |||
89 | */ | 75 | */ |
90 | static void | 76 | static void |
91 | local_test_finished_run (void *cls, | 77 | local_test_finished_run (void *cls, |
92 | const struct GNUNET_TESTING_Command *cmd, | ||
93 | struct GNUNET_TESTING_Interpreter *is) | 78 | struct GNUNET_TESTING_Interpreter *is) |
94 | { | 79 | { |
95 | struct LocalFinishedState *lfs = cls; | 80 | struct LocalFinishedState *lfs = cls; |
96 | |||
97 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | 81 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; |
98 | size_t msg_length; | 82 | size_t msg_length; |
99 | 83 | ||
@@ -102,22 +86,8 @@ local_test_finished_run (void *cls, | |||
102 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | 86 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); |
103 | reply->header.size = htons ((uint16_t) msg_length); | 87 | reply->header.size = htons ((uint16_t) msg_length); |
104 | lfs->reply = reply; | 88 | lfs->reply = reply; |
105 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | 89 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, |
106 | } | 90 | msg_length); |
107 | |||
108 | |||
109 | /** | ||
110 | * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. | ||
111 | * | ||
112 | */ | ||
113 | static int | ||
114 | local_test_finished_finish (void *cls, | ||
115 | GNUNET_SCHEDULER_TaskCallback cont, | ||
116 | void *cont_cls) | ||
117 | { | ||
118 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
119 | "Stopping local loop\n"); | ||
120 | return GNUNET_YES; | ||
121 | } | 91 | } |
122 | 92 | ||
123 | 93 | ||
@@ -129,23 +99,22 @@ local_test_finished_finish (void *cls, | |||
129 | * @return command. | 99 | * @return command. |
130 | */ | 100 | */ |
131 | struct GNUNET_TESTING_Command | 101 | struct GNUNET_TESTING_Command |
132 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | 102 | GNUNET_TESTING_cmd_local_test_finished ( |
133 | TESTING_CMD_HELPER_write_cb | 103 | const char *label, |
134 | write_message) | 104 | TESTING_CMD_HELPER_write_cb write_message) |
135 | { | 105 | { |
136 | struct LocalFinishedState *lfs; | 106 | struct LocalFinishedState *lfs; |
137 | 107 | ||
138 | lfs = GNUNET_new (struct LocalFinishedState); | 108 | lfs = GNUNET_new (struct LocalFinishedState); |
139 | lfs->write_message = write_message; | 109 | lfs->write_message = write_message; |
140 | 110 | { | |
141 | struct GNUNET_TESTING_Command cmd = { | 111 | struct GNUNET_TESTING_Command cmd = { |
142 | .cls = lfs, | 112 | .cls = lfs, |
143 | .label = label, | 113 | .label = label, |
144 | .run = &local_test_finished_run, | 114 | .run = &local_test_finished_run, |
145 | .finish = &local_test_finished_finish, | 115 | .cleanup = &local_test_finished_cleanup, |
146 | .cleanup = &local_test_finished_cleanup, | 116 | }; |
147 | .traits = &local_test_finished_traits | 117 | |
148 | }; | 118 | return cmd; |
149 | 119 | } | |
150 | return cmd; | ||
151 | } | 120 | } |
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c index 536b356a6..35fb90f3c 100644 --- a/src/testing/testing_api_cmd_netjail_start.c +++ b/src/testing/testing_api_cmd_netjail_start.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testing/testing_api_cmd_hello_world.c | 22 | * @file testing/testing_api_cmd_netjail_start.c |
23 | * @brief Command to start the netjail script. | 23 | * @brief Command to start the netjail script. |
24 | * @author t3sserakt | 24 | * @author t3sserakt |
25 | */ | 25 | */ |
@@ -35,22 +35,24 @@ | |||
35 | */ | 35 | */ |
36 | struct NetJailState | 36 | struct NetJailState |
37 | { | 37 | { |
38 | /** | ||
39 | * Context for our asynchronous completion. | ||
40 | */ | ||
41 | struct GNUNET_TESTING_AsyncContext ac; | ||
42 | |||
38 | // Child Wait handle | 43 | // Child Wait handle |
39 | struct GNUNET_ChildWaitHandle *cwh; | 44 | struct GNUNET_ChildWaitHandle *cwh; |
40 | 45 | ||
41 | // Number of local nodes in each namespace. | ||
42 | char *local_m; | ||
43 | |||
44 | // The number of namespaces. | ||
45 | char *global_n; | ||
46 | |||
47 | /** | 46 | /** |
48 | * The process id of the start script. | 47 | * The process id of the start script. |
49 | */ | 48 | */ |
50 | struct GNUNET_OS_Process *start_proc; | 49 | struct GNUNET_OS_Process *start_proc; |
51 | 50 | ||
52 | // Flag indication if the script finished. | 51 | /** |
53 | unsigned int finished; | 52 | * Configuration file for the test topology. |
53 | */ | ||
54 | char *topology_config; | ||
55 | |||
54 | }; | 56 | }; |
55 | 57 | ||
56 | 58 | ||
@@ -59,8 +61,7 @@ struct NetJailState | |||
59 | * | 61 | * |
60 | */ | 62 | */ |
61 | static void | 63 | static void |
62 | netjail_start_cleanup (void *cls, | 64 | netjail_start_cleanup (void *cls) |
63 | const struct GNUNET_TESTING_Command *cmd) | ||
64 | { | 65 | { |
65 | struct NetJailState *ns = cls; | 66 | struct NetJailState *ns = cls; |
66 | 67 | ||
@@ -87,20 +88,6 @@ netjail_start_cleanup (void *cls, | |||
87 | 88 | ||
88 | 89 | ||
89 | /** | 90 | /** |
90 | * Trait function of this cmd does nothing. | ||
91 | * | ||
92 | */ | ||
93 | static int | ||
94 | netjail_start_traits (void *cls, | ||
95 | const void **ret, | ||
96 | const char *trait, | ||
97 | unsigned int index) | ||
98 | { | ||
99 | return GNUNET_OK; | ||
100 | } | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Callback which will be called if the setup script finished. | 91 | * Callback which will be called if the setup script finished. |
105 | * | 92 | * |
106 | */ | 93 | */ |
@@ -111,40 +98,40 @@ child_completed_callback (void *cls, | |||
111 | { | 98 | { |
112 | struct NetJailState *ns = cls; | 99 | struct NetJailState *ns = cls; |
113 | 100 | ||
101 | GNUNET_OS_process_destroy (ns->start_proc); | ||
102 | ns->start_proc = NULL; | ||
114 | if (0 == exit_code) | 103 | if (0 == exit_code) |
115 | { | 104 | { |
116 | ns->finished = GNUNET_YES; | 105 | GNUNET_TESTING_async_finish (&ns->ac); |
117 | } | 106 | } |
118 | else | 107 | else |
119 | { | 108 | { |
120 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
121 | "Child completed with an error!\n"); | 110 | "Child failed with error %lu!\n", |
122 | ns->finished = GNUNET_SYSERR; | 111 | exit_code); |
112 | GNUNET_TESTING_async_fail (&ns->ac); | ||
123 | } | 113 | } |
124 | GNUNET_OS_process_destroy (ns->start_proc); | ||
125 | ns->start_proc = NULL; | ||
126 | } | 114 | } |
127 | 115 | ||
128 | 116 | ||
129 | |||
130 | /** | 117 | /** |
131 | * The run method starts the script which setup the network namespaces. | 118 | * The run method starts the script which setup the network namespaces. |
132 | * | 119 | * |
133 | * @param cls closure. | 120 | * @param cls closure. |
134 | * @param cmd CMD being run. | ||
135 | * @param is interpreter state. | 121 | * @param is interpreter state. |
136 | */ | 122 | */ |
137 | static void | 123 | static void |
138 | netjail_start_run (void *cls, | 124 | netjail_start_run (void *cls, |
139 | const struct GNUNET_TESTING_Command *cmd, | ||
140 | struct GNUNET_TESTING_Interpreter *is) | 125 | struct GNUNET_TESTING_Interpreter *is) |
141 | { | 126 | { |
142 | struct NetJailState *ns = cls; | 127 | struct NetJailState *ns = cls; |
143 | char *const script_argv[] = {NETJAIL_START_SCRIPT, | 128 | char pid[15]; |
144 | ns->local_m, | 129 | enum GNUNET_GenericReturnValue helper_check; |
145 | ns->global_n, | 130 | |
146 | NULL}; | 131 | // FIXME: NETJAIL_START_SCRIPT like this is bad, |
147 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | 132 | // use location from share/gnunet/ of installed |
133 | // binary in case libgnunettesting is used as a lib! | ||
134 | helper_check = GNUNET_OS_check_helper_binary ( | ||
148 | NETJAIL_START_SCRIPT, | 135 | NETJAIL_START_SCRIPT, |
149 | GNUNET_YES, | 136 | GNUNET_YES, |
150 | NULL); | 137 | NULL); |
@@ -154,23 +141,38 @@ netjail_start_run (void *cls, | |||
154 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 141 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
155 | "No SUID for %s!\n", | 142 | "No SUID for %s!\n", |
156 | NETJAIL_START_SCRIPT); | 143 | NETJAIL_START_SCRIPT); |
157 | GNUNET_TESTING_interpreter_fail (); | 144 | GNUNET_TESTING_interpreter_fail (is); |
145 | return; | ||
158 | } | 146 | } |
159 | else if (GNUNET_NO == helper_check) | 147 | if (GNUNET_SYSERR == helper_check) |
160 | { | 148 | { |
161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 149 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
162 | "%s not found!\n", | 150 | "%s not found!\n", |
163 | NETJAIL_START_SCRIPT); | 151 | NETJAIL_START_SCRIPT); |
164 | GNUNET_TESTING_interpreter_fail (); | 152 | GNUNET_TESTING_interpreter_fail (is); |
153 | return; | ||
165 | } | 154 | } |
166 | 155 | ||
167 | ns->start_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | 156 | GNUNET_snprintf (pid, |
168 | NULL, | 157 | sizeof (pid), |
169 | NULL, | 158 | "%u", |
170 | NULL, | 159 | getpid ()); |
171 | NETJAIL_START_SCRIPT, | 160 | { |
172 | script_argv); | 161 | char *const script_argv[] = { |
173 | 162 | NETJAIL_START_SCRIPT, | |
163 | ns->topology_config, | ||
164 | pid, | ||
165 | NULL | ||
166 | }; | ||
167 | |||
168 | ns->start_proc | ||
169 | = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | ||
170 | NULL, | ||
171 | NULL, | ||
172 | NULL, | ||
173 | NETJAIL_START_SCRIPT, | ||
174 | script_argv); | ||
175 | } | ||
174 | ns->cwh = GNUNET_wait_child (ns->start_proc, | 176 | ns->cwh = GNUNET_wait_child (ns->start_proc, |
175 | &child_completed_callback, | 177 | &child_completed_callback, |
176 | ns); | 178 | ns); |
@@ -179,51 +181,29 @@ netjail_start_run (void *cls, | |||
179 | 181 | ||
180 | 182 | ||
181 | /** | 183 | /** |
182 | * This function checks the flag NetJailState#finished, if this cmd finished. | ||
183 | * | ||
184 | */ | ||
185 | static int | ||
186 | netjail_start_finish (void *cls, | ||
187 | GNUNET_SCHEDULER_TaskCallback cont, | ||
188 | void *cont_cls) | ||
189 | { | ||
190 | struct NetJailState *ns = cls; | ||
191 | |||
192 | if (ns->finished) | ||
193 | { | ||
194 | cont (cont_cls); | ||
195 | } | ||
196 | return ns->finished; | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Create command. | 184 | * Create command. |
201 | * | 185 | * |
202 | * @param label name for command. | 186 | * @param label name for command. |
203 | * @param local_m Number of local nodes in each namespace. | 187 | * @param topology_config Configuration file for the test topology. |
204 | * @param global_n The number of namespaces. | ||
205 | * @return command. | 188 | * @return command. |
206 | */ | 189 | */ |
207 | struct GNUNET_TESTING_Command | 190 | struct GNUNET_TESTING_Command |
208 | GNUNET_TESTING_cmd_netjail_start (const char *label, | 191 | GNUNET_TESTING_cmd_netjail_start (const char *label, |
209 | char *local_m, | 192 | char *topology_config) |
210 | char *global_n) | ||
211 | { | 193 | { |
212 | struct NetJailState *ns; | 194 | struct NetJailState *ns; |
213 | 195 | ||
214 | ns = GNUNET_new (struct NetJailState); | 196 | ns = GNUNET_new (struct NetJailState); |
215 | ns->local_m = local_m; | 197 | ns->topology_config = topology_config; |
216 | ns->global_n = global_n; | 198 | { |
217 | ns->finished = GNUNET_NO; | 199 | struct GNUNET_TESTING_Command cmd = { |
218 | 200 | .cls = ns, | |
219 | struct GNUNET_TESTING_Command cmd = { | 201 | .label = label, |
220 | .cls = ns, | 202 | .run = &netjail_start_run, |
221 | .label = label, | 203 | .ac = &ns->ac, |
222 | .run = &netjail_start_run, | 204 | .cleanup = &netjail_start_cleanup |
223 | .finish = &netjail_start_finish, | 205 | }; |
224 | .cleanup = &netjail_start_cleanup, | 206 | |
225 | .traits = &netjail_start_traits | 207 | return cmd; |
226 | }; | 208 | } |
227 | |||
228 | return cmd; | ||
229 | } | 209 | } |
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c index 531621eb5..a1d71c436 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c | |||
@@ -62,6 +62,16 @@ struct HelperMessage | |||
62 | struct NetJailState | 62 | struct NetJailState |
63 | { | 63 | { |
64 | /** | 64 | /** |
65 | * Context for our asynchronous completion. | ||
66 | */ | ||
67 | struct GNUNET_TESTING_AsyncContext ac; | ||
68 | |||
69 | /** | ||
70 | * The complete topology information. | ||
71 | */ | ||
72 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
73 | |||
74 | /** | ||
65 | * Pointer to the return value of the test. | 75 | * Pointer to the return value of the test. |
66 | * | 76 | * |
67 | */ | 77 | */ |
@@ -91,16 +101,22 @@ struct NetJailState | |||
91 | unsigned int n_helper; | 101 | unsigned int n_helper; |
92 | 102 | ||
93 | /** | 103 | /** |
94 | * Number of nodes in a network namespace. //TODO make this a unsigned int | 104 | * Number of nodes in a natted subnet. |
95 | * | 105 | * |
96 | */ | 106 | */ |
97 | char *local_m; | 107 | unsigned int local_m; |
98 | 108 | ||
99 | /** | 109 | /** |
100 | * Number of network namespaces. //TODO make this a unsigned int | 110 | * Number of natted subnets. |
101 | * | 111 | * |
102 | */ | 112 | */ |
103 | char *global_n; | 113 | unsigned int global_n; |
114 | |||
115 | /** | ||
116 | * Number of global known nodes. | ||
117 | * | ||
118 | */ | ||
119 | unsigned int known; | ||
104 | 120 | ||
105 | /** | 121 | /** |
106 | * The send handle for the helper | 122 | * The send handle for the helper |
@@ -194,11 +210,9 @@ struct TestingSystemCount | |||
194 | * Code to clean up resource this cmd used. | 210 | * Code to clean up resource this cmd used. |
195 | * | 211 | * |
196 | * @param cls closure | 212 | * @param cls closure |
197 | * @param cmd current CMD being cleaned up. | ||
198 | */ | 213 | */ |
199 | static void | 214 | static void |
200 | netjail_exec_cleanup (void *cls, | 215 | netjail_exec_cleanup (void *cls) |
201 | const struct GNUNET_TESTING_Command *cmd) | ||
202 | { | 216 | { |
203 | struct NetJailState *ns = cls; | 217 | struct NetJailState *ns = cls; |
204 | struct HelperMessage *message_pos; | 218 | struct HelperMessage *message_pos; |
@@ -268,7 +282,8 @@ netjail_exec_traits (void *cls, | |||
268 | int | 282 | int |
269 | GNUNET_TESTING_get_trait_helper_handles (const struct | 283 | GNUNET_TESTING_get_trait_helper_handles (const struct |
270 | GNUNET_TESTING_Command *cmd, | 284 | GNUNET_TESTING_Command *cmd, |
271 | struct GNUNET_HELPER_Handle ***helper) | 285 | struct GNUNET_HELPER_Handle *** |
286 | helper) | ||
272 | { | 287 | { |
273 | return cmd->traits (cmd->cls, | 288 | return cmd->traits (cmd->cls, |
274 | (const void **) helper, | 289 | (const void **) helper, |
@@ -298,6 +313,43 @@ clear_msg (void *cls, int result) | |||
298 | } | 313 | } |
299 | 314 | ||
300 | 315 | ||
316 | static void | ||
317 | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | ||
318 | { | ||
319 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
320 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
321 | size_t msg_length; | ||
322 | struct GNUNET_HELPER_Handle *helper; | ||
323 | struct TestingSystemCount *tbc; | ||
324 | |||
325 | tbc = GNUNET_new (struct TestingSystemCount); | ||
326 | tbc->ns = ns; | ||
327 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
328 | if (0 == i) | ||
329 | tbc->count = j + total_number; | ||
330 | else | ||
331 | tbc->count = (i - 1) * ns->local_m + j + total_number + ns->known; | ||
332 | |||
333 | helper = ns->helper[tbc->count - 1 - total_number]; | ||
334 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
335 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
336 | reply->header.type = htons ( | ||
337 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
338 | reply->header.size = htons ((uint16_t) msg_length); | ||
339 | |||
340 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
341 | |||
342 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
343 | helper, | ||
344 | &reply->header, | ||
345 | GNUNET_NO, | ||
346 | &clear_msg, | ||
347 | tbc); | ||
348 | |||
349 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | ||
350 | } | ||
351 | |||
352 | |||
301 | /** | 353 | /** |
302 | * Functions with this signature are called whenever a | 354 | * Functions with this signature are called whenever a |
303 | * complete message is received by the tokenizer. | 355 | * complete message is received by the tokenizer. |
@@ -316,6 +368,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
316 | struct TestingSystemCount *tbc = cls; | 368 | struct TestingSystemCount *tbc = cls; |
317 | struct NetJailState *ns = tbc->ns; | 369 | struct NetJailState *ns = tbc->ns; |
318 | struct HelperMessage *hp_msg; | 370 | struct HelperMessage *hp_msg; |
371 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
319 | 372 | ||
320 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | 373 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) |
321 | { | 374 | { |
@@ -325,11 +378,31 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
325 | message->type)) | 378 | message->type)) |
326 | { | 379 | { |
327 | ns->number_of_peers_started++; | 380 | ns->number_of_peers_started++; |
381 | if (ns->number_of_peers_started == total_number) | ||
382 | { | ||
383 | for (int i = 1; i <= ns->known; i++) | ||
384 | { | ||
385 | send_all_peers_started (0,i, ns); | ||
386 | } | ||
387 | |||
388 | for (int i = 1; i <= ns->global_n; i++) | ||
389 | { | ||
390 | for (int j = 1; j <= ns->local_m; j++) | ||
391 | { | ||
392 | send_all_peers_started (i,j, ns); | ||
393 | } | ||
394 | } | ||
395 | ns->number_of_peers_started = 0; | ||
396 | } | ||
328 | } | 397 | } |
329 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( | 398 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( |
330 | message->type)) | 399 | message->type)) |
331 | { | 400 | { |
332 | ns->number_of_local_test_finished++; | 401 | ns->number_of_local_test_finished++; |
402 | if (ns->number_of_local_test_finished == total_number) | ||
403 | { | ||
404 | GNUNET_TESTING_async_finish (&ns->ac); | ||
405 | } | ||
333 | } | 406 | } |
334 | else | 407 | else |
335 | { | 408 | { |
@@ -340,6 +413,12 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
340 | hp_msg); | 413 | hp_msg); |
341 | } | 414 | } |
342 | 415 | ||
416 | |||
417 | |||
418 | |||
419 | |||
420 | |||
421 | |||
343 | return GNUNET_OK; | 422 | return GNUNET_OK; |
344 | } | 423 | } |
345 | 424 | ||
@@ -351,24 +430,21 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
351 | static void | 430 | static void |
352 | exp_cb (void *cls) | 431 | exp_cb (void *cls) |
353 | { | 432 | { |
354 | struct NetJailState *ns = cls; | 433 | struct TestingSystemCount *tbc = cls; |
434 | |||
355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); | 435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); |
356 | *ns->rv = 1; | 436 | GNUNET_TESTING_interpreter_fail (tbc->ns->ac.is); |
357 | } | 437 | } |
358 | 438 | ||
359 | 439 | ||
360 | /** | 440 | /** |
361 | * Function to initialize a init message for the helper. | 441 | * Function to initialize a init message for the helper. |
362 | * | 442 | * |
363 | * @param m_char The actual node in a namespace. //TODO Change this to unsigned int | ||
364 | * @param n_char The actual namespace. //TODO Change this to unsigned int | ||
365 | * @param plugin_name Name of the test case plugin the helper will load. | 443 | * @param plugin_name Name of the test case plugin the helper will load. |
366 | * | 444 | * |
367 | */ | 445 | */ |
368 | static struct GNUNET_CMDS_HelperInit * | 446 | static struct GNUNET_CMDS_HelperInit * |
369 | create_helper_init_msg_ (char *m_char, | 447 | create_helper_init_msg_ (const char *plugin_name) |
370 | char *n_char, | ||
371 | const char *plugin_name) | ||
372 | { | 448 | { |
373 | struct GNUNET_CMDS_HelperInit *msg; | 449 | struct GNUNET_CMDS_HelperInit *msg; |
374 | uint16_t plugin_name_len; | 450 | uint16_t plugin_name_len; |
@@ -395,22 +471,49 @@ create_helper_init_msg_ (char *m_char, | |||
395 | static void | 471 | static void |
396 | start_helper (struct NetJailState *ns, struct | 472 | start_helper (struct NetJailState *ns, struct |
397 | GNUNET_CONFIGURATION_Handle *config, | 473 | GNUNET_CONFIGURATION_Handle *config, |
398 | char *m_char, | 474 | unsigned int m, |
399 | char *n_char) | 475 | unsigned int n) |
400 | { | 476 | { |
401 | struct GNUNET_HELPER_Handle *helper; | 477 | struct GNUNET_HELPER_Handle *helper; |
402 | struct GNUNET_CMDS_HelperInit *msg; | 478 | struct GNUNET_CMDS_HelperInit *msg; |
403 | struct TestingSystemCount *tbc; | 479 | struct TestingSystemCount *tbc; |
480 | char *m_char, *n_char, *global_n_char, *local_m_char, *known_char, *node_id, | ||
481 | *plugin; | ||
482 | pid_t pid; | ||
483 | unsigned int script_num; | ||
484 | struct GNUNET_ShortHashCode *hkey; | ||
485 | struct GNUNET_HashCode hc; | ||
486 | struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; | ||
487 | struct GNUNET_TESTING_NetjailNode *node; | ||
488 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
489 | |||
490 | |||
491 | if (0 == n) | ||
492 | script_num = m - 1; | ||
493 | else | ||
494 | script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known; | ||
495 | pid = getpid (); | ||
496 | |||
497 | GNUNET_asprintf (&m_char, "%u", m); | ||
498 | GNUNET_asprintf (&n_char, "%u", n); | ||
499 | GNUNET_asprintf (&local_m_char, "%u", ns->local_m); | ||
500 | GNUNET_asprintf (&global_n_char, "%u",ns->global_n); | ||
501 | GNUNET_asprintf (&known_char, "%u",ns->known); | ||
502 | GNUNET_asprintf (&node_id, "%06x-%08x\n", | ||
503 | pid, | ||
504 | script_num); | ||
505 | |||
506 | |||
404 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | 507 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, |
405 | m_char, | 508 | m_char, |
406 | n_char, | 509 | n_char, |
407 | GNUNET_OS_get_libexec_binary_path ( | 510 | GNUNET_OS_get_libexec_binary_path ( |
408 | HELPER_CMDS_BINARY), | 511 | HELPER_CMDS_BINARY), |
409 | ns->global_n, | 512 | global_n_char, |
410 | ns->local_m, | 513 | local_m_char, |
514 | node_id, | ||
411 | NULL}; | 515 | NULL}; |
412 | unsigned int m = atoi (m_char); | 516 | |
413 | unsigned int n = atoi (n_char); | ||
414 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | 517 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
415 | NETJAIL_EXEC_SCRIPT, | 518 | NETJAIL_EXEC_SCRIPT, |
416 | GNUNET_YES, | 519 | GNUNET_YES, |
@@ -418,7 +521,10 @@ start_helper (struct NetJailState *ns, struct | |||
418 | 521 | ||
419 | tbc = GNUNET_new (struct TestingSystemCount); | 522 | tbc = GNUNET_new (struct TestingSystemCount); |
420 | tbc->ns = ns; | 523 | tbc->ns = ns; |
421 | tbc->count = (n - 1) * atoi (ns->local_m) + m; | 524 | if (0 == n) |
525 | tbc->count = m; | ||
526 | else | ||
527 | tbc->count = (n - 1) * ns->local_m + m + ns->known; | ||
422 | 528 | ||
423 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, | 529 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, |
424 | tbc); | 530 | tbc); |
@@ -429,14 +535,14 @@ start_helper (struct NetJailState *ns, struct | |||
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
430 | "No SUID for %s!\n", | 536 | "No SUID for %s!\n", |
431 | NETJAIL_EXEC_SCRIPT); | 537 | NETJAIL_EXEC_SCRIPT); |
432 | *ns->rv = 1; | 538 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
433 | } | 539 | } |
434 | else if (GNUNET_NO == helper_check) | 540 | else if (GNUNET_NO == helper_check) |
435 | { | 541 | { |
436 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
437 | "%s not found!\n", | 543 | "%s not found!\n", |
438 | NETJAIL_EXEC_SCRIPT); | 544 | NETJAIL_EXEC_SCRIPT); |
439 | *ns->rv = 1; | 545 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
440 | } | 546 | } |
441 | 547 | ||
442 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( | 548 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( |
@@ -449,9 +555,57 @@ start_helper (struct NetJailState *ns, struct | |||
449 | 555 | ||
450 | helper = ns->helper[tbc->count - 1]; | 556 | helper = ns->helper[tbc->count - 1]; |
451 | 557 | ||
452 | msg = create_helper_init_msg_ (m_char, | 558 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
453 | n_char, | 559 | |
454 | ns->plugin_name); | 560 | plugin = topology->plugin; |
561 | |||
562 | if (0 == m) | ||
563 | { | ||
564 | |||
565 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
566 | memcpy (hkey, | ||
567 | &hc, | ||
568 | sizeof (*hkey)); | ||
569 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_globals, | ||
570 | hkey)) | ||
571 | { | ||
572 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
573 | hkey); | ||
574 | if (NULL != node->plugin) | ||
575 | plugin = node->plugin; | ||
576 | } | ||
577 | |||
578 | } | ||
579 | else | ||
580 | { | ||
581 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); | ||
582 | memcpy (hkey, | ||
583 | &hc, | ||
584 | sizeof (*hkey)); | ||
585 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_namespaces, | ||
586 | hkey)) | ||
587 | { | ||
588 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
589 | hkey); | ||
590 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
591 | memcpy (hkey, | ||
592 | &hc, | ||
593 | sizeof (*hkey)); | ||
594 | if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes, | ||
595 | hkey)) | ||
596 | { | ||
597 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
598 | hkey); | ||
599 | if (NULL != node->plugin) | ||
600 | plugin = node->plugin; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | |||
605 | } | ||
606 | |||
607 | msg = create_helper_init_msg_ (plugin); | ||
608 | |||
455 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | 609 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); |
456 | 610 | ||
457 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | 611 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( |
@@ -466,7 +620,7 @@ start_helper (struct NetJailState *ns, struct | |||
466 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 620 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
467 | "Send handle is NULL!\n"); | 621 | "Send handle is NULL!\n"); |
468 | GNUNET_free (msg); | 622 | GNUNET_free (msg); |
469 | *ns->rv = 1; | 623 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
470 | } | 624 | } |
471 | } | 625 | } |
472 | 626 | ||
@@ -480,95 +634,28 @@ start_helper (struct NetJailState *ns, struct | |||
480 | */ | 634 | */ |
481 | static void | 635 | static void |
482 | netjail_exec_run (void *cls, | 636 | netjail_exec_run (void *cls, |
483 | const struct GNUNET_TESTING_Command *cmd, | ||
484 | struct GNUNET_TESTING_Interpreter *is) | 637 | struct GNUNET_TESTING_Interpreter *is) |
485 | { | 638 | { |
486 | char str_m[12]; | ||
487 | char str_n[12]; | ||
488 | struct NetJailState *ns = cls; | 639 | struct NetJailState *ns = cls; |
489 | struct GNUNET_CONFIGURATION_Handle *config = | 640 | struct GNUNET_CONFIGURATION_Handle *config = |
490 | GNUNET_CONFIGURATION_create (); | 641 | GNUNET_CONFIGURATION_create (); |
491 | 642 | ||
492 | for (int i = 1; i <= atoi (ns->global_n); i++) | 643 | for (int i = 1; i <= ns->known; i++) |
493 | { | 644 | { |
494 | for (int j = 1; j <= atoi (ns->local_m); j++) | 645 | start_helper (ns, config, |
495 | { | 646 | i, |
496 | sprintf (str_n, "%d", i); | 647 | 0); |
497 | sprintf (str_m, "%d", j); | ||
498 | start_helper (ns, config, | ||
499 | str_m, | ||
500 | str_n); | ||
501 | } | ||
502 | } | 648 | } |
503 | } | ||
504 | 649 | ||
505 | 650 | for (int i = 1; i <= ns->global_n; i++) | |
506 | /** | ||
507 | * This function checks on three different information. | ||
508 | * | ||
509 | * 1. Did all helpers start. This is only logged. | ||
510 | * 2. Did all peer start. | ||
511 | * In this case a GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED is send to all peers. | ||
512 | * 3. Did all peers finished the test case. In this case interpreter_next will be called. | ||
513 | * | ||
514 | */ | ||
515 | static int | ||
516 | netjail_start_finish (void *cls, | ||
517 | GNUNET_SCHEDULER_TaskCallback cont, | ||
518 | void *cont_cls) | ||
519 | { | ||
520 | unsigned int ret = GNUNET_NO; | ||
521 | struct NetJailState *ns = cls; | ||
522 | unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n); | ||
523 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
524 | size_t msg_length; | ||
525 | struct GNUNET_HELPER_Handle *helper; | ||
526 | struct TestingSystemCount *tbc; | ||
527 | |||
528 | if (ns->number_of_local_test_finished == total_number) | ||
529 | { | ||
530 | ret = GNUNET_YES; | ||
531 | cont (cont_cls); | ||
532 | } | ||
533 | |||
534 | if (ns->number_of_testsystems_started == total_number) | ||
535 | { | ||
536 | ns->number_of_testsystems_started = 0; | ||
537 | } | ||
538 | |||
539 | if (ns->number_of_peers_started == total_number) | ||
540 | { | 651 | { |
541 | for (int i = 1; i <= atoi (ns->global_n); i++) | 652 | for (int j = 1; j <= ns->local_m; j++) |
542 | { | 653 | { |
543 | for (int j = 1; j <= atoi (ns->local_m); j++) | 654 | start_helper (ns, config, |
544 | { | 655 | j, |
545 | tbc = GNUNET_new (struct TestingSystemCount); | 656 | i); |
546 | tbc->ns = ns; | ||
547 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
548 | tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; | ||
549 | |||
550 | helper = ns->helper[tbc->count - 1 - total_number]; | ||
551 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
552 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
553 | reply->header.type = htons ( | ||
554 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
555 | reply->header.size = htons ((uint16_t) msg_length); | ||
556 | |||
557 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
558 | |||
559 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
560 | helper, | ||
561 | &reply->header, | ||
562 | GNUNET_NO, | ||
563 | &clear_msg, | ||
564 | tbc); | ||
565 | |||
566 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | ||
567 | } | ||
568 | } | 657 | } |
569 | ns->number_of_peers_started = 0; | ||
570 | } | 658 | } |
571 | return ret; | ||
572 | } | 659 | } |
573 | 660 | ||
574 | 661 | ||
@@ -576,32 +663,30 @@ netjail_start_finish (void *cls, | |||
576 | * Create command. | 663 | * Create command. |
577 | * | 664 | * |
578 | * @param label Name for the command. | 665 | * @param label Name for the command. |
579 | * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int | 666 | * @param topology_config Configuration file for the test topology. |
580 | * @param global_n Number of network namespaces. //TODO make this a unsigned int | ||
581 | * @param plugin_name Name of the test case plugin the helper will load. | ||
582 | * @param rv Pointer to the return value of the test. | ||
583 | * @return command. | 667 | * @return command. |
584 | */ | 668 | */ |
585 | struct GNUNET_TESTING_Command | 669 | struct GNUNET_TESTING_Command |
586 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | 670 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, |
587 | char *local_m, | 671 | const char *topology_config) |
588 | char *global_n, | ||
589 | char *plugin_name, | ||
590 | unsigned int *rv) | ||
591 | { | 672 | { |
592 | struct NetJailState *ns; | 673 | struct NetJailState *ns; |
593 | 674 | ||
675 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
676 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
677 | |||
594 | ns = GNUNET_new (struct NetJailState); | 678 | ns = GNUNET_new (struct NetJailState); |
595 | ns->local_m = local_m; | 679 | ns->local_m = topology->nodes_m; |
596 | ns->global_n = global_n; | 680 | ns->global_n = topology->namespaces_n; |
597 | ns->plugin_name = plugin_name; | 681 | ns->known = topology->nodes_x; |
598 | ns->rv = rv; | 682 | ns->plugin_name = topology->plugin; |
683 | ns->topology = topology; | ||
599 | 684 | ||
600 | struct GNUNET_TESTING_Command cmd = { | 685 | struct GNUNET_TESTING_Command cmd = { |
601 | .cls = ns, | 686 | .cls = ns, |
602 | .label = label, | 687 | .label = label, |
603 | .run = &netjail_exec_run, | 688 | .run = &netjail_exec_run, |
604 | .finish = &netjail_start_finish, | 689 | .ac = &ns->ac, |
605 | .cleanup = &netjail_exec_cleanup, | 690 | .cleanup = &netjail_exec_cleanup, |
606 | .traits = &netjail_exec_traits | 691 | .traits = &netjail_exec_traits |
607 | }; | 692 | }; |
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c b/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c deleted file mode 100644 index 5e27a7a82..000000000 --- a/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c +++ /dev/null | |||
@@ -1,809 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to start the netjail peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "testing_cmds.h" | ||
29 | |||
30 | #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec_v2.sh" | ||
31 | |||
32 | /** | ||
33 | * Generic logging shortcut | ||
34 | */ | ||
35 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
36 | |||
37 | /** | ||
38 | * Struct to store messages send/received by the helper into a DLL | ||
39 | * | ||
40 | */ | ||
41 | struct HelperMessage | ||
42 | { | ||
43 | |||
44 | /** | ||
45 | * Kept in a DLL. | ||
46 | */ | ||
47 | struct HelperMessage *next; | ||
48 | |||
49 | /** | ||
50 | * Kept in a DLL. | ||
51 | */ | ||
52 | struct HelperMessage *prev; | ||
53 | |||
54 | /** | ||
55 | * Size of the original message. | ||
56 | */ | ||
57 | uint16_t bytes_msg; | ||
58 | |||
59 | /* Followed by @e bytes_msg of msg.*/ | ||
60 | }; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Struct to store information handed over to callbacks. | ||
65 | * | ||
66 | */ | ||
67 | struct NetJailState | ||
68 | { | ||
69 | /** | ||
70 | * The complete topology information. | ||
71 | */ | ||
72 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
73 | |||
74 | /** | ||
75 | * Pointer to the return value of the test. | ||
76 | * | ||
77 | */ | ||
78 | unsigned int *rv; | ||
79 | |||
80 | /** | ||
81 | * Head of the DLL which stores messages received by the helper. | ||
82 | * | ||
83 | */ | ||
84 | struct HelperMessage *hp_messages_head; | ||
85 | |||
86 | /** | ||
87 | * Tail of the DLL which stores messages received by the helper. | ||
88 | * | ||
89 | */ | ||
90 | struct HelperMessage *hp_messages_tail; | ||
91 | |||
92 | /** | ||
93 | * Array with handles of helper processes. | ||
94 | */ | ||
95 | struct GNUNET_HELPER_Handle **helper; | ||
96 | |||
97 | /** | ||
98 | * Size of the array NetJailState#helper. | ||
99 | * | ||
100 | */ | ||
101 | unsigned int n_helper; | ||
102 | |||
103 | /** | ||
104 | * Number of nodes in a natted subnet. | ||
105 | * | ||
106 | */ | ||
107 | unsigned int local_m; | ||
108 | |||
109 | /** | ||
110 | * Number of natted subnets. | ||
111 | * | ||
112 | */ | ||
113 | unsigned int global_n; | ||
114 | |||
115 | /** | ||
116 | * Number of global known nodes. | ||
117 | * | ||
118 | */ | ||
119 | unsigned int known; | ||
120 | |||
121 | /** | ||
122 | * The send handle for the helper | ||
123 | */ | ||
124 | // struct GNUNET_HELPER_SendHandle **shandle; | ||
125 | |||
126 | /** | ||
127 | * Size of the array NetJailState#shandle. | ||
128 | * | ||
129 | */ | ||
130 | // unsigned int n_shandle; | ||
131 | |||
132 | /** | ||
133 | * The messages send to the helper. | ||
134 | */ | ||
135 | struct GNUNET_MessageHeader **msg; | ||
136 | |||
137 | /** | ||
138 | * Size of the array NetJailState#msg. | ||
139 | * | ||
140 | */ | ||
141 | unsigned int n_msg; | ||
142 | |||
143 | /** | ||
144 | * Number of test environments started. | ||
145 | * | ||
146 | */ | ||
147 | unsigned int number_of_testsystems_started; | ||
148 | |||
149 | /** | ||
150 | * Number of peers started. | ||
151 | * | ||
152 | */ | ||
153 | unsigned int number_of_peers_started; | ||
154 | |||
155 | /** | ||
156 | * Number of local tests finished. | ||
157 | * | ||
158 | */ | ||
159 | unsigned int number_of_local_tests_finished; | ||
160 | |||
161 | /** | ||
162 | * Number of local tests prepared to finish. | ||
163 | * | ||
164 | */ | ||
165 | unsigned int number_of_local_tests_prepared; | ||
166 | |||
167 | /** | ||
168 | * Name of the test case plugin the helper will load. | ||
169 | * | ||
170 | */ | ||
171 | char *plugin_name; | ||
172 | |||
173 | /** | ||
174 | * HEAD of the DLL containing TestingSystemCount. | ||
175 | * | ||
176 | */ | ||
177 | struct TestingSystemCount *tbcs_head; | ||
178 | |||
179 | /** | ||
180 | * TAIL of the DLL containing TestingSystemCount. | ||
181 | * | ||
182 | */ | ||
183 | struct TestingSystemCount *tbcs_tail; | ||
184 | }; | ||
185 | |||
186 | /** | ||
187 | * Struct containing the number of the test environment and the NetJailState which | ||
188 | * will be handed to callbacks specific to a test environment. | ||
189 | */ | ||
190 | struct TestingSystemCount | ||
191 | { | ||
192 | /** | ||
193 | * Kept in a DLL. | ||
194 | */ | ||
195 | struct TestingSystemCount *next; | ||
196 | |||
197 | /** | ||
198 | * Kept in a DLL. | ||
199 | */ | ||
200 | struct TestingSystemCount *prev; | ||
201 | |||
202 | /** | ||
203 | * The send handle for the helper | ||
204 | */ | ||
205 | struct GNUNET_HELPER_SendHandle *shandle;// **shandle; | ||
206 | |||
207 | /** | ||
208 | * Size of the array NetJailState#shandle. | ||
209 | * | ||
210 | */ | ||
211 | // unsigned int n_shandle; | ||
212 | |||
213 | /** | ||
214 | * The number of the test environment. | ||
215 | * | ||
216 | */ | ||
217 | unsigned int count; | ||
218 | |||
219 | /** | ||
220 | * Struct to store information handed over to callbacks. | ||
221 | * | ||
222 | */ | ||
223 | struct NetJailState *ns; | ||
224 | }; | ||
225 | |||
226 | /** | ||
227 | * Code to clean up resource this cmd used. | ||
228 | * | ||
229 | * @param cls closure | ||
230 | * @param cmd current CMD being cleaned up. | ||
231 | */ | ||
232 | static void | ||
233 | netjail_exec_cleanup (void *cls, | ||
234 | const struct GNUNET_TESTING_Command *cmd) | ||
235 | { | ||
236 | struct NetJailState *ns = cls; | ||
237 | struct HelperMessage *message_pos; | ||
238 | struct TestingSystemCount *tbc_pos; | ||
239 | |||
240 | while (NULL != (message_pos = ns->hp_messages_head)) | ||
241 | { | ||
242 | GNUNET_CONTAINER_DLL_remove (ns->hp_messages_head, | ||
243 | ns->hp_messages_tail, | ||
244 | message_pos); | ||
245 | GNUNET_free (message_pos); | ||
246 | } | ||
247 | while (NULL != (tbc_pos = ns->tbcs_head)) | ||
248 | { | ||
249 | GNUNET_CONTAINER_DLL_remove (ns->tbcs_head, | ||
250 | ns->tbcs_tail, | ||
251 | tbc_pos); | ||
252 | GNUNET_free (tbc_pos); | ||
253 | } | ||
254 | GNUNET_free (ns); | ||
255 | } | ||
256 | |||
257 | |||
258 | /** | ||
259 | * This function prepares an array with traits. | ||
260 | * | ||
261 | */ | ||
262 | static int | ||
263 | netjail_exec_traits (void *cls, | ||
264 | const void **ret, | ||
265 | const char *trait, | ||
266 | unsigned int index) | ||
267 | { | ||
268 | struct NetJailState *ns = cls; | ||
269 | struct GNUNET_HELPER_Handle **helper = ns->helper; | ||
270 | struct HelperMessage *hp_messages_head = ns->hp_messages_head; | ||
271 | |||
272 | |||
273 | struct GNUNET_TESTING_Trait traits[] = { | ||
274 | { | ||
275 | .index = 0, | ||
276 | .trait_name = "helper_handles", | ||
277 | .ptr = (const void *) helper, | ||
278 | }, | ||
279 | { | ||
280 | .index = 1, | ||
281 | .trait_name = "hp_msgs_head", | ||
282 | .ptr = (const void *) hp_messages_head, | ||
283 | }, | ||
284 | GNUNET_TESTING_trait_end () | ||
285 | }; | ||
286 | |||
287 | return GNUNET_TESTING_get_trait (traits, | ||
288 | ret, | ||
289 | trait, | ||
290 | index); | ||
291 | } | ||
292 | |||
293 | |||
294 | /** | ||
295 | * Offer handles to testing cmd helper from trait | ||
296 | * | ||
297 | * @param cmd command to extract the message from. | ||
298 | * @param pt pointer to message. | ||
299 | * @return #GNUNET_OK on success. | ||
300 | */ | ||
301 | int | ||
302 | GNUNET_TESTING_get_trait_helper_handles_v2 ( | ||
303 | const struct GNUNET_TESTING_Command *cmd, | ||
304 | struct GNUNET_HELPER_Handle ***helper) | ||
305 | { | ||
306 | return cmd->traits (cmd->cls, | ||
307 | (const void **) helper, | ||
308 | "helper_handles", | ||
309 | (unsigned int) 0); | ||
310 | } | ||
311 | |||
312 | |||
313 | /** | ||
314 | * Continuation function from GNUNET_HELPER_send() | ||
315 | * | ||
316 | * @param cls closure | ||
317 | * @param result #GNUNET_OK on success, | ||
318 | * #GNUNET_NO if helper process died | ||
319 | * #GNUNET_SYSERR during GNUNET_HELPER_stop | ||
320 | */ | ||
321 | static void | ||
322 | clear_msg (void *cls, | ||
323 | int result) | ||
324 | { | ||
325 | struct TestingSystemCount *tbc = cls; | ||
326 | struct NetJailState *ns = tbc->ns; | ||
327 | |||
328 | GNUNET_assert (NULL != tbc->shandle);// [tbc->count - 1]); | ||
329 | tbc->shandle = NULL;// [tbc->count - 1] = NULL; | ||
330 | GNUNET_free (ns->msg[tbc->count - 1]); | ||
331 | ns->msg[tbc->count - 1] = NULL; | ||
332 | } | ||
333 | |||
334 | |||
335 | /** | ||
336 | * Functions with this signature are called whenever a | ||
337 | * complete message is received by the tokenizer. | ||
338 | * | ||
339 | * Do not call GNUNET_SERVER_mst_destroy in callback | ||
340 | * | ||
341 | * @param cls closure | ||
342 | * @param client identification of the client | ||
343 | * @param message the actual message | ||
344 | * | ||
345 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | ||
346 | */ | ||
347 | static int | ||
348 | helper_mst (void *cls, | ||
349 | const struct GNUNET_MessageHeader *message) | ||
350 | { | ||
351 | // struct TestingSystemCount *tbc = cls; | ||
352 | struct NetJailState *ns = cls;// tbc->ns; | ||
353 | struct HelperMessage *hp_msg; | ||
354 | |||
355 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | ||
356 | { | ||
357 | ns->number_of_testsystems_started++; | ||
358 | } | ||
359 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( | ||
360 | message->type)) | ||
361 | { | ||
362 | ns->number_of_peers_started++; | ||
363 | } | ||
364 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs ( | ||
365 | message->type)) | ||
366 | { | ||
367 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
368 | "received prepare msg %u\n", | ||
369 | ns->number_of_local_tests_prepared); | ||
370 | ns->number_of_local_tests_prepared++; | ||
371 | } | ||
372 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( | ||
373 | message->type)) | ||
374 | { | ||
375 | ns->number_of_local_tests_finished++; | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | hp_msg = GNUNET_new (struct HelperMessage); | ||
380 | hp_msg->bytes_msg = message->size; | ||
381 | memcpy (&hp_msg[1], message, message->size); | ||
382 | GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail, | ||
383 | hp_msg); | ||
384 | } | ||
385 | |||
386 | return GNUNET_OK; | ||
387 | } | ||
388 | |||
389 | |||
390 | /** | ||
391 | * Callback called if there was an exception during execution of the helper. | ||
392 | * | ||
393 | */ | ||
394 | static void | ||
395 | exp_cb (void *cls) | ||
396 | { | ||
397 | struct NetJailState *ns = cls; | ||
398 | unsigned int *rv = ns->rv; | ||
399 | |||
400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); | ||
401 | *rv = 1; | ||
402 | } | ||
403 | |||
404 | |||
405 | /** | ||
406 | * Function to initialize a init message for the helper. | ||
407 | * | ||
408 | * @param m_char The actual node in a namespace. //TODO Change this to unsigned int | ||
409 | * @param n_char The actual namespace. //TODO Change this to unsigned int | ||
410 | * @param plugin_name Name of the test case plugin the helper will load. | ||
411 | * | ||
412 | */ | ||
413 | static struct GNUNET_CMDS_HelperInit * | ||
414 | create_helper_init_msg_ (const char *plugin_name) | ||
415 | { | ||
416 | struct GNUNET_CMDS_HelperInit *msg; | ||
417 | uint16_t plugin_name_len; | ||
418 | uint16_t msg_size; | ||
419 | |||
420 | GNUNET_assert (NULL != plugin_name); | ||
421 | plugin_name_len = strlen (plugin_name); | ||
422 | msg_size = sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_len; | ||
423 | msg = GNUNET_malloc (msg_size); | ||
424 | msg->header.size = htons (msg_size); | ||
425 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT); | ||
426 | msg->plugin_name_size = htons (plugin_name_len); | ||
427 | GNUNET_memcpy ((char *) &msg[1], | ||
428 | plugin_name, | ||
429 | plugin_name_len); | ||
430 | return msg; | ||
431 | } | ||
432 | |||
433 | |||
434 | /** | ||
435 | * Function which start a single helper process. | ||
436 | * | ||
437 | */ | ||
438 | static void | ||
439 | start_helper (struct NetJailState *ns, struct | ||
440 | GNUNET_CONFIGURATION_Handle *config, | ||
441 | unsigned int m, | ||
442 | unsigned int n) | ||
443 | { | ||
444 | struct GNUNET_HELPER_Handle *helper; | ||
445 | struct GNUNET_CMDS_HelperInit *msg; | ||
446 | struct TestingSystemCount *tbc; | ||
447 | char *m_char, *n_char, *global_n_char, *local_m_char, *known_char, *node_id, | ||
448 | *plugin; | ||
449 | pid_t pid; | ||
450 | unsigned int script_num; | ||
451 | struct GNUNET_ShortHashCode *hkey; | ||
452 | struct GNUNET_HashCode hc; | ||
453 | struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; | ||
454 | struct GNUNET_TESTING_NetjailNode *node; | ||
455 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
456 | unsigned int *rv = ns->rv; | ||
457 | |||
458 | |||
459 | if (0 == n) | ||
460 | script_num = m - 1; | ||
461 | else | ||
462 | script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known; | ||
463 | pid = getpid (); | ||
464 | |||
465 | GNUNET_asprintf (&m_char, "%u", m); | ||
466 | GNUNET_asprintf (&n_char, "%u", n); | ||
467 | GNUNET_asprintf (&local_m_char, "%u", ns->local_m); | ||
468 | GNUNET_asprintf (&global_n_char, "%u",ns->global_n); | ||
469 | GNUNET_asprintf (&known_char, "%u",ns->known); | ||
470 | GNUNET_asprintf (&node_id, "%06x-%08x\n", | ||
471 | pid, | ||
472 | script_num); | ||
473 | |||
474 | |||
475 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | ||
476 | m_char, | ||
477 | n_char, | ||
478 | GNUNET_OS_get_libexec_binary_path ( | ||
479 | HELPER_CMDS_BINARY), | ||
480 | global_n_char, | ||
481 | local_m_char, | ||
482 | node_id, | ||
483 | NULL}; | ||
484 | |||
485 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | ||
486 | NETJAIL_EXEC_SCRIPT, | ||
487 | GNUNET_YES, | ||
488 | NULL); | ||
489 | |||
490 | tbc = GNUNET_new (struct TestingSystemCount); | ||
491 | tbc->ns = ns; | ||
492 | if (0 == n) | ||
493 | tbc->count = m; | ||
494 | else | ||
495 | tbc->count = (n - 1) * ns->local_m + m + ns->known; | ||
496 | |||
497 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, | ||
498 | ns->tbcs_tail, | ||
499 | tbc); | ||
500 | |||
501 | |||
502 | if (GNUNET_NO == helper_check) | ||
503 | { | ||
504 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
505 | "No SUID for %s!\n", | ||
506 | NETJAIL_EXEC_SCRIPT); | ||
507 | *rv = 1; | ||
508 | } | ||
509 | else if (GNUNET_NO == helper_check) | ||
510 | { | ||
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
512 | "%s not found!\n", | ||
513 | NETJAIL_EXEC_SCRIPT); | ||
514 | *rv = 1; | ||
515 | } | ||
516 | |||
517 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( | ||
518 | GNUNET_YES, | ||
519 | NETJAIL_EXEC_SCRIPT, | ||
520 | script_argv, | ||
521 | &helper_mst, | ||
522 | &exp_cb, | ||
523 | ns)); | ||
524 | |||
525 | helper = ns->helper[tbc->count - 1]; | ||
526 | |||
527 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
528 | |||
529 | plugin = topology->plugin; | ||
530 | |||
531 | if (0 == m) | ||
532 | { | ||
533 | |||
534 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
535 | memcpy (hkey, | ||
536 | &hc, | ||
537 | sizeof (*hkey)); | ||
538 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_globals, | ||
539 | hkey)) | ||
540 | { | ||
541 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
542 | hkey); | ||
543 | if (NULL != node->plugin) | ||
544 | plugin = node->plugin; | ||
545 | } | ||
546 | |||
547 | } | ||
548 | else | ||
549 | { | ||
550 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); | ||
551 | memcpy (hkey, | ||
552 | &hc, | ||
553 | sizeof (*hkey)); | ||
554 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_namespaces, | ||
555 | hkey)) | ||
556 | { | ||
557 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
558 | hkey); | ||
559 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
560 | memcpy (hkey, | ||
561 | &hc, | ||
562 | sizeof (*hkey)); | ||
563 | if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes, | ||
564 | hkey)) | ||
565 | { | ||
566 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
567 | hkey); | ||
568 | if (NULL != node->plugin) | ||
569 | plugin = node->plugin; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | |||
574 | } | ||
575 | |||
576 | msg = create_helper_init_msg_ (plugin); | ||
577 | |||
578 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | ||
579 | |||
580 | // GNUNET_array_append (tbc->shandle, tbc->n_shandle, | ||
581 | tbc->shandle = GNUNET_HELPER_send ( | ||
582 | helper, | ||
583 | &msg->header, | ||
584 | GNUNET_NO, | ||
585 | &clear_msg, | ||
586 | tbc); // ); | ||
587 | |||
588 | if (NULL == tbc->shandle)// [tbc->count - 1]) | ||
589 | { | ||
590 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
591 | "Send handle is NULL!\n"); | ||
592 | GNUNET_free (msg); | ||
593 | *rv = 1; | ||
594 | } | ||
595 | } | ||
596 | |||
597 | |||
598 | /** | ||
599 | * This function starts a helper process for each node. | ||
600 | * | ||
601 | * @param cls closure. | ||
602 | * @param cmd CMD being run. | ||
603 | * @param is interpreter state. | ||
604 | */ | ||
605 | static void | ||
606 | netjail_exec_run (void *cls, | ||
607 | const struct GNUNET_TESTING_Command *cmd, | ||
608 | struct GNUNET_TESTING_Interpreter *is) | ||
609 | { | ||
610 | struct NetJailState *ns = cls; | ||
611 | struct GNUNET_CONFIGURATION_Handle *config = | ||
612 | GNUNET_CONFIGURATION_create (); | ||
613 | |||
614 | for (int i = 1; i <= ns->known; i++) | ||
615 | { | ||
616 | start_helper (ns, config, | ||
617 | i, | ||
618 | 0); | ||
619 | } | ||
620 | |||
621 | for (int i = 1; i <= ns->global_n; i++) | ||
622 | { | ||
623 | for (int j = 1; j <= ns->local_m; j++) | ||
624 | { | ||
625 | start_helper (ns, config, | ||
626 | j, | ||
627 | i); | ||
628 | } | ||
629 | } | ||
630 | } | ||
631 | |||
632 | |||
633 | static void | ||
634 | send_message_to_locals ( | ||
635 | unsigned int i, | ||
636 | unsigned int j, | ||
637 | struct NetJailState *ns, | ||
638 | struct GNUNET_MessageHeader *header | ||
639 | ) | ||
640 | { | ||
641 | // unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
642 | struct GNUNET_HELPER_Handle *helper; | ||
643 | struct TestingSystemCount *tbc; | ||
644 | |||
645 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
646 | "send message to locals\n"); | ||
647 | tbc = GNUNET_new (struct TestingSystemCount); | ||
648 | tbc->ns = ns; | ||
649 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
650 | if (0 == i) | ||
651 | tbc->count = j; // + total_number; | ||
652 | else | ||
653 | tbc->count = (i - 1) * ns->local_m + j + ns->known; // + total_number ; | ||
654 | |||
655 | helper = ns->helper[tbc->count - 1];// - total_number]; | ||
656 | |||
657 | GNUNET_array_append (ns->msg, ns->n_msg, header); | ||
658 | |||
659 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
660 | helper, | ||
661 | header, | ||
662 | GNUNET_NO, | ||
663 | &clear_msg, | ||
664 | tbc); | ||
665 | |||
666 | tbc->shandle = sh; | ||
667 | // GNUNET_array_append (tbc->shandle, tbc->n_shandle, sh); | ||
668 | } | ||
669 | |||
670 | |||
671 | static void | ||
672 | send_all_local_tests_prepared (unsigned int i, unsigned int j, struct | ||
673 | NetJailState *ns) | ||
674 | { | ||
675 | struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED *reply; | ||
676 | size_t msg_length; | ||
677 | |||
678 | |||
679 | msg_length = sizeof(struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); | ||
680 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); | ||
681 | reply->header.type = htons ( | ||
682 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED); | ||
683 | reply->header.size = htons ((uint16_t) msg_length); | ||
684 | |||
685 | send_message_to_locals (i, j, ns, &reply->header); | ||
686 | } | ||
687 | |||
688 | |||
689 | static void | ||
690 | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | ||
691 | { | ||
692 | |||
693 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
694 | size_t msg_length; | ||
695 | |||
696 | |||
697 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
698 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
699 | reply->header.type = htons ( | ||
700 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
701 | reply->header.size = htons ((uint16_t) msg_length); | ||
702 | |||
703 | send_message_to_locals (i, j, ns, &reply->header); | ||
704 | } | ||
705 | |||
706 | |||
707 | /** | ||
708 | * This function checks on three different information. | ||
709 | * | ||
710 | * 1. Did all helpers start. This is only logged. | ||
711 | * 2. Did all peer start. | ||
712 | * In this case a GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED is send to all peers. | ||
713 | * 3. Did all peers finished the test case. In this case interpreter_next will be called. | ||
714 | * | ||
715 | */ | ||
716 | static int | ||
717 | netjail_start_finish (void *cls, | ||
718 | GNUNET_SCHEDULER_TaskCallback cont, | ||
719 | void *cont_cls) | ||
720 | { | ||
721 | unsigned int ret = GNUNET_NO; | ||
722 | struct NetJailState *ns = cls; | ||
723 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
724 | |||
725 | |||
726 | if (ns->number_of_local_tests_finished == total_number) | ||
727 | { | ||
728 | ret = GNUNET_YES; | ||
729 | cont (cont_cls); | ||
730 | } | ||
731 | |||
732 | if (ns->number_of_local_tests_prepared == total_number) | ||
733 | { | ||
734 | for (int i = 1; i <= ns->known; i++) | ||
735 | { | ||
736 | send_all_local_tests_prepared (0,i, ns); | ||
737 | } | ||
738 | |||
739 | for (int i = 1; i <= ns->global_n; i++) | ||
740 | { | ||
741 | for (int j = 1; j <= ns->local_m; j++) | ||
742 | { | ||
743 | send_all_local_tests_prepared (i,j, ns); | ||
744 | } | ||
745 | } | ||
746 | } | ||
747 | |||
748 | if (ns->number_of_testsystems_started == total_number) | ||
749 | { | ||
750 | ns->number_of_testsystems_started = 0; | ||
751 | } | ||
752 | |||
753 | if (ns->number_of_peers_started == total_number) | ||
754 | { | ||
755 | for (int i = 1; i <= ns->known; i++) | ||
756 | { | ||
757 | send_all_peers_started (0,i, ns); | ||
758 | } | ||
759 | |||
760 | for (int i = 1; i <= ns->global_n; i++) | ||
761 | { | ||
762 | for (int j = 1; j <= ns->local_m; j++) | ||
763 | { | ||
764 | send_all_peers_started (i,j, ns); | ||
765 | } | ||
766 | } | ||
767 | ns->number_of_peers_started = 0; | ||
768 | } | ||
769 | return ret; | ||
770 | } | ||
771 | |||
772 | |||
773 | /** | ||
774 | * Create command. | ||
775 | * | ||
776 | * @param label Name for the command. | ||
777 | * @param topology_config Configuration file for the test topology. | ||
778 | * @param rv Pointer to the return value of the test. | ||
779 | * @return command. | ||
780 | */ | ||
781 | struct GNUNET_TESTING_Command | ||
782 | GNUNET_TESTING_cmd_netjail_start_testing_system_v2 (const char *label, | ||
783 | const char *topology_config, | ||
784 | unsigned int *rv) | ||
785 | { | ||
786 | struct NetJailState *ns; | ||
787 | |||
788 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
789 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
790 | |||
791 | ns = GNUNET_new (struct NetJailState); | ||
792 | ns->rv = rv; | ||
793 | ns->local_m = topology->nodes_m; | ||
794 | ns->global_n = topology->namespaces_n; | ||
795 | ns->known = topology->nodes_x; | ||
796 | ns->plugin_name = topology->plugin; | ||
797 | ns->topology = topology; | ||
798 | |||
799 | struct GNUNET_TESTING_Command cmd = { | ||
800 | .cls = ns, | ||
801 | .label = label, | ||
802 | .run = &netjail_exec_run, | ||
803 | .finish = &netjail_start_finish, | ||
804 | .cleanup = &netjail_exec_cleanup, | ||
805 | .traits = &netjail_exec_traits | ||
806 | }; | ||
807 | |||
808 | return cmd; | ||
809 | } | ||
diff --git a/src/testing/testing_api_cmd_netjail_start_v2.c b/src/testing/testing_api_cmd_netjail_start_v2.c deleted file mode 100644 index 7d802db6a..000000000 --- a/src/testing/testing_api_cmd_netjail_start_v2.c +++ /dev/null | |||
@@ -1,229 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to start the netjail script. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | |||
30 | #define NETJAIL_START_SCRIPT "./../testing/netjail_start_v2.sh" | ||
31 | |||
32 | /** | ||
33 | * Struct to hold information for callbacks. | ||
34 | * | ||
35 | */ | ||
36 | struct NetJailState | ||
37 | { | ||
38 | // Child Wait handle | ||
39 | struct GNUNET_ChildWaitHandle *cwh; | ||
40 | |||
41 | /** | ||
42 | * Configuration file for the test topology. | ||
43 | */ | ||
44 | char *topology_config; | ||
45 | |||
46 | /** | ||
47 | * The process id of the start script. | ||
48 | */ | ||
49 | struct GNUNET_OS_Process *start_proc; | ||
50 | |||
51 | // Flag indication if the script finished. | ||
52 | unsigned int finished; | ||
53 | }; | ||
54 | |||
55 | |||
56 | /** | ||
57 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
58 | * | ||
59 | */ | ||
60 | static void | ||
61 | netjail_start_cleanup (void *cls, | ||
62 | const struct GNUNET_TESTING_Command *cmd) | ||
63 | { | ||
64 | struct NetJailState *ns = cls; | ||
65 | |||
66 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
67 | "netjail_start_cleanup!\n"); | ||
68 | |||
69 | if (NULL != ns->cwh) | ||
70 | { | ||
71 | GNUNET_wait_child_cancel (ns->cwh); | ||
72 | ns->cwh = NULL; | ||
73 | } | ||
74 | if (NULL != ns->start_proc) | ||
75 | { | ||
76 | GNUNET_assert (0 == | ||
77 | GNUNET_OS_process_kill (ns->start_proc, | ||
78 | SIGTERM)); | ||
79 | GNUNET_assert (GNUNET_OK == | ||
80 | GNUNET_OS_process_wait (ns->start_proc)); | ||
81 | GNUNET_OS_process_destroy (ns->start_proc); | ||
82 | ns->start_proc = NULL; | ||
83 | } | ||
84 | GNUNET_free (ns); | ||
85 | } | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Trait function of this cmd does nothing. | ||
90 | * | ||
91 | */ | ||
92 | static int | ||
93 | netjail_start_traits (void *cls, | ||
94 | const void **ret, | ||
95 | const char *trait, | ||
96 | unsigned int index) | ||
97 | { | ||
98 | return GNUNET_OK; | ||
99 | } | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Callback which will be called if the setup script finished. | ||
104 | * | ||
105 | */ | ||
106 | static void | ||
107 | child_completed_callback (void *cls, | ||
108 | enum GNUNET_OS_ProcessStatusType type, | ||
109 | long unsigned int exit_code) | ||
110 | { | ||
111 | struct NetJailState *ns = cls; | ||
112 | |||
113 | if (0 == exit_code) | ||
114 | { | ||
115 | ns->finished = GNUNET_YES; | ||
116 | } | ||
117 | else | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
120 | "Child completed with an error!\n"); | ||
121 | ns->finished = GNUNET_SYSERR; | ||
122 | } | ||
123 | GNUNET_OS_process_destroy (ns->start_proc); | ||
124 | ns->start_proc = NULL; | ||
125 | } | ||
126 | |||
127 | |||
128 | |||
129 | /** | ||
130 | * The run method starts the script which setup the network namespaces. | ||
131 | * | ||
132 | * @param cls closure. | ||
133 | * @param cmd CMD being run. | ||
134 | * @param is interpreter state. | ||
135 | */ | ||
136 | static void | ||
137 | netjail_start_run (void *cls, | ||
138 | const struct GNUNET_TESTING_Command *cmd, | ||
139 | struct GNUNET_TESTING_Interpreter *is) | ||
140 | { | ||
141 | struct NetJailState *ns = cls; | ||
142 | char *pid; | ||
143 | GNUNET_asprintf (&pid, | ||
144 | "%u", | ||
145 | getpid ()); | ||
146 | char *const script_argv[] = {NETJAIL_START_SCRIPT, | ||
147 | ns->topology_config, | ||
148 | pid, | ||
149 | NULL}; | ||
150 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | ||
151 | NETJAIL_START_SCRIPT, | ||
152 | GNUNET_YES, | ||
153 | NULL); | ||
154 | |||
155 | if (GNUNET_NO == helper_check) | ||
156 | { | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
158 | "No SUID for %s!\n", | ||
159 | NETJAIL_START_SCRIPT); | ||
160 | GNUNET_TESTING_interpreter_fail (); | ||
161 | } | ||
162 | else if (GNUNET_NO == helper_check) | ||
163 | { | ||
164 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
165 | "%s not found!\n", | ||
166 | NETJAIL_START_SCRIPT); | ||
167 | GNUNET_TESTING_interpreter_fail (); | ||
168 | } | ||
169 | |||
170 | ns->start_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | ||
171 | NULL, | ||
172 | NULL, | ||
173 | NULL, | ||
174 | NETJAIL_START_SCRIPT, | ||
175 | script_argv); | ||
176 | |||
177 | ns->cwh = GNUNET_wait_child (ns->start_proc, | ||
178 | &child_completed_callback, | ||
179 | ns); | ||
180 | GNUNET_break (NULL != ns->cwh); | ||
181 | } | ||
182 | |||
183 | |||
184 | /** | ||
185 | * This function checks the flag NetJailState#finished, if this cmd finished. | ||
186 | * | ||
187 | */ | ||
188 | static int | ||
189 | netjail_start_finish (void *cls, | ||
190 | GNUNET_SCHEDULER_TaskCallback cont, | ||
191 | void *cont_cls) | ||
192 | { | ||
193 | struct NetJailState *ns = cls; | ||
194 | |||
195 | if (ns->finished) | ||
196 | { | ||
197 | cont (cont_cls); | ||
198 | } | ||
199 | return ns->finished; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Create command. | ||
204 | * | ||
205 | * @param label name for command. | ||
206 | * @param topology_config Configuration file for the test topology. | ||
207 | * @return command. | ||
208 | */ | ||
209 | struct GNUNET_TESTING_Command | ||
210 | GNUNET_TESTING_cmd_netjail_start_v2 (const char *label, | ||
211 | char *topology_config) | ||
212 | { | ||
213 | struct NetJailState *ns; | ||
214 | |||
215 | ns = GNUNET_new (struct NetJailState); | ||
216 | ns->finished = GNUNET_NO; | ||
217 | ns->topology_config = topology_config; | ||
218 | |||
219 | struct GNUNET_TESTING_Command cmd = { | ||
220 | .cls = ns, | ||
221 | .label = label, | ||
222 | .run = &netjail_start_run, | ||
223 | .finish = &netjail_start_finish, | ||
224 | .cleanup = &netjail_start_cleanup, | ||
225 | .traits = &netjail_start_traits | ||
226 | }; | ||
227 | |||
228 | return cmd; | ||
229 | } | ||
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index 99084d9af..5033272a3 100644 --- a/src/testing/testing_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testing/testing_api_cmd_hello_world.c | 22 | * @file testing/testing_api_cmd_netjail_stop.c |
23 | * @brief Command to stop the netjail script. | 23 | * @brief Command to stop the netjail script. |
24 | * @author t3sserakt | 24 | * @author t3sserakt |
25 | */ | 25 | */ |
@@ -31,7 +31,7 @@ | |||
31 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" | 31 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" |
32 | 32 | ||
33 | // Child Wait handle | 33 | // Child Wait handle |
34 | struct GNUNET_ChildWaitHandle *cwh; | 34 | static struct GNUNET_ChildWaitHandle *cwh; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Struct to hold information for callbacks. | 37 | * Struct to hold information for callbacks. |
@@ -39,19 +39,21 @@ struct GNUNET_ChildWaitHandle *cwh; | |||
39 | */ | 39 | */ |
40 | struct NetJailState | 40 | struct NetJailState |
41 | { | 41 | { |
42 | // Number of local nodes in each namespace. | 42 | /** |
43 | char *local_m; | 43 | * Context for our asynchronous completion. |
44 | */ | ||
45 | struct GNUNET_TESTING_AsyncContext ac; | ||
44 | 46 | ||
45 | // The number of namespaces. | 47 | /** |
46 | char *global_n; | 48 | * Configuration file for the test topology. |
49 | */ | ||
50 | char *topology_config; | ||
47 | 51 | ||
48 | /** | 52 | /** |
49 | * The process id of the start script. | 53 | * The process id of the start script. |
50 | */ | 54 | */ |
51 | struct GNUNET_OS_Process *stop_proc; | 55 | struct GNUNET_OS_Process *stop_proc; |
52 | 56 | ||
53 | // Flag indication if the script finished. | ||
54 | unsigned int finished; | ||
55 | }; | 57 | }; |
56 | 58 | ||
57 | 59 | ||
@@ -60,8 +62,7 @@ struct NetJailState | |||
60 | * | 62 | * |
61 | */ | 63 | */ |
62 | static void | 64 | static void |
63 | netjail_stop_cleanup (void *cls, | 65 | netjail_stop_cleanup (void *cls) |
64 | const struct GNUNET_TESTING_Command *cmd) | ||
65 | { | 66 | { |
66 | struct NetJailState *ns = cls; | 67 | struct NetJailState *ns = cls; |
67 | 68 | ||
@@ -84,20 +85,6 @@ netjail_stop_cleanup (void *cls, | |||
84 | 85 | ||
85 | 86 | ||
86 | /** | 87 | /** |
87 | * Trait function of this cmd does nothing. | ||
88 | * | ||
89 | */ | ||
90 | static int | ||
91 | netjail_stop_traits (void *cls, | ||
92 | const void **ret, | ||
93 | const char *trait, | ||
94 | unsigned int index) | ||
95 | { | ||
96 | return GNUNET_OK; | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Callback which will be called if the setup script finished. | 88 | * Callback which will be called if the setup script finished. |
102 | * | 89 | * |
103 | */ | 90 | */ |
@@ -108,17 +95,17 @@ child_completed_callback (void *cls, | |||
108 | { | 95 | { |
109 | struct NetJailState *ns = cls; | 96 | struct NetJailState *ns = cls; |
110 | 97 | ||
111 | cwh = NULL; | 98 | cwh = NULL; // WTF? globals!?!?! |
99 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
100 | ns->stop_proc = NULL; | ||
112 | if (0 == exit_code) | 101 | if (0 == exit_code) |
113 | { | 102 | { |
114 | ns->finished = GNUNET_YES; | 103 | GNUNET_TESTING_async_finish (&ns->ac); |
115 | } | 104 | } |
116 | else | 105 | else |
117 | { | 106 | { |
118 | ns->finished = GNUNET_SYSERR; | 107 | GNUNET_TESTING_async_fail (&ns->ac); |
119 | } | 108 | } |
120 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
121 | ns->stop_proc = NULL; | ||
122 | } | 109 | } |
123 | 110 | ||
124 | 111 | ||
@@ -126,18 +113,21 @@ child_completed_callback (void *cls, | |||
126 | * The run method starts the script which deletes the network namespaces. | 113 | * The run method starts the script which deletes the network namespaces. |
127 | * | 114 | * |
128 | * @param cls closure. | 115 | * @param cls closure. |
129 | * @param cmd CMD being run. | ||
130 | * @param is interpreter state. | 116 | * @param is interpreter state. |
131 | */ | 117 | */ |
132 | static void | 118 | static void |
133 | netjail_stop_run (void *cls, | 119 | netjail_stop_run (void *cls, |
134 | const struct GNUNET_TESTING_Command *cmd, | ||
135 | struct GNUNET_TESTING_Interpreter *is) | 120 | struct GNUNET_TESTING_Interpreter *is) |
136 | { | 121 | { |
137 | struct NetJailState *ns = cls; | 122 | struct NetJailState *ns = cls; |
123 | char *pid; | ||
124 | |||
125 | GNUNET_asprintf (&pid, | ||
126 | "%u", | ||
127 | getpid ()); | ||
138 | char *const script_argv[] = {NETJAIL_STOP_SCRIPT, | 128 | char *const script_argv[] = {NETJAIL_STOP_SCRIPT, |
139 | ns->local_m, | 129 | ns->topology_config, |
140 | ns->global_n, | 130 | pid, |
141 | NULL}; | 131 | NULL}; |
142 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | 132 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
143 | NETJAIL_STOP_SCRIPT, | 133 | NETJAIL_STOP_SCRIPT, |
@@ -149,14 +139,14 @@ netjail_stop_run (void *cls, | |||
149 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
150 | "No SUID for %s!\n", | 140 | "No SUID for %s!\n", |
151 | NETJAIL_STOP_SCRIPT); | 141 | NETJAIL_STOP_SCRIPT); |
152 | GNUNET_TESTING_interpreter_fail (); | 142 | GNUNET_TESTING_interpreter_fail (is); |
153 | } | 143 | } |
154 | else if (GNUNET_NO == helper_check) | 144 | else if (GNUNET_NO == helper_check) |
155 | { | 145 | { |
156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 146 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
157 | "%s not found!\n", | 147 | "%s not found!\n", |
158 | NETJAIL_STOP_SCRIPT); | 148 | NETJAIL_STOP_SCRIPT); |
159 | GNUNET_TESTING_interpreter_fail (); | 149 | GNUNET_TESTING_interpreter_fail (is); |
160 | } | 150 | } |
161 | 151 | ||
162 | ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | 152 | ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, |
@@ -170,56 +160,26 @@ netjail_stop_run (void *cls, | |||
170 | &child_completed_callback, | 160 | &child_completed_callback, |
171 | ns); | 161 | ns); |
172 | GNUNET_break (NULL != cwh); | 162 | GNUNET_break (NULL != cwh); |
173 | |||
174 | } | 163 | } |
175 | 164 | ||
176 | 165 | ||
177 | /** | ||
178 | * This function checks the flag NetJailState#finished, if this cmd finished. | ||
179 | * | ||
180 | */ | ||
181 | static int | ||
182 | netjail_stop_finish (void *cls, | ||
183 | GNUNET_SCHEDULER_TaskCallback cont, | ||
184 | void *cont_cls) | ||
185 | { | ||
186 | struct NetJailState *ns = cls; | ||
187 | |||
188 | if (ns->finished) | ||
189 | { | ||
190 | cont (cont_cls); | ||
191 | } | ||
192 | return ns->finished; | ||
193 | } | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Create command. | ||
198 | * | ||
199 | * @param label name for command. | ||
200 | * @param local_m Number of local nodes in each namespace. | ||
201 | * @param global_n The number of namespaces. | ||
202 | * @return command. | ||
203 | */ | ||
204 | struct GNUNET_TESTING_Command | 166 | struct GNUNET_TESTING_Command |
205 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | 167 | GNUNET_TESTING_cmd_netjail_stop (const char *label, |
206 | char *local_m, | 168 | char *topology_config) |
207 | char *global_n) | ||
208 | { | 169 | { |
209 | struct NetJailState *ns; | 170 | struct NetJailState *ns; |
210 | 171 | ||
211 | ns = GNUNET_new (struct NetJailState); | 172 | ns = GNUNET_new (struct NetJailState); |
212 | ns->local_m = local_m; | 173 | ns->topology_config = topology_config; |
213 | ns->global_n = global_n; | 174 | { |
214 | 175 | struct GNUNET_TESTING_Command cmd = { | |
215 | struct GNUNET_TESTING_Command cmd = { | 176 | .cls = ns, |
216 | .cls = ns, | 177 | .label = label, |
217 | .label = label, | 178 | .run = &netjail_stop_run, |
218 | .run = &netjail_stop_run, | 179 | .ac = &ns->ac, |
219 | .finish = &netjail_stop_finish, | 180 | .cleanup = &netjail_stop_cleanup |
220 | .cleanup = &netjail_stop_cleanup, | 181 | }; |
221 | .traits = &netjail_stop_traits | 182 | |
222 | }; | 183 | return cmd; |
223 | 184 | } | |
224 | return cmd; | ||
225 | } | 185 | } |
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c index 0ae82a26a..d3754153d 100644 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c | |||
@@ -42,9 +42,15 @@ struct StopHelperState | |||
42 | */ | 42 | */ |
43 | struct GNUNET_HELPER_Handle **helper; | 43 | struct GNUNET_HELPER_Handle **helper; |
44 | 44 | ||
45 | char *local_m; | 45 | unsigned int local_m; |
46 | 46 | ||
47 | char *global_n; | 47 | unsigned int global_n; |
48 | |||
49 | /** | ||
50 | * Number of global known nodes. | ||
51 | * | ||
52 | */ | ||
53 | unsigned int known; | ||
48 | }; | 54 | }; |
49 | 55 | ||
50 | 56 | ||
@@ -55,8 +61,7 @@ struct StopHelperState | |||
55 | * @param cmd current CMD being cleaned up. | 61 | * @param cmd current CMD being cleaned up. |
56 | */ | 62 | */ |
57 | static void | 63 | static void |
58 | stop_testing_system_cleanup (void *cls, | 64 | stop_testing_system_cleanup (void *cls) |
59 | const struct GNUNET_TESTING_Command *cmd) | ||
60 | { | 65 | { |
61 | 66 | ||
62 | } | 67 | } |
@@ -80,28 +85,40 @@ stop_testing_system_traits (void *cls, | |||
80 | * This function stops the helper process for each node. | 85 | * This function stops the helper process for each node. |
81 | * | 86 | * |
82 | * @param cls closure. | 87 | * @param cls closure. |
83 | * @param cmd CMD being run. | ||
84 | * @param is interpreter state. | 88 | * @param is interpreter state. |
85 | */ | 89 | */ |
86 | static void | 90 | static void |
87 | stop_testing_system_run (void *cls, | 91 | stop_testing_system_run (void *cls, |
88 | const struct GNUNET_TESTING_Command *cmd, | ||
89 | struct GNUNET_TESTING_Interpreter *is) | 92 | struct GNUNET_TESTING_Interpreter *is) |
90 | { | 93 | { |
91 | struct StopHelperState *shs = cls; | 94 | struct StopHelperState *shs = cls; |
92 | struct GNUNET_HELPER_Handle **helper; | 95 | struct GNUNET_HELPER_Handle **helper; |
93 | const struct GNUNET_TESTING_Command *start_helper_cmd; | 96 | const struct GNUNET_TESTING_Command *start_helper_cmd; |
94 | 97 | ||
95 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | 98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (NULL, |
96 | shs->helper_start_label); | 99 | shs-> |
100 | helper_start_label); | ||
97 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | 101 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, |
98 | &helper); | 102 | &helper); |
99 | 103 | ||
100 | for (int i = 1; i <= atoi (shs->global_n); i++) | 104 | for (int i = 1; i <= shs->known; i++) |
105 | { | ||
106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
107 | "i: %u\n", | ||
108 | i); | ||
109 | GNUNET_HELPER_stop (helper[i - 1], | ||
110 | GNUNET_YES); | ||
111 | } | ||
112 | |||
113 | for (int i = 1; i <= shs->global_n; i++) | ||
101 | { | 114 | { |
102 | for (int j = 1; j <= atoi (shs->local_m); j++) | 115 | for (int j = 1; j <= shs->local_m; j++) |
103 | { | 116 | { |
104 | GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], | 117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
118 | "i: %u j: %u\n", | ||
119 | i, | ||
120 | j); | ||
121 | GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j + shs->known - 1], | ||
105 | GNUNET_YES); | 122 | GNUNET_YES); |
106 | } | 123 | } |
107 | } | 124 | } |
@@ -110,26 +127,27 @@ stop_testing_system_run (void *cls, | |||
110 | 127 | ||
111 | /** | 128 | /** |
112 | * Create command. | 129 | * Create command. |
113 | * @param helper_start_label label of the cmd to start the test system. | 130 | * |
114 | * @param label name for command. | 131 | * @param label name for command. |
115 | * @param . | 132 | * @param helper_start_label label of the cmd to start the test system. |
116 | * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int | 133 | * @param topology_config Configuration file for the test topology. |
117 | * @param global_n Number of network namespaces. //TODO make this a unsigned int | ||
118 | * @return command. | 134 | * @return command. |
119 | */ | 135 | */ |
120 | struct GNUNET_TESTING_Command | 136 | struct GNUNET_TESTING_Command |
121 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | 137 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, |
122 | const char *helper_start_label, | 138 | const char *helper_start_label, |
123 | char *local_m, | 139 | const char *topology_config) |
124 | char *global_n | ||
125 | ) | ||
126 | { | 140 | { |
127 | struct StopHelperState *shs; | 141 | struct StopHelperState *shs; |
128 | 142 | ||
143 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
144 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
145 | |||
129 | shs = GNUNET_new (struct StopHelperState); | 146 | shs = GNUNET_new (struct StopHelperState); |
130 | shs->helper_start_label = helper_start_label; | 147 | shs->helper_start_label = helper_start_label; |
131 | shs->local_m = local_m; | 148 | shs->local_m = topology->nodes_m; |
132 | shs->global_n = global_n; | 149 | shs->global_n = topology->namespaces_n; |
150 | shs->known = topology->nodes_x; | ||
133 | 151 | ||
134 | struct GNUNET_TESTING_Command cmd = { | 152 | struct GNUNET_TESTING_Command cmd = { |
135 | .cls = shs, | 153 | .cls = shs, |
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c b/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c deleted file mode 100644 index 6ce106eaa..000000000 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c +++ /dev/null | |||
@@ -1,163 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to start the netjail peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "testing_cmds.h" | ||
29 | |||
30 | |||
31 | /** | ||
32 | * Struct to store information handed over to callbacks. | ||
33 | * | ||
34 | */ | ||
35 | struct StopHelperState | ||
36 | { | ||
37 | |||
38 | const char *helper_start_label; | ||
39 | |||
40 | /** | ||
41 | * The process handle | ||
42 | */ | ||
43 | struct GNUNET_HELPER_Handle **helper; | ||
44 | |||
45 | unsigned int local_m; | ||
46 | |||
47 | unsigned int global_n; | ||
48 | |||
49 | /** | ||
50 | * Number of global known nodes. | ||
51 | * | ||
52 | */ | ||
53 | unsigned int known; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Code to clean up resource this cmd used. | ||
59 | * | ||
60 | * @param cls closure | ||
61 | * @param cmd current CMD being cleaned up. | ||
62 | */ | ||
63 | static void | ||
64 | stop_testing_system_cleanup (void *cls, | ||
65 | const struct GNUNET_TESTING_Command *cmd) | ||
66 | { | ||
67 | |||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Trait function of this cmd does nothing. | ||
73 | * | ||
74 | */ | ||
75 | static int | ||
76 | stop_testing_system_traits (void *cls, | ||
77 | const void **ret, | ||
78 | const char *trait, | ||
79 | unsigned int index) | ||
80 | { | ||
81 | return GNUNET_OK; | ||
82 | } | ||
83 | |||
84 | |||
85 | /** | ||
86 | * This function stops the helper process for each node. | ||
87 | * | ||
88 | * @param cls closure. | ||
89 | * @param cmd CMD being run. | ||
90 | * @param is interpreter state. | ||
91 | */ | ||
92 | static void | ||
93 | stop_testing_system_run (void *cls, | ||
94 | const struct GNUNET_TESTING_Command *cmd, | ||
95 | struct GNUNET_TESTING_Interpreter *is) | ||
96 | { | ||
97 | struct StopHelperState *shs = cls; | ||
98 | struct GNUNET_HELPER_Handle **helper; | ||
99 | const struct GNUNET_TESTING_Command *start_helper_cmd; | ||
100 | |||
101 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
102 | shs->helper_start_label); | ||
103 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | ||
104 | &helper); | ||
105 | |||
106 | for (int i = 1; i <= shs->known; i++) | ||
107 | { | ||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
109 | "i: %u\n", | ||
110 | i); | ||
111 | GNUNET_HELPER_stop (helper[i - 1], | ||
112 | GNUNET_YES); | ||
113 | } | ||
114 | |||
115 | for (int i = 1; i <= shs->global_n; i++) | ||
116 | { | ||
117 | for (int j = 1; j <= shs->local_m; j++) | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
120 | "i: %u j: %u\n", | ||
121 | i, | ||
122 | j); | ||
123 | GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j + shs->known - 1], | ||
124 | GNUNET_YES); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Create command. | ||
132 | * | ||
133 | * @param label name for command. | ||
134 | * @param helper_start_label label of the cmd to start the test system. | ||
135 | * @param topology_config Configuration file for the test topology. | ||
136 | * @return command. | ||
137 | */ | ||
138 | struct GNUNET_TESTING_Command | ||
139 | GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label, | ||
140 | const char *helper_start_label, | ||
141 | const char *topology_config) | ||
142 | { | ||
143 | struct StopHelperState *shs; | ||
144 | |||
145 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
146 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
147 | |||
148 | shs = GNUNET_new (struct StopHelperState); | ||
149 | shs->helper_start_label = helper_start_label; | ||
150 | shs->local_m = topology->nodes_m; | ||
151 | shs->global_n = topology->namespaces_n; | ||
152 | shs->known = topology->nodes_x; | ||
153 | |||
154 | struct GNUNET_TESTING_Command cmd = { | ||
155 | .cls = shs, | ||
156 | .label = label, | ||
157 | .run = &stop_testing_system_run, | ||
158 | .cleanup = &stop_testing_system_cleanup, | ||
159 | .traits = &stop_testing_system_traits | ||
160 | }; | ||
161 | |||
162 | return cmd; | ||
163 | } | ||
diff --git a/src/testing/testing_api_cmd_netjail_stop_v2.c b/src/testing/testing_api_cmd_netjail_stop_v2.c deleted file mode 100644 index 8c1f3cedd..000000000 --- a/src/testing/testing_api_cmd_netjail_stop_v2.c +++ /dev/null | |||
@@ -1,225 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to stop the netjail script. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | |||
30 | |||
31 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop_v2.sh" | ||
32 | |||
33 | // Child Wait handle | ||
34 | static struct GNUNET_ChildWaitHandle *cwh; | ||
35 | |||
36 | /** | ||
37 | * Struct to hold information for callbacks. | ||
38 | * | ||
39 | */ | ||
40 | struct NetJailState | ||
41 | { | ||
42 | /** | ||
43 | * Configuration file for the test topology. | ||
44 | */ | ||
45 | char *topology_config; | ||
46 | |||
47 | /** | ||
48 | * The process id of the start script. | ||
49 | */ | ||
50 | struct GNUNET_OS_Process *stop_proc; | ||
51 | |||
52 | // Flag indication if the script finished. | ||
53 | unsigned int finished; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
59 | * | ||
60 | */ | ||
61 | static void | ||
62 | netjail_stop_cleanup (void *cls, | ||
63 | const struct GNUNET_TESTING_Command *cmd) | ||
64 | { | ||
65 | struct NetJailState *ns = cls; | ||
66 | |||
67 | if (NULL != cwh) | ||
68 | { | ||
69 | GNUNET_wait_child_cancel (cwh); | ||
70 | cwh = NULL; | ||
71 | } | ||
72 | if (NULL != ns->stop_proc) | ||
73 | { | ||
74 | GNUNET_assert (0 == | ||
75 | GNUNET_OS_process_kill (ns->stop_proc, | ||
76 | SIGKILL)); | ||
77 | GNUNET_assert (GNUNET_OK == | ||
78 | GNUNET_OS_process_wait (ns->stop_proc)); | ||
79 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
80 | ns->stop_proc = NULL; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Trait function of this cmd does nothing. | ||
87 | * | ||
88 | */ | ||
89 | static int | ||
90 | netjail_stop_traits (void *cls, | ||
91 | const void **ret, | ||
92 | const char *trait, | ||
93 | unsigned int index) | ||
94 | { | ||
95 | return GNUNET_OK; | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Callback which will be called if the setup script finished. | ||
101 | * | ||
102 | */ | ||
103 | static void | ||
104 | child_completed_callback (void *cls, | ||
105 | enum GNUNET_OS_ProcessStatusType type, | ||
106 | long unsigned int exit_code) | ||
107 | { | ||
108 | struct NetJailState *ns = cls; | ||
109 | |||
110 | cwh = NULL; | ||
111 | if (0 == exit_code) | ||
112 | { | ||
113 | ns->finished = GNUNET_YES; | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | ns->finished = GNUNET_SYSERR; | ||
118 | } | ||
119 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
120 | ns->stop_proc = NULL; | ||
121 | } | ||
122 | |||
123 | |||
124 | /** | ||
125 | * The run method starts the script which deletes the network namespaces. | ||
126 | * | ||
127 | * @param cls closure. | ||
128 | * @param cmd CMD being run. | ||
129 | * @param is interpreter state. | ||
130 | */ | ||
131 | static void | ||
132 | netjail_stop_run (void *cls, | ||
133 | const struct GNUNET_TESTING_Command *cmd, | ||
134 | struct GNUNET_TESTING_Interpreter *is) | ||
135 | { | ||
136 | struct NetJailState *ns = cls; | ||
137 | char *pid; | ||
138 | GNUNET_asprintf (&pid, | ||
139 | "%u", | ||
140 | getpid ()); | ||
141 | char *const script_argv[] = {NETJAIL_STOP_SCRIPT, | ||
142 | ns->topology_config, | ||
143 | pid, | ||
144 | NULL}; | ||
145 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | ||
146 | NETJAIL_STOP_SCRIPT, | ||
147 | GNUNET_YES, | ||
148 | NULL); | ||
149 | |||
150 | if (GNUNET_NO == helper_check) | ||
151 | { | ||
152 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
153 | "No SUID for %s!\n", | ||
154 | NETJAIL_STOP_SCRIPT); | ||
155 | GNUNET_TESTING_interpreter_fail (); | ||
156 | } | ||
157 | else if (GNUNET_NO == helper_check) | ||
158 | { | ||
159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
160 | "%s not found!\n", | ||
161 | NETJAIL_STOP_SCRIPT); | ||
162 | GNUNET_TESTING_interpreter_fail (); | ||
163 | } | ||
164 | |||
165 | ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | ||
166 | NULL, | ||
167 | NULL, | ||
168 | NULL, | ||
169 | NETJAIL_STOP_SCRIPT, | ||
170 | script_argv); | ||
171 | |||
172 | cwh = GNUNET_wait_child (ns->stop_proc, | ||
173 | &child_completed_callback, | ||
174 | ns); | ||
175 | GNUNET_break (NULL != cwh); | ||
176 | |||
177 | } | ||
178 | |||
179 | |||
180 | /** | ||
181 | * This function checks the flag NetJailState#finished, if this cmd finished. | ||
182 | * | ||
183 | */ | ||
184 | static int | ||
185 | netjail_stop_finish (void *cls, | ||
186 | GNUNET_SCHEDULER_TaskCallback cont, | ||
187 | void *cont_cls) | ||
188 | { | ||
189 | struct NetJailState *ns = cls; | ||
190 | |||
191 | if (ns->finished) | ||
192 | { | ||
193 | cont (cont_cls); | ||
194 | } | ||
195 | return ns->finished; | ||
196 | } | ||
197 | |||
198 | |||
199 | /** | ||
200 | * Create command. | ||
201 | * | ||
202 | * @param label name for command. | ||
203 | * @param topology_config Configuration file for the test topology. | ||
204 | * @return command. | ||
205 | */ | ||
206 | struct GNUNET_TESTING_Command | ||
207 | GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label, | ||
208 | char *topology_config) | ||
209 | { | ||
210 | struct NetJailState *ns; | ||
211 | |||
212 | ns = GNUNET_new (struct NetJailState); | ||
213 | ns->topology_config = topology_config; | ||
214 | |||
215 | struct GNUNET_TESTING_Command cmd = { | ||
216 | .cls = ns, | ||
217 | .label = label, | ||
218 | .run = &netjail_stop_run, | ||
219 | .finish = &netjail_stop_finish, | ||
220 | .cleanup = &netjail_stop_cleanup, | ||
221 | .traits = &netjail_stop_traits | ||
222 | }; | ||
223 | |||
224 | return cmd; | ||
225 | } | ||
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c index 016837214..8b4c11deb 100644 --- a/src/testing/testing_api_cmd_send_peer_ready.c +++ b/src/testing/testing_api_cmd_send_peer_ready.c | |||
@@ -53,13 +53,13 @@ struct SendPeerReadyState | |||
53 | * Trait function of this cmd does nothing. | 53 | * Trait function of this cmd does nothing. |
54 | * | 54 | * |
55 | */ | 55 | */ |
56 | static int | 56 | static enum GNUNET_GenericReturnValue |
57 | send_peer_ready_traits (void *cls, | 57 | send_peer_ready_traits (void *cls, |
58 | const void **ret, | 58 | const void **ret, |
59 | const char *trait, | 59 | const char *trait, |
60 | unsigned int index) | 60 | unsigned int index) |
61 | { | 61 | { |
62 | return GNUNET_OK; | 62 | return GNUNET_NO; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
@@ -68,8 +68,7 @@ send_peer_ready_traits (void *cls, | |||
68 | * | 68 | * |
69 | */ | 69 | */ |
70 | static void | 70 | static void |
71 | send_peer_ready_cleanup (void *cls, | 71 | send_peer_ready_cleanup (void *cls) |
72 | const struct GNUNET_TESTING_Command *cmd) | ||
73 | { | 72 | { |
74 | struct SendPeerReadyState *sprs = cls; | 73 | struct SendPeerReadyState *sprs = cls; |
75 | 74 | ||
@@ -84,7 +83,6 @@ send_peer_ready_cleanup (void *cls, | |||
84 | */ | 83 | */ |
85 | static void | 84 | static void |
86 | send_peer_ready_run (void *cls, | 85 | send_peer_ready_run (void *cls, |
87 | const struct GNUNET_TESTING_Command *cmd, | ||
88 | struct GNUNET_TESTING_Interpreter *is) | 86 | struct GNUNET_TESTING_Interpreter *is) |
89 | { | 87 | { |
90 | struct SendPeerReadyState *sprs = cls; | 88 | struct SendPeerReadyState *sprs = cls; |
@@ -115,14 +113,15 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label, | |||
115 | 113 | ||
116 | sprs = GNUNET_new (struct SendPeerReadyState); | 114 | sprs = GNUNET_new (struct SendPeerReadyState); |
117 | sprs->write_message = write_message; | 115 | sprs->write_message = write_message; |
118 | 116 | { | |
119 | struct GNUNET_TESTING_Command cmd = { | 117 | struct GNUNET_TESTING_Command cmd = { |
120 | .cls = sprs, | 118 | .cls = sprs, |
121 | .label = label, | 119 | .label = label, |
122 | .run = &send_peer_ready_run, | 120 | .run = &send_peer_ready_run, |
123 | .cleanup = &send_peer_ready_cleanup, | 121 | .cleanup = &send_peer_ready_cleanup, |
124 | .traits = &send_peer_ready_traits | 122 | .traits = &send_peer_ready_traits |
125 | }; | 123 | }; |
126 | 124 | ||
127 | return cmd; | 125 | return cmd; |
126 | } | ||
128 | } | 127 | } |
diff --git a/src/testing/testing_api_cmd_system_create.c b/src/testing/testing_api_cmd_system_create.c index f3a0b1a4c..820adf1bd 100644 --- a/src/testing/testing_api_cmd_system_create.c +++ b/src/testing/testing_api_cmd_system_create.c | |||
@@ -46,7 +46,6 @@ struct TestSystemState | |||
46 | */ | 46 | */ |
47 | static void | 47 | static void |
48 | system_create_run (void *cls, | 48 | system_create_run (void *cls, |
49 | const struct GNUNET_TESTING_Command *cmd, | ||
50 | struct GNUNET_TESTING_Interpreter *is) | 49 | struct GNUNET_TESTING_Interpreter *is) |
51 | { | 50 | { |
52 | struct TestSystemState *tss = cls; | 51 | struct TestSystemState *tss = cls; |
@@ -115,8 +114,7 @@ GNUNET_TESTING_get_trait_test_system (const struct | |||
115 | * | 114 | * |
116 | */ | 115 | */ |
117 | static void | 116 | static void |
118 | system_create_cleanup (void *cls, | 117 | system_create_cleanup (void *cls) |
119 | const struct GNUNET_TESTING_Command *cmd) | ||
120 | { | 118 | { |
121 | struct TestSystemState *tss = cls; | 119 | struct TestSystemState *tss = cls; |
122 | 120 | ||
diff --git a/src/testing/testing_api_cmd_system_destroy.c b/src/testing/testing_api_cmd_system_destroy.c index 5ed0c2fd2..338123d91 100644 --- a/src/testing/testing_api_cmd_system_destroy.c +++ b/src/testing/testing_api_cmd_system_destroy.c | |||
@@ -46,17 +46,18 @@ struct TestSystemState | |||
46 | */ | 46 | */ |
47 | static void | 47 | static void |
48 | system_destroy_run (void *cls, | 48 | system_destroy_run (void *cls, |
49 | const struct GNUNET_TESTING_Command *cmd, | ||
50 | struct GNUNET_TESTING_Interpreter *is) | 49 | struct GNUNET_TESTING_Interpreter *is) |
51 | { | 50 | { |
52 | struct TestSystemState *tss = cls; | 51 | struct TestSystemState *tss = cls; |
53 | const struct GNUNET_TESTING_Command *system_cmd; | 52 | const struct GNUNET_TESTING_Command *system_cmd; |
54 | struct GNUNET_TESTING_System *tl_system; | 53 | struct GNUNET_TESTING_System *tl_system; |
55 | 54 | ||
56 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (tss->create_label); | 55 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
56 | tss->create_label); | ||
57 | GNUNET_TESTING_get_trait_test_system (system_cmd, | 57 | GNUNET_TESTING_get_trait_test_system (system_cmd, |
58 | &tl_system); | 58 | &tl_system); |
59 | GNUNET_TESTING_system_destroy (tl_system, GNUNET_YES); | 59 | GNUNET_TESTING_system_destroy (tl_system, |
60 | GNUNET_YES); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | 63 | ||
@@ -65,8 +66,7 @@ system_destroy_run (void *cls, | |||
65 | * | 66 | * |
66 | */ | 67 | */ |
67 | static void | 68 | static void |
68 | system_destroy_cleanup (void *cls, | 69 | system_destroy_cleanup (void *cls) |
69 | const struct GNUNET_TESTING_Command *cmd) | ||
70 | { | 70 | { |
71 | struct TestSystemState *tss = cls; | 71 | struct TestSystemState *tss = cls; |
72 | 72 | ||
@@ -78,7 +78,7 @@ system_destroy_cleanup (void *cls, | |||
78 | * Trait function of this cmd does nothing. | 78 | * Trait function of this cmd does nothing. |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | static int | 81 | static enum GNUNET_GenericReturnValue |
82 | system_destroy_traits (void *cls, | 82 | system_destroy_traits (void *cls, |
83 | const void **ret, | 83 | const void **ret, |
84 | const char *trait, | 84 | const char *trait, |
@@ -103,14 +103,15 @@ GNUNET_TESTING_cmd_system_destroy (const char *label, | |||
103 | 103 | ||
104 | tss = GNUNET_new (struct TestSystemState); | 104 | tss = GNUNET_new (struct TestSystemState); |
105 | tss->create_label = create_label; | 105 | tss->create_label = create_label; |
106 | 106 | { | |
107 | struct GNUNET_TESTING_Command cmd = { | 107 | struct GNUNET_TESTING_Command cmd = { |
108 | .cls = tss, | 108 | .cls = tss, |
109 | .label = label, | 109 | .label = label, |
110 | .run = &system_destroy_run, | 110 | .run = &system_destroy_run, |
111 | .cleanup = &system_destroy_cleanup, | 111 | .cleanup = &system_destroy_cleanup, |
112 | .traits = &system_destroy_traits | 112 | .traits = &system_destroy_traits |
113 | }; | 113 | }; |
114 | 114 | ||
115 | return cmd; | 115 | return cmd; |
116 | } | ||
116 | } | 117 | } |
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index bb04280a9..3727d2543 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c | |||
@@ -24,67 +24,68 @@ | |||
24 | * @author Christian Grothoff (GNU Taler testing) | 24 | * @author Christian Grothoff (GNU Taler testing) |
25 | * @author Marcello Stanisci (GNU Taler testing) | 25 | * @author Marcello Stanisci (GNU Taler testing) |
26 | * @author t3sserakt | 26 | * @author t3sserakt |
27 | */ | 27 | */ |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_testing_ng_lib.h" | 30 | #include "gnunet_testing_ng_lib.h" |
31 | #include "testing.h" | 31 | #include "testing.h" |
32 | 32 | ||
33 | #define CHECK_FINISHED_PERIOD \ | ||
34 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | ||
35 | |||
36 | struct GNUNET_TESTING_Interpreter *is; | ||
37 | |||
38 | |||
39 | /** | 33 | /** |
40 | * Closure used to sync an asynchronous with an synchronous command. | 34 | * Global state of the interpreter, used by a command |
35 | * to access information about other commands. | ||
41 | */ | 36 | */ |
42 | struct SyncTaskClosure | 37 | struct GNUNET_TESTING_Interpreter |
43 | { | 38 | { |
44 | 39 | ||
45 | /** | 40 | /** |
46 | * The asynchronous command the synchronous command waits for. | 41 | * Function to call with the test result. |
47 | */ | 42 | */ |
48 | const struct GNUNET_TESTING_Command *async_cmd; | 43 | GNUNET_TESTING_ResultCallback rc; |
49 | 44 | ||
50 | /** | 45 | /** |
51 | * The synchronous command that waits for the asynchronous command. | 46 | * Closure for @e rc. |
52 | */ | 47 | */ |
53 | const struct GNUNET_TESTING_Command *sync_cmd; | 48 | void *rc_cls; |
54 | 49 | ||
55 | /** | 50 | /** |
56 | * The interpreter of the test. | 51 | * Commands the interpreter will run. |
57 | */ | 52 | */ |
58 | struct GNUNET_TESTING_Interpreter *is; | 53 | struct GNUNET_TESTING_Command *commands; |
59 | }; | ||
60 | 54 | ||
55 | /** | ||
56 | * Interpreter task (if one is scheduled). | ||
57 | */ | ||
58 | struct GNUNET_SCHEDULER_Task *task; | ||
61 | 59 | ||
62 | /** | 60 | /** |
63 | * Closure used to run the finish task. | 61 | * Final task that returns the result. |
64 | */ | 62 | */ |
65 | struct FinishTaskClosure | 63 | struct GNUNET_SCHEDULER_Task *final_task; |
66 | { | ||
67 | 64 | ||
68 | /** | 65 | /** |
69 | * The asynchronous command the synchronous command waits for. | 66 | * Task run on timeout. |
70 | */ | 67 | */ |
71 | const struct GNUNET_TESTING_Command *cmd; | 68 | struct GNUNET_SCHEDULER_Task *timeout_task; |
72 | 69 | ||
73 | /** | 70 | /** |
74 | * The interpreter of the test. | 71 | * Instruction pointer. Tells #interpreter_run() which instruction to run |
72 | * next. Need (signed) int because it gets -1 when rewinding the | ||
73 | * interpreter to the first CMD. | ||
75 | */ | 74 | */ |
76 | struct GNUNET_TESTING_Interpreter *is; | 75 | int ip; |
76 | |||
77 | /** | ||
78 | * Result of the testcases, #GNUNET_OK on success | ||
79 | */ | ||
80 | enum GNUNET_GenericReturnValue result; | ||
81 | |||
77 | }; | 82 | }; |
78 | 83 | ||
79 | 84 | ||
80 | /** | ||
81 | * Lookup command by label. | ||
82 | * | ||
83 | * @param label label to look for | ||
84 | * @return NULL if command was not found | ||
85 | */ | ||
86 | const struct GNUNET_TESTING_Command * | 85 | const struct GNUNET_TESTING_Command * |
87 | GNUNET_TESTING_interpreter_lookup_command (const char *label) | 86 | GNUNET_TESTING_interpreter_lookup_command ( |
87 | struct GNUNET_TESTING_Interpreter *is, | ||
88 | const char *label) | ||
88 | { | 89 | { |
89 | if (NULL == label) | 90 | if (NULL == label) |
90 | { | 91 | { |
@@ -103,7 +104,7 @@ GNUNET_TESTING_interpreter_lookup_command (const char *label) | |||
103 | label)) ) | 104 | label)) ) |
104 | return cmd; | 105 | return cmd; |
105 | 106 | ||
106 | if (GNUNET_TESTING_cmd_is_batch (cmd)) | 107 | if (GNUNET_TESTING_cmd_is_batch_ (cmd)) |
107 | { | 108 | { |
108 | #define BATCH_INDEX 1 | 109 | #define BATCH_INDEX 1 |
109 | struct GNUNET_TESTING_Command *batch; | 110 | struct GNUNET_TESTING_Command *batch; |
@@ -111,7 +112,7 @@ GNUNET_TESTING_interpreter_lookup_command (const char *label) | |||
111 | struct GNUNET_TESTING_Command *icmd; | 112 | struct GNUNET_TESTING_Command *icmd; |
112 | const struct GNUNET_TESTING_Command *match; | 113 | const struct GNUNET_TESTING_Command *match; |
113 | 114 | ||
114 | current = GNUNET_TESTING_cmd_batch_get_current (cmd); | 115 | current = GNUNET_TESTING_cmd_batch_get_current_ (cmd); |
115 | GNUNET_assert (GNUNET_OK == | 116 | GNUNET_assert (GNUNET_OK == |
116 | GNUNET_TESTING_get_trait_cmd (cmd, | 117 | GNUNET_TESTING_get_trait_cmd (cmd, |
117 | BATCH_INDEX, | 118 | BATCH_INDEX, |
@@ -134,10 +135,58 @@ GNUNET_TESTING_interpreter_lookup_command (const char *label) | |||
134 | } | 135 | } |
135 | } | 136 | } |
136 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
137 | "Command not found: %s\n", | 138 | "Command `%s' not found\n", |
138 | label); | 139 | label); |
139 | return NULL; | 140 | return NULL; |
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Finish the test run, return the final result. | ||
146 | * | ||
147 | * @param cls the `struct GNUNET_TESTING_Interpreter` | ||
148 | */ | ||
149 | static void | ||
150 | finish_test (void *cls) | ||
151 | { | ||
152 | struct GNUNET_TESTING_Interpreter *is = cls; | ||
153 | struct GNUNET_TESTING_Command *cmd; | ||
154 | const char *label; | ||
140 | 155 | ||
156 | is->final_task = NULL; | ||
157 | label = is->commands[is->ip].label; | ||
158 | if (NULL == label) | ||
159 | label = "END"; | ||
160 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
161 | "Interpreter finishes at `%s' with status %d\n", | ||
162 | label, | ||
163 | is->result); | ||
164 | for (unsigned int j = 0; | ||
165 | NULL != (cmd = &is->commands[j])->label; | ||
166 | j++) | ||
167 | { | ||
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
169 | "Cleaning up cmd %s\n", | ||
170 | cmd->label); | ||
171 | cmd->cleanup (cmd->cls); | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
173 | "Cleaned up cmd %s\n", | ||
174 | cmd->label); | ||
175 | } | ||
176 | if (NULL != is->task) | ||
177 | { | ||
178 | GNUNET_SCHEDULER_cancel (is->task); | ||
179 | is->task = NULL; | ||
180 | } | ||
181 | if (NULL != is->timeout_task) | ||
182 | { | ||
183 | GNUNET_SCHEDULER_cancel (is->timeout_task); | ||
184 | is->timeout_task = NULL; | ||
185 | } | ||
186 | GNUNET_free (is->commands); | ||
187 | is->rc (is->rc_cls, | ||
188 | is->result); | ||
189 | GNUNET_free (is); | ||
141 | } | 190 | } |
142 | 191 | ||
143 | 192 | ||
@@ -163,15 +212,10 @@ interpreter_next (void *cls) | |||
163 | 212 | ||
164 | if (GNUNET_SYSERR == is->result) | 213 | if (GNUNET_SYSERR == is->result) |
165 | return; /* ignore, we already failed! */ | 214 | return; /* ignore, we already failed! */ |
166 | if (GNUNET_TESTING_cmd_is_batch (cmd)) | 215 | cmd->finish_time = GNUNET_TIME_absolute_get (); |
167 | { | 216 | if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) || |
168 | GNUNET_TESTING_cmd_batch_next (is); | 217 | (! GNUNET_TESTING_cmd_batch_next_ (cmd->cls)) ) |
169 | } | ||
170 | else | ||
171 | { | ||
172 | cmd->finish_time = GNUNET_TIME_absolute_get (); | ||
173 | is->ip++; | 218 | is->ip++; |
174 | } | ||
175 | if (0 == (ipc % 1000)) | 219 | if (0 == (ipc % 1000)) |
176 | { | 220 | { |
177 | if (0 != ipc) | 221 | if (0 != ipc) |
@@ -188,253 +232,44 @@ interpreter_next (void *cls) | |||
188 | } | 232 | } |
189 | 233 | ||
190 | 234 | ||
191 | /** | ||
192 | * This function checks if the finish function of a command returns GNUNET_YES, when the command is finished. In this case the finish function might have called interpreter_next. IF GNUNET_NO was returned this function is added to the scheduler again. In case of an error interpreter_fail is called. | ||
193 | * | ||
194 | */ | ||
195 | static void | ||
196 | run_finish_task_next (void *cls) | ||
197 | { | ||
198 | struct FinishTaskClosure *ftc = cls; | ||
199 | const struct GNUNET_TESTING_Command *cmd = ftc->cmd; | ||
200 | struct GNUNET_TESTING_Interpreter *is = ftc->is; | ||
201 | unsigned int finished = cmd->finish (cmd->cls, &interpreter_next, is); | ||
202 | |||
203 | if (GNUNET_YES == finished) | ||
204 | { | ||
205 | is->finish_task = NULL; | ||
206 | } | ||
207 | else if (GNUNET_NO == finished) | ||
208 | { | ||
209 | is->finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD, | ||
210 | &run_finish_task_next, ftc); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
215 | "Next task finished with an error.\n"); | ||
216 | GNUNET_TESTING_interpreter_fail (); | ||
217 | } | ||
218 | |||
219 | } | ||
220 | |||
221 | |||
222 | /** | ||
223 | * This function checks if the finish function of an asynchronous command returns GNUNET_YES, when the command is finished. In this case the finish function might have called interpreter_next. IF GNUNET_NO was returned this function is added to the scheduler again. In case of an error interpreter_fail is called. | ||
224 | * | ||
225 | * //TODO run_finish_task_next and this function can be merged. | ||
226 | * | ||
227 | */ | ||
228 | static void | ||
229 | run_finish_task_sync (void *cls) | ||
230 | { | ||
231 | struct SyncTaskClosure *stc = cls; | ||
232 | const struct GNUNET_TESTING_Command *cmd = stc->async_cmd; | ||
233 | const struct GNUNET_TESTING_Command *sync_cmd = stc->sync_cmd; | ||
234 | struct FinishTaskClosure *ftc; | ||
235 | struct SyncState *sync_state = sync_cmd->cls; | ||
236 | struct GNUNET_SCHEDULER_Task *finish_task = sync_state->finish_task; | ||
237 | unsigned int finished = cmd->finish (cmd->cls, &interpreter_next, is); | ||
238 | |||
239 | GNUNET_assert (NULL != finish_task); | ||
240 | ftc = GNUNET_new (struct FinishTaskClosure); | ||
241 | ftc->cmd = stc->sync_cmd; | ||
242 | ftc->is = stc->is; | ||
243 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | ||
244 | if (cmd->default_timeout.rel_value_us < now.abs_value_us | ||
245 | - sync_state->start_finish_time.abs_value_us) | ||
246 | { | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
248 | "The command with label %s did not finish its asynchronous task in time.\n", | ||
249 | cmd->label); | ||
250 | GNUNET_TESTING_interpreter_fail (); | ||
251 | } | ||
252 | |||
253 | if (GNUNET_YES == finished) | ||
254 | { | ||
255 | finish_task = NULL; | ||
256 | } | ||
257 | else if (GNUNET_NO == finished) | ||
258 | { | ||
259 | finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD, | ||
260 | &run_finish_task_sync, stc); | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
265 | "Sync task finished with an error.\n"); | ||
266 | GNUNET_TESTING_interpreter_fail (); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | |||
271 | /** | ||
272 | * run method of the command created by the interpreter to wait for another command to finish. | ||
273 | * | ||
274 | */ | ||
275 | static void | ||
276 | start_finish_on_ref (void *cls, | ||
277 | const struct GNUNET_TESTING_Command *cmd, | ||
278 | struct GNUNET_TESTING_Interpreter *is) | ||
279 | { | ||
280 | struct SyncState *sync_state = cls; | ||
281 | struct SyncTaskClosure *stc; | ||
282 | const struct GNUNET_TESTING_Command *async_cmd; | ||
283 | |||
284 | async_cmd = sync_state->async_cmd; | ||
285 | stc = GNUNET_new (struct SyncTaskClosure); | ||
286 | stc->async_cmd = async_cmd; | ||
287 | stc->sync_cmd = cmd; | ||
288 | stc->is = is; | ||
289 | sync_state->start_finish_time = GNUNET_TIME_absolute_get (); | ||
290 | sync_state->finish_task = GNUNET_SCHEDULER_add_delayed ( | ||
291 | CHECK_FINISHED_PERIOD, | ||
292 | &run_finish_task_sync, | ||
293 | stc); | ||
294 | } | ||
295 | |||
296 | |||
297 | /** | ||
298 | * Create (synchronous) command that waits for another command to finish. | ||
299 | * If @a cmd_ref did not finish after @a timeout, this command will fail | ||
300 | * the test case. | ||
301 | * | ||
302 | * @param finish_label label for this command | ||
303 | * @param cmd_ref reference to a previous command which we should | ||
304 | * wait for (call `finish()` on) | ||
305 | * @param timeout how long to wait at most for @a cmd_ref to finish | ||
306 | * @return a finish-command. | ||
307 | */ | ||
308 | const struct GNUNET_TESTING_Command | ||
309 | GNUNET_TESTING_cmd_finish (const char *finish_label, | ||
310 | const char *cmd_ref, | ||
311 | struct GNUNET_TIME_Relative timeout) | ||
312 | { | ||
313 | const struct GNUNET_TESTING_Command *async_cmd; | ||
314 | struct SyncState *sync_state; | ||
315 | |||
316 | async_cmd = GNUNET_TESTING_interpreter_lookup_command (cmd_ref); | ||
317 | sync_state = GNUNET_new (struct SyncState); | ||
318 | sync_state->async_cmd = async_cmd; | ||
319 | |||
320 | struct GNUNET_TESTING_Command cmd = { | ||
321 | .cls = sync_state, | ||
322 | .label = finish_label, | ||
323 | .run = &start_finish_on_ref, | ||
324 | .asynchronous_finish = GNUNET_NO | ||
325 | }; | ||
326 | |||
327 | return cmd; | ||
328 | } | ||
329 | |||
330 | |||
331 | const struct GNUNET_TESTING_Command | ||
332 | GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd) | ||
333 | { | ||
334 | |||
335 | GNUNET_assert (NULL != cmd.finish); | ||
336 | const struct GNUNET_TESTING_Command async_cmd = { | ||
337 | .cls = cmd.cls, | ||
338 | .label = cmd.label, | ||
339 | .run = cmd.run, | ||
340 | .cleanup = cmd.cleanup, | ||
341 | .traits = cmd.traits, | ||
342 | .finish = cmd.finish, | ||
343 | .asynchronous_finish = GNUNET_YES | ||
344 | }; | ||
345 | |||
346 | return async_cmd; | ||
347 | } | ||
348 | |||
349 | |||
350 | /** | ||
351 | * Current command failed, clean up and fail the test case. | ||
352 | * | ||
353 | * @param is interpreter of the test | ||
354 | */ | ||
355 | void | 235 | void |
356 | GNUNET_TESTING_interpreter_fail () | 236 | GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is) |
357 | { | 237 | { |
358 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; | 238 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; |
359 | 239 | ||
360 | if (GNUNET_SYSERR == is->result) | 240 | if (GNUNET_SYSERR == is->result) |
241 | { | ||
242 | GNUNET_break (0); | ||
361 | return; /* ignore, we already failed! */ | 243 | return; /* ignore, we already failed! */ |
362 | 244 | } | |
363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
364 | "interpreter_fail!\n"); | ||
365 | |||
366 | if (NULL != cmd) | 245 | if (NULL != cmd) |
367 | { | 246 | { |
368 | while (GNUNET_TESTING_cmd_is_batch (cmd)) | 247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
248 | "Failed at command `%s'\n", | ||
249 | cmd->label); | ||
250 | while (GNUNET_TESTING_cmd_is_batch_ (cmd)) | ||
369 | { | 251 | { |
370 | cmd = GNUNET_TESTING_cmd_batch_get_current (cmd); | 252 | cmd = GNUNET_TESTING_cmd_batch_get_current_ (cmd); |
371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 253 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
372 | "Batch is at command `%s'\n", | 254 | "Failed in batch at command `%s'\n", |
373 | cmd->label); | 255 | cmd->label); |
374 | } | 256 | } |
375 | |||
376 | } | 257 | } |
377 | else | 258 | else |
378 | { | 259 | { |
379 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
380 | "cmd is NULL.\n"); | 261 | "Failed with CMD being NULL!\n"); |
381 | } | 262 | } |
382 | |||
383 | if (NULL == cmd->label) | ||
384 | { | ||
385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
386 | "Failed at command `%s'\n", | ||
387 | cmd->label); | ||
388 | |||
389 | } | ||
390 | else | ||
391 | { | ||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
393 | "cmd->label is NULL.\n"); | ||
394 | } | ||
395 | |||
396 | is->result = GNUNET_SYSERR; | 263 | is->result = GNUNET_SYSERR; |
397 | GNUNET_SCHEDULER_shutdown (); | 264 | GNUNET_assert (NULL == is->final_task); |
398 | } | 265 | is->final_task = GNUNET_SCHEDULER_add_now (&finish_test, |
399 | 266 | is); | |
400 | |||
401 | /** | ||
402 | * Create command array terminator. | ||
403 | * | ||
404 | * @return a end-command. | ||
405 | */ | ||
406 | struct GNUNET_TESTING_Command | ||
407 | GNUNET_TESTING_cmd_end (void) | ||
408 | { | ||
409 | static struct GNUNET_TESTING_Command cmd; | ||
410 | cmd.label = NULL; | ||
411 | cmd.shutdown_on_end = GNUNET_YES; | ||
412 | |||
413 | return cmd; | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Create command array terminator without shutdown. | ||
418 | * | ||
419 | * @return a end-command. | ||
420 | */ | ||
421 | struct GNUNET_TESTING_Command | ||
422 | GNUNET_TESTING_cmd_end_without_shutdown (void) | ||
423 | { | ||
424 | static struct GNUNET_TESTING_Command cmd; | ||
425 | cmd.label = NULL; | ||
426 | cmd.shutdown_on_end = GNUNET_NO; | ||
427 | |||
428 | return cmd; | ||
429 | } | 267 | } |
430 | 268 | ||
431 | 269 | ||
432 | /** | ||
433 | * Obtain current label. | ||
434 | */ | ||
435 | const char * | 270 | const char * |
436 | GNUNET_TESTING_interpreter_get_current_label (struct | 271 | GNUNET_TESTING_interpreter_get_current_label ( |
437 | GNUNET_TESTING_Interpreter *is) | 272 | struct GNUNET_TESTING_Interpreter *is) |
438 | { | 273 | { |
439 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; | 274 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; |
440 | 275 | ||
@@ -450,189 +285,195 @@ GNUNET_TESTING_interpreter_get_current_label (struct | |||
450 | static void | 285 | static void |
451 | interpreter_run (void *cls) | 286 | interpreter_run (void *cls) |
452 | { | 287 | { |
453 | struct FinishTaskClosure *ftc; | ||
454 | struct GNUNET_TESTING_Interpreter *is = cls; | 288 | struct GNUNET_TESTING_Interpreter *is = cls; |
455 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; | 289 | struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip]; |
456 | bool shutdown_on_end = cmd->shutdown_on_end; | ||
457 | 290 | ||
458 | is->task = NULL; | 291 | is->task = NULL; |
459 | |||
460 | if (NULL == cmd->label) | 292 | if (NULL == cmd->label) |
461 | { | 293 | { |
462 | |||
463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
464 | "Running command END %p %u\n", | 295 | "Running command END\n"); |
465 | is, | ||
466 | shutdown_on_end); | ||
467 | is->result = GNUNET_OK; | 296 | is->result = GNUNET_OK; |
468 | if (GNUNET_YES == shutdown_on_end) | 297 | finish_test (is); |
469 | { | ||
470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
471 | "Running command END with shutdown\n"); | ||
472 | GNUNET_SCHEDULER_shutdown (); | ||
473 | } | ||
474 | return; | 298 | return; |
475 | } | 299 | } |
476 | else if (NULL != cmd) | 300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
477 | { | 301 | "Running command `%s'\n", |
478 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 302 | cmd->label); |
479 | "Running command `%s' %p\n", | ||
480 | cmd->label, | ||
481 | is); | ||
482 | } | ||
483 | cmd->start_time | 303 | cmd->start_time |
484 | = cmd->last_req_time | 304 | = cmd->last_req_time |
485 | = GNUNET_TIME_absolute_get (); | 305 | = GNUNET_TIME_absolute_get (); |
486 | cmd->num_tries = 1; | 306 | cmd->num_tries = 1; |
307 | if (NULL != cmd->ac) | ||
308 | { | ||
309 | cmd->ac->is = is; | ||
310 | cmd->ac->cont = &interpreter_next; | ||
311 | cmd->ac->cont_cls = is; | ||
312 | cmd->ac->finished = GNUNET_NO; | ||
313 | } | ||
487 | cmd->run (cmd->cls, | 314 | cmd->run (cmd->cls, |
488 | cmd, | ||
489 | is); | 315 | is); |
490 | if ((NULL != cmd->finish) && (GNUNET_NO == cmd->asynchronous_finish)) | 316 | if (NULL == cmd->ac) |
491 | { | 317 | { |
492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 318 | interpreter_next (is); |
493 | "Next task will not be called directly!\n"); | ||
494 | ftc = GNUNET_new (struct FinishTaskClosure); | ||
495 | ftc->cmd = cmd; | ||
496 | ftc->is = is; | ||
497 | is->finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD, | ||
498 | &run_finish_task_next, | ||
499 | ftc); | ||
500 | } | 319 | } |
501 | else | 320 | else if ( (cmd->asynchronous_finish) && |
321 | (NULL != cmd->ac->cont) ) | ||
502 | { | 322 | { |
323 | cmd->ac->cont = NULL; | ||
503 | interpreter_next (is); | 324 | interpreter_next (is); |
504 | } | 325 | } |
505 | } | 326 | } |
506 | 327 | ||
507 | 328 | ||
508 | /** | 329 | /** |
509 | * Function run when the test terminates (good or bad). | 330 | * Function run when the test terminates (good or bad) with timeout. |
510 | * Cleans up our state. | ||
511 | * | 331 | * |
512 | * @param cls the interpreter state. | 332 | * @param cls the interpreter state |
513 | */ | 333 | */ |
514 | static void | 334 | static void |
515 | do_shutdown (void *cls) | 335 | do_timeout (void *cls) |
516 | { | 336 | { |
517 | (void) cls; | 337 | struct GNUNET_TESTING_Interpreter *is = cls; |
518 | struct GNUNET_TESTING_Command *cmd; | ||
519 | const char *label; | ||
520 | 338 | ||
521 | label = is->commands[is->ip].label; | 339 | is->timeout_task = NULL; |
522 | if (NULL == label) | 340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
523 | label = "END"; | 341 | "Terminating test due to global timeout\n"); |
342 | is->result = GNUNET_SYSERR; | ||
343 | finish_test (is); | ||
344 | } | ||
524 | 345 | ||
525 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
526 | "Executing shutdown at `%s'\n", | ||
527 | label); | ||
528 | 346 | ||
529 | for (unsigned int j = 0; | 347 | void |
530 | NULL != (cmd = &is->commands[j])->label; | 348 | GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, |
531 | j++) { | 349 | struct GNUNET_TIME_Relative timeout, |
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 350 | GNUNET_TESTING_ResultCallback rc, |
533 | "Cleaning up cmd %s\n", | 351 | void *rc_cls) |
534 | cmd->label); | 352 | { |
535 | cmd->cleanup (cmd->cls, | 353 | struct GNUNET_TESTING_Interpreter *is; |
536 | cmd); | 354 | unsigned int i; |
537 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
538 | "Cleaned up cmd %s\n", | ||
539 | cmd->label); | ||
540 | } | ||
541 | |||
542 | if (NULL != is->finish_task) | ||
543 | { | ||
544 | GNUNET_SCHEDULER_cancel (is->finish_task); | ||
545 | cmd->finish_task = NULL; | ||
546 | } | ||
547 | 355 | ||
548 | if (NULL != is->task) | 356 | is = GNUNET_new (struct GNUNET_TESTING_Interpreter); |
549 | { | 357 | is->rc = rc; |
550 | GNUNET_SCHEDULER_cancel (is->task); | 358 | is->rc_cls = rc_cls; |
551 | is->task = NULL; | 359 | /* get the number of commands */ |
552 | } | 360 | for (i = 0; NULL != commands[i].label; i++) |
553 | if (NULL != is->timeout_task) | 361 | ; |
554 | { | 362 | is->commands = GNUNET_new_array (i + 1, |
555 | GNUNET_SCHEDULER_cancel (is->timeout_task); | 363 | struct GNUNET_TESTING_Command); |
556 | is->timeout_task = NULL; | 364 | memcpy (is->commands, |
557 | } | 365 | commands, |
558 | GNUNET_free (is->commands); | 366 | sizeof (struct GNUNET_TESTING_Command) * i); |
367 | is->timeout_task | ||
368 | = GNUNET_SCHEDULER_add_delayed (timeout, | ||
369 | &do_timeout, | ||
370 | is); | ||
371 | is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, | ||
372 | is); | ||
559 | } | 373 | } |
560 | 374 | ||
561 | 375 | ||
562 | /** | 376 | /** |
563 | * Function run when the test terminates (good or bad) with timeout. | 377 | * Closure for #loop_run(). |
378 | */ | ||
379 | struct MainParams | ||
380 | { | ||
381 | |||
382 | /** | ||
383 | * NULL-label terminated array of commands. | ||
384 | */ | ||
385 | struct GNUNET_TESTING_Command *commands; | ||
386 | |||
387 | /** | ||
388 | * Global timeout for the test. | ||
389 | */ | ||
390 | struct GNUNET_TIME_Relative timeout; | ||
391 | |||
392 | /** | ||
393 | * Set to #EXIT_FAILURE on error. | ||
394 | */ | ||
395 | int rv; | ||
396 | }; | ||
397 | |||
398 | |||
399 | /** | ||
400 | * Function called with the final result of the test. | ||
564 | * | 401 | * |
565 | * @param cls NULL | 402 | * @param cls the `struct MainParams` |
403 | * @param rv #GNUNET_OK if the test passed | ||
566 | */ | 404 | */ |
567 | static void | 405 | static void |
568 | do_timeout (void *cls) | 406 | handle_result (void *cls, |
407 | enum GNUNET_GenericReturnValue rv) | ||
569 | { | 408 | { |
570 | (void) cls; | 409 | struct MainParams *mp = cls; |
571 | 410 | ||
572 | is->timeout_task = NULL; | 411 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
573 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 412 | "Test exits with status %d\n", |
574 | "Terminating test due to timeout\n"); | 413 | rv); |
414 | if (GNUNET_OK != rv) | ||
415 | mp->rv = EXIT_FAILURE; | ||
575 | GNUNET_SCHEDULER_shutdown (); | 416 | GNUNET_SCHEDULER_shutdown (); |
576 | } | 417 | } |
577 | 418 | ||
578 | 419 | ||
579 | /** | 420 | /** |
580 | * Run the testsuite. Note, CMDs are copied into | 421 | * Main function to run the test cases. |
581 | * the interpreter state because they are _usually_ | ||
582 | * defined into the "run" method that returns after | ||
583 | * having scheduled the test interpreter. | ||
584 | * | 422 | * |
585 | * @param is the interpreter state | 423 | * @param cls a `struct MainParams *` |
586 | * @param commands the list of command to execute | ||
587 | * @param timeout how long to wait | ||
588 | */ | 424 | */ |
425 | static void | ||
426 | loop_run (void *cls) | ||
427 | { | ||
428 | struct MainParams *mp = cls; | ||
429 | |||
430 | GNUNET_TESTING_run (mp->commands, | ||
431 | mp->timeout, | ||
432 | &handle_result, | ||
433 | mp); | ||
434 | } | ||
435 | |||
436 | |||
589 | int | 437 | int |
590 | GNUNET_TESTING_run (const char *cfg_filename, | 438 | GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, |
591 | struct GNUNET_TESTING_Command *commands, | 439 | struct GNUNET_TIME_Relative timeout) |
592 | struct GNUNET_TIME_Relative timeout) | ||
593 | { | 440 | { |
594 | unsigned int i; | 441 | struct MainParams mp = { |
442 | .commands = commands, | ||
443 | .timeout = timeout, | ||
444 | .rv = EXIT_SUCCESS | ||
445 | }; | ||
595 | 446 | ||
596 | is = GNUNET_new (struct GNUNET_TESTING_Interpreter); | 447 | GNUNET_SCHEDULER_run (&loop_run, |
448 | &mp); | ||
449 | return mp.rv; | ||
450 | } | ||
597 | 451 | ||
598 | if (NULL != is->timeout_task) | 452 | |
599 | { | 453 | void |
600 | GNUNET_SCHEDULER_cancel (is->timeout_task); | 454 | GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac) |
601 | is->timeout_task = NULL; | 455 | { |
602 | } | 456 | GNUNET_assert (GNUNET_NO == ac->finished); |
603 | /* get the number of commands */ | 457 | ac->finished = GNUNET_SYSERR; |
604 | for (i = 0; NULL != commands[i].label; i++) | 458 | GNUNET_TESTING_interpreter_fail (ac->is); |
459 | if (NULL != ac->cont) | ||
605 | { | 460 | { |
606 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 461 | ac->cont (ac->cont_cls); |
607 | "on end %u\n", | 462 | ac->cont = NULL; |
608 | commands[i].shutdown_on_end); | ||
609 | } | 463 | } |
610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 464 | } |
611 | "on end %u\n", | 465 | |
612 | commands[i].shutdown_on_end); | ||
613 | // ; | ||
614 | is->commands = GNUNET_new_array (i + 1, | ||
615 | struct GNUNET_TESTING_Command); | ||
616 | memcpy (is->commands, | ||
617 | commands, | ||
618 | sizeof (struct GNUNET_TESTING_Command) * (i + 1)); | ||
619 | 466 | ||
620 | for (i = 0; NULL != is->commands[i].label; i++) | 467 | void |
468 | GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac) | ||
469 | { | ||
470 | GNUNET_assert (GNUNET_NO == ac->finished); | ||
471 | ac->finished = GNUNET_OK; | ||
472 | if (NULL != ac->cont) | ||
621 | { | 473 | { |
622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 474 | ac->cont (ac->cont_cls); |
623 | "on end %u\n", | 475 | ac->cont = NULL; |
624 | is->commands[i].shutdown_on_end); | ||
625 | } | 476 | } |
626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
627 | "on end %u\n", | ||
628 | is->commands[i].shutdown_on_end); | ||
629 | is->timeout_task = GNUNET_SCHEDULER_add_delayed | ||
630 | (timeout, | ||
631 | &do_timeout, | ||
632 | is); | ||
633 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); | ||
634 | is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is); | ||
635 | return GNUNET_OK; | ||
636 | } | 477 | } |
637 | 478 | ||
638 | 479 | ||
diff --git a/src/testing/testing_api_trait_cmd.c b/src/testing/testing_api_trait_cmd.c index 886baee5b..7afa8b264 100644 --- a/src/testing/testing_api_trait_cmd.c +++ b/src/testing/testing_api_trait_cmd.c | |||
@@ -41,7 +41,7 @@ | |||
41 | * @param[out] _cmd where to write the wire details. | 41 | * @param[out] _cmd where to write the wire details. |
42 | * @return #GNUNET_OK on success. | 42 | * @return #GNUNET_OK on success. |
43 | */ | 43 | */ |
44 | int | 44 | enum GNUNET_GenericReturnValue |
45 | GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, | 45 | GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, |
46 | unsigned int index, | 46 | unsigned int index, |
47 | struct GNUNET_TESTING_Command **_cmd) | 47 | struct GNUNET_TESTING_Command **_cmd) |
diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c index 66626833d..2f836ddfa 100644 --- a/src/testing/testing_api_traits.c +++ b/src/testing/testing_api_traits.c | |||
@@ -55,7 +55,7 @@ GNUNET_TESTING_trait_end () | |||
55 | * @param index index number of the object to extract. | 55 | * @param index index number of the object to extract. |
56 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | 56 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. |
57 | */ | 57 | */ |
58 | int | 58 | enum GNUNET_GenericReturnValue |
59 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, | 59 | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, |
60 | const void **ret, | 60 | const void **ret, |
61 | const char *trait, | 61 | const char *trait, |
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h index 005402a73..12db87d19 100644 --- a/src/testing/testing_cmds.h +++ b/src/testing/testing_cmds.h | |||
@@ -83,6 +83,8 @@ struct GNUNET_CMDS_LOCAL_FINISHED | |||
83 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED | 83 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED |
84 | */ | 84 | */ |
85 | struct GNUNET_MessageHeader header; | 85 | struct GNUNET_MessageHeader header; |
86 | |||
87 | enum GNUNET_GenericReturnValue result; | ||
86 | }; | 88 | }; |
87 | 89 | ||
88 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED | 90 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED |
diff --git a/src/topology/Makefile.am b/src/topology/Makefile.am index 8580d200c..e5920116b 100644 --- a/src/topology/Makefile.am +++ b/src/topology/Makefile.am | |||
@@ -42,10 +42,8 @@ gnunet_daemon_topology_LDADD = \ | |||
42 | $(GN_LIBINTL) | 42 | $(GN_LIBINTL) |
43 | 43 | ||
44 | 44 | ||
45 | if HAVE_TESTING | ||
46 | check_PROGRAMS = \ | 45 | check_PROGRAMS = \ |
47 | test_gnunet_daemon_topology | 46 | test_gnunet_daemon_topology |
48 | endif | ||
49 | 47 | ||
50 | if ENABLE_TEST_RUN | 48 | if ENABLE_TEST_RUN |
51 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 49 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 73544a8d5..d281c4ffb 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -128,11 +128,9 @@ noinst_PROGRAMS = \ | |||
128 | $(WLAN_BIN_SENDER) \ | 128 | $(WLAN_BIN_SENDER) \ |
129 | $(WLAN_BIN_RECEIVER) | 129 | $(WLAN_BIN_RECEIVER) |
130 | 130 | ||
131 | if HAVE_TESTING | ||
132 | TESTING_LIBS = \ | 131 | TESTING_LIBS = \ |
133 | libgnunettransporttesting.la \ | 132 | libgnunettransporttesting.la \ |
134 | libgnunettransporttesting2.la | 133 | libgnunettransporttesting2.la |
135 | endif | ||
136 | 134 | ||
137 | lib_LTLIBRARIES = \ | 135 | lib_LTLIBRARIES = \ |
138 | libgnunettransport.la \ | 136 | libgnunettransport.la \ |
@@ -161,16 +159,10 @@ libgnunettransporttesting_la_LDFLAGS = \ | |||
161 | 159 | ||
162 | libgnunettransporttesting2_la_SOURCES = \ | 160 | libgnunettransporttesting2_la_SOURCES = \ |
163 | transport_api_cmd_connecting_peers.c \ | 161 | transport_api_cmd_connecting_peers.c \ |
164 | transport_api_cmd_connecting_peers_v2.c \ | ||
165 | transport_api_cmd_connecting_peers_v3.c \ | ||
166 | transport_api_cmd_backchannel_check.c \ | 162 | transport_api_cmd_backchannel_check.c \ |
167 | transport_api_cmd_start_peer.c \ | 163 | transport_api_cmd_start_peer.c \ |
168 | transport_api_cmd_start_peer_v2.c \ | ||
169 | transport_api_cmd_start_peer_v3.c \ | ||
170 | transport_api_cmd_stop_peer.c \ | 164 | transport_api_cmd_stop_peer.c \ |
171 | transport_api_cmd_send_simple.c \ | 165 | transport_api_cmd_send_simple.c \ |
172 | transport_api_cmd_send_simple_v2.c \ | ||
173 | transport_api_cmd_send_simple_v3.c \ | ||
174 | transport-testing2.c transport-testing2.h \ | 166 | transport-testing2.c transport-testing2.h \ |
175 | transport-testing-cmds.h \ | 167 | transport-testing-cmds.h \ |
176 | transport-testing-filenames2.c \ | 168 | transport-testing-filenames2.c \ |
@@ -398,7 +390,6 @@ plugin_LTLIBRARIES = \ | |||
398 | $(WLAN_PLUGIN_LA) \ | 390 | $(WLAN_PLUGIN_LA) \ |
399 | $(BT_PLUGIN_LA) \ | 391 | $(BT_PLUGIN_LA) \ |
400 | libgnunet_test_transport_plugin_cmd_simple_send.la \ | 392 | libgnunet_test_transport_plugin_cmd_simple_send.la \ |
401 | libgnunet_test_transport_plugin_cmd_simple_send_v2.la \ | ||
402 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la | 393 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la |
403 | 394 | ||
404 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ | 395 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ |
@@ -435,23 +426,6 @@ libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ | |||
435 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ | 426 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ |
436 | $(GN_PLUGIN_LDFLAGS) | 427 | $(GN_PLUGIN_LDFLAGS) |
437 | 428 | ||
438 | libgnunet_test_transport_plugin_cmd_simple_send_v2_la_SOURCES = \ | ||
439 | test_transport_plugin_cmd_simple_send_v2.c | ||
440 | libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \ | ||
441 | libgnunettransporttesting2.la \ | ||
442 | libgnunettransportapplication.la \ | ||
443 | libgnunettransportcore.la \ | ||
444 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
445 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
446 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
447 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
448 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
449 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
450 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
451 | $(LTLIBINTL) | ||
452 | libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LDFLAGS = \ | ||
453 | $(GN_PLUGIN_LDFLAGS) | ||
454 | |||
455 | if HAVE_EXPERIMENTAL | 429 | if HAVE_EXPERIMENTAL |
456 | plugin_LTLIBRARIES += \ | 430 | plugin_LTLIBRARIES += \ |
457 | libgnunet_plugin_transport_udp.la | 431 | libgnunet_plugin_transport_udp.la |
@@ -596,10 +570,7 @@ libgnunet_plugin_transport_https_server_la_LDFLAGS = \ | |||
596 | libgnunet_plugin_transport_https_server_la_CFLAGS = \ | 570 | libgnunet_plugin_transport_https_server_la_CFLAGS = \ |
597 | $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS | 571 | $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS |
598 | 572 | ||
599 | if HAVE_TESTING | ||
600 | check_PROGRAMS = \ | 573 | check_PROGRAMS = \ |
601 | test_transport_simple_send \ | ||
602 | test_transport_simple_send_v2 \ | ||
603 | test_transport_start_with_config \ | 574 | test_transport_start_with_config \ |
604 | test_transport_address_switch_tcp \ | 575 | test_transport_address_switch_tcp \ |
605 | test_transport_testing_startstop \ | 576 | test_transport_testing_startstop \ |
@@ -684,7 +655,6 @@ check_PROGRAMS += \ | |||
684 | test_communicator_backchannel-udp \ | 655 | test_communicator_backchannel-udp \ |
685 | test_communicator_bidirect-tcp | 656 | test_communicator_bidirect-tcp |
686 | endif | 657 | endif |
687 | endif | ||
688 | 658 | ||
689 | if ENABLE_TEST_RUN | 659 | if ENABLE_TEST_RUN |
690 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 660 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
@@ -749,8 +719,6 @@ test_transport_api_slow_ats | |||
749 | endif | 719 | endif |
750 | if HAVE_EXPERIMENTAL | 720 | if HAVE_EXPERIMENTAL |
751 | TESTS += \ | 721 | TESTS += \ |
752 | test_transport_simple_send \ | ||
753 | test_transport_simple_send_v2 \ | ||
754 | test_transport_start_with_config \ | 722 | test_transport_start_with_config \ |
755 | test_transport_address_switch_udp \ | 723 | test_transport_address_switch_udp \ |
756 | test_plugin_udp \ | 724 | test_plugin_udp \ |
@@ -771,7 +739,6 @@ endif | |||
771 | 739 | ||
772 | check_SCRIPTS= \ | 740 | check_SCRIPTS= \ |
773 | test_transport_simple_send.sh \ | 741 | test_transport_simple_send.sh \ |
774 | test_transport_simple_send_v2.sh \ | ||
775 | test_transport_udp_backchannel.sh | 742 | test_transport_udp_backchannel.sh |
776 | 743 | ||
777 | test_transport_start_with_config_SOURCES = \ | 744 | test_transport_start_with_config_SOURCES = \ |
@@ -784,26 +751,6 @@ test_transport_start_with_config_LDADD = \ | |||
784 | libgnunettransportcore.la \ | 751 | libgnunettransportcore.la \ |
785 | libgnunettransporttesting2.la | 752 | libgnunettransporttesting2.la |
786 | 753 | ||
787 | test_transport_simple_send_SOURCES = \ | ||
788 | test_transport_simple_send.c | ||
789 | test_transport_simple_send_LDADD = \ | ||
790 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
791 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
792 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
793 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
794 | libgnunettransportcore.la \ | ||
795 | libgnunettransporttesting2.la | ||
796 | |||
797 | test_transport_simple_send_v2_SOURCES = \ | ||
798 | test_transport_simple_send_v2.c | ||
799 | test_transport_simple_send_v2_LDADD = \ | ||
800 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
801 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
802 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
803 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
804 | libgnunettransportcore.la \ | ||
805 | libgnunettransporttesting2.la | ||
806 | |||
807 | test_transport_testing_startstop_SOURCES = \ | 754 | test_transport_testing_startstop_SOURCES = \ |
808 | test_transport_testing_startstop.c | 755 | test_transport_testing_startstop.c |
809 | test_transport_testing_startstop_LDADD = \ | 756 | test_transport_testing_startstop_LDADD = \ |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index b578219ca..8889f9d06 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -37,28 +37,33 @@ | |||
37 | 37 | ||
38 | #define BASE_DIR "testdir" | 38 | #define BASE_DIR "testdir" |
39 | 39 | ||
40 | /** | ||
41 | * The name for a specific test environment directory. | ||
42 | * | ||
43 | */ | ||
44 | char *testdir; | ||
45 | 40 | ||
46 | /** | 41 | struct TestState |
47 | * The name for the configuration file of the specific node. | 42 | { |
48 | * | 43 | /** |
49 | */ | 44 | * Callback to write messages to the master loop. |
50 | char *cfgname; | 45 | * |
46 | */ | ||
47 | TESTING_CMD_HELPER_write_cb write_message; | ||
51 | 48 | ||
52 | /** | 49 | /** |
53 | * Flag indicating if all peers have been started. | 50 | * The name for a specific test environment directory. |
54 | * | 51 | * |
55 | */ | 52 | */ |
56 | unsigned int are_all_peers_started; | 53 | char *testdir; |
57 | 54 | ||
58 | /** | 55 | /** |
59 | * Flag indicating a received message. | 56 | * The name for the configuration file of the specific node. |
60 | */ | 57 | * |
61 | unsigned int message_received; | 58 | */ |
59 | char *cfgname; | ||
60 | }; | ||
61 | |||
62 | static struct GNUNET_TESTING_Command block_send; | ||
63 | |||
64 | static struct GNUNET_TESTING_Command block_receive; | ||
65 | |||
66 | static struct GNUNET_TESTING_Command connect_peers; | ||
62 | 67 | ||
63 | 68 | ||
64 | /** | 69 | /** |
@@ -83,7 +88,14 @@ static void | |||
83 | handle_test (void *cls, | 88 | handle_test (void *cls, |
84 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 89 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
85 | { | 90 | { |
86 | message_received = GNUNET_YES; | 91 | struct GNUNET_TESTING_AsyncContext *ac; |
92 | |||
93 | GNUNET_TESTING_get_trait_async_context (&block_receive, | ||
94 | &ac); | ||
95 | if ((NULL == ac) || (NULL == ac->cont)) | ||
96 | GNUNET_TESTING_async_fail (ac); | ||
97 | else | ||
98 | GNUNET_TESTING_async_finish (ac); | ||
87 | } | 99 | } |
88 | 100 | ||
89 | 101 | ||
@@ -94,7 +106,62 @@ handle_test (void *cls, | |||
94 | static void | 106 | static void |
95 | all_peers_started () | 107 | all_peers_started () |
96 | { | 108 | { |
97 | are_all_peers_started = GNUNET_YES; | 109 | struct GNUNET_TESTING_AsyncContext *ac; |
110 | |||
111 | GNUNET_TESTING_get_trait_async_context (&block_send, | ||
112 | &ac); | ||
113 | if ((NULL == ac) || (NULL == ac->cont)) | ||
114 | GNUNET_TESTING_async_fail (ac); | ||
115 | else | ||
116 | GNUNET_TESTING_async_finish (ac); | ||
117 | } | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Function called with the final result of the test. | ||
122 | * | ||
123 | * @param cls the `struct MainParams` | ||
124 | * @param rv #GNUNET_OK if the test passed | ||
125 | */ | ||
126 | static void | ||
127 | handle_result (void *cls, | ||
128 | enum GNUNET_GenericReturnValue rv) | ||
129 | { | ||
130 | struct TestState *ts = cls; | ||
131 | struct GNUNET_MessageHeader *reply; | ||
132 | |||
133 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
134 | "Local test exits with status %d\n", | ||
135 | rv); | ||
136 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | ||
137 | |||
138 | ts->write_message (reply, | ||
139 | ntohs (reply->size)); | ||
140 | GNUNET_free (ts->testdir); | ||
141 | GNUNET_free (ts->cfgname); | ||
142 | GNUNET_free (ts); | ||
143 | } | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Callback from start peer cmd for signaling a peer got connected. | ||
148 | * | ||
149 | */ | ||
150 | static void * | ||
151 | notify_connect (void *cls, | ||
152 | const struct GNUNET_PeerIdentity *peer, | ||
153 | struct GNUNET_MQ_Handle *mq) | ||
154 | { | ||
155 | struct ConnectPeersState *cps; | ||
156 | |||
157 | GNUNET_TESTING_get_trait_connect_peer_state (&connect_peers, | ||
158 | &cps); | ||
159 | void *ret = NULL; | ||
160 | |||
161 | cps->notify_connect (cps, | ||
162 | peer, | ||
163 | mq); | ||
164 | return ret; | ||
98 | } | 165 | } |
99 | 166 | ||
100 | 167 | ||
@@ -116,24 +183,46 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
116 | char *local_m) | 183 | char *local_m) |
117 | { | 184 | { |
118 | 185 | ||
119 | GNUNET_asprintf (&cfgname, | 186 | unsigned int n_int; |
120 | "test_transport_api2_tcp_node%s.conf", | 187 | unsigned int m_int; |
121 | "1"); | 188 | unsigned int local_m_int; |
189 | unsigned int num; | ||
190 | struct TestState *ts = GNUNET_new (struct TestState); | ||
191 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
192 | GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); | ||
193 | |||
194 | if (0 == m_int) | ||
195 | num = n_int; | ||
196 | else | ||
197 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | ||
198 | |||
199 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | ||
200 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
201 | "block-receive"); | ||
202 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | ||
203 | "start-peer", | ||
204 | "system-create", | ||
205 | num, | ||
206 | NULL); | ||
207 | |||
208 | |||
209 | |||
210 | sscanf (m, "%u", &m_int); | ||
211 | sscanf (n, "%u", &n_int); | ||
212 | sscanf (local_m, "%u", &local_m_int); | ||
213 | |||
214 | GNUNET_asprintf (&ts->cfgname, | ||
215 | "test_transport_api2_tcp_node1.conf"); | ||
122 | 216 | ||
123 | LOG (GNUNET_ERROR_TYPE_ERROR, | 217 | LOG (GNUNET_ERROR_TYPE_ERROR, |
124 | "plugin cfgname: %s\n", | 218 | "plugin cfgname: %s\n", |
125 | cfgname); | 219 | ts->cfgname); |
126 | 220 | ||
127 | LOG (GNUNET_ERROR_TYPE_ERROR, | 221 | LOG (GNUNET_ERROR_TYPE_ERROR, |
128 | "node ip: %s\n", | 222 | "node ip: %s\n", |
129 | node_ip); | 223 | node_ip); |
130 | 224 | ||
131 | LOG (GNUNET_ERROR_TYPE_ERROR, | 225 | GNUNET_asprintf (&ts->testdir, |
132 | "m: %s n: %s\n", | ||
133 | m, | ||
134 | n); | ||
135 | |||
136 | GNUNET_asprintf (&testdir, | ||
137 | "%s%s%s", | 226 | "%s%s%s", |
138 | BASE_DIR, | 227 | BASE_DIR, |
139 | m, | 228 | m, |
@@ -143,50 +232,38 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
143 | GNUNET_MQ_hd_var_size (test, | 232 | GNUNET_MQ_hd_var_size (test, |
144 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | 233 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, |
145 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | 234 | struct GNUNET_TRANSPORT_TESTING_TestMessage, |
146 | NULL), | 235 | ts), |
147 | GNUNET_MQ_handler_end () | 236 | GNUNET_MQ_handler_end () |
148 | }; | 237 | }; |
149 | 238 | ||
150 | struct GNUNET_TESTING_Command commands[] = { | 239 | struct GNUNET_TESTING_Command commands[] = { |
151 | GNUNET_TESTING_cmd_system_create ("system-create", | 240 | GNUNET_TESTING_cmd_system_create ("system-create", |
152 | testdir), | 241 | ts->testdir), |
153 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer", | 242 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer", |
154 | "system-create", | 243 | "system-create", |
155 | m, | 244 | num, |
156 | n, | ||
157 | local_m, | ||
158 | node_ip, | 245 | node_ip, |
159 | handlers, | 246 | handlers, |
160 | cfgname), | 247 | ts->cfgname, |
248 | notify_connect), | ||
161 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | 249 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", |
162 | write_message), | 250 | write_message), |
163 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block", | 251 | block_send, |
164 | &are_all_peers_started), | 252 | connect_peers, |
165 | GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | ||
166 | "start-peer", | ||
167 | "system-create", | ||
168 | (atoi (n) - 1) * atoi (local_m) + atoi ( | ||
169 | m)), | ||
170 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", | 253 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", |
171 | m, | 254 | "start-peer", |
172 | n, | 255 | num), |
173 | (atoi (n) - 1) * atoi (local_m) + atoi ( | 256 | block_receive, |
174 | m), | ||
175 | "start-peer"), | ||
176 | GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive", | ||
177 | &message_received), | ||
178 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 257 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
179 | "start-peer"), | 258 | "start-peer"), |
180 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 259 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
181 | "system-create"), | 260 | "system-create") |
182 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished", | ||
183 | write_message), | ||
184 | GNUNET_TESTING_cmd_end_without_shutdown () | ||
185 | }; | 261 | }; |
186 | 262 | ||
187 | GNUNET_TESTING_run (NULL, | 263 | GNUNET_TESTING_run (commands, |
188 | commands, | 264 | GNUNET_TIME_UNIT_FOREVER_REL, |
189 | GNUNET_TIME_UNIT_FOREVER_REL); | 265 | &handle_result, |
266 | ts); | ||
190 | 267 | ||
191 | } | 268 | } |
192 | 269 | ||
@@ -225,8 +302,6 @@ libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls) | |||
225 | struct GNUNET_TESTING_PluginFunctions *api = cls; | 302 | struct GNUNET_TESTING_PluginFunctions *api = cls; |
226 | 303 | ||
227 | GNUNET_free (api); | 304 | GNUNET_free (api); |
228 | GNUNET_free (testdir); | ||
229 | GNUNET_free (cfgname); | ||
230 | return NULL; | 305 | return NULL; |
231 | } | 306 | } |
232 | 307 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_v2.c b/src/transport/test_transport_plugin_cmd_simple_send_v2.c deleted file mode 100644 index c308d9a29..000000000 --- a/src/transport/test_transport_plugin_cmd_simple_send_v2.c +++ /dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testbed/plugin_cmd_simple_send.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_transport_application_service.h" | ||
30 | #include "transport-testing2.h" | ||
31 | #include "transport-testing-cmds.h" | ||
32 | |||
33 | /** | ||
34 | * Generic logging shortcut | ||
35 | */ | ||
36 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
37 | |||
38 | #define BASE_DIR "testdir" | ||
39 | |||
40 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
41 | |||
42 | /** | ||
43 | * The name for a specific test environment directory. | ||
44 | * | ||
45 | */ | ||
46 | char *testdir; | ||
47 | |||
48 | /** | ||
49 | * The name for the configuration file of the specific node. | ||
50 | * | ||
51 | */ | ||
52 | char *cfgname; | ||
53 | |||
54 | /** | ||
55 | * Flag indicating if all peers have been started. | ||
56 | * | ||
57 | */ | ||
58 | unsigned int are_all_peers_started; | ||
59 | |||
60 | /** | ||
61 | * Flag indicating a received message. | ||
62 | */ | ||
63 | unsigned int message_received; | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | ||
68 | * received. | ||
69 | * | ||
70 | */ | ||
71 | static int | ||
72 | check_test (void *cls, | ||
73 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
74 | { | ||
75 | return GNUNET_OK; | ||
76 | } | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE | ||
81 | * being received. | ||
82 | * | ||
83 | */ | ||
84 | static void | ||
85 | handle_test (void *cls, | ||
86 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
87 | { | ||
88 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
89 | "Message received\n"); | ||
90 | message_received = GNUNET_YES; | ||
91 | } | ||
92 | |||
93 | |||
94 | /** | ||
95 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | ||
96 | * | ||
97 | */ | ||
98 | static void | ||
99 | all_peers_started () | ||
100 | { | ||
101 | are_all_peers_started = GNUNET_YES; | ||
102 | } | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Function to start a local test case. | ||
107 | * | ||
108 | * @param write_message Callback to send a message to the master loop. | ||
109 | * @param router_ip Global address of the network namespace. | ||
110 | * @param node_ip Local address of a node i a network namespace. | ||
111 | * @param m The number of the node in a network namespace. | ||
112 | * @param n The number of the network namespace. | ||
113 | * @param local_m The number of nodes in a network namespace. | ||
114 | */ | ||
115 | static void | ||
116 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | ||
117 | char *node_ip, | ||
118 | char *m, | ||
119 | char *n, | ||
120 | char *local_m) | ||
121 | { | ||
122 | |||
123 | unsigned int n_int, m_int, local_m_int, num; | ||
124 | |||
125 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
126 | GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); | ||
127 | |||
128 | sscanf (m, "%u", &m_int); | ||
129 | sscanf (n, "%u", &n_int); | ||
130 | sscanf (local_m, "%u", &local_m_int); | ||
131 | |||
132 | |||
133 | if (0 == m_int) | ||
134 | num = n_int; | ||
135 | else | ||
136 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | ||
137 | |||
138 | GNUNET_asprintf (&cfgname, | ||
139 | "test_transport_api2_tcp_node1.conf"); | ||
140 | |||
141 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
142 | "plugin cfgname: %s\n", | ||
143 | cfgname); | ||
144 | |||
145 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
146 | "node ip: %s\n", | ||
147 | node_ip); | ||
148 | |||
149 | GNUNET_asprintf (&testdir, | ||
150 | "%s%s%s", | ||
151 | BASE_DIR, | ||
152 | m, | ||
153 | n); | ||
154 | |||
155 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
156 | GNUNET_MQ_hd_var_size (test, | ||
157 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | ||
158 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
159 | NULL), | ||
160 | GNUNET_MQ_handler_end () | ||
161 | }; | ||
162 | |||
163 | struct GNUNET_TESTING_Command commands[] = { | ||
164 | GNUNET_TESTING_cmd_system_create ("system-create", | ||
165 | testdir), | ||
166 | GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer", | ||
167 | "system-create", | ||
168 | num, | ||
169 | node_ip, | ||
170 | handlers, | ||
171 | cfgname), | ||
172 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | ||
173 | write_message), | ||
174 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block", | ||
175 | &are_all_peers_started), | ||
176 | GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers", | ||
177 | "start-peer", | ||
178 | "system-create", | ||
179 | num), | ||
180 | GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple", | ||
181 | "start-peer", | ||
182 | num), | ||
183 | GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive", | ||
184 | &message_received), | ||
185 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | ||
186 | "start-peer"), | ||
187 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | ||
188 | "system-create"), | ||
189 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished", | ||
190 | write_message), | ||
191 | GNUNET_TESTING_cmd_end_without_shutdown () | ||
192 | }; | ||
193 | |||
194 | GNUNET_TESTING_run (NULL, | ||
195 | commands, | ||
196 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
197 | |||
198 | } | ||
199 | |||
200 | |||
201 | /** | ||
202 | * Entry point for the plugin. | ||
203 | * | ||
204 | * @param cls NULL | ||
205 | * @return the exported block API | ||
206 | */ | ||
207 | void * | ||
208 | libgnunet_test_transport_plugin_cmd_simple_send_v2_init (void *cls) | ||
209 | { | ||
210 | struct GNUNET_TESTING_PluginFunctions *api; | ||
211 | |||
212 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | ||
213 | api->start_testcase = &start_testcase; | ||
214 | api->all_peers_started = &all_peers_started; | ||
215 | return api; | ||
216 | } | ||
217 | |||
218 | |||
219 | /** | ||
220 | * Exit point from the plugin. | ||
221 | * | ||
222 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init | ||
223 | * @return NULL | ||
224 | */ | ||
225 | void * | ||
226 | libgnunet_test_transport_plugin_cmd_simple_send_v2_done (void *cls) | ||
227 | { | ||
228 | struct GNUNET_TESTING_PluginFunctions *api = cls; | ||
229 | |||
230 | GNUNET_free (api); | ||
231 | GNUNET_free (testdir); | ||
232 | GNUNET_free (cfgname); | ||
233 | return NULL; | ||
234 | } | ||
235 | |||
236 | |||
237 | /* end of plugin_cmd_simple_send.c */ | ||
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index e2e0b258b..b0ca37447 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -39,34 +39,32 @@ | |||
39 | 39 | ||
40 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" | 40 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" |
41 | 41 | ||
42 | /** | 42 | struct TestState |
43 | * The name for a specific test environment directory. | 43 | { |
44 | * | 44 | /** |
45 | */ | 45 | * Callback to write messages to the master loop. |
46 | char *testdir; | 46 | * |
47 | */ | ||
48 | TESTING_CMD_HELPER_write_cb write_message; | ||
47 | 49 | ||
48 | /** | 50 | /** |
49 | * The name for the configuration file of the specific node. | 51 | * The name for a specific test environment directory. |
50 | * | 52 | * |
51 | */ | 53 | */ |
52 | char *cfgname; | 54 | char *testdir; |
53 | 55 | ||
54 | /** | 56 | /** |
55 | * Flag indicating if all peers have been started. | 57 | * The name for the configuration file of the specific node. |
56 | * | 58 | * |
57 | */ | 59 | */ |
58 | unsigned int are_all_peers_started; | 60 | char *cfgname; |
61 | }; | ||
59 | 62 | ||
60 | /** | 63 | static struct GNUNET_TESTING_Command block_send; |
61 | * Flag indicating if all local tests are prepared to finish. | ||
62 | * | ||
63 | */ | ||
64 | unsigned int are_all_local_tests_prepared; | ||
65 | 64 | ||
66 | /** | 65 | static struct GNUNET_TESTING_Command block_receive; |
67 | * Flag indicating a received message. | 66 | |
68 | */ | 67 | static struct GNUNET_TESTING_Command connect_peers; |
69 | unsigned int message_received; | ||
70 | 68 | ||
71 | 69 | ||
72 | /** | 70 | /** |
@@ -91,9 +89,14 @@ static void | |||
91 | handle_test (void *cls, | 89 | handle_test (void *cls, |
92 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 90 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
93 | { | 91 | { |
94 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 92 | struct GNUNET_TESTING_AsyncContext *ac; |
95 | "Message received.\n"); | 93 | |
96 | message_received = GNUNET_YES; | 94 | GNUNET_TESTING_get_trait_async_context (&block_receive, |
95 | &ac); | ||
96 | if ((NULL == ac) || (NULL == ac->cont)) | ||
97 | GNUNET_TESTING_async_fail (ac); | ||
98 | else | ||
99 | GNUNET_TESTING_async_finish (ac); | ||
97 | } | 100 | } |
98 | 101 | ||
99 | 102 | ||
@@ -104,14 +107,65 @@ handle_test (void *cls, | |||
104 | static void | 107 | static void |
105 | all_peers_started () | 108 | all_peers_started () |
106 | { | 109 | { |
107 | are_all_peers_started = GNUNET_YES; | 110 | struct GNUNET_TESTING_AsyncContext *ac; |
108 | LOG (GNUNET_ERROR_TYPE_ERROR, | 111 | |
109 | "setting are_all_peers_started: %d\n", | 112 | GNUNET_TESTING_get_trait_async_context (&block_send, |
110 | are_all_peers_started); | 113 | &ac); |
114 | if ((NULL == ac) || (NULL == ac->cont)) | ||
115 | GNUNET_TESTING_async_fail (ac); | ||
116 | else | ||
117 | GNUNET_TESTING_async_finish (ac); | ||
111 | } | 118 | } |
112 | 119 | ||
113 | 120 | ||
114 | /** | 121 | /** |
122 | * Function called with the final result of the test. | ||
123 | * | ||
124 | * @param cls the `struct MainParams` | ||
125 | * @param rv #GNUNET_OK if the test passed | ||
126 | */ | ||
127 | static void | ||
128 | handle_result (void *cls, | ||
129 | enum GNUNET_GenericReturnValue rv) | ||
130 | { | ||
131 | struct TestState *ts = cls; | ||
132 | struct GNUNET_MessageHeader *reply; | ||
133 | |||
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
135 | "Local test exits with status %d\n", | ||
136 | rv); | ||
137 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | ||
138 | |||
139 | ts->write_message (reply, | ||
140 | ntohs (reply->size)); | ||
141 | GNUNET_free (ts->testdir); | ||
142 | GNUNET_free (ts->cfgname); | ||
143 | GNUNET_free (ts); | ||
144 | } | ||
145 | |||
146 | |||
147 | /** | ||
148 | * Callback from start peer cmd for signaling a peer got connected. | ||
149 | * | ||
150 | */ | ||
151 | static void * | ||
152 | notify_connect (void *cls, | ||
153 | const struct GNUNET_PeerIdentity *peer, | ||
154 | struct GNUNET_MQ_Handle *mq) | ||
155 | { | ||
156 | struct ConnectPeersState *cps; | ||
157 | |||
158 | GNUNET_TESTING_get_trait_connect_peer_state (&connect_peers, | ||
159 | &cps); | ||
160 | void *ret = NULL; | ||
161 | |||
162 | cps->notify_connect (cps, | ||
163 | peer, | ||
164 | mq); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | /** | ||
115 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. | 169 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. |
116 | */ | 170 | */ |
117 | static void | 171 | static void |
@@ -120,7 +174,6 @@ all_local_tests_prepared () | |||
120 | are_all_local_tests_prepared = GNUNET_YES; | 174 | are_all_local_tests_prepared = GNUNET_YES; |
121 | } | 175 | } |
122 | 176 | ||
123 | |||
124 | /** | 177 | /** |
125 | * Function to start a local test case. | 178 | * Function to start a local test case. |
126 | * | 179 | * |
@@ -139,7 +192,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
139 | char *local_m) | 192 | char *local_m) |
140 | { | 193 | { |
141 | 194 | ||
142 | unsigned int n_int, m_int, local_m_int, num; | 195 | unsigned int n_int; |
196 | unsigned int m_int; | ||
197 | unsigned int local_m_int; | ||
198 | unsigned int num; | ||
199 | struct TestState *ts = GNUNET_new (struct TestState); | ||
143 | 200 | ||
144 | struct GNUNET_TESTING_NetjailTopology *topology = | 201 | struct GNUNET_TESTING_NetjailTopology *topology = |
145 | GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); | 202 | GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); |
@@ -154,18 +211,27 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
154 | else | 211 | else |
155 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | 212 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; |
156 | 213 | ||
157 | GNUNET_asprintf (&cfgname, | 214 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); |
215 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
216 | "block-receive"); | ||
217 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | ||
218 | "start-peer", | ||
219 | "system-create", | ||
220 | num, | ||
221 | NULL); | ||
222 | |||
223 | GNUNET_asprintf (&ts->cfgname, | ||
158 | "test_transport_api2_tcp_node1.conf"); | 224 | "test_transport_api2_tcp_node1.conf"); |
159 | 225 | ||
160 | LOG (GNUNET_ERROR_TYPE_ERROR, | 226 | LOG (GNUNET_ERROR_TYPE_ERROR, |
161 | "plugin cfgname: %s\n", | 227 | "plugin cfgname: %s\n", |
162 | cfgname); | 228 | ts->cfgname); |
163 | 229 | ||
164 | LOG (GNUNET_ERROR_TYPE_ERROR, | 230 | LOG (GNUNET_ERROR_TYPE_ERROR, |
165 | "node ip: %s\n", | 231 | "node ip: %s\n", |
166 | node_ip); | 232 | node_ip); |
167 | 233 | ||
168 | GNUNET_asprintf (&testdir, | 234 | GNUNET_asprintf (&ts->testdir, |
169 | "%s%s%s", | 235 | "%s%s%s", |
170 | BASE_DIR, | 236 | BASE_DIR, |
171 | m, | 237 | m, |
@@ -181,22 +247,18 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
181 | 247 | ||
182 | struct GNUNET_TESTING_Command commands[] = { | 248 | struct GNUNET_TESTING_Command commands[] = { |
183 | GNUNET_TESTING_cmd_system_create ("system-create", | 249 | GNUNET_TESTING_cmd_system_create ("system-create", |
184 | testdir), | 250 | ts->testdir), |
185 | GNUNET_TRANSPORT_cmd_start_peer_v3 ("start-peer", | 251 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer", |
186 | "system-create", | 252 | "system-create", |
187 | num, | 253 | num, |
188 | node_ip, | 254 | node_ip, |
189 | handlers, | 255 | handlers, |
190 | cfgname), | 256 | ts->cfgname, |
257 | notify_connect), | ||
191 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | 258 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", |
192 | write_message), | 259 | write_message), |
193 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block", | 260 | block_send, |
194 | &are_all_peers_started), | 261 | connect_peers, |
195 | GNUNET_TRANSPORT_cmd_connect_peers_v3 ("connect-peers", | ||
196 | "start-peer", | ||
197 | "system-create", | ||
198 | num, | ||
199 | topology), | ||
200 | GNUNET_TRANSPORT_cmd_backchannel_check ("backchannel-check", | 262 | GNUNET_TRANSPORT_cmd_backchannel_check ("backchannel-check", |
201 | "start-peer", | 263 | "start-peer", |
202 | "system-create", | 264 | "system-create", |
@@ -207,18 +269,17 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
207 | GNUNET_TESTING_cmd_local_test_prepared ("local-test-prepared", | 269 | GNUNET_TESTING_cmd_local_test_prepared ("local-test-prepared", |
208 | write_message, | 270 | write_message, |
209 | &are_all_local_tests_prepared), | 271 | &are_all_local_tests_prepared), |
272 | block_receive, | ||
210 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 273 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
211 | "start-peer"), | 274 | "start-peer"), |
212 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 275 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
213 | "system-create"), | 276 | "system-create") |
214 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished", | ||
215 | write_message), | ||
216 | GNUNET_TESTING_cmd_end_without_shutdown () | ||
217 | }; | 277 | }; |
218 | 278 | ||
219 | GNUNET_TESTING_run (NULL, | 279 | GNUNET_TESTING_run (commands, |
220 | commands, | 280 | GNUNET_TIME_UNIT_FOREVER_REL, |
221 | GNUNET_TIME_UNIT_FOREVER_REL); | 281 | &handle_result, |
282 | ts); | ||
222 | 283 | ||
223 | } | 284 | } |
224 | 285 | ||
@@ -258,8 +319,6 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_done (void *cls) | |||
258 | struct GNUNET_TESTING_PluginFunctions *api = cls; | 319 | struct GNUNET_TESTING_PluginFunctions *api = cls; |
259 | 320 | ||
260 | GNUNET_free (api); | 321 | GNUNET_free (api); |
261 | GNUNET_free (testdir); | ||
262 | GNUNET_free (cfgname); | ||
263 | return NULL; | 322 | return NULL; |
264 | } | 323 | } |
265 | 324 | ||
diff --git a/src/transport/test_transport_port_forward.c b/src/transport/test_transport_port_forward.c deleted file mode 100644 index d3233c2da..000000000 --- a/src/transport/test_transport_port_forward.c +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/test_transport_port_forward.c | ||
23 | * @brief Test case executing a script which sends a test UDP message from a nated peer | ||
24 | * to a global known peer. There is a tcp port forwarding in place towards the | ||
25 | * natted peer to test the backchannel functionality of the TNG service. | ||
26 | * @author t3sserakt | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include "gnunet_testing_ng_lib.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | |||
32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | ||
33 | |||
34 | /** | ||
35 | * Return value of the test. | ||
36 | * | ||
37 | */ | ||
38 | static unsigned int rv = 0; | ||
39 | |||
40 | |||
41 | /** | ||
42 | * Main function to run the test cases. | ||
43 | * | ||
44 | * @param cls not used. | ||
45 | * | ||
46 | */ | ||
47 | static void | ||
48 | run (void *cls) | ||
49 | { | ||
50 | const char *topology_config = "test_topology_port_forward.conf"; | ||
51 | |||
52 | struct GNUNET_TESTING_Command commands[] = { | ||
53 | GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start", | ||
54 | topology_config), | ||
55 | GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed", | ||
56 | topology_config, | ||
57 | &rv), | ||
58 | GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed", | ||
59 | "netjail-start-testbed", | ||
60 | topology_config), | ||
61 | GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop", | ||
62 | topology_config), | ||
63 | GNUNET_TESTING_cmd_end () | ||
64 | }; | ||
65 | |||
66 | GNUNET_TESTING_run (NULL, | ||
67 | commands, | ||
68 | TIMEOUT); | ||
69 | } | ||
70 | |||
71 | |||
72 | int | ||
73 | main (int argc, | ||
74 | char *const *argv) | ||
75 | { | ||
76 | GNUNET_log_setup ("test-netjail", | ||
77 | "DEBUG", | ||
78 | NULL); | ||
79 | GNUNET_SCHEDULER_run (&run, | ||
80 | NULL); | ||
81 | |||
82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
83 | "Test finished!\n"); | ||
84 | return rv; | ||
85 | } | ||
diff --git a/src/transport/test_transport_simple_send.c b/src/transport/test_transport_simple_send.c deleted file mode 100644 index 924990d0a..000000000 --- a/src/transport/test_transport_simple_send.c +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/test_transport_api_cmd_simple_send.c | ||
23 | * @brief Test case executing a script which sends a test message between two peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | ||
31 | |||
32 | /** | ||
33 | * Return value of the test. | ||
34 | * | ||
35 | */ | ||
36 | static unsigned int rv = 0; | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Main function to run the test cases. | ||
41 | * | ||
42 | * @param cls not used. | ||
43 | * | ||
44 | */ | ||
45 | static void | ||
46 | run (void *cls) | ||
47 | { | ||
48 | struct GNUNET_TESTING_Command commands[] = { | ||
49 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", | ||
50 | "2", | ||
51 | "1"), | ||
52 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", | ||
53 | "2", | ||
54 | "1", | ||
55 | "libgnunet_test_transport_plugin_cmd_simple_send", | ||
56 | &rv), | ||
57 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", | ||
58 | "netjail-start-testbed", | ||
59 | "2", | ||
60 | "1"), | ||
61 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | ||
62 | "2", | ||
63 | "1"), | ||
64 | GNUNET_TESTING_cmd_end () | ||
65 | }; | ||
66 | |||
67 | GNUNET_TESTING_run (NULL, | ||
68 | commands, | ||
69 | TIMEOUT); | ||
70 | } | ||
71 | |||
72 | |||
73 | int | ||
74 | main (int argc, | ||
75 | char *const *argv) | ||
76 | { | ||
77 | GNUNET_log_setup ("test-netjail", | ||
78 | "DEBUG", | ||
79 | NULL); | ||
80 | GNUNET_SCHEDULER_run (&run, | ||
81 | NULL); | ||
82 | |||
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
84 | "Test finished!\n"); | ||
85 | return rv; | ||
86 | } | ||
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh index 25d5b6797..2dd269fcc 100755 --- a/src/transport/test_transport_simple_send.sh +++ b/src/transport/test_transport_simple_send.sh | |||
@@ -1,2 +1,2 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_simple_send" | 2 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf" |
diff --git a/src/transport/test_transport_simple_send_topo.conf b/src/transport/test_transport_simple_send_topo.conf new file mode 100644 index 000000000..f878f9719 --- /dev/null +++ b/src/transport/test_transport_simple_send_topo.conf | |||
@@ -0,0 +1,4 @@ | |||
1 | M:2 | ||
2 | N:1 | ||
3 | X:0 | ||
4 | T:libgnunet_test_transport_plugin_cmd_simple_send \ No newline at end of file | ||
diff --git a/src/transport/test_transport_simple_send_v2.c b/src/transport/test_transport_simple_send_v2.c deleted file mode 100644 index feb65468a..000000000 --- a/src/transport/test_transport_simple_send_v2.c +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/test_transport_api_cmd_simple_send.c | ||
23 | * @brief Test case executing a script which sends a test message between two peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | ||
31 | |||
32 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
33 | |||
34 | /** | ||
35 | * Return value of the test. | ||
36 | * | ||
37 | */ | ||
38 | static unsigned int rv = 0; | ||
39 | |||
40 | |||
41 | /** | ||
42 | * Main function to run the test cases. | ||
43 | * | ||
44 | * @param cls not used. | ||
45 | * | ||
46 | */ | ||
47 | static void | ||
48 | run (void *cls) | ||
49 | { | ||
50 | struct GNUNET_TESTING_Command cmd = GNUNET_TESTING_cmd_end (); | ||
51 | |||
52 | if (GNUNET_YES == cmd.shutdown_on_end) | ||
53 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
54 | "gaga %p\n", | ||
55 | cmd); | ||
56 | struct GNUNET_TESTING_Command commands[] = { | ||
57 | GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start", | ||
58 | TOPOLOGY_CONFIG), | ||
59 | GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed", | ||
60 | TOPOLOGY_CONFIG, | ||
61 | &rv), | ||
62 | GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed", | ||
63 | "netjail-start-testbed", | ||
64 | TOPOLOGY_CONFIG), | ||
65 | GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop", | ||
66 | TOPOLOGY_CONFIG), | ||
67 | cmd | ||
68 | }; | ||
69 | |||
70 | GNUNET_TESTING_run (NULL, | ||
71 | commands, | ||
72 | TIMEOUT); | ||
73 | } | ||
74 | |||
75 | |||
76 | int | ||
77 | main (int argc, | ||
78 | char *const *argv) | ||
79 | { | ||
80 | GNUNET_log_setup ("test-netjail", | ||
81 | "DEBUG", | ||
82 | NULL); | ||
83 | GNUNET_SCHEDULER_run (&run, | ||
84 | NULL); | ||
85 | |||
86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
87 | "Test finished!\n"); | ||
88 | return rv; | ||
89 | } | ||
diff --git a/src/transport/test_transport_simple_send_v2.sh b/src/transport/test_transport_simple_send_v2.sh deleted file mode 100755 index 8462d1849..000000000 --- a/src/transport/test_transport_simple_send_v2.sh +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_simple_send_v2" | ||
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c index 795c157d7..932b0e583 100644 --- a/src/transport/test_transport_start_with_config.c +++ b/src/transport/test_transport_start_with_config.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/test_transport_start_with_config.c | 22 | * @file transport/test_transport_start_with_config.c |
23 | * @brief Test case executing a script which sends a test message between two peers. | 23 | * @brief Generic program to start testcases in an configurable topology. |
24 | * @author t3sserakt | 24 | * @author t3sserakt |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
@@ -29,57 +29,32 @@ | |||
29 | 29 | ||
30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) |
31 | 31 | ||
32 | /** | ||
33 | * Return value of the test. | ||
34 | * | ||
35 | */ | ||
36 | static unsigned int rv = 0; | ||
37 | |||
38 | static char *topology_config; | ||
39 | |||
40 | /** | ||
41 | * Main function to run the test cases. | ||
42 | * | ||
43 | * @param cls not used. | ||
44 | * | ||
45 | */ | ||
46 | static void | ||
47 | run (void *cls) | ||
48 | { | ||
49 | struct GNUNET_TESTING_Command commands[] = { | ||
50 | GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start", | ||
51 | topology_config), | ||
52 | GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed", | ||
53 | topology_config, | ||
54 | &rv), | ||
55 | GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed", | ||
56 | "netjail-start-testbed", | ||
57 | topology_config), | ||
58 | GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop", | ||
59 | topology_config), | ||
60 | GNUNET_TESTING_cmd_end () | ||
61 | }; | ||
62 | |||
63 | GNUNET_TESTING_run (NULL, | ||
64 | commands, | ||
65 | TIMEOUT); | ||
66 | } | ||
67 | |||
68 | 32 | ||
69 | int | 33 | int |
70 | main (int argc, | 34 | main (int argc, |
71 | char *const *argv) | 35 | char *const *argv) |
72 | { | 36 | { |
37 | char *topology_config; | ||
38 | |||
73 | GNUNET_log_setup ("test-netjail", | 39 | GNUNET_log_setup ("test-netjail", |
74 | "DEBUG", | 40 | "DEBUG", |
75 | NULL); | 41 | NULL); |
76 | 42 | ||
77 | topology_config = argv[1]; | 43 | topology_config = argv[1]; |
78 | 44 | ||
79 | GNUNET_SCHEDULER_run (&run, | 45 | struct GNUNET_TESTING_Command commands[] = { |
80 | NULL); | 46 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", |
47 | topology_config), | ||
48 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", | ||
49 | topology_config), | ||
50 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", | ||
51 | "netjail-start-testbed", | ||
52 | topology_config), | ||
53 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | ||
54 | topology_config), | ||
55 | GNUNET_TESTING_cmd_end () | ||
56 | }; | ||
81 | 57 | ||
82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 58 | return GNUNET_TESTING_main (commands, |
83 | "Test finished!\n"); | 59 | TIMEOUT); |
84 | return rv; | ||
85 | } | 60 | } |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index 67e5723f5..f6e34df62 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -29,92 +29,71 @@ | |||
29 | #include "gnunet_testing_lib.h" | 29 | #include "gnunet_testing_lib.h" |
30 | 30 | ||
31 | 31 | ||
32 | struct StartPeerState_v2 | 32 | /** |
33 | * Struct to store information needed in callbacks. | ||
34 | * | ||
35 | */ | ||
36 | struct ConnectPeersState | ||
33 | { | 37 | { |
34 | /** | 38 | /** |
35 | * The ip of a node. | 39 | * Context for our asynchronous completion. |
36 | */ | ||
37 | char *node_ip; | ||
38 | |||
39 | /** | ||
40 | * Receive callback | ||
41 | */ | 40 | */ |
42 | struct GNUNET_MQ_MessageHandler *handlers; | 41 | struct GNUNET_TESTING_AsyncContext ac; |
43 | 42 | ||
44 | const char *cfgname; | 43 | GNUNET_TRANSPORT_NotifyConnect notify_connect; |
45 | 44 | ||
46 | /** | 45 | /** |
47 | * Peer's configuration | 46 | * The testing system of this node. |
48 | */ | 47 | */ |
49 | struct GNUNET_CONFIGURATION_Handle *cfg; | 48 | struct GNUNET_TESTING_System *tl_system; |
50 | 49 | ||
51 | struct GNUNET_TESTING_Peer *peer; | 50 | // Label of the cmd which started the test system. |
51 | const char *create_label; | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Peer identity | 54 | * Number globally identifying the node. |
55 | * | ||
55 | */ | 56 | */ |
56 | struct GNUNET_PeerIdentity id; | 57 | uint32_t num; |
57 | 58 | ||
58 | /** | 59 | /** |
59 | * Peer's transport service handle | 60 | * Label of the cmd to start a peer. |
61 | * | ||
60 | */ | 62 | */ |
61 | struct GNUNET_TRANSPORT_CoreHandle *th; | 63 | const char *start_peer_label; |
62 | 64 | ||
63 | /** | 65 | /** |
64 | * Application handle | 66 | * The peer identity of this peer. |
67 | * | ||
65 | */ | 68 | */ |
66 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | 69 | struct GNUNET_PeerIdentity *id; |
67 | 70 | ||
68 | /** | 71 | /** |
69 | * Peer's PEERSTORE Handle | 72 | * The topology of the test setup. |
70 | */ | 73 | */ |
71 | struct GNUNET_PEERSTORE_Handle *ph; | 74 | struct GNUNET_TESTING_NetjailTopology *topology; |
72 | 75 | ||
73 | /** | 76 | /** |
74 | * Hello get task | 77 | * Connections to other peers. |
75 | */ | 78 | */ |
76 | struct GNUNET_SCHEDULER_Task *rh_task; | 79 | struct GNUNET_TESTING_NodeConnection *node_connections_head; |
77 | 80 | ||
78 | /** | 81 | struct GNUNET_TESTING_Interpreter *is; |
79 | * Peer's transport get hello handle to retrieve peer's HELLO message | ||
80 | */ | ||
81 | struct GNUNET_PEERSTORE_IterateContext *pic; | ||
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Hello | 84 | * Number of connections. |
85 | */ | 85 | */ |
86 | char *hello; | 86 | unsigned int con_num; |
87 | |||
88 | /** | ||
89 | * Hello size | ||
90 | */ | ||
91 | size_t hello_size; | ||
92 | |||
93 | char *m; | ||
94 | |||
95 | char *n; | ||
96 | |||
97 | char *local_m; | ||
98 | |||
99 | unsigned int finished; | ||
100 | |||
101 | const char *system_label; | ||
102 | |||
103 | /** | ||
104 | * An unique number to identify the peer | ||
105 | */ | ||
106 | unsigned int no; | ||
107 | |||
108 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
109 | |||
110 | struct GNUNET_TESTING_System *tl_system; | ||
111 | |||
112 | }; | 87 | }; |
113 | 88 | ||
114 | |||
115 | struct StartPeerState | 89 | struct StartPeerState |
116 | { | 90 | { |
117 | /** | 91 | /** |
92 | * Context for our asynchronous completion. | ||
93 | */ | ||
94 | struct GNUNET_TESTING_AsyncContext ac; | ||
95 | |||
96 | /** | ||
118 | * The ip of a node. | 97 | * The ip of a node. |
119 | */ | 98 | */ |
120 | char *node_ip; | 99 | char *node_ip; |
@@ -179,8 +158,6 @@ struct StartPeerState | |||
179 | 158 | ||
180 | char *local_m; | 159 | char *local_m; |
181 | 160 | ||
182 | unsigned int finished; | ||
183 | |||
184 | const char *system_label; | 161 | const char *system_label; |
185 | 162 | ||
186 | /** | 163 | /** |
@@ -192,9 +169,24 @@ struct StartPeerState | |||
192 | 169 | ||
193 | struct GNUNET_TESTING_System *tl_system; | 170 | struct GNUNET_TESTING_System *tl_system; |
194 | 171 | ||
172 | GNUNET_TRANSPORT_NotifyConnect notify_connect; | ||
173 | |||
195 | }; | 174 | }; |
196 | 175 | ||
197 | 176 | ||
177 | /** | ||
178 | * Function to get the trait with the struct ConnectPeersState. | ||
179 | * | ||
180 | * @param[out] sps struct ConnectPeersState. | ||
181 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
182 | * | ||
183 | */ | ||
184 | int | ||
185 | GNUNET_TESTING_get_trait_connect_peer_state ( | ||
186 | const struct GNUNET_TESTING_Command *cmd, | ||
187 | struct ConnectPeersState **cps); | ||
188 | |||
189 | |||
198 | int | 190 | int |
199 | GNUNET_TRANSPORT_get_trait_state (const struct | 191 | GNUNET_TRANSPORT_get_trait_state (const struct |
200 | GNUNET_TESTING_Command | 192 | GNUNET_TESTING_Command |
@@ -203,30 +195,13 @@ GNUNET_TRANSPORT_get_trait_state (const struct | |||
203 | 195 | ||
204 | 196 | ||
205 | struct GNUNET_TESTING_Command | 197 | struct GNUNET_TESTING_Command |
206 | GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label, | ||
207 | const char *system_label, | ||
208 | uint32_t no, | ||
209 | char *node_ip, | ||
210 | struct GNUNET_MQ_MessageHandler *handlers, | ||
211 | const char *cfgname); | ||
212 | |||
213 | struct GNUNET_TESTING_Command | ||
214 | GNUNET_TRANSPORT_cmd_start_peer_v3 (const char *label, | ||
215 | const char *system_label, | ||
216 | uint32_t no, | ||
217 | char *node_ip, | ||
218 | struct GNUNET_MQ_MessageHandler *handlers, | ||
219 | const char *cfgname); | ||
220 | |||
221 | struct GNUNET_TESTING_Command | ||
222 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, | 198 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, |
223 | const char *system_label, | 199 | const char *system_label, |
224 | char *m, | 200 | uint32_t no, |
225 | char *n, | ||
226 | char *local_m, | ||
227 | char *node_ip, | 201 | char *node_ip, |
228 | struct GNUNET_MQ_MessageHandler *handlers, | 202 | struct GNUNET_MQ_MessageHandler *handlers, |
229 | const char *cfgname); | 203 | const char *cfgname, |
204 | GNUNET_TRANSPORT_NotifyConnect notify_connect); | ||
230 | 205 | ||
231 | 206 | ||
232 | struct GNUNET_TESTING_Command | 207 | struct GNUNET_TESTING_Command |
@@ -238,56 +213,9 @@ struct GNUNET_TESTING_Command | |||
238 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | 213 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, |
239 | const char *start_peer_label, | 214 | const char *start_peer_label, |
240 | const char *create_label, | 215 | const char *create_label, |
241 | uint32_t num); | 216 | uint32_t num, |
242 | 217 | struct GNUNET_TESTING_NetjailTopology * | |
243 | 218 | topology); | |
244 | struct GNUNET_TESTING_Command | ||
245 | GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label, | ||
246 | const char *start_peer_label, | ||
247 | const char *create_label, | ||
248 | uint32_t num); | ||
249 | |||
250 | |||
251 | /** | ||
252 | * Create command. | ||
253 | * | ||
254 | * @param label name for command. | ||
255 | * @param start_peer_label Label of the cmd to start a peer. | ||
256 | * @param create_label Label of the cmd to create the testing system. | ||
257 | * @param num Number globally identifying the node. | ||
258 | * @param The topology for the test setup. | ||
259 | * @return command. | ||
260 | */ | ||
261 | struct GNUNET_TESTING_Command | ||
262 | GNUNET_TRANSPORT_cmd_connect_peers_v3 (const char *label, | ||
263 | const char *start_peer_label, | ||
264 | const char *create_label, | ||
265 | uint32_t num, | ||
266 | struct GNUNET_TESTING_NetjailTopology * | ||
267 | topology); | ||
268 | |||
269 | |||
270 | /** | ||
271 | * Create command. | ||
272 | * | ||
273 | * @param label name for command. | ||
274 | * @param start_peer_label Label of the cmd to start a peer. | ||
275 | * @param create_label Label of the cmd to create the testing system. | ||
276 | * @param num Number globally identifying the node. | ||
277 | * @param node_n The number of the node in a network namespace. | ||
278 | * @param namespace_n The number of the network namespace. | ||
279 | * @param The topology for the test setup. | ||
280 | * @return command. | ||
281 | */ | ||
282 | struct GNUNET_TESTING_Command | ||
283 | GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | ||
284 | const char *start_peer_label, | ||
285 | const char *create_label, | ||
286 | uint32_t num, | ||
287 | unsigned int node_n, | ||
288 | unsigned int namespace_n, | ||
289 | struct GNUNET_TESTING_NetjailTopology * | ||
290 | topology); | ||
291 | 219 | ||
292 | 220 | ||
293 | /** | 221 | /** |
@@ -302,42 +230,11 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | |||
302 | */ | 230 | */ |
303 | struct GNUNET_TESTING_Command | 231 | struct GNUNET_TESTING_Command |
304 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, | 232 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, |
305 | char *m, | 233 | const char *start_peer_label, |
306 | char *n, | 234 | uint32_t num); |
307 | uint32_t num, | ||
308 | const char *start_peer_label); | ||
309 | 235 | ||
310 | /** | ||
311 | * Create command. | ||
312 | * | ||
313 | * @param label name for command. | ||
314 | * @param start_peer_label Label of the cmd to start a peer. | ||
315 | * @param num Number globally identifying the node. | ||
316 | * @return command. | ||
317 | */ | ||
318 | struct GNUNET_TESTING_Command | ||
319 | GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label, | ||
320 | const char *start_peer_label, | ||
321 | uint32_t num); | ||
322 | 236 | ||
323 | 237 | ||
324 | /** | ||
325 | * Create command. | ||
326 | * | ||
327 | * @param label name for command. | ||
328 | * @param start_peer_label Label of the cmd to start a peer. | ||
329 | * @param start_peer_label Label of the cmd which started the test system. | ||
330 | * @param num Number globally identifying the node. | ||
331 | * @param The topology for the test setup. | ||
332 | * @return command. | ||
333 | */ | ||
334 | struct GNUNET_TESTING_Command | ||
335 | GNUNET_TRANSPORT_cmd_send_simple_v3 (const char *label, | ||
336 | const char *start_peer_label, | ||
337 | const char *create_label, | ||
338 | uint32_t num, | ||
339 | struct GNUNET_TESTING_NetjailTopology * | ||
340 | topology); | ||
341 | 238 | ||
342 | 239 | ||
343 | int | 240 | int |
@@ -345,34 +242,16 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct | |||
345 | GNUNET_TESTING_Command *cmd, | 242 | GNUNET_TESTING_Command *cmd, |
346 | struct GNUNET_PeerIdentity **id); | 243 | struct GNUNET_PeerIdentity **id); |
347 | 244 | ||
245 | |||
348 | int | 246 | int |
349 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | 247 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct |
350 | GNUNET_TESTING_Command | 248 | GNUNET_TESTING_Command |
351 | *cmd, | 249 | *cmd, |
352 | struct | 250 | struct |
353 | GNUNET_CONTAINER_MultiShortmap * | 251 | GNUNET_CONTAINER_MultiShortmap |
252 | * | ||
354 | * | 253 | * |
355 | connected_peers_map); | 254 | connected_peers_map); |
356 | |||
357 | int | ||
358 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct | ||
359 | GNUNET_TESTING_Command | ||
360 | *cmd, | ||
361 | struct | ||
362 | GNUNET_CONTAINER_MultiShortmap | ||
363 | * | ||
364 | * | ||
365 | connected_peers_map); | ||
366 | |||
367 | int | ||
368 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v3 (const struct | ||
369 | GNUNET_TESTING_Command | ||
370 | *cmd, | ||
371 | struct | ||
372 | GNUNET_CONTAINER_MultiShortmap | ||
373 | * | ||
374 | * | ||
375 | connected_peers_map); | ||
376 | int | 255 | int |
377 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | 256 | GNUNET_TRANSPORT_get_trait_hello_size (const struct |
378 | GNUNET_TESTING_Command | 257 | GNUNET_TESTING_Command |
@@ -393,19 +272,5 @@ GNUNET_TRANSPORT_get_trait_application_handle (const struct | |||
393 | GNUNET_TRANSPORT_ApplicationHandle | 272 | GNUNET_TRANSPORT_ApplicationHandle |
394 | **ah); | 273 | **ah); |
395 | 274 | ||
396 | int | ||
397 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct | ||
398 | GNUNET_TESTING_Command *cmd, | ||
399 | struct | ||
400 | GNUNET_TRANSPORT_ApplicationHandle | ||
401 | **ah); | ||
402 | |||
403 | int | ||
404 | GNUNET_TRANSPORT_get_trait_application_handle_v3 (const struct | ||
405 | GNUNET_TESTING_Command *cmd, | ||
406 | struct | ||
407 | GNUNET_TRANSPORT_ApplicationHandle | ||
408 | **ah); | ||
409 | |||
410 | #endif | 275 | #endif |
411 | /* end of transport_testing.h */ | 276 | /* end of transport_testing.h */ |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 39c7db450..2e51363f6 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -36,199 +36,348 @@ | |||
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
38 | 38 | ||
39 | /** | 39 | #define CONNECT_ADDRESS_TEMPLATE_TCP "tcp-192.168.15.%u:60002" |
40 | * Struct to store information needed in callbacks. | ||
41 | * | ||
42 | */ | ||
43 | struct ConnectPeersState | ||
44 | { | ||
45 | // Label of the cmd which started the test system. | ||
46 | const char *create_label; | ||
47 | 40 | ||
48 | /** | 41 | #define CONNECT_ADDRESS_TEMPLATE_UDP "udp-192.168.15.%u:60002" |
49 | * Number globally identifying the node. | ||
50 | * | ||
51 | */ | ||
52 | uint32_t num; | ||
53 | 42 | ||
54 | /** | 43 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.150.%u:60002" |
55 | * Label of the cmd to start a peer. | ||
56 | * | ||
57 | */ | ||
58 | const char *start_peer_label; | ||
59 | 44 | ||
60 | /** | 45 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.150.%u:60002" |
61 | * The peer identity of this peer. | ||
62 | * | ||
63 | */ | ||
64 | struct GNUNET_PeerIdentity *id; | ||
65 | }; | ||
66 | 46 | ||
47 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.151.%u:60002" | ||
67 | 48 | ||
68 | /** | 49 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.151.%u:60002" |
69 | * The run method of this cmd will connect to peers. | 50 | |
70 | * | 51 | #define PREFIX_TCP "tcp" |
71 | */ | 52 | |
72 | static void | 53 | #define PREFIX_UDP "udp" |
73 | connect_peers_run (void *cls, | 54 | |
74 | const struct GNUNET_TESTING_Command *cmd, | 55 | |
75 | struct GNUNET_TESTING_Interpreter *is) | 56 | |
57 | |||
58 | static struct GNUNET_PeerIdentity * | ||
59 | get_pub_key (unsigned int num, struct GNUNET_TESTING_System *tl_system) | ||
76 | { | 60 | { |
77 | struct ConnectPeersState *cps = cls; | 61 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); |
78 | const struct GNUNET_TESTING_Command *system_cmd; | ||
79 | struct GNUNET_TESTING_System *tl_system; | ||
80 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct | ||
81 | GNUNET_CRYPTO_EddsaPrivateKey); | ||
82 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct | 62 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct |
83 | GNUNET_CRYPTO_EddsaPublicKey); | 63 | GNUNET_CRYPTO_EddsaPublicKey); |
84 | ; | 64 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct |
85 | const struct GNUNET_TESTING_Command *peer1_cmd; | 65 | GNUNET_CRYPTO_EddsaPrivateKey); |
86 | // const struct GNUNET_TESTING_Command *peer2_cmd; | ||
87 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
88 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
89 | char *addr; | ||
90 | // struct GNUNET_TIME_Absolute t; | ||
91 | char *hello; | ||
92 | // size_t *hello_size; | ||
93 | enum GNUNET_NetworkType nt = 0; | ||
94 | // char *peer_id; | ||
95 | struct GNUNET_PeerIdentity *id; | ||
96 | struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity); | ||
97 | uint32_t num; | ||
98 | 66 | ||
99 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | 67 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, |
100 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | 68 | num, |
101 | &ah); | 69 | peer); |
102 | 70 | ||
103 | GNUNET_TRANSPORT_get_trait_hello (peer1_cmd, | 71 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, |
104 | &hello); | 72 | pub_key); |
73 | peer->public_key = *pub_key; | ||
74 | return peer; | ||
75 | } | ||
105 | 76 | ||
106 | GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | ||
107 | &id); | ||
108 | 77 | ||
109 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label); | 78 | static int |
110 | GNUNET_TESTING_get_trait_test_system (system_cmd, | 79 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
111 | &tl_system); | 80 | { |
81 | struct GNUNET_TESTING_NetjailNode *node = value; | ||
82 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
83 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | ||
112 | 84 | ||
113 | if (2 == cps->num) | 85 | LOG (GNUNET_ERROR_TYPE_ERROR, |
114 | num = 1; | 86 | "plugin: %s space: %u node: %u global: %u\n", |
115 | else | 87 | node->plugin, |
116 | num = 2; | 88 | node->namespace_n, |
89 | node->node_n, | ||
90 | node->is_global); | ||
91 | |||
92 | for (pos_connection = node->node_connections_head; NULL != pos_connection; | ||
93 | pos_connection = pos_connection->next) | ||
94 | { | ||
95 | |||
96 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
97 | "namespace_n: %u node_n: %u node_type: %u\n", | ||
98 | pos_connection->namespace_n, | ||
99 | pos_connection->node_n, | ||
100 | pos_connection->node_type); | ||
101 | |||
102 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
103 | pos_prefix = | ||
104 | pos_prefix->next) | ||
105 | { | ||
106 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
107 | "prefix: %s\n", | ||
108 | pos_prefix->address_prefix); | ||
109 | } | ||
110 | } | ||
111 | return GNUNET_YES; | ||
112 | } | ||
113 | |||
114 | |||
115 | static int | ||
116 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
117 | { | ||
118 | struct GNUNET_TESTING_NetjailNamespace *namespace = value; | ||
119 | struct GNUNET_TESTING_NetjailRouter *router = namespace->router; | ||
120 | |||
121 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
122 | "router_tcp: %u router_udp: %u spaces: %u\n", | ||
123 | router->tcp_port, | ||
124 | router->udp_port, | ||
125 | namespace->namespace_n); | ||
126 | GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL); | ||
127 | return GNUNET_YES; | ||
128 | } | ||
117 | 129 | ||
118 | 130 | ||
131 | static int | ||
132 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) | ||
133 | { | ||
134 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
135 | "plugin: %s spaces: %u nodes: %u known: %u\n", | ||
136 | topology->plugin, | ||
137 | topology->namespaces_n, | ||
138 | topology->nodes_m, | ||
139 | topology->nodes_x); | ||
140 | |||
141 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, | ||
142 | log_namespaces, NULL); | ||
143 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, &log_nodes, | ||
144 | NULL); | ||
145 | return GNUNET_YES; | ||
146 | } | ||
147 | |||
148 | |||
149 | static struct GNUNET_TESTING_NodeConnection * | ||
150 | get_connections (unsigned int num, struct | ||
151 | GNUNET_TESTING_NetjailTopology *topology) | ||
152 | { | ||
153 | struct GNUNET_TESTING_NetjailNode *node; | ||
154 | struct GNUNET_ShortHashCode *hkey; | ||
155 | struct GNUNET_HashCode hc; | ||
156 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
157 | unsigned int namespace_n, node_m; | ||
119 | 158 | ||
159 | log_topo (topology); | ||
120 | 160 | ||
121 | // if (strstr (hello, "60002") != NULL) | 161 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
122 | if (2 == num) | 162 | if (topology->nodes_x >= num) |
123 | { | 163 | { |
124 | addr = "tcp-192.168.15.2:60002"; | 164 | |
125 | // peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; | 165 | GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); |
166 | memcpy (hkey, | ||
167 | &hc, | ||
168 | sizeof (*hkey)); | ||
169 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
170 | hkey); | ||
126 | } | 171 | } |
127 | else | 172 | else |
128 | { | 173 | { |
129 | addr = "tcp-192.168.15.1:60002"; | 174 | namespace_n = (unsigned int) floor ((num - topology->nodes_x) |
130 | // peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; | 175 | / topology->nodes_m); |
176 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
177 | "num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", | ||
178 | num, | ||
179 | topology->nodes_x, | ||
180 | topology->nodes_m, | ||
181 | namespace_n); | ||
182 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
183 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); | ||
184 | memcpy (hkey, | ||
185 | &hc, | ||
186 | sizeof (*hkey)); | ||
187 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
188 | hkey); | ||
189 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); | ||
190 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
191 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); | ||
192 | memcpy (hkey, | ||
193 | &hc, | ||
194 | sizeof (*hkey)); | ||
195 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
196 | hkey); | ||
131 | } | 197 | } |
132 | 198 | ||
133 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, | ||
134 | num, | ||
135 | other); | ||
136 | 199 | ||
137 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, | 200 | return node->node_connections_head; |
138 | pub_key); | 201 | } |
139 | 202 | ||
140 | /*GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | ||
141 | strlen (peer_id), | ||
142 | &peer->public_key);*/ | ||
143 | 203 | ||
144 | peer->public_key = *pub_key; | 204 | static unsigned int |
205 | calculate_num (struct GNUNET_TESTING_NodeConnection *node_connection, | ||
206 | struct GNUNET_TESTING_NetjailTopology *topology) | ||
207 | { | ||
208 | unsigned int n, m, num; | ||
145 | 209 | ||
146 | LOG (GNUNET_ERROR_TYPE_ERROR, | 210 | n = node_connection->namespace_n; |
147 | "num: %u id: %s pub_key %s\n", | 211 | m = node_connection->node_n; |
148 | num, | 212 | |
149 | GNUNET_i2s_full (id), | 213 | if (0 == n) |
150 | GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key)); | 214 | num = m; |
151 | 215 | else | |
152 | cps->id = peer; | 216 | num = (n - 1) * topology->nodes_m + m + topology->nodes_x; |
153 | 217 | ||
154 | // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. | 218 | return num; |
155 | // --------------------------------------------- | 219 | } |
156 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | 220 | |
157 | GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd, | 221 | |
158 | &id); | 222 | static char * |
159 | GNUNET_TRANSPORT_get_trait_hello (peer2_cmd, | 223 | get_address (struct GNUNET_TESTING_NodeConnection *connection, |
160 | &hello); | 224 | char *prefix) |
161 | GNUNET_TRANSPORT_get_trait_hello_size (peer2_cmd, | 225 | { |
162 | &hello_size); | 226 | struct GNUNET_TESTING_NetjailNode *node; |
163 | 227 | char *addr; | |
164 | addr = GNUNET_HELLO_extract_address (hello, | 228 | |
165 | *hello_size, | 229 | node = connection->node; |
166 | id, | 230 | if (connection->namespace_n == node->namespace_n) |
167 | &nt, | 231 | { |
168 | &t);*/ | 232 | if (0 == strcmp (PREFIX_TCP, prefix)) |
169 | 233 | { | |
170 | // ---------------------------------------------- | 234 | |
171 | 235 | GNUNET_asprintf (&addr, | |
172 | 236 | CONNECT_ADDRESS_TEMPLATE_TCP, | |
173 | GNUNET_TRANSPORT_application_validate (ah, | 237 | connection->node_n); |
174 | peer, | 238 | } |
175 | nt, | 239 | else if (0 == strcmp (PREFIX_UDP, prefix)) |
176 | addr); | 240 | { |
241 | GNUNET_asprintf (&addr, | ||
242 | CONNECT_ADDRESS_TEMPLATE_UDP, | ||
243 | connection->node_n); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | GNUNET_break (0); | ||
248 | } | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | if (0 == strcmp (PREFIX_TCP, prefix)) | ||
253 | { | ||
254 | |||
255 | GNUNET_asprintf (&addr, | ||
256 | ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP, | ||
257 | connection->namespace_n); | ||
258 | } | ||
259 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
260 | { | ||
261 | GNUNET_asprintf (&addr, | ||
262 | ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP, | ||
263 | connection->namespace_n); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | GNUNET_break (0); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | return addr; | ||
177 | } | 272 | } |
178 | 273 | ||
179 | 274 | ||
180 | /** | 275 | /** |
181 | * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer. | 276 | * The run method of this cmd will connect to peers. |
182 | * | 277 | * |
183 | */ | 278 | */ |
184 | static int | 279 | static void |
185 | connect_peers_finish (void *cls, | 280 | connect_peers_run (void *cls, |
186 | GNUNET_SCHEDULER_TaskCallback cont, | 281 | struct GNUNET_TESTING_Interpreter *is) |
187 | void *cont_cls) | ||
188 | { | 282 | { |
189 | struct ConnectPeersState *cps = cls; | 283 | struct ConnectPeersState *cps = cls; |
284 | const struct GNUNET_TESTING_Command *system_cmd; | ||
285 | struct GNUNET_TESTING_System *tl_system; | ||
286 | |||
287 | |||
190 | const struct GNUNET_TESTING_Command *peer1_cmd; | 288 | const struct GNUNET_TESTING_Command *peer1_cmd; |
191 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 289 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
192 | unsigned int ret; | 290 | struct GNUNET_PeerIdentity *peer; |
193 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | 291 | char *addr; |
194 | struct GNUNET_HashCode hc; | 292 | enum GNUNET_NetworkType nt = 0; |
195 | int node_number; | 293 | uint32_t num; |
294 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
295 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | ||
296 | unsigned int con_num = 0; | ||
196 | 297 | ||
197 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | 298 | cps->is = is; |
198 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | 299 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
199 | &connected_peers_map); | 300 | cps->start_peer_label); |
301 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | ||
302 | &ah); | ||
200 | 303 | ||
201 | node_number = 1; | 304 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
202 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | 305 | cps->create_label); |
306 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
307 | &tl_system); | ||
308 | |||
309 | cps->tl_system = tl_system; | ||
203 | 310 | ||
204 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | 311 | cps->node_connections_head = get_connections (cps->num, cps->topology); |
205 | memcpy (key, | ||
206 | &hc, | ||
207 | sizeof (*key)); | ||
208 | ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map, | ||
209 | key); | ||
210 | 312 | ||
211 | if (GNUNET_YES == ret) | 313 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
314 | pos_connection = pos_connection->next) | ||
212 | { | 315 | { |
213 | cont (cont_cls); | 316 | con_num++; |
317 | num = calculate_num (pos_connection, cps->topology); | ||
318 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
319 | pos_prefix = | ||
320 | pos_prefix->next) | ||
321 | { | ||
322 | |||
323 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
324 | "prefix: %s\n", | ||
325 | pos_prefix->address_prefix); | ||
326 | |||
327 | addr = get_address (pos_connection, pos_prefix->address_prefix); | ||
328 | |||
329 | peer = get_pub_key (num, tl_system); | ||
330 | |||
331 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
332 | "num: %u pub_key %s addr: %s\n", | ||
333 | num, | ||
334 | GNUNET_CRYPTO_eddsa_public_key_to_string (&(peer->public_key)), | ||
335 | addr); | ||
336 | |||
337 | cps->id = peer; | ||
338 | |||
339 | GNUNET_TRANSPORT_application_validate (ah, | ||
340 | peer, | ||
341 | nt, | ||
342 | addr); | ||
343 | } | ||
214 | } | 344 | } |
215 | 345 | cps->con_num = con_num; | |
216 | GNUNET_free (key); | ||
217 | return ret; | ||
218 | } | 346 | } |
219 | 347 | ||
220 | 348 | ||
221 | /** | 349 | /** |
222 | * Trait function of this cmd does nothing. | 350 | * Callback from start peer cmd for signaling a peer got connected. |
223 | * | 351 | * |
224 | */ | 352 | */ |
225 | static int | 353 | static void * |
226 | connect_peers_traits (void *cls, | 354 | notify_connect (void *cls, |
227 | const void **ret, | 355 | const struct GNUNET_PeerIdentity *peer, |
228 | const char *trait, | 356 | struct GNUNET_MQ_Handle *mq) |
229 | unsigned int index) | ||
230 | { | 357 | { |
231 | return GNUNET_OK; | 358 | struct ConnectPeersState *cps = cls; |
359 | struct GNUNET_PeerIdentity *peer_connection; | ||
360 | unsigned int con_num = 0; | ||
361 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
362 | unsigned int num; | ||
363 | void *ret = NULL; | ||
364 | |||
365 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | ||
366 | pos_connection = pos_connection->next) | ||
367 | { | ||
368 | num = calculate_num (pos_connection, cps->topology); | ||
369 | peer_connection = get_pub_key (num, cps->tl_system); | ||
370 | if (0 == GNUNET_memcmp (peer, | ||
371 | peer_connection)) | ||
372 | con_num++; | ||
373 | } | ||
374 | |||
375 | |||
376 | if (cps->con_num == con_num) | ||
377 | { | ||
378 | GNUNET_TESTING_async_finish (&cps->ac); | ||
379 | } | ||
380 | return ret; | ||
232 | } | 381 | } |
233 | 382 | ||
234 | 383 | ||
@@ -237,8 +386,7 @@ connect_peers_traits (void *cls, | |||
237 | * | 386 | * |
238 | */ | 387 | */ |
239 | static void | 388 | static void |
240 | connect_peers_cleanup (void *cls, | 389 | connect_peers_cleanup (void *cls) |
241 | const struct GNUNET_TESTING_Command *cmd) | ||
242 | { | 390 | { |
243 | struct ConnectPeersState *cps = cls; | 391 | struct ConnectPeersState *cps = cls; |
244 | 392 | ||
@@ -248,17 +396,57 @@ connect_peers_cleanup (void *cls, | |||
248 | 396 | ||
249 | 397 | ||
250 | /** | 398 | /** |
251 | * Create command. | 399 | * This function prepares an array with traits. |
400 | * | ||
401 | */ | ||
402 | static int | ||
403 | connect_peers_traits (void *cls, | ||
404 | const void **ret, | ||
405 | const char *trait, | ||
406 | unsigned int index) | ||
407 | { | ||
408 | struct StartPeerState *cps = cls; | ||
409 | struct GNUNET_TESTING_Trait traits[] = { | ||
410 | { | ||
411 | .index = 0, | ||
412 | .trait_name = "state", | ||
413 | .ptr = (const void *) cps, | ||
414 | }, | ||
415 | GNUNET_TESTING_trait_end () | ||
416 | }; | ||
417 | return GNUNET_TESTING_get_trait (traits, | ||
418 | ret, | ||
419 | trait, | ||
420 | index); | ||
421 | } | ||
422 | |||
423 | |||
424 | /** | ||
425 | * Function to get the trait with the struct ConnectPeersState. | ||
426 | * | ||
427 | * @param[out] sps struct ConnectPeersState. | ||
428 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
252 | * | 429 | * |
253 | * @param label name for command. | ||
254 | * @param start_peer_label Label of the cmd to start a peer. | ||
255 | * @return command. | ||
256 | */ | 430 | */ |
431 | int | ||
432 | GNUNET_TESTING_get_trait_connect_peer_state ( | ||
433 | const struct GNUNET_TESTING_Command *cmd, | ||
434 | struct ConnectPeersState **cps) | ||
435 | { | ||
436 | return cmd->traits (cmd->cls, | ||
437 | (const void **) cps, | ||
438 | "state", | ||
439 | (unsigned int) 0); | ||
440 | } | ||
441 | |||
442 | |||
257 | struct GNUNET_TESTING_Command | 443 | struct GNUNET_TESTING_Command |
258 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | 444 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, |
259 | const char *start_peer_label, | 445 | const char *start_peer_label, |
260 | const char *create_label, | 446 | const char *create_label, |
261 | uint32_t num) | 447 | uint32_t num, |
448 | struct GNUNET_TESTING_NetjailTopology * | ||
449 | topology) | ||
262 | { | 450 | { |
263 | struct ConnectPeersState *cps; | 451 | struct ConnectPeersState *cps; |
264 | 452 | ||
@@ -266,16 +454,19 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
266 | cps->start_peer_label = start_peer_label; | 454 | cps->start_peer_label = start_peer_label; |
267 | cps->num = num; | 455 | cps->num = num; |
268 | cps->create_label = create_label; | 456 | cps->create_label = create_label; |
457 | cps->topology = topology; | ||
458 | cps->notify_connect = ¬ify_connect; | ||
269 | 459 | ||
270 | 460 | { | |
271 | struct GNUNET_TESTING_Command cmd = { | 461 | struct GNUNET_TESTING_Command cmd = { |
272 | .cls = cps, | 462 | .cls = cps, |
273 | .label = label, | 463 | .label = label, |
274 | .run = &connect_peers_run, | 464 | .run = &connect_peers_run, |
275 | .finish = &connect_peers_finish, | 465 | .ac = &cps->ac, |
276 | .cleanup = &connect_peers_cleanup, | 466 | .cleanup = &connect_peers_cleanup, |
277 | .traits = &connect_peers_traits | 467 | .traits = &connect_peers_traits |
278 | }; | 468 | }; |
279 | 469 | ||
280 | return cmd; | 470 | return cmd; |
471 | } | ||
281 | } | 472 | } |
diff --git a/src/transport/transport_api_cmd_connecting_peers_v2.c b/src/transport/transport_api_cmd_connecting_peers_v2.c deleted file mode 100644 index 0d286b714..000000000 --- a/src/transport/transport_api_cmd_connecting_peers_v2.c +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_transport_application_service.h" | ||
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_transport_service.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | #define CONNECT_ADDRESS_TEMPLATE "tcp-192.168.15.%u:60002" | ||
40 | |||
41 | /** | ||
42 | * Struct to store information needed in callbacks. | ||
43 | * | ||
44 | */ | ||
45 | struct ConnectPeersState | ||
46 | { | ||
47 | // Label of the cmd which started the test system. | ||
48 | const char *create_label; | ||
49 | |||
50 | /** | ||
51 | * Number globally identifying the node. | ||
52 | * | ||
53 | */ | ||
54 | uint32_t num; | ||
55 | |||
56 | /** | ||
57 | * Label of the cmd to start a peer. | ||
58 | * | ||
59 | */ | ||
60 | const char *start_peer_label; | ||
61 | |||
62 | /** | ||
63 | * The peer identity of this peer. | ||
64 | * | ||
65 | */ | ||
66 | struct GNUNET_PeerIdentity *id; | ||
67 | }; | ||
68 | |||
69 | |||
70 | /** | ||
71 | * The run method of this cmd will connect to peers. | ||
72 | * | ||
73 | */ | ||
74 | static void | ||
75 | connect_peers_run (void *cls, | ||
76 | const struct GNUNET_TESTING_Command *cmd, | ||
77 | struct GNUNET_TESTING_Interpreter *is) | ||
78 | { | ||
79 | struct ConnectPeersState *cps = cls; | ||
80 | const struct GNUNET_TESTING_Command *system_cmd; | ||
81 | struct GNUNET_TESTING_System *tl_system; | ||
82 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct | ||
83 | GNUNET_CRYPTO_EddsaPrivateKey); | ||
84 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct | ||
85 | GNUNET_CRYPTO_EddsaPublicKey); | ||
86 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
87 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
88 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
89 | char *addr; | ||
90 | enum GNUNET_NetworkType nt = 0; | ||
91 | struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity); | ||
92 | uint32_t num; | ||
93 | |||
94 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | ||
95 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd, | ||
96 | &ah); | ||
97 | |||
98 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label); | ||
99 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
100 | &tl_system); | ||
101 | |||
102 | if (1 == cps->num) | ||
103 | { | ||
104 | num = 2; | ||
105 | // addr = "tcp-192.168.15.2:60002"; | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | num = 1; | ||
110 | // addr = "tcp-192.168.15.1:60002"; | ||
111 | } | ||
112 | |||
113 | GNUNET_asprintf (&addr, | ||
114 | CONNECT_ADDRESS_TEMPLATE, | ||
115 | num); | ||
116 | |||
117 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, | ||
118 | num, | ||
119 | other); | ||
120 | |||
121 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, | ||
122 | pub_key); | ||
123 | |||
124 | |||
125 | peer->public_key = *pub_key; | ||
126 | |||
127 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
128 | "num: %u pub_key %s\n", | ||
129 | num, | ||
130 | GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key)); | ||
131 | |||
132 | cps->id = peer; | ||
133 | |||
134 | GNUNET_TRANSPORT_application_validate (ah, | ||
135 | peer, | ||
136 | nt, | ||
137 | addr); | ||
138 | } | ||
139 | |||
140 | |||
141 | /** | ||
142 | * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer. | ||
143 | * | ||
144 | */ | ||
145 | static int | ||
146 | connect_peers_finish (void *cls, | ||
147 | GNUNET_SCHEDULER_TaskCallback cont, | ||
148 | void *cont_cls) | ||
149 | { | ||
150 | struct ConnectPeersState *cps = cls; | ||
151 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
152 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
153 | unsigned int ret; | ||
154 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
155 | struct GNUNET_HashCode hc; | ||
156 | int node_number; | ||
157 | |||
158 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | ||
159 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (peer1_cmd, | ||
160 | &connected_peers_map); | ||
161 | |||
162 | node_number = 1; | ||
163 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | ||
164 | |||
165 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | ||
166 | memcpy (key, | ||
167 | &hc, | ||
168 | sizeof (*key)); | ||
169 | ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map, | ||
170 | key); | ||
171 | |||
172 | if (GNUNET_YES == ret) | ||
173 | { | ||
174 | cont (cont_cls); | ||
175 | } | ||
176 | |||
177 | GNUNET_free (key); | ||
178 | return ret; | ||
179 | } | ||
180 | |||
181 | |||
182 | /** | ||
183 | * Trait function of this cmd does nothing. | ||
184 | * | ||
185 | */ | ||
186 | static int | ||
187 | connect_peers_traits (void *cls, | ||
188 | const void **ret, | ||
189 | const char *trait, | ||
190 | unsigned int index) | ||
191 | { | ||
192 | return GNUNET_OK; | ||
193 | } | ||
194 | |||
195 | |||
196 | /** | ||
197 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
198 | * | ||
199 | */ | ||
200 | static void | ||
201 | connect_peers_cleanup (void *cls, | ||
202 | const struct GNUNET_TESTING_Command *cmd) | ||
203 | { | ||
204 | struct ConnectPeersState *cps = cls; | ||
205 | |||
206 | GNUNET_free (cps->id); | ||
207 | GNUNET_free (cps); | ||
208 | } | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Create command. | ||
213 | * | ||
214 | * @param label name for command. | ||
215 | * @param start_peer_label Label of the cmd to start a peer. | ||
216 | * @return command. | ||
217 | */ | ||
218 | struct GNUNET_TESTING_Command | ||
219 | GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label, | ||
220 | const char *start_peer_label, | ||
221 | const char *create_label, | ||
222 | uint32_t num) | ||
223 | { | ||
224 | struct ConnectPeersState *cps; | ||
225 | |||
226 | cps = GNUNET_new (struct ConnectPeersState); | ||
227 | cps->start_peer_label = start_peer_label; | ||
228 | cps->num = num; | ||
229 | cps->create_label = create_label; | ||
230 | |||
231 | |||
232 | struct GNUNET_TESTING_Command cmd = { | ||
233 | .cls = cps, | ||
234 | .label = label, | ||
235 | .run = &connect_peers_run, | ||
236 | .finish = &connect_peers_finish, | ||
237 | .cleanup = &connect_peers_cleanup, | ||
238 | .traits = &connect_peers_traits | ||
239 | }; | ||
240 | |||
241 | return cmd; | ||
242 | } | ||
diff --git a/src/transport/transport_api_cmd_connecting_peers_v3.c b/src/transport/transport_api_cmd_connecting_peers_v3.c deleted file mode 100644 index 2273d9852..000000000 --- a/src/transport/transport_api_cmd_connecting_peers_v3.c +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_transport_application_service.h" | ||
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_transport_service.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | /** | ||
40 | * Struct to store information needed in callbacks. | ||
41 | * | ||
42 | */ | ||
43 | struct ConnectPeersState | ||
44 | { | ||
45 | /** | ||
46 | * The testing system of this node. | ||
47 | */ | ||
48 | struct GNUNET_TESTING_System *tl_system; | ||
49 | |||
50 | // Label of the cmd which started the test system. | ||
51 | const char *create_label; | ||
52 | |||
53 | /** | ||
54 | * Number globally identifying the node. | ||
55 | * | ||
56 | */ | ||
57 | uint32_t num; | ||
58 | |||
59 | /** | ||
60 | * Label of the cmd to start a peer. | ||
61 | * | ||
62 | */ | ||
63 | const char *start_peer_label; | ||
64 | |||
65 | /** | ||
66 | * The peer identity of this peer. | ||
67 | * | ||
68 | */ | ||
69 | struct GNUNET_PeerIdentity *id; | ||
70 | |||
71 | /** | ||
72 | * The topology of the test setup. | ||
73 | */ | ||
74 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
75 | |||
76 | /** | ||
77 | * Connections to other peers. | ||
78 | */ | ||
79 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
80 | |||
81 | /** | ||
82 | * Number of connections. | ||
83 | */ | ||
84 | unsigned int con_num; | ||
85 | }; | ||
86 | |||
87 | |||
88 | /** | ||
89 | * The run method of this cmd will connect to peers. | ||
90 | * | ||
91 | */ | ||
92 | static void | ||
93 | connect_peers_run (void *cls, | ||
94 | const struct GNUNET_TESTING_Command *cmd, | ||
95 | struct GNUNET_TESTING_Interpreter *is) | ||
96 | { | ||
97 | struct ConnectPeersState *cps = cls; | ||
98 | const struct GNUNET_TESTING_Command *system_cmd; | ||
99 | struct GNUNET_TESTING_System *tl_system; | ||
100 | |||
101 | |||
102 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
103 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
104 | struct GNUNET_PeerIdentity *peer; | ||
105 | char *addr; | ||
106 | enum GNUNET_NetworkType nt = 0; | ||
107 | uint32_t num; | ||
108 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
109 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; | ||
110 | unsigned int con_num = 0; | ||
111 | |||
112 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | ||
113 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd, | ||
114 | &ah); | ||
115 | |||
116 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label); | ||
117 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
118 | &tl_system); | ||
119 | |||
120 | cps->tl_system = tl_system; | ||
121 | |||
122 | cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num, | ||
123 | cps->topology); | ||
124 | |||
125 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | ||
126 | pos_connection = pos_connection->next) | ||
127 | { | ||
128 | con_num++; | ||
129 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); | ||
130 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
131 | pos_prefix = | ||
132 | pos_prefix->next) | ||
133 | { | ||
134 | |||
135 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
136 | "prefix: %s\n", | ||
137 | pos_prefix->address_prefix); | ||
138 | |||
139 | addr = GNUNET_TESTING_get_address (pos_connection, | ||
140 | pos_prefix->address_prefix); | ||
141 | |||
142 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); | ||
143 | |||
144 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
145 | "num: %u pub_key %s addr: %s\n", | ||
146 | num, | ||
147 | GNUNET_CRYPTO_eddsa_public_key_to_string (&(peer->public_key)), | ||
148 | addr); | ||
149 | |||
150 | cps->id = peer; | ||
151 | |||
152 | GNUNET_TRANSPORT_application_validate (ah, | ||
153 | peer, | ||
154 | nt, | ||
155 | addr); | ||
156 | } | ||
157 | } | ||
158 | cps->con_num = con_num; | ||
159 | } | ||
160 | |||
161 | |||
162 | /** | ||
163 | * The finish function of this cmd will check if the peers we are trying to | ||
164 | * connect to are in the connected peers map of the start peer cmd for this peer. | ||
165 | * | ||
166 | */ | ||
167 | static int | ||
168 | connect_peers_finish (void *cls, | ||
169 | GNUNET_SCHEDULER_TaskCallback cont, | ||
170 | void *cont_cls) | ||
171 | { | ||
172 | struct ConnectPeersState *cps = cls; | ||
173 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
174 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
175 | unsigned int ret; | ||
176 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
177 | struct GNUNET_HashCode hc; | ||
178 | struct GNUNET_PeerIdentity *peer; | ||
179 | unsigned int con_num = 0; | ||
180 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
181 | unsigned int num; | ||
182 | |||
183 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | ||
184 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (peer1_cmd, | ||
185 | &connected_peers_map); | ||
186 | |||
187 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | ||
188 | pos_connection = pos_connection->next) | ||
189 | { | ||
190 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); | ||
191 | peer = GNUNET_TESTING_get_pub_key (num, cps->tl_system); | ||
192 | GNUNET_CRYPTO_hash (&(peer->public_key), sizeof(peer->public_key), &hc); | ||
193 | memcpy (key, | ||
194 | &hc, | ||
195 | sizeof (*key)); | ||
196 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( | ||
197 | connected_peers_map, | ||
198 | key)) | ||
199 | con_num++; | ||
200 | } | ||
201 | |||
202 | |||
203 | |||
204 | if (cps->con_num == con_num) | ||
205 | { | ||
206 | cont (cont_cls); | ||
207 | ret = GNUNET_YES; | ||
208 | } | ||
209 | |||
210 | GNUNET_free (key); | ||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | |||
215 | /** | ||
216 | * Trait function of this cmd does nothing. | ||
217 | * | ||
218 | */ | ||
219 | static int | ||
220 | connect_peers_traits (void *cls, | ||
221 | const void **ret, | ||
222 | const char *trait, | ||
223 | unsigned int index) | ||
224 | { | ||
225 | return GNUNET_OK; | ||
226 | } | ||
227 | |||
228 | |||
229 | /** | ||
230 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
231 | * | ||
232 | */ | ||
233 | static void | ||
234 | connect_peers_cleanup (void *cls, | ||
235 | const struct GNUNET_TESTING_Command *cmd) | ||
236 | { | ||
237 | struct ConnectPeersState *cps = cls; | ||
238 | |||
239 | GNUNET_free (cps->id); | ||
240 | GNUNET_free (cps); | ||
241 | } | ||
242 | |||
243 | |||
244 | /** | ||
245 | * Create command. | ||
246 | * | ||
247 | * @param label name for command. | ||
248 | * @param start_peer_label Label of the cmd to start a peer. | ||
249 | * @param create_label Label of the cmd to create the testing system. | ||
250 | * @param num Number globally identifying the node. | ||
251 | * @param The topology for the test setup. | ||
252 | * @return command. | ||
253 | */ | ||
254 | struct GNUNET_TESTING_Command | ||
255 | GNUNET_TRANSPORT_cmd_connect_peers_v3 (const char *label, | ||
256 | const char *start_peer_label, | ||
257 | const char *create_label, | ||
258 | uint32_t num, | ||
259 | struct GNUNET_TESTING_NetjailTopology * | ||
260 | topology) | ||
261 | { | ||
262 | struct ConnectPeersState *cps; | ||
263 | |||
264 | cps = GNUNET_new (struct ConnectPeersState); | ||
265 | cps->start_peer_label = start_peer_label; | ||
266 | cps->num = num; | ||
267 | cps->create_label = create_label; | ||
268 | cps->topology = topology; | ||
269 | |||
270 | |||
271 | struct GNUNET_TESTING_Command cmd = { | ||
272 | .cls = cps, | ||
273 | .label = label, | ||
274 | .run = &connect_peers_run, | ||
275 | .finish = &connect_peers_finish, | ||
276 | .cleanup = &connect_peers_cleanup, | ||
277 | .traits = &connect_peers_traits | ||
278 | }; | ||
279 | |||
280 | return cmd; | ||
281 | } | ||
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c index f9e515c0f..0631f7051 100644 --- a/src/transport/transport_api_cmd_send_simple.c +++ b/src/transport/transport_api_cmd_send_simple.c | |||
@@ -36,18 +36,6 @@ | |||
36 | struct SendSimpleState | 36 | struct SendSimpleState |
37 | { | 37 | { |
38 | /** | 38 | /** |
39 | * The number of the local node of the actual network namespace. | ||
40 | * | ||
41 | */ | ||
42 | char *m; | ||
43 | |||
44 | /** | ||
45 | * The number of the actual namespace. | ||
46 | * | ||
47 | */ | ||
48 | char *n; | ||
49 | |||
50 | /** | ||
51 | * Number globally identifying the node. | 39 | * Number globally identifying the node. |
52 | * | 40 | * |
53 | */ | 41 | */ |
@@ -80,8 +68,7 @@ send_simple_traits (void *cls, | |||
80 | * | 68 | * |
81 | */ | 69 | */ |
82 | static void | 70 | static void |
83 | send_simple_cleanup (void *cls, | 71 | send_simple_cleanup (void *cls) |
84 | const struct GNUNET_TESTING_Command *cmd) | ||
85 | { | 72 | { |
86 | struct SendSimpleState *sss = cls; | 73 | struct SendSimpleState *sss = cls; |
87 | 74 | ||
@@ -95,7 +82,6 @@ send_simple_cleanup (void *cls, | |||
95 | */ | 82 | */ |
96 | static void | 83 | static void |
97 | send_simple_run (void *cls, | 84 | send_simple_run (void *cls, |
98 | const struct GNUNET_TESTING_Command *cmd, | ||
99 | struct GNUNET_TESTING_Interpreter *is) | 85 | struct GNUNET_TESTING_Interpreter *is) |
100 | { | 86 | { |
101 | struct SendSimpleState *sss = cls; | 87 | struct SendSimpleState *sss = cls; |
@@ -108,7 +94,8 @@ send_simple_run (void *cls, | |||
108 | struct GNUNET_HashCode hc; | 94 | struct GNUNET_HashCode hc; |
109 | int node_number; | 95 | int node_number; |
110 | 96 | ||
111 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label); | 97 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
98 | sss->start_peer_label); | ||
112 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | 99 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, |
113 | &connected_peers_map); | 100 | &connected_peers_map); |
114 | 101 | ||
@@ -147,26 +134,23 @@ send_simple_run (void *cls, | |||
147 | */ | 134 | */ |
148 | struct GNUNET_TESTING_Command | 135 | struct GNUNET_TESTING_Command |
149 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, | 136 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, |
150 | char *m, | 137 | const char *start_peer_label, |
151 | char *n, | 138 | uint32_t num) |
152 | uint32_t num, | ||
153 | const char *start_peer_label) | ||
154 | { | 139 | { |
155 | struct SendSimpleState *sss; | 140 | struct SendSimpleState *sss; |
156 | 141 | ||
157 | sss = GNUNET_new (struct SendSimpleState); | 142 | sss = GNUNET_new (struct SendSimpleState); |
158 | sss->m = m; | ||
159 | sss->n = n; | ||
160 | sss->num = num; | 143 | sss->num = num; |
161 | sss->start_peer_label = start_peer_label; | 144 | sss->start_peer_label = start_peer_label; |
162 | 145 | { | |
163 | struct GNUNET_TESTING_Command cmd = { | 146 | struct GNUNET_TESTING_Command cmd = { |
164 | .cls = sss, | 147 | .cls = sss, |
165 | .label = label, | 148 | .label = label, |
166 | .run = &send_simple_run, | 149 | .run = &send_simple_run, |
167 | .cleanup = &send_simple_cleanup, | 150 | .cleanup = &send_simple_cleanup, |
168 | .traits = &send_simple_traits | 151 | .traits = &send_simple_traits |
169 | }; | 152 | }; |
170 | 153 | ||
171 | return cmd; | 154 | return cmd; |
155 | } | ||
172 | } | 156 | } |
diff --git a/src/transport/transport_api_cmd_send_simple_v2.c b/src/transport/transport_api_cmd_send_simple_v2.c deleted file mode 100644 index d43c0b425..000000000 --- a/src/transport/transport_api_cmd_send_simple_v2.c +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "transport-testing2.h" | ||
30 | #include "transport-testing-cmds.h" | ||
31 | |||
32 | /** | ||
33 | * Struct to hold information for callbacks. | ||
34 | * | ||
35 | */ | ||
36 | struct SendSimpleState | ||
37 | { | ||
38 | /** | ||
39 | * Number globally identifying the node. | ||
40 | * | ||
41 | */ | ||
42 | uint32_t num; | ||
43 | |||
44 | /** | ||
45 | * Label of the cmd to start a peer. | ||
46 | * | ||
47 | */ | ||
48 | const char *start_peer_label; | ||
49 | }; | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Trait function of this cmd does nothing. | ||
54 | * | ||
55 | */ | ||
56 | static int | ||
57 | send_simple_traits (void *cls, | ||
58 | const void **ret, | ||
59 | const char *trait, | ||
60 | unsigned int index) | ||
61 | { | ||
62 | return GNUNET_OK; | ||
63 | } | ||
64 | |||
65 | |||
66 | /** | ||
67 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
68 | * | ||
69 | */ | ||
70 | static void | ||
71 | send_simple_cleanup (void *cls, | ||
72 | const struct GNUNET_TESTING_Command *cmd) | ||
73 | { | ||
74 | struct SendSimpleState *sss = cls; | ||
75 | |||
76 | GNUNET_free (sss); | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * The run method of this cmd will send a simple message to the connected peer. | ||
82 | * | ||
83 | */ | ||
84 | static void | ||
85 | send_simple_run (void *cls, | ||
86 | const struct GNUNET_TESTING_Command *cmd, | ||
87 | struct GNUNET_TESTING_Interpreter *is) | ||
88 | { | ||
89 | struct SendSimpleState *sss = cls; | ||
90 | struct GNUNET_MQ_Envelope *env; | ||
91 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; | ||
92 | struct GNUNET_MQ_Handle *mq; | ||
93 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
94 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
95 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
96 | struct GNUNET_HashCode hc; | ||
97 | int node_number; | ||
98 | |||
99 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label); | ||
100 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | ||
101 | &connected_peers_map); | ||
102 | |||
103 | node_number = 1; | ||
104 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | ||
105 | memcpy (key, | ||
106 | &hc, | ||
107 | sizeof (*key)); | ||
108 | |||
109 | mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, | ||
110 | key); | ||
111 | |||
112 | env = GNUNET_MQ_msg_extra (test, | ||
113 | 2600 - sizeof(*test), | ||
114 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); | ||
115 | test->num = htonl (sss->num); | ||
116 | memset (&test[1], | ||
117 | sss->num, | ||
118 | 2600 - sizeof(*test)); | ||
119 | GNUNET_MQ_send (mq, | ||
120 | env); | ||
121 | GNUNET_free (key); | ||
122 | |||
123 | } | ||
124 | |||
125 | |||
126 | /** | ||
127 | * Create command. | ||
128 | * | ||
129 | * @param label name for command. | ||
130 | * @param m The number of the local node of the actual network namespace. | ||
131 | * @param n The number of the actual namespace. | ||
132 | * @param num Number globally identifying the node. | ||
133 | * @param start_peer_label Label of the cmd to start a peer. | ||
134 | * @return command. | ||
135 | */ | ||
136 | struct GNUNET_TESTING_Command | ||
137 | GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label, | ||
138 | const char *start_peer_label, | ||
139 | uint32_t num) | ||
140 | { | ||
141 | struct SendSimpleState *sss; | ||
142 | |||
143 | sss = GNUNET_new (struct SendSimpleState); | ||
144 | sss->num = num; | ||
145 | sss->start_peer_label = start_peer_label; | ||
146 | |||
147 | struct GNUNET_TESTING_Command cmd = { | ||
148 | .cls = sss, | ||
149 | .label = label, | ||
150 | .run = &send_simple_run, | ||
151 | .cleanup = &send_simple_cleanup, | ||
152 | .traits = &send_simple_traits | ||
153 | }; | ||
154 | |||
155 | return cmd; | ||
156 | } | ||
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index f4e92944b..dc19f10eb 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -65,7 +65,7 @@ hello_iter_cb (void *cb_cls, | |||
65 | 65 | ||
66 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | 66 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); |
67 | sps->pic = NULL; | 67 | sps->pic = NULL; |
68 | sps->finished = GNUNET_YES; | 68 | GNUNET_TESTING_async_finish (&sps->ac); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
@@ -90,26 +90,6 @@ retrieve_hello (void *cls) | |||
90 | 90 | ||
91 | 91 | ||
92 | /** | 92 | /** |
93 | * This function checks StartPeerState#finished, which is set when the hello was retrieved. | ||
94 | * | ||
95 | */ | ||
96 | static int | ||
97 | start_peer_finish (void *cls, | ||
98 | GNUNET_SCHEDULER_TaskCallback cont, | ||
99 | void *cont_cls) | ||
100 | { | ||
101 | struct StartPeerState *sps = cls; | ||
102 | |||
103 | if (GNUNET_YES == sps->finished) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return sps->finished; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Disconnect callback for the connection to the core service. | 93 | * Disconnect callback for the connection to the core service. |
114 | * | 94 | * |
115 | */ | 95 | */ |
@@ -141,7 +121,7 @@ notify_connect (void *cls, | |||
141 | struct StartPeerState *sps = cls; | 121 | struct StartPeerState *sps = cls; |
142 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | 122 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); |
143 | struct GNUNET_HashCode hc; | 123 | struct GNUNET_HashCode hc; |
144 | int node_number; | 124 | struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key; |
145 | 125 | ||
146 | void *ret = NULL; | 126 | void *ret = NULL; |
147 | 127 | ||
@@ -152,9 +132,7 @@ notify_connect (void *cls, | |||
152 | sps->no, | 132 | sps->no, |
153 | GNUNET_i2s (&sps->id)); | 133 | GNUNET_i2s (&sps->id)); |
154 | 134 | ||
155 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | 135 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); |
156 | node_number = 1; | ||
157 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | ||
158 | 136 | ||
159 | 137 | ||
160 | memcpy (key, | 138 | memcpy (key, |
@@ -166,6 +144,11 @@ notify_connect (void *cls, | |||
166 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 144 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
167 | 145 | ||
168 | GNUNET_free (key); | 146 | GNUNET_free (key); |
147 | |||
148 | sps->notify_connect (cls, | ||
149 | peer, | ||
150 | mq); | ||
151 | |||
169 | // TODO what does the handler function need? | 152 | // TODO what does the handler function need? |
170 | return ret; | 153 | return ret; |
171 | } | 154 | } |
@@ -177,7 +160,6 @@ notify_connect (void *cls, | |||
177 | */ | 160 | */ |
178 | static void | 161 | static void |
179 | start_peer_run (void *cls, | 162 | start_peer_run (void *cls, |
180 | const struct GNUNET_TESTING_Command *cmd, | ||
181 | struct GNUNET_TESTING_Interpreter *is) | 163 | struct GNUNET_TESTING_Interpreter *is) |
182 | { | 164 | { |
183 | struct StartPeerState *sps = cls; | 165 | struct StartPeerState *sps = cls; |
@@ -187,7 +169,8 @@ start_peer_run (void *cls, | |||
187 | struct GNUNET_TESTING_System *tl_system; | 169 | struct GNUNET_TESTING_System *tl_system; |
188 | char *home; | 170 | char *home; |
189 | char *transport_unix_path; | 171 | char *transport_unix_path; |
190 | char *communicator_unix_path; | 172 | char *tcp_communicator_unix_path; |
173 | char *udp_communicator_unix_path; | ||
191 | char *bindto; | 174 | char *bindto; |
192 | 175 | ||
193 | if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) | 176 | if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) |
@@ -195,7 +178,7 @@ start_peer_run (void *cls, | |||
195 | LOG (GNUNET_ERROR_TYPE_ERROR, | 178 | LOG (GNUNET_ERROR_TYPE_ERROR, |
196 | "File not found: `%s'\n", | 179 | "File not found: `%s'\n", |
197 | sps->cfgname); | 180 | sps->cfgname); |
198 | GNUNET_TESTING_interpreter_fail (); | 181 | GNUNET_TESTING_interpreter_fail (is); |
199 | return; | 182 | return; |
200 | } | 183 | } |
201 | 184 | ||
@@ -212,7 +195,11 @@ start_peer_run (void *cls, | |||
212 | "$GNUNET_RUNTIME_DIR/tng-p%u.sock", | 195 | "$GNUNET_RUNTIME_DIR/tng-p%u.sock", |
213 | sps->no); | 196 | sps->no); |
214 | 197 | ||
215 | GNUNET_asprintf (&communicator_unix_path, | 198 | GNUNET_asprintf (&tcp_communicator_unix_path, |
199 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
200 | sps->no); | ||
201 | |||
202 | GNUNET_asprintf (&udp_communicator_unix_path, | ||
216 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | 203 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", |
217 | sps->no); | 204 | sps->no); |
218 | 205 | ||
@@ -220,6 +207,9 @@ start_peer_run (void *cls, | |||
220 | "%s:60002", | 207 | "%s:60002", |
221 | sps->node_ip); | 208 | sps->node_ip); |
222 | 209 | ||
210 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
211 | "node_ip %s\n", | ||
212 | bindto); | ||
223 | 213 | ||
224 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", | 214 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", |
225 | home); | 215 | home); |
@@ -228,11 +218,18 @@ start_peer_run (void *cls, | |||
228 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | 218 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", |
229 | "BINDTO", | 219 | "BINDTO", |
230 | bindto); | 220 | bindto); |
221 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
222 | "BINDTO", | ||
223 | bindto); | ||
231 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | 224 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", |
232 | "UNIXPATH", | 225 | "UNIXPATH", |
233 | communicator_unix_path); | 226 | tcp_communicator_unix_path); |
227 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
228 | "UNIXPATH", | ||
229 | udp_communicator_unix_path); | ||
234 | 230 | ||
235 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label); | 231 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
232 | sps->system_label); | ||
236 | GNUNET_TESTING_get_trait_test_system (system_cmd, | 233 | GNUNET_TESTING_get_trait_test_system (system_cmd, |
237 | &tl_system); | 234 | &tl_system); |
238 | 235 | ||
@@ -246,7 +243,7 @@ start_peer_run (void *cls, | |||
246 | "Testing library failed to create unique configuration based on `%s'\n", | 243 | "Testing library failed to create unique configuration based on `%s'\n", |
247 | sps->cfgname); | 244 | sps->cfgname); |
248 | GNUNET_CONFIGURATION_destroy (sps->cfg); | 245 | GNUNET_CONFIGURATION_destroy (sps->cfg); |
249 | GNUNET_TESTING_interpreter_fail (); | 246 | GNUNET_TESTING_interpreter_fail (is); |
250 | return; | 247 | return; |
251 | } | 248 | } |
252 | 249 | ||
@@ -262,7 +259,7 @@ start_peer_run (void *cls, | |||
262 | sps->cfgname, | 259 | sps->cfgname, |
263 | emsg); | 260 | emsg); |
264 | GNUNET_free (emsg); | 261 | GNUNET_free (emsg); |
265 | GNUNET_TESTING_interpreter_fail (); | 262 | GNUNET_TESTING_interpreter_fail (is); |
266 | return; | 263 | return; |
267 | } | 264 | } |
268 | 265 | ||
@@ -272,7 +269,7 @@ start_peer_run (void *cls, | |||
272 | "Testing library failed to create unique configuration based on `%s'\n", | 269 | "Testing library failed to create unique configuration based on `%s'\n", |
273 | sps->cfgname); | 270 | sps->cfgname); |
274 | GNUNET_free (emsg); | 271 | GNUNET_free (emsg); |
275 | GNUNET_TESTING_interpreter_fail (); | 272 | GNUNET_TESTING_interpreter_fail (is); |
276 | return; | 273 | return; |
277 | } | 274 | } |
278 | 275 | ||
@@ -291,7 +288,7 @@ start_peer_run (void *cls, | |||
291 | "Testing library failed to obtain peer identity for peer %u\n", | 288 | "Testing library failed to obtain peer identity for peer %u\n", |
292 | sps->no); | 289 | sps->no); |
293 | GNUNET_free (emsg); | 290 | GNUNET_free (emsg); |
294 | GNUNET_TESTING_interpreter_fail (); | 291 | GNUNET_TESTING_interpreter_fail (is); |
295 | return; | 292 | return; |
296 | } | 293 | } |
297 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 294 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -312,7 +309,7 @@ start_peer_run (void *cls, | |||
312 | sps->cfgname, | 309 | sps->cfgname, |
313 | emsg); | 310 | emsg); |
314 | GNUNET_free (emsg); | 311 | GNUNET_free (emsg); |
315 | GNUNET_TESTING_interpreter_fail (); | 312 | GNUNET_TESTING_interpreter_fail (is); |
316 | return; | 313 | return; |
317 | } | 314 | } |
318 | 315 | ||
@@ -324,7 +321,7 @@ start_peer_run (void *cls, | |||
324 | sps->cfgname, | 321 | sps->cfgname, |
325 | emsg); | 322 | emsg); |
326 | GNUNET_free (emsg); | 323 | GNUNET_free (emsg); |
327 | GNUNET_TESTING_interpreter_fail (); | 324 | GNUNET_TESTING_interpreter_fail (is); |
328 | return; | 325 | return; |
329 | } | 326 | } |
330 | 327 | ||
@@ -336,7 +333,7 @@ start_peer_run (void *cls, | |||
336 | sps->cfgname, | 333 | sps->cfgname, |
337 | emsg); | 334 | emsg); |
338 | GNUNET_free (emsg); | 335 | GNUNET_free (emsg); |
339 | GNUNET_TESTING_interpreter_fail (); | 336 | GNUNET_TESTING_interpreter_fail (is); |
340 | return; | 337 | return; |
341 | } | 338 | } |
342 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | 339 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); |
@@ -348,8 +345,7 @@ start_peer_run (void *cls, | |||
348 | * | 345 | * |
349 | */ | 346 | */ |
350 | static void | 347 | static void |
351 | start_peer_cleanup (void *cls, | 348 | start_peer_cleanup (void *cls) |
352 | const struct GNUNET_TESTING_Command *cmd) | ||
353 | { | 349 | { |
354 | struct StartPeerState *sps = cls; | 350 | struct StartPeerState *sps = cls; |
355 | 351 | ||
@@ -437,10 +433,9 @@ start_peer_traits (void *cls, | |||
437 | * | 433 | * |
438 | */ | 434 | */ |
439 | int | 435 | int |
440 | GNUNET_TRANSPORT_get_trait_state (const struct | 436 | GNUNET_TRANSPORT_get_trait_state ( |
441 | GNUNET_TESTING_Command | 437 | const struct GNUNET_TESTING_Command *cmd, |
442 | *cmd, | 438 | struct StartPeerState **sps) |
443 | struct StartPeerState **sps) | ||
444 | { | 439 | { |
445 | return cmd->traits (cmd->cls, | 440 | return cmd->traits (cmd->cls, |
446 | (const void **) sps, | 441 | (const void **) sps, |
@@ -501,7 +496,8 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | |||
501 | GNUNET_TESTING_Command | 496 | GNUNET_TESTING_Command |
502 | *cmd, | 497 | *cmd, |
503 | struct | 498 | struct |
504 | GNUNET_CONTAINER_MultiShortmap * | 499 | GNUNET_CONTAINER_MultiShortmap |
500 | * | ||
505 | * | 501 | * |
506 | connected_peers_map) | 502 | connected_peers_map) |
507 | { | 503 | { |
@@ -565,12 +561,11 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct | |||
565 | struct GNUNET_TESTING_Command | 561 | struct GNUNET_TESTING_Command |
566 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, | 562 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, |
567 | const char *system_label, | 563 | const char *system_label, |
568 | char *m, | 564 | uint32_t no, |
569 | char *n, | ||
570 | char *local_m, | ||
571 | char *node_ip, | 565 | char *node_ip, |
572 | struct GNUNET_MQ_MessageHandler *handlers, | 566 | struct GNUNET_MQ_MessageHandler *handlers, |
573 | const char *cfgname) | 567 | const char *cfgname, |
568 | GNUNET_TRANSPORT_NotifyConnect notify_connect) | ||
574 | { | 569 | { |
575 | struct StartPeerState *sps; | 570 | struct StartPeerState *sps; |
576 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | 571 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = |
@@ -578,14 +573,12 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
578 | unsigned int i; | 573 | unsigned int i; |
579 | 574 | ||
580 | sps = GNUNET_new (struct StartPeerState); | 575 | sps = GNUNET_new (struct StartPeerState); |
581 | sps->m = m; | 576 | sps->no = no; |
582 | sps->n = n; | ||
583 | sps->local_m = local_m; | ||
584 | sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m); | ||
585 | sps->system_label = system_label; | 577 | sps->system_label = system_label; |
586 | sps->connected_peers_map = connected_peers_map; | 578 | sps->connected_peers_map = connected_peers_map; |
587 | sps->cfgname = cfgname; | 579 | sps->cfgname = cfgname; |
588 | sps->node_ip = node_ip; | 580 | sps->node_ip = node_ip; |
581 | sps->notify_connect = notify_connect; | ||
589 | 582 | ||
590 | if (NULL != handlers) | 583 | if (NULL != handlers) |
591 | { | 584 | { |
@@ -602,7 +595,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
602 | .cls = sps, | 595 | .cls = sps, |
603 | .label = label, | 596 | .label = label, |
604 | .run = &start_peer_run, | 597 | .run = &start_peer_run, |
605 | .finish = &start_peer_finish, | 598 | .ac = &sps->ac, |
606 | .cleanup = &start_peer_cleanup, | 599 | .cleanup = &start_peer_cleanup, |
607 | .traits = &start_peer_traits | 600 | .traits = &start_peer_traits |
608 | }; | 601 | }; |
diff --git a/src/transport/transport_api_cmd_start_peer_v2.c b/src/transport/transport_api_cmd_start_peer_v2.c deleted file mode 100644 index 0e39bd915..000000000 --- a/src/transport/transport_api_cmd_start_peer_v2.c +++ /dev/null | |||
@@ -1,607 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_peerstore_service.h" | ||
30 | #include "gnunet_transport_core_service.h" | ||
31 | #include "gnunet_transport_application_service.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | static void | ||
41 | retrieve_hello (void *cls); | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Callback delivering the hello of this peer from peerstore. | ||
46 | * | ||
47 | */ | ||
48 | static void | ||
49 | hello_iter_cb (void *cb_cls, | ||
50 | const struct GNUNET_PEERSTORE_Record *record, | ||
51 | const char *emsg) | ||
52 | { | ||
53 | struct StartPeerState_v2 *sps = cb_cls; | ||
54 | if (NULL == record) | ||
55 | { | ||
56 | sps->pic = NULL; | ||
57 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
58 | return; | ||
59 | } | ||
60 | // Check record type et al? | ||
61 | sps->hello_size = record->value_size; | ||
62 | sps->hello = GNUNET_malloc (sps->hello_size); | ||
63 | memcpy (sps->hello, record->value, sps->hello_size); | ||
64 | sps->hello[sps->hello_size - 1] = '\0'; | ||
65 | |||
66 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | ||
67 | sps->pic = NULL; | ||
68 | sps->finished = GNUNET_YES; | ||
69 | } | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Function to start the retrieval task to retrieve the hello of this peer | ||
74 | * from the peerstore. | ||
75 | * | ||
76 | */ | ||
77 | static void | ||
78 | retrieve_hello (void *cls) | ||
79 | { | ||
80 | struct StartPeerState_v2 *sps = cls; | ||
81 | sps->rh_task = NULL; | ||
82 | sps->pic = GNUNET_PEERSTORE_iterate (sps->ph, | ||
83 | "transport", | ||
84 | &sps->id, | ||
85 | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, | ||
86 | hello_iter_cb, | ||
87 | sps); | ||
88 | |||
89 | } | ||
90 | |||
91 | |||
92 | /** | ||
93 | * This function checks StartPeerState_v2#finished, which is set when the hello was retrieved. | ||
94 | * | ||
95 | */ | ||
96 | static int | ||
97 | start_peer_finish (void *cls, | ||
98 | GNUNET_SCHEDULER_TaskCallback cont, | ||
99 | void *cont_cls) | ||
100 | { | ||
101 | struct StartPeerState_v2 *sps = cls; | ||
102 | |||
103 | if (GNUNET_YES == sps->finished) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return sps->finished; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Disconnect callback for the connection to the core service. | ||
114 | * | ||
115 | */ | ||
116 | static void | ||
117 | notify_disconnect (void *cls, | ||
118 | const struct GNUNET_PeerIdentity *peer, | ||
119 | void *handler_cls) | ||
120 | { | ||
121 | struct StartPeerState_v2 *sps = cls; | ||
122 | |||
123 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
124 | "Peer %s disconnected from peer %u (`%s')\n", | ||
125 | GNUNET_i2s (peer), | ||
126 | sps->no, | ||
127 | GNUNET_i2s (&sps->id)); | ||
128 | |||
129 | } | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Connect callback for the connection to the core service. | ||
134 | * | ||
135 | */ | ||
136 | static void * | ||
137 | notify_connect (void *cls, | ||
138 | const struct GNUNET_PeerIdentity *peer, | ||
139 | struct GNUNET_MQ_Handle *mq) | ||
140 | { | ||
141 | struct StartPeerState_v2 *sps = cls; | ||
142 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
143 | struct GNUNET_HashCode hc; | ||
144 | int node_number; | ||
145 | |||
146 | void *ret = NULL; | ||
147 | |||
148 | |||
149 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
150 | "Peer %s connected to peer %u (`%s')\n", | ||
151 | GNUNET_i2s (peer), | ||
152 | sps->no, | ||
153 | GNUNET_i2s (&sps->id)); | ||
154 | |||
155 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | ||
156 | node_number = 1; | ||
157 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | ||
158 | |||
159 | |||
160 | memcpy (key, | ||
161 | &hc, | ||
162 | sizeof (*key)); | ||
163 | GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map, | ||
164 | key, | ||
165 | mq, | ||
166 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
167 | |||
168 | GNUNET_free (key); | ||
169 | // TODO what does the handler function need? | ||
170 | return ret; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * The run method of this cmd will start all services of a peer to test the transport service. | ||
176 | * | ||
177 | */ | ||
178 | static void | ||
179 | start_peer_run (void *cls, | ||
180 | const struct GNUNET_TESTING_Command *cmd, | ||
181 | struct GNUNET_TESTING_Interpreter *is) | ||
182 | { | ||
183 | struct StartPeerState_v2 *sps = cls; | ||
184 | char *emsg = NULL; | ||
185 | struct GNUNET_PeerIdentity dummy; | ||
186 | const struct GNUNET_TESTING_Command *system_cmd; | ||
187 | struct GNUNET_TESTING_System *tl_system; | ||
188 | char *home; | ||
189 | char *transport_unix_path; | ||
190 | char *communicator_unix_path; | ||
191 | char *bindto; | ||
192 | |||
193 | if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) | ||
194 | { | ||
195 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
196 | "File not found: `%s'\n", | ||
197 | sps->cfgname); | ||
198 | GNUNET_TESTING_interpreter_fail (); | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | |||
203 | sps->cfg = GNUNET_CONFIGURATION_create (); | ||
204 | GNUNET_assert (GNUNET_OK == | ||
205 | GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname)); | ||
206 | |||
207 | GNUNET_asprintf (&home, | ||
208 | "$GNUNET_TMP/test-transport/api-tcp-p%u", | ||
209 | sps->no); | ||
210 | |||
211 | GNUNET_asprintf (&transport_unix_path, | ||
212 | "$GNUNET_RUNTIME_DIR/tng-p%u.sock", | ||
213 | sps->no); | ||
214 | |||
215 | GNUNET_asprintf (&communicator_unix_path, | ||
216 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
217 | sps->no); | ||
218 | |||
219 | GNUNET_asprintf (&bindto, | ||
220 | "%s:60002", | ||
221 | sps->node_ip); | ||
222 | |||
223 | |||
224 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", | ||
225 | home); | ||
226 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH", | ||
227 | transport_unix_path); | ||
228 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
229 | "BINDTO", | ||
230 | bindto); | ||
231 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
232 | "UNIXPATH", | ||
233 | communicator_unix_path); | ||
234 | |||
235 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label); | ||
236 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
237 | &tl_system); | ||
238 | |||
239 | sps->tl_system = tl_system; | ||
240 | |||
241 | if (GNUNET_SYSERR == | ||
242 | GNUNET_TESTING_configuration_create (tl_system, | ||
243 | sps->cfg)) | ||
244 | { | ||
245 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
246 | "Testing library failed to create unique configuration based on `%s'\n", | ||
247 | sps->cfgname); | ||
248 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
249 | GNUNET_TESTING_interpreter_fail (); | ||
250 | return; | ||
251 | } | ||
252 | |||
253 | sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system, | ||
254 | sps->cfg, | ||
255 | sps->no, | ||
256 | NULL, | ||
257 | &emsg); | ||
258 | if (NULL == sps->peer) | ||
259 | { | ||
260 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
261 | "Testing library failed to create unique configuration based on `%s': `%s'\n", | ||
262 | sps->cfgname, | ||
263 | emsg); | ||
264 | GNUNET_free (emsg); | ||
265 | GNUNET_TESTING_interpreter_fail (); | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer)) | ||
270 | { | ||
271 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
272 | "Testing library failed to create unique configuration based on `%s'\n", | ||
273 | sps->cfgname); | ||
274 | GNUNET_free (emsg); | ||
275 | GNUNET_TESTING_interpreter_fail (); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | memset (&dummy, | ||
280 | '\0', | ||
281 | sizeof(dummy)); | ||
282 | |||
283 | GNUNET_TESTING_peer_get_identity (sps->peer, | ||
284 | &sps->id); | ||
285 | |||
286 | if (0 == memcmp (&dummy, | ||
287 | &sps->id, | ||
288 | sizeof(struct GNUNET_PeerIdentity))) | ||
289 | { | ||
290 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
291 | "Testing library failed to obtain peer identity for peer %u\n", | ||
292 | sps->no); | ||
293 | GNUNET_free (emsg); | ||
294 | GNUNET_TESTING_interpreter_fail (); | ||
295 | return; | ||
296 | } | ||
297 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
298 | "Peer %u configured with identity `%s'\n", | ||
299 | sps->no, | ||
300 | GNUNET_i2s_full (&sps->id)); | ||
301 | |||
302 | sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg, | ||
303 | NULL, | ||
304 | sps->handlers, | ||
305 | sps, | ||
306 | ¬ify_connect, | ||
307 | ¬ify_disconnect); | ||
308 | if (NULL == sps->th) | ||
309 | { | ||
310 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
311 | "Failed to connect to transport service for peer `%s': `%s'\n", | ||
312 | sps->cfgname, | ||
313 | emsg); | ||
314 | GNUNET_free (emsg); | ||
315 | GNUNET_TESTING_interpreter_fail (); | ||
316 | return; | ||
317 | } | ||
318 | |||
319 | sps->ph = GNUNET_PEERSTORE_connect (sps->cfg); | ||
320 | if (NULL == sps->th) | ||
321 | { | ||
322 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
323 | "Failed to connect to peerstore service for peer `%s': `%s'\n", | ||
324 | sps->cfgname, | ||
325 | emsg); | ||
326 | GNUNET_free (emsg); | ||
327 | GNUNET_TESTING_interpreter_fail (); | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg); | ||
332 | if (NULL == sps->ah) | ||
333 | { | ||
334 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
335 | "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n", | ||
336 | sps->cfgname, | ||
337 | emsg); | ||
338 | GNUNET_free (emsg); | ||
339 | GNUNET_TESTING_interpreter_fail (); | ||
340 | return; | ||
341 | } | ||
342 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
343 | } | ||
344 | |||
345 | |||
346 | /** | ||
347 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
348 | * | ||
349 | */ | ||
350 | static void | ||
351 | start_peer_cleanup (void *cls, | ||
352 | const struct GNUNET_TESTING_Command *cmd) | ||
353 | { | ||
354 | struct StartPeerState_v2 *sps = cls; | ||
355 | |||
356 | if (NULL != sps->handlers) | ||
357 | { | ||
358 | GNUNET_free (sps->handlers); | ||
359 | sps->handlers = NULL; | ||
360 | } | ||
361 | if (NULL != sps->cfg) | ||
362 | { | ||
363 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
364 | sps->cfg = NULL; | ||
365 | } | ||
366 | GNUNET_free (sps->hello); | ||
367 | GNUNET_free (sps->connected_peers_map); | ||
368 | GNUNET_free (sps); | ||
369 | } | ||
370 | |||
371 | |||
372 | /** | ||
373 | * This function prepares an array with traits. | ||
374 | * | ||
375 | */ | ||
376 | static int | ||
377 | start_peer_traits (void *cls, | ||
378 | const void **ret, | ||
379 | const char *trait, | ||
380 | unsigned int index) | ||
381 | { | ||
382 | struct StartPeerState_v2 *sps = cls; | ||
383 | struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; | ||
384 | struct GNUNET_PeerIdentity *id = &sps->id; | ||
385 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
386 | sps->connected_peers_map; | ||
387 | char *hello = sps->hello; | ||
388 | size_t hello_size = sps->hello_size; | ||
389 | |||
390 | |||
391 | struct GNUNET_TESTING_Trait traits[] = { | ||
392 | { | ||
393 | .index = 0, | ||
394 | .trait_name = "application_handle", | ||
395 | .ptr = (const void *) ah, | ||
396 | }, | ||
397 | { | ||
398 | .index = 1, | ||
399 | .trait_name = "peer_id", | ||
400 | .ptr = (const void *) id, | ||
401 | }, | ||
402 | { | ||
403 | .index = 2, | ||
404 | .trait_name = "connected_peers_map", | ||
405 | .ptr = (const void *) connected_peers_map, | ||
406 | }, | ||
407 | { | ||
408 | .index = 3, | ||
409 | .trait_name = "hello", | ||
410 | .ptr = (const void *) hello, | ||
411 | }, | ||
412 | { | ||
413 | .index = 4, | ||
414 | .trait_name = "hello_size", | ||
415 | .ptr = (const void *) hello_size, | ||
416 | }, | ||
417 | { | ||
418 | .index = 5, | ||
419 | .trait_name = "state", | ||
420 | .ptr = (const void *) sps, | ||
421 | }, | ||
422 | GNUNET_TESTING_trait_end () | ||
423 | }; | ||
424 | |||
425 | return GNUNET_TESTING_get_trait (traits, | ||
426 | ret, | ||
427 | trait, | ||
428 | index); | ||
429 | } | ||
430 | |||
431 | |||
432 | /** | ||
433 | * Function to get the trait with the struct StartPeerState_v2. | ||
434 | * | ||
435 | * @param[out] sps struct StartPeerState_v2. | ||
436 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
437 | * | ||
438 | */ | ||
439 | int | ||
440 | GNUNET_TRANSPORT_get_trait_state_v2 (const struct | ||
441 | GNUNET_TESTING_Command | ||
442 | *cmd, | ||
443 | struct StartPeerState_v2 **sps) | ||
444 | { | ||
445 | return cmd->traits (cmd->cls, | ||
446 | (const void **) sps, | ||
447 | "state", | ||
448 | (unsigned int) 5); | ||
449 | } | ||
450 | |||
451 | |||
452 | /** | ||
453 | * Function to get the trait with the size of the hello. | ||
454 | * | ||
455 | * @param[out] hello_size size of hello. | ||
456 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
457 | * | ||
458 | */ | ||
459 | int | ||
460 | GNUNET_TRANSPORT_get_trait_hello_size_v2 (const struct | ||
461 | GNUNET_TESTING_Command | ||
462 | *cmd, | ||
463 | size_t **hello_size) | ||
464 | { | ||
465 | return cmd->traits (cmd->cls, | ||
466 | (const void **) hello_size, | ||
467 | "hello_size", | ||
468 | (unsigned int) 4); | ||
469 | } | ||
470 | |||
471 | |||
472 | /** | ||
473 | * Function to get the trait with the hello. | ||
474 | * | ||
475 | * @param[out] hello The hello for the peer. | ||
476 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
477 | * | ||
478 | */ | ||
479 | int | ||
480 | GNUNET_TRANSPORT_get_trait_hello_v2 (const struct | ||
481 | GNUNET_TESTING_Command | ||
482 | *cmd, | ||
483 | char **hello) | ||
484 | { | ||
485 | return cmd->traits (cmd->cls, | ||
486 | (const void **) hello, | ||
487 | "hello", | ||
488 | (unsigned int) 3); | ||
489 | } | ||
490 | |||
491 | |||
492 | /** | ||
493 | * Function to get the trait with the map of connected peers. | ||
494 | * | ||
495 | * @param[out] connected_peers_map The map with connected peers. | ||
496 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
497 | * | ||
498 | */ | ||
499 | int | ||
500 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct | ||
501 | GNUNET_TESTING_Command | ||
502 | *cmd, | ||
503 | struct | ||
504 | GNUNET_CONTAINER_MultiShortmap | ||
505 | * | ||
506 | * | ||
507 | connected_peers_map) | ||
508 | { | ||
509 | return cmd->traits (cmd->cls, | ||
510 | (const void **) connected_peers_map, | ||
511 | "connected_peers_map", | ||
512 | (unsigned int) 2); | ||
513 | } | ||
514 | |||
515 | |||
516 | /** | ||
517 | * Function to get the trait with the transport application handle. | ||
518 | * | ||
519 | * @param[out] ah The application handle. | ||
520 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
521 | */ | ||
522 | int | ||
523 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct | ||
524 | GNUNET_TESTING_Command *cmd, | ||
525 | struct | ||
526 | GNUNET_TRANSPORT_ApplicationHandle | ||
527 | **ah) | ||
528 | { | ||
529 | return cmd->traits (cmd->cls, | ||
530 | (const void **) ah, | ||
531 | "application_handle", | ||
532 | (unsigned int) 0); | ||
533 | } | ||
534 | |||
535 | |||
536 | /** | ||
537 | * Function to get the trait with the peer id. | ||
538 | * | ||
539 | * @param[out] id The peer id. | ||
540 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
541 | */ | ||
542 | int | ||
543 | GNUNET_TRANSPORT_get_trait_peer_id_v2 (const struct | ||
544 | GNUNET_TESTING_Command *cmd, | ||
545 | struct GNUNET_PeerIdentity **id) | ||
546 | { | ||
547 | return cmd->traits (cmd->cls, | ||
548 | (const void **) id, | ||
549 | "peer_id", | ||
550 | (unsigned int) 1); | ||
551 | } | ||
552 | |||
553 | |||
554 | /** | ||
555 | * Create command. | ||
556 | * | ||
557 | * @param label name for command. | ||
558 | * @param system_label Label of the cmd to setup a test environment. | ||
559 | * @param m The number of the local node of the actual network namespace. | ||
560 | * @param n The number of the actual namespace. | ||
561 | * @param local_m Number of local nodes in each namespace. | ||
562 | * @param handlers Handler for messages received by this peer. | ||
563 | * @param cfgname Configuration file name for this peer. | ||
564 | * @return command. | ||
565 | */ | ||
566 | struct GNUNET_TESTING_Command | ||
567 | GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label, | ||
568 | const char *system_label, | ||
569 | uint32_t no, | ||
570 | char *node_ip, | ||
571 | struct GNUNET_MQ_MessageHandler *handlers, | ||
572 | const char *cfgname) | ||
573 | { | ||
574 | struct StartPeerState_v2 *sps; | ||
575 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
576 | GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | ||
577 | unsigned int i; | ||
578 | |||
579 | sps = GNUNET_new (struct StartPeerState_v2); | ||
580 | sps->no = no; | ||
581 | sps->system_label = system_label; | ||
582 | sps->connected_peers_map = connected_peers_map; | ||
583 | sps->cfgname = cfgname; | ||
584 | sps->node_ip = node_ip; | ||
585 | |||
586 | if (NULL != handlers) | ||
587 | { | ||
588 | for (i = 0; NULL != handlers[i].cb; i++) | ||
589 | ; | ||
590 | sps->handlers = GNUNET_new_array (i + 1, | ||
591 | struct GNUNET_MQ_MessageHandler); | ||
592 | GNUNET_memcpy (sps->handlers, | ||
593 | handlers, | ||
594 | i * sizeof(struct GNUNET_MQ_MessageHandler)); | ||
595 | } | ||
596 | |||
597 | struct GNUNET_TESTING_Command cmd = { | ||
598 | .cls = sps, | ||
599 | .label = label, | ||
600 | .run = &start_peer_run, | ||
601 | .finish = &start_peer_finish, | ||
602 | .cleanup = &start_peer_cleanup, | ||
603 | .traits = &start_peer_traits | ||
604 | }; | ||
605 | |||
606 | return cmd; | ||
607 | } | ||
diff --git a/src/transport/transport_api_cmd_start_peer_v3.c b/src/transport/transport_api_cmd_start_peer_v3.c deleted file mode 100644 index b5cefecc8..000000000 --- a/src/transport/transport_api_cmd_start_peer_v3.c +++ /dev/null | |||
@@ -1,619 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_peerstore_service.h" | ||
30 | #include "gnunet_transport_core_service.h" | ||
31 | #include "gnunet_transport_application_service.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | static void | ||
41 | retrieve_hello (void *cls); | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Callback delivering the hello of this peer from peerstore. | ||
46 | * | ||
47 | */ | ||
48 | static void | ||
49 | hello_iter_cb (void *cb_cls, | ||
50 | const struct GNUNET_PEERSTORE_Record *record, | ||
51 | const char *emsg) | ||
52 | { | ||
53 | struct StartPeerState_v2 *sps = cb_cls; | ||
54 | if (NULL == record) | ||
55 | { | ||
56 | sps->pic = NULL; | ||
57 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
58 | return; | ||
59 | } | ||
60 | // Check record type et al? | ||
61 | sps->hello_size = record->value_size; | ||
62 | sps->hello = GNUNET_malloc (sps->hello_size); | ||
63 | memcpy (sps->hello, record->value, sps->hello_size); | ||
64 | sps->hello[sps->hello_size - 1] = '\0'; | ||
65 | |||
66 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | ||
67 | sps->pic = NULL; | ||
68 | sps->finished = GNUNET_YES; | ||
69 | } | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Function to start the retrieval task to retrieve the hello of this peer | ||
74 | * from the peerstore. | ||
75 | * | ||
76 | */ | ||
77 | static void | ||
78 | retrieve_hello (void *cls) | ||
79 | { | ||
80 | struct StartPeerState_v2 *sps = cls; | ||
81 | sps->rh_task = NULL; | ||
82 | sps->pic = GNUNET_PEERSTORE_iterate (sps->ph, | ||
83 | "transport", | ||
84 | &sps->id, | ||
85 | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, | ||
86 | hello_iter_cb, | ||
87 | sps); | ||
88 | |||
89 | } | ||
90 | |||
91 | |||
92 | /** | ||
93 | * This function checks StartPeerState_v2#finished, which is set when the hello was retrieved. | ||
94 | * | ||
95 | */ | ||
96 | static int | ||
97 | start_peer_finish (void *cls, | ||
98 | GNUNET_SCHEDULER_TaskCallback cont, | ||
99 | void *cont_cls) | ||
100 | { | ||
101 | struct StartPeerState_v2 *sps = cls; | ||
102 | |||
103 | if (GNUNET_YES == sps->finished) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return sps->finished; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Disconnect callback for the connection to the core service. | ||
114 | * | ||
115 | */ | ||
116 | static void | ||
117 | notify_disconnect (void *cls, | ||
118 | const struct GNUNET_PeerIdentity *peer, | ||
119 | void *handler_cls) | ||
120 | { | ||
121 | struct StartPeerState_v2 *sps = cls; | ||
122 | |||
123 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
124 | "Peer %s disconnected from peer %u (`%s')\n", | ||
125 | GNUNET_i2s (peer), | ||
126 | sps->no, | ||
127 | GNUNET_i2s (&sps->id)); | ||
128 | |||
129 | } | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Connect callback for the connection to the core service. | ||
134 | * | ||
135 | */ | ||
136 | static void * | ||
137 | notify_connect (void *cls, | ||
138 | const struct GNUNET_PeerIdentity *peer, | ||
139 | struct GNUNET_MQ_Handle *mq) | ||
140 | { | ||
141 | struct StartPeerState_v2 *sps = cls; | ||
142 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
143 | struct GNUNET_HashCode hc; | ||
144 | struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key; | ||
145 | |||
146 | void *ret = NULL; | ||
147 | |||
148 | |||
149 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
150 | "Peer %s connected to peer %u (`%s')\n", | ||
151 | GNUNET_i2s (peer), | ||
152 | sps->no, | ||
153 | GNUNET_i2s (&sps->id)); | ||
154 | |||
155 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); | ||
156 | |||
157 | |||
158 | memcpy (key, | ||
159 | &hc, | ||
160 | sizeof (*key)); | ||
161 | GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map, | ||
162 | key, | ||
163 | mq, | ||
164 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
165 | |||
166 | GNUNET_free (key); | ||
167 | // TODO what does the handler function need? | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | |||
172 | /** | ||
173 | * The run method of this cmd will start all services of a peer to test the transport service. | ||
174 | * | ||
175 | */ | ||
176 | static void | ||
177 | start_peer_run (void *cls, | ||
178 | const struct GNUNET_TESTING_Command *cmd, | ||
179 | struct GNUNET_TESTING_Interpreter *is) | ||
180 | { | ||
181 | struct StartPeerState_v2 *sps = cls; | ||
182 | char *emsg = NULL; | ||
183 | struct GNUNET_PeerIdentity dummy; | ||
184 | const struct GNUNET_TESTING_Command *system_cmd; | ||
185 | struct GNUNET_TESTING_System *tl_system; | ||
186 | char *home; | ||
187 | char *transport_unix_path; | ||
188 | char *tcp_communicator_unix_path; | ||
189 | char *udp_communicator_unix_path; | ||
190 | char *bindto; | ||
191 | |||
192 | if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) | ||
193 | { | ||
194 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
195 | "File not found: `%s'\n", | ||
196 | sps->cfgname); | ||
197 | GNUNET_TESTING_interpreter_fail (); | ||
198 | return; | ||
199 | } | ||
200 | |||
201 | |||
202 | sps->cfg = GNUNET_CONFIGURATION_create (); | ||
203 | GNUNET_assert (GNUNET_OK == | ||
204 | GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname)); | ||
205 | |||
206 | GNUNET_asprintf (&home, | ||
207 | "$GNUNET_TMP/test-transport/api-tcp-p%u", | ||
208 | sps->no); | ||
209 | |||
210 | GNUNET_asprintf (&transport_unix_path, | ||
211 | "$GNUNET_RUNTIME_DIR/tng-p%u.sock", | ||
212 | sps->no); | ||
213 | |||
214 | GNUNET_asprintf (&tcp_communicator_unix_path, | ||
215 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
216 | sps->no); | ||
217 | |||
218 | GNUNET_asprintf (&udp_communicator_unix_path, | ||
219 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
220 | sps->no); | ||
221 | |||
222 | GNUNET_asprintf (&bindto, | ||
223 | "%s:60002", | ||
224 | sps->node_ip); | ||
225 | |||
226 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
227 | "node_ip %s\n", | ||
228 | bindto); | ||
229 | |||
230 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", | ||
231 | home); | ||
232 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH", | ||
233 | transport_unix_path); | ||
234 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
235 | "BINDTO", | ||
236 | bindto); | ||
237 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
238 | "BINDTO", | ||
239 | bindto); | ||
240 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
241 | "UNIXPATH", | ||
242 | tcp_communicator_unix_path); | ||
243 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
244 | "UNIXPATH", | ||
245 | udp_communicator_unix_path); | ||
246 | |||
247 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label); | ||
248 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
249 | &tl_system); | ||
250 | |||
251 | sps->tl_system = tl_system; | ||
252 | |||
253 | if (GNUNET_SYSERR == | ||
254 | GNUNET_TESTING_configuration_create (tl_system, | ||
255 | sps->cfg)) | ||
256 | { | ||
257 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
258 | "Testing library failed to create unique configuration based on `%s'\n", | ||
259 | sps->cfgname); | ||
260 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
261 | GNUNET_TESTING_interpreter_fail (); | ||
262 | return; | ||
263 | } | ||
264 | |||
265 | sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system, | ||
266 | sps->cfg, | ||
267 | sps->no, | ||
268 | NULL, | ||
269 | &emsg); | ||
270 | if (NULL == sps->peer) | ||
271 | { | ||
272 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
273 | "Testing library failed to create unique configuration based on `%s': `%s'\n", | ||
274 | sps->cfgname, | ||
275 | emsg); | ||
276 | GNUNET_free (emsg); | ||
277 | GNUNET_TESTING_interpreter_fail (); | ||
278 | return; | ||
279 | } | ||
280 | |||
281 | if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer)) | ||
282 | { | ||
283 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
284 | "Testing library failed to create unique configuration based on `%s'\n", | ||
285 | sps->cfgname); | ||
286 | GNUNET_free (emsg); | ||
287 | GNUNET_TESTING_interpreter_fail (); | ||
288 | return; | ||
289 | } | ||
290 | |||
291 | memset (&dummy, | ||
292 | '\0', | ||
293 | sizeof(dummy)); | ||
294 | |||
295 | GNUNET_TESTING_peer_get_identity (sps->peer, | ||
296 | &sps->id); | ||
297 | |||
298 | if (0 == memcmp (&dummy, | ||
299 | &sps->id, | ||
300 | sizeof(struct GNUNET_PeerIdentity))) | ||
301 | { | ||
302 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
303 | "Testing library failed to obtain peer identity for peer %u\n", | ||
304 | sps->no); | ||
305 | GNUNET_free (emsg); | ||
306 | GNUNET_TESTING_interpreter_fail (); | ||
307 | return; | ||
308 | } | ||
309 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
310 | "Peer %u configured with identity `%s'\n", | ||
311 | sps->no, | ||
312 | GNUNET_i2s_full (&sps->id)); | ||
313 | |||
314 | sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg, | ||
315 | NULL, | ||
316 | sps->handlers, | ||
317 | sps, | ||
318 | ¬ify_connect, | ||
319 | ¬ify_disconnect); | ||
320 | if (NULL == sps->th) | ||
321 | { | ||
322 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
323 | "Failed to connect to transport service for peer `%s': `%s'\n", | ||
324 | sps->cfgname, | ||
325 | emsg); | ||
326 | GNUNET_free (emsg); | ||
327 | GNUNET_TESTING_interpreter_fail (); | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | sps->ph = GNUNET_PEERSTORE_connect (sps->cfg); | ||
332 | if (NULL == sps->th) | ||
333 | { | ||
334 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
335 | "Failed to connect to peerstore service for peer `%s': `%s'\n", | ||
336 | sps->cfgname, | ||
337 | emsg); | ||
338 | GNUNET_free (emsg); | ||
339 | GNUNET_TESTING_interpreter_fail (); | ||
340 | return; | ||
341 | } | ||
342 | |||
343 | sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg); | ||
344 | if (NULL == sps->ah) | ||
345 | { | ||
346 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
347 | "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n", | ||
348 | sps->cfgname, | ||
349 | emsg); | ||
350 | GNUNET_free (emsg); | ||
351 | GNUNET_TESTING_interpreter_fail (); | ||
352 | return; | ||
353 | } | ||
354 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
355 | } | ||
356 | |||
357 | |||
358 | /** | ||
359 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
360 | * | ||
361 | */ | ||
362 | static void | ||
363 | start_peer_cleanup (void *cls, | ||
364 | const struct GNUNET_TESTING_Command *cmd) | ||
365 | { | ||
366 | struct StartPeerState_v2 *sps = cls; | ||
367 | |||
368 | if (NULL != sps->handlers) | ||
369 | { | ||
370 | GNUNET_free (sps->handlers); | ||
371 | sps->handlers = NULL; | ||
372 | } | ||
373 | if (NULL != sps->cfg) | ||
374 | { | ||
375 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
376 | sps->cfg = NULL; | ||
377 | } | ||
378 | GNUNET_free (sps->hello); | ||
379 | GNUNET_free (sps->connected_peers_map); | ||
380 | GNUNET_free (sps); | ||
381 | } | ||
382 | |||
383 | |||
384 | /** | ||
385 | * This function prepares an array with traits. | ||
386 | * | ||
387 | */ | ||
388 | static int | ||
389 | start_peer_traits (void *cls, | ||
390 | const void **ret, | ||
391 | const char *trait, | ||
392 | unsigned int index) | ||
393 | { | ||
394 | struct StartPeerState_v2 *sps = cls; | ||
395 | struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; | ||
396 | struct GNUNET_PeerIdentity *id = &sps->id; | ||
397 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
398 | sps->connected_peers_map; | ||
399 | char *hello = sps->hello; | ||
400 | size_t hello_size = sps->hello_size; | ||
401 | |||
402 | |||
403 | struct GNUNET_TESTING_Trait traits[] = { | ||
404 | { | ||
405 | .index = 0, | ||
406 | .trait_name = "application_handle", | ||
407 | .ptr = (const void *) ah, | ||
408 | }, | ||
409 | { | ||
410 | .index = 1, | ||
411 | .trait_name = "peer_id", | ||
412 | .ptr = (const void *) id, | ||
413 | }, | ||
414 | { | ||
415 | .index = 2, | ||
416 | .trait_name = "connected_peers_map", | ||
417 | .ptr = (const void *) connected_peers_map, | ||
418 | }, | ||
419 | { | ||
420 | .index = 3, | ||
421 | .trait_name = "hello", | ||
422 | .ptr = (const void *) hello, | ||
423 | }, | ||
424 | { | ||
425 | .index = 4, | ||
426 | .trait_name = "hello_size", | ||
427 | .ptr = (const void *) hello_size, | ||
428 | }, | ||
429 | { | ||
430 | .index = 5, | ||
431 | .trait_name = "state", | ||
432 | .ptr = (const void *) sps, | ||
433 | }, | ||
434 | GNUNET_TESTING_trait_end () | ||
435 | }; | ||
436 | |||
437 | return GNUNET_TESTING_get_trait (traits, | ||
438 | ret, | ||
439 | trait, | ||
440 | index); | ||
441 | } | ||
442 | |||
443 | |||
444 | /** | ||
445 | * Function to get the trait with the struct StartPeerState_v2. | ||
446 | * | ||
447 | * @param[out] sps struct StartPeerState_v2. | ||
448 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
449 | * | ||
450 | */ | ||
451 | int | ||
452 | GNUNET_TRANSPORT_get_trait_state_v3 (const struct | ||
453 | GNUNET_TESTING_Command | ||
454 | *cmd, | ||
455 | struct StartPeerState_v2 **sps) | ||
456 | { | ||
457 | return cmd->traits (cmd->cls, | ||
458 | (const void **) sps, | ||
459 | "state", | ||
460 | (unsigned int) 5); | ||
461 | } | ||
462 | |||
463 | |||
464 | /** | ||
465 | * Function to get the trait with the size of the hello. | ||
466 | * | ||
467 | * @param[out] hello_size size of hello. | ||
468 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
469 | * | ||
470 | */ | ||
471 | int | ||
472 | GNUNET_TRANSPORT_get_trait_hello_size_v3 (const struct | ||
473 | GNUNET_TESTING_Command | ||
474 | *cmd, | ||
475 | size_t **hello_size) | ||
476 | { | ||
477 | return cmd->traits (cmd->cls, | ||
478 | (const void **) hello_size, | ||
479 | "hello_size", | ||
480 | (unsigned int) 4); | ||
481 | } | ||
482 | |||
483 | |||
484 | /** | ||
485 | * Function to get the trait with the hello. | ||
486 | * | ||
487 | * @param[out] hello The hello for the peer. | ||
488 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
489 | * | ||
490 | */ | ||
491 | int | ||
492 | GNUNET_TRANSPORT_get_trait_hello_v3 (const struct | ||
493 | GNUNET_TESTING_Command | ||
494 | *cmd, | ||
495 | char **hello) | ||
496 | { | ||
497 | return cmd->traits (cmd->cls, | ||
498 | (const void **) hello, | ||
499 | "hello", | ||
500 | (unsigned int) 3); | ||
501 | } | ||
502 | |||
503 | |||
504 | /** | ||
505 | * Function to get the trait with the map of connected peers. | ||
506 | * | ||
507 | * @param[out] connected_peers_map The map with connected peers. | ||
508 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
509 | * | ||
510 | */ | ||
511 | int | ||
512 | GNUNET_TRANSPORT_get_trait_connected_peers_map_v3 (const struct | ||
513 | GNUNET_TESTING_Command | ||
514 | *cmd, | ||
515 | struct | ||
516 | GNUNET_CONTAINER_MultiShortmap | ||
517 | * | ||
518 | * | ||
519 | connected_peers_map) | ||
520 | { | ||
521 | return cmd->traits (cmd->cls, | ||
522 | (const void **) connected_peers_map, | ||
523 | "connected_peers_map", | ||
524 | (unsigned int) 2); | ||
525 | } | ||
526 | |||
527 | |||
528 | /** | ||
529 | * Function to get the trait with the transport application handle. | ||
530 | * | ||
531 | * @param[out] ah The application handle. | ||
532 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
533 | */ | ||
534 | int | ||
535 | GNUNET_TRANSPORT_get_trait_application_handle_v3 (const struct | ||
536 | GNUNET_TESTING_Command *cmd, | ||
537 | struct | ||
538 | GNUNET_TRANSPORT_ApplicationHandle | ||
539 | **ah) | ||
540 | { | ||
541 | return cmd->traits (cmd->cls, | ||
542 | (const void **) ah, | ||
543 | "application_handle", | ||
544 | (unsigned int) 0); | ||
545 | } | ||
546 | |||
547 | |||
548 | /** | ||
549 | * Function to get the trait with the peer id. | ||
550 | * | ||
551 | * @param[out] id The peer id. | ||
552 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
553 | */ | ||
554 | int | ||
555 | GNUNET_TRANSPORT_get_trait_peer_id_v3 (const struct | ||
556 | GNUNET_TESTING_Command *cmd, | ||
557 | struct GNUNET_PeerIdentity **id) | ||
558 | { | ||
559 | return cmd->traits (cmd->cls, | ||
560 | (const void **) id, | ||
561 | "peer_id", | ||
562 | (unsigned int) 1); | ||
563 | } | ||
564 | |||
565 | |||
566 | /** | ||
567 | * Create command. | ||
568 | * | ||
569 | * @param label name for command. | ||
570 | * @param system_label Label of the cmd to setup a test environment. | ||
571 | * @param m The number of the local node of the actual network namespace. | ||
572 | * @param n The number of the actual namespace. | ||
573 | * @param local_m Number of local nodes in each namespace. | ||
574 | * @param handlers Handler for messages received by this peer. | ||
575 | * @param cfgname Configuration file name for this peer. | ||
576 | * @return command. | ||
577 | */ | ||
578 | struct GNUNET_TESTING_Command | ||
579 | GNUNET_TRANSPORT_cmd_start_peer_v3 (const char *label, | ||
580 | const char *system_label, | ||
581 | uint32_t no, | ||
582 | char *node_ip, | ||
583 | struct GNUNET_MQ_MessageHandler *handlers, | ||
584 | const char *cfgname) | ||
585 | { | ||
586 | struct StartPeerState_v2 *sps; | ||
587 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
588 | GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | ||
589 | unsigned int i; | ||
590 | |||
591 | sps = GNUNET_new (struct StartPeerState_v2); | ||
592 | sps->no = no; | ||
593 | sps->system_label = system_label; | ||
594 | sps->connected_peers_map = connected_peers_map; | ||
595 | sps->cfgname = cfgname; | ||
596 | sps->node_ip = node_ip; | ||
597 | |||
598 | if (NULL != handlers) | ||
599 | { | ||
600 | for (i = 0; NULL != handlers[i].cb; i++) | ||
601 | ; | ||
602 | sps->handlers = GNUNET_new_array (i + 1, | ||
603 | struct GNUNET_MQ_MessageHandler); | ||
604 | GNUNET_memcpy (sps->handlers, | ||
605 | handlers, | ||
606 | i * sizeof(struct GNUNET_MQ_MessageHandler)); | ||
607 | } | ||
608 | |||
609 | struct GNUNET_TESTING_Command cmd = { | ||
610 | .cls = sps, | ||
611 | .label = label, | ||
612 | .run = &start_peer_run, | ||
613 | .finish = &start_peer_finish, | ||
614 | .cleanup = &start_peer_cleanup, | ||
615 | .traits = &start_peer_traits | ||
616 | }; | ||
617 | |||
618 | return cmd; | ||
619 | } | ||
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c index 4d7228378..dcb982a65 100644 --- a/src/transport/transport_api_cmd_stop_peer.c +++ b/src/transport/transport_api_cmd_stop_peer.c | |||
@@ -54,14 +54,14 @@ struct StopPeerState | |||
54 | */ | 54 | */ |
55 | static void | 55 | static void |
56 | stop_peer_run (void *cls, | 56 | stop_peer_run (void *cls, |
57 | const struct GNUNET_TESTING_Command *cmd, | ||
58 | struct GNUNET_TESTING_Interpreter *is) | 57 | struct GNUNET_TESTING_Interpreter *is) |
59 | { | 58 | { |
60 | struct StopPeerState *stop_ps = cls; | 59 | struct StopPeerState *stop_ps = cls; |
61 | struct StartPeerState *sps; | 60 | struct StartPeerState *sps; |
62 | const struct GNUNET_TESTING_Command *start_cmd; | 61 | const struct GNUNET_TESTING_Command *start_cmd; |
63 | 62 | ||
64 | start_cmd = GNUNET_TESTING_interpreter_lookup_command (stop_ps->start_label); | 63 | start_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
64 | stop_ps->start_label); | ||
65 | GNUNET_TRANSPORT_get_trait_state (start_cmd, | 65 | GNUNET_TRANSPORT_get_trait_state (start_cmd, |
66 | &sps); | 66 | &sps); |
67 | 67 | ||
@@ -112,8 +112,7 @@ stop_peer_run (void *cls, | |||
112 | * | 112 | * |
113 | */ | 113 | */ |
114 | static void | 114 | static void |
115 | stop_peer_cleanup (void *cls, | 115 | stop_peer_cleanup (void *cls) |
116 | const struct GNUNET_TESTING_Command *cmd) | ||
117 | { | 116 | { |
118 | struct StopPeerState *sps = cls; | 117 | struct StopPeerState *sps = cls; |
119 | 118 | ||
@@ -150,14 +149,14 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label, | |||
150 | 149 | ||
151 | sps = GNUNET_new (struct StopPeerState); | 150 | sps = GNUNET_new (struct StopPeerState); |
152 | sps->start_label = start_label; | 151 | sps->start_label = start_label; |
153 | 152 | { | |
154 | struct GNUNET_TESTING_Command cmd = { | 153 | struct GNUNET_TESTING_Command cmd = { |
155 | .cls = sps, | 154 | .cls = sps, |
156 | .label = label, | 155 | .label = label, |
157 | .run = &stop_peer_run, | 156 | .run = &stop_peer_run, |
158 | .cleanup = &stop_peer_cleanup, | 157 | .cleanup = &stop_peer_cleanup, |
159 | .traits = &stop_peer_traits | 158 | .traits = &stop_peer_traits |
160 | }; | 159 | }; |
161 | 160 | return cmd; | |
162 | return cmd; | 161 | } |
163 | } | 162 | } |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index a3a77073e..c3a0feccc 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -145,10 +145,8 @@ libgnunetutil_la_LDFLAGS = \ | |||
145 | $(GN_LIB_LDFLAGS) \ | 145 | $(GN_LIB_LDFLAGS) \ |
146 | -version-info 14:0:0 | 146 | -version-info 14:0:0 |
147 | 147 | ||
148 | if HAVE_TESTING | 148 | GNUNET_ECC = gnunet-ecc |
149 | GNUNET_ECC = gnunet-ecc | 149 | GNUNET_SCRYPT = gnunet-scrypt |
150 | GNUNET_SCRYPT = gnunet-scrypt | ||
151 | endif | ||
152 | 150 | ||
153 | lib_LTLIBRARIES = libgnunetutil.la | 151 | lib_LTLIBRARIES = libgnunetutil.la |
154 | 152 | ||
diff --git a/src/util/child_management.c b/src/util/child_management.c index 3afd682b9..832e05ece 100644 --- a/src/util/child_management.c +++ b/src/util/child_management.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testing/child_management.c | 22 | * @file util/child_management.c |
23 | * @brief Handling of child processes in GNUnet. | 23 | * @brief Handling of child processes in GNUnet. |
24 | * @author Christian Grothoff (ANASTASIS) | 24 | * @author Christian Grothoff (ANASTASIS) |
25 | * @author Dominik Meister (ANASTASIS) | 25 | * @author Dominik Meister (ANASTASIS) |
@@ -91,15 +91,10 @@ maint_child_death (void *cls) | |||
91 | 91 | ||
92 | (void) cls; | 92 | (void) cls; |
93 | sig_task = NULL; | 93 | sig_task = NULL; |
94 | |||
95 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
96 | "Received SIGCHLD.\n"); | ||
97 | |||
98 | /* drain pipe */ | 94 | /* drain pipe */ |
99 | pr = GNUNET_DISK_pipe_handle (sigpipe, | 95 | pr = GNUNET_DISK_pipe_handle (sigpipe, |
100 | GNUNET_DISK_PIPE_END_READ); | 96 | GNUNET_DISK_PIPE_END_READ); |
101 | GNUNET_assert (! GNUNET_DISK_handle_invalid (pr)); | 97 | GNUNET_assert (! GNUNET_DISK_handle_invalid (pr)); |
102 | |||
103 | (void) GNUNET_DISK_file_read (pr, | 98 | (void) GNUNET_DISK_file_read (pr, |
104 | buf, | 99 | buf, |
105 | sizeof(buf)); | 100 | sizeof(buf)); |
@@ -158,10 +153,11 @@ sighandler_child_death (void) | |||
158 | errno = old_errno; /* restore errno */ | 153 | errno = old_errno; /* restore errno */ |
159 | } | 154 | } |
160 | 155 | ||
161 | 156 | /** | |
162 | // void __attribute__ ((constructor)) | 157 | * Initializing the signal pipe for child handling. |
158 | */ | ||
163 | static void | 159 | static void |
164 | child_management_start () | 160 | child_management_start (void) |
165 | { | 161 | { |
166 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
167 | "Trying to start child management.\n"); | 163 | "Trying to start child management.\n"); |
@@ -170,19 +166,24 @@ child_management_start () | |||
170 | sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); | 166 | sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); |
171 | GNUNET_assert (sigpipe != NULL); | 167 | GNUNET_assert (sigpipe != NULL); |
172 | shc_chld = | 168 | shc_chld = |
173 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | 169 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, |
170 | &sighandler_child_death); | ||
174 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 171 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
175 | "Child management started.\n"); | 172 | "Child management started.\n"); |
176 | } | 173 | } |
177 | 174 | ||
175 | |||
178 | /** | 176 | /** |
179 | * Clean up. | 177 | * Clean up. |
180 | */ | 178 | */ |
181 | // void __attribute__ ((destructor)) | ||
182 | static void | 179 | static void |
183 | child_management_done () | 180 | child_management_done (void) |
184 | { | 181 | { |
185 | GNUNET_assert (NULL == sig_task); | 182 | if (NULL != sig_task) |
183 | { | ||
184 | GNUNET_SCHEDULER_cancel (sig_task); | ||
185 | sig_task = NULL; | ||
186 | } | ||
186 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | 187 | GNUNET_SIGNAL_handler_uninstall (shc_chld); |
187 | shc_chld = NULL; | 188 | shc_chld = NULL; |
188 | GNUNET_DISK_pipe_close (sigpipe); | 189 | GNUNET_DISK_pipe_close (sigpipe); |
@@ -191,6 +192,15 @@ child_management_done () | |||
191 | "Child management stopped.\n"); | 192 | "Child management stopped.\n"); |
192 | } | 193 | } |
193 | 194 | ||
195 | |||
196 | /** | ||
197 | * Adding a child process to be monitored by the child management. | ||
198 | * | ||
199 | * @param proc The child process to be monitored. | ||
200 | * @param cp The callback to be called, when the child process completed. | ||
201 | * @param cb_cls The closure for the callback. | ||
202 | * @return An handle for the the child being monitored. | ||
203 | */ | ||
194 | struct GNUNET_ChildWaitHandle * | 204 | struct GNUNET_ChildWaitHandle * |
195 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, | 205 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, |
196 | GNUNET_ChildCompletedCallback cb, | 206 | GNUNET_ChildCompletedCallback cb, |
@@ -198,9 +208,6 @@ GNUNET_wait_child (struct GNUNET_OS_Process *proc, | |||
198 | { | 208 | { |
199 | struct GNUNET_ChildWaitHandle *cwh; | 209 | struct GNUNET_ChildWaitHandle *cwh; |
200 | 210 | ||
201 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
202 | "Adding child!\n"); | ||
203 | |||
204 | child_management_start (); | 211 | child_management_start (); |
205 | cwh = GNUNET_new (struct GNUNET_ChildWaitHandle); | 212 | cwh = GNUNET_new (struct GNUNET_ChildWaitHandle); |
206 | cwh->proc = proc; | 213 | cwh->proc = proc; |
@@ -221,23 +228,20 @@ GNUNET_wait_child (struct GNUNET_OS_Process *proc, | |||
221 | return cwh; | 228 | return cwh; |
222 | } | 229 | } |
223 | 230 | ||
231 | |||
232 | /** | ||
233 | * Removing child handle. | ||
234 | * | ||
235 | * @param cwh The handle to be removed. | ||
236 | */ | ||
224 | void | 237 | void |
225 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) | 238 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) |
226 | { | 239 | { |
227 | if ((NULL != cwh_head)) | 240 | GNUNET_CONTAINER_DLL_remove (cwh_head, |
228 | { | 241 | cwh_tail, |
229 | GNUNET_CONTAINER_DLL_remove (cwh_head, | 242 | cwh); |
230 | cwh_tail, | ||
231 | cwh); | ||
232 | } | ||
233 | if (NULL == cwh_head) | ||
234 | { | ||
235 | child_management_done (); | ||
236 | } | ||
237 | if (NULL != sig_task) | ||
238 | { | ||
239 | GNUNET_SCHEDULER_cancel (sig_task); | ||
240 | sig_task = NULL; | ||
241 | } | ||
242 | GNUNET_free (cwh); | 243 | GNUNET_free (cwh); |
244 | if (NULL != cwh_head) | ||
245 | return; | ||
246 | child_management_done (); | ||
243 | } | 247 | } |
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 308488131..f48f87167 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -42,13 +42,6 @@ | |||
42 | #define INT_MAX 0x7FFFFFFF | 42 | #define INT_MAX 0x7FFFFFFF |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #if 0 | ||
46 | #define W32_MEM_LIMIT 200000000 | ||
47 | #endif | ||
48 | |||
49 | #ifdef W32_MEM_LIMIT | ||
50 | static LONG mem_used = 0; | ||
51 | #endif | ||
52 | 45 | ||
53 | /** | 46 | /** |
54 | * Allocate memory. Checks the return value, aborts if no more | 47 | * Allocate memory. Checks the return value, aborts if no more |
@@ -184,11 +177,6 @@ GNUNET_xmemdup_ (const void *buf, | |||
184 | /* As a security precaution, we generally do not allow very large | 177 | /* As a security precaution, we generally do not allow very large |
185 | * allocations here */ | 178 | * allocations here */ |
186 | GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber); | 179 | GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber); |
187 | #ifdef W32_MEM_LIMIT | ||
188 | size += sizeof(size_t); | ||
189 | if (mem_used + size > W32_MEM_LIMIT) | ||
190 | return NULL; | ||
191 | #endif | ||
192 | GNUNET_assert_at (size < INT_MAX, filename, linenumber); | 180 | GNUNET_assert_at (size < INT_MAX, filename, linenumber); |
193 | ret = malloc (size); | 181 | ret = malloc (size); |
194 | if (ret == NULL) | 182 | if (ret == NULL) |
@@ -196,11 +184,6 @@ GNUNET_xmemdup_ (const void *buf, | |||
196 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); | 184 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); |
197 | GNUNET_assert (0); | 185 | GNUNET_assert (0); |
198 | } | 186 | } |
199 | #ifdef W32_MEM_LIMIT | ||
200 | *((size_t *) ret) = size; | ||
201 | ret = &((size_t *) ret)[1]; | ||
202 | mem_used += size; | ||
203 | #endif | ||
204 | GNUNET_memcpy (ret, buf, size); | 187 | GNUNET_memcpy (ret, buf, size); |
205 | return ret; | 188 | return ret; |
206 | } | 189 | } |
@@ -222,23 +205,12 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber) | |||
222 | 205 | ||
223 | (void) filename; | 206 | (void) filename; |
224 | (void) linenumber; | 207 | (void) linenumber; |
225 | #ifdef W32_MEM_LIMIT | ||
226 | size += sizeof(size_t); | ||
227 | if (mem_used + size > W32_MEM_LIMIT) | ||
228 | return NULL; | ||
229 | #endif | ||
230 | 208 | ||
231 | result = malloc (size); | 209 | result = malloc (size); |
232 | if (NULL == result) | 210 | if (NULL == result) |
233 | return NULL; | 211 | return NULL; |
234 | memset (result, 0, size); | 212 | memset (result, 0, size); |
235 | 213 | ||
236 | #ifdef W32_MEM_LIMIT | ||
237 | *((size_t *) result) = size; | ||
238 | result = &((size_t *) result)[1]; | ||
239 | mem_used += size; | ||
240 | #endif | ||
241 | |||
242 | return result; | 214 | return result; |
243 | } | 215 | } |
244 | 216 | ||
@@ -260,11 +232,6 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) | |||
260 | (void) filename; | 232 | (void) filename; |
261 | (void) linenumber; | 233 | (void) linenumber; |
262 | 234 | ||
263 | #ifdef W32_MEM_LIMIT | ||
264 | n += sizeof(size_t); | ||
265 | ptr = &((size_t *) ptr)[-1]; | ||
266 | mem_used = mem_used - *((size_t *) ptr) + n; | ||
267 | #endif | ||
268 | #if defined(M_SIZE) | 235 | #if defined(M_SIZE) |
269 | #if ENABLE_POISONING | 236 | #if ENABLE_POISONING |
270 | { | 237 | { |
@@ -295,9 +262,6 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) | |||
295 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); | 262 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); |
296 | GNUNET_assert (0); | 263 | GNUNET_assert (0); |
297 | } | 264 | } |
298 | #ifdef W32_MEM_LIMIT | ||
299 | ptr = &((size_t *) ptr)[1]; | ||
300 | #endif | ||
301 | return ptr; | 265 | return ptr; |
302 | } | 266 | } |
303 | 267 | ||
@@ -333,10 +297,6 @@ GNUNET_xfree_ (void *ptr, | |||
333 | { | 297 | { |
334 | if (NULL == ptr) | 298 | if (NULL == ptr) |
335 | return; | 299 | return; |
336 | #ifdef W32_MEM_LIMIT | ||
337 | ptr = &((size_t *) ptr)[-1]; | ||
338 | mem_used -= *((size_t *) ptr); | ||
339 | #endif | ||
340 | #if defined(M_SIZE) | 300 | #if defined(M_SIZE) |
341 | #if ENABLE_POISONING | 301 | #if ENABLE_POISONING |
342 | { | 302 | { |