summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2024-01-10 11:49:15 +0100
committert3sserakt <t3ss@posteo.de>2024-01-10 11:49:15 +0100
commit29213833fc4681761d3e9aadd74603909abfb1cd (patch)
tree6571990b92df82e2563cd5ca223932db3a590da4
parent01b7a5d0ab3ee3029c0a5b064f8ee9e6f7f78ac7 (diff)
parent577ad2f7d2be48b86d3d6084f344244efcc04f7c (diff)
Merge branch 'master' of ssh://git.gnunet.org/gnunetv0.21.0-talerdev.4
-rw-r--r--.gitignore5
-rwxr-xr-xbootstrap5
-rw-r--r--configure.ac1
m---------contrib/gana0
m---------contrib/handbook0
-rw-r--r--doc/man/Makefile.am3
-rw-r--r--doc/man/gnunet-ats.1114
-rw-r--r--doc/man/gnunet-peerinfo.199
-rw-r--r--doc/man/gnunet-testbed-profiler.189
-rw-r--r--doc/man/meson.build3
-rw-r--r--meson-dist-script18
-rw-r--r--meson.build69
-rw-r--r--pkgconfig/Makefile.am2
-rw-r--r--pkgconfig/gnunetreclaim.pc.in12
-rw-r--r--po/POTFILES.in10
-rwxr-xr-xscripts/gana_update.sh43
-rw-r--r--src/cli/gns/meson.build6
-rw-r--r--src/cli/gns/openssl.cnf2
-rwxr-xr-xsrc/cli/gns/test_gns_sbox.sh2
-rw-r--r--src/contrib/cli/template/meson.build3
-rw-r--r--src/contrib/service/conversation/meson.build23
-rw-r--r--src/contrib/service/conversation/plugin_gnsrecord_conversation.c2
-rw-r--r--src/contrib/service/rps/Makefile.am18
-rw-r--r--src/contrib/service/rps/gnunet-rps-profiler.c3199
-rw-r--r--src/contrib/service/secretsharing/Makefile.am13
-rw-r--r--src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c662
-rw-r--r--src/contrib/service/set/Makefile.am13
-rw-r--r--src/contrib/service/set/gnunet-set-profiler.c508
-rw-r--r--src/contrib/service/template/meson.build6
-rw-r--r--src/include/Makefile.am3
-rw-r--r--src/include/gnu_name_system_service_ports.h6
-rw-r--r--src/include/gnunet_messenger_service.h38
-rw-r--r--src/include/gnunet_peerinfo_service.h214
-rw-r--r--src/include/gnunet_pq_lib.h2
-rw-r--r--src/include/gnunet_strings_lib.h8
-rw-r--r--src/include/gnunet_testbed_logger_service.h139
-rw-r--r--src/include/gnunet_testbed_service.h1735
-rw-r--r--src/include/meson.build3
-rw-r--r--src/include/platform.h4
-rw-r--r--src/lib/hello/hello-uri.c4
-rw-r--r--src/lib/json/json_generator.c6
-rw-r--r--src/lib/json/json_helper.c9
-rw-r--r--src/lib/pq/Makefile.am2
-rw-r--r--src/lib/pq/pq_event.c2
-rw-r--r--src/lib/util/Makefile.am2
-rw-r--r--src/lib/util/common_logging.c70
-rw-r--r--src/lib/util/dnsparser.c5
-rw-r--r--src/lib/util/gnunet_error_codes.c1
-rw-r--r--src/lib/util/strings.c419
-rw-r--r--src/lib/util/test_strings.c8
-rw-r--r--src/plugin/gns/plugin_gnsrecord_gns.c1
-rw-r--r--src/plugin/messenger/plugin_gnsrecord_messenger.c6
-rw-r--r--src/plugin/reclaim/pabc_helper.c16
-rw-r--r--src/service/cadet/cadet_test_lib.c376
-rw-r--r--src/service/cadet/cadet_test_lib.h106
-rw-r--r--src/service/core/meson.build3
-rw-r--r--src/service/dht/dht_test_lib.c202
-rw-r--r--src/service/dht/dht_test_lib.h95
-rw-r--r--src/service/dht/test_dht_monitor.c439
-rw-r--r--src/service/dht/test_dht_monitor.conf39
-rw-r--r--src/service/dht/test_dht_topo.c637
-rw-r--r--src/service/dns/meson.build7
-rw-r--r--src/service/fs/Makefile.am9
-rw-r--r--src/service/fs/fs_test_lib.c630
-rw-r--r--src/service/fs/fs_test_lib.h102
-rw-r--r--src/service/fs/fs_test_lib_data.conf17
-rw-r--r--src/service/messenger/Makefile.am1
-rw-r--r--src/service/messenger/gnunet-service-messenger.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_basement.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_handle.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_list_handles.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_list_handles.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_list_messages.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_list_messages.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_member_session.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_member_session.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_member_store.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_handle.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_handle.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_kind.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_kind.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_recv.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_recv.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_send.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_send.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_state.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_state.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_store.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_message_store.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_operation.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_operation.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_operation_store.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_room.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_sender_session.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_service.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_service.h1
-rw-r--r--src/service/messenger/gnunet-service-messenger_tunnel.c1
-rw-r--r--src/service/messenger/gnunet-service-messenger_tunnel.h1
-rw-r--r--src/service/messenger/messenger-testing-cmds.h1
-rw-r--r--src/service/messenger/messenger-testing.c1
-rw-r--r--src/service/messenger/messenger-testing.h1
-rw-r--r--src/service/messenger/messenger_api.c160
-rw-r--r--src/service/messenger/messenger_api_cmd_join_room.c2
-rw-r--r--src/service/messenger/messenger_api_cmd_start_service.c2
-rw-r--r--src/service/messenger/messenger_api_cmd_stop_service.c2
-rw-r--r--src/service/messenger/messenger_api_contact.c1
-rw-r--r--src/service/messenger/messenger_api_contact.h1
-rw-r--r--src/service/messenger/messenger_api_contact_store.c1
-rw-r--r--src/service/messenger/messenger_api_contact_store.h1
-rw-r--r--src/service/messenger/messenger_api_handle.c1
-rw-r--r--src/service/messenger/messenger_api_handle.h1
-rw-r--r--src/service/messenger/messenger_api_list_tunnels.c3
-rw-r--r--src/service/messenger/messenger_api_list_tunnels.h1
-rw-r--r--src/service/messenger/messenger_api_message.c50
-rw-r--r--src/service/messenger/messenger_api_message.h1
-rw-r--r--src/service/messenger/messenger_api_message_kind.c19
-rw-r--r--src/service/messenger/messenger_api_message_kind.h17
-rw-r--r--src/service/messenger/messenger_api_peer_store.c1
-rw-r--r--src/service/messenger/messenger_api_peer_store.h1
-rw-r--r--src/service/messenger/messenger_api_queue_messages.h1
-rw-r--r--src/service/messenger/messenger_api_room.c1
-rw-r--r--src/service/messenger/messenger_api_room.h1
-rw-r--r--src/service/messenger/messenger_api_traits.c2
-rw-r--r--src/service/messenger/messenger_api_util.c1
-rw-r--r--src/service/messenger/messenger_api_util.h1
-rw-r--r--src/service/messenger/test_messenger.c2
-rw-r--r--src/service/messenger/test_messenger_anonymous.c2
-rw-r--r--src/service/messenger/test_messenger_plugin_cmd_simple_join.c1
-rw-r--r--src/service/nse/Makefile.am14
-rw-r--r--src/service/nse/gnunet-nse-profiler.c921
-rw-r--r--src/service/nse/hostkeys.datbin10389438 -> 0 bytes
-rw-r--r--src/service/regex/Makefile.am16
-rw-r--r--src/service/regex/gnunet-regex-simulation-profiler.c727
-rw-r--r--src/service/regex/regex_simulation_profiler_test.conf7
-rw-r--r--src/service/rest/openid_plugin.c18
-rw-r--r--src/service/seti/Makefile.am13
-rw-r--r--src/service/seti/gnunet-seti-profiler.c480
-rw-r--r--src/service/setu/Makefile.am13
-rw-r--r--src/service/setu/gnunet-setu-profiler.c499
140 files changed, 727 insertions, 12589 deletions
diff --git a/.gitignore b/.gitignore
index cfb634b8e..7f9d827c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,7 +80,12 @@ CMakeLists.txt
CMakeFiles.txt
# Prevent cache files from IDEA from being commited
+.cproject
+.project
+.settings/
.idea/
+.vscode/
+.vimrc
src/util/test_child_management
gnunet_config.h
gnunet_config.h.in
diff --git a/bootstrap b/bootstrap
index 1973f233a..d5bf30af4 100755
--- a/bootstrap
+++ b/bootstrap
@@ -96,8 +96,7 @@ submodules()
if ! git --version >/dev/null; then
echo "git not installed, skipping submodule update"
else
- git submodule update --init --recursive && \
- git submodule sync --recursive
+ git submodule update --init --force --remote
fi
}
@@ -131,7 +130,7 @@ main()
check_yapf
create_handbook
update_gana
- if [ "$@" = "meson" ]; then
+ if [ "$1" = "meson" ]; then
echo "Skipping autoreconf"
else
check_libtool
diff --git a/configure.ac b/configure.ac
index 8cc00d1de..43934319d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1380,6 +1380,7 @@ pkgconfig/gnunetnamestore.pc
pkgconfig/gnunetnat.pc
pkgconfig/gnunetnse.pc
pkgconfig/gnunetpq.pc
+pkgconfig/gnunetreclaim.pc
pkgconfig/gnunetregex.pc
pkgconfig/gnunetrevocation.pc
pkgconfig/gnunetrps.pc
diff --git a/contrib/gana b/contrib/gana
-Subproject 91e5fd6edb1b3567fd151960059ffb911973a44
+Subproject 9eddc2cf7b65bb43d285c75ef22fd9bc9cc7020
diff --git a/contrib/handbook b/contrib/handbook
-Subproject 5c20e0aaa95c7cebc225d02231221d18fdcbdb5
+Subproject e5b42badb7450aee5367e70294a0f8b1595945e
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 2dc433f49..6ab720826 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -38,7 +38,6 @@ endif
man_MANS = \
gnunet.conf.5 \
gnunet-arm.1 \
- gnunet-ats.1 \
gnunet-auto-share.1 \
gnunet-base32.1 \
gnunet-bcd.1 \
@@ -72,7 +71,6 @@ man_MANS = \
gnunet-nat-auto.1 \
gnunet-nat-server.1 \
gnunet-nse.1 \
- gnunet-peerinfo.1 \
gnunet-publish.1 \
gnunet-qr.1 \
gnunet-reclaim.1 \
@@ -82,7 +80,6 @@ man_MANS = \
gnunet-scrypt.1 \
gnunet-search.1 \
gnunet-statistics.1 \
- gnunet-testbed-profiler.1 \
gnunet-testing.1 \
gnunet-testing-run-service.1 \
gnunet-timeout.1 \
diff --git a/doc/man/gnunet-ats.1 b/doc/man/gnunet-ats.1
deleted file mode 100644
index 311501002..000000000
--- a/doc/man/gnunet-ats.1
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" This file is part of GNUnet.
-.\" Copyright (C) 2001-2019 GNUnet e.V.
-.\"
-.\" Permission is granted to copy, distribute and/or modify this document
-.\" under the terms of the GNU Free Documentation License, Version 1.3 or
-.\" any later version published by the Free Software Foundation; with no
-.\" Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
-.\" copy of the license is included in the file
-.\" FDL-1.3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/fdl.html}.
-.\"
-.\" Alternately, this document is also available under the General
-.\" Public License, version 3 or later, as published by the Free Software
-.\" Foundation. A copy of the license is included in the file
-.\" GPL3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/gpl.html
-.\"
-.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
-.\"
-.Dd October 16, 2015
-.Dt GNUNET-ATS 1
-.Os
-.Sh NAME
-.Nm gnunet-ats
-.Nd display information about transport resource allocation
-.Sh SYNOPSIS
-.Nm
-.Op Fl a | -all
-.Op Fl C Ar PEERID | Fl -connect= Ns Ar PEERID
-.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-.Op Fl h | -help
-.Op Fl i Ar PEERID | Fl -id= Ns Ar PEERID
-.Op Fl k Ar VALUE | Fl -value= Ns Ar VALUE
-.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-.Op Fl m | -monitor
-.Op Fl n | -numeric
-.Op Fl p Ar PREFERENCE | Fl -preference= Ns Ar PREFERENCE
-.Op Fl q | -quotas
-.Op Fl t Ar TYPE | Fl -type= Ns Ar TYPE
-.Op Fl u | -used
-.Op Fl V | -verbose
-.Op Fl v | -version
-.Sh DESCRIPTION
-.Nm
-can be used to display information about the
-GNUnet's transport selection mechanism.
-It shows information about the addresses and
-the assigned input and output bandwidth.
-.Sh OPTIONS
-.Bl -tag -width indent
-.It Fl a | -all
-List all addresses currently known to ats.
-.It Fl C Ar PEERID | Fl -connect= Ns Ar PEERID
-Ask ATS to suggest an address for PEERID to transport
-to establish a connection.
-Note that you can use the
-.Xr gnunet-transport 1
-commandline tool to force disconnects.
-.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-Use the configuration file FILENAME.
-.It Fl h | -help
-Print short help on options.
-.It Fl i Ar PEERID | Fl -id= Ns Ar PEERID
-Print information for a specific peer identity only.
-.It Fl k Ar VALUE | Fl -value= Ns Ar VALUE
-Value to set for when changing preference values.
-.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-Use LOGLEVEL for logging.
-Valid values are DEBUG, INFO, WARNING and ERROR.
-.It Fl m | -monitor
-Monitor changes to the bandwidth assignments continuously.
-.It Fl n | -numeric
-Do not resolve IP addresses to hostnames.
-.It Fl p Ar PREFERENCE | Fl -preference= Ns Ar PREFERENCE
-Set preference values, -i, -k and -t required.
-.It Fl q | -quotas
-Print quotas for all network types
-.It Fl t Ar TYPE | Fl -type= Ns Ar TYPE
-Preference type to change: latency | bandwidth
-.It Fl u | -used
-Print addresses actively used only
-.It Fl V | -verbose
-Print verbose output (include ATS address properties)
-.It v | -version
-Print GNUnet version number.
-.El
-.Sh SEE ALSO
-.Xr gnunet-transport 1
-.sp
-The full documentation for gnunet is maintained as a Texinfo manual.
-If the
-.Xr info 1
-and gnunet programs are properly installed at your site, the command
-.Pp
-.Dl info gnunet
-.Pp
-should give you access to the complete handbook,
-.Pp
-.Dl info gnunet-c-tutorial
-.Pp
-will give you access to a tutorial for developers.
-.Pp
-Depending on your installation, this information is also available in
-.Xr gnunet 7 and
-.Xr gnunet-c-tutorial 7 .
-.Sh BUGS
-Report bugs by using
-.Lk https://bugs.gnunet.org
-or by sending electronic mail to
-.Aq Mt bug-gnunet@gnu.org .
diff --git a/doc/man/gnunet-peerinfo.1 b/doc/man/gnunet-peerinfo.1
deleted file mode 100644
index 94951af86..000000000
--- a/doc/man/gnunet-peerinfo.1
+++ /dev/null
@@ -1,99 +0,0 @@
-.\" This file is part of GNUnet.
-.\" Copyright (C) 2001-2019 GNUnet e.V.
-.\"
-.\" Permission is granted to copy, distribute and/or modify this document
-.\" under the terms of the GNU Free Documentation License, Version 1.3 or
-.\" any later version published by the Free Software Foundation; with no
-.\" Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
-.\" copy of the license is included in the file
-.\" FDL-1.3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/fdl.html}.
-.\"
-.\" Alternately, this document is also available under the General
-.\" Public License, version 3 or later, as published by the Free Software
-.\" Foundation. A copy of the license is included in the file
-.\" GPL3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/gpl.html
-.\"
-.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
-.\"
-.Dd March 4, 2013
-.Dt GNUNET-PEERINFO 1
-.Os
-.Sh NAME
-.Nm gnunet-peerinfo
-.Nd display information about other peers
-.Sh SYNOPSIS
-.Nm
-.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-.Op Fl g | -get-hello
-.Op Fl h | -help
-.Op Fl i | -info
-.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-.Op Fl l Ar LOGFILE | Fl -logfile= ns Ar LOGFILE
-.Op Fl n | -numeric
-.Op Fl p Ar HELLO | Fl -put-hello= Ns Ar HELLO
-.Op Fl q | -quiet
-.Op Fl s | -self
-.Op Fl v | -version
-.Sh DESCRIPTION
-.Nm
-displays the known addresses and trust of known peers.
-.Bl -tag -width indent
-.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-Load config file, default FILENAME of the config is
-.Pa ~/.config/gnunet.conf .
-.It Fl g | -get-hello
-Output HELLO uri(s)
-.It Fl h | -help
-Print the help page.
-.It Fl i | -info
-List all known peers (and their addresses).
-.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-Set the loglevel
-.It Fl l Ar LOGFILE | Fl -logfile= ns Ar LOGFILE
-Log messages to LOGFILE
-.It Fl n | -numeric
-Disable resolution of IPs to hostnames
-.It Fl p Ar HELLO | Fl -put-hello= Ns Ar HELLO
-Add given HELLO uri to the database
-.It Fl q | -quiet
-Do not print anything but the peer identities
-.It Fl s | -self
-Print only our own identity.
-Together with
-.Fl q ,
-this is the exact line that other peers would have to put in to their friends file in order to consider this peer one of their friends in F2F mode.
-.It Fl v | -version
-Print the version number
-.El
-.Sh SEE ALSO
-.Xr gnunet.conf 5
-.sp
-The full documentation for gnunet is maintained as a Texinfo manual.
-If the
-.Xr info 1
-and gnunet programs are properly installed at your site, the command
-.Pp
-.Dl info gnunet
-.Pp
-should give you access to the complete handbook,
-.Pp
-.Dl info gnunet-c-tutorial
-.Pp
-will give you access to a tutorial for developers.
-.sp
-Depending on your installation, this information is also available in
-.Xr gnunet 7 and
-.Xr gnunet-c-tutorial 7 .
-.\".Sh HISTORY
-.\".Sh AUTHORS
-.Sh BUGS
-Report bugs by using
-.Lk https://bugs.gnunet.org
-or by sending electronic mail to
-.Aq Mt gnunet-developers@gnu.org .
diff --git a/doc/man/gnunet-testbed-profiler.1 b/doc/man/gnunet-testbed-profiler.1
deleted file mode 100644
index d079609ad..000000000
--- a/doc/man/gnunet-testbed-profiler.1
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" This file is part of GNUnet.
-.\" Copyright (C) 2001-2019 GNUnet e.V.
-.\"
-.\" Permission is granted to copy, distribute and/or modify this document
-.\" under the terms of the GNU Free Documentation License, Version 1.3 or
-.\" any later version published by the Free Software Foundation; with no
-.\" Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
-.\" copy of the license is included in the file
-.\" FDL-1.3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/fdl.html}.
-.\"
-.\" Alternately, this document is also available under the General
-.\" Public License, version 3 or later, as published by the Free Software
-.\" Foundation. A copy of the license is included in the file
-.\" GPL3.
-.\"
-.\" A copy of the license is also available from the Free Software
-.\" Foundation Web site at http://www.gnu.org/licenses/gpl.html
-.\"
-.\" SPDX-License-Identifier: GPL3.0-or-later OR FDL1.3-or-later
-.\"
-.Dd September 13, 2014
-.Dt GNUNET-TESTBED-PROFILER 1
-.Os
-.Sh NAME
-.Nm gnunet-testbed-profiler
-.Nd profiling driver for the testbed
-.Sh SYNOPSIS
-.Nm
-.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-.Op Fl e Ar COUNT | Fl -num-errors= Ns Ar COUNT
-.Op Fl H Ar FILENAME | Fl -hosts= Ns Ar FILENAME
-.Op Fl h | -help
-.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-.Op Fl l Ar LOGFILE | Fl -logfile= Ns Ar LOGFILE
-.Op Fl n | -non-interactive
-.Op Fl p Ar COUNT | Fl -num-peers= Ns Ar COUNT
-.Op Fl v | -version
-.Sh DESCRIPTION
-.Nm
-is a command line profiling driver for the testbed.
-.Sh OPTIONS
-.Bl -tag -width indent
-.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
-Use the configuration file FILENAME.
-.It Fl e Ar COUNT | Fl -num-errors= Ns Ar COUNT
-Tolerate COUNT number of continuous timeout failures.
-.It Fl H Ar FILENAME | Fl -hosts= Ns Ar FILENAME
-Name of the file with the login information for the testbed.
-.It Fl h | -help
-Print short help on options.
-.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
-Use LOGLEVEL for logging.
-Valid values are DEBUG, INFO, WARNING and ERROR.
-.It Fl l Ar LOGFILE | Fl -logfile= Ns Ar LOGFILE
-Configure logging to write logs to LOGFILE.
-.It Fl n | -non-interactive
-Run profiler in non-interactive mode where upon testbed setup the profiler does not wait for a keystroke but continues to run until a termination signal is received.
-.It Fl p Ar COUNT | Fl -num-peers= Ns Ar COUNT
-Create COUNT number of peers.
-.It Fl v | -version
-Print GNUnet version number.
-.El
-.Sh SEE ALSO
-The full documentation for gnunet is maintained as a Texinfo manual.
-If the
-.Xr info 1
-and gnunet programs are properly installed at your site, the command
-.Pp
-.Dl info gnunet
-.Pp
-should give you access to the complete handbook,
-.Pp
-.Dl info gnunet-c-tutorial
-.Pp
-will give you access to a tutorial for developers.
-.sp
-Depending on your installation, this information is also available in
-.Xr gnunet 7 and
-.Xr gnunet-c-tutorial 7 .
-.\".Sh HISTORY
-.\".Sh AUTHORS
-.Sh BUGS
-Report bugs by using
-.Lk https://bugs.gnunet.org
-or by sending electronic mail to
-.Aq Mt gnunet-developers@gnu.org .
diff --git a/doc/man/meson.build b/doc/man/meson.build
index 74679053f..fbd8179ba 100644
--- a/doc/man/meson.build
+++ b/doc/man/meson.build
@@ -8,7 +8,6 @@ install_man(
[
five,
'gnunet-arm.1',
- 'gnunet-ats.1',
'gnunet-auto-share.1',
'gnunet-base32.1',
'gnunet-bcd.1',
@@ -42,7 +41,6 @@ install_man(
'gnunet-nat-auto.1',
'gnunet-nat-server.1',
'gnunet-nse.1',
- 'gnunet-peerinfo.1',
'gnunet-publish.1',
'gnunet-qr.1',
'gnunet-reclaim.1',
@@ -52,7 +50,6 @@ install_man(
'gnunet-scrypt.1',
'gnunet-search.1',
'gnunet-statistics.1',
- 'gnunet-testbed-profiler.1',
'gnunet-testing.1',
'gnunet-testing-run-service.1',
'gnunet-timeout.1',
diff --git a/meson-dist-script b/meson-dist-script
index e5e9287dc..382681978 100644
--- a/meson-dist-script
+++ b/meson-dist-script
@@ -2,5 +2,19 @@
set -eu
-cd "${MESON_DIST_ROOT}"
-. ./scripts/sphinx_update.sh
+HANDBOOK_BOOTSTRAP=${MESON_SOURCE_ROOT}/contrib/handbook/_build
+
+if [ ! -d ${HANDBOOK_BOOTSTRAP}/html ] || [ ! -d ${HANDBOOK_BOOTSTRAP}/texinfo ]
+then
+ echo "Handbook not found, did you run bootstrap? Trying to compile now..."
+ cd "${MESON_DIST_ROOT}"
+ . ./scripts/sphinx_update.sh || exit 1
+ rm -rf ${MESON_DIST_ROOT}/contrib/handbook/_build
+else
+ cp -r ${HANDBOOK_BOOTSTRAP}/html ${MESON_DIST_ROOT}/handbook/ || exit 1
+ cp -r ${HANDBOOK_BOOTSTRAP}/texinfo ${MESON_DIST_ROOT}/handbook/ || exit 1
+fi
+
+# Do not dist old handbook
+rm -rf ${MESON_DIST_ROOT}/doc/old
+
diff --git a/meson.build b/meson.build
index 0101d43dd..10937517f 100644
--- a/meson.build
+++ b/meson.build
@@ -64,8 +64,8 @@ endif
# FIXME
cdata.set('extractor', 0)
-cdata.set('PKGDATADIRECTORY', get_option('datadir')/'gnunet')
-cdata.set('SYSCONFDIR', get_option('sysconfdir'))
+cdata.set('PKGDATADIRECTORY', get_option('prefix')/get_option('datadir')/'gnunet')
+cdata.set('SYSCONFDIR', get_option('prefix')/get_option('sysconfdir'))
# Various checks
if cc.has_member ('struct sockaddr_in', 'sin_len', prefix : ['#include <sys/types.h>', '#include <sys/socket.h>', '#include <netinet/in.h>'])
add_project_arguments('-DHAVE_SOCKADDR_IN_SIN_LEN', language: 'c')
@@ -321,20 +321,25 @@ endif
if ogg_dep.found()
add_project_arguments('-DHAVE_OGG', language : 'c')
endif
-
-gst_dep = dependency('libgst', required : false)
+gst_dep = dependency('gstreamer-1.0', required : false)
if not gst_dep.found()
- gst_dep = cc.find_library('gstreamer', required : false)
+ gst_dep = cc.find_library('gstreamer-1.0', required : false)
+endif
+gst_app_dep = dependency('gstreamer-app-1.0', required : false)
+if not gst_app_dep.found()
+ gst_app_dep = cc.find_library('gstreamer-app-1.0', required : false)
endif
-if gst_dep.found()
- add_project_arguments('-DHAVE_GST', language : 'c')
+gst_audio_dep = dependency('gstreamer-audio-1.0', required : false)
+if not gst_audio_dep.found()
+ gst_audio_dep = cc.find_library('gstreamer-audio-1.0', required : false)
endif
conversation_backend = 'none'
if pulse_dep.found() and opus_dep.found() and ogg_dep.found()
conversation_backend = 'pulse'
-elif gst_dep.found()
- conversation_backend = 'gst'
+elif gst_dep.found() and gst_app_dep.found() and gst_audio_dep.found()
+ add_project_arguments('-DHAVE_GST', language : 'c')
+ conversation_backend = 'gst'
endif
## END conversation
@@ -392,10 +397,10 @@ endif
# GNUTLS DANE
if cc.check_header('gnutls/dane.h')
if cc.has_function('dane_verify_crt_raw',
- prefix: '#include <gnutls/dane.h>',
- dependencies: gnutls_dep)
- add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c')
- endif
+ prefix: '#include <gnutls/dane.h>',
+ dependencies: gnutls_dep)
+ add_project_arguments('-DHAVE_GNUTLS_DANE', language : 'c')
+endif
endif
curl_ssl_check ='''#include <curl/curl.h>
int main(int argc, char **argv) {
@@ -404,7 +409,7 @@ curl_ssl_check ='''#include <curl/curl.h>
'''
result = cc.run(curl_ssl_check, name : 'cURL gnutls check',
- dependencies: curl_dep)
+ dependencies: curl_dep)
cdata.set('curl_gnutls', 0)
if result.returncode() == 0
cdata.set('curl_gnutls', 1)
@@ -459,27 +464,27 @@ add_test_setup('default', env: ['GNUNET_PREFIX='+gnunet_prefix], exclude_suites:
add_test_setup('full', env: ['GNUNET_PREFIX='+gnunet_prefix], is_default: false)
summary({'host': host_machine.system(),
- 'prefix': get_option('prefix'),
- 'compiler': cc.get_id(),
- 'libdir': get_option('libdir'),
- 'datadir': get_option('datadir'),
- 'default interface': cdata.get('GNUNET_DEFAULT_INTERFACE'),
- 'PostgreSQL': pq_dep.found(),
- 'curl w/ gnutls': (cdata.get('curl_gnutls') == 1),
- 'ifconfig': ifconfig_bin.found(),
- 'iptables': iptables_bin.found()
- }, section: 'Detected system')
+ 'prefix': get_option('prefix'),
+ 'compiler': cc.get_id(),
+ 'libdir': get_option('libdir'),
+ 'datadir': get_option('datadir'),
+ 'default interface': cdata.get('GNUNET_DEFAULT_INTERFACE'),
+ 'PostgreSQL': pq_dep.found(),
+ 'curl w/ gnutls': (cdata.get('curl_gnutls') == 1),
+ 'ifconfig': ifconfig_bin.found(),
+ 'iptables': iptables_bin.found()
+ }, section: 'Detected system')
if not gnunet_user
message('Please make sure NOW to create a user and group \'gnunet\' and additionally a group \'gnunetdns\'. Make sure that \'/var/lib/gnunet\' is owned (and writable) by user \'gnunet\'')
message('Each user of GNUnet should be added to the \'gnunet\' group')
if adduser_bin.found() and not gnunet_user
message('''Create the gnunet user and add users to the gnunetdns group, run:
- # addgroup gnunetdns
- # adduser --system --disabled-login --home /var/lib/gnunet gnunet''')
- message('''To add users to the gnunet group, run:
- # adduser USERNAME gnunet
- for each of your users, replacing \'USERNAME\' with the respective login name.
- Users may have to login again for the changes to take effect.''')
- endif
-endif
+ # addgroup gnunetdns
+ # adduser --system --disabled-login --home /var/lib/gnunet gnunet''')
+ message('''To add users to the gnunet group, run:
+ # adduser USERNAME gnunet
+ for each of your users, replacing \'USERNAME\' with the respective login name.
+ Users may have to login again for the changes to take effect.''')
+ endif
+ endif
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am
index 550785a50..754d71571 100644
--- a/pkgconfig/Makefile.am
+++ b/pkgconfig/Makefile.am
@@ -20,6 +20,7 @@ pcfiles = \
gnunetnamestore.pc \
gnunetnat.pc \
gnunetnse.pc \
+ gnunetreclaim.pc \
gnunetregex.pc \
gnunetrevocation.pc \
gnunetrps.pc \
@@ -59,6 +60,7 @@ EXTRA_DIST = \
gnunetnat.pc.in \
gnunetnse.pc.in \
gnunetpostgres.pc.in \
+ gnunetreclaim.pc.in \
gnunetregex.pc.in \
gnunetrevocation.pc.in \
gnunetrps.pc.in \
diff --git a/pkgconfig/gnunetreclaim.pc.in b/pkgconfig/gnunetreclaim.pc.in
new file mode 100644
index 000000000..b23e2ca70
--- /dev/null
+++ b/pkgconfig/gnunetreclaim.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: GNUnet RECLAIM
+Description: Provides API to access the GNUnet RECLAIM subsystem
+URL: http://gnunet.org
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -lgnunetreclaim
+Cflags: -I${includedir}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ed3d397ed..261b50000 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -70,7 +70,6 @@ src/contrib/service/conversation/gnunet_gst_test.c
src/contrib/service/conversation/microphone.c
src/contrib/service/conversation/plugin_gnsrecord_conversation.c
src/contrib/service/conversation/speaker.c
-src/contrib/service/rps/gnunet-rps-profiler.c
src/contrib/service/rps/gnunet-rps.c
src/contrib/service/rps/gnunet-service-rps.c
src/contrib/service/rps/gnunet-service-rps_custommap.c
@@ -87,7 +86,6 @@ src/contrib/service/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/contrib/service/scalarproduct/gnunet-service-scalarproduct_alice.c
src/contrib/service/scalarproduct/gnunet-service-scalarproduct_bob.c
src/contrib/service/scalarproduct/scalarproduct_api.c
-src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
src/contrib/service/secretsharing/gnunet-service-secretsharing.c
src/contrib/service/secretsharing/secretsharing_api.c
src/contrib/service/secretsharing/secretsharing_common.c
@@ -96,7 +94,6 @@ src/contrib/service/set/gnunet-service-set_intersection.c
src/contrib/service/set/gnunet-service-set_union.c
src/contrib/service/set/gnunet-service-set_union_strata_estimator.c
src/contrib/service/set/gnunet-set-ibf-profiler.c
-src/contrib/service/set/gnunet-set-profiler.c
src/contrib/service/set/ibf.c
src/contrib/service/set/ibf_sim.c
src/contrib/service/set/plugin_block_set_test.c
@@ -251,7 +248,6 @@ src/service/cadet/cadet_api_get_path.c
src/service/cadet/cadet_api_helper.c
src/service/cadet/cadet_api_list_peers.c
src/service/cadet/cadet_api_list_tunnels.c
-src/service/cadet/cadet_test_lib.c
src/service/cadet/desirability_table.c
src/service/cadet/gnunet-service-cadet.c
src/service/cadet/gnunet-service-cadet_channel.c
@@ -273,7 +269,6 @@ src/service/datacache/datacache.c
src/service/datastore/datastore_api.c
src/service/datastore/gnunet-service-datastore.c
src/service/dht/dht_api.c
-src/service/dht/dht_test_lib.c
src/service/dht/gnunet-service-dht.c
src/service/dht/gnunet-service-dht_clients.c
src/service/dht/gnunet-service-dht_datacache.c
@@ -305,7 +300,6 @@ src/service/fs/fs_publish_ksk.c
src/service/fs/fs_publish_ublock.c
src/service/fs/fs_search.c
src/service/fs/fs_sharetree.c
-src/service/fs/fs_test_lib.c
src/service/fs/fs_tree.c
src/service/fs/fs_unindex.c
src/service/fs/fs_uri.c
@@ -395,7 +389,6 @@ src/service/nat/gnunet-service-nat_mini.c
src/service/nat/gnunet-service-nat_stun.c
src/service/nat/nat_api.c
src/service/nat/nat_api_stun.c
-src/service/nse/gnunet-nse-profiler.c
src/service/nse/gnunet-service-nse.c
src/service/nse/nse_api.c
src/service/peerstore/gnunet-service-peerstore.c
@@ -412,7 +405,6 @@ src/service/reclaim/reclaim_attribute.c
src/service/reclaim/reclaim_credential.c
src/service/regex/gnunet-daemon-regexprofiler.c
src/service/regex/gnunet-regex-profiler.c
-src/service/regex/gnunet-regex-simulation-profiler.c
src/service/regex/gnunet-service-regex.c
src/service/regex/perf-regex.c
src/service/regex/regex_api_announce.c
@@ -437,12 +429,10 @@ src/service/rest/rest.c
src/service/revocation/gnunet-service-revocation.c
src/service/revocation/revocation_api.c
src/service/seti/gnunet-service-seti.c
-src/service/seti/gnunet-seti-profiler.c
src/service/seti/seti_api.c
src/service/setu/gnunet-service-setu.c
src/service/setu/gnunet-service-setu_strata_estimator.c
src/service/setu/gnunet-setu-ibf-profiler.c
-src/service/setu/gnunet-setu-profiler.c
src/service/setu/ibf.c
src/service/setu/ibf_sim.c
src/service/setu/setu_api.c
diff --git a/scripts/gana_update.sh b/scripts/gana_update.sh
index 0707433f5..0f2d17509 100755
--- a/scripts/gana_update.sh
+++ b/scripts/gana_update.sh
@@ -13,42 +13,35 @@ gana_update()
fi
echo "Updating GANA..."
if existence recfmt; then
- cwd=$PWD
+ GNUNET_SRC_ROOT=$PWD
cd contrib/gana || exit 1
# GNS
echo "Updating GNS record types"
- cd gnu-name-system-record-types && \
- make >/dev/null && \
- cp gnu_name_system_record_types.h ../../../src/include/ || exit 1
+ make -C gnu-name-system-record-types >/dev/null && \
+ cp gnu-name-system-record-types/gnu_name_system_record_types.h $GNUNET_SRC_ROOT/src/include/ || exit 1
echo "Creating default TLDs"
- cd ../gnu-name-system-default-tlds && \
- make >/dev/null && \
- cp tlds.conf ../../../src/service/gns || exit 1
+ make -C gnu-name-system-default-tlds >/dev/null && \
+ cp gnu-name-system-default-tlds/tlds.conf $GNUNET_SRC_ROOT/src/service/gns || exit 1
echo "Creating default GNS protocol numbers"
- cd ../gns-protocol-numbers && \
- make >/dev/null && \
- cp gnu_name_system_protocols.h ../../../src/include/ || exit 1
- echo "Creating default GNS service port nummbers"
- cd ../gns-service-port-numbers && \
- make >/dev/null && \
- cp gnu_name_system_service_ports.h ../../../src/include/ || exit 1
+ make -C gns-protocol-numbers >/dev/null && \
+ cp gns-protocol-numbers/gnu_name_system_protocols.h $GNUNET_SRC_ROOT/src/include/ || exit 1
+ echo "Creating default GNS service port numbers"
+ make -C gns-service-port-numbers >/dev/null && \
+ cp gns-service-port-numbers/gnu_name_system_service_ports.h $GNUNET_SRC_ROOT/src/include/ || exit 1
# Signatures
echo "Updating GNUnet signatures"
- cd ../gnunet-signatures && \
- make >/dev/null && \
- cp gnunet_signatures.h ../../../src/include || exit 1
+ make -C gnunet-signatures >/dev/null && \
+ cp gnunet-signatures/gnunet_signatures.h $GNUNET_SRC_ROOT/src/include || exit 1
# DHT Block Types
echo "Updating DHT record types"
- cd ../gnunet-dht-block-types && \
- make >/dev/null && \
- cp gnunet_dht_block_types.h ../../../src/include || exit 1
+ make -C gnunet-dht-block-types >/dev/null && \
+ cp gnunet-dht-block-types/gnunet_dht_block_types.h $GNUNET_SRC_ROOT/src/include || exit 1
echo "Generating GNUnet error types"
- cd ../gnunet-error-codes && \
- make >/dev/null && \
- cp gnunet_error_codes.h ../../../src/include && \
- cp gnunet_error_codes.c ../../../src/lib/util || exit 1
- cd $cwd
+ make -C gnunet-error-codes >/dev/null && \
+ cp gnunet-error-codes/gnunet_error_codes.h $GNUNET_SRC_ROOT/src/include && \
+ cp gnunet-error-codes/gnunet_error_codes.c $GNUNET_SRC_ROOT/src/lib/util || exit 1
+ cd $GNUNET_SRC_ROOT
else
echo "ERROR: No recutils found! Unable to generate recent GANA headers and configs."
exit 1
diff --git a/src/cli/gns/meson.build b/src/cli/gns/meson.build
index d4529c941..bb6bfc477 100644
--- a/src/cli/gns/meson.build
+++ b/src/cli/gns/meson.build
@@ -2,10 +2,13 @@ configure_file(input : 'gnunet-gns-proxy-setup-ca.in',
output : 'gnunet-gns-proxy-setup-ca',
configuration : cdata,
install: true,
+ install_mode: 'rwxr-xr-x',
install_dir: get_option('bindir'))
install_data('gnunet-gns-proxy-ca.template',
install_dir: get_option('datadir')/'gnunet')
+install_data('openssl.cnf',
+ install_dir: get_option('datadir')/'gnunet')
executable ('gnunet-gns',
'gnunet-gns.c',
@@ -37,6 +40,9 @@ testgns = [
'test_gns_soa_lookup',
'test_gns_txt_lookup',
'test_gns_zkey_lookup',
+ 'test_gns_sbox_simple',
+ 'test_gns_sbox',
+ 'test_gns_box_sbox',
]
testconfigs = [
diff --git a/src/cli/gns/openssl.cnf b/src/cli/gns/openssl.cnf
index a2561b9b2..5dce35388 100644
--- a/src/cli/gns/openssl.cnf
+++ b/src/cli/gns/openssl.cnf
@@ -6,7 +6,7 @@
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
-RANDFILE = $ENV::HOME/.rnd
+#RANDFILE = $ENV::HOME/.rnd
# Extra OBJECT IDENTIFIER info:
#oid_file = $ENV::HOME/.oid
diff --git a/src/cli/gns/test_gns_sbox.sh b/src/cli/gns/test_gns_sbox.sh
index 8ff70a57a..6918bf130 100755
--- a/src/cli/gns/test_gns_sbox.sh
+++ b/src/cli/gns/test_gns_sbox.sh
@@ -15,7 +15,7 @@ then
fi
rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
-which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
+which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 7"
TEST_A="139.134.54.9"
MY_EGO="myego"
LABEL="testsbox"
diff --git a/src/contrib/cli/template/meson.build b/src/contrib/cli/template/meson.build
index f5adc97b3..dba66a8f2 100644
--- a/src/contrib/cli/template/meson.build
+++ b/src/contrib/cli/template/meson.build
@@ -2,5 +2,4 @@ executable ('gnunet-template',
['gnunet-template.c'],
dependencies: [libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('bindir'))
+ install: false)
diff --git a/src/contrib/service/conversation/meson.build b/src/contrib/service/conversation/meson.build
index 052fa1a6e..4ecc0fc93 100644
--- a/src/contrib/service/conversation/meson.build
+++ b/src/contrib/service/conversation/meson.build
@@ -82,6 +82,16 @@ executable ('gnunet-conversation',
install: true,
install_dir: get_option('bindir'))
+executable ('gnunet-conversation-test',
+ 'gnunet-conversation-test.c',
+ dependencies: [libgnunetconversation_dep,
+ libgnunetspeaker_dep,
+ libgnunetmicrophone_dep,
+ libgnunetutil_dep],
+ include_directories: [incdir, configuration_inc],
+ install: true,
+ install_dir: get_option('bindir'))
+
executable ('gnunet-service-conversation',
gnunetserviceconversation_src,
dependencies: [libgnunetconversation_dep,
@@ -108,6 +118,8 @@ executable ('gnunet-helper-audio-record',
libgnunetspeaker_dep,
libgnunetmicrophone_dep,
gst_dep,
+ gst_app_dep,
+ gst_audio_dep,
ogg_dep,
pulse_dep,
opus_dep
@@ -123,6 +135,8 @@ executable ('gnunet-helper-audio-playback',
libgnunetspeaker_dep,
libgnunetmicrophone_dep,
gst_dep,
+ gst_app_dep,
+ gst_audio_dep,
ogg_dep,
pulse_dep,
opus_dep
@@ -143,8 +157,7 @@ testconvapi = executable ('test_conversation_api',
libgnunetmicrophone_dep,
],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+ install: false)
testconvapitwo = executable ('test_conversation_api_twocalls',
['test_conversation_api_twocalls.c'],
@@ -158,8 +171,7 @@ testconvapitwo = executable ('test_conversation_api_twocalls',
libgnunetmicrophone_dep,
],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+ install: false)
testconvapireject = executable ('test_conversation_api_reject',
['test_conversation_api_reject.c'],
@@ -173,8 +185,7 @@ testconvapireject = executable ('test_conversation_api_reject',
libgnunetmicrophone_dep,
],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+ install: false)
configure_file(input : 'test_conversation.conf',
output : 'test_conversation.conf',
diff --git a/src/contrib/service/conversation/plugin_gnsrecord_conversation.c b/src/contrib/service/conversation/plugin_gnsrecord_conversation.c
index 786711c8e..802732cfe 100644
--- a/src/contrib/service/conversation/plugin_gnsrecord_conversation.c
+++ b/src/contrib/service/conversation/plugin_gnsrecord_conversation.c
@@ -121,7 +121,7 @@ conversation_string_to_value (void *cls,
case GNUNET_GNSRECORD_TYPE_PHONE:
{
struct GNUNET_CONVERSATION_PhoneRecord *pr;
- char line_port[103];
+ char line_port[104];
const char *dash;
struct GNUNET_PeerIdentity peer;
diff --git a/src/contrib/service/rps/Makefile.am b/src/contrib/service/rps/Makefile.am
index 28aa3e050..1a3c9fa3a 100644
--- a/src/contrib/service/rps/Makefile.am
+++ b/src/contrib/service/rps/Makefile.am
@@ -45,10 +45,6 @@ libgnunetrps_la_CFLAGS = $(AM_CFLAGS)
libexec_PROGRAMS = \
gnunet-service-rps
-#noinst_PROGRAMS = \
-# gnunet-rps-profiler
-
-
gnunet_service_rps_SOURCES = \
gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
rps-sampler_common.h rps-sampler_common.c \
@@ -149,19 +145,5 @@ test_service_rps_sampler_elem_LDADD = $(top_builddir)/src/lib/util/libgnunetutil
#test_rps_malicious_3_SOURCES = $(rps_test_src)
#test_rps_malicious_3_LDADD = $(ld_rps_test_lib)
-#gnunet_rps_profiler_SOURCES = \
-# gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
-# rps-sampler_common.h rps-sampler_common.c \
-# gnunet-service-rps_sampler.h gnunet-service-rps_sampler.c \
-# rps-test_util.h rps-test_util.c \
-# gnunet-rps-profiler.c
-#gnunet_rps_profiler_LDADD = \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
-# libgnunetrps.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# -lm
-
-
EXTRA_DIST = \
test_rps.conf
diff --git a/src/contrib/service/rps/gnunet-rps-profiler.c b/src/contrib/service/rps/gnunet-rps-profiler.c
deleted file mode 100644
index df10ad5da..000000000
--- a/src/contrib/service/rps/gnunet-rps-profiler.c
+++ /dev/null
@@ -1,3199 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2009, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file rps/test_rps.c
- * @brief Testcase for the random peer sampling service. Starts
- * a peergroup with a given number of peers, then waits to
- * receive size pushes/pulls from each peer. Expects to wait
- * for one message from each peer.
- */
-#include "platform.h"
-// #include "rps_test_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testbed_service.h"
-
-#include "gnunet_rps_service.h"
-#include "rps-test_util.h"
-#include "gnunet-service-rps_sampler_elem.h"
-
-#include <inttypes.h>
-
-
-#define BIT(n) (1 << (n))
-
-/**
- * How many peers do we start?
- */
-static uint32_t num_peers;
-
-/**
- * @brief number of bits required to represent the largest peer id
- */
-static unsigned bits_needed;
-
-/**
- * How long do we run the test?
- */
-static struct GNUNET_TIME_Relative duration;
-
-/**
- * When do we do a hard shutdown?
- */
-static struct GNUNET_TIME_Relative timeout;
-
-
-// /**
-// * Portion of malicious peers
-// */
-// static double portion = .1;
-
-/**
- * Type of malicious peer to test
- */
-static unsigned int mal_type = 0;
-
-/**
- * Handles to all of the running peers
- */
-static struct GNUNET_TESTBED_Peer **testbed_peers;
-
-enum STAT_TYPE
-{
- STAT_TYPE_ROUNDS, /* 0 */
- STAT_TYPE_BLOCKS, /* 1 */
- STAT_TYPE_BLOCKS_MANY_PUSH, /* 2 */
- STAT_TYPE_BLOCKS_NO_PUSH, /* 3 */
- STAT_TYPE_BLOCKS_NO_PULL, /* 4 */
- STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL, /* 5 */
- STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL, /* 6 */
- STAT_TYPE_ISSUED_PUSH_SEND, /* 7 */
- STAT_TYPE_ISSUED_PUSH_SEND_MH, /* 8 */
- STAT_TYPE_ISSUED_PULL_REQ, /* 9 */
- STAT_TYPE_ISSUED_PULL_REQ_MH, /* 10 */
- STAT_TYPE_ISSUED_PULL_REP, /* 11 */
- STAT_TYPE_SENT_PUSH_SEND, /* 12 */
- STAT_TYPE_SENT_PULL_REQ, /* 13 */
- STAT_TYPE_SENT_PULL_REQ_MH, /* 14 */
- STAT_TYPE_SENT_PULL_REP, /* 15 */
- STAT_TYPE_RECV_PUSH_SEND, /* 16 */
- STAT_TYPE_RECV_PUSH_SEND_MH, /* 17 */
- STAT_TYPE_RECV_PULL_REQ, /* 18 */
- STAT_TYPE_RECV_PULL_REQ_MH, /* 19 */
- STAT_TYPE_RECV_PULL_REP, /* 20 */
- STAT_TYPE_RECV_PULL_REP_MH, /* 21 */
- STAT_TYPE_VIEW_SIZE, /* 22 */
- STAT_TYPE_KNOWN_PEERS, /* 23 */
- STAT_TYPE_VALID_PEERS, /* 24 */
- STAT_TYPE_LEARND_PEERS, /* 25 */
- STAT_TYPE_PENDING_ONLINE_CHECKS, /* 26 */
- STAT_TYPE_UNREQUESTED_PULL_REPLIES, /* 27 */
- STAT_TYPE_PEERS_IN_PUSH_MAP, /* 28 */
- STAT_TYPE_PEERS_IN_PULL_MAP, /* 29 */
- STAT_TYPE_PEERS_IN_VIEW, /* 30 */
- STAT_TYPE_VIEW_SIZE_AIM, /* 31 */
- STAT_TYPE_MAX, /* 32 */
-};
-
-static char*stat_type_strings[] = {
- "# rounds",
- "# rounds blocked",
- "# rounds blocked - too many pushes",
- "# rounds blocked - no pushes",
- "# rounds blocked - no pull replies",
- "# rounds blocked - too many pushes, no pull replies",
- "# rounds blocked - no pushes, no pull replies",
- "# push send issued",
- "# push send issued (multi-hop peer)",
- "# pull request send issued",
- "# pull request send issued (multi-hop peer)",
- "# pull reply send issued",
- "# pushes sent",
- "# pull requests sent",
- "# pull requests sent (multi-hop peer)",
- "# pull replies sent",
- "# push message received",
- "# push message received (multi-hop peer)",
- "# pull request message received",
- "# pull request message received (multi-hop peer)",
- "# pull reply messages received",
- "# pull reply messages received (multi-hop peer)",
- "view size",
- "# known peers",
- "# valid peers",
- "# learnd peers",
- "# pending online checks",
- "# unrequested pull replies",
- "# peers in push map at end of round",
- "# peers in pull map at end of round",
- "# peers in view at end of round",
- "view size aim",
-};
-
-struct STATcls
-{
- struct RPSPeer *rps_peer;
- enum STAT_TYPE stat_type;
-};
-
-
-/**
- * @brief Converts string representation to the corresponding #STAT_TYPE enum.
- *
- * @param stat_str string representation of statistics specifier
- *
- * @return corresponding enum
- */
-enum STAT_TYPE
-stat_str_2_type (const char *stat_str)
-{
- if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH])))
- {
- return STAT_TYPE_BLOCKS_MANY_PUSH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL])))
- {
- return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH])))
- {
- return STAT_TYPE_BLOCKS_NO_PUSH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_BLOCKS])))
- {
- return STAT_TYPE_BLOCKS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ROUNDS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_ROUNDS])))
- {
- return STAT_TYPE_ROUNDS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND])))
- {
- return STAT_TYPE_ISSUED_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH])))
- {
- return STAT_TYPE_ISSUED_PUSH_SEND_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ])))
- {
- return STAT_TYPE_ISSUED_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH])))
- {
- return STAT_TYPE_ISSUED_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REP],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_ISSUED_PULL_REP])))
- {
- return STAT_TYPE_ISSUED_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND])))
- {
- return STAT_TYPE_SENT_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REQ])))
- {
- return STAT_TYPE_SENT_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH])))
- {
- return STAT_TYPE_SENT_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REP],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REP])))
- {
- return STAT_TYPE_SENT_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND])))
- {
- return STAT_TYPE_RECV_PUSH_SEND;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH])))
- {
- return STAT_TYPE_RECV_PUSH_SEND_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REQ])))
- {
- return STAT_TYPE_RECV_PULL_REQ;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH])))
- {
- return STAT_TYPE_RECV_PULL_REQ_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REP])))
- {
- return STAT_TYPE_RECV_PULL_REP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH])))
- {
- return STAT_TYPE_RECV_PULL_REP_MH;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE])))
- {
- return STAT_TYPE_VIEW_SIZE;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_KNOWN_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_KNOWN_PEERS])))
- {
- return STAT_TYPE_KNOWN_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VALID_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VALID_PEERS])))
- {
- return STAT_TYPE_VALID_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_LEARND_PEERS],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_LEARND_PEERS])))
- {
- return STAT_TYPE_LEARND_PEERS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS])))
- {
- return STAT_TYPE_PENDING_ONLINE_CHECKS;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES])))
- {
- return STAT_TYPE_UNREQUESTED_PULL_REPLIES;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP])))
- {
- return STAT_TYPE_PEERS_IN_PUSH_MAP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP],
- stat_str,
- strlen (
- stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP])))
- {
- return STAT_TYPE_PEERS_IN_PULL_MAP;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW])))
- {
- return STAT_TYPE_PEERS_IN_VIEW;
- }
- else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM],
- stat_str,
- strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM])))
- {
- return STAT_TYPE_VIEW_SIZE_AIM;
- }
- return STAT_TYPE_MAX;
-}
-
-
-/**
- * @brief Indicates whether peer should go off- or online
- */
-enum PEER_ONLINE_DELTA
-{
- /**
- * @brief Indicates peer going online
- */
- PEER_GO_ONLINE = 1,
- /**
- * @brief Indicates peer going offline
- */
- PEER_GO_OFFLINE = -1,
-};
-
-/**
- * Operation map entry
- */
-struct OpListEntry
-{
- /**
- * DLL next ptr
- */
- struct OpListEntry *next;
-
- /**
- * DLL prev ptr
- */
- struct OpListEntry *prev;
-
- /**
- * The testbed operation
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Depending on whether we start or stop RPS service at the peer, set this to
- * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
- */
- enum PEER_ONLINE_DELTA delta;
-
- /**
- * Index of the regarding peer
- */
- unsigned int index;
-};
-
-/**
- * OpList DLL head
- */
-static struct OpListEntry *oplist_head;
-
-/**
- * OpList DLL tail
- */
-static struct OpListEntry *oplist_tail;
-
-
-/**
- * A pending reply: A request was sent and the reply is pending.
- */
-struct PendingReply
-{
- /**
- * DLL next,prev ptr
- */
- struct PendingReply *next;
- struct PendingReply *prev;
-
- /**
- * Handle to the request we are waiting for
- */
- struct GNUNET_RPS_Request_Handle_Single_Info *req_handle;
-
- /**
- * The peer that requested
- */
- struct RPSPeer *rps_peer;
-};
-
-
-/**
- * A pending request: A request was not made yet but is scheduled for later.
- */
-struct PendingRequest
-{
- /**
- * DLL next,prev ptr
- */
- struct PendingRequest *next;
- struct PendingRequest *prev;
-
- /**
- * Handle to the request we are waiting for
- */
- struct GNUNET_SCHEDULER_Task *request_task;
-
- /**
- * The peer that requested
- */
- struct RPSPeer *rps_peer;
-};
-
-
-/**
- * Information we track for each peer.
- */
-struct RPSPeer
-{
- /**
- * Index of the peer.
- */
- uint32_t index;
-
- /**
- * Handle for RPS connect operation.
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Handle to RPS service.
- */
- struct GNUNET_RPS_Handle *rps_handle;
-
- /**
- * ID of the peer.
- */
- struct GNUNET_PeerIdentity *peer_id;
-
- /**
- * A request handle to check for an request
- */
- // struct GNUNET_RPS_Request_Handle *req_handle;
-
- /**
- * Peer on- or offline?
- */
- int online;
-
- /**
- * Number of Peer IDs to request during the whole test
- */
- unsigned int num_ids_to_request;
-
- /**
- * Pending requests DLL
- */
- struct PendingRequest *pending_req_head;
- struct PendingRequest *pending_req_tail;
-
- /**
- * Number of pending requests
- */
- unsigned int num_pending_reqs;
-
- /**
- * Pending replies DLL
- */
- struct PendingReply *pending_rep_head;
- struct PendingReply *pending_rep_tail;
-
- /**
- * Number of pending replies
- */
- unsigned int num_pending_reps;
-
- /**
- * Number of received PeerIDs
- */
- unsigned int num_recv_ids;
-
- /**
- * Pending operation on that peer
- */
- const struct OpListEntry *entry_op_manage;
-
- /**
- * Testbed operation to connect to statistics service
- */
- struct GNUNET_TESTBED_Operation *stat_op;
-
- /**
- * Handle to the statistics service
- */
- struct GNUNET_STATISTICS_Handle *stats_h;
-
- /**
- * @brief flags to indicate which statistics values have been already
- * collected from the statistics service.
- * Used to check whether we are able to shutdown.
- */
- uint32_t stat_collected_flags;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_stats;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_probs;
-
- /**
- * @brief File name of the file the stats are finally written to
- */
- const char *file_name_probs_hist;
-
- /**
- * @brief The current view
- */
- struct GNUNET_PeerIdentity *cur_view;
-
- /**
- * @brief Number of peers in the #cur_view.
- */
- uint32_t cur_view_count;
-
- /**
- * @brief Number of occurrences in other peer's view
- */
- uint32_t count_in_views;
-
- /**
- * @brief statistics values
- */
- uint64_t stats[STAT_TYPE_MAX];
- /**
- * @brief Handle for the statistics get request
- */
- struct GNUNET_STATISTICS_GetHandle *h_stat_get[STAT_TYPE_MAX];
-
- /**
- * @brief Keep the probabilities in cache for computing the probabilities
- * with respect to history.
- */
- double *eval_probs_cache;
-};
-
-/**
- * Information for all the peers.
- */
-static struct RPSPeer *rps_peers;
-
-/**
- * Peermap to get the index of a given peer ID quick.
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
-
-/**
- * IDs of the peers.
- */
-static struct GNUNET_PeerIdentity *rps_peer_ids;
-
-/**
- * ID of the targeted peer.
- */
-static struct GNUNET_PeerIdentity *target_peer;
-
-/**
- * Number of online peers.
- */
-static unsigned int num_peers_online;
-
-/**
- * @brief The added sizes of the peer's views
- */
-static unsigned int view_sizes;
-
-/**
- * Return value from 'main'.
- */
-static int ok;
-
-/**
- * Identifier for the task that runs after the test to collect results
- */
-static struct GNUNET_SCHEDULER_Task *post_test_task;
-
-/**
- * Identifier for the shutdown task
- */
-static struct GNUNET_SCHEDULER_Task *shutdown_task;
-
-
-/**
- * Identifier for the churn task that runs periodically
- */
-static struct GNUNET_SCHEDULER_Task *churn_task;
-
-/**
- * Called to initialise the given RPSPeer
- */
-typedef void (*InitPeer) (struct RPSPeer *rps_peer);
-
-/**
- * @brief Called directly after connecting to the service
- *
- * @param rps_peer Specific peer the function is called on
- * @param h the handle to the rps service
- */
-typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h);
-
-/**
- * @brief Executes functions to test the api/service for a given peer
- *
- * Called from within #rps_connect_complete_cb ()
- * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
- * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
- *
- * @param rps_peer the peer the task runs on
- */
-typedef void (*MainTest) (struct RPSPeer *rps_peer);
-
-/**
- * Callback called once the requested random peers are available
- */
-typedef void (*ReplyHandle) (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers);
-
-/**
- * Called directly before disconnecting from the service
- */
-typedef void (*PostTest) (struct RPSPeer *peer);
-
-/**
- * Function called after disconnect to evaluate test success
- */
-typedef int (*EvaluationCallback) (void);
-
-/**
- * @brief Do we have Churn?
- */
-enum OPTION_CHURN
-{
- /**
- * @brief If we have churn this is set
- */
- HAVE_CHURN,
- /**
- * @brief If we have no churn this is set
- */
- HAVE_NO_CHURN,
-};
-
-/**
- * @brief Is it ok to quit the test before the timeout?
- */
-enum OPTION_QUICK_QUIT
-{
- /**
- * @brief It is ok for the test to quit before the timeout triggers
- */
- HAVE_QUICK_QUIT,
-
- /**
- * @brief It is NOT ok for the test to quit before the timeout triggers
- */
- HAVE_NO_QUICK_QUIT,
-};
-
-/**
- * @brief Do we collect statistics at the end?
- */
-enum OPTION_COLLECT_STATISTICS
-{
- /**
- * @brief We collect statistics at the end
- */
- COLLECT_STATISTICS,
-
- /**
- * @brief We do not collect statistics at the end
- */
- NO_COLLECT_STATISTICS,
-};
-
-/**
- * @brief Do we collect views during run?
- */
-enum OPTION_COLLECT_VIEW
-{
- /**
- * @brief We collect view during run
- */
- COLLECT_VIEW,
-
- /**
- * @brief We do not collect the view during run
- */
- NO_COLLECT_VIEW,
-};
-
-/**
- * Structure to define a single test
- */
-struct SingleTestRun
-{
- /**
- * Name of the test
- */
- char *name;
-
- /**
- * Called with a single peer in order to initialise that peer
- */
- InitPeer init_peer;
-
- /**
- * Called directly after connecting to the service
- */
- PreTest pre_test;
-
- /**
- * Main function for each peer
- */
- MainTest main_test;
-
- /**
- * Callback called once the requested peers are available
- */
- ReplyHandle reply_handle;
-
- /**
- * Called directly before disconnecting from the service
- */
- PostTest post_test;
-
- /**
- * Function to evaluate the test results
- */
- EvaluationCallback eval_cb;
-
- /**
- * Request interval
- */
- uint32_t request_interval;
-
- /**
- * Number of Requests to make.
- */
- uint32_t num_requests;
-
- /**
- * Run with (-out) churn
- */
- enum OPTION_CHURN have_churn;
-
- /**
- * Quit test before timeout?
- */
- enum OPTION_QUICK_QUIT have_quick_quit;
-
- /**
- * Collect statistics at the end?
- */
- enum OPTION_COLLECT_STATISTICS have_collect_statistics;
-
- /**
- * Collect view during run?
- */
- enum OPTION_COLLECT_VIEW have_collect_view;
-
- /**
- * @brief Mark which values from the statistics service to collect at the end
- * of the run
- */
- uint32_t stat_collect_flags;
-} cur_test_run;
-
-/**
- * Did we finish the test?
- */
-static int post_test;
-
-/**
- * Are we shutting down?
- */
-static int in_shutdown;
-
-/**
- * Append arguments to file
- */
-static void
-tofile_ (const char *file_name, const char *line)
-{
- struct GNUNET_DISK_FileHandle *f;
- /* char output_buffer[512]; */
- size_t size;
- /* int size; */
- size_t size2;
-
- if (NULL == (f = GNUNET_DISK_file_open (file_name,
- GNUNET_DISK_OPEN_APPEND
- | GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_PERM_GROUP_READ
- | GNUNET_DISK_PERM_OTHER_READ)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Not able to open file %s\n",
- file_name);
- return;
- }
- /* size = GNUNET_snprintf (output_buffer,
- sizeof (output_buffer),
- "%llu %s\n",
- GNUNET_TIME_absolute_get ().abs_value_us,
- line);
- if (0 > size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to write string to buffer (size: %i)\n",
- size);
- return;
- } */size = strlen (line) * sizeof(char);
-
- size2 = GNUNET_DISK_file_write (f, line, size);
- if (size != size2)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to write to file! (Size: %lu, size2: %lu)\n",
- size,
- size2);
- if (GNUNET_YES != GNUNET_DISK_file_close (f))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to close file\n");
- }
- return;
- }
-
- if (GNUNET_YES != GNUNET_DISK_file_close (f))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unable to close file\n");
- }
-}
-
-
-/**
- * This function is used to facilitate writing important information to disk
- */
-#define tofile(file_name, ...) do { \
- char tmp_buf[512]; \
- int size; \
- size = GNUNET_snprintf (tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \
- if (0 > size) \
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
- "Failed to create tmp_buf\n"); \
- else \
- tofile_ (file_name, tmp_buf); \
-} while (0);
-
-
-/**
- * Write the ids and their according index in the given array to a file
- * Unused
- */
-/* static void
- ids_to_file (char *file_name,
- struct GNUNET_PeerIdentity *peer_ids,
- unsigned int num_peer_ids)
- {
- unsigned int i;
-
- for (i=0 ; i < num_peer_ids ; i++)
- {
- to_file (file_name,
- "%u\t%s",
- i,
- GNUNET_i2s_full (&peer_ids[i]));
- }
- } */
-
-/**
- * Test the success of a single test
- */
-static int
-evaluate (void)
-{
- unsigned int i;
- int tmp_ok;
-
- tmp_ok = 1;
-
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].num_recv_ids,
- rps_peers[i].num_ids_to_request,
- (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids));
- tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids);
- }
- return tmp_ok ? 0 : 1;
-}
-
-
-/**
- * Creates an oplist entry and adds it to the oplist DLL
- */
-static struct OpListEntry *
-make_oplist_entry ()
-{
- struct OpListEntry *entry;
-
- entry = GNUNET_new (struct OpListEntry);
- GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
- return entry;
-}
-
-
-/**
- * @brief Checks if given peer already received its statistics value from the
- * statistics service.
- *
- * @param rps_peer the peer to check for
- *
- * @return #GNUNET_YES if so
- * #GNUNET_NO otherwise
- */
-static int
-check_statistics_collect_completed_single_peer (
- const struct RPSPeer *rps_peer)
-{
- if (cur_test_run.stat_collect_flags !=
- (cur_test_run.stat_collect_flags
- & rps_peer->stat_collected_flags))
- {
- return GNUNET_NO;
- }
- return GNUNET_YES;
-}
-
-
-/**
- * @brief Checks if all peers already received their statistics value from the
- * statistics service.
- *
- * @return #GNUNET_YES if so
- * #GNUNET_NO otherwise
- */
-static int
-check_statistics_collect_completed ()
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++)
- {
- if (GNUNET_NO == check_statistics_collect_completed_single_peer (
- &rps_peers[i]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At least Peer %" PRIu32
- " did not yet receive all statistics values\n",
- i);
- return GNUNET_NO;
- }
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "All peers received their statistics values\n");
- return GNUNET_YES;
-}
-
-
-static void
-rps_disconnect_adapter (void *cls,
- void *op_result);
-
-static void
-cancel_pending_req (struct PendingRequest *pending_req)
-{
- struct RPSPeer *rps_peer;
-
- rps_peer = pending_req->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling pending rps get request\n");
- GNUNET_SCHEDULER_cancel (pending_req->request_task);
- GNUNET_free (pending_req);
-}
-
-
-static void
-cancel_request (struct PendingReply *pending_rep)
-{
- struct RPSPeer *rps_peer;
-
- rps_peer = pending_rep->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling rps get reply\n");
- GNUNET_assert (NULL != pending_rep->req_handle);
- GNUNET_RPS_request_single_info_cancel (pending_rep->req_handle);
- pending_rep->req_handle = NULL;
- GNUNET_free (pending_rep);
- pending_rep = NULL;
-}
-
-
-void
-clean_peer (unsigned peer_index)
-{
- struct PendingRequest *pending_req;
-
- while (NULL != (pending_req = rps_peers[peer_index].pending_req_head))
- {
- cancel_pending_req (pending_req);
- }
- pending_req = rps_peers[peer_index].pending_req_head;
- rps_disconnect_adapter (&rps_peers[peer_index],
- &rps_peers[peer_index].rps_handle);
- for (unsigned stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- if (NULL != rps_peers[peer_index].h_stat_get[stat_type])
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "(%u) did not yet receive stat value for `%s'\n",
- rps_peers[peer_index].index,
- stat_type_strings[stat_type]);
- GNUNET_STATISTICS_get_cancel (
- rps_peers[peer_index].h_stat_get[stat_type]);
- }
- }
- if (NULL != rps_peers[peer_index].op)
- {
- GNUNET_TESTBED_operation_done (rps_peers[peer_index].op);
- rps_peers[peer_index].op = NULL;
- }
-}
-
-
-/**
- * Task run on timeout to shut everything down.
- */
-static void
-shutdown_op (void *cls)
-{
- unsigned int i;
- struct OpListEntry *entry;
-
- (void) cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutdown task scheduled, going down.\n");
- in_shutdown = GNUNET_YES;
-
- if (NULL != shutdown_task)
- {
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = NULL;
- }
- if (NULL != post_test_task)
- {
- GNUNET_SCHEDULER_cancel (post_test_task);
- post_test_task = NULL;
- }
- if (NULL != churn_task)
- {
- GNUNET_SCHEDULER_cancel (churn_task);
- churn_task = NULL;
- }
- entry = oplist_head;
- while (NULL != (entry = oplist_head))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Operation still pending on shutdown (%u)\n",
- entry->index);
- GNUNET_TESTBED_operation_done (entry->op);
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_free (entry);
- }
- for (i = 0; i < num_peers; i++)
- {
- clean_peer (i);
- }
- close_all_files ();
-}
-
-
-static void
-trigger_shutdown (void *cls)
-{
- (void) cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutdown was triggered by timeout, going down.\n");
- shutdown_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Task run after #duration to collect statistics and potentially shut down.
- */
-static void
-post_test_op (void *cls)
-{
- unsigned int i;
-
- (void) cls;
-
- post_test_task = NULL;
- post_test = GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Executing post test op.\n");
- if (NULL != churn_task)
- {
- GNUNET_SCHEDULER_cancel (churn_task);
- churn_task = NULL;
- }
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Executing post test op. (peer %" PRIu32 ")\n",
- rps_peers[i].index);
- if (NULL != rps_peers[i].op)
- {
- GNUNET_TESTBED_operation_done (rps_peers[i].op);
- rps_peers[i].op = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelled testbed operation\n");
- }
- if (NULL != cur_test_run.post_test)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n",
- i);
- cur_test_run.post_test (&rps_peers[i]);
- }
- }
- /* If we do not collect statistics, shut down directly */
- if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) ||
- (GNUNET_YES == check_statistics_collect_completed ()) )
- {
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
- }
-}
-
-
-/**
- * Get the id of peer i.
- */
-void
-info_cb (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
-
- (void) op;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- if ((NULL == pinfo) || (NULL != emsg))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
- GNUNET_TESTBED_operation_done (entry->op);
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u is %s\n",
- entry->index,
- GNUNET_i2s (pinfo->result.id));
-
- rps_peer_ids[entry->index] = *(pinfo->result.id);
- rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index];
-
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (peer_map,
- &rps_peer_ids[entry->index],
- &rps_peers[entry->index],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- tofile ("/tmp/rps/peer_ids",
- "%u\t%s\n",
- entry->index,
- GNUNET_i2s_full (&rps_peer_ids[entry->index]));
-
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_TESTBED_operation_done (entry->op);
- GNUNET_free (entry);
-}
-
-
-/**
- * Callback to be called when RPS service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the RPS service handle returned from rps_connect_adapter
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-rps_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct RPSPeer *rps_peer = cls;
- struct GNUNET_RPS_Handle *rps = ca_result;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- rps_peer->rps_handle = rps;
- rps_peer->online = GNUNET_YES;
- num_peers_online++;
-
- GNUNET_assert (op == rps_peer->op);
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to RPS service: %s\n",
- emsg);
- ok = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Started client successfully (%u)\n",
- rps_peer->index);
-
- cur_test_run.main_test (rps_peer);
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * the RPS service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-rps_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_RPS_Handle *h;
-
- h = GNUNET_RPS_connect (cfg);
-
- if (NULL != cur_test_run.pre_test)
- cur_test_run.pre_test (cls, h);
-
- return h;
-}
-
-
-/**
- * Called to open a connection to the peer's statistics
- *
- * @param cls peer context
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-stat_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct RPSPeer *peer = cls;
-
- peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg);
- return peer->stats_h;
-}
-
-
-/**
- * Called to disconnect from peer's statistics service
- *
- * @param cls peer context
- * @param op_result service handle returned from the connect adapter
- */
-static void
-stat_disconnect_adapter (void *cls, void *op_result)
-{
- struct RPSPeer *peer = cls;
-
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
- // (peer->stats_h, "core", "# peers connected",
- // stat_iterator, peer));
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
- // (peer->stats_h, "nse", "# peers connected",
- // stat_iterator, peer));
- GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
- peer->stats_h = NULL;
-}
-
-
-/**
- * Called after successfully opening a connection to a peer's statistics
- * service; we register statistics monitoring for CORE and NSE here.
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-stat_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- // struct GNUNET_STATISTICS_Handle *sh = ca_result;
- // struct RPSPeer *peer = (struct RPSPeer *) cls;
- (void) cls;
- (void) op;
- (void) ca_result;
-
- if (NULL != emsg)
- {
- GNUNET_break (0);
- return;
- }
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
- // (sh, "core", "# peers connected",
- // stat_iterator, peer));
- // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
- // (sh, "nse", "# peers connected",
- // stat_iterator, peer));
-}
-
-
-/**
- * Adapter function called to destroy connection to
- * RPS service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-rps_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct RPSPeer *peer = cls;
- struct GNUNET_RPS_Handle *h = op_result;
- struct PendingReply *pending_rep;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "disconnect_adapter (%u)\n",
- peer->index);
- GNUNET_assert (NULL != peer);
- if (NULL != peer->rps_handle)
- {
- while (NULL != (pending_rep = peer->pending_rep_head))
- {
- cancel_request (pending_rep);
- }
- GNUNET_assert (h == peer->rps_handle);
- if (NULL != h)
- {
- GNUNET_RPS_disconnect (h);
- h = NULL;
- }
- peer->rps_handle = NULL;
- }
-}
-
-
-/***********************************************************************
-* Definition of tests
-***********************************************************************/
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-default_reply_handle (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers)
-{
- struct RPSPeer *rps_peer;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
- unsigned int i;
-
- rps_peer = pending_rep->rps_peer;
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got %" PRIu64 " peers:\n",
- GNUNET_i2s (rps_peer->peer_id),
- n);
-
- for (i = 0; i < n; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u: %s\n",
- i,
- GNUNET_i2s (&recv_peers[i]));
-
- rps_peer->num_recv_ids++;
- }
-
- if (GNUNET_YES != post_test)
- return;
- if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit)
- return;
- if (0 == evaluate ())
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test succeeded before end of duration\n");
- if (NULL != post_test_task)
- GNUNET_SCHEDULER_cancel (post_test_task);
- post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL);
- GNUNET_assert (NULL != post_test_task);
- }
-}
-
-
-static void
-profiler_reply_handle_info (void *cls,
- const struct GNUNET_PeerIdentity *recv_peer,
- double probability,
- uint32_t num_observed);
-
-/**
- * Request random peers.
- */
-static void
-request_peers (void *cls)
-{
- struct PendingRequest *pending_req = cls;
- struct RPSPeer *rps_peer;
- struct PendingReply *pending_rep;
-
- rps_peer = pending_req->rps_peer;
- GNUNET_assert (1 <= rps_peer->num_pending_reqs);
- GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs--;
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting one peer\n");
- pending_rep = GNUNET_new (struct PendingReply);
- pending_rep->rps_peer = rps_peer;
- // pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle,
- // 1,
- // cur_test_run.reply_handle,
- // pending_rep);
- pending_rep->req_handle = GNUNET_RPS_request_peer_info (rps_peer->rps_handle,
- profiler_reply_handle_info,
- pending_rep);
- GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head,
- rps_peer->pending_rep_tail,
- pending_rep);
- rps_peer->num_pending_reps++;
-}
-
-
-/**
- * Schedule requests for peer @a rps_peer that have neither been scheduled, nor
- * issued, nor replied
- */
-void
-schedule_missing_requests (struct RPSPeer *rps_peer)
-{
- unsigned int i;
- struct PendingRequest *pending_req;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Scheduling %u - %u missing requests\n",
- rps_peer->num_ids_to_request,
- rps_peer->num_pending_reqs + rps_peer->num_pending_reps);
- GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <=
- rps_peer->num_ids_to_request);
- for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps;
- i < rps_peer->num_ids_to_request; i++)
- {
- pending_req = GNUNET_new (struct PendingRequest);
- pending_req->rps_peer = rps_peer;
- pending_req->request_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- cur_test_run.request_interval * i),
- request_peers,
- pending_req);
- GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head,
- rps_peer->pending_req_tail,
- pending_req);
- rps_peer->num_pending_reqs++;
- }
-}
-
-
-void
-cancel_pending_req_rep (struct RPSPeer *rps_peer)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cancelling all (pending) requests.\n");
- while (NULL != rps_peer->pending_req_head)
- cancel_pending_req (rps_peer->pending_req_head);
- GNUNET_assert (0 == rps_peer->num_pending_reqs);
- while (NULL != rps_peer->pending_rep_head)
- cancel_request (rps_peer->pending_rep_head);
- GNUNET_assert (0 == rps_peer->num_pending_reps);
-}
-
-
-/***********************************
-* MALICIOUS
-***********************************/
-
-///**
-// * Initialise only non-mal RPSPeers
-// */
-//static void
-//mal_init_peer (struct RPSPeer *rps_peer)
-//{
-// if (rps_peer->index >= round (portion * num_peers))
-// rps_peer->num_ids_to_request = 1;
-//}
-
-
-///**
-// * @brief Set peers to (non-)malicious before execution
-// *
-// * Of signature #PreTest
-// *
-// * @param rps_peer the peer to set (non-) malicious
-// * @param h the handle to the service
-// */
-//static void
-//mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-//{
-// #if ENABLE_MALICIOUS
-// uint32_t num_mal_peers;
-//
-// GNUNET_assert ((1 >= portion) &&
-// (0 < portion));
-// num_mal_peers = round (portion * num_peers);
-//
-// if (rps_peer->index < num_mal_peers)
-// {
-// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-// "%u. peer [%s] of %" PRIu32
-// " malicious peers turning malicious\n",
-// rps_peer->index,
-// GNUNET_i2s (rps_peer->peer_id),
-// num_mal_peers);
-//
-// GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
-// rps_peer_ids, target_peer);
-// }
-// #endif /* ENABLE_MALICIOUS */
-//}
-
-
-// static void
-// mal_cb (struct RPSPeer *rps_peer)
-// {
-// if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-// {
-// return;
-// }
-//
-// #if ENABLE_MALICIOUS
-// uint32_t num_mal_peers;
-//
-// GNUNET_assert ((1 >= portion) &&
-// (0 < portion));
-// num_mal_peers = round (portion * num_peers);
-//
-// if (rps_peer->index >= num_mal_peers)
-// { /* It's useless to ask a malicious peer about a random sample -
-// it's not sampling */
-// GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
-// GNUNET_TIME_UNIT_SECONDS, 2),
-// seed_peers, rps_peer);
-// schedule_missing_requests (rps_peer);
-// }
-// #endif /* ENABLE_MALICIOUS */
-// }
-
-
-/***********************************
-* CHURN
-***********************************/
-
-static void
-churn (void *cls);
-
-
-/***********************************
-* PROFILER
-***********************************/
-
-/**
- * Callback to be called when RPS service is started or stopped at peers
- *
- * @param cls NULL
- * @param op the operation handle
- * @param emsg NULL on success; otherwise an error description
- */
-static void
-churn_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- // FIXME
- struct OpListEntry *entry = cls;
-
- (void) op;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- GNUNET_TESTBED_operation_done (entry->op);
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to start/stop RPS at a peer\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_assert (0 != entry->delta);
-
- num_peers_online += entry->delta;
-
- if (PEER_GO_OFFLINE == entry->delta)
- { /* Peer hopefully just went offline */
- if (GNUNET_YES != rps_peers[entry->index].online)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "peer %s was expected to go offline but is still marked as online\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- GNUNET_break (0);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "peer %s probably went offline as expected\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- }
- rps_peers[entry->index].online = GNUNET_NO;
- }
-
- else if (PEER_GO_ONLINE < entry->delta)
- { /* Peer hopefully just went online */
- if (GNUNET_NO != rps_peers[entry->index].online)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "peer %s was expected to go online but is still marked as offline\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- GNUNET_break (0);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "peer %s probably went online as expected\n",
- GNUNET_i2s (rps_peers[entry->index].peer_id));
- if (NULL != cur_test_run.pre_test)
- {
- cur_test_run.pre_test (&rps_peers[entry->index],
- rps_peers[entry->index].rps_handle);
- schedule_missing_requests (&rps_peers[entry->index]);
- }
- }
- rps_peers[entry->index].online = GNUNET_YES;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid value for delta: %i\n", entry->delta);
- GNUNET_break (0);
- }
-
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- rps_peers[entry->index].entry_op_manage = NULL;
- GNUNET_free (entry);
- // if (num_peers_in_round[current_round] == peers_running)
- // run_round ();
-}
-
-
-/**
- * @brief Set the rps-service up or down for a specific peer
- *
- * @param i index of action
- * @param j index of peer
- * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
- * @param prob_go_on_off the probability of the action
- */
-static void
-manage_service_wrapper (unsigned int i, unsigned int j,
- enum PEER_ONLINE_DELTA delta,
- double prob_go_on_off)
-{
- struct OpListEntry *entry = NULL;
- uint32_t prob;
-
- /* make sure that management operation is not already scheduled */
- if (NULL != rps_peers[j].entry_op_manage)
- {
- return;
- }
-
- prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u. selected peer (%u: %s) is %s.\n",
- i,
- j,
- GNUNET_i2s (rps_peers[j].peer_id),
- (PEER_GO_ONLINE == delta) ? "online" : "offline");
- if (prob < prob_go_on_off * UINT32_MAX)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s goes %s\n",
- GNUNET_i2s (rps_peers[j].peer_id),
- (PEER_GO_OFFLINE == delta) ? "offline" : "online");
-
- if (PEER_GO_OFFLINE == delta)
- cancel_pending_req_rep (&rps_peers[j]);
- entry = make_oplist_entry ();
- entry->delta = delta;
- entry->index = j;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- testbed_peers[j],
- "rps",
- &churn_cb,
- entry,
- (PEER_GO_OFFLINE == delta) ?
- 0 : 1);
- rps_peers[j].entry_op_manage = entry;
- }
-}
-
-
-static void
-churn (void *cls)
-{
- unsigned int i;
- unsigned int j;
- double portion_online;
- unsigned int *permut;
- double prob_go_offline;
- double portion_go_online;
- double portion_go_offline;
-
- (void) cls;
-
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Churn function executing\n");
-
- churn_task = NULL; /* Should be invalid by now */
-
- /* Compute the probability for an online peer to go offline
- * this round */
- portion_online = num_peers_online * 1.0 / num_peers;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion online: %f\n",
- portion_online);
- portion_go_online = ((1 - portion_online) * .5 * .66);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion that should go online: %f\n",
- portion_go_online);
- portion_go_offline = (portion_online + portion_go_online) - .75;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Portion that probably goes offline: %f\n",
- portion_go_offline);
- prob_go_offline = portion_go_offline / (portion_online * .5);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Probability of a selected online peer to go offline: %f\n",
- prob_go_offline);
-
- permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
- (unsigned int) num_peers);
-
- /* Go over 50% randomly chosen peers */
- for (i = 0; i < .5 * num_peers; i++)
- {
- j = permut[i];
-
- /* If online, shut down with certain probability */
- if (GNUNET_YES == rps_peers[j].online)
- {
- manage_service_wrapper (i, j, -1, prob_go_offline);
- }
-
- /* If offline, restart with certain probability */
- else if (GNUNET_NO == rps_peers[j].online)
- {
- manage_service_wrapper (i, j, 1, 0.66);
- }
- }
-
- GNUNET_free (permut);
-
- churn_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
- churn,
- NULL);
-}
-
-
-/**
- * Initialise given RPSPeer
- */
-static void
-profiler_init_peer (struct RPSPeer *rps_peer)
-{
- rps_peer->num_ids_to_request = cur_test_run.num_requests;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n",
- rps_peer->num_ids_to_request);
-}
-
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-profiler_reply_handle (void *cls,
- uint64_t n,
- const struct GNUNET_PeerIdentity *recv_peers)
-{
- struct RPSPeer *rps_peer;
- struct RPSPeer *rcv_rps_peer;
- char file_name_buf[128];
- char file_name_dh_buf[128];
- char file_name_dhr_buf[128];
- char file_name_dhru_buf[128];
- char *file_name = file_name_buf;
- char *file_name_dh = file_name_dh_buf;
- char *file_name_dhr = file_name_dhr_buf;
- char *file_name_dhru = file_name_dhru_buf;
- unsigned int i;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
-
- pending_rep->req_handle = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
- rps_peer = pending_rep->rps_peer;
- (void) GNUNET_asprintf (&file_name,
- "/tmp/rps/received_ids-%u",
- rps_peer->index);
-
- (void) GNUNET_asprintf (&file_name_dh,
- "/tmp/rps/diehard_input-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhr,
- "/tmp/rps/diehard_input_raw-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhru,
- "/tmp/rps/diehard_input_raw_aligned-%u",
- rps_peer->index);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got %" PRIu64 " peers:\n",
- GNUNET_i2s (rps_peer->peer_id),
- n);
- for (i = 0; i < n; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u: %s\n",
- i,
- GNUNET_i2s (&recv_peers[i]));
- tofile (file_name,
- "%s\n",
- GNUNET_i2s_full (&recv_peers[i]));
- rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]);
- GNUNET_assert (NULL != rcv_rps_peer);
- tofile (file_name_dh,
- "%" PRIu32 "\n",
- (uint32_t) rcv_rps_peer->index);
-#ifdef TO_FILE
- to_file_raw (file_name_dhr,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t));
- to_file_raw_unaligned (file_name_dhru,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t),
- bits_needed);
-#endif /* TO_FILE */
- }
- default_reply_handle (cls, n, recv_peers);
-}
-
-
-/**
- * Callback to call on receipt of a reply
- *
- * @param cls closure
- * @param n number of peers
- * @param recv_peers the received peers
- */
-static void
-profiler_reply_handle_info (void *cls,
- const struct GNUNET_PeerIdentity *recv_peer,
- double probability,
- uint32_t num_observed)
-{
- struct RPSPeer *rps_peer;
- struct RPSPeer *rcv_rps_peer;
- char file_name_buf[128];
- char file_name_dh_buf[128];
- char file_name_dhr_buf[128];
- char file_name_dhru_buf[128];
- char *file_name = file_name_buf;
- char *file_name_dh = file_name_dh_buf;
- char *file_name_dhr = file_name_dhr_buf;
- char *file_name_dhru = file_name_dhru_buf;
- struct PendingReply *pending_rep = (struct PendingReply *) cls;
-
- pending_rep->req_handle = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
- rps_peer = pending_rep->rps_peer;
- (void) GNUNET_asprintf (&file_name,
- "/tmp/rps/received_ids-%u",
- rps_peer->index);
-
- (void) GNUNET_asprintf (&file_name_dh,
- "/tmp/rps/diehard_input-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhr,
- "/tmp/rps/diehard_input_raw-%u",
- rps_peer->index);
- (void) GNUNET_asprintf (&file_name_dhru,
- "/tmp/rps/diehard_input_raw_aligned-%u",
- rps_peer->index);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "[%s] got peer with info:\n",
- GNUNET_i2s (rps_peer->peer_id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " %s\n",
- GNUNET_i2s (recv_peer));
- tofile (file_name,
- "%s %f %" PRIu32 " \n",
- GNUNET_i2s_full (recv_peer),
- probability,
- num_observed);
- rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, recv_peer);
- GNUNET_assert (NULL != rcv_rps_peer);
- tofile (file_name_dh,
- "%" PRIu32 "\n",
- (uint32_t) rcv_rps_peer->index);
-#ifdef TO_FILE
- to_file_raw (file_name_dhr,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t));
- to_file_raw_unaligned (file_name_dhru,
- (char *) &rcv_rps_peer->index,
- sizeof(uint32_t),
- bits_needed);
-#endif /* TO_FILE */
- default_reply_handle (cls, 1, recv_peer);
-}
-
-
-static void
-profiler_cb (struct RPSPeer *rps_peer)
-{
- if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
- {
- return;
- }
-
- /* Start churn */
- if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting churn task\n");
- churn_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
- churn,
- NULL);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Not starting churn task\n");
- }
-
- /* Only request peer ids at one peer.
- * (It's the before-last because last one is target of the focused attack.)
- */
- if (0 < rps_peer->num_ids_to_request)
- schedule_missing_requests (rps_peer);
-}
-
-
-/**
- * Function called from #profiler_eval with a filename.
- *
- * @param cls closure
- * @param filename complete filename (absolute path)
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_NO to stop iteration with no error,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-file_name_cb (void *cls, const char *filename)
-{
- if (NULL != strstr (filename, "sampler_el"))
- {
- struct RPS_SamplerElement *s_elem;
- struct GNUNET_CRYPTO_AuthKey auth_key;
- const char *key_char;
- uint32_t i;
- (void) cls;
-
- key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */
- tofile (filename, "--------------------------\n");
-
- auth_key = string_to_auth_key (key_char);
- s_elem = RPS_sampler_elem_create ();
- RPS_sampler_elem_set (s_elem, auth_key);
-
- for (i = 0; i < num_peers; i++)
- {
- RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]);
- }
- RPS_sampler_elem_destroy (s_elem);
- }
- return GNUNET_OK;
-}
-
-
-/**
- * This is run after the test finished.
- *
- * Compute all perfect samples.
- */
-static int
-profiler_eval (void)
-{
-#ifdef TO_FILE
- /* Compute perfect sample for each sampler element */
- if (-1 == GNUNET_DISK_directory_scan ("/tmp/rps/", file_name_cb, NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n");
- }
-#endif /* TO_FILE */
-
- return evaluate ();
-}
-
-
-/** @brief is b in view of a?
- *
- * @param a
- * @param b
- *
- * @return
- */
-static int
-is_in_view (uint32_t a, uint32_t b)
-{
- uint32_t i;
-
- for (i = 0; i < rps_peers[a].cur_view_count; i++)
- {
- if (0 == memcmp (rps_peers[b].peer_id,
- &rps_peers[a].cur_view[i],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- return GNUNET_YES;
- }
- }
- return GNUNET_NO;
-}
-
-
-static uint32_t
-get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++)
- {
- if (0 == memcmp (pid,
- rps_peers[i].peer_id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- return i;
- }
- }
- // return 0; /* Should not happen - make compiler happy */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No known _PeerIdentity %s!\n",
- GNUNET_i2s_full (pid));
- GNUNET_assert (0);
-}
-
-
-/**
- * @brief Counts number of peers in view of a that have b in their view
- *
- * @param a
- * @param b
- *
- * @return
- */
-static uint32_t
-count_containing_views (uint32_t a, uint32_t b)
-{
- uint32_t i;
- uint32_t peer_idx;
- uint32_t count = 0;
-
- for (i = 0; i < rps_peers[a].cur_view_count; i++)
- {
- peer_idx = get_idx_of_pid (&rps_peers[a].cur_view[i]);
- if (GNUNET_YES == is_in_view (peer_idx, b))
- {
- count++;
- }
- }
- return count;
-}
-
-
-/**
- * @brief Computes the probability for each other peer to be selected by the
- * sampling process based on the views of all peers
- *
- * @param peer_idx index of the peer that is about to sample
- */
-static void
-compute_probabilities (uint32_t peer_idx)
-{
- // double probs[num_peers] = { 0 };
- double probs[num_peers];
- double probs_hist[num_peers]; /* Probability respecting the history */
- size_t probs_as_str_size = (num_peers * 10 + 2) * sizeof(char);
- char *probs_as_str = GNUNET_malloc (probs_as_str_size);
- char *probs_as_str_cpy;
- uint32_t i;
- double prob_push;
- double prob_pull;
- uint32_t view_size;
- uint32_t cont_views;
- uint32_t number_of_being_in_pull_events;
- int tmp;
- double sum_non_zero_prob = 0;
- double sum_non_zero_prob_hist = 0;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Computing probabilities for peer %" PRIu32 "\n", peer_idx);
- /* Firstly without knowledge of old views */
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\tfor peer %" PRIu32 ":\n", i);
- view_size = rps_peers[i].cur_view_count;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tview_size: %" PRIu32 "\n", view_size);
- /* For peer i the probability of being sampled is
- * evenly distributed among all possibly observed peers. */
- /* We could have observed a peer in three cases:
- * 1. peer sent a push
- * 2. peer was contained in a pull reply
- * 3. peer was in history (sampler) - ignored for now */
- /* 1. Probability of having received a push from peer i */
- if ((GNUNET_YES == is_in_view (i, peer_idx)) &&
- (1 <= (0.45 * view_size)))
- {
- if (0 == binom (view_size, 0.45 * view_size))
- prob_push = 0;
- else
- {
- prob_push = 1.0 * binom (0.45 * view_size, 1)
- /
- binom (view_size, 0.45 * view_size);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n",
- peer_idx,
- i,
- prob_push);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tposs choices from view: %" PRIu32 ", containing i: %"
- PRIu32 "\n",
- binom (view_size, 0.45 * view_size),
- binom (0.45 * view_size, 1));
- }
- else
- {
- prob_push = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n",
- peer_idx,
- i);
- }
- /* 2. Probability of peer i being contained in pulls */
- view_size = rps_peers[peer_idx].cur_view_count;
- cont_views = count_containing_views (peer_idx, i);
- number_of_being_in_pull_events =
- (binom (view_size, 0.45 * view_size)
- - binom (view_size - cont_views, 0.45 * view_size));
- if (0 != number_of_being_in_pull_events)
- {
- prob_pull = number_of_being_in_pull_events
- /
- (1.0 * binom (view_size, 0.45 * view_size));
- }
- else
- {
- prob_pull = 0;
- }
- probs[i] = prob_push + prob_pull - (prob_push * prob_pull);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32
- " peers in its view who know %" PRIu32 " prob: %f\n",
- peer_idx,
- cont_views,
- view_size,
- i,
- prob_pull);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations: %" PRIu32 "\n",
- binom (view_size, 0.45 * view_size));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations without %" PRIu32
- ": %" PRIu32 "\n",
- i,
- binom (view_size - cont_views, 0.45 * view_size));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t\tnumber of possible pull combinations with %" PRIu32
- ": %" PRIu32 "\n",
- i,
- number_of_being_in_pull_events);
-
- probs_hist[i] = 0.9 * rps_peers[peer_idx].eval_probs_cache[i] + probs[i];
- rps_peers[peer_idx].eval_probs_cache[i] = probs_hist[i];
-
- sum_non_zero_prob += probs[i];
- sum_non_zero_prob_hist += probs_hist[i];
- }
- /* normalize */
- if (0 != sum_non_zero_prob)
- {
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = probs[i] * (1.0 / sum_non_zero_prob);
- }
- }
- if (0 != sum_non_zero_prob_hist)
- {
- for (i = 0; i < num_peers; i++)
- {
- probs_hist[i] = probs_hist[i] * (1.0 / sum_non_zero_prob_hist);
- }
- }
-
- /* str repr */
- for (i = 0; i < num_peers; i++)
- {
- probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
- tmp = GNUNET_snprintf (probs_as_str,
- probs_as_str_size,
- "%s %7.6f", probs_as_str_cpy, probs[i]);
- GNUNET_free (probs_as_str_cpy);
- GNUNET_assert (0 <= tmp);
- }
-
- to_file_w_len (rps_peers[peer_idx].file_name_probs,
- probs_as_str_size,
- "%s",
- probs_as_str);
-
- probs_as_str[0] = '\0';
- for (i = 0; i < num_peers; i++)
- {
- probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
- tmp = GNUNET_snprintf (probs_as_str,
- probs_as_str_size,
- "%s %7.6f", probs_as_str_cpy, probs_hist[i]);
- GNUNET_free (probs_as_str_cpy);
- GNUNET_assert (0 <= tmp);
- }
-
- to_file_w_len (rps_peers[peer_idx].file_name_probs_hist,
- probs_as_str_size,
- "%s",
- probs_as_str);
- GNUNET_free (probs_as_str);
-}
-
-
-/**
- * @brief This counts the number of peers in which views a given peer occurs.
- *
- * It also stores this value in the rps peer.
- *
- * @param peer_idx the index of the peer to count the representation
- *
- * @return the number of occurrences
- */
-static uint32_t
-count_peer_in_views_2 (uint32_t peer_idx)
-{
- uint32_t i, j;
- uint32_t count = 0;
-
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
- {
- if (0 == memcmp (rps_peers[peer_idx].peer_id,
- &rps_peers[i].cur_view[j],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- count++;
- break;
- }
- }
- }
- rps_peers[peer_idx].count_in_views = count;
- return count;
-}
-
-
-static uint32_t
-cumulated_view_sizes ()
-{
- uint32_t i;
-
- view_sizes = 0;
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- view_sizes += rps_peers[i].cur_view_count;
- }
- return view_sizes;
-}
-
-
-static void
-count_peer_in_views (uint32_t *count_peers)
-{
- uint32_t i, j;
-
- for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
- {
- for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
- {
- if (0 == memcmp (rps_peers[i].peer_id,
- &rps_peers[i].cur_view[j],
- sizeof(struct GNUNET_PeerIdentity)))
- {
- count_peers[i]++;
- }
- }
- }
-}
-
-
-void
-compute_diversity ()
-{
- uint32_t i;
- /* ith entry represents the number of occurrences in other peer's views */
- uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t);
- uint32_t views_total_size;
- double expected;
- /* deviation from expected number of peers */
- double *deviation = GNUNET_new_array (num_peers, double);
-
- views_total_size = 0;
- expected = 0;
-
- /* For each peer count its representation in other peer's views*/
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- views_total_size += rps_peers[i].cur_view_count;
- count_peer_in_views (count_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32
- "\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- count_peers[i]);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "size of all views combined: %" PRIu32 "\n",
- views_total_size);
- expected = ((double) 1 / num_peers) * views_total_size;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Expected number of occurrences of each peer in all views: %f\n",
- expected);
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- deviation[i] = expected - count_peers[i];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deviation from expectation: %f\n", deviation[i]);
- }
- GNUNET_free (count_peers);
- GNUNET_free (deviation);
-}
-
-
-void
-print_view_sizes ()
-{
- uint32_t i;
-
- for (i = 0; i < num_peers; i++) /* Peer to count */
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].cur_view_count);
- }
-}
-
-
-void
-all_views_updated_cb ()
-{
- compute_diversity ();
- print_view_sizes ();
-}
-
-
-void
-view_update_cb (void *cls,
- uint64_t view_size,
- const struct GNUNET_PeerIdentity *peers)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "View was updated (%" PRIu64 ")\n", view_size);
- struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
- to_file ("/tmp/rps/view_sizes.txt",
- "%" PRIu32 " %" PRIu64 "",
- rps_peer->index,
- view_size);
- for (uint64_t i = 0; i < view_size; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\t%s\n", GNUNET_i2s (&peers[i]));
- }
- GNUNET_array_grow (rps_peer->cur_view,
- rps_peer->cur_view_count,
- view_size);
- // *rps_peer->cur_view = *peers;
- GNUNET_memcpy (rps_peer->cur_view,
- peers,
- view_size * sizeof(struct GNUNET_PeerIdentity));
- to_file ("/tmp/rps/count_in_views.txt",
- "%" PRIu32 " %" PRIu32 "",
- rps_peer->index,
- count_peer_in_views_2 (rps_peer->index));
- cumulated_view_sizes ();
- if (0 != view_size)
- {
- to_file ("/tmp/rps/repr.txt",
- "%" PRIu32 /* index */
- " %" PRIu32 /* occurrence in views */
- " %" PRIu32 /* view sizes */
- " %f" /* fraction of repr in views */
- " %f" /* average view size */
- " %f" /* prob of occurrence in view slot */
- " %f" "", /* exp frac of repr in views */
- rps_peer->index,
- count_peer_in_views_2 (rps_peer->index),
- view_sizes,
- count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */
- view_sizes / (view_size * 1.0), /* average view size */
- 1.0 / view_size, /* prob of occurrence in view slot */
- (1.0 / view_size) * (view_sizes / view_size) /* expected fraction of repr in views */
- );
- }
- compute_probabilities (rps_peer->index);
- all_views_updated_cb ();
-}
-
-
-static void
-pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-{
- rps_peer->file_name_probs =
- store_prefix_file_name (rps_peer->index, "probs");
- rps_peer->file_name_probs_hist =
- store_prefix_file_name (rps_peer->index, "probs_hist");
- rps_peer->eval_probs_cache = GNUNET_new_array (num_peers, double);
- memset (rps_peer->eval_probs_cache, 0, num_peers * sizeof (double));
- GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
-}
-
-void
-write_final_stats (void)
-{
- uint64_t sums[STAT_TYPE_MAX] = { 0 };
-
- for (uint32_t i = 0; i < num_peers; i++)
- {
- to_file ("/tmp/rps/final_stats.csv",
- "%" PRIu32 ", " /* index */
- "%s, %" /* id */
- PRIu64 ", %" /* rounds */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %" /* blocking */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %" /* recv */
- PRIu64 ", %" /* view size */
- PRIu64 ", %" /* known peers */
- PRIu64 ", %" /* valid peers */
- PRIu64 ", %" /* learned peers */
- PRIu64 ", %" /* pending online checks */
- PRIu64 ", %" /* unrequested pull replies */
- PRIu64 ", %" /* peers in push map */
- PRIu64 ", %" /* peers in pull map */
- PRIu64 ", %" /* peers in view */
- PRIu64 "\n" /* view size aim */,
- i,
- GNUNET_i2s (rps_peers[i].peer_id),
- rps_peers[i].stats[STAT_TYPE_ROUNDS],
- rps_peers[i].stats[STAT_TYPE_BLOCKS],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_SENT_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_SENT_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND],
- rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP_MH],
- rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP],
- rps_peers[i].stats[STAT_TYPE_VIEW_SIZE],
- rps_peers[i].stats[STAT_TYPE_KNOWN_PEERS],
- rps_peers[i].stats[STAT_TYPE_VALID_PEERS],
- rps_peers[i].stats[STAT_TYPE_LEARND_PEERS],
- rps_peers[i].stats[STAT_TYPE_PENDING_ONLINE_CHECKS],
- rps_peers[i].stats[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_PUSH_MAP],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_PULL_MAP],
- rps_peers[i].stats[STAT_TYPE_PEERS_IN_VIEW],
- rps_peers[i].stats[STAT_TYPE_VIEW_SIZE_AIM]);
- for (enum STAT_TYPE stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- sums[stat_type] += rps_peers[i].stats[stat_type];
- }
- }
- to_file ("/tmp/rps/final_stats.dat",
- "SUM %"
- PRIu64 " %" /* rounds */
- PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64
- " %" /* blocking */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
- PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %"
- PRIu64 ", %" /* recv */
- PRIu64 ", %" /* view size */
- PRIu64 ", %" /* known peers */
- PRIu64 ", %" /* valid peers */
- PRIu64 ", %" /* learned peers */
- PRIu64 ", %" /* pending online checks */
- PRIu64 ", %" /* unrequested pull replies */
- PRIu64 ", %" /* peers in push map */
- PRIu64 ", %" /* peers in pull map */
- PRIu64 ", %" /* peers in view */
- PRIu64 "\n" /* view size aim */,
- sums[STAT_TYPE_ROUNDS],
- sums[STAT_TYPE_BLOCKS],
- sums[STAT_TYPE_BLOCKS_MANY_PUSH],
- sums[STAT_TYPE_BLOCKS_NO_PUSH],
- sums[STAT_TYPE_BLOCKS_NO_PULL],
- sums[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
- sums[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
- sums[STAT_TYPE_ISSUED_PUSH_SEND],
- sums[STAT_TYPE_ISSUED_PUSH_SEND_MH],
- sums[STAT_TYPE_ISSUED_PULL_REQ],
- sums[STAT_TYPE_ISSUED_PULL_REQ_MH],
- sums[STAT_TYPE_ISSUED_PULL_REP],
- sums[STAT_TYPE_SENT_PUSH_SEND],
- sums[STAT_TYPE_SENT_PULL_REQ],
- sums[STAT_TYPE_SENT_PULL_REQ_MH],
- sums[STAT_TYPE_SENT_PULL_REP],
- sums[STAT_TYPE_RECV_PUSH_SEND],
- sums[STAT_TYPE_RECV_PUSH_SEND_MH],
- sums[STAT_TYPE_RECV_PULL_REQ],
- sums[STAT_TYPE_RECV_PULL_REQ_MH],
- sums[STAT_TYPE_RECV_PULL_REP],
- sums[STAT_TYPE_RECV_PULL_REP_MH],
- sums[STAT_TYPE_VIEW_SIZE],
- sums[STAT_TYPE_KNOWN_PEERS],
- sums[STAT_TYPE_VALID_PEERS],
- sums[STAT_TYPE_LEARND_PEERS],
- sums[STAT_TYPE_PENDING_ONLINE_CHECKS],
- sums[STAT_TYPE_UNREQUESTED_PULL_REPLIES],
- sums[STAT_TYPE_PEERS_IN_PUSH_MAP],
- sums[STAT_TYPE_PEERS_IN_PULL_MAP],
- sums[STAT_TYPE_PEERS_IN_VIEW],
- sums[STAT_TYPE_VIEW_SIZE_AIM]);
-}
-
-
-/**
- * Continuation called by #GNUNET_STATISTICS_get() functions.
- *
- * Remembers that this specific statistics value was received for this peer.
- * Checks whether all peers received their statistics yet.
- * Issues the shutdown.
- *
- * @param cls closure
- * @param success #GNUNET_OK if statistics were
- * successfully obtained, #GNUNET_SYSERR if not.
- */
-void
-post_test_shutdown_ready_cb (void *cls,
- int success)
-{
- struct STATcls *stat_cls = (struct STATcls *) cls;
- struct RPSPeer *rps_peer = stat_cls->rps_peer;
-
- rps_peer->h_stat_get[stat_cls->stat_type] = NULL;
- if (GNUNET_OK == success)
- {
- /* set flag that we we got the value */
- rps_peer->stat_collected_flags |= BIT (stat_cls->stat_type);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peer %u did not receive statistics value\n",
- rps_peer->index);
- GNUNET_free (stat_cls);
- GNUNET_break (0);
- return;
- }
-
- if ((NULL != rps_peer->stat_op) &&
- (GNUNET_YES == check_statistics_collect_completed_single_peer (
- rps_peer)) )
- {
- GNUNET_TESTBED_operation_done (rps_peer->stat_op);
- }
-
- write_final_stats ();
- if (GNUNET_YES == check_statistics_collect_completed ())
- {
- // write_final_stats ();
- GNUNET_free (stat_cls);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down\n");
- GNUNET_SCHEDULER_shutdown ();
- }
- else
- {
- GNUNET_free (stat_cls);
- }
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls closure
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-int
-stat_iterator (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- const struct STATcls *stat_cls = (const struct STATcls *) cls;
- struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
- enum STAT_TYPE stat_type;
-
- (void) subsystem;
- (void) is_persistent;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got stat value: %s - %" PRIu64 " (%u)\n",
- name,
- value,
- rps_peer->index);
- to_file (rps_peer->file_name_stats,
- "%s: %" PRIu64 "\n",
- name,
- value);
- stat_type = stat_str_2_type (name);
- GNUNET_assert (STAT_TYPE_ROUNDS <= stat_type &&
- STAT_TYPE_MAX > stat_type);
- rps_peer->stats[stat_type] = value;
- return GNUNET_OK;
-}
-
-
-void
-post_profiler (struct RPSPeer *rps_peer)
-{
- if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
- {
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going to request statistic values with mask 0x%" PRIx32 "\n",
- cur_test_run.stat_collect_flags);
-
- struct STATcls *stat_cls;
- uint32_t stat_type;
- for (stat_type = STAT_TYPE_ROUNDS;
- stat_type < STAT_TYPE_MAX;
- stat_type++)
- {
- if (BIT (stat_type) & cur_test_run.stat_collect_flags)
- {
- stat_cls = GNUNET_malloc (sizeof(struct STATcls));
- stat_cls->rps_peer = rps_peer;
- stat_cls->stat_type = stat_type;
- rps_peer->file_name_stats =
- store_prefix_file_name (rps_peer->index, "stats");
- rps_peer->h_stat_get[stat_type] =
- GNUNET_STATISTICS_get (rps_peer->stats_h,
- "rps",
- stat_type_strings [stat_type],
- post_test_shutdown_ready_cb,
- stat_iterator,
- (struct STATcls *) stat_cls);
- GNUNET_assert (NULL != rps_peer->h_stat_get);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requested statistics for %s (peer %" PRIu32 ")\n",
- stat_type_strings [stat_type],
- rps_peer->index);
- }
- }
- GNUNET_free (rps_peer->eval_probs_cache);
-}
-
-
-/***********************************************************************
-* /Definition of tests
-***********************************************************************/
-
-
-/**
- * Actual "main" function for the testcase.
- *
- * @param cls closure
- * @param h the run handle
- * @param n_peers number of peers in 'peers'
- * @param peers handle to peers run in the testbed
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int n_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- unsigned int i;
- struct OpListEntry *entry;
-
- (void) cls;
- (void) h;
- (void) links_failed;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
-
- /* Check whether we timed out */
- if ((n_peers != num_peers) ||
- (NULL == peers) ||
- (0 == links_succeeded) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going down due to args (eg. timeout)\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n",
- num_peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n",
- links_succeeded);
- ok = 1;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
-
- /* Initialize peers */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "going to initialise peers\n");
- testbed_peers = peers;
- num_peers_online = 0;
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "initialising %u\n", i);
- entry = make_oplist_entry ();
- entry->index = i;
- rps_peers[i].index = i;
- if (NULL != cur_test_run.init_peer)
- cur_test_run.init_peer (&rps_peers[i]);
- if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
- {
- rps_peers->cur_view_count = 0;
- rps_peers->cur_view = NULL;
- }
- entry->op = GNUNET_TESTBED_peer_get_information (peers[i],
- GNUNET_TESTBED_PIT_IDENTITY,
- &info_cb,
- entry);
- }
-
- /* Bring peers up */
- GNUNET_assert (num_peers == n_peers);
- for (i = 0; i < n_peers; i++)
- {
- rps_peers[i].index = i;
- rps_peers[i].op =
- GNUNET_TESTBED_service_connect (&rps_peers[i],
- peers[i],
- "rps",
- &rps_connect_complete_cb,
- &rps_peers[i],
- &rps_connect_adapter,
- &rps_disconnect_adapter,
- &rps_peers[i]);
- /* Connect all peers to statistics service */
- if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting to statistics service\n");
- rps_peers[i].stat_op =
- GNUNET_TESTBED_service_connect (NULL,
- peers[i],
- "statistics",
- stat_complete_cb,
- &rps_peers[i],
- &stat_connect_adapter,
- &stat_disconnect_adapter,
- &rps_peers[i]);
- }
- }
-
- if (NULL != churn_task)
- GNUNET_SCHEDULER_cancel (churn_task);
- post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n",
- timeout.rel_value_us / 1000000);
- shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout,
- &trigger_shutdown,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL);
-}
-
-
-/**
- * Entry point for the testcase, sets up the testbed.
- *
- * @param argc unused
- * @param argv unused
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- // int ret_value;
- (void) cls;
- (void) args;
- (void) cfgfile;
-
- /* Defaults for tests */
- churn_task = NULL;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
- cur_test_run.name = "test-rps-profiler";
- if (0 == num_peers)
- num_peers = 10;
- mal_type = 3;
- cur_test_run.init_peer = profiler_init_peer;
- // cur_test_run.pre_test = mal_pre;
- cur_test_run.pre_test = pre_profiler;
- cur_test_run.main_test = profiler_cb;
- cur_test_run.reply_handle = profiler_reply_handle;
- cur_test_run.eval_cb = profiler_eval;
- cur_test_run.post_test = post_profiler;
- cur_test_run.request_interval = 2;
- if (0 == cur_test_run.num_requests)
- cur_test_run.num_requests = 5;
- // cur_test_run.have_churn = HAVE_CHURN;
- cur_test_run.have_churn = HAVE_NO_CHURN;
- cur_test_run.have_quick_quit = HAVE_QUICK_QUIT;
- cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
- cur_test_run.stat_collect_flags = BIT (STAT_TYPE_ROUNDS)
- | BIT (STAT_TYPE_BLOCKS)
- | BIT (STAT_TYPE_BLOCKS_MANY_PUSH)
- | BIT (STAT_TYPE_BLOCKS_NO_PUSH)
- | BIT (STAT_TYPE_BLOCKS_NO_PULL)
- | BIT (STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL)
- | BIT (STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL)
- | BIT (STAT_TYPE_ISSUED_PUSH_SEND)
- | BIT (STAT_TYPE_ISSUED_PUSH_SEND_MH)
- | BIT (STAT_TYPE_ISSUED_PULL_REQ)
- | BIT (STAT_TYPE_ISSUED_PULL_REQ_MH)
- | BIT (STAT_TYPE_ISSUED_PULL_REP)
- | BIT (STAT_TYPE_SENT_PUSH_SEND)
- | BIT (STAT_TYPE_SENT_PULL_REQ)
- | BIT (STAT_TYPE_SENT_PULL_REQ_MH)
- | BIT (STAT_TYPE_SENT_PULL_REP)
- | BIT (STAT_TYPE_RECV_PUSH_SEND)
- | BIT (STAT_TYPE_RECV_PUSH_SEND_MH)
- | BIT (STAT_TYPE_RECV_PULL_REQ)
- | BIT (STAT_TYPE_RECV_PULL_REQ_MH)
- | BIT (STAT_TYPE_RECV_PULL_REP)
- | BIT (STAT_TYPE_RECV_PULL_REP_MH)
- | BIT (STAT_TYPE_VIEW_SIZE)
- | BIT (STAT_TYPE_KNOWN_PEERS)
- | BIT (STAT_TYPE_VALID_PEERS)
- | BIT (STAT_TYPE_LEARND_PEERS)
- | BIT (STAT_TYPE_PENDING_ONLINE_CHECKS)
- | BIT (STAT_TYPE_UNREQUESTED_PULL_REPLIES)
- | BIT (STAT_TYPE_PEERS_IN_PUSH_MAP)
- | BIT (STAT_TYPE_PEERS_IN_PULL_MAP)
- | BIT (STAT_TYPE_PEERS_IN_VIEW)
- | BIT (STAT_TYPE_VIEW_SIZE_AIM);
- cur_test_run.have_collect_view = COLLECT_VIEW;
-
- /* 'Clean' directory */
- (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
- GNUNET_DISK_directory_create ("/tmp/rps/");
- if (0 == duration.rel_value_us)
- {
- if (0 == timeout.rel_value_us)
- {
- duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90);
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- (90 * 1.2)
- + (0.01 * num_peers));
- }
- else
- {
- duration = GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS,
- ( (double) timeout.rel_value_us / (double) 1000000)
- * 0.75);
- }
- }
- else
- {
- if (0 == timeout.rel_value_us)
- {
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- ((duration.rel_value_us
- / 1000000)
- * 1.2) + (0.01 * num_peers));
- }
- }
- GNUNET_assert (duration.rel_value_us < timeout.rel_value_us);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "duration is %lus\n",
- duration.rel_value_us / 1000000);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "timeout is %lus\n",
- timeout.rel_value_us / 1000000);
-
- /* Compute number of bits for representing largest peer id */
- for (bits_needed = 1; (uint32_t) (1 << bits_needed) < num_peers; bits_needed++)
- ;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Need %u bits to represent %" PRIu32 " peers\n",
- bits_needed,
- num_peers);
-
- rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
- peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
- rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
- if ((2 == mal_type) ||
- (3 == mal_type))
- target_peer = &rps_peer_ids[num_peers - 2];
-
- ok = 1;
- GNUNET_TESTBED_run (NULL,
- cfg,
- num_peers,
- 0, /* event mask */
- NULL,
- NULL,
- &test_run,
- NULL);
-}
-
-
-/**
- * Entry point for the testcase, sets up the testbed.
- *
- * @param argc unused
- * @param argv unused
- * @return 0 on success
- */
-int
-main (int argc, char *argv[])
-{
- int ret_value;
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('n',
- "num-peers",
- "COUNT",
- gettext_noop ("number of peers to start"),
- &num_peers),
- GNUNET_GETOPT_option_relative_time ('d',
- "duration",
- "DURATION",
- gettext_noop (
- "duration of the profiling"),
- &duration),
- GNUNET_GETOPT_option_relative_time ('t',
- "timeout",
- "TIMEOUT",
- gettext_noop (
- "timeout for the profiling"),
- &timeout),
- GNUNET_GETOPT_option_uint ('r',
- "num-requests",
- "COUNT",
- gettext_noop ("number of PeerIDs to request"),
- &cur_test_run.num_requests),
- GNUNET_GETOPT_OPTION_END
- };
-
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
- // if (GNUNET_OK !=
- // GNUNET_STRINGS_get_utf8_args (argc, argv,
- // &argc, &argv))
- // return 2;
- ret_value = 0;
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-rps-profiler",
- gettext_noop (
- "Measure quality and performance of the RPS service."),
- options,
- &run,
- NULL))
- {
- ret_value = 1;
- }
- if (0 != ret_value)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Test did not run successfully!\n");
- }
- else
- {
- ret_value = cur_test_run.eval_cb ();
- if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
- {
- GNUNET_array_grow (rps_peers->cur_view,
- rps_peers->cur_view_count,
- 0);
- }
- GNUNET_free (rps_peers);
- GNUNET_free (rps_peer_ids);
- GNUNET_CONTAINER_multipeermap_destroy (peer_map);
- }
- return ret_value;
-}
-
-
-/* end of test_rps.c */
diff --git a/src/contrib/service/secretsharing/Makefile.am b/src/contrib/service/secretsharing/Makefile.am
index afc42309c..d9c2b37b4 100644
--- a/src/contrib/service/secretsharing/Makefile.am
+++ b/src/contrib/service/secretsharing/Makefile.am
@@ -16,23 +16,10 @@ endif
libexec_PROGRAMS = \
gnunet-service-secretsharing
-#noinst_PROGRAMS = \
-# gnunet-secretsharing-profiler
-
lib_LTLIBRARIES = \
libgnunetsecretsharing.la
-# TNG
-#gnunet_secretsharing_profiler_SOURCES = \
-# gnunet-secretsharing-profiler.c
-#gnunet_secretsharing_profiler_LDADD = \
-# libgnunetsecretsharing.la \
-# $(top_builddir)/src/service/testing/libgnunettesting.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(GN_LIBINTL)
-
gnunet_service_secretsharing_SOURCES = \
gnunet-service-secretsharing.c \
secretsharing_common.c \
diff --git a/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c b/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
deleted file mode 100644
index 432d6da89..000000000
--- a/src/contrib/service/secretsharing/gnunet-secretsharing-profiler.c
+++ /dev/null
@@ -1,662 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2014 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file secretsharing/gnunet-secretsharing-profiler.c
- * @brief profiling tool for distributed key generation and decryption
- * @author Florian Dold
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_secretsharing_service.h"
-#include "gnunet_testbed_service.h"
-
-/**
- * How many peers should participate in the key generation?
- */
-static unsigned int num_peers = 3;
-
-/**
- * What should the threshold for then key be?
- */
-static unsigned int threshold = 2;
-
-/**
- * Should we try to decrypt a value after the key generation?
- */
-static int decrypt = GNUNET_NO;
-
-/**
- * When would we like to see the operation finished?
- */
-static struct GNUNET_TIME_Relative timeout;
-
-/**
- * When should dkg communication start?
- */
-static struct GNUNET_TIME_Relative delay;
-
-/**
- * Handles for secretsharing sessions.
- */
-static struct GNUNET_SECRETSHARING_Session **session_handles;
-
-static struct GNUNET_SECRETSHARING_DecryptionHandle **decrypt_handles;
-
-/**
- * Shares we got from the distributed key generation.
- */
-static struct GNUNET_SECRETSHARING_Share **shares;
-
-static struct GNUNET_SECRETSHARING_PublicKey common_pubkey;
-
-
-static unsigned int num_connected_sessions;
-
-static unsigned int num_connected_decrypt;
-
-/**
- * Handles to the running peers.
- * When peers[i] is NULL, the i-th peer has stopped.
- */
-static struct GNUNET_TESTBED_Peer **peers;
-
-static struct GNUNET_PeerIdentity *peer_ids;
-
-static unsigned int num_retrieved_peer_ids;
-
-static unsigned int num_generated;
-
-static unsigned int num_decrypted;
-
-static struct GNUNET_HashCode session_id;
-
-static unsigned int verbose;
-
-static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext;
-
-static struct GNUNET_SECRETSHARING_Ciphertext ciphertext;
-
-static struct GNUNET_TIME_Absolute dkg_start;
-
-static struct GNUNET_TIME_Absolute dkg_deadline;
-
-
-static struct GNUNET_TIME_Absolute decrypt_start;
-
-static struct GNUNET_TIME_Absolute decrypt_deadline;
-
-/**
- * Connect operations, one for every peer.
- */
-static struct GNUNET_TESTBED_Operation **connect_ops;
-
-/**
- * Are we performing a shutdown right now?
- */
-static int in_shutdown;
-
-
-/**
- * Signature of the event handler function called by the
- * respective event controller.
- *
- * @param cls closure
- * @param event information about the event
- */
-static void
-controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- GNUNET_assert (0);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-session_connect_complete (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "testbed connect emsg: %s\n",
- emsg);
- GNUNET_assert (0);
- }
-
- num_connected_sessions++;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "dkg: session connect complete\n");
-
- if (num_connected_sessions == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "dkg: all peers connected\n");
- }
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-decrypt_connect_complete (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "testbed connect emsg: %s\n",
- emsg);
- GNUNET_assert (0);
- }
-
- num_connected_decrypt++;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt: session connect complete\n");
-
- if (num_connected_decrypt == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt: all peers connected\n");
- }
-}
-
-
-/**
- * Called when a decryption has succeeded.
- *
- * @param cls Plaintext
- * @param plaintext Plaintext
- */
-static void
-decrypt_cb (void *cls,
- const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **dhp = cls;
- unsigned int n = dhp - decrypt_handles;
-
- num_decrypted++;
-
- *dhp = NULL;
-
- // we should still be connected if this is called
- GNUNET_assert (NULL != connect_ops[n]);
-
- GNUNET_TESTBED_operation_done (connect_ops[n]);
-
- if (NULL == plaintext)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt failed for peer %u\n", n);
- return;
- }
- else if (0 == GNUNET_memcmp (&reference_plaintext, plaintext))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt got correct result for peer %u\n", n);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "decrypt got wrong result for peer %u\n", n);
-
- if (num_decrypted == num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "every peer decrypted\n");
- GNUNET_SCHEDULER_shutdown ();
- }
-
- *dhp = NULL;
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-decrypt_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **hp = cls;
- unsigned int n = hp - decrypt_handles;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "decrypt connect adapter, %d peers\n",
- num_peers);
- *hp = GNUNET_SECRETSHARING_decrypt (cfg, shares[n], &ciphertext,
- decrypt_start, decrypt_deadline,
- decrypt_cb,
- hp);
-
- return *hp;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-decrypt_disconnect_adapter (void *cls, void *op_result)
-{
- struct GNUNET_SECRETSHARING_DecryptionHandle **dh = cls;
- unsigned int n = dh - decrypt_handles;
-
- GNUNET_assert (*dh == decrypt_handles[n]);
-
- if (NULL != *dh)
- {
- GNUNET_SECRETSHARING_decrypt_cancel (*dh);
- *dh = NULL;
- }
-
- GNUNET_assert (NULL != connect_ops[n]);
- connect_ops[n] = NULL;
-}
-
-
-static void
-secret_ready_cb (void *cls,
- struct GNUNET_SECRETSHARING_Share *my_share,
- struct GNUNET_SECRETSHARING_PublicKey *public_key,
- unsigned int num_ready_peers,
- const struct GNUNET_PeerIdentity *ready_peers)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
- unsigned int n = sp - session_handles;
- char pubkey_str[1024];
- char *ret;
-
- num_generated++;
- *sp = NULL;
- shares[n] = my_share;
- if (NULL == my_share)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation failed for peer #%u\n",
- n);
- }
- else
- {
- ret = GNUNET_STRINGS_data_to_string (public_key, sizeof *public_key,
- pubkey_str, 1024);
- GNUNET_assert (NULL != ret);
- *ret = '\0';
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "key generation successful for peer #%u, pubkey %s\n", n,
- pubkey_str);
-
- /* we're the first to get the key -> store it */
- if (num_generated == 1)
- {
- common_pubkey = *public_key;
- }
- else if (0 != GNUNET_memcmp (public_key, &common_pubkey))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "generated public keys do not match\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- }
-
- // we should still be connected
- GNUNET_assert (NULL != connect_ops[n]);
-
- // disconnect from the service, will call the disconnect callback
- GNUNET_TESTBED_operation_done (connect_ops[n]);
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-session_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "connect adapter, %d peers\n",
- num_peers);
- *sp = GNUNET_SECRETSHARING_create_session (cfg,
- num_peers,
- peer_ids,
- &session_id,
- dkg_start,
- dkg_deadline,
- threshold,
- &secret_ready_cb, sp);
- return *sp;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-session_disconnect_adapter (void *cls, void *op_result)
-{
- struct GNUNET_SECRETSHARING_Session **sp = cls;
- unsigned int n = (sp - session_handles);
-
- GNUNET_assert (*sp == session_handles[n]);
-
- if (NULL != *sp)
- {
- GNUNET_SECRETSHARING_session_destroy (*sp);
- *sp = NULL;
- }
-
- GNUNET_assert (NULL != connect_ops[n]);
- connect_ops[n] = NULL;
-
- if (GNUNET_YES == in_shutdown)
- return;
-
- // all peers received their secret
- if (num_generated == num_peers)
- {
- int i;
-
- // only do decryption if requested by the user
- if (GNUNET_NO == decrypt)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- decrypt_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
- delay);
- decrypt_deadline = GNUNET_TIME_absolute_add (decrypt_start, timeout);
-
- // compute g^42 as the plaintext which we will decrypt and then
- // cooperatively decrypt
- GNUNET_SECRETSHARING_plaintext_generate_i (&reference_plaintext, 42);
- GNUNET_SECRETSHARING_encrypt (&common_pubkey, &reference_plaintext,
- &ciphertext);
-
- for (i = 0; i < num_peers; i++)
- connect_ops[i] =
- GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing",
- &decrypt_connect_complete, NULL,
- &decrypt_connect_adapter,
- &decrypt_disconnect_adapter,
- &decrypt_handles[i]);
- }
-}
-
-
-/**
- * Callback to be called when the requested peer information is available
- *
- * @param cb_cls the closure from GNUNET_TESTBED_peer_get_information()
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed; will be NULL if the
- * operation is successful
- */
-static void
-peer_info_cb (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct GNUNET_PeerIdentity *p;
- int i;
-
- GNUNET_assert (NULL == emsg);
-
- p = (struct GNUNET_PeerIdentity *) cb_cls;
-
- if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
- {
- *p = *pinfo->result.id;
- num_retrieved_peer_ids++;
- if (num_retrieved_peer_ids == num_peers)
- for (i = 0; i < num_peers; i++)
- connect_ops[i] =
- GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing",
- session_connect_complete, NULL,
- session_connect_adapter,
- session_disconnect_adapter,
- &session_handles[i]);
- }
- else
- {
- GNUNET_assert (0);
- }
-
- GNUNET_TESTBED_operation_done (op);
-}
-
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- */
-static void
-handle_shutdown (void *cls)
-{
- in_shutdown = GNUNET_YES;
-
- if (NULL != connect_ops)
- {
- unsigned int i;
- for (i = 0; i < num_peers; i++)
- if (NULL != connect_ops[i])
- {
- // the disconnect callback will set the op to NULL
- GNUNET_TESTBED_operation_done (connect_ops[i]);
- }
- GNUNET_free (connect_ops);
- }
-
- // killing the testbed operation will take care of remaining
- // service handles in the disconnect callback
-}
-
-
-/**
- * Signature of a main function for a testcase.
- *
- * @param cls closure
- * @param h the run handle
- * @param num_peers number of peers in 'peers'
- * @param started_peers handle to peers run in the testbed. NULL upon timeout (see
- * GNUNET_TESTBED_test_run()).
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_master (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **started_peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- int i;
-
- GNUNET_log_setup ("gnunet-secretsharing-profiler", "INFO", NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
-
- GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
-
- peers = started_peers;
-
- peer_ids = GNUNET_malloc (num_peers * sizeof(struct GNUNET_PeerIdentity));
-
- session_handles = GNUNET_new_array (num_peers, struct
- GNUNET_SECRETSHARING_Session *);
- decrypt_handles = GNUNET_new_array (num_peers, struct
- GNUNET_SECRETSHARING_DecryptionHandle *);
- connect_ops = GNUNET_new_array (num_peers, struct GNUNET_TESTBED_Operation *);
- shares = GNUNET_new_array (num_peers, struct GNUNET_SECRETSHARING_Share *);
-
- for (i = 0; i < num_peers; i++)
- {
- // we do not store the returned operation, as peer_info_cb
- // will receive it as a parameter and call GNUNET_TESTBED_operation_done.
- GNUNET_TESTBED_peer_get_information (peers[i],
- GNUNET_TESTBED_PIT_IDENTITY,
- peer_info_cb,
- &peer_ids[i]);
- }
-}
-
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- static char *session_str = "gnunet-secretsharing/test";
- char *topology;
- int topology_cmp_result;
-
- dkg_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay);
- dkg_deadline = GNUNET_TIME_absolute_add (dkg_start, timeout);
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
- "OVERLAY_TOPOLOGY",
- &topology))
- {
- fprintf (stderr,
- "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
- "seems like you passed the wrong configuration file\n");
- return;
- }
-
- topology_cmp_result = strcasecmp (topology, "NONE");
- GNUNET_free (topology);
-
- if (0 == topology_cmp_result)
- {
- fprintf (stderr,
- "'OVERLAY_TOPOLOGY' set to 'NONE', "
- "seems like you passed the wrong configuration file\n");
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "running gnunet-secretsharing-profiler\n");
-
- GNUNET_CRYPTO_hash (session_str, strlen (session_str), &session_id);
-
- (void) GNUNET_TESTBED_test_run ("gnunet-secretsharing-profiler",
- cfgfile,
- num_peers,
- 0,
- controller_cb,
- NULL,
- test_master,
- NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('n',
- "num-peers",
- NULL,
- gettext_noop ("number of peers in consensus"),
- &num_peers),
-
- GNUNET_GETOPT_option_relative_time ('D',
- "delay",
- NULL,
- gettext_noop ("dkg start delay"),
- &delay),
-
- GNUNET_GETOPT_option_relative_time ('t',
- "timeout",
- NULL,
- gettext_noop ("dkg timeout"),
- &timeout),
-
- GNUNET_GETOPT_option_uint ('k',
- "threshold",
- NULL,
- gettext_noop ("threshold"),
- &threshold),
-
- GNUNET_GETOPT_option_flag ('d',
- "descrypt",
- gettext_noop ("also profile decryption"),
- &decrypt),
-
-
- GNUNET_GETOPT_option_verbose (&verbose),
-
- GNUNET_GETOPT_OPTION_END
- };
-
- delay = GNUNET_TIME_UNIT_ZERO;
- timeout = GNUNET_TIME_UNIT_MINUTES;
- GNUNET_PROGRAM_run2 (argc, argv, "gnunet-secretsharing-profiler",
- "help",
- options, &run, NULL, GNUNET_YES);
- return 0;
-}
diff --git a/src/contrib/service/set/Makefile.am b/src/contrib/service/set/Makefile.am
index 88d4d39ad..d8e19e6d4 100644
--- a/src/contrib/service/set/Makefile.am
+++ b/src/contrib/service/set/Makefile.am
@@ -15,8 +15,7 @@ if USE_COVERAGE
endif
noinst_PROGRAMS = \
- gnunet-set-ibf-profiler \
- gnunet-set-profiler
+ gnunet-set-ibf-profiler
libexec_PROGRAMS = \
gnunet-service-set
@@ -24,16 +23,6 @@ libexec_PROGRAMS = \
lib_LTLIBRARIES = \
libgnunetset.la
-gnunet_set_profiler_SOURCES = \
- gnunet-set-profiler.c
-gnunet_set_profiler_LDADD = \
- $(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
- libgnunetset.la \
- $(top_builddir)/src/service/testing/libgnunettesting.la \
- $(GN_LIBINTL)
-
-
gnunet_set_ibf_profiler_SOURCES = \
gnunet-set-ibf-profiler.c \
ibf.c
diff --git a/src/contrib/service/set/gnunet-set-profiler.c b/src/contrib/service/set/gnunet-set-profiler.c
deleted file mode 100644
index 3014861a6..000000000
--- a/src/contrib/service/set/gnunet-set-profiler.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file set/gnunet-set-profiler.c
- * @brief profiling tool for set
- * @author Florian Dold
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-#include "gnunet_set_service.h"
-#include "gnunet_testbed_service.h"
-
-
-static int ret;
-
-static unsigned int num_a = 5;
-static unsigned int num_b = 5;
-static unsigned int num_c = 20;
-
-static char *op_str = "union";
-
-const static struct GNUNET_CONFIGURATION_Handle *config;
-
-struct SetInfo
-{
- char *id;
- struct GNUNET_SET_Handle *set;
- struct GNUNET_SET_OperationHandle *oh;
- struct GNUNET_CONTAINER_MultiHashMap *sent;
- struct GNUNET_CONTAINER_MultiHashMap *received;
- int done;
-} info1, info2;
-
-static struct GNUNET_CONTAINER_MultiHashMap *common_sent;
-
-static struct GNUNET_HashCode app_id;
-
-static struct GNUNET_PeerIdentity local_peer;
-
-static struct GNUNET_SET_ListenHandle *set_listener;
-
-static int byzantine;
-static unsigned int force_delta;
-static unsigned int force_full;
-static unsigned int element_size = 32;
-
-/**
- * Handle to the statistics service.
- */
-static struct GNUNET_STATISTICS_Handle *statistics;
-
-/**
- * The profiler will write statistics
- * for all peers to the file with this name.
- */
-static char *statistics_filename;
-
-/**
- * The profiler will write statistics
- * for all peers to this file.
- */
-static FILE *statistics_file;
-
-
-static int
-map_remove_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_CONTAINER_MultiHashMap *m = cls;
- int ret;
-
- GNUNET_assert (NULL != key);
-
- ret = GNUNET_CONTAINER_multihashmap_remove_all (m, key);
- if (GNUNET_OK != ret)
- printf ("spurious element\n");
- return GNUNET_YES;
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls closure
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static int
-statistics_result (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- if (NULL != statistics_file)
- {
- fprintf (statistics_file, "%s\t%s\t%lu\n", subsystem, name, (unsigned
- long) value);
- }
- return GNUNET_OK;
-}
-
-
-static void
-statistics_done (void *cls,
- int success)
-{
- GNUNET_assert (GNUNET_YES == success);
- if (NULL != statistics_file)
- fclose (statistics_file);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-check_all_done (void)
-{
- if ((info1.done == GNUNET_NO) || (info2.done == GNUNET_NO))
- return;
-
- GNUNET_CONTAINER_multihashmap_iterate (info1.received, map_remove_iterator,
- info2.sent);
- GNUNET_CONTAINER_multihashmap_iterate (info2.received, map_remove_iterator,
- info1.sent);
-
- printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info1.sent));
- printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info2.sent));
-
- if (NULL == statistics_filename)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- statistics_file = fopen (statistics_filename, "w");
- GNUNET_STATISTICS_get (statistics, NULL, NULL,
- &statistics_done,
- &statistics_result, NULL);
-}
-
-
-static void
-set_result_cb (void *cls,
- const struct GNUNET_SET_Element *element,
- uint64_t current_size,
- enum GNUNET_SET_Status status)
-{
- struct SetInfo *info = cls;
- struct GNUNET_HashCode hash;
-
- GNUNET_assert (GNUNET_NO == info->done);
- switch (status)
- {
- case GNUNET_SET_STATUS_DONE:
- case GNUNET_SET_STATUS_HALF_DONE:
- info->done = GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s done\n", info->id);
- check_all_done ();
- info->oh = NULL;
- return;
-
- case GNUNET_SET_STATUS_FAILURE:
- info->oh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failure\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
-
- case GNUNET_SET_STATUS_ADD_LOCAL:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: local element\n", info->id);
- break;
-
- case GNUNET_SET_STATUS_ADD_REMOTE:
- GNUNET_CRYPTO_hash (element->data, element->size, &hash);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: remote element %s\n", info->id,
- GNUNET_h2s (&hash));
- // XXX: record and check
- return;
-
- default:
- GNUNET_assert (0);
- }
-
- if (element->size != element_size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "wrong element size: %u, expected %u\n",
- element->size,
- (unsigned int) sizeof(struct GNUNET_HashCode));
- GNUNET_assert (0);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n",
- info->id, GNUNET_h2s (element->data));
- GNUNET_assert (NULL != element->data);
- struct GNUNET_HashCode data_hash;
- GNUNET_CRYPTO_hash (element->data, element_size, &data_hash);
- GNUNET_CONTAINER_multihashmap_put (info->received,
- &data_hash, NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
-}
-
-
-static void
-set_listen_cb (void *cls,
- const struct GNUNET_PeerIdentity *other_peer,
- const struct GNUNET_MessageHeader *context_msg,
- struct GNUNET_SET_Request *request)
-{
- /* max. 2 options plus terminator */
- struct GNUNET_SET_Option opts[3] = { { 0 } };
- unsigned int n_opts = 0;
-
- if (NULL == request)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "listener failed\n");
- return;
- }
- GNUNET_assert (NULL == info2.oh);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "set listen cb called\n");
- if (byzantine)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_BYZANTINE };
- }
- GNUNET_assert (! (force_full && force_delta));
- if (force_full)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_FORCE_FULL };
- }
- if (force_delta)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_FORCE_DELTA };
- }
-
- opts[n_opts].type = 0;
- info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
- opts,
- set_result_cb, &info2);
- GNUNET_SET_commit (info2.oh, info2.set);
-}
-
-
-static int
-set_insert_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_SET_Handle *set = cls;
- struct GNUNET_SET_Element el;
-
- el.element_type = 0;
- el.data = value;
- el.size = element_size;
- GNUNET_SET_add_element (set, &el, NULL, NULL);
- return GNUNET_YES;
-}
-
-
-static void
-handle_shutdown (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutting down set profiler\n");
- if (NULL != set_listener)
- {
- GNUNET_SET_listen_cancel (set_listener);
- set_listener = NULL;
- }
- if (NULL != info1.oh)
- {
- GNUNET_SET_operation_cancel (info1.oh);
- info1.oh = NULL;
- }
- if (NULL != info2.oh)
- {
- GNUNET_SET_operation_cancel (info2.oh);
- info2.oh = NULL;
- }
- if (NULL != info1.set)
- {
- GNUNET_SET_destroy (info1.set);
- info1.set = NULL;
- }
- if (NULL != info2.set)
- {
- GNUNET_SET_destroy (info2.set);
- info2.set = NULL;
- }
- GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- unsigned int i;
- struct GNUNET_HashCode hash;
- /* max. 2 options plus terminator */
- struct GNUNET_SET_Option opts[3] = { { 0 } };
- unsigned int n_opts = 0;
-
- config = cfg;
-
- GNUNET_assert (element_size > 0);
-
- if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n");
- ret = 0;
- return;
- }
-
- statistics = GNUNET_STATISTICS_create ("set-profiler", cfg);
-
- GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
-
- info1.id = "a";
- info2.id = "b";
-
- info1.sent = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.sent = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
- common_sent = GNUNET_CONTAINER_multihashmap_create (num_c + 1, GNUNET_NO);
-
- info1.received = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.received = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
-
- for (i = 0; i < num_a; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_b; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_c; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &app_id);
-
- /* FIXME: also implement intersection etc. */
- info1.set = GNUNET_SET_create (config, GNUNET_SET_OPERATION_UNION);
- info2.set = GNUNET_SET_create (config, GNUNET_SET_OPERATION_UNION);
-
- GNUNET_CONTAINER_multihashmap_iterate (info1.sent, set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (info2.sent, set_insert_iterator,
- info2.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent, set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent, set_insert_iterator,
- info2.set);
-
- set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
- &app_id, set_listen_cb, NULL);
-
-
- if (byzantine)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_BYZANTINE };
- }
- GNUNET_assert (! (force_full && force_delta));
- if (force_full)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_FORCE_FULL };
- }
- if (force_delta)
- {
- opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
- GNUNET_SET_OPTION_FORCE_DELTA };
- }
-
- opts[n_opts].type = 0;
-
- info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
- GNUNET_SET_RESULT_SYMMETRIC,
- opts,
- set_result_cb, &info1);
- GNUNET_SET_commit (info1.oh, info1.set);
- GNUNET_SET_destroy (info1.set);
- info1.set = NULL;
-}
-
-
-static void
-pre_run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- if (0 != GNUNET_TESTING_peer_run ("set-profiler",
- cfgfile,
- &run, NULL))
- ret = 2;
-}
-
-
-int
-main (int argc, char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('A',
- "num-first",
- NULL,
- gettext_noop ("number of values"),
- &num_a),
-
- GNUNET_GETOPT_option_uint ('B',
- "num-second",
- NULL,
- gettext_noop ("number of values"),
- &num_b),
-
- GNUNET_GETOPT_option_flag ('b',
- "byzantine",
- gettext_noop ("use byzantine mode"),
- &byzantine),
-
- GNUNET_GETOPT_option_uint ('f',
- "force-full",
- NULL,
- gettext_noop ("force sending full set"),
- &force_full),
-
- GNUNET_GETOPT_option_uint ('d',
- "force-delta",
- NULL,
- gettext_noop ("number delta operation"),
- &force_delta),
-
- GNUNET_GETOPT_option_uint ('C',
- "num-common",
- NULL,
- gettext_noop ("number of values"),
- &num_c),
-
- GNUNET_GETOPT_option_string ('x',
- "operation",
- NULL,
- gettext_noop ("operation to execute"),
- &op_str),
-
- GNUNET_GETOPT_option_uint ('w',
- "element-size",
- NULL,
- gettext_noop ("element size"),
- &element_size),
-
- GNUNET_GETOPT_option_filename ('s',
- "statistics",
- "FILENAME",
- gettext_noop ("write statistics to file"),
- &statistics_filename),
-
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler",
- "help",
- options, &pre_run, NULL, GNUNET_YES);
- return ret;
-}
diff --git a/src/contrib/service/template/meson.build b/src/contrib/service/template/meson.build
index 7a30a7575..414abc880 100644
--- a/src/contrib/service/template/meson.build
+++ b/src/contrib/service/template/meson.build
@@ -3,15 +3,13 @@ gnunetservicetemplate_src = ['gnunet-service-template.c']
configure_file(input : 'template.conf',
output : 'template.conf',
configuration : cdata,
- install: true,
- install_dir: pkgcfgdir)
+ install: false)
executable ('gnunet-service-template',
gnunetservicetemplate_src,
dependencies: [libgnunetutil_dep],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet' / 'libexec')
+ install: false)
testtemplateapi = executable ('test_template_api',
['test_template_api.c'],
dependencies: [libgnunetutil_dep],
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index fc2facdbf..8f39faab6 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -84,7 +84,6 @@ gnunetinclude_HEADERS = \
gnunet_op_lib.h \
gnunet_os_lib.h \
gnunet_peer_lib.h \
- gnunet_peerinfo_service.h \
gnunet_peerstore_plugin.h \
gnunet_peerstore_service.h \
gnunet_plugin_lib.h \
@@ -111,8 +110,6 @@ gnunetinclude_HEADERS = \
gnunet_sq_lib.h \
gnunet_statistics_service.h \
gnunet_strings_lib.h \
- gnunet_testbed_service.h \
- gnunet_testbed_logger_service.h \
gnunet_testing_barrier.h \
gnunet_testing_lib.h \
gnunet_testing_plugin.h \
diff --git a/src/include/gnu_name_system_service_ports.h b/src/include/gnu_name_system_service_ports.h
index a95941882..040e598b6 100644
--- a/src/include/gnu_name_system_service_ports.h
+++ b/src/include/gnu_name_system_service_ports.h
@@ -45,7 +45,7 @@ struct GNUNET_GNS_ServicePort
struct GNUNET_GNS_ServicePort GNUNET_GNS_ServicePorts[] = {
/**
- * LIGHTest trust policy scheme
+ * Used by Trust Scheme Authorities to publish information about Trust Schemes (LIGHTest)
*/
{
.name = "scheme",
@@ -53,10 +53,10 @@ struct GNUNET_GNS_ServicePort GNUNET_GNS_ServicePorts[] = {
},
/**
- * LIGHTest trust policy trustlist
+ * Used Trust Translation Authorities to publish information about Trust Translations (LIGHTest)
*/
{
- .name = "trustlist",
+ .name = "translation",
.port = 49153
},
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h
index c647272df..5457e8ddb 100644
--- a/src/include/gnunet_messenger_service.h
+++ b/src/include/gnunet_messenger_service.h
@@ -42,6 +42,8 @@ extern "C" {
#include "gnunet_common.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_identity_service.h"
+#include "gnunet_reclaim_lib.h"
+#include "gnunet_reclaim_service.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
@@ -201,6 +203,11 @@ enum GNUNET_MESSENGER_MessageKind
GNUNET_MESSENGER_KIND_CONNECTION = 16,
/**
+ * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body.
+ */
+ GNUNET_MESSENGER_KIND_TICKET = 17,
+
+ /**
* The unknown kind. The message contains an unknown body.
*/
GNUNET_MESSENGER_KIND_UNKNOWN = 0
@@ -516,6 +523,20 @@ struct GNUNET_MESSENGER_MessageConnection
};
/**
+ * A ticket message body
+ * This allows to exchange ticket identifiers with an audience.
+ *
+ * Message-body-size: 32 bytes
+ */
+struct GNUNET_MESSENGER_MessageTicket
+{
+ /**
+ * The identifier of a RECLAIM ticket.
+ */
+ struct GNUNET_RECLAIM_Identifier identifier;
+};
+
+/**
* The unified body of a #GNUNET_MESSENGER_Message.
*/
struct GNUNET_MESSENGER_MessageBody
@@ -538,6 +559,7 @@ struct GNUNET_MESSENGER_MessageBody
struct GNUNET_MESSENGER_MessagePrivate privacy;
struct GNUNET_MESSENGER_MessageDelete deletion;
struct GNUNET_MESSENGER_MessageConnection connection;
+ struct GNUNET_MESSENGER_MessageTicket ticket;
};
};
@@ -883,6 +905,22 @@ GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
GNUNET_MESSENGER_MemberCallback callback,
void *cls);
+/**
+ * Send a <i>ticket</i> into a <i>room</i>. The ticket will automatically be converted
+ * into a message to be sent only to its audience as a private message.
+ *
+ * A ticket can only be sent with this function if its issuer's public key is the one
+ * being used by the messenger. The audience's public key is not allowed to be the
+ * anonymous public key. The room needs to contain a member using the audience's public
+ * key.
+ *
+ * @param[in,out] room Room handle
+ * @param[in] ticket Ticket to send
+ */
+void
+GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_RECLAIM_Ticket *ticket);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
deleted file mode 100644
index 806de963c..000000000
--- a/src/include/gnunet_peerinfo_service.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2009, 2010 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @addtogroup Backbone
- * @{
- *
- * @author Christian Grothoff
- *
- * @file
- * Maintain the list of currently known hosts
- *
- * @defgroup peerinfo Peer Info service
- * Maintain the list of currently known hosts.
- *
- * Holds an in-memory structure of data/hosts.
- *
- * @see [Documentation](https://gnunet.org/gnunets-peerinfo-subsystem)
- *
- * @{
- */
-
-#ifndef GNUNET_PEERINFO_SERVICE_H
-#define GNUNET_PEERINFO_SERVICE_H
-
-
-#include "gnunet_common.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_hello_lib.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-/**
- * Handle to the peerinfo service.
- */
-struct GNUNET_PEERINFO_Handle;
-
-
-/**
- * Connect to the peerinfo service.
- *
- * @param cfg configuration to use
- * @return NULL on error (configuration related, actual connection
- * etablishment may happen asynchronously).
- */
-struct GNUNET_PEERINFO_Handle *
-GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Disconnect from the peerinfo service. Note that all iterators must
- * have completed or have been cancelled by the time this function is
- * called (otherwise, calling this function is a serious error).
- * Furthermore, if #GNUNET_PEERINFO_add_peer() operations are still
- * pending, they will be cancelled silently on disconnect.
- *
- * @param h handle to disconnect
- */
-void
-GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h);
-
-
-/**
- * Add a host to the persistent list. This method operates in
- * semi-reliable mode: if the transmission is not completed by
- * the time #GNUNET_PEERINFO_disconnect() is called, it will be
- * aborted. Furthermore, if a second HELLO is added for the
- * same peer before the first one was transmitted, PEERINFO may
- * merge the two HELLOs prior to transmission to the service.
- *
- * @param h handle to the peerinfo service
- * @param hello the verified (!) HELLO message
- * @param cont continuation to call when done, NULL is allowed
- * @param cont_cls closure for @a cont
- * @return handle to cancel add operation; all pending
- * 'add' operations will be cancelled automatically
- * on disconnect, so it is not necessary to keep this
- * handle (unless @a cont is non-NULL and at some point
- * calling @a cont must be prevented)
- */
-struct GNUNET_MQ_Envelope *
-GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
- const struct GNUNET_HELLO_Message *hello,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls);
-
-
-/**
- * Type of an iterator over the hosts. Note that each
- * host will be called with each available protocol.
- *
- * @param cls closure
- * @param peer id of the peer, NULL for last call
- * @param hello hello message for the peer (can be NULL)
- * @param error message
- */
-typedef void
-(*GNUNET_PEERINFO_Processor) (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
- const char *err_msg);
-
-
-/**
- * Handle for cancellation of iteration over peers.
- */
-struct GNUNET_PEERINFO_IteratorContext;
-
-
-/**
- * Call a method for each known matching host. The callback method
- * will be invoked once for each matching host and then finally once
- * with a NULL pointer. After that final invocation, the iterator
- * context must no longer be used.
- *
- * Instead of calling this function with `peer == NULL` it is often
- * better to use #GNUNET_PEERINFO_notify().
- *
- * @param h handle to the peerinfo service
- * @param include_friend_only include HELLO messages for friends only
- * @param peer restrict iteration to this peer only (can be NULL)
- * @param callback the method to call for each peer
- * @param callback_cls closure for @a callback
- * @return iterator context
- */
-struct GNUNET_PEERINFO_IteratorContext *
-GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
- int include_friend_only,
- const struct GNUNET_PeerIdentity *peer,
- GNUNET_PEERINFO_Processor callback,
- void *callback_cls);
-
-
-/**
- * Cancel an iteration over peer information.
- *
- * @param ic context of the iterator to cancel
- */
-void
-GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic);
-
-
-/**
- * Handle for notifications about changes to the set of known peers.
- */
-struct GNUNET_PEERINFO_NotifyContext;
-
-
-/**
- * Call a method whenever our known information about peers
- * changes. Initially calls the given function for all known
- * peers and then only signals changes.
- *
- * If @a include_friend_only is set to #GNUNET_YES peerinfo will include HELLO
- * messages which are intended for friend to friend mode and which do not
- * have to be gossiped. Otherwise these messages are skipped.
- *
- * @param cfg configuration to use
- * @param include_friend_only include HELLO messages for friends only
- * @param callback the method to call for each peer
- * @param callback_cls closure for @a callback
- * @return NULL on error
- */
-struct GNUNET_PEERINFO_NotifyContext *
-GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
- int include_friend_only,
- GNUNET_PEERINFO_Processor callback,
- void *callback_cls);
-
-
-/**
- * Stop notifying about changes.
- *
- * @param nc context to stop notifying
- */
-void
-GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/** @} */ /* end of group */
-
-/** @} */ /* end of group addition */
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index db9befa1a..3d9c12cb2 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -1621,7 +1621,7 @@ GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db,
* @return channel to notify upon
*/
char *
-GNUNET_PG_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es);
+GNUNET_PQ_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es);
/**
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index be41fb1d9..36dfe9c12 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -417,8 +417,8 @@ GNUNET_STRINGS_base64_encode (const void *in,
* @return the size of the output
*/
size_t
-GNUNET_STRINGS_urlencode (const char *data,
- size_t len,
+GNUNET_STRINGS_urlencode (size_t len,
+ const char data[static len],
char **out);
@@ -578,7 +578,7 @@ GNUNET_STRINGS_check_filename (const char *filename,
*/
enum GNUNET_GenericReturnValue
GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
- uint16_t addrlen,
+ size_t addrlen,
struct sockaddr_in6 *r_buf);
@@ -594,7 +594,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
*/
enum GNUNET_GenericReturnValue
GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
- uint16_t addrlen,
+ size_t addrlen,
struct sockaddr_in *r_buf);
diff --git a/src/include/gnunet_testbed_logger_service.h b/src/include/gnunet_testbed_logger_service.h
deleted file mode 100644
index 7ab943b15..000000000
--- a/src/include/gnunet_testbed_logger_service.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2008--2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @addtogroup Testing
- * @{
- *
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
- *
- * @file
- * API for submitting data to the testbed logger service
- *
- * @defgroup testbed-logger Testbed Logger service
- * Submit data to the testbed logger service.
- * @{
- */
-
-#ifndef GNUNET_TESTBED_LOGGER_SERVICE_H
-#define GNUNET_TESTBED_LOGGER_SERVICE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-#include "gnunet_util_lib.h"
-
-/**
- * Opaque handle for the logging service
- */
-struct GNUNET_TESTBED_LOGGER_Handle;
-
-
-/**
- * Connect to the testbed logger service
- *
- * @param cfg configuration to use
- * @return the handle which can be used for sending data to the service; NULL
- * upon any error
- */
-struct GNUNET_TESTBED_LOGGER_Handle *
-GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Disconnect from the logger service. Also cancels any pending send handles.
- *
- * @param h the logger handle
- */
-void
-GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h);
-
-
-/**
- * Functions of this type are called to notify a successful transmission of the
- * message to the logger service.
- *
- * @param cls the closure given to GNUNET_TESTBED_LOGGER_send()
- * @param size the amount of data sent
- */
-typedef void
-(*GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls,
- size_t size);
-
-
-/**
- * Send data to be logged to the logger service. The data will be buffered and
- * will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon
- * exceeding a threshold size.
- *
- * @param h the logger handle
- * @param data the data to send;
- * @param size how many bytes of @a data to send
- */
-void
-GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h,
- const void *data,
- size_t size);
-
-
-/**
- * Flush the buffered data to the logger service
- *
- * @param h the logger handle
- * @param cb the callback to call after the data is flushed
- * @param cb_cls the closure for @a cb
- */
-void
-GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h,
- GNUNET_TESTBED_LOGGER_FlushCompletion cb,
- void *cb_cls);
-
-
-/**
- * Cancel notification upon flush. Should only be used when the flush
- * completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already
- * called.
- *
- * @param h the logger handle
- */
-void
-GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GNUNET_TESTBED_LOGGER_SERVICE_H */
-
-/** @} */ /* end of group */
-
-/** @} */ /* end of group addition */
-
-/* End of gnunet_testbed_logger_service.h */
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
deleted file mode 100644
index 2aeafc977..000000000
--- a/src/include/gnunet_testbed_service.h
+++ /dev/null
@@ -1,1735 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2008--2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @addtogroup Testing
- * @{
- *
- * @author Christian Grothoff
- *
- * @file
- * API for writing tests and creating large-scale emulation testbeds for GNUnet.
- *
- * @defgroup testbed Testbed service
- * Writing tests and creating large-scale emulation testbeds for GNUnet.
- *
- * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-Subsystem)
- *
- * @{
- */
-
-#ifndef GNUNET_TESTBED_SERVICE_H
-#define GNUNET_TESTBED_SERVICE_H
-
-
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-/**
- * Opaque handle to a host running experiments managed by the testbed framework.
- * The master process must be able to SSH to this host without password (via
- * ssh-agent).
- */
-struct GNUNET_TESTBED_Host;
-
-/**
- * Opaque handle to a peer controlled by the testbed framework. A peer runs
- * at a particular host.
- */
-struct GNUNET_TESTBED_Peer;
-
-/**
- * Opaque handle to an abstract operation to be executed by the testbed framework.
- */
-struct GNUNET_TESTBED_Operation;
-
-/**
- * Handle to interact with a GNUnet testbed controller. Each
- * controller has at least one master handle which is created when the
- * controller is created; this master handle interacts with the
- * controller process, destroying it destroys the controller (by
- * closing stdin of the controller process). Additionally,
- * controllers can interact with each other (in a P2P fashion); those
- * links are established via TCP/IP on the controller's service port.
- */
-struct GNUNET_TESTBED_Controller;
-
-
-/**
- * Create a host to run peers and controllers on.
- *
- * @param hostname name of the host, use "NULL" for localhost
- * @param username username to use for the login; may be NULL
- * @param cfg the configuration to use as a template while starting a controller
- * on this host. Operation queue sizes specific to a host are also
- * read from this configuration handle
- * @param port port number to use for ssh; use 0 to let ssh decide
- * @return handle to the host, NULL on error
- */
-struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create (const char *hostname,
- const char *username,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- uint16_t port);
-
-
-/**
- * Create a host to run peers and controllers on. This function is used
- * if a peer learns about a host via IPC between controllers (and thus
- * some higher-level controller has already determined the unique IDs).
- *
- * @param id global host ID assigned to the host; 0 is
- * reserved to always mean 'localhost'
- * @param hostname name of the host, use "NULL" for localhost
- * @param username username to use for the login; may be NULL
- * @param cfg the configuration to use as a template while starting a controller
- * on this host. Operation queue sizes specific to a host are also
- * read from this configuration handle
- * @param port port number to use for ssh; use 0 to let ssh decide
- * @return handle to the host, NULL on error
- */
-struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create_with_id (uint32_t id,
- const char *hostname,
- const char *username,
- const struct GNUNET_CONFIGURATION_Handle
- *cfg,
- uint16_t port);
-
-
-/**
- * Load a set of hosts from a configuration file. The hostfile format is
- * specified at https://gnunet.org/content/hosts-file-format
- *
- * @param filename file with the host specification
- * @param cfg the configuration to use as a template while starting a controller
- * on any of the loaded hosts. Operation queue sizes specific to a host
- * are also read from this configuration handle
- * @param hosts set to the hosts found in the file; caller must free this if
- * number of hosts returned is greater than 0
- * @return number of hosts returned in 'hosts', 0 on error
- */
-unsigned int
-GNUNET_TESTBED_hosts_load_from_file (const char *filename,
- const struct GNUNET_CONFIGURATION_Handle
- *cfg,
- struct GNUNET_TESTBED_Host ***hosts);
-
-
-/**
- * Destroy a host handle. Must only be called once everything
- * running on that host has been stopped.
- *
- * @param host handle to destroy
- */
-void
-GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
-
-
-/**
- * The handle for whether a host is habitable or not
- */
-struct GNUNET_TESTBED_HostHabitableCheckHandle;
-
-
-/**
- * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to
- * inform whether the given host is habitable or not. The Handle returned by
- * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called
- *
- * @param cls the closure given to GNUNET_TESTBED_is_host_habitable()
- * @param host the host whose status is being reported; will be NULL if the host
- * given to GNUNET_TESTBED_is_host_habitable() is NULL
- * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
- */
-typedef void
-(*GNUNET_TESTBED_HostHabitableCallback) (void *cls,
- const struct GNUNET_TESTBED_Host *host,
- int status);
-
-
-/**
- * Checks whether a host can be used to start testbed service
- *
- * @param host the host to check
- * @param config the configuration handle to lookup the path of the testbed
- * helper
- * @param cb the callback to call to inform about habitability of the given host
- * @param cb_cls the closure for the callback
- * @return NULL upon any error or a handle which can be passed to
- * GNUNET_TESTBED_is_host_habitable_cancel()
- */
-struct GNUNET_TESTBED_HostHabitableCheckHandle *
-GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_CONFIGURATION_Handle
- *config,
- GNUNET_TESTBED_HostHabitableCallback cb,
- void *cb_cls);
-
-
-/**
- * Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
- *
- * @param handle the habitability check handle
- */
-void
-GNUNET_TESTBED_is_host_habitable_cancel (struct
- GNUNET_TESTBED_HostHabitableCheckHandle
- *handle);
-
-/**
- * Obtain the host's hostname.
- *
- * @param host handle to the host, NULL means 'localhost'
- * @return hostname of the host
- */
-const char *
-GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host);
-
-
-/**
- * Enumeration with (at most 64) possible event types that
- * can be monitored using the testbed framework.
- */
-enum GNUNET_TESTBED_EventType
-{
- /**
- * A peer has been started.
- */
- GNUNET_TESTBED_ET_PEER_START = 0,
-
- /**
- * A peer has been stopped.
- */
- GNUNET_TESTBED_ET_PEER_STOP = 1,
-
- /**
- * A connection between two peers was established.
- */
- GNUNET_TESTBED_ET_CONNECT = 2,
-
- /**
- * A connection between two peers was torn down.
- */
- GNUNET_TESTBED_ET_DISCONNECT = 3,
-
- /**
- * A requested testbed operation has been completed.
- */
- GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
-};
-
-
-/**
- * Types of information that can be requested about a peer.
- */
-enum GNUNET_TESTBED_PeerInformationType
-{
- /**
- * Special value (not valid for requesting information)
- * that is used in the event struct if a 'generic' pointer
- * is returned (for other operations not related to this
- * enumeration).
- */
- GNUNET_TESTBED_PIT_GENERIC = 0,
-
- /**
- * What configuration is the peer using? Returns a 'const struct
- * GNUNET_CONFIGURATION_Handle *'. Valid until
- * 'GNUNET_TESTNIG_operation_done' is called. However, the
- * values may be inaccurate if the peer is reconfigured in
- * the meantime.
- */
- GNUNET_TESTBED_PIT_CONFIGURATION,
-
- /**
- * What is the identity of the peer? Returns a
- * 'const struct GNUNET_PeerIdentity *'. Valid until
- * 'GNUNET_TESTNIG_operation_done' is called.
- */
- GNUNET_TESTBED_PIT_IDENTITY
-};
-
-
-/**
- * Argument to GNUNET_TESTBED_ControllerCallback with details about
- * the event.
- */
-struct GNUNET_TESTBED_EventInformation
-{
- /**
- * Type of the event.
- */
- enum GNUNET_TESTBED_EventType type;
-
- /**
- * Handle for the corresponding operation that generated this event
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Closure given while creating the above operation
- */
- void *op_cls;
-
- /**
- * Details about the event.
- */
- union
- {
- /**
- * Details about peer start event.
- */
- struct
- {
- /**
- * Handle for the host where the peer
- * was started.
- */
- struct GNUNET_TESTBED_Host *host;
-
- /**
- * Handle for the peer that was started.
- */
- struct GNUNET_TESTBED_Peer *peer;
- } peer_start;
-
- /**
- * Details about peer stop event.
- */
- struct
- {
- /**
- * Handle for the peer that was started.
- */
- struct GNUNET_TESTBED_Peer *peer;
- } peer_stop;
-
- /**
- * Details about connect event.
- */
- struct
- {
- /**
- * Handle for one of the connected peers.
- */
- struct GNUNET_TESTBED_Peer *peer1;
-
- /**
- * Handle for one of the connected peers.
- */
- struct GNUNET_TESTBED_Peer *peer2;
- } peer_connect;
-
- /**
- * Details about disconnect event.
- */
- struct
- {
- /**
- * Handle for one of the disconnected peers.
- */
- struct GNUNET_TESTBED_Peer *peer1;
-
- /**
- * Handle for one of the disconnected peers.
- */
- struct GNUNET_TESTBED_Peer *peer2;
- } peer_disconnect;
-
- /**
- * Details about an operation finished event.
- */
- struct
- {
- /**
- * Error message for the operation, NULL on success.
- */
- const char *emsg;
-
- /**
- * No result (NULL pointer) or generic result
- * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
- */
- void *generic;
- } operation_finished;
- } details;
-};
-
-
-/**
- * Signature of the event handler function called by the
- * respective event controller.
- *
- * @param cls closure
- * @param event information about the event
- */
-typedef void
-(*GNUNET_TESTBED_ControllerCallback)(void *cls,
- const struct
- GNUNET_TESTBED_EventInformation *event);
-
-
-/**
- * Opaque Handle for Controller process
- */
-struct GNUNET_TESTBED_ControllerProc;
-
-
-/**
- * Callback to signal successful startup of the controller process
- *
- * @param cls the closure from GNUNET_TESTBED_controller_start()
- * @param cfg the configuration with which the controller has been started;
- * NULL if status is not #GNUNET_OK
- * @param status #GNUNET_OK if the startup is successful; #GNUNET_SYSERR if not,
- * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
- */
-typedef void
-(*GNUNET_TESTBED_ControllerStatusCallback) (void *cls,
- const struct
- GNUNET_CONFIGURATION_Handle *cfg,
- int status);
-
-
-/**
- * Starts a controller process at the given host. The given host's configuration
- * is used as a Template configuration to use for the remote controller; the
- * remote controller will be started with a slightly modified configuration
- * (port numbers, unix domain sockets and service home values are changed as per
- * TESTING library on the remote host). The modified configuration replaces the
- * host's existing configuration before signalling success through the
- * GNUNET_TESTBED_ControllerStatusCallback()
- *
- * @param trusted_ip the ip address of the controller which will be set as TRUSTED
- * HOST(all connections from this ip are permitted by the testbed) when
- * starting testbed controller at host. This can either be a single ip
- * address or a network address in CIDR notation.
- * @param host the host where the controller has to be started. CANNOT be NULL.
- * @param cb function called when the controller is successfully started or
- * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be
- * called if cb is called with GNUNET_SYSERR as status. Will never be
- * called in the same task as 'GNUNET_TESTBED_controller_start'
- * (synchronous errors will be signalled by returning NULL). This
- * parameter cannot be NULL.
- * @param cls closure for above callbacks
- * @return the controller process handle, NULL on errors
- */
-struct GNUNET_TESTBED_ControllerProc *
-GNUNET_TESTBED_controller_start (const char *trusted_ip,
- struct GNUNET_TESTBED_Host *host,
- GNUNET_TESTBED_ControllerStatusCallback cb,
- void *cls);
-
-
-/**
- * Stop the controller process (also will terminate all peers and controllers
- * dependent on this controller). This function blocks until the testbed has
- * been fully terminated (!). The controller status cb from
- * GNUNET_TESTBED_controller_start() will not be called.
- *
- * @param cproc the controller process handle
- */
-void
-GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc);
-
-
-/**
- * Connect to a controller process. The configuration to use for the connection
- * is retrieved from the given host where a controller is started using
- * GNUNET_TESTBED_controller_start().
- *
- * @param host host to run the controller on; This should be the same host if
- * the controller was previously started with
- * GNUNET_TESTBED_controller_start()
- * @param event_mask bit mask with set of events to call 'cc' for;
- * or-ed values of "1LL" shifted by the
- * respective 'enum GNUNET_TESTBED_EventType'
- * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
- * @param cc controller callback to invoke on events
- * @param cc_cls closure for cc
- * @return handle to the controller
- */
-struct GNUNET_TESTBED_Controller *
-GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
- uint64_t event_mask,
- GNUNET_TESTBED_ControllerCallback cc,
- void *cc_cls);
-
-
-/**
- * Stop the given controller (also will terminate all peers and
- * controllers dependent on this controller). This function
- * blocks until the testbed has been fully terminated (!).
- *
- * @param c handle to controller to stop
- */
-void
-GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c);
-
-
-/**
- * Opaque handle for host registration
- */
-struct GNUNET_TESTBED_HostRegistrationHandle;
-
-
-/**
- * Callback which will be called to after a host registration succeeded or failed
- *
- * @param cls the closure
- * @param emsg the error message; NULL if host registration is successful
- */
-typedef void
-(*GNUNET_TESTBED_HostRegistrationCompletion) (void *cls,
- const char *emsg);
-
-
-/**
- * Register a host with the controller. This makes the controller aware of the
- * host. A host should be registered at the controller before starting a
- * sub-controller on that host using GNUNET_TESTBED_controller_link().
- *
- * @param controller the controller handle
- * @param host the host to register
- * @param cc the completion callback to call to inform the status of
- * registration. After calling this callback the registration handle
- * will be invalid. Cannot be NULL
- * @param cc_cls the closure for the cc
- * @return handle to the host registration which can be used to cancel the
- * registration; NULL if another registration handle is present and
- * is not cancelled
- */
-struct GNUNET_TESTBED_HostRegistrationHandle *
-GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
- struct GNUNET_TESTBED_Host *host,
- GNUNET_TESTBED_HostRegistrationCompletion cc,
- void *cc_cls);
-
-
-/**
- * Cancel the pending registration. Note that the registration message will
- * already be queued to be sent to the service, cancellation has only the
- * effect that the registration completion callback for the registration is
- * never called and from our perspective the host is not registered until the
- * completion callback is called.
- *
- * @param handle the registration handle to cancel
- */
-void
-GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
- *handle);
-
-
-/**
- * Callback to be called when an operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-typedef void
-(*GNUNET_TESTBED_OperationCompletionCallback) (void *cls,
- struct GNUNET_TESTBED_Operation *
- op,
- const char *emsg);
-
-
-/**
- * Create a link from slave controller to delegated controller. Whenever the
- * master controller is asked to start a peer at the delegated controller the
- * request will be routed towards slave controller (if a route exists). The
- * slave controller will then route it to the delegated controller. The
- * configuration of the delegated controller is given and is used to either
- * create the delegated controller or to connect to an existing controller. Note
- * that while starting the delegated controller the configuration will be
- * modified to accommodate available free ports. the 'is_subordinate' specifies
- * if the given delegated controller should be started and managed by the slave
- * controller, or if the delegated controller already has a master and the slave
- * controller connects to it as a non master controller. The success or failure
- * of this operation will be signalled through the
- * GNUNET_TESTBED_ControllerCallback() with an event of type
- * #GNUNET_TESTBED_ET_OPERATION_FINISHED
- *
- * @param op_cls the operation closure for the event which is generated to
- * signal success or failure of this operation
- * @param master handle to the master controller who creates the association
- * @param delegated_host requests to which host should be delegated; cannot be NULL
- * @param slave_host which host is used to run the slave controller; use NULL to
- * make the master controller connect to the delegated host
- * @param is_subordinate #GNUNET_YES if the controller at delegated_host should
- * be started by the slave controller; #GNUNET_NO if the slave
- * controller has to connect to the already started delegated
- * controller via TCP/IP
- * @return the operation handle
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_controller_link (void *op_cls,
- struct GNUNET_TESTBED_Controller *master,
- struct GNUNET_TESTBED_Host *delegated_host,
- struct GNUNET_TESTBED_Host *slave_host,
- int is_subordinate);
-
-
-/**
- * Function to acquire the configuration of a running slave controller. The
- * completion of the operation is signalled through the controller_cb from
- * GNUNET_TESTBED_controller_connect(). If the operation is successful the
- * handle to the configuration is available in the generic pointer of
- * operation_finished field of `struct GNUNET_TESTBED_EventInformation`.
- *
- * @param op_cls the closure for the operation
- * @param master the handle to master controller
- * @param slave_host the host where the slave controller is running; the handle
- * to the slave_host should remain valid until this operation is
- * cancelled or marked as finished
- * @return the operation handle; NULL if the slave_host is not registered at
- * master
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_get_slave_config (void *op_cls,
- struct GNUNET_TESTBED_Controller *master,
- struct GNUNET_TESTBED_Host *slave_host);
-
-
-/**
- * Functions of this signature are called when a peer has been successfully
- * created
- *
- * @param cls the closure from GNUNET_TESTBED_peer_create()
- * @param peer the handle for the created peer; NULL on any error during
- * creation
- * @param emsg NULL if peer is not NULL; else MAY contain the error description
- */
-typedef void
-(*GNUNET_TESTBED_PeerCreateCallback) (void *cls,
- struct GNUNET_TESTBED_Peer *peer,
- const char *emsg);
-
-
-/**
- * Create the given peer at the specified host using the given
- * controller. If the given controller is not running on the target
- * host, it should find or create a controller at the target host and
- * delegate creating the peer. Explicit delegation paths can be setup
- * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
- * path exists, a direct link with a subordinate controller is setup
- * for the first delegated peer to a particular host; the subordinate
- * controller is then destroyed once the last peer that was delegated
- * to the remote host is stopped.
- *
- * Creating the peer only creates the handle to manipulate and further
- * configure the peer; use #GNUNET_TESTBED_peer_start and
- * #GNUNET_TESTBED_peer_stop to actually start/stop the peer's
- * processes.
- *
- * Note that the given configuration will be adjusted by the
- * controller to avoid port/path conflicts with other peers.
- * The "final" configuration can be obtained using
- * #GNUNET_TESTBED_peer_get_information.
- *
- * @param controller controller process to use
- * @param host host to run the peer on; cannot be NULL
- * @param cfg Template configuration to use for the peer. Should exist until
- * operation is cancelled or GNUNET_TESTBED_operation_done() is called
- * @param cb the callback to call when the peer has been created
- * @param cls the closure to the above callback
- * @return the operation handle
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
- struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_TESTBED_PeerCreateCallback cb,
- void *cls);
-
-
-/**
- * Functions of this signature are called when a peer has been successfully
- * started or stopped.
- *
- * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
- * @param emsg NULL on success; otherwise an error description
- */
-typedef void
-(*GNUNET_TESTBED_PeerChurnCallback) (void *cls,
- const char *emsg);
-
-
-/**
- * Start the given peer.
- *
- * @param op_cls the closure for this operation; will be set in the event
- * information
- * @param peer peer to start
- * @param pcc function to call upon completion
- * @param pcc_cls closure for 'pcc'
- * @return handle to the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_start (void *op_cls,
- struct GNUNET_TESTBED_Peer *peer,
- GNUNET_TESTBED_PeerChurnCallback pcc,
- void *pcc_cls);
-
-
-/**
- * Stop the given peer. The handle remains valid (use
- * #GNUNET_TESTBED_peer_destroy to fully clean up the
- * state of the peer).
- *
- * @param op_cls the closure for this operation; will be set in the event
- * information
- * @param peer peer to stop
- * @param pcc function to call upon completion
- * @param pcc_cls closure for 'pcc'
- * @return handle to the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_stop (void *op_cls,
- struct GNUNET_TESTBED_Peer *peer,
- GNUNET_TESTBED_PeerChurnCallback pcc,
- void *pcc_cls);
-
-
-/**
- * Data returned from GNUNET_TESTBED_peer_get_information
- */
-struct GNUNET_TESTBED_PeerInformation
-{
- /**
- * Peer information type; captures which of the types
- * in the 'op_result' is actually in use.
- */
- enum GNUNET_TESTBED_PeerInformationType pit;
-
- /**
- * The result of the get information operation; Choose according to the pit
- */
- union
- {
- /**
- * The configuration of the peer
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * The identity of the peer
- */
- struct GNUNET_PeerIdentity *id;
- } result;
-};
-
-
-/**
- * Callback to be called when the requested peer information is available
- * The peer information in the callback is valid until the operation 'op' is canceled.
- *
- * @param cb_cls the closure from GNUNET_TESTBED_peer_get_information()
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed; will be NULL if the
- * operation is successful
- */
-typedef void
-(*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct
- GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg);
-
-
-/**
- * Request information about a peer. The controller callback will not be called
- * with event type #GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
- * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will
- * be called.
- * The peer information in the callback is valid until the operation is canceled.
- *
- * @param peer peer to request information about
- * @param pit desired information
- * @param cb the convenience callback to be called when results for this
- * operation are available
- * @param cb_cls the closure for @a cb
- * @return handle to the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
- enum GNUNET_TESTBED_PeerInformationType
- pit,
- GNUNET_TESTBED_PeerInfoCallback cb,
- void *cb_cls);
-
-
-/**
- * Change @a peer configuration. Ports and paths cannot be changed this
- * way.
- *
- * @param peer peer to change configuration for
- * @param cfg new configuration
- * @return handle to the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
- const struct
- GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Destroy the given peer; the peer should have been
- * stopped first (if it was started).
- *
- * @param peer peer to stop
- * @return handle to the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
-
-
-/**
- * Start or stop given service at a peer. This should not be called to
- * start/stop the peer's ARM service. Use GNUNET_TESTBED_peer_start(),
- * GNUNET_TESTBED_peer_stop() for starting/stopping peer's ARM service. Success
- * or failure of the generated operation is signalled through the controller
- * event callback and/or operation completion callback.
- *
- * @param op_cls the closure for the operation
- * @param peer the peer whose service is to be started/stopped
- * @param service_name the name of the service
- * @param cb the operation completion callback
- * @param cb_cls the closure for @a cb
- * @param start 1 to start the service; 0 to stop the service
- * @return an operation handle; NULL upon error (peer not running)
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_peer_manage_service (void *op_cls,
- struct GNUNET_TESTBED_Peer *peer,
- const char *service_name,
- GNUNET_TESTBED_OperationCompletionCallback
- cb,
- void *cb_cls,
- unsigned int start);
-
-
-/**
- * Stops and destroys all peers. Is equivalent of calling
- * GNUNET_TESTBED_peer_stop() and GNUNET_TESTBED_peer_destroy() on all peers,
- * except that the peer stop event and operation finished event corresponding to
- * the respective functions are not generated. This function should be called
- * when there are no other pending operations. If there are pending operations,
- * it will return NULL
- *
- * @param c the controller to send this message to
- * @param op_cls closure for the operation
- * @param cb the callback to call when all peers are stopped and destroyed
- * @param cb_cls the closure for the callback
- * @return operation handle on success; NULL if any pending operations are
- * present
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c,
- void *op_cls,
- GNUNET_TESTBED_OperationCompletionCallback cb,
- void *cb_cls);
-
-
-/**
- * Options for peer connections.
- */
-enum GNUNET_TESTBED_ConnectOption
-{
- /**
- * No option (not valid as an argument).
- */
- GNUNET_TESTBED_CO_NONE = 0,
-
- /**
- * Allow or disallow a connection between the specified peers.
- * Followed by #GNUNET_NO (int) if a connection is disallowed
- * or #GNUNET_YES if a connection is allowed. Note that the
- * default (all connections allowed or disallowed) is
- * specified in the configuration of the controller.
- */
- GNUNET_TESTBED_CO_ALLOW = 1,
-
- /**
- * FIXME: add (and implement) options to limit connection to
- * particular transports, force simulation of particular latencies
- * or message loss rates, or set bandwidth limitations.
- */
-};
-
-
-/**
- * Manipulate the P2P underlay topology by configuring a link
- * between two peers.
- *
- * @param op_cls closure argument to give with the operation event
- * @param p1 first peer
- * @param p2 second peer
- * @param co option to change
- * @param ap option-specific values
- * @return handle to the operation, NULL if configuring the link at this
- * time is not allowed
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_underlay_configure_link_va (void *op_cls,
- struct GNUNET_TESTBED_Peer *p1,
- struct GNUNET_TESTBED_Peer *p2,
- enum GNUNET_TESTBED_ConnectOption co,
- va_list ap);
-
-
-/**
- * Manipulate the P2P underlay topology by configuring a link
- * between two peers.
- *
- * @param op_cls closure argument to give with the operation event
- * @param p1 first peer
- * @param p2 second peer
- * @param co option to change
- * @param ... option-specific values
- * @return handle to the operation, NULL if configuring the link at this
- * time is not allowed
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_underlay_configure_link (void *op_cls,
- struct GNUNET_TESTBED_Peer *p1,
- struct GNUNET_TESTBED_Peer *p2,
- enum GNUNET_TESTBED_ConnectOption co,
- ...);
-
-
-/**
- * Topologies and topology options supported for testbeds. Options should always
- * end with #GNUNET_TESTBED_TOPOLOGY_OPTION_END
- */
-enum GNUNET_TESTBED_TopologyOption
-{
- /**
- * A clique (everyone connected to everyone else). No options. If there are N
- * peers this topology results in (N * (N -1)) connections.
- */
- GNUNET_TESTBED_TOPOLOGY_CLIQUE,
-
- /**
- * Small-world network (2d torus plus random links). Followed
- * by the number of random links to add (unsigned int).
- */
- GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD,
-
- /**
- * Small-world network (ring plus random links). Followed
- * by the number of random links to add (unsigned int).
- */
- GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING,
-
- /**
- * Ring topology. No options.
- */
- GNUNET_TESTBED_TOPOLOGY_RING,
-
- /**
- * Star topology. No options.
- */
- GNUNET_TESTBED_TOPOLOGY_STAR,
-
- /**
- * 2-d torus. No options.
- */
- GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
-
- /**
- * Random graph. Followed by the number of random links to be established
- * (unsigned int)
- */
- GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
-
- /**
- * Certain percentage of peers are unable to communicate directly
- * replicating NAT conditions. Followed by the fraction of
- * NAT'ed peers (float).
- */
- GNUNET_TESTBED_TOPOLOGY_INTERNAT,
-
- /**
- * Scale free topology. It is generated according to the method described in
- * "Emergence of Scaling in Random Networks." Science 286, 509-512, 1999.
- *
- * This options takes two arguments in the following order: an uint16_t to
- * determine the maximum number of edges a peer is permitted to have while
- * generating scale free topology, a good value for this argument is 70; and
- * an uint8_t to determine the number of edges to be established when adding a
- * new node to the scale free network, a good value for this argument is 4.
- */
- GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
-
- /**
- * Straight line topology. No options.
- */
- GNUNET_TESTBED_TOPOLOGY_LINE,
-
- /**
- * Read a topology from a given file. Followed by the name of the file (const char *).
- */
- GNUNET_TESTBED_TOPOLOGY_FROM_FILE,
-
- /**
- * All peers are disconnected. No options.
- */
- GNUNET_TESTBED_TOPOLOGY_NONE,
-
- /**
- * The options should always end with this
- */
- GNUNET_TESTBED_TOPOLOGY_OPTION_END,
-
- /* The following are not topologies but influence how the topology has to be
- setup. These options should follow the topology specific options (if
- required by the chosen topology). Note that these should be given before
- GNUNET_TESTBED_TOPOLOGY_OPTION_END */
-
- /**
- * How many times should the failed overlay connect operations be retried
- * before giving up. The default if this option is not specified is to retry
- * 3 times. This option takes and unsigned integer as a parameter. Use this
- * option with parameter 0 to disable retrying of failed overlay connect
- * operations.
- */
- GNUNET_TESTBED_TOPOLOGY_RETRY_CNT
-};
-
-
-/**
- * Configure overall network topology to have a particular shape.
- *
- * @param op_cls closure argument to give with the operation event
- * @param num_peers number of peers in @a peers
- * @param peers array of @a num_peers with the peers to configure
- * @param topo desired underlay topology to use
- * @param ap topology-specific options
- * @return handle to the operation, NULL if configuring the topology
- * is not allowed at this time
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **
- peers,
- enum
- GNUNET_TESTBED_TopologyOption
- topo,
- va_list ap);
-
-
-/**
- * Configure overall network topology to have a particular shape.
- *
- * @param op_cls closure argument to give with the operation event
- * @param num_peers number of peers in @a peers
- * @param peers array of @a num_peers with the peers to configure
- * @param topo desired underlay topology to use
- * @param ... topology-specific options
- * @return handle to the operation, NULL if configuring the topology
- * is not allowed at this time
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- enum GNUNET_TESTBED_TopologyOption
- topo,
- ...);
-
-
-/**
- * Both peers must have been started before calling this function.
- * This function then obtains a HELLO from @a p1, gives it to @a p2
- * and asks @a p2 to connect to @a p1.
- *
- * @param op_cls closure argument to give with the operation event
- * @param cb the callback to call when this operation has finished
- * @param cb_cls the closure for @a cb
- * @param p1 first peer
- * @param p2 second peer
- * @return handle to the operation, NULL if connecting these two
- * peers is fundamentally not possible at this time (peers
- * not running or underlay disallows)
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_overlay_connect (void *op_cls,
- GNUNET_TESTBED_OperationCompletionCallback cb,
- void *cb_cls,
- struct GNUNET_TESTBED_Peer *p1,
- struct GNUNET_TESTBED_Peer *p2);
-
-
-/**
- * Callbacks of this type are called when topology configuration is completed
- *
- * @param cls the operation closure given to
- * GNUNET_TESTBED_overlay_configure_topology_va() and
- * GNUNET_TESTBED_overlay_configure() calls
- * @param nsuccess the number of successful overlay connects
- * @param nfailures the number of overlay connects which failed
- */
-typedef void (*GNUNET_TESTBED_TopologyCompletionCallback) (void *cls,
- unsigned int
- nsuccess,
- unsigned int
- nfailures);
-
-
-/**
- * All peers must have been started before calling this function.
- * This function then connects the given peers in the P2P overlay
- * using the given topology.
- *
- * @param op_cls closure argument to give with the peer connect operation events
- * generated through this function
- * @param num_peers number of peers in 'peers'
- * @param peers array of 'num_peers' with the peers to configure
- * @param max_connections the maximums number of overlay connections that will
- * be made to achieve the given topology
- * @param comp_cb the completion callback to call when the topology generation
- * is completed
- * @param comp_cb_cls closure for the @a comp_cb
- * @param topo desired underlay topology to use
- * @param va topology-specific options
- * @return handle to the operation, NULL if connecting these
- * peers is fundamentally not possible at this time (peers
- * not running or underlay disallows) or if num_peers is less than 2
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int *max_connections,
- GNUNET_TESTBED_TopologyCompletionCallback
- comp_cb,
- void *comp_cb_cls,
- enum GNUNET_TESTBED_TopologyOption
- topo,
- va_list va);
-
-
-/**
- * All peers must have been started before calling this function.
- * This function then connects the given peers in the P2P overlay
- * using the given topology.
- *
- * @param op_cls closure argument to give with the peer connect operation events
- * generated through this function
- * @param num_peers number of peers in 'peers'
- * @param peers array of 'num_peers' with the peers to configure
- * @param max_connections the maximums number of overlay connections that will
- * be made to achieve the given topology
- * @param comp_cb the completion callback to call when the topology generation
- * is completed
- * @param comp_cb_cls closure for the above completion callback
- * @param topo desired underlay topology to use
- * @param ... topology-specific options
- * @return handle to the operation, NULL if connecting these
- * peers is fundamentally not possible at this time (peers
- * not running or underlay disallows) or if num_peers is less than 2
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int *max_connections,
- GNUNET_TESTBED_TopologyCompletionCallback
- comp_cb,
- void *comp_cb_cls,
- enum GNUNET_TESTBED_TopologyOption
- topo,
- ...);
-
-
-/**
- * Ask the testbed controller to write the current overlay topology to
- * a file. Naturally, the file will only contain a snapshot as the
- * topology may evolve all the time.
- * FIXME: needs continuation!?
- *
- * @param controller overlay controller to inspect
- * @param filename name of the file the topology should
- * be written to.
- */
-void
-GNUNET_TESTBED_overlay_write_topology_to_file (struct
- GNUNET_TESTBED_Controller *
- controller,
- const char *filename);
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-typedef void *
-(*GNUNET_TESTBED_ConnectAdapter)(void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-typedef void
-(*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
- void *op_result);
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-typedef void
-(*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls,
- struct
- GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg);
-
-
-/**
- * Connect to a service offered by the given peer. Will ensure that
- * the request is queued to not overwhelm our ability to create and
- * maintain connections with other systems. The actual service
- * handle is then returned via the 'op_result' member in the event
- * callback. The @a ca callback is used to create the connection
- * when the time is right; the @a da callback will be used to
- * destroy the connection (upon #GNUNET_TESTBED_operation_done).
- * #GNUNET_TESTBED_operation_done can be used to abort this
- * operation until the event callback has been called.
- *
- * @param op_cls closure to pass in operation event // FIXME: didn't we say we'd no longer use the global callback for these? -CG
- * @param peer peer that runs the service
- * @param service_name name of the service to connect to
- * @param cb the callback to call when this operation is ready (that is,
- * right after the connect adapter returns)
- * @param cb_cls closure for @a cb
- * @param ca helper function to establish the connection
- * @param da helper function to close the connection
- * @param cada_cls closure for @a ca and @a da
- * @return handle for the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_service_connect (void *op_cls,
- struct GNUNET_TESTBED_Peer *peer,
- const char *service_name,
- GNUNET_TESTBED_ServiceConnectCompletionCallback
- cb,
- void *cb_cls,
- GNUNET_TESTBED_ConnectAdapter ca,
- GNUNET_TESTBED_DisconnectAdapter da,
- void *cada_cls);
-
-
-/**
- * This function is used to signal that the event information (struct
- * GNUNET_TESTBED_EventInformation) from an operation has been fully processed
- * i.e. if the event callback is ever called for this operation. If the event
- * callback for this operation has not yet been called, calling this function
- * cancels the operation, frees its resources and ensures the no event is
- * generated with respect to this operation. Note that however cancelling an
- * operation does NOT guarantee that the operation will be fully undone (or that
- * nothing ever happened).
- *
- * This function MUST be called for every operation to fully remove the
- * operation from the operation queue. After calling this function, if
- * operation is completed and its event information is of type
- * GNUNET_TESTBED_ET_OPERATION_FINISHED, the 'op_result' becomes invalid (!).
-
- * If the operation is generated from GNUNET_TESTBED_service_connect() then
- * calling this function on such as operation calls the disconnect adapter if
- * the connect adapter was ever called.
- *
- * @param operation operation to signal completion or cancellation
- */
-void
-GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
-
-
-/**
- * Callback function to process statistic values from all peers.
- *
- * @param cls closure
- * @param peer the peer the statistic belong to
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-typedef int
-(*GNUNET_TESTBED_StatisticsIterator) (void *cls,
- const struct GNUNET_TESTBED_Peer *peer,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent);
-
-
-/**
- * Convenience method that iterates over all (running) peers
- * and retrieves all statistics from each peer.
- *
- * @param num_peers number of peers to iterate over
- * @param peers array of peers to iterate over
- * @param subsystem limit to the specified subsystem, NULL for all subsystems
- * @param name name of the statistic value, NULL for all values
- * @param proc processing function for each statistic retrieved
- * @param cont continuation to call once call is completed. The completion of this
- * operation is *ONLY* signalled through this callback -- no
- * GNUNET_TESTBED_ET_OPERATION_FINISHED is generated
- * @param cls closure to pass to proc and cont
- * @return operation handle to cancel the operation
- */
-struct GNUNET_TESTBED_Operation *
-GNUNET_TESTBED_get_statistics (unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- const char *subsystem, const char *name,
- GNUNET_TESTBED_StatisticsIterator proc,
- GNUNET_TESTBED_OperationCompletionCallback cont,
- void *cls);
-
-
-/**
- * Return the index of the peer inside of the total peer array,
- * aka. the peer's "unique ID".
- *
- * @param peer Peer handle.
- *
- * @return The peer's unique ID.
- */
-uint32_t
-GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer);
-
-
-/**
- * Handle for testbed run helper functions
- */
-struct GNUNET_TESTBED_RunHandle;
-
-
-/**
- * Signature of a main function for a testcase.
- *
- * @param cls closure
- * @param h the run handle
- * @param num_peers number of peers in 'peers'
- * @param peers handle to peers run in the testbed. NULL upon timeout (see
- * GNUNET_TESTBED_test_run()).
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- * @see GNUNET_TESTBED_test_run()
- */
-typedef void
-(*GNUNET_TESTBED_TestMaster)(void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed);
-
-
-/**
- * Convenience method for running a testbed with
- * a single call. Underlay and overlay topology
- * are configured using the "UNDERLAY" and "OVERLAY"
- * options in the "[testbed]" section of the configuration\
- * (with possible options given in "UNDERLAY_XXX" and/or
- * "OVERLAY_XXX").
- *
- * The test_master callback will be called once the testbed setup is finished or
- * upon a timeout. This timeout is given through the configuration file by
- * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section.
- *
- * The testbed is to be terminated using a call to
- * "GNUNET_SCHEDULER_shutdown".
- *
- * @param host_filename name of the file with the 'hosts', NULL
- * to run everything on 'localhost'
- * @param cfg configuration to use (for testbed, controller and peers)
- * @param num_peers number of peers to start; FIXME: maybe put that ALSO into
- * cfg?; should be greater than 0
- * @param event_mask bit mask with set of events to call 'cc' for;
- * or-ed values of "1LL" shifted by the
- * respective 'enum GNUNET_TESTBED_EventType'
- * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
- * @param cc controller callback to invoke on events; This callback is called
- * for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't
- * set in the event_mask as this is the only way get access to the
- * handle of each peer
- * @param cc_cls closure for cc
- * @param test_master this callback will be called once the test is ready or
- * upon timeout
- * @param test_master_cls closure for 'test_master'.
- */
-void
-GNUNET_TESTBED_run (const char *host_filename,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- unsigned int num_peers,
- uint64_t event_mask,
- GNUNET_TESTBED_ControllerCallback cc,
- void *cc_cls,
- GNUNET_TESTBED_TestMaster test_master,
- void *test_master_cls);
-
-
-/**
- * Convenience method for running a "simple" test on the local system
- * with a single call from 'main'. Underlay and overlay topology are
- * configured using the "UNDERLAY" and "OVERLAY" options in the
- * "[TESTBED]" section of the configuration (with possible options
- * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
- *
- * The test_master callback will be called once the testbed setup is finished or
- * upon a timeout. This timeout is given through the configuration file by
- * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section.
- *
- * The test is to be terminated using a call to
- * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
- * the program is stopped without 'master' ever being run.
- *
- * NOTE: this function should be called from 'main', NOT from
- * within a GNUNET_SCHEDULER-loop. This function will initialize
- * the scheduler loop, the testbed and then pass control to
- * 'master'.
- *
- * @param testname name of the testcase (to configure logging, etc.)
- * @param cfg_filename configuration filename to use
- * (for testbed, controller and peers)
- * @param num_peers number of peers to start; should be greter than 0
- * @param event_mask bit mask with set of events to call 'cc' for;
- * or-ed values of "1LL" shifted by the
- * respective 'enum GNUNET_TESTBED_EventType'
- * (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
- * @param cc controller callback to invoke on events; This callback is called
- * for all peer start events even if #GNUNET_TESTBED_ET_PEER_START isn't
- * set in the event_mask as this is the only way get access to the
- * handle of each peer
- * @param cc_cls closure for @a cc
- * @param test_master this callback will be called once the test is ready or
- * upon timeout
- * @param test_master_cls closure for @a test_master.
- * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
- */
-int
-GNUNET_TESTBED_test_run (const char *testname,
- const char *cfg_filename,
- unsigned int num_peers,
- uint64_t event_mask,
- GNUNET_TESTBED_ControllerCallback cc,
- void *cc_cls,
- GNUNET_TESTBED_TestMaster test_master,
- void *test_master_cls);
-
-
-/**
- * Obtain handle to the master controller from a testbed run. The handle
- * returned should not be disconnected.
- *
- * @param h the testbed run handle
- * @return handle to the master controller
- */
-struct GNUNET_TESTBED_Controller *
-GNUNET_TESTBED_run_get_controller_handle (struct GNUNET_TESTBED_RunHandle *h);
-
-
-/**
- * Opaque handle for barrier
- */
-struct GNUNET_TESTBED_Barrier;
-
-
-/**
- * Status of a barrier
- */
-enum GNUNET_TESTBED_BarrierStatus
-{
- /**
- * Barrier initialised successfully
- */
- GNUNET_TESTBED_BARRIERSTATUS_INITIALISED = 1,
-
- /**
- * Barrier is crossed
- */
- GNUNET_TESTBED_BARRIERSTATUS_CROSSED,
-
- /**
- * Error status
- */
- GNUNET_TESTBED_BARRIERSTATUS_ERROR,
-};
-
-
-/**
- * Functions of this type are to be given as callback argument to
- * GNUNET_TESTBED_barrier_init(). The callback will be called when status
- * information is available for the barrier.
- *
- * @param cls the closure given to GNUNET_TESTBED_barrier_init()
- * @param name the name of the barrier
- * @param barrier the barrier handle
- * @param status status of the barrier. The barrier is removed once it has been
- * crossed or an error occurs while processing it. Therefore it is
- * invalid to call GNUNET_TESTBED_barrier_cancel() on a crossed or
- * errored barrier.
- * @param emsg if the status were to be #GNUNET_SYSERR, this parameter has the
- * error message
- */
-typedef void
-(*GNUNET_TESTBED_barrier_status_cb) (void *cls,
- const char *name,
- struct GNUNET_TESTBED_Barrier *barrier,
- enum GNUNET_TESTBED_BarrierStatus status,
- const char *emsg);
-
-
-/**
- * Initialise a barrier and call the given callback when the required percentage
- * of peers (quorum) reach the barrier.
- *
- * @param controller the handle to the controller
- * @param name identification name of the barrier
- * @param quorum the percentage of peers that is required to reach the barrier.
- * Peers signal reaching a barrier by calling
- * GNUNET_TESTBED_barrier_reached().
- * @param cb the callback to call when the barrier is reached or upon error.
- * Cannot be NULL.
- * @param cb_cls closure for @a cb
- * @return barrier handle
- */
-struct GNUNET_TESTBED_Barrier *
-GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller,
- const char *name,
- unsigned int quorum,
- GNUNET_TESTBED_barrier_status_cb cb,
- void *cb_cls);
-
-
-/**
- * Cancel a barrier.
- *
- * @param barrier the barrier handle
- */
-void
-GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier);
-
-
-/**
- * Opaque handle for barrier wait
- */
-struct GNUNET_TESTBED_BarrierWaitHandle;
-
-
-/**
- * Functions of this type are to be given as acallback argument to
- * GNUNET_TESTBED_barrier_wait(). The callback will be called when the barrier
- * corresponding given in GNUNET_TESTBED_barrier_wait() is crossed or cancelled.
- *
- * @param cls closure pointer given to GNUNET_TESTBED_barrier_wait()
- * @param name the barrier name
- * @param status #GNUNET_SYSERR in case of error while waiting for the barrier;
- * #GNUNET_OK if the barrier is crossed
- */
-typedef void
-(*GNUNET_TESTBED_barrier_wait_cb) (void *cls,
- const char *name,
- int status);
-
-
-/**
- * Wait for a barrier to be crossed. This function should be called by the
- * peers which have been started by the testbed. If the peer is not started by
- * testbed this function may return error
- *
- * @param name the name of the barrier
- * @param cb the barrier wait callback
- * @param cls the closure for the above callback
- * @return barrier wait handle which can be used to cancel the waiting at
- * anytime before the callback is called. NULL upon error.
- */
-struct GNUNET_TESTBED_BarrierWaitHandle *
-GNUNET_TESTBED_barrier_wait (const char *name,
- GNUNET_TESTBED_barrier_wait_cb cb,
- void *cls);
-
-
-/**
- * Cancel a barrier wait handle. Should not be called in or after the callback
- * given to GNUNET_TESTBED_barrier_wait() has been called.
- *
- * @param h the barrier wait handle
- */
-void
-GNUNET_TESTBED_barrier_wait_cancel (struct GNUNET_TESTBED_BarrierWaitHandle *h);
-
-
-/**
- * Model for configuring underlay links of a peer
- * @ingroup underlay
- */
-struct GNUNET_TESTBED_UnderlayLinkModel;
-
-
-/**
- * The type of GNUNET_TESTBED_UnderlayLinkModel
- * @ingroup underlay
- */
-enum GNUNET_TESTBED_UnderlayLinkModelType
-{
- /**
- * The model is based on white listing of peers to which underlay connections
- * are permitted. Underlay connections to all other peers will not be
- * permitted.
- */
- GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST,
-
- /**
- * The model is based on black listing of peers to which underlay connections
- * are not permitted. Underlay connections to all other peers will be
- * permitted
- */
- GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST
-};
-
-
-/**
- * Create a GNUNET_TESTBED_UnderlayLinkModel for the given peer. A peer can
- * have ONLY ONE model and it can be either a blacklist or whitelist based one.
- *
- * @ingroup underlay
- * @param peer the peer for which the model has to be created
- * @param type the type of the model
- * @return the model
- */
-struct GNUNET_TESTBED_UnderlayLinkModel *
-GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer,
- enum
- GNUNET_TESTBED_UnderlayLinkModelType
- type);
-
-
-/**
- * Add a peer to the given model. Underlay connections to the given peer will
- * be permitted if the model is whitelist based; otherwise they will not be
- * permitted.
- *
- * @ingroup underlay
- * @param model the model
- * @param peer the peer to add
- */
-void
-GNUNET_TESTBED_underlaylinkmodel_add_peer (struct
- GNUNET_TESTBED_UnderlayLinkModel *
- model,
- struct GNUNET_TESTBED_Peer *peer);
-
-
-/**
- * Set the metrics for a link to the given peer in the underlay model. The link
- * SHOULD be permittable according to the given model.
- *
- * @ingroup underlay
- * @param model the model
- * @param peer the other end peer of the link
- * @param latency latency of the link in microseconds
- * @param loss data loss of the link expressed as a percentage
- * @param bandwidth bandwidth of the link in kilobytes per second [kB/s]
- */
-void
-GNUNET_TESTBED_underlaylinkmodel_set_link (struct
- GNUNET_TESTBED_UnderlayLinkModel *
- model,
- struct GNUNET_TESTBED_Peer *peer,
- uint32_t latency,
- uint32_t loss,
- uint32_t bandwidth);
-
-
-/**
- * Commit the model. The model is freed in this function(!).
- *
- * @ingroup underlay
- * @param model the model to commit
- */
-void
-GNUNET_TESTBED_underlaylinkmodel_commit (struct
- GNUNET_TESTBED_UnderlayLinkModel *model);
-
-
-/**
- * Free the resources of the model. Use this function only if the model has not
- * be committed and has to be unallocated. The peer can then have another model
- * created.
- *
- * @ingroup underlay
- * @param model the model to unallocate
- */
-void
-GNUNET_TESTBED_underlaylinkmodel_free (struct
- GNUNET_TESTBED_UnderlayLinkModel *model);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/** @} */ /* end of group */
-
-/** @} */ /* end of group addition */
diff --git a/src/include/meson.build b/src/include/meson.build
index 5388ae649..3127a6a40 100644
--- a/src/include/meson.build
+++ b/src/include/meson.build
@@ -78,7 +78,6 @@ install_headers(
'gnunet_op_lib.h',
'gnunet_os_lib.h',
'gnunet_peer_lib.h',
- 'gnunet_peerinfo_service.h',
'gnunet_peerstore_plugin.h',
'gnunet_peerstore_service.h',
'gnunet_plugin_lib.h',
@@ -105,8 +104,6 @@ install_headers(
'gnunet_sq_lib.h',
'gnunet_statistics_service.h',
'gnunet_strings_lib.h',
- 'gnunet_testbed_service.h',
- 'gnunet_testbed_logger_service.h',
'gnunet_testing_barrier.h',
'gnunet_testing_lib.h',
'gnunet_testing_plugin.h',
diff --git a/src/include/platform.h b/src/include/platform.h
index baf6986ed..c04d8d487 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -273,6 +273,10 @@ atoll (const char *nptr);
#define EXIT_NOTRUNNING 7
#endif
+#ifndef EXIT_NO_RESTART
+#define EXIT_NO_RESTART 9
+#endif
+
/**
* clang et al do not have such an attribute
*/
diff --git a/src/lib/hello/hello-uri.c b/src/lib/hello/hello-uri.c
index 2e99d701a..49acaf7a9 100644
--- a/src/lib/hello/hello-uri.c
+++ b/src/lib/hello/hello-uri.c
@@ -759,8 +759,8 @@ GNUNET_HELLO_builder_to_url (const struct GNUNET_HELLO_Builder *builder,
}
pfx_len = eou - a->uri;
eou += 3;
- GNUNET_STRINGS_urlencode (eou,
- a->uri_len - 4 - pfx_len,
+ GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
+ eou,
&ue);
GNUNET_asprintf (&tmp,
"%s%s%.*s=%s",
diff --git a/src/lib/json/json_generator.c b/src/lib/json/json_generator.c
index 4fda86e32..43b72ba57 100644
--- a/src/lib/json/json_generator.c
+++ b/src/lib/json/json_generator.c
@@ -34,8 +34,7 @@ GNUNET_JSON_from_data (const void *data,
char *buf;
json_t *json;
- if ((size * 8 + 4) / 5 + 1 >=
- GNUNET_MAX_MALLOC_CHECKED)
+ if (size >= ( (GNUNET_MAX_MALLOC_CHECKED - 1) * 5) - 4 / 8)
{
GNUNET_break (0);
return NULL;
@@ -57,8 +56,7 @@ GNUNET_JSON_from_data64 (const void *data,
json_t *json;
size_t len;
- if ((size * 8 + 5) / 6 + 1 >=
- GNUNET_MAX_MALLOC_CHECKED)
+ if (size >= ( ( (GNUNET_MAX_MALLOC_CHECKED - 1) * 6) - 5) / 8)
{
GNUNET_break (0);
return NULL;
diff --git a/src/lib/json/json_helper.c b/src/lib/json/json_helper.c
index 7e1d239f7..b6965e080 100644
--- a/src/lib/json/json_helper.c
+++ b/src/lib/json/json_helper.c
@@ -55,7 +55,7 @@ parse_fixed_data (void *cls,
struct GNUNET_JSON_Specification *spec)
{
const char *enc;
- unsigned int len;
+ size_t len;
if (NULL == (enc = json_string_value (root)))
{
@@ -63,6 +63,11 @@ parse_fixed_data (void *cls,
return GNUNET_SYSERR;
}
len = strlen (enc);
+ if (len >= SIZE_MAX / 5)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
if (((len * 5) / 8) != spec->ptr_size)
{
GNUNET_break_op (0);
@@ -279,7 +284,7 @@ GNUNET_JSON_spec_string (const char *name,
{
struct GNUNET_JSON_Specification ret = {
.parser = &parse_string,
- .field = name,
+ .field = name,
.ptr = strptr
};
diff --git a/src/lib/pq/Makefile.am b/src/lib/pq/Makefile.am
index 6a42499ca..1884fc868 100644
--- a/src/lib/pq/Makefile.am
+++ b/src/lib/pq/Makefile.am
@@ -32,7 +32,7 @@ libgnunetpq_la_LIBADD = -lpq \
libgnunetpq_la_LDFLAGS = \
$(POSTGRESQL_LDFLAGS) \
$(GN_LIB_LDFLAGS) \
- -version-info 4:0:0
+ -version-info 5:0:0
if ENABLE_TEST_RUN
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/lib/pq/pq_event.c b/src/lib/pq/pq_event.c
index fff9e16f7..7506ff2f0 100644
--- a/src/lib/pq/pq_event.c
+++ b/src/lib/pq/pq_event.c
@@ -519,7 +519,7 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
char *
-GNUNET_PG_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es)
+GNUNET_PQ_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es)
{
char sql[16 + 64 + 8];
char *end;
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index 7ab6301f5..6facc5921 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -145,7 +145,7 @@ libgnunetutil_la_LIBADD = \
libgnunetutil_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
- -version-info 15:0:0
+ -version-info 16:0:0
lib_LTLIBRARIES = libgnunetutil.la
diff --git a/src/lib/util/common_logging.c b/src/lib/util/common_logging.c
index d27f70e83..37c6064b8 100644
--- a/src/lib/util/common_logging.c
+++ b/src/lib/util/common_logging.c
@@ -348,7 +348,7 @@ GNUNET_b2s (const void *buf,
* @param tm timestamp for which we should setup logging
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
-static int
+static enum GNUNET_GenericReturnValue
setup_log_file (const struct tm *tm)
{
static char last_fn[PATH_MAX + 1];
@@ -725,7 +725,7 @@ parse_all_definitions ()
* @param logfile which file to write log messages to (can be NULL)
* @return #GNUNET_OK on success
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_log_setup (const char *comp,
const char *loglevel,
const char *logfile)
@@ -737,7 +737,10 @@ GNUNET_log_setup (const char *comp,
parse_all_definitions ();
#endif
GNUNET_free (component);
- GNUNET_asprintf (&component, "%s-%d", comp, getpid ());
+ GNUNET_asprintf (&component,
+ "%s-%d",
+ comp,
+ getpid ());
GNUNET_free (component_nopid);
component_nopid = GNUNET_strdup (comp);
@@ -768,7 +771,8 @@ GNUNET_log_setup (const char *comp,
void
-GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
+GNUNET_logger_add (GNUNET_Logger logger,
+ void *logger_cls)
{
struct CustomLogger *entry;
@@ -781,7 +785,8 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
void
-GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls)
+GNUNET_logger_remove (GNUNET_Logger logger,
+ void *logger_cls)
{
struct CustomLogger *pos;
struct CustomLogger *prev;
@@ -817,8 +822,21 @@ output_message (enum GNUNET_ErrorType kind,
const char *datestr,
const char *msg)
{
+ static int have_journald = -1;
struct CustomLogger *pos;
+ if (-1 == have_journald)
+ {
+ /* systemd after version 231 sets this environment
+ variable if we are logging to journald. In this
+ case, skip outputting our component name, PID
+ and timestamp as journald already adds those. (#8032) */
+ if (NULL != getenv ("JOURNAL_STREAM"))
+ have_journald = 1;
+ else
+ have_journald = 0;
+ }
+
/* only use the standard logger if no custom loggers are present */
if ((NULL != GNUNET_stderr) && (NULL == loggers))
{
@@ -831,7 +849,8 @@ output_message (enum GNUNET_ErrorType kind,
* interactively, yet the same message shouldn't look
* this way if the output is going to logfiles or robots
* instead.
- */fprintf (GNUNET_stderr, "* %s", msg);
+ */
+ fprintf (GNUNET_stderr, "* %s", msg);
}
else if (GNUNET_YES == current_async_scope.have_scope)
{
@@ -847,22 +866,35 @@ output_message (enum GNUNET_ErrorType kind,
GNUNET_assert (NULL != end);
*end = '\0';
skip_log = 0;
- fprintf (GNUNET_stderr,
- "%s %s(%s) %s %s",
- datestr,
- comp,
- id_buf,
- GNUNET_error_type_to_string (kind),
- msg);
+ if (have_journald)
+ fprintf (GNUNET_stderr,
+ "(%s) %s %s",
+ id_buf,
+ GNUNET_error_type_to_string (kind),
+ msg);
+ else
+ fprintf (GNUNET_stderr,
+ "%s %s(%s) %s %s",
+ datestr,
+ comp,
+ id_buf,
+ GNUNET_error_type_to_string (kind),
+ msg);
}
else
{
- fprintf (GNUNET_stderr,
- "%s %s %s %s",
- datestr,
- comp,
- GNUNET_error_type_to_string (kind),
- msg);
+ if (have_journald)
+ fprintf (GNUNET_stderr,
+ "%s %s",
+ GNUNET_error_type_to_string (kind),
+ msg);
+ else
+ fprintf (GNUNET_stderr,
+ "%s %s %s %s",
+ datestr,
+ comp,
+ GNUNET_error_type_to_string (kind),
+ msg);
}
fflush (GNUNET_stderr);
}
diff --git a/src/lib/util/dnsparser.c b/src/lib/util/dnsparser.c
index 1f51eacdc..93b2b590b 100644
--- a/src/lib/util/dnsparser.c
+++ b/src/lib/util/dnsparser.c
@@ -552,8 +552,8 @@ GNUNET_DNSPARSER_parse_uri (const char *udp_payload,
uri = GNUNET_new (struct GNUNET_DNSPARSER_UriRecord);
uri->priority = ntohs (uri_bin.prio);
uri->weight = ntohs (uri_bin.weight);
- int len = GNUNET_asprintf (&(uri->target), "%.*s", udp_payload_length
- - sizeof(struct GNUNET_TUN_DnsUriRecord),
+ int max_len = udp_payload_length - sizeof(struct GNUNET_TUN_DnsUriRecord);
+ int len = GNUNET_asprintf (&(uri->target), "%.*s", max_len,
&udp_payload[*off]);
(*off) += len;
if (NULL == uri->target)
@@ -1252,7 +1252,6 @@ GNUNET_DNSPARSER_builder_add_uri (char *dst,
const struct GNUNET_DNSPARSER_UriRecord *uri)
{
struct GNUNET_TUN_DnsUriRecord sd;
- int ret;
if (*off + sizeof(struct GNUNET_TUN_DnsUriRecord) > dst_len)
return GNUNET_NO;
diff --git a/src/lib/util/gnunet_error_codes.c b/src/lib/util/gnunet_error_codes.c
index c286f2e52..11ce2d0c8 100644
--- a/src/lib/util/gnunet_error_codes.c
+++ b/src/lib/util/gnunet_error_codes.c
@@ -17,7 +17,6 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
-#include "platform.h"
#include "gnunet_error_codes.h"
#include <stddef.h>
#include <microhttpd.h>
diff --git a/src/lib/util/strings.c b/src/lib/util/strings.c
index e0ae6a2fa..96cd4352a 100644
--- a/src/lib/util/strings.c
+++ b/src/lib/util/strings.c
@@ -945,9 +945,8 @@ GNUNET_STRINGS_parse_uri (const char *path,
return GNUNET_NO;
if (scheme_part)
{
- *scheme_part = GNUNET_malloc (post_scheme_part - path + 1);
- GNUNET_memcpy (*scheme_part, path, post_scheme_part - path);
- (*scheme_part)[post_scheme_part - path] = '\0';
+ *scheme_part = GNUNET_strndup (path,
+ post_scheme_part - path);
}
if (path_part)
*path_part = post_scheme_part;
@@ -1032,70 +1031,77 @@ GNUNET_STRINGS_check_filename (const char *filename,
enum GNUNET_GenericReturnValue
GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
- uint16_t addrlen,
+ size_t addrlen,
struct sockaddr_in6 *r_buf)
{
- char zbuf[addrlen + 1];
- int ret;
- char *port_colon;
- unsigned int port;
- char dummy[2];
-
if (addrlen < 6)
return GNUNET_SYSERR;
- GNUNET_memcpy (zbuf, zt_addr, addrlen);
- if ('[' != zbuf[0])
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("IPv6 address did not start with `['\n"));
- return GNUNET_SYSERR;
- }
- zbuf[addrlen] = '\0';
- port_colon = strrchr (zbuf, ':');
- if (NULL == port_colon)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("IPv6 address did contain ':' to separate port number\n"));
- return GNUNET_SYSERR;
- }
- if (']' != *(port_colon - 1))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- _ ("IPv6 address did contain ']' before ':' to separate port number\n"));
- return GNUNET_SYSERR;
- }
- ret = sscanf (port_colon, ":%u%1s", &port, dummy);
- if ((1 != ret) || (port > 65535))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- _ ("IPv6 address did contain a valid port number after the last ':'\n"));
- return GNUNET_SYSERR;
- }
- *(port_colon - 1) = '\0';
- memset (r_buf, 0, sizeof(struct sockaddr_in6));
- ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
- if (ret <= 0)
+ if (addrlen > 512)
+ return GNUNET_SYSERR; /* sanity check to protect zbuf allocation,
+ actual limit is not precise */
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Invalid IPv6 address `%s': %s\n"),
- &zbuf[1],
- strerror (errno));
- return GNUNET_SYSERR;
- }
- r_buf->sin6_port = htons (port);
- r_buf->sin6_family = AF_INET6;
+ char zbuf[addrlen + 1];
+ int ret;
+ char *port_colon;
+ unsigned int port;
+ char dummy[2];
+
+ GNUNET_memcpy (zbuf, zt_addr, addrlen);
+ if ('[' != zbuf[0])
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _ ("IPv6 address did not start with `['\n"));
+ return GNUNET_SYSERR;
+ }
+ zbuf[addrlen] = '\0';
+ port_colon = strrchr (zbuf, ':');
+ if (NULL == port_colon)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _ ("IPv6 address did contain ':' to separate port number\n"));
+ return GNUNET_SYSERR;
+ }
+ if (']' != *(port_colon - 1))
+ {
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_WARNING,
+ _ (
+ "IPv6 address did contain ']' before ':' to separate port number\n"));
+ return GNUNET_SYSERR;
+ }
+ ret = sscanf (port_colon, ":%u%1s", &port, dummy);
+ if ((1 != ret) || (port > 65535))
+ {
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_WARNING,
+ _ (
+ "IPv6 address did contain a valid port number after the last ':'\n"));
+ return GNUNET_SYSERR;
+ }
+ *(port_colon - 1) = '\0';
+ memset (r_buf, 0, sizeof(struct sockaddr_in6));
+ ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
+ if (ret <= 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _ ("Invalid IPv6 address `%s': %s\n"),
+ &zbuf[1],
+ strerror (errno));
+ return GNUNET_SYSERR;
+ }
+ r_buf->sin6_port = htons (port);
+ r_buf->sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
- r_buf->sin6_len = (u_char) sizeof(struct sockaddr_in6);
+ r_buf->sin6_len = (u_char) sizeof(struct sockaddr_in6);
#endif
- return GNUNET_OK;
+ return GNUNET_OK;
+ }
}
enum GNUNET_GenericReturnValue
GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
- uint16_t addrlen,
+ size_t addrlen,
struct sockaddr_in *r_buf)
{
unsigned int temps[4];
@@ -1151,25 +1157,21 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
uint8_t *af,
struct sockaddr **sa)
{
- char *cp = GNUNET_strdup (addr);
-
*af = AF_UNSPEC;
if ('[' == *addr)
{
/* IPv6 */
*sa = GNUNET_malloc (sizeof(struct sockaddr_in6));
if (GNUNET_OK !=
- GNUNET_STRINGS_to_address_ipv6 (cp,
- strlen (cp),
+ GNUNET_STRINGS_to_address_ipv6 (addr,
+ strlen (addr),
(struct sockaddr_in6 *) *sa))
{
GNUNET_free (*sa);
*sa = NULL;
- GNUNET_free (cp);
return 0;
}
*af = AF_INET6;
- GNUNET_free (cp);
return sizeof(struct sockaddr_in6);
}
else
@@ -1177,17 +1179,15 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
/* IPv4 */
*sa = GNUNET_malloc (sizeof(struct sockaddr_in));
if (GNUNET_OK !=
- GNUNET_STRINGS_to_address_ipv4 (cp,
- strlen (cp),
+ GNUNET_STRINGS_to_address_ipv4 (addr,
+ strlen (addr),
(struct sockaddr_in *) *sa))
{
GNUNET_free (*sa);
*sa = NULL;
- GNUNET_free (cp);
return 0;
}
*af = AF_INET;
- GNUNET_free (cp);
return sizeof(struct sockaddr_in);
}
}
@@ -1198,14 +1198,21 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
* freed with a single call to GNUNET_free();
*/
static char *const *
-_make_continuous_arg_copy (int argc, char *const *argv)
+_make_continuous_arg_copy (int argc,
+ char *const *argv)
{
size_t argvsize = 0;
char **new_argv;
char *p;
for (int i = 0; i < argc; i++)
+ {
+ size_t ail = strlen (argv[i]);
+
+ GNUNET_assert (SIZE_MAX - 1 - sizeof (char *) > argvsize);
+ GNUNET_assert (SIZE_MAX - ail > argvsize + 1 + sizeof (char*));
argvsize += strlen (argv[i]) + 1 + sizeof(char *);
+ }
new_argv = GNUNET_malloc (argvsize + sizeof(char *));
p = (char *) &new_argv[argc + 1];
for (int i = 0; i < argc; i++)
@@ -1290,19 +1297,12 @@ parse_port_policy (const char *port_policy,
struct GNUNET_STRINGS_IPv4NetworkPolicy *
GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
{
- unsigned int count;
- unsigned int i;
- unsigned int j;
- unsigned int len;
- int cnt;
- unsigned int pos;
+ size_t count;
+ size_t len;
+ size_t pos;
unsigned int temps[8];
- int slash;
struct GNUNET_STRINGS_IPv4NetworkPolicy *result;
- int colon;
- int end;
char *routeList;
- char dummy[2];
if (NULL == routeListX)
return NULL;
@@ -1311,15 +1311,19 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
return NULL;
routeList = GNUNET_strdup (routeListX);
count = 0;
- for (i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
if (routeList[i] == ';')
count++;
- result = GNUNET_malloc (sizeof(struct GNUNET_STRINGS_IPv4NetworkPolicy)
- * (count + 1));
- i = 0;
+ GNUNET_assert (count < SIZE_MAX);
+ result = GNUNET_new_array (count + 1,
+ struct GNUNET_STRINGS_IPv4NetworkPolicy);
pos = 0;
- while (i < count)
+ for (size_t i = 0; i < count; i++)
{
+ size_t colon;
+ size_t end;
+ char dummy;
+
for (colon = pos; ':' != routeList[colon]; colon++)
if ((';' == routeList[colon]) || ('\0' == routeList[colon]))
break;
@@ -1335,20 +1339,20 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
if (GNUNET_OK != parse_port_policy (&routeList[colon + 1], &result[i].pp))
break;
}
- cnt = sscanf (&routeList[pos],
- "%u.%u.%u.%u/%u.%u.%u.%u%1s",
- &temps[0],
- &temps[1],
- &temps[2],
- &temps[3],
- &temps[4],
- &temps[5],
- &temps[6],
- &temps[7],
- dummy);
- if (8 == cnt)
+ if (8 ==
+ sscanf (&routeList[pos],
+ "%u.%u.%u.%u/%u.%u.%u.%u%c",
+ &temps[0],
+ &temps[1],
+ &temps[2],
+ &temps[3],
+ &temps[4],
+ &temps[5],
+ &temps[6],
+ &temps[7],
+ &dummy))
{
- for (j = 0; j < 8; j++)
+ for (unsigned int j = 0; j < 8; j++)
if (temps[j] > 0xFF)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1363,68 +1367,72 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
result[i].netmask.s_addr = htonl ((temps[4] << 24) + (temps[5] << 16)
+ (temps[6] << 8) + temps[7]);
pos = end + 1;
- i++;
continue;
}
+
/* try second notation */
- cnt = sscanf (&routeList[pos],
- "%u.%u.%u.%u/%u%1s",
+ {
+ unsigned int slash;
+
+ if (5 ==
+ sscanf (&routeList[pos],
+ "%u.%u.%u.%u/%u%c",
&temps[0],
&temps[1],
&temps[2],
&temps[3],
&slash,
- dummy);
- if (5 == cnt)
- {
- for (j = 0; j < 4; j++)
- if (temps[j] > 0xFF)
+ &dummy))
+ {
+ for (unsigned int j = 0; j < 4; j++)
+ if (temps[j] > 0xFF)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _ ("Invalid format for IP: `%s'\n"),
+ &routeList[pos]);
+ GNUNET_free (result);
+ GNUNET_free (routeList);
+ return NULL;
+ }
+ result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
+ + (temps[2] << 8) + temps[3]);
+ if (slash <= 32)
+ {
+ result[i].netmask.s_addr = 0;
+ while (slash > 0)
+ {
+ result[i].netmask.s_addr =
+ (result[i].netmask.s_addr >> 1) + 0x80000000;
+ slash--;
+ }
+ result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
+ pos = end + 1;
+ continue;
+ }
+ else
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _ ("Invalid format for IP: `%s'\n"),
- &routeList[pos]);
+ _ (
+ "Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
+ slash);
GNUNET_free (result);
GNUNET_free (routeList);
- return NULL;
- }
- result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
- + (temps[2] << 8) + temps[3]);
- if ((slash <= 32) && (slash >= 0))
- {
- result[i].netmask.s_addr = 0;
- while (slash > 0)
- {
- result[i].netmask.s_addr =
- (result[i].netmask.s_addr >> 1) + 0x80000000;
- slash--;
+ return NULL; /* error */
}
- result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
- pos = end + 1;
- i++;
- continue;
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _ ("Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
- slash);
- GNUNET_free (result);
- GNUNET_free (routeList);
- return NULL; /* error */
}
}
+
/* try third notation */
- slash = 32;
- cnt = sscanf (&routeList[pos],
- "%u.%u.%u.%u%1s",
- &temps[0],
- &temps[1],
- &temps[2],
- &temps[3],
- dummy);
- if (4 == cnt)
+ if (4 ==
+ sscanf (&routeList[pos],
+ "%u.%u.%u.%u%c",
+ &temps[0],
+ &temps[1],
+ &temps[2],
+ &temps[3],
+ &dummy))
{
- for (j = 0; j < 4; j++)
+ for (unsigned int j = 0; j < 4; j++)
if (temps[j] > 0xFF)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1436,15 +1444,8 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
}
result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
+ (temps[2] << 8) + temps[3]);
- result[i].netmask.s_addr = 0;
- while (slash > 0)
- {
- result[i].netmask.s_addr = (result[i].netmask.s_addr >> 1) + 0x80000000;
- slash--;
- }
- result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
+ result[i].netmask.s_addr = htonl (0xffffffff); /* yeah, the htonl is useless */
pos = end + 1;
- i++;
continue;
}
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1471,20 +1472,13 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
struct GNUNET_STRINGS_IPv6NetworkPolicy *
GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
{
- unsigned int count;
- unsigned int i;
- unsigned int len;
- unsigned int pos;
- int start;
- int slash;
+ size_t count;
+ size_t len;
+ size_t pos;
int ret;
char *routeList;
struct GNUNET_STRINGS_IPv6NetworkPolicy *result;
- unsigned int bits;
unsigned int off;
- int save;
- int colon;
- char dummy[2];
if (NULL == routeListX)
return NULL;
@@ -1493,8 +1487,8 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
return NULL;
routeList = GNUNET_strdup (routeListX);
count = 0;
- for (i = 0; i < len; i++)
- if (';' == routeList[i])
+ for (size_t j = 0; j < len; j++)
+ if (';' == routeList[j])
count++;
if (';' != routeList[len - 1])
{
@@ -1504,27 +1498,34 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
GNUNET_free (routeList);
return NULL;
}
-
- result = GNUNET_malloc (sizeof(struct GNUNET_STRINGS_IPv6NetworkPolicy)
- * (count + 1));
- i = 0;
+ GNUNET_assert (count < UINT_MAX);
+ result = GNUNET_new_array (count + 1,
+ struct GNUNET_STRINGS_IPv6NetworkPolicy);
pos = 0;
- while (i < count)
+ for (size_t i = 0; i < count; i++)
{
+ size_t start;
+ size_t slash;
+
start = pos;
while (';' != routeList[pos])
pos++;
slash = pos;
- while ((slash >= start) && (routeList[slash] != '/'))
+ while ( (slash >= start) &&
+ (routeList[slash] != '/') )
slash--;
if (slash < start)
{
- memset (&result[i].netmask, 0xFF, sizeof(struct in6_addr));
+ memset (&result[i].netmask,
+ 0xFF,
+ sizeof(struct in6_addr));
slash = pos;
}
else
{
+ size_t colon;
+
routeList[pos] = '\0';
for (colon = pos; ':' != routeList[colon]; colon--)
if ('/' == routeList[colon])
@@ -1533,19 +1534,28 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
{
routeList[colon] = '\0';
if (GNUNET_OK !=
- parse_port_policy (&routeList[colon + 1], &result[i].pp))
+ parse_port_policy (&routeList[colon + 1],
+ &result[i].pp))
{
GNUNET_free (result);
GNUNET_free (routeList);
return NULL;
}
}
- ret = inet_pton (AF_INET6, &routeList[slash + 1], &result[i].netmask);
+ ret = inet_pton (AF_INET6,
+ &routeList[slash + 1],
+ &result[i].netmask);
if (ret <= 0)
{
- save = errno;
- if ((1 != sscanf (&routeList[slash + 1], "%u%1s", &bits, dummy)) ||
- (bits > 128))
+ char dummy;
+ unsigned int bits;
+ int save = errno;
+
+ if ( (1 != sscanf (&routeList[slash + 1],
+ "%u%c",
+ &bits,
+ &dummy)) ||
+ (bits > 128) )
{
if (0 == ret)
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1554,7 +1564,8 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
else
{
errno = save;
- LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "inet_pton");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
+ "inet_pton");
}
GNUNET_free (result);
GNUNET_free (routeList);
@@ -1575,7 +1586,9 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
}
}
routeList[slash] = '\0';
- ret = inet_pton (AF_INET6, &routeList[start], &result[i].network);
+ ret = inet_pton (AF_INET6,
+ &routeList[start],
+ &result[i].network);
if (ret <= 0)
{
if (0 == ret)
@@ -1583,13 +1596,13 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
_ ("Wrong format `%s' for network\n"),
&routeList[slash + 1]);
else
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "inet_pton");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
+ "inet_pton");
GNUNET_free (result);
GNUNET_free (routeList);
return NULL;
}
pos++;
- i++;
}
GNUNET_free (routeList);
return result;
@@ -1614,7 +1627,7 @@ GNUNET_STRINGS_base64_encode (const void *in,
char *opt;
ret = 0;
- GNUNET_assert (len < SIZE_MAX / 4 * 3);
+ GNUNET_assert (len < SIZE_MAX / 4);
opt = GNUNET_malloc (2 + (len * 4 / 3) + 8);
for (size_t i = 0; i < len; ++i)
{
@@ -1860,15 +1873,23 @@ GNUNET_STRINGS_urldecode (const char *data,
size_t
-GNUNET_STRINGS_urlencode (const char *data,
- size_t len,
+GNUNET_STRINGS_urlencode (size_t len,
+ const char data[static len],
char **out)
{
struct GNUNET_Buffer buf = { 0 };
const uint8_t *i8 = (uint8_t *) data;
+ const uint8_t *end = (uint8_t *) (data + len);
- while (0 != *i8)
+ while (end != i8)
{
+ if (0 == *i8)
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
if (0 == (0x80 & *i8))
{
/* traditional ASCII */
@@ -1900,6 +1921,14 @@ GNUNET_STRINGS_urlencode (const char *data,
*i8 >> 4,
*i8 & 15);
i8++;
+ if ( (end == i8) ||
+ (0 == *i8) )
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
GNUNET_buffer_write_fstr (&buf,
"%%%X%X",
*i8 >> 4,
@@ -1912,6 +1941,14 @@ GNUNET_STRINGS_urlencode (const char *data,
/* 3-byte value, percent-encode */
for (unsigned int i = 0; i<3; i++)
{
+ if ( (end == i8) ||
+ (0 == *i8) )
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
GNUNET_buffer_write_fstr (&buf,
"%%%X%X",
*i8 >> 4,
@@ -1925,6 +1962,14 @@ GNUNET_STRINGS_urlencode (const char *data,
/* 4-byte value, percent-encode */
for (unsigned int i = 0; i<4; i++)
{
+ if ( (end == i8) ||
+ (0 == *i8) )
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
GNUNET_buffer_write_fstr (&buf,
"%%%X%X",
*i8 >> 4,
@@ -1939,6 +1984,14 @@ GNUNET_STRINGS_urlencode (const char *data,
/* 5-byte value, percent-encode (outside of UTF-8 modern standard, but so what) */
for (unsigned int i = 0; i<5; i++)
{
+ if ( (end == i8) ||
+ (0 == *i8) )
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
GNUNET_buffer_write_fstr (&buf,
"%%%X%X",
*i8 >> 4,
@@ -1954,6 +2007,14 @@ GNUNET_STRINGS_urlencode (const char *data,
/* 6-byte value, percent-encode (outside of UTF-8 modern standard, but so what) */
for (unsigned int i = 0; i<6; i++)
{
+ if ( (end == i8) ||
+ (0 == *i8) )
+ {
+ /* invalid UTF-8 (or bad @a len): fail */
+ GNUNET_break (0);
+ GNUNET_buffer_clear (&buf);
+ return 0;
+ }
GNUNET_buffer_write_fstr (&buf,
"%%%X%X",
*i8 >> 4,
diff --git a/src/lib/util/test_strings.c b/src/lib/util/test_strings.c
index 0e39b9958..e55741040 100644
--- a/src/lib/util/test_strings.c
+++ b/src/lib/util/test_strings.c
@@ -149,16 +149,16 @@ main (int argc, char *argv[])
GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx));
GNUNET_assert (rt.rel_value_us == rtx.rel_value_us);
- GNUNET_assert (0 != GNUNET_STRINGS_urlencode (URLENCODE_TEST_VECTOR_PLAIN,
- strlen (
+ GNUNET_assert (0 != GNUNET_STRINGS_urlencode (strlen (
URLENCODE_TEST_VECTOR_PLAIN),
+ URLENCODE_TEST_VECTOR_PLAIN,
&b));
WANT (URLENCODE_TEST_VECTOR_ENCODED, b);
GNUNET_free (b);
GNUNET_assert (0 !=
- GNUNET_STRINGS_urldecode (URLENCODE_TEST_VECTOR_ENCODED,
- strlen (
+ GNUNET_STRINGS_urldecode (strlen (
URLENCODE_TEST_VECTOR_ENCODED),
+ URLENCODE_TEST_VECTOR_ENCODED,
&b));
WANT (URLENCODE_TEST_VECTOR_PLAIN, b);
GNUNET_free (b);
diff --git a/src/plugin/gns/plugin_gnsrecord_gns.c b/src/plugin/gns/plugin_gnsrecord_gns.c
index cc0e3167a..36e0c9fde 100644
--- a/src/plugin/gns/plugin_gnsrecord_gns.c
+++ b/src/plugin/gns/plugin_gnsrecord_gns.c
@@ -337,7 +337,6 @@ gns_string_to_value (void *cls,
size_t rest;
char *prefix;
char *underscore_prefix;
- unsigned int protocol;
unsigned int record_type;
void *bval;
size_t bval_size;
diff --git a/src/plugin/messenger/plugin_gnsrecord_messenger.c b/src/plugin/messenger/plugin_gnsrecord_messenger.c
index ed675dd1d..81763e3b5 100644
--- a/src/plugin/messenger/plugin_gnsrecord_messenger.c
+++ b/src/plugin/messenger/plugin_gnsrecord_messenger.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2021--2023 GNUnet e.V.
+ Copyright (C) 2021--2024 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -126,7 +126,7 @@ messenger_string_to_value (void *cls,
{
case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY:
{
- char key[103];
+ char key[104];
const char *dash;
struct GNUNET_PeerIdentity door;
@@ -168,7 +168,7 @@ messenger_string_to_value (void *cls,
}
case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS:
{
- char flags[7];
+ char flags[8];
const char *dash;
if ((NULL == (dash = strchr (s, '-'))) ||
diff --git a/src/plugin/reclaim/pabc_helper.c b/src/plugin/reclaim/pabc_helper.c
index 65a633f7b..d7688e9e1 100644
--- a/src/plugin/reclaim/pabc_helper.c
+++ b/src/plugin/reclaim/pabc_helper.c
@@ -145,7 +145,9 @@ PABC_load_public_parameters (struct pabc_context *const ctx,
if (pp_name == NULL)
return GNUNET_SYSERR;
- GNUNET_STRINGS_urlencode (pp_name, strlen (pp_name), &pp_filename);
+ GNUNET_STRINGS_urlencode (strlen (pp_name),
+ pp_name,
+ &pp_filename);
if (GNUNET_YES != GNUNET_DISK_directory_test (pdir, GNUNET_YES))
{
GNUNET_free (pp_filename);
@@ -177,7 +179,9 @@ PABC_write_public_parameters (char const *const pp_name,
enum pabc_status status;
struct pabc_context *ctx = NULL;
- GNUNET_STRINGS_urlencode (pp_name, strlen (pp_name), &pp_filename);
+ GNUNET_STRINGS_urlencode (strlen (pp_name),
+ pp_name,
+ &pp_filename);
PABC_ASSERT (pabc_new_ctx (&ctx));
// store in json file
status = pabc_encode_public_parameters (ctx, pp, &json);
@@ -258,7 +262,9 @@ PABC_write_usr_ctx (char const *const usr_name,
return GNUNET_SYSERR;
}
- GNUNET_STRINGS_urlencode (pp_name, strlen (pp_name), &pp_filename);
+ GNUNET_STRINGS_urlencode (strlen (pp_name),
+ pp_name,
+ &pp_filename);
status = pabc_encode_user_ctx (ctx, pp, usr_ctx, &json);
if (PABC_OK != status)
{
@@ -329,7 +335,9 @@ PABC_read_usr_ctx (char const *const usr_name,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No user context given.\n");
return GNUNET_SYSERR;
}
- GNUNET_STRINGS_urlencode (pp_name, strlen (pp_name), &pp_filename);
+ GNUNET_STRINGS_urlencode (strlen (pp_name),
+ pp_name,
+ &pp_filename);
size_t fname_size = strlen (get_pabcdir ()) + 1 + strlen (usr_name) + 1
+ strlen (pp_filename) + strlen (PABC_USR_EXT) + 1;
diff --git a/src/service/cadet/cadet_test_lib.c b/src/service/cadet/cadet_test_lib.c
deleted file mode 100644
index 9c7b9063d..000000000
--- a/src/service/cadet/cadet_test_lib.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012, 2017 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file cadet/cadet_test_lib.c
- * @author Bartlomiej Polot
- * @brief library for writing CADET tests
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "cadet_test_lib.h"
-#include "gnunet_cadet_service.h"
-
-
-/**
- * Test context for a CADET Test.
- */
-struct GNUNET_CADET_TEST_Context
-{
- /**
- * Array of running peers.
- */
- struct GNUNET_TESTBED_Peer **peers;
-
- /**
- * Array of handles to the CADET for each peer.
- */
- struct GNUNET_CADET_Handle **cadets;
-
- /**
- * Operation associated with the connection to the CADET.
- */
- struct GNUNET_TESTBED_Operation **ops;
-
- /**
- * Number of peers running, size of the arrays above.
- */
- unsigned int num_peers;
-
- /**
- * Main function of the test to run once all CADETs are available.
- */
- GNUNET_CADET_TEST_AppMain app_main;
-
- /**
- * Closure for 'app_main'.
- */
- void *app_main_cls;
-
- /**
- * Handler for incoming tunnels.
- */
- GNUNET_CADET_ConnectEventHandler connects;
-
- /**
- * Function called when the transmit window size changes.
- */
- GNUNET_CADET_WindowSizeEventHandler window_changes;
-
- /**
- * Cleaner for destroyed incoming tunnels.
- */
- GNUNET_CADET_DisconnectEventHandler disconnects;
-
- /**
- * Message handlers.
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * Application ports.
- */
- const struct GNUNET_HashCode **ports;
-
- /**
- * Number of ports in #ports.
- */
- unsigned int port_count;
-};
-
-
-/**
- * Context for a cadet adapter callback.
- */
-struct GNUNET_CADET_TEST_AdapterContext
-{
- /**
- * Peer number for the particular peer.
- */
- unsigned int peer;
-
- /**
- * Port handlers for open ports.
- */
- struct GNUNET_CADET_Port **ports;
-
- /**
- * General context.
- */
- struct GNUNET_CADET_TEST_Context *ctx;
-};
-
-
-/**
- * Adapter function called to establish a connection to
- * the CADET service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-cadet_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
- struct GNUNET_CADET_TEST_Context *ctx = actx->ctx;
- struct GNUNET_CADET_Handle *h;
-
- h = GNUNET_CADET_connect (cfg);
- if (NULL == h)
- {
- GNUNET_break (0);
- return NULL;
- }
- if (NULL == ctx->ports)
- return h;
- actx->ports = GNUNET_new_array (ctx->port_count,
- struct GNUNET_CADET_Port *);
- for (unsigned int i = 0; i < ctx->port_count; i++)
- {
- actx->ports[i] = GNUNET_CADET_open_port (h,
- ctx->ports[i],
- ctx->connects,
- (void *) (long) actx->peer,
- ctx->window_changes,
- ctx->disconnects,
- ctx->handlers);
- }
- return h;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * the CADET service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-cadet_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_CADET_Handle *cadet = op_result;
- struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
-
- if (NULL != actx->ports)
- {
- for (unsigned int i = 0; i < actx->ctx->port_count; i++)
- {
- GNUNET_CADET_close_port (actx->ports[i]);
- actx->ports[i] = NULL;
- }
- GNUNET_free (actx->ports);
- }
- GNUNET_free (actx);
- GNUNET_CADET_disconnect (cadet);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed.
- *
- * @param cls The callback closure from functions generating an operation.
- * @param op The operation that has been finished.
- * @param ca_result The service handle returned from
- * GNUNET_TESTBED_ConnectAdapter() (cadet handle).
- * @param emsg Error message in case the operation has failed.
- * NULL if operation has executed successfully.
- */
-static void
-cadet_connect_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_CADET_TEST_Context *ctx = cls;
-
- if (NULL != emsg)
- {
- fprintf (stderr,
- "Failed to connect to CADET service: %s\n",
- emsg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (op == ctx->ops[i])
- {
- ctx->cadets[i] = ca_result;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "...cadet %u connected\n",
- i);
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (NULL == ctx->cadets[i])
- return;
- /* still some CADET connections missing */
- /* all CADET connections ready! */
- ctx->app_main (ctx->app_main_cls,
- ctx,
- ctx->num_peers,
- ctx->peers,
- ctx->cadets);
-}
-
-
-void
-GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx)
-{
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- {
- GNUNET_assert (NULL != ctx->ops[i]);
- GNUNET_TESTBED_operation_done (ctx->ops[i]);
- ctx->ops[i] = NULL;
- }
- GNUNET_free (ctx->ops);
- GNUNET_free (ctx->cadets);
- GNUNET_free (ctx->handlers);
- GNUNET_free (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Callback run when the testbed is ready (peers running and connected to
- * each other)
- *
- * @param cls Closure (context).
- * @param h the run handle
- * @param num_peers Number of peers that are running.
- * @param peers Handles to each one of the @c num_peers peers.
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-cadet_test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- struct GNUNET_CADET_TEST_Context *ctx = cls;
-
- if (0 != links_failed)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Some links failed (%u), ending\n",
- links_failed);
- exit (77);
- }
- if (num_peers != ctx->num_peers)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peers started %u/%u, ending\n",
- num_peers,
- ctx->num_peers);
- exit (1);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testbed up, %u peers and %u links\n",
- num_peers,
- links_succeeded);
- ctx->peers = peers;
- for (unsigned int i = 0; i < num_peers; i++)
- {
- struct GNUNET_CADET_TEST_AdapterContext *newctx;
-
- newctx = GNUNET_new (struct GNUNET_CADET_TEST_AdapterContext);
- newctx->peer = i;
- newctx->ctx = ctx;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Connecting to cadet %u\n",
- i);
- ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
- peers[i],
- "cadet",
- &cadet_connect_cb,
- ctx,
- &cadet_connect_adapter,
- &cadet_disconnect_adapter,
- newctx);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "op handle %p\n",
- ctx->ops[i]);
- }
-}
-
-
-/**
- * Run a test using the given name, configuration file and number of peers.
- * All cadet callbacks will receive the peer number (long) as the closure.
- *
- * @param testname Name of the test (for logging).
- * @param cfgfile Name of the configuration file.
- * @param num_peers Number of peers to start.
- * @param tmain Main function to run once the testbed is ready.
- * @param tmain_cls Closure for @a tmain.
- * @param connects Handler for incoming channels.
- * @param window_changes Handler for the window size change notification.
- * @param disconnects Cleaner for destroyed incoming channels.
- * @param handlers Message handlers.
- * @param ports Ports the peers offer, NULL-terminated.
- */
-void
-GNUNET_CADET_TEST_ruN (const char *testname,
- const char *cfgfile,
- unsigned int num_peers,
- GNUNET_CADET_TEST_AppMain tmain,
- void *tmain_cls,
- GNUNET_CADET_ConnectEventHandler connects,
- GNUNET_CADET_WindowSizeEventHandler window_changes,
- GNUNET_CADET_DisconnectEventHandler disconnects,
- struct GNUNET_MQ_MessageHandler *handlers,
- const struct GNUNET_HashCode **ports)
-{
- struct GNUNET_CADET_TEST_Context *ctx;
-
- ctx = GNUNET_new (struct GNUNET_CADET_TEST_Context);
- ctx->num_peers = num_peers;
- ctx->ops = GNUNET_new_array (num_peers,
- struct GNUNET_TESTBED_Operation *);
- ctx->cadets = GNUNET_new_array (num_peers,
- struct GNUNET_CADET_Handle *);
- ctx->app_main = tmain;
- ctx->app_main_cls = tmain_cls;
- ctx->connects = connects;
- ctx->window_changes = window_changes;
- ctx->disconnects = disconnects;
- ctx->handlers = GNUNET_MQ_copy_handlers (handlers);
- ctx->ports = ports;
- ctx->port_count = 0;
- while (NULL != ctx->ports[ctx->port_count])
- ctx->port_count++;
- GNUNET_TESTBED_test_run (testname,
- cfgfile,
- num_peers,
- 0LL, NULL, NULL,
- &cadet_test_run,
- ctx);
-}
-
-
-/* end of cadet_test_lib.c */
diff --git a/src/service/cadet/cadet_test_lib.h b/src/service/cadet/cadet_test_lib.h
deleted file mode 100644
index 7d446801a..000000000
--- a/src/service/cadet/cadet_test_lib.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012,2017 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file cadet/cadet_test_lib.h
- * @author Bartlomiej Polot
- * @brief library for writing CADET tests
- */
-#ifndef CADET_TEST_LIB_H
-#define CADET_TEST_LIB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-#include "gnunet_testbed_service.h"
-#include "gnunet_cadet_service.h"
-
-/**
- * Test context for a CADET Test.
- */
-struct GNUNET_CADET_TEST_Context;
-
-
-/**
- * Main function of a CADET test.
- *
- * @param cls Closure.
- * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
- * @param num_peers Number of peers that are running.
- * @param peers Array of peers.
- * @param cadets Handle to each of the CADETs of the peers.
- */
-typedef void (*GNUNET_CADET_TEST_AppMain) (void *cls,
- struct GNUNET_CADET_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_CADET_Handle **cadets);
-
-
-/**
- * Run a test using the given name, configuration file and number of peers.
- * All cadet callbacks will receive the peer number (long) as the closure.
- *
- * @param testname Name of the test (for logging).
- * @param cfgfile Name of the configuration file.
- * @param num_peers Number of peers to start.
- * @param tmain Main function to run once the testbed is ready.
- * @param tmain_cls Closure for @a tmain.
- * @param connects Handler for incoming channels.
- * @param window_changes Handler for the window size change notification.
- * @param disconnects Cleaner for destroyed incoming channels.
- * @param handlers Message handlers.
- * @param ports Ports the peers offer, NULL-terminated.
- */
-void
-GNUNET_CADET_TEST_ruN (const char *testname,
- const char *cfgfile,
- unsigned int num_peers,
- GNUNET_CADET_TEST_AppMain tmain,
- void *tmain_cls,
- GNUNET_CADET_ConnectEventHandler connects,
- GNUNET_CADET_WindowSizeEventHandler window_changes,
- GNUNET_CADET_DisconnectEventHandler disconnects,
- struct GNUNET_MQ_MessageHandler *handlers,
- const struct GNUNET_HashCode **ports);
-
-/**
- * Clean up the testbed.
- *
- * @param ctx handle for the testbed
- */
-void
-GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-
-/* ifndef CADET_TEST_LIB_H */
-#endif
diff --git a/src/service/core/meson.build b/src/service/core/meson.build
index 19ffd0ddc..09fdc8dab 100644
--- a/src/service/core/meson.build
+++ b/src/service/core/meson.build
@@ -63,8 +63,7 @@ shared_module('gnunet_test_core_plugin_cmd_just_run',
libgnunetarm_dep
],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir')/'gnunet')
+ install: false)
executable ('gnunet-service-core',
gnunetservicecore_src,
diff --git a/src/service/dht/dht_test_lib.c b/src/service/dht/dht_test_lib.c
deleted file mode 100644
index 29c5088d1..000000000
--- a/src/service/dht/dht_test_lib.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/dht_test_lib.c
- * @author Christian Grothoff
- * @brief library for writing DHT tests
- */
-#include "platform.h"
-#include "dht_test_lib.h"
-
-/**
- * Test context for a DHT Test.
- */
-struct GNUNET_DHT_TEST_Context
-{
- /**
- * Array of running peers.
- */
- struct GNUNET_TESTBED_Peer **peers;
-
- /**
- * Array of handles to the DHT for each peer.
- */
- struct GNUNET_DHT_Handle **dhts;
-
- /**
- * Operation associated with the connection to the DHT.
- */
- struct GNUNET_TESTBED_Operation **ops;
-
- /**
- * Main function of the test to run once all DHTs are available.
- */
- GNUNET_DHT_TEST_AppMain app_main;
-
- /**
- * Closure for 'app_main'.
- */
- void *app_main_cls;
-
- /**
- * Number of peers running, size of the arrays above.
- */
- unsigned int num_peers;
-};
-
-
-/**
- * Adapter function called to establish a connection to
- * the DHT service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-dht_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- return GNUNET_DHT_connect (cfg, 16);
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * the DHT service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-dht_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_DHT_Handle *dht = op_result;
-
- GNUNET_DHT_disconnect (dht);
-}
-
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-dht_connect_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- if (NULL != emsg)
- {
- fprintf (stderr,
- "Failed to connect to DHT service: %s\n",
- emsg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (op == ctx->ops[i])
- ctx->dhts[i] = ca_result;
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- if (NULL == ctx->dhts[i])
- return;
- /* still some DHT connections missing */
- /* all DHT connections ready! */
- ctx->app_main (ctx->app_main_cls,
- ctx,
- ctx->num_peers,
- ctx->peers,
- ctx->dhts);
-}
-
-
-void
-GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx)
-{
- for (unsigned int i = 0; i < ctx->num_peers; i++)
- GNUNET_TESTBED_operation_done (ctx->ops[i]);
- GNUNET_free (ctx->ops);
- GNUNET_free (ctx->dhts);
- GNUNET_free (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-dht_test_run (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- GNUNET_assert (num_peers == ctx->num_peers);
- ctx->peers = peers;
- for (unsigned int i = 0; i < num_peers; i++)
- ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
- peers[i],
- "dht",
- &dht_connect_cb,
- ctx,
- &dht_connect_adapter,
- &dht_disconnect_adapter,
- ctx);
-}
-
-
-void
-GNUNET_DHT_TEST_run (const char *testname,
- const char *cfgname,
- unsigned int num_peers,
- GNUNET_DHT_TEST_AppMain tmain,
- void *tmain_cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx;
-
- ctx = GNUNET_new (struct GNUNET_DHT_TEST_Context);
- ctx->num_peers = num_peers;
- ctx->ops = GNUNET_new_array (num_peers,
- struct GNUNET_TESTBED_Operation *);
- ctx->dhts = GNUNET_new_array (num_peers,
- struct GNUNET_DHT_Handle *);
- ctx->app_main = tmain;
- ctx->app_main_cls = tmain_cls;
- (void) GNUNET_TESTBED_test_run (testname,
- cfgname,
- num_peers,
- 0LL, NULL, NULL,
- &dht_test_run, ctx);
-}
-
-
-/* end of dht_test_lib.c */
diff --git a/src/service/dht/dht_test_lib.h b/src/service/dht/dht_test_lib.h
deleted file mode 100644
index efffc9ef7..000000000
--- a/src/service/dht/dht_test_lib.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/dht_test_lib.h
- * @author Christian Grothoff
- * @brief library for writing DHT tests
- */
-#ifndef DHT_TEST_LIB_H
-#define DHT_TEST_LIB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-#include "gnunet_testbed_service.h"
-#include "gnunet_dht_service.h"
-
-/**
- * Test context for a DHT Test.
- */
-struct GNUNET_DHT_TEST_Context;
-
-
-/**
- * Main function of a DHT test.
- *
- * @param cls closure
- * @param ctx argument to give to GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-typedef void (*GNUNET_DHT_TEST_AppMain) (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts);
-
-
-/**
- * Run a test using the given name, configuration file and number of
- * peers.
- *
- * @param testname name of the test (for logging)
- * @param cfgname name of the configuration file
- * @param num_peers number of peers to start
- * @param tmain main function to run once the testbed is ready
- * @param tmain_cls closure for 'tmain'
- */
-void
-GNUNET_DHT_TEST_run (const char *testname,
- const char *cfgname,
- unsigned int num_peers,
- GNUNET_DHT_TEST_AppMain tmain,
- void *tmain_cls);
-
-
-/**
- * Clean up the testbed.
- *
- * @param ctx handle for the testbed
- */
-void
-GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx);
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-/* ifndef DHT_TEST_LIB_H */
-#endif
diff --git a/src/service/dht/test_dht_monitor.c b/src/service/dht/test_dht_monitor.c
deleted file mode 100644
index 3960a2235..000000000
--- a/src/service/dht/test_dht_monitor.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/test_dht_monitor.c
- * @brief Test for the dht monitoring API; checks that we receive "some" monitor events
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_dht_service.h"
-#include "dht_test_lib.h"
-
-
-/**
- * How long do we run the test at most?
- */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
-
-/**
- * How often do we run the PUTs?
- */
-#define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
- 10)
-
-
-/**
- * Information we keep for each GET operation.
- */
-struct GetOperation
-{
- /**
- * DLL.
- */
- struct GetOperation *next;
-
- /**
- * DLL.
- */
- struct GetOperation *prev;
-
- /**
- * Handle for the operation.
- */
- struct GNUNET_DHT_GetHandle *get;
-};
-
-
-/**
- * Return value from 'main'.
- */
-static int ok;
-
-/**
- * Head of list of active GET operations.
- */
-static struct GetOperation *get_head;
-
-/**
- * Tail of list of active GET operations.
- */
-static struct GetOperation *get_tail;
-
-/**
- * Array of the testbed's peers.
- */
-static struct GNUNET_TESTBED_Peer **my_peers;
-
-/**
- * Number of peers to run.
- */
-static unsigned int NUM_PEERS = 3;
-
-/**
- * Task called to disconnect peers.
- */
-static struct GNUNET_SCHEDULER_Task *timeout_task;
-
-/**
- * Task to do DHT_puts
- */
-static struct GNUNET_SCHEDULER_Task *put_task;
-
-static struct GNUNET_DHT_MonitorHandle **monitors;
-
-static unsigned int monitor_counter;
-
-
-/**
- * Task run on success or timeout to clean up.
- * Terminates active get operations and shuts down
- * the testbed.
- *
- * @param cls the `struct GNUNET_DHT_TEST_Context`
- */
-static void
-shutdown_task (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
- unsigned int i;
- struct GetOperation *get_op;
-
- ok = (monitor_counter > NUM_PEERS) ? 0 : 2;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Received %u monitor events\n",
- monitor_counter);
- while (NULL != (get_op = get_tail))
- {
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- }
- for (i = 0; i < NUM_PEERS; i++)
- GNUNET_DHT_monitor_stop (monitors[i]);
- GNUNET_free (monitors);
- GNUNET_SCHEDULER_cancel (put_task);
- GNUNET_DHT_TEST_cleanup (ctx);
- if (NULL != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
-}
-
-
-/**
- * Task run on success or timeout to clean up.
- * Terminates active get operations and shuts down
- * the testbed.
- *
- * @param cls NULL
- */
-static void
-timeout_task_cb (void *cls)
-{
- timeout_task = NULL;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator called on each result obtained for a DHT
- * operation that expects a reply
- *
- * @param cls closure with our 'struct GetOperation'
- * @param exp when will this value expire
- * @param key key of the result
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path peers on reply path (or NULL if not recorded)
- * @param get_path_length number of entries in get_path
- * @param put_path peers on the PUT path (or NULL if not recorded)
- * @param put_path_length number of entries in get_path
- * @param type type of the result
- * @param size number of bytes in data
- * @param data pointer to the result data
- */
-static void
-dht_get_handler (void *cls, struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
-{
- struct GetOperation *get_op = cls;
- struct GNUNET_HashCode want;
-
- if (sizeof(struct GNUNET_HashCode) != size)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_CRYPTO_hash (key,
- sizeof(*key),
- &want);
- if (0 != memcmp (&want, data, sizeof(want)))
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get successful\n");
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- if (NULL != get_head)
- return;
- /* all DHT GET operations successful; terminate! */
- ok = 0;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Task to put the id of each peer into the DHT.
- *
- * @param cls array with NUM_PEERS DHT handles
- */
-static void
-do_puts (void *cls)
-{
- struct GNUNET_DHT_Handle **hs = cls;
- struct GNUNET_HashCode key;
- struct GNUNET_HashCode value;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting values into DHT\n");
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- GNUNET_CRYPTO_hash (&i, sizeof(i), &key);
- GNUNET_CRYPTO_hash (&key, sizeof(key), &value);
- GNUNET_DHT_put (hs[i], &key, 10U,
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
- sizeof(value), &value,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- NULL, NULL);
- }
- put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY,
- &do_puts, hs);
-}
-
-
-/**
- * Callback called on each GET request going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param desired_replication_level Desired replication level.
- * @param key Key of the requested data.
- */
-static void
-monitor_get_cb (void *cls,
- enum GNUNET_DHT_RouteOption options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- const struct GNUNET_HashCode *key)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a GET message for key %s\n",
- i,
- GNUNET_h2s (key));
- monitor_counter++;
-}
-
-
-/**
- * Callback called on each PUT request going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param path_length number of entries in path (or 0 if not recorded).
- * @param path peers on the PUT path (or NULL if not recorded).
- * @param desired_replication_level Desired replication level.
- * @param exp Expiration time of the data.
- * @param key Key under which data is to be stored.
- * @param data Pointer to the data carried.
- * @param size Number of bytes in data.
- */
-static void
-monitor_put_cb (void *cls,
- enum GNUNET_DHT_RouteOption options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- const struct GNUNET_PeerIdentity *trunc_peer,
- unsigned int path_length,
- const struct GNUNET_DHT_PathElement *path,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const void *data,
- size_t size)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a PUT message for key %s with %u bytes\n",
- i,
- GNUNET_h2s (key),
- (unsigned int) size);
- monitor_counter++;
-}
-
-
-/**
- * Callback called on each GET reply going through the DHT.
- * Prints the info about the intercepted packet and increments a counter.
- *
- * @param cls Closure.
- * @param type The type of data in the result.
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path Peers on GET path (or NULL if not recorded).
- * @param get_path_length number of entries in get_path.
- * @param put_path peers on the PUT path (or NULL if not recorded).
- * @param put_path_length number of entries in get_path.
- * @param exp Expiration time of the data.
- * @param key Key of the data.
- * @param data Pointer to the result data.
- * @param size Number of bytes in data.
- */
-static void
-monitor_res_cb (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *key,
- const void *data,
- size_t size)
-{
- unsigned int i;
-
- i = (unsigned int) (long) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%u got a REPLY message for key %s with %u bytes\n",
- i,
- GNUNET_h2s (key),
- (unsigned int) size);
- monitor_counter++;
-}
-
-
-/**
- * Main function of the test.
- *
- * @param cls closure (NULL)
- * @param ctx argument to give to GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-static void
-run (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts)
-{
- unsigned int i;
- unsigned int j;
- struct GNUNET_HashCode key;
- struct GetOperation *get_op;
-
- GNUNET_assert (NUM_PEERS == num_peers);
- my_peers = peers;
- monitors = GNUNET_new_array (num_peers,
- struct GNUNET_DHT_MonitorHandle *);
- for (i = 0; i < num_peers; i++)
- monitors[i] = GNUNET_DHT_monitor_start (dhts[i],
- GNUNET_BLOCK_TYPE_ANY,
- NULL,
- &monitor_get_cb,
- &monitor_res_cb,
- &monitor_put_cb,
- (void *) (long) i);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers setup, starting test\n");
- put_task = GNUNET_SCHEDULER_add_now (&do_puts, dhts);
- for (i = 0; i < num_peers; i++)
- {
- GNUNET_CRYPTO_hash (&i, sizeof(i), &key);
- for (j = 0; j < num_peers; j++)
- {
- get_op = GNUNET_new (struct GetOperation);
- GNUNET_CONTAINER_DLL_insert (get_head,
- get_tail,
- get_op);
- get_op->get = GNUNET_DHT_get_start (dhts[j],
- GNUNET_BLOCK_TYPE_TEST, /* type */
- &key, /*key to search */
- 4U, /* replication level */
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_handler, get_op);
- }
- }
- timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &timeout_task_cb,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- ctx);
-}
-
-
-/**
- * Main: start test
- */
-int
-main (int xargc, char *xargv[])
-{
- GNUNET_DHT_TEST_run ("test-dht-monitor",
- "test_dht_monitor.conf",
- NUM_PEERS,
- &run, NULL);
- return ok;
-}
-
-
-/* end of test_dht_monitor.c */
diff --git a/src/service/dht/test_dht_monitor.conf b/src/service/dht/test_dht_monitor.conf
deleted file mode 100644
index 703065f00..000000000
--- a/src/service/dht/test_dht_monitor.conf
+++ /dev/null
@@ -1,39 +0,0 @@
-@INLINE@ ../../../contrib/conf/gnunet/no_forcestart.conf
-@INLINE@ ../../../contrib/conf/gnunet/no_autostart_above_core.conf
-
-
-[dhtcache]
-QUOTA = 1 MB
-DATABASE = heap
-
-[transport]
-PLUGINS = tcp
-
-[ats]
-WAN_QUOTA_IN = 1 GB
-WAN_QUOTA_OUT = 1 GB
-
-[testbed]
-OVERLAY_TOPOLOGY = LINE
-
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-monitor/
-
-[nat]
-DISABLEV6 = YES
-ENABLE_UPNP = NO
-BEHIND_NAT = NO
-ALLOW_NAT = NO
-INTERNAL_ADDRESS = 127.0.0.1
-EXTERNAL_ADDRESS = 127.0.0.1
-USE_LOCALADDR = YES
-RETURN_LOCAL_ADDRESSES = YES
-
-
-[dht]
-START_ON_DEMAND = YES
-IMMEDIATE_START = YES
-
-[nse]
-START_ON_DEMAND = YES
-WORKBITS = 1
diff --git a/src/service/dht/test_dht_topo.c b/src/service/dht/test_dht_topo.c
deleted file mode 100644
index a8294c65d..000000000
--- a/src/service/dht/test_dht_topo.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2012, 2016 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file dht/test_dht_topo.c
- * @author Christian Grothoff
- * @brief Test for the dht service: store and retrieve in various topologies.
- * Each peer stores a value from the DHT and then each peer tries to get each
- * value from each other peer.
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_dht_service.h"
-#include "dht_test_lib.h"
-
-/**
- * How long until we give up on fetching the data?
- */
-#define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
- 120)
-
-/**
- * How frequently do we execute the PUTs?
- */
-#define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
- 5)
-
-
-/**
- * Information we keep for each GET operation.
- */
-struct GetOperation
-{
- /**
- * DLL.
- */
- struct GetOperation *next;
-
- /**
- * DLL.
- */
- struct GetOperation *prev;
-
- /**
- * Operation to fetch @a me.
- */
- struct GNUNET_TESTBED_Operation *to;
-
- /**
- * Handle for the operation.
- */
- struct GNUNET_DHT_GetHandle *get;
-
- /**
- * DHT used by this operation.
- */
- struct GNUNET_DHT_Handle *dht;
-
- /**
- * Key we are looking up.
- */
- struct GNUNET_HashCode key;
-
- /**
- * At which peer is this operation being performed?
- */
- struct GNUNET_PeerIdentity me;
-};
-
-
-/**
- * Result of the test.
- */
-static int ok;
-
-/**
- * Task to do DHT_puts
- */
-static struct GNUNET_SCHEDULER_Task *put_task;
-
-/**
- * Task to do DHT_gets
- */
-static struct GNUNET_SCHEDULER_Task *get_task;
-
-/**
- * Task to time out / regular shutdown.
- */
-static struct GNUNET_SCHEDULER_Task *timeout_task;
-
-/**
- * Head of list of active GET operations.
- */
-static struct GetOperation *get_head;
-
-/**
- * Tail of list of active GET operations.
- */
-static struct GetOperation *get_tail;
-
-/**
- * Array of the testbed's peers.
- */
-static struct GNUNET_TESTBED_Peer **my_peers;
-
-/**
- * Number of peers to run.
- */
-static unsigned int NUM_PEERS;
-
-
-/**
- * Statistics we print out.
- */
-static struct
-{
- const char *subsystem;
- const char *name;
- unsigned long long total;
-} stats[] = {
- { "core", "# bytes decrypted", 0 },
- { "core", "# bytes encrypted", 0 },
- { "core", "# type maps received", 0 },
- { "core", "# session keys confirmed via PONG", 0 },
- { "core", "# peers connected", 0 },
- { "core", "# key exchanges initiated", 0 },
- { "core", "# send requests dropped (disconnected)", 0 },
- { "core", "# transmissions delayed due to corking", 0 },
- { "core", "# messages discarded (expired prior to transmission)", 0 },
- { "core", "# messages discarded (disconnected)", 0 },
- { "core", "# discarded CORE_SEND requests", 0 },
- { "core", "# discarded lower priority CORE_SEND requests", 0 },
- { "transport", "# bytes received via TCP", 0 },
- { "transport", "# bytes transmitted via TCP", 0 },
- { "dht", "# PUT messages queued for transmission", 0 },
- { "dht", "# P2P PUT requests received", 0 },
- { "dht", "# GET messages queued for transmission", 0 },
- { "dht", "# P2P GET requests received", 0 },
- { "dht", "# RESULT messages queued for transmission", 0 },
- { "dht", "# P2P RESULTS received", 0 },
- { "dht", "# Queued messages discarded (peer disconnected)", 0 },
- { "dht", "# Peers excluded from routing due to Bloomfilter", 0 },
- { "dht", "# Peer selection failed", 0 },
- { "dht", "# FIND PEER requests ignored due to Bloomfilter", 0 },
- { "dht", "# FIND PEER requests ignored due to lack of HELLO", 0 },
- { "dht", "# P2P FIND PEER requests processed", 0 },
- { "dht", "# P2P GET requests ONLY routed", 0 },
- { "dht", "# Preference updates given to core", 0 },
- { "dht", "# REPLIES ignored for CLIENTS (no match)", 0 },
- { "dht", "# GET requests from clients injected", 0 },
- { "dht", "# GET requests received from clients", 0 },
- { "dht", "# GET STOP requests received from clients", 0 },
- { "dht", "# ITEMS stored in datacache", 0 },
- { "dht", "# Good RESULTS found in datacache", 0 },
- { "dht", "# GET requests given to datacache", 0 },
- { NULL, NULL, 0 }
-};
-
-
-static struct GNUNET_DHT_TEST_Context *
-stop_ops (void)
-{
- struct GetOperation *get_op;
- struct GNUNET_DHT_TEST_Context *ctx = NULL;
-
- if (NULL != timeout_task)
- {
- ctx = GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
- if (NULL != put_task)
- {
- GNUNET_SCHEDULER_cancel (put_task);
- put_task = NULL;
- }
- if (NULL != get_task)
- {
- GNUNET_SCHEDULER_cancel (get_task);
- get_task = NULL;
- }
- while (NULL != (get_op = get_tail))
- {
- if (NULL != get_op->to)
- {
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- }
- if (NULL != get_op->get)
- {
- GNUNET_DHT_get_stop (get_op->get);
- get_op->get = NULL;
- }
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- }
- return ctx;
-}
-
-
-/**
- * Function called once we're done processing stats.
- *
- * @param cls the test context
- * @param op the stats operation
- * @param emsg error message on failure
- */
-static void
-stats_finished (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- if (NULL != op)
- GNUNET_TESTBED_operation_done (op);
- if (NULL != emsg)
- {
- fprintf (stderr,
- _ ("Gathering statistics failed: %s\n"),
- emsg);
- GNUNET_SCHEDULER_cancel (put_task);
- GNUNET_DHT_TEST_cleanup (ctx);
- return;
- }
- for (unsigned int i = 0; NULL != stats[i].name; i++)
- fprintf (stderr,
- "%6s/%60s = %12llu\n",
- stats[i].subsystem,
- stats[i].name,
- stats[i].total);
- GNUNET_DHT_TEST_cleanup (ctx);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Function called to process statistic values from all peers.
- *
- * @param cls closure
- * @param peer the peer the statistic belong to
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static enum GNUNET_GenericReturnValue
-handle_stats (void *cls,
- const struct GNUNET_TESTBED_Peer *peer,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- for (unsigned int i = 0; NULL != stats[i].name; i++)
- if ((0 == strcasecmp (subsystem,
- stats[i].subsystem)) &&
- (0 == strcasecmp (name,
- stats[i].name)))
- stats[i].total += value;
- return GNUNET_OK;
-}
-
-
-/**
- * Task run on shutdown to clean up. Terminates active get operations
- * and shuts down the testbed.
- *
- * @param cls the 'struct GNUNET_DHT_TestContext'
- */
-static void
-shutdown_task (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx;
-
- (void) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Performing shutdown\n");
- ctx = stop_ops ();
- if (NULL != ctx)
- GNUNET_DHT_TEST_cleanup (ctx);
-}
-
-
-/**
- * Task run on timeout to clean up. Terminates active get operations
- * and shuts down the testbed.
- *
- * @param cls the `struct GNUNET_DHT_TestContext`
- */
-static void
-timeout_cb (void *cls)
-{
- struct GNUNET_DHT_TEST_Context *ctx = cls;
-
- timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
- &timeout_cb,
- ctx);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout\n");
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator called on each result obtained for a DHT
- * operation that expects a reply
- *
- * @param cls closure with our 'struct GetOperation'
- * @param exp when will this value expire
- * @param query query hash
- * @param trunc_peer peer the path was truncated at, or NULL
- * @param get_path peers on reply path (or NULL if not recorded)
- * @param get_path_length number of entries in @a get_path
- * @param put_path peers on the PUT path (or NULL if not recorded)
- * @param put_path_length number of entries in @a put_path
- * @param type type of the result
- * @param size number of bytes in @a data
- * @param data pointer to the result data
- */
-static void
-dht_get_handler (void *cls,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode *query,
- const struct GNUNET_PeerIdentity *trunc_peer,
- const struct GNUNET_DHT_PathElement *get_path,
- unsigned int get_path_length,
- const struct GNUNET_DHT_PathElement *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size,
- const void *data)
-{
- struct GetOperation *get_op = cls;
- struct GNUNET_HashCode want;
- struct GNUNET_DHT_TEST_Context *ctx;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GET HANDLER called on PID %s\n",
- GNUNET_i2s (&get_op->me));
- if (sizeof(struct GNUNET_HashCode) != size)
- {
- GNUNET_break (0);
- return;
- }
- if (0 != GNUNET_memcmp (query,
- &get_op->key))
- {
- /* exact search should only yield exact results */
- GNUNET_break (0);
- return;
- }
- GNUNET_CRYPTO_hash (query,
- sizeof(*query),
- &want);
- if (0 != memcmp (&want,
- data,
- sizeof(want)))
- {
- GNUNET_break (0);
- return;
- }
- if (0 !=
- GNUNET_DHT_verify_path (data,
- size,
- exp,
- trunc_peer,
- put_path,
- put_path_length,
- get_path,
- get_path_length,
- &get_op->me))
- {
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Path signature (%u/%u) verification failed for peer %s!\n",
- get_path_length,
- put_path_length,
- GNUNET_i2s (&get_op->me));
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get successful\n");
- ok--;
- }
- GNUNET_DHT_get_stop (get_op->get);
- GNUNET_CONTAINER_DLL_remove (get_head,
- get_tail,
- get_op);
- GNUNET_free (get_op);
- if (NULL != get_head)
- return;
- /* all DHT GET operations successful; get stats! */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "All DHT operations successful. Obtaining stats!\n");
- ctx = stop_ops ();
- GNUNET_assert (NULL != ctx);
- (void) GNUNET_TESTBED_get_statistics (NUM_PEERS,
- my_peers,
- NULL, NULL,
- &handle_stats,
- &stats_finished,
- ctx);
-}
-
-
-/**
- * Task to put the id of each peer into the DHT.
- *
- * @param cls array with NUM_PEERS DHT handles
- * @param tc Task context
- */
-static void
-do_puts (void *cls)
-{
- struct GNUNET_DHT_Handle **hs = cls;
- struct GNUNET_HashCode key;
- struct GNUNET_HashCode value;
-
- put_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Putting %u values into DHT\n",
- NUM_PEERS);
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- GNUNET_CRYPTO_hash (&i,
- sizeof(i),
- &key);
- GNUNET_CRYPTO_hash (&key,
- sizeof(key),
- &value);
- GNUNET_DHT_put (hs[i],
- &key,
- 10U,
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
- sizeof(value),
- &value,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- NULL,
- NULL);
- }
- put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY,
- &do_puts,
- hs);
-}
-
-
-/**
- * Callback to be called when the requested peer information is available
- * The peer information in the callback is valid until the operation 'op' is canceled.
- *
- * @param cls a `struct GetOperation *`
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed; will be NULL if the
- * operation is successful
- */
-static void
-pid_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct GetOperation *get_op = cls;
-
- if (NULL != emsg)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Testbed failure: %s\n",
- emsg);
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testbed provided PID %s\n",
- GNUNET_i2s (pinfo->result.id));
- get_op->me = *pinfo->result.id;
- GNUNET_TESTBED_operation_done (get_op->to);
- get_op->to = NULL;
- get_op->get = GNUNET_DHT_get_start (get_op->dht,
- GNUNET_BLOCK_TYPE_TEST,
- &get_op->key,
- 4U, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE
- | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_handler,
- get_op);
-}
-
-
-/**
- * Start GET operations.
- */
-static void
-start_get (void *cls)
-{
- struct GNUNET_DHT_Handle **dhts = cls;
-
- get_task = NULL;
- for (unsigned int i = 0; i < NUM_PEERS; i++)
- {
- struct GNUNET_HashCode key;
-
- GNUNET_CRYPTO_hash (&i,
- sizeof(i),
- &key);
- for (unsigned int j = 0; j < NUM_PEERS; j++)
- {
- struct GetOperation *get_op;
-
- get_op = GNUNET_new (struct GetOperation);
- ok++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting GET %p\n",
- get_op);
- get_op->key = key;
- get_op->dht = dhts[j];
- get_op->to = GNUNET_TESTBED_peer_get_information (my_peers[j],
- GNUNET_TESTBED_PIT_IDENTITY,
- &pid_cb,
- get_op);
- GNUNET_CONTAINER_DLL_insert (get_head,
- get_tail,
- get_op);
- }
- }
-}
-
-
-/**
- * Main function of the test.
- *
- * @param cls closure (NULL)
- * @param ctx argument to give to #GNUNET_DHT_TEST_cleanup on test end
- * @param num_peers number of @a peers that are running
- * @param peers array of peers
- * @param dhts handle to each of the DHTs of the peers
- */
-static void
-run (void *cls,
- struct GNUNET_DHT_TEST_Context *ctx,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- struct GNUNET_DHT_Handle **dhts)
-{
- GNUNET_assert (NUM_PEERS == num_peers);
- my_peers = peers;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers setup, starting test\n");
- put_task = GNUNET_SCHEDULER_add_now (&do_puts,
- dhts);
- get_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &start_get,
- dhts);
- timeout_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
- &timeout_cb,
- ctx);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- ctx);
-}
-
-
-/**
- * Main: start test
- */
-int
-main (int xargc, char *xargv[])
-{
- const char *cfg_filename;
- const char *test_name;
-
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
- unsetenv ("XDG_CACHE_HOME");
- if (NULL != strstr (xargv[0], "test_dht_2dtorus"))
- {
- cfg_filename = "test_dht_2dtorus.conf";
- test_name = "test-dht-2dtorus";
- NUM_PEERS = 16;
- }
- else if (NULL != strstr (xargv[0], "test_dht_line"))
- {
- cfg_filename = "test_dht_line.conf";
- test_name = "test-dht-line";
- NUM_PEERS = 5;
- }
- else if (NULL != strstr (xargv[0], "test_dht_twopeer"))
- {
- cfg_filename = "test_dht_line.conf";
- test_name = "test-dht-twopeer";
- NUM_PEERS = 2;
- }
- else if (NULL != strstr (xargv[0], "test_dht_multipeer"))
- {
- cfg_filename = "test_dht_multipeer.conf";
- test_name = "test-dht-multipeer";
- NUM_PEERS = 10;
- }
- else
- {
- GNUNET_break (0);
- return 1;
- }
- GNUNET_DHT_TEST_run (test_name,
- cfg_filename,
- NUM_PEERS,
- &run, NULL);
- return ok;
-}
-
-
-/* end of test_dht_topo.c */
diff --git a/src/service/dns/meson.build b/src/service/dns/meson.build
index e1b7f7670..81fecd32a 100644
--- a/src/service/dns/meson.build
+++ b/src/service/dns/meson.build
@@ -39,14 +39,13 @@ executable ('gnunet-dns-monitor',
gnunetdnsmonitor_src,
dependencies: [libgnunetdns_dep, libgnunetutil_dep, libgnunetdns_dep],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir')/'gnunet'/'libexec')
+ install: false)
+
executable ('gnunet-dns-redirector',
gnunetdnsredirector_src,
dependencies: [libgnunetdns_dep, libgnunetutil_dep, libgnunetdns_dep],
include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir')/'gnunet'/'libexec')
+ install: false)
if host_machine.system() == 'linux'
executable ('gnunet-helper-dns',
diff --git a/src/service/fs/Makefile.am b/src/service/fs/Makefile.am
index 93c8814ca..c1d545af1 100644
--- a/src/service/fs/Makefile.am
+++ b/src/service/fs/Makefile.am
@@ -118,7 +118,6 @@ check_PROGRAMS = \
test_fs_search_probes \
test_fs_search_persistence \
test_fs_start_stop \
- test_fs_test_lib \
test_fs_unindex \
test_fs_unindex_persistence \
test_fs_uri \
@@ -298,13 +297,6 @@ test_fs_uri_LDADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la
# TNG
-#test_fs_test_lib_SOURCES = \
-# test_fs_test_lib.c
-#test_fs_test_lib_LDADD = \
-# libgnunetfstest.a \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# libgnunetfs.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la
#test_gnunet_service_fs_p2p_SOURCES = \
# test_gnunet_service_fs_p2p.c
@@ -367,7 +359,6 @@ test_fs_uri_LDADD = \
# $(top_builddir)/src/lib/util/libgnunetutil.la
EXTRA_DIST = \
- fs_test_lib_data.conf \
perf_gnunet_service_fs_p2p.conf \
test_fs_data.conf \
test_fs_defaults.conf \
diff --git a/src/service/fs/fs_test_lib.c b/src/service/fs/fs_test_lib.c
deleted file mode 100644
index f80a2859c..000000000
--- a/src/service/fs/fs_test_lib.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2010, 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file fs/fs_test_lib.c
- * @brief library routines for testing FS publishing and downloading;
- * this code is limited to flat files
- * and no keywords (those functions can be tested with
- * single-peer setups; this is for testing routing).
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "fs_api.h"
-#include "fs_test_lib.h"
-
-
-#define CONTENT_LIFETIME GNUNET_TIME_UNIT_HOURS
-
-
-/**
- * Handle for a publishing operation started for testing FS.
- */
-struct TestPublishOperation
-{
- /**
- * Handle for the operation to connect to the peer's 'fs' service.
- */
- struct GNUNET_TESTBED_Operation *fs_op;
-
- /**
- * Handle to the file sharing context using this daemon.
- */
- struct GNUNET_FS_Handle *fs;
-
- /**
- * Function to call when upload is done.
- */
- GNUNET_FS_TEST_UriContinuation publish_cont;
-
- /**
- * Closure for publish_cont.
- */
- void *publish_cont_cls;
-
- /**
- * Task to abort publishing (timeout).
- */
- struct GNUNET_SCHEDULER_Task *publish_timeout_task;
-
- /**
- * Seed for file generation.
- */
- uint32_t publish_seed;
-
- /**
- * Context for current publishing operation.
- */
- struct GNUNET_FS_PublishContext *publish_context;
-
- /**
- * Result URI.
- */
- struct GNUNET_FS_Uri *publish_uri;
-
- /**
- * Name of the temporary file used, or NULL for none.
- */
- char *publish_tmp_file;
-
- /**
- * Size of the file.
- */
- uint64_t size;
-
- /**
- * Anonymity level used.
- */
- uint32_t anonymity;
-
- /**
- * Verbosity level of the current operation.
- */
- unsigned int verbose;
-
- /**
- * Are we testing indexing? (YES: index, NO: insert, SYSERR: simulate)
- */
- int do_index;
-};
-
-
-/**
- * Handle for a download operation started for testing FS.
- */
-struct TestDownloadOperation
-{
- /**
- * Handle for the operation to connect to the peer's 'fs' service.
- */
- struct GNUNET_TESTBED_Operation *fs_op;
-
- /**
- * Handle to the file sharing context using this daemon.
- */
- struct GNUNET_FS_Handle *fs;
-
- /**
- * Handle to the daemon via testing.
- */
- struct GNUNET_TESTING_Daemon *daemon;
-
- /**
- * Function to call when download is done.
- */
- GNUNET_SCHEDULER_TaskCallback download_cont;
-
- /**
- * Closure for download_cont.
- */
- void *download_cont_cls;
-
- /**
- * URI to download.
- */
- struct GNUNET_FS_Uri *uri;
-
- /**
- * Task to abort downloading (timeout).
- */
- struct GNUNET_SCHEDULER_Task *download_timeout_task;
-
- /**
- * Context for current download operation.
- */
- struct GNUNET_FS_DownloadContext *download_context;
-
- /**
- * Size of the file.
- */
- uint64_t size;
-
- /**
- * Anonymity level used.
- */
- uint32_t anonymity;
-
- /**
- * Seed for download verification.
- */
- uint32_t download_seed;
-
- /**
- * Verbosity level of the current operation.
- */
- unsigned int verbose;
-};
-
-
-/**
- * Task scheduled to report on the completion of our publish operation.
- *
- * @param cls the publish operation context
- */
-static void
-report_uri (void *cls)
-{
- struct TestPublishOperation *po = cls;
-
- GNUNET_FS_publish_stop (po->publish_context);
- GNUNET_TESTBED_operation_done (po->fs_op);
- po->publish_cont (po->publish_cont_cls,
- po->publish_uri,
- (GNUNET_YES == po->do_index)
- ? po->publish_tmp_file
- : NULL);
- GNUNET_FS_uri_destroy (po->publish_uri);
- if ((GNUNET_YES != po->do_index) &&
- (NULL != po->publish_tmp_file))
- (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
- GNUNET_free (po->publish_tmp_file);
- GNUNET_free (po);
-}
-
-
-/**
- * Task scheduled to run when publish operation times out.
- *
- * @param cls the publish operation context
- */
-static void
-publish_timeout (void *cls)
-{
- struct TestPublishOperation *po = cls;
-
- po->publish_timeout_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout while trying to publish data\n");
- GNUNET_TESTBED_operation_done (po->fs_op);
- GNUNET_FS_publish_stop (po->publish_context);
- po->publish_cont (po->publish_cont_cls, NULL, NULL);
- (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
- GNUNET_free (po->publish_tmp_file);
- GNUNET_free (po);
-}
-
-
-/**
- * Progress callback for file-sharing events while publishing.
- *
- * @param cls the publish operation context
- * @param info information about the event
- */
-static void *
-publish_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
-{
- struct TestPublishOperation *po = cls;
-
- switch (info->status)
- {
- case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
- GNUNET_SCHEDULER_cancel (po->publish_timeout_task);
- po->publish_timeout_task = NULL;
- po->publish_uri =
- GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri);
- GNUNET_SCHEDULER_add_now (&report_uri,
- po);
- break;
-
- case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
- if (po->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Publishing at %llu/%llu bytes\n",
- (unsigned long long) info->value.publish.completed,
- (unsigned long long) info->value.publish.size);
- break;
-
- case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY:
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
- if (po->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n",
- (unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size);
- break;
-
- default:
- break;
- }
- return NULL;
-}
-
-
-/**
- * Generate test data for publishing test.
- *
- * @param cls pointer to uint32_t with publishing seed
- * @param offset offset to generate data for
- * @param max maximum number of bytes to generate
- * @param buf where to write generated data
- * @param emsg where to store error message (unused)
- * @return number of bytes written to buf
- */
-static size_t
-file_generator (void *cls,
- uint64_t offset,
- size_t max,
- void *buf,
- char **emsg)
-{
- uint32_t *publish_seed = cls;
- uint64_t pos;
- uint8_t *cbuf = buf;
- int mod;
-
- if (emsg != NULL)
- *emsg = NULL;
- if (buf == NULL)
- return 0;
- for (pos = 0; pos < 8; pos++)
- cbuf[pos] = (uint8_t) (offset >> pos * 8);
- for (pos = 8; pos < max; pos++)
- {
- mod = (255 - (offset / 1024 / 32));
- if (mod == 0)
- mod = 1;
- cbuf[pos] = (uint8_t) ((offset * (*publish_seed)) % mod);
- }
- return max;
-}
-
-
-/**
- * Connect adapter for publishing operation.
- *
- * @param cls the 'struct TestPublishOperation'
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-publish_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct TestPublishOperation *po = cls;
-
- return GNUNET_FS_start (cfg,
- "fs-test-publish",
- &publish_progress_cb, po,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_END);
-}
-
-
-/**
- * Adapter function called to destroy connection to file-sharing service.
- *
- * @param cls the 'struct GNUNET_FS_Handle'
- * @param op_result unused (different for publish/download!)
- */
-static void
-fs_disconnect_adapter (void *cls,
- void *op_result)
-{
- struct GNUNET_FS_Handle *fs = op_result;
-
- GNUNET_FS_stop (fs);
-}
-
-
-/**
- * Callback to be called when testbed has connected to the fs service
- *
- * @param cls the 'struct TestPublishOperation'
- * @param op the operation that has been finished
- * @param ca_result the 'struct GNUNET_FS_Handle ' (NULL on error)
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-publish_fs_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct TestPublishOperation *po = cls;
- struct GNUNET_FS_FileInformation *fi;
- struct GNUNET_DISK_FileHandle *fh;
- char *em;
- uint64_t off;
- char buf[DBLOCK_SIZE];
- size_t bsize;
- struct GNUNET_FS_BlockOptions bo;
-
- if (NULL == ca_result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to FS for publishing: %s\n", emsg);
- po->publish_cont (po->publish_cont_cls,
- NULL, NULL);
- GNUNET_TESTBED_operation_done (po->fs_op);
- GNUNET_free (po);
- return;
- }
- po->fs = ca_result;
-
- bo.expiration_time = GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME);
- bo.anonymity_level = po->anonymity;
- bo.content_priority = 42;
- bo.replication_level = 1;
- if (GNUNET_YES == po->do_index)
- {
- po->publish_tmp_file = GNUNET_DISK_mktemp ("fs-test-publish-index");
- GNUNET_assert (po->publish_tmp_file != NULL);
- fh = GNUNET_DISK_file_open (po->publish_tmp_file,
- GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE);
- GNUNET_assert (NULL != fh);
- off = 0;
- while (off < po->size)
- {
- bsize = GNUNET_MIN (sizeof(buf), po->size - off);
- emsg = NULL;
- GNUNET_assert (bsize == file_generator (&po->publish_seed, off, bsize,
- buf, &em));
- GNUNET_assert (em == NULL);
- GNUNET_assert (bsize == GNUNET_DISK_file_write (fh, buf, bsize));
- off += bsize;
- }
- GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
- fi = GNUNET_FS_file_information_create_from_file (po->fs, po,
- po->publish_tmp_file,
- NULL, NULL, po->do_index,
- &bo);
- GNUNET_assert (NULL != fi);
- }
- else
- {
- fi = GNUNET_FS_file_information_create_from_reader (po->fs, po,
- po->size,
- &file_generator,
- &po->publish_seed,
- NULL, NULL,
- po->do_index, &bo);
- GNUNET_assert (NULL != fi);
- }
- po->publish_context =
- GNUNET_FS_publish_start (po->fs, fi, NULL, NULL, NULL,
- GNUNET_FS_PUBLISH_OPTION_NONE);
-}
-
-
-void
-GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout, uint32_t anonymity,
- int do_index, uint64_t size, uint32_t seed,
- unsigned int verbose,
- GNUNET_FS_TEST_UriContinuation cont, void *cont_cls)
-{
- struct TestPublishOperation *po;
-
- po = GNUNET_new (struct TestPublishOperation);
- po->publish_cont = cont;
- po->publish_cont_cls = cont_cls;
- po->publish_seed = seed;
- po->anonymity = anonymity;
- po->size = size;
- po->verbose = verbose;
- po->do_index = do_index;
- po->fs_op = GNUNET_TESTBED_service_connect (po,
- peer,
- "fs",
- &publish_fs_connect_complete_cb,
- po,
- &publish_connect_adapter,
- &fs_disconnect_adapter,
- po);
- po->publish_timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, po);
-}
-
-
-/* ************************** download ************************ */
-
-
-/**
- * Task scheduled to run when download operation times out.
- *
- * @param cls the download operation context
- */
-static void
-download_timeout (void *cls)
-{
- struct TestDownloadOperation *dop = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout while trying to download file\n");
- dop->download_timeout_task = NULL;
- GNUNET_FS_download_stop (dop->download_context,
- GNUNET_YES);
- GNUNET_SCHEDULER_add_now (dop->download_cont,
- dop->download_cont_cls);
- GNUNET_TESTBED_operation_done (dop->fs_op);
- GNUNET_FS_uri_destroy (dop->uri);
- GNUNET_free (dop);
-}
-
-
-/**
- * Task scheduled to report on the completion of our download operation.
- *
- * @param cls the download operation context
- */
-static void
-report_success (void *cls)
-{
- struct TestDownloadOperation *dop = cls;
-
- GNUNET_FS_download_stop (dop->download_context,
- GNUNET_YES);
- GNUNET_SCHEDULER_add_now (dop->download_cont,
- dop->download_cont_cls);
- GNUNET_TESTBED_operation_done (dop->fs_op);
- GNUNET_FS_uri_destroy (dop->uri);
- GNUNET_free (dop);
-}
-
-
-/**
- * Progress callback for file-sharing events while downloading.
- *
- * @param cls the download operation context
- * @param info information about the event
- */
-static void *
-download_progress_cb (void *cls,
- const struct GNUNET_FS_ProgressInfo *info)
-{
- struct TestDownloadOperation *dop = cls;
-
- switch (info->status)
- {
- case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
- if (dop->verbose)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Download at %llu/%llu bytes\n",
- (unsigned long long) info->value.download.completed,
- (unsigned long long) info->value.download.size);
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
- GNUNET_SCHEDULER_cancel (dop->download_timeout_task);
- dop->download_timeout_task = NULL;
- GNUNET_SCHEDULER_add_now (&report_success, dop);
- break;
-
- case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
- case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
- break;
-
- /* FIXME: monitor data correctness during download progress */
- /* FIXME: do performance reports given sufficient verbosity */
- /* FIXME: advance timeout task to "immediate" on error */
- default:
- break;
- }
- return NULL;
-}
-
-
-/**
- * Connect adapter for download operation.
- *
- * @param cls the 'struct TestDownloadOperation'
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-download_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct TestPublishOperation *po = cls;
-
- return GNUNET_FS_start (cfg,
- "fs-test-download",
- &download_progress_cb, po,
- GNUNET_FS_FLAGS_NONE,
- GNUNET_FS_OPTIONS_END);
-}
-
-
-/**
- * Callback to be called when testbed has connected to the fs service
- *
- * @param cls the 'struct TestPublishOperation'
- * @param op the operation that has been finished
- * @param ca_result the 'struct GNUNET_FS_Handle ' (NULL on error)
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-download_fs_connect_complete_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct TestDownloadOperation *dop = cls;
-
- dop->fs = ca_result;
- GNUNET_assert (NULL != dop->fs);
- dop->download_context =
- GNUNET_FS_download_start (dop->fs, dop->uri, NULL, NULL, NULL, 0, dop->size,
- dop->anonymity, GNUNET_FS_DOWNLOAD_OPTION_NONE,
- NULL, NULL);
-}
-
-
-void
-GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity, uint32_t seed,
- const struct GNUNET_FS_Uri *uri, unsigned int verbose,
- GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
-{
- struct TestDownloadOperation *dop;
-
- dop = GNUNET_new (struct TestDownloadOperation);
- dop->uri = GNUNET_FS_uri_dup (uri);
- dop->size = GNUNET_FS_uri_chk_get_file_size (uri);
- dop->verbose = verbose;
- dop->anonymity = anonymity;
- dop->download_cont = cont;
- dop->download_cont_cls = cont_cls;
- dop->download_seed = seed;
-
- dop->fs_op = GNUNET_TESTBED_service_connect (dop,
- peer,
- "fs",
- &download_fs_connect_complete_cb,
- dop,
- &download_connect_adapter,
- &fs_disconnect_adapter,
- dop);
- dop->download_timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, dop);
-}
-
-
-/* end of fs_test_lib.c */
diff --git a/src/service/fs/fs_test_lib.h b/src/service/fs/fs_test_lib.h
deleted file mode 100644
index 36244eb19..000000000
--- a/src/service/fs/fs_test_lib.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2010, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file fs/fs_test_lib.h
- * @brief library routines for testing FS publishing and downloading;
- * this code is limited to flat files
- * and no keywords (those functions can be tested with
- * single-peer setups; this is for testing routing).
- * @author Christian Grothoff
- */
-#ifndef FS_TEST_LIB_H
-#define FS_TEST_LIB_H
-
-#include "gnunet_util_lib.h"
-#include "gnunet_fs_service.h"
-#include "gnunet_testbed_service.h"
-
-
-/**
- * Function signature.
- *
- * @param cls closure (user defined)
- * @param uri a URI, NULL for errors
- * @param fn name of the file on disk to be removed upon
- * completion, or NULL for inserted files (also NULL on error)
- */
-typedef void
-(*GNUNET_FS_TEST_UriContinuation) (void *cls,
- const struct GNUNET_FS_Uri *uri,
- const char *fn);
-
-
-/**
- * Publish a file at the given daemon.
- *
- * @param peer where to publish
- * @param timeout if this operation cannot be completed within the
- * given period, call the continuation with an error code
- * @param anonymity option for publication
- * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
- * #GNUNET_SYSERR for simulation
- * @param size size of the file to publish
- * @param seed seed to use for file generation
- * @param verbose how verbose to be in reporting
- * @param cont function to call when done
- * @param cont_cls closure for @a cont
- */
-void
-GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity,
- int do_index,
- uint64_t size,
- uint32_t seed,
- unsigned int verbose,
- GNUNET_FS_TEST_UriContinuation cont,
- void *cont_cls);
-
-
-/**
- * Perform test download.
- *
- * @param peer which peer to download from
- * @param timeout if this operation cannot be completed within the
- * given period, call the continuation with an error code
- * @param anonymity option for download
- * @param seed used for file validation
- * @param uri URI of file to download (CHK/LOC only)
- * @param verbose how verbose to be in reporting
- * @param cont function to call when done
- * @param cont_cls closure for @a cont
- */
-void
-GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_TIME_Relative timeout,
- uint32_t anonymity,
- uint32_t seed,
- const struct GNUNET_FS_Uri *uri,
- unsigned int verbose,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls);
-
-
-#endif
diff --git a/src/service/fs/fs_test_lib_data.conf b/src/service/fs/fs_test_lib_data.conf
deleted file mode 100644
index c99674798..000000000
--- a/src/service/fs/fs_test_lib_data.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-@INLINE@ test_fs_defaults.conf
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/gnunet-fs-test-lib/
-
-[ats]
-WAN_QUOTA_IN = 3932160
-WAN_QUOTA_OUT = 3932160
-
-[datastore]
-QUOTA = 2 GB
-#PLUGIN = heap
-#
-[fs]
-IMMEDIATE_START = YES
-
-[testbed]
-OVERLAY_TOPOLOGY = CLIQUE
diff --git a/src/service/messenger/Makefile.am b/src/service/messenger/Makefile.am
index de1456084..3acc0a6e3 100644
--- a/src/service/messenger/Makefile.am
+++ b/src/service/messenger/Makefile.am
@@ -71,6 +71,7 @@ libgnunetmessengertesting_la_LDFLAGS = \
-version-info 0:0:0
libgnunet_test_messenger_plugin_cmd_simple_join_la_SOURCES = \
+ messenger-testing-cmds.h \
test_messenger_plugin_cmd_simple_join.c
libgnunet_test_messenger_plugin_cmd_simple_join_la_LIBADD = \
libgnunetmessenger.la \
diff --git a/src/service/messenger/gnunet-service-messenger.c b/src/service/messenger/gnunet-service-messenger.c
index 7dc4e414d..f613b8b14 100644
--- a/src/service/messenger/gnunet-service-messenger.c
+++ b/src/service/messenger/gnunet-service-messenger.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_handle.h"
diff --git a/src/service/messenger/gnunet-service-messenger.h b/src/service/messenger/gnunet-service-messenger.h
index 450f66bc7..821836fdf 100644
--- a/src/service/messenger/gnunet-service-messenger.h
+++ b/src/service/messenger/gnunet-service-messenger.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_H
#define GNUNET_SERVICE_MESSENGER_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_identity_service.h"
#include "gnunet_protocols.h"
diff --git a/src/service/messenger/gnunet-service-messenger_basement.c b/src/service/messenger/gnunet-service-messenger_basement.c
index 8e3dd3358..5d1d475e9 100644
--- a/src/service/messenger/gnunet-service-messenger_basement.c
+++ b/src/service/messenger/gnunet-service-messenger_basement.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_basement.h"
size_t
diff --git a/src/service/messenger/gnunet-service-messenger_handle.h b/src/service/messenger/gnunet-service-messenger_handle.h
index 988b8774e..ce9244771 100644
--- a/src/service/messenger/gnunet-service-messenger_handle.h
+++ b/src/service/messenger/gnunet-service-messenger_handle.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_HANDLE_H
#define GNUNET_SERVICE_MESSENGER_HANDLE_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/gnunet-service-messenger_list_handles.c b/src/service/messenger/gnunet-service-messenger_list_handles.c
index 62427ecde..dee692960 100644
--- a/src/service/messenger/gnunet-service-messenger_list_handles.c
+++ b/src/service/messenger/gnunet-service-messenger_list_handles.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_list_handles.h"
#include "gnunet-service-messenger_handle.h"
diff --git a/src/service/messenger/gnunet-service-messenger_list_handles.h b/src/service/messenger/gnunet-service-messenger_list_handles.h
index d8ce23020..43c754d6c 100644
--- a/src/service/messenger/gnunet-service-messenger_list_handles.h
+++ b/src/service/messenger/gnunet-service-messenger_list_handles.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H
#define GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H
-#include "platform.h"
#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_SrvHandle;
diff --git a/src/service/messenger/gnunet-service-messenger_list_messages.c b/src/service/messenger/gnunet-service-messenger_list_messages.c
index 063e1ebfc..c140b8480 100644
--- a/src/service/messenger/gnunet-service-messenger_list_messages.c
+++ b/src/service/messenger/gnunet-service-messenger_list_messages.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_list_messages.h"
void
diff --git a/src/service/messenger/gnunet-service-messenger_list_messages.h b/src/service/messenger/gnunet-service-messenger_list_messages.h
index 5839f63ca..ccdfa1c99 100644
--- a/src/service/messenger/gnunet-service-messenger_list_messages.h
+++ b/src/service/messenger/gnunet-service-messenger_list_messages.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H
#define GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H
-#include "platform.h"
#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_ListMessage
diff --git a/src/service/messenger/gnunet-service-messenger_member_session.c b/src/service/messenger/gnunet-service-messenger_member_session.c
index 206d6eac5..dc1124360 100644
--- a/src/service/messenger/gnunet-service-messenger_member_session.c
+++ b/src/service/messenger/gnunet-service-messenger_member_session.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_member_session.h"
#include "gnunet-service-messenger_room.h"
diff --git a/src/service/messenger/gnunet-service-messenger_member_session.h b/src/service/messenger/gnunet-service-messenger_member_session.h
index 1f37e3d1a..85ce44e28 100644
--- a/src/service/messenger/gnunet-service-messenger_member_session.h
+++ b/src/service/messenger/gnunet-service-messenger_member_session.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H
#define GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_time_lib.h"
diff --git a/src/service/messenger/gnunet-service-messenger_member_store.h b/src/service/messenger/gnunet-service-messenger_member_store.h
index 3bdd0fe7c..161c93818 100644
--- a/src/service/messenger/gnunet-service-messenger_member_store.h
+++ b/src/service/messenger/gnunet-service-messenger_member_store.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H
#define GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "messenger_api_message.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_handle.c b/src/service/messenger/gnunet-service-messenger_message_handle.c
index b42c8f6a4..e730e12fe 100644
--- a/src/service/messenger/gnunet-service-messenger_message_handle.c
+++ b/src/service/messenger/gnunet-service-messenger_message_handle.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_handle.h"
static void
diff --git a/src/service/messenger/gnunet-service-messenger_message_handle.h b/src/service/messenger/gnunet-service-messenger_message_handle.h
index f4306383d..f76ae356a 100644
--- a/src/service/messenger/gnunet-service-messenger_message_handle.h
+++ b/src/service/messenger/gnunet-service-messenger_message_handle.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_sender_session.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_kind.c b/src/service/messenger/gnunet-service-messenger_message_kind.c
index 8d474d504..a7932a068 100644
--- a/src/service/messenger/gnunet-service-messenger_message_kind.c
+++ b/src/service/messenger/gnunet-service-messenger_message_kind.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_kind.h"
#include "messenger_api_util.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_kind.h b/src/service/messenger/gnunet-service-messenger_message_kind.h
index 0204da50a..972149288 100644
--- a/src/service/messenger/gnunet-service-messenger_message_kind.h
+++ b/src/service/messenger/gnunet-service-messenger_message_kind.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_time_lib.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_recv.c b/src/service/messenger/gnunet-service-messenger_message_recv.c
index 02e871c59..b51b91d55 100644
--- a/src/service/messenger/gnunet-service-messenger_message_recv.c
+++ b/src/service/messenger/gnunet-service-messenger_message_recv.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_recv.h"
#include "gnunet-service-messenger_message_kind.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_recv.h b/src/service/messenger/gnunet-service-messenger_message_recv.h
index b4a4f38f9..2c6cda4ad 100644
--- a/src/service/messenger/gnunet-service-messenger_message_recv.h
+++ b/src/service/messenger/gnunet-service-messenger_message_recv.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_member_session.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_send.c b/src/service/messenger/gnunet-service-messenger_message_send.c
index d0c624057..ddabf0b32 100644
--- a/src/service/messenger/gnunet-service-messenger_message_send.c
+++ b/src/service/messenger/gnunet-service-messenger_message_send.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_send.h"
#include "gnunet-service-messenger_handle.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_send.h b/src/service/messenger/gnunet-service-messenger_message_send.h
index e78215a67..0118dac99 100644
--- a/src/service/messenger/gnunet-service-messenger_message_send.h
+++ b/src/service/messenger/gnunet-service-messenger_message_send.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_tunnel.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_state.c b/src/service/messenger/gnunet-service-messenger_message_state.c
index 9fdb62918..7229eb6ba 100644
--- a/src/service/messenger/gnunet-service-messenger_message_state.c
+++ b/src/service/messenger/gnunet-service-messenger_message_state.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_state.h"
void
diff --git a/src/service/messenger/gnunet-service-messenger_message_state.h b/src/service/messenger/gnunet-service-messenger_message_state.h
index 5c6f3d981..fc1ccfac8 100644
--- a/src/service/messenger/gnunet-service-messenger_message_state.h
+++ b/src/service/messenger/gnunet-service-messenger_message_state.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "messenger_api_message.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_store.c b/src/service/messenger/gnunet-service-messenger_message_store.c
index f14be03b0..835a9ef53 100644
--- a/src/service/messenger/gnunet-service-messenger_message_store.c
+++ b/src/service/messenger/gnunet-service-messenger_message_store.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_message_store.h"
#include "messenger_api_message.h"
diff --git a/src/service/messenger/gnunet-service-messenger_message_store.h b/src/service/messenger/gnunet-service-messenger_message_store.h
index f73e1c3f3..9daf8fd11 100644
--- a/src/service/messenger/gnunet-service-messenger_message_store.h
+++ b/src/service/messenger/gnunet-service-messenger_message_store.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_MessageEntry
diff --git a/src/service/messenger/gnunet-service-messenger_operation.c b/src/service/messenger/gnunet-service-messenger_operation.c
index 3abd8382b..66cefb9ac 100644
--- a/src/service/messenger/gnunet-service-messenger_operation.c
+++ b/src/service/messenger/gnunet-service-messenger_operation.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_operation.h"
#include "gnunet-service-messenger_operation_store.h"
diff --git a/src/service/messenger/gnunet-service-messenger_operation.h b/src/service/messenger/gnunet-service-messenger_operation.h
index 3885b3856..0e02cdf6a 100644
--- a/src/service/messenger/gnunet-service-messenger_operation.h
+++ b/src/service/messenger/gnunet-service-messenger_operation.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_OPERATION_H
#define GNUNET_SERVICE_MESSENGER_OPERATION_H
-#include "platform.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_scheduler_lib.h"
diff --git a/src/service/messenger/gnunet-service-messenger_operation_store.h b/src/service/messenger/gnunet-service-messenger_operation_store.h
index 3e7ab4a32..9b1c3259a 100644
--- a/src/service/messenger/gnunet-service-messenger_operation_store.h
+++ b/src/service/messenger/gnunet-service-messenger_operation_store.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_OPERATION_STORE_H
#define GNUNET_SERVICE_MESSENGER_OPERATION_STORE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
diff --git a/src/service/messenger/gnunet-service-messenger_room.h b/src/service/messenger/gnunet-service-messenger_room.h
index 00dc2140c..c3063748d 100644
--- a/src/service/messenger/gnunet-service-messenger_room.h
+++ b/src/service/messenger/gnunet-service-messenger_room.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_ROOM_H
#define GNUNET_SERVICE_MESSENGER_ROOM_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/gnunet-service-messenger_sender_session.h b/src/service/messenger/gnunet-service-messenger_sender_session.h
index 6eb287607..8da9044ce 100644
--- a/src/service/messenger/gnunet-service-messenger_sender_session.h
+++ b/src/service/messenger/gnunet-service-messenger_sender_session.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_SENDER_SESSION_H
#define GNUNET_SERVICE_MESSENGER_SENDER_SESSION_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_member_session.h"
diff --git a/src/service/messenger/gnunet-service-messenger_service.c b/src/service/messenger/gnunet-service-messenger_service.c
index d4d2a4a89..e6c9866df 100644
--- a/src/service/messenger/gnunet-service-messenger_service.c
+++ b/src/service/messenger/gnunet-service-messenger_service.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_message_kind.h"
diff --git a/src/service/messenger/gnunet-service-messenger_service.h b/src/service/messenger/gnunet-service-messenger_service.h
index c0295691d..82a72ea9e 100644
--- a/src/service/messenger/gnunet-service-messenger_service.h
+++ b/src/service/messenger/gnunet-service-messenger_service.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_SERVICE_H
#define GNUNET_SERVICE_MESSENGER_SERVICE_H
-#include "platform.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/gnunet-service-messenger_tunnel.c b/src/service/messenger/gnunet-service-messenger_tunnel.c
index b36f9427c..87395797d 100644
--- a/src/service/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/service/messenger/gnunet-service-messenger_tunnel.c
@@ -23,7 +23,6 @@
* @brief GNUnet MESSENGER service
*/
-#include "platform.h"
#include "gnunet-service-messenger_tunnel.h"
#include "gnunet-service-messenger_handle.h"
diff --git a/src/service/messenger/gnunet-service-messenger_tunnel.h b/src/service/messenger/gnunet-service-messenger_tunnel.h
index a31ff31c6..6a8452f61 100644
--- a/src/service/messenger/gnunet-service-messenger_tunnel.h
+++ b/src/service/messenger/gnunet-service-messenger_tunnel.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_TUNNEL_H
#define GNUNET_SERVICE_MESSENGER_TUNNEL_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
diff --git a/src/service/messenger/messenger-testing-cmds.h b/src/service/messenger/messenger-testing-cmds.h
index e763b9782..c7f068db9 100644
--- a/src/service/messenger/messenger-testing-cmds.h
+++ b/src/service/messenger/messenger-testing-cmds.h
@@ -25,6 +25,7 @@
*/
#ifndef MESSENGER_TESTING_CMDS_H
#define MESSENGER_TESTING_CMDS_H
+
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_plugin.h"
diff --git a/src/service/messenger/messenger-testing.c b/src/service/messenger/messenger-testing.c
index 7ffafb613..ec0f84a97 100644
--- a/src/service/messenger/messenger-testing.c
+++ b/src/service/messenger/messenger-testing.c
@@ -26,7 +26,6 @@
#include "messenger-testing.h"
-#include "platform.h"
#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_TestStage
diff --git a/src/service/messenger/messenger-testing.h b/src/service/messenger/messenger-testing.h
index a0d98ff90..ba38557e8 100644
--- a/src/service/messenger/messenger-testing.h
+++ b/src/service/messenger/messenger-testing.h
@@ -23,6 +23,7 @@
* @brief testing lib for messenger service
* @author Tobias Frisch
*/
+
#ifndef MESSENGER_TESTING_H
#define MESSENGER_TESTING_H
diff --git a/src/service/messenger/messenger_api.c b/src/service/messenger/messenger_api.c
index 22fa6e1ba..7fd873211 100644
--- a/src/service/messenger/messenger_api.c
+++ b/src/service/messenger/messenger_api.c
@@ -23,12 +23,14 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
+#include "gnunet_common.h"
#include "gnunet_identity_service.h"
#include "gnunet_messenger_service.h"
#include "gnunet-service-messenger.h"
+#include "gnunet_reclaim_service.h"
+#include "messenger_api_contact.h"
#include "messenger_api_handle.h"
#include "messenger_api_message.h"
#include "messenger_api_message_kind.h"
@@ -1042,28 +1044,11 @@ GNUNET_MESSENGER_contact_get_id (const struct
}
-void
-GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
+static void
+send_message_to_room_with_key (struct GNUNET_MESSENGER_Room *room,
struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_MESSENGER_Contact *contact)
+ const struct GNUNET_CRYPTO_PublicKey *public_key)
{
- if ((! room) || (! message))
- return;
-
- switch (filter_message_sending (message))
- {
- case GNUNET_SYSERR:
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Sending message aborted: This kind of message is reserved for the service!\n");
- return;
- case GNUNET_NO:
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Sending message aborted: This kind of message could cause issues!\n");
- return;
- default:
- break;
- }
-
char *original_name;
char *changed_name = NULL;
@@ -1085,19 +1070,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
}
skip_naming:
- if (contact)
+ if (public_key)
{
- const struct GNUNET_CRYPTO_PublicKey *public_key = get_non_anonymous_key (
- get_contact_key (contact)
- );
-
- if (! public_key)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Sending message aborted: Invalid key!\n");
- goto reset_naming;
- }
-
struct GNUNET_MESSENGER_Message *original = message;
message = copy_message (original);
@@ -1126,6 +1100,50 @@ reset_naming:
}
+void
+GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_MESSENGER_Contact *contact)
+{
+ if ((! room) || (! message))
+ return;
+
+ switch (filter_message_sending (message))
+ {
+ case GNUNET_SYSERR:
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Sending message aborted: This kind of message is reserved for the service!\n");
+ return;
+ case GNUNET_NO:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Sending message aborted: This kind of message could cause issues!\n");
+ return;
+ default:
+ break;
+ }
+
+ const struct GNUNET_CRYPTO_PublicKey *public_key;
+
+ if (contact)
+ {
+ public_key = get_non_anonymous_key (
+ get_contact_key (contact)
+ );
+
+ if (! public_key)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Sending message aborted: Invalid key!\n");
+ return;
+ }
+ }
+ else
+ public_key = NULL;
+
+ send_message_to_room_with_key (room, message, public_key);
+}
+
+
const struct GNUNET_MESSENGER_Message*
GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_HashCode *hash)
@@ -1161,3 +1179,79 @@ GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
return iterate_room_members (room, callback, cls);
}
+
+
+struct GNUNET_MESSENGER_CheckTicket
+{
+ const struct GNUNET_CRYPTO_PublicKey *audience;
+ enum GNUNET_GenericReturnValue result;
+};
+
+
+static enum GNUNET_GenericReturnValue
+check_ticket_audience (void *cls,
+ struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Contact *contact)
+{
+ struct GNUNET_MESSENGER_CheckTicket *check = cls;
+
+ const struct GNUNET_CRYPTO_PublicKey *key;
+ key = get_contact_key(contact);
+
+ if (0 == GNUNET_memcmp(key, check->audience))
+ {
+ check->result = GNUNET_YES;
+ return GNUNET_NO;
+ }
+
+ return GNUNET_YES;
+}
+
+
+void
+GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_RECLAIM_Ticket *ticket)
+{
+ if ((! room) || (! ticket))
+ return;
+
+ const struct GNUNET_CRYPTO_PublicKey *pubkey;
+ pubkey = get_handle_pubkey(room->handle);
+
+ if (0 != GNUNET_memcmp(pubkey, &(ticket->identity)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Sending ticket aborted: Invalid identity!\n");
+ return;
+ }
+
+ struct GNUNET_MESSENGER_CheckTicket check;
+ check.audience = &(ticket->audience);
+ check.result = GNUNET_NO;
+
+ const int members = iterate_room_members (
+ room,
+ check_ticket_audience,
+ &check);
+
+ if ((! members) || (GNUNET_YES != check.result))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Sending ticket aborted: Audience not found!\n");
+ return;
+ }
+
+ struct GNUNET_MESSENGER_Message *message = create_message_ticket(
+ &(ticket->rnd)
+ );
+
+ if (! message)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Sending ticket aborted: Message creation failed!\n");
+ return;
+ }
+
+ send_message_to_room_with_key (room, message, &(ticket->audience));
+ destroy_message (message);
+}
diff --git a/src/service/messenger/messenger_api_cmd_join_room.c b/src/service/messenger/messenger_api_cmd_join_room.c
index f35220017..4e9cf1e22 100644
--- a/src/service/messenger/messenger_api_cmd_join_room.c
+++ b/src/service/messenger/messenger_api_cmd_join_room.c
@@ -23,7 +23,7 @@
* @brief cmd to join a room in a messenger service.
* @author Tobias Frisch
*/
-#include "platform.h"
+
#include "gnunet_util_lib.h"
#include "gnunet_core_testing_lib.h"
#include "gnunet_transport_testing_ng_lib.h"
diff --git a/src/service/messenger/messenger_api_cmd_start_service.c b/src/service/messenger/messenger_api_cmd_start_service.c
index 2e56a365f..a35d338fd 100644
--- a/src/service/messenger/messenger_api_cmd_start_service.c
+++ b/src/service/messenger/messenger_api_cmd_start_service.c
@@ -23,7 +23,7 @@
* @brief cmd to start a messenger service.
* @author Tobias Frisch
*/
-#include "platform.h"
+
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
diff --git a/src/service/messenger/messenger_api_cmd_stop_service.c b/src/service/messenger/messenger_api_cmd_stop_service.c
index 697b59f98..0aeb9dcc5 100644
--- a/src/service/messenger/messenger_api_cmd_stop_service.c
+++ b/src/service/messenger/messenger_api_cmd_stop_service.c
@@ -23,7 +23,7 @@
* @brief cmd to stop a messenger service.
* @author Tobias Frisch
*/
-#include "platform.h"
+
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_messenger_service.h"
diff --git a/src/service/messenger/messenger_api_contact.c b/src/service/messenger/messenger_api_contact.c
index 4d3a089ee..841f72a10 100644
--- a/src/service/messenger/messenger_api_contact.c
+++ b/src/service/messenger/messenger_api_contact.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_contact.h"
struct GNUNET_MESSENGER_Contact*
diff --git a/src/service/messenger/messenger_api_contact.h b/src/service/messenger/messenger_api_contact.h
index fb933c578..2ef049200 100644
--- a/src/service/messenger/messenger_api_contact.h
+++ b/src/service/messenger/messenger_api_contact.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_CONTACT_H
#define GNUNET_MESSENGER_API_CONTACT_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/messenger_api_contact_store.c b/src/service/messenger/messenger_api_contact_store.c
index 806983764..843377e6e 100644
--- a/src/service/messenger/messenger_api_contact_store.c
+++ b/src/service/messenger/messenger_api_contact_store.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_contact_store.h"
#include "messenger_api_contact.h"
diff --git a/src/service/messenger/messenger_api_contact_store.h b/src/service/messenger/messenger_api_contact_store.h
index 8654273ea..f9982f3f3 100644
--- a/src/service/messenger/messenger_api_contact_store.h
+++ b/src/service/messenger/messenger_api_contact_store.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_CONTACT_STORE_H
#define GNUNET_MESSENGER_API_CONTACT_STORE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/messenger_api_handle.c b/src/service/messenger/messenger_api_handle.c
index 7b3796310..a8cdf001b 100644
--- a/src/service/messenger/messenger_api_handle.c
+++ b/src/service/messenger/messenger_api_handle.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_handle.h"
#include "messenger_api_room.h"
diff --git a/src/service/messenger/messenger_api_handle.h b/src/service/messenger/messenger_api_handle.h
index fb4e4c580..0d4c945c0 100644
--- a/src/service/messenger/messenger_api_handle.h
+++ b/src/service/messenger/messenger_api_handle.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_HANDLE_H
#define GNUNET_MESSENGER_API_HANDLE_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/messenger_api_list_tunnels.c b/src/service/messenger/messenger_api_list_tunnels.c
index aa9b91bc5..355f17527 100644
--- a/src/service/messenger/messenger_api_list_tunnels.c
+++ b/src/service/messenger/messenger_api_list_tunnels.c
@@ -23,7 +23,6 @@
* @brief messenger api: client and service implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_list_tunnels.h"
void
@@ -147,7 +146,7 @@ verify_list_tunnels_flag_token (const struct GNUNET_MESSENGER_ListTunnels *tunne
for (element = tunnels->head; element; element = element->next)
{
- if (element->connection.flags & flag != flag)
+ if ((element->connection.flags & flag) != flag)
continue;
GNUNET_PEER_resolve (element->peer, &pid);
diff --git a/src/service/messenger/messenger_api_list_tunnels.h b/src/service/messenger/messenger_api_list_tunnels.h
index 427d0ef13..80d237fd1 100644
--- a/src/service/messenger/messenger_api_list_tunnels.h
+++ b/src/service/messenger/messenger_api_list_tunnels.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_LIST_TUNNELS_H
#define GNUNET_MESSENGER_API_LIST_TUNNELS_H
-#include "platform.h"
#include "gnunet_messenger_service.h"
#include "gnunet_util_lib.h"
diff --git a/src/service/messenger/messenger_api_message.c b/src/service/messenger/messenger_api_message.c
index 2a2cbe2e2..486a0e081 100644
--- a/src/service/messenger/messenger_api_message.c
+++ b/src/service/messenger/messenger_api_message.c
@@ -23,8 +23,8 @@
* @brief messenger api: client and service implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_message.h"
+#include "gnunet_messenger_service.h"
struct GNUNET_MESSENGER_MessageSignature
{
@@ -241,6 +241,13 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
length += member_size (struct GNUNET_MESSENGER_Message,
body.deletion.delay);
break;
+ case GNUNET_MESSENGER_KIND_CONNECTION:
+ length += member_size (struct GNUNET_MESSENGER_Message, body.connection.amount);
+ length += member_size (struct GNUNET_MESSENGER_Message, body.connection.flags);
+ break;
+ case GNUNET_MESSENGER_KIND_TICKET:
+ length += member_size (struct GNUNET_MESSENGER_Message, body.ticket.identifier);
+ break;
default:
break;
}
@@ -425,13 +432,13 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind,
char *buffer,
uint16_t offset)
{
- uint32_t version;
+ uint32_t value0, value1;
switch (kind)
{
case GNUNET_MESSENGER_KIND_INFO:
- version = GNUNET_htobe32 (body->info.messenger_version);
+ value0 = GNUNET_htobe32 (body->info.messenger_version);
- encode_step (buffer, offset, &version);
+ encode_step (buffer, offset, &value0);
break;
case GNUNET_MESSENGER_KIND_JOIN:
encode_step_key (buffer, offset, &(body->join.key), length);
@@ -487,6 +494,16 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind,
encode_step (buffer, offset, &(body->deletion.hash));
encode_step (buffer, offset, &(body->deletion.delay));
break;
+ case GNUNET_MESSENGER_KIND_CONNECTION:
+ value0 = GNUNET_htobe32 (body->connection.amount);
+ value1 = GNUNET_htobe32 (body->connection.flags);
+
+ encode_step (buffer, offset, &value0);
+ encode_step (buffer, offset, &value1);
+ break;
+ case GNUNET_MESSENGER_KIND_TICKET:
+ encode_step (buffer, offset, &(body->ticket.identifier));
+ break;
default:
break;
}
@@ -611,13 +628,13 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind,
length -= padding;
- uint32_t version;
+ uint32_t value0, value1;
switch (*kind)
{
case GNUNET_MESSENGER_KIND_INFO: {
- decode_step (buffer, offset, &version);
+ decode_step (buffer, offset, &value0);
- body->info.messenger_version = GNUNET_be32toh (version);
+ body->info.messenger_version = GNUNET_be32toh (value0);
break;
} case GNUNET_MESSENGER_KIND_JOIN: {
decode_step_key (buffer, offset, &(body->join.key), length);
@@ -669,6 +686,16 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind,
decode_step (buffer, offset, &(body->deletion.hash));
decode_step (buffer, offset, &(body->deletion.delay));
break;
+ case GNUNET_MESSENGER_KIND_CONNECTION:
+ decode_step (buffer, offset, &value0);
+ decode_step (buffer, offset, &value1);
+
+ body->connection.amount = GNUNET_be32toh (value0);
+ body->connection.flags = GNUNET_be32toh (value1);
+ break;
+ case GNUNET_MESSENGER_KIND_TICKET:
+ decode_step (buffer, offset, &(body->ticket.identifier));
+ break;
default:
*kind = GNUNET_MESSENGER_KIND_UNKNOWN;
break;
@@ -1054,6 +1081,7 @@ is_peer_message (const struct GNUNET_MESSENGER_Message *message)
case GNUNET_MESSENGER_KIND_PEER:
case GNUNET_MESSENGER_KIND_MISS:
case GNUNET_MESSENGER_KIND_MERGE:
+ case GNUNET_MESSENGER_KIND_CONNECTION:
return GNUNET_YES;
default:
return GNUNET_NO;
@@ -1099,6 +1127,10 @@ is_service_message (const struct GNUNET_MESSENGER_Message *message)
return GNUNET_YES; // Prevent duplicate encryption breaking all access!
case GNUNET_MESSENGER_KIND_DELETE:
return GNUNET_YES; // Deletion should not apply individually! (inefficieny)
+ case GNUNET_MESSENGER_KIND_CONNECTION:
+ return GNUNET_YES; // Reserved for connection handling only!
+ case GNUNET_MESSENGER_KIND_TICKET:
+ return GNUNET_NO;
default:
return GNUNET_SYSERR;
}
@@ -1143,6 +1175,10 @@ filter_message_sending (const struct GNUNET_MESSENGER_Message *message)
return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead!
case GNUNET_MESSENGER_KIND_DELETE:
return GNUNET_YES;
+ case GNUNET_MESSENGER_KIND_CONNECTION:
+ return GNUNET_SYSERR; // Reserved for connection handling only!
+ case GNUNET_MESSENGER_KIND_TICKET:
+ return GNUNET_YES;
default:
return GNUNET_SYSERR;
}
diff --git a/src/service/messenger/messenger_api_message.h b/src/service/messenger/messenger_api_message.h
index dd399975f..41684c6b6 100644
--- a/src/service/messenger/messenger_api_message.h
+++ b/src/service/messenger/messenger_api_message.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_MESSAGE_H
#define GNUNET_MESSENGER_API_MESSAGE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_signatures.h"
diff --git a/src/service/messenger/messenger_api_message_kind.c b/src/service/messenger/messenger_api_message_kind.c
index d2c11bbc5..c9cf227a2 100644
--- a/src/service/messenger/messenger_api_message_kind.c
+++ b/src/service/messenger/messenger_api_message_kind.c
@@ -25,7 +25,6 @@
#include "messenger_api_message_kind.h"
-#include "platform.h"
#include "messenger_api_util.h"
struct GNUNET_MESSENGER_Message*
@@ -188,3 +187,21 @@ create_message_delete (const struct GNUNET_HashCode *hash,
return message;
}
+
+struct GNUNET_MESSENGER_Message*
+create_message_ticket (const struct GNUNET_RECLAIM_Identifier *identifier)
+{
+ if (! identifier)
+ return NULL;
+
+ struct GNUNET_MESSENGER_Message *message = create_message (
+ GNUNET_MESSENGER_KIND_TICKET);
+
+ if (! message)
+ return NULL;
+
+ GNUNET_memcpy (&(message->body.ticket.identifier), identifier,
+ sizeof(struct GNUNET_RECLAIM_Identifier));
+
+ return message;
+}
diff --git a/src/service/messenger/messenger_api_message_kind.h b/src/service/messenger/messenger_api_message_kind.h
index 5f7421c07..20e3cba83 100644
--- a/src/service/messenger/messenger_api_message_kind.h
+++ b/src/service/messenger/messenger_api_message_kind.h
@@ -26,7 +26,8 @@
#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
#define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
-#include "platform.h"
+#include "gnunet_messenger_service.h"
+#include "gnunet_reclaim_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_time_lib.h"
@@ -116,7 +117,8 @@ struct GNUNET_MESSENGER_Message*
create_message_text (const char *text);
/**
- * Creates and allocates a new delete message containing the <i>hash</i> of a message to delete after a specific <i>delay</i>.
+ * Creates and allocates a new delete message containing the <i>hash</i> of a message to delete
+ * after a specific <i>delay</i>.
* (all values are stored as copy)
*
* @param[in] hash Hash of message
@@ -127,4 +129,15 @@ struct GNUNET_MESSENGER_Message*
create_message_delete (const struct GNUNET_HashCode *hash,
const struct GNUNET_TIME_Relative delay);
+/**
+ * Creates and allocates a new ticket message containing the <i>identifier</i> of a ticket to
+ * exchange it with a given audience.
+ * (all values are stored as copy)
+ *
+ * @param[in] identifier Identifier of ticket
+ * @return New message
+ */
+struct GNUNET_MESSENGER_Message*
+create_message_ticket (const struct GNUNET_RECLAIM_Identifier *identifier);
+
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
diff --git a/src/service/messenger/messenger_api_peer_store.c b/src/service/messenger/messenger_api_peer_store.c
index 949510960..f9b4867f8 100644
--- a/src/service/messenger/messenger_api_peer_store.c
+++ b/src/service/messenger/messenger_api_peer_store.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_peer_store.h"
#include "messenger_api_message.h"
diff --git a/src/service/messenger/messenger_api_peer_store.h b/src/service/messenger/messenger_api_peer_store.h
index f4f948cb9..960787466 100644
--- a/src/service/messenger/messenger_api_peer_store.h
+++ b/src/service/messenger/messenger_api_peer_store.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_PEER_STORE_H
#define GNUNET_MESSENGER_API_PEER_STORE_H
-#include "platform.h"
#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_Message;
diff --git a/src/service/messenger/messenger_api_queue_messages.h b/src/service/messenger/messenger_api_queue_messages.h
index 5ba204153..64ded85ce 100644
--- a/src/service/messenger/messenger_api_queue_messages.h
+++ b/src/service/messenger/messenger_api_queue_messages.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_QUEUE_MESSAGES_H
#define GNUNET_MESSENGER_API_QUEUE_MESSAGES_H
-#include "platform.h"
#include "gnunet_identity_service.h"
#include "gnunet_util_lib.h"
diff --git a/src/service/messenger/messenger_api_room.c b/src/service/messenger/messenger_api_room.c
index e66757f80..ea19879ec 100644
--- a/src/service/messenger/messenger_api_room.c
+++ b/src/service/messenger/messenger_api_room.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_room.h"
#include "messenger_api_handle.h"
diff --git a/src/service/messenger/messenger_api_room.h b/src/service/messenger/messenger_api_room.h
index 3c276968f..19cef2131 100644
--- a/src/service/messenger/messenger_api_room.h
+++ b/src/service/messenger/messenger_api_room.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_MESSENGER_API_ROOM_H
#define GNUNET_MESSENGER_API_ROOM_H
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
diff --git a/src/service/messenger/messenger_api_traits.c b/src/service/messenger/messenger_api_traits.c
index f4641d24c..5f5088c9d 100644
--- a/src/service/messenger/messenger_api_traits.c
+++ b/src/service/messenger/messenger_api_traits.c
@@ -23,7 +23,7 @@
* @brief testing lib for messenger service
* @author Tobias Frisch
*/
-#include "platform.h"
+
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "messenger-testing-cmds.h"
diff --git a/src/service/messenger/messenger_api_util.c b/src/service/messenger/messenger_api_util.c
index 391e36ebf..6cdeb647b 100644
--- a/src/service/messenger/messenger_api_util.c
+++ b/src/service/messenger/messenger_api_util.c
@@ -23,7 +23,6 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
-#include "platform.h"
#include "messenger_api_util.h"
static void
diff --git a/src/service/messenger/messenger_api_util.h b/src/service/messenger/messenger_api_util.h
index 5055245a0..a8b4e9150 100644
--- a/src/service/messenger/messenger_api_util.h
+++ b/src/service/messenger/messenger_api_util.h
@@ -26,7 +26,6 @@
#ifndef GNUNET_SERVICE_MESSENGER_UTIL_H
#define GNUNET_SERVICE_MESSENGER_UTIL_H
-#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
diff --git a/src/service/messenger/test_messenger.c b/src/service/messenger/test_messenger.c
index 4d85e984f..3c3dbd14d 100644
--- a/src/service/messenger/test_messenger.c
+++ b/src/service/messenger/test_messenger.c
@@ -22,7 +22,7 @@
* @author Tobias Frisch
* @brief Test for the messenger service using cadet API.
*/
-#include "platform.h"
+
#include <stdio.h>
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
diff --git a/src/service/messenger/test_messenger_anonymous.c b/src/service/messenger/test_messenger_anonymous.c
index d3dadf2c5..5f77cca53 100644
--- a/src/service/messenger/test_messenger_anonymous.c
+++ b/src/service/messenger/test_messenger_anonymous.c
@@ -22,7 +22,7 @@
* @author Tobias Frisch
* @brief Test for the messenger service using cadet API.
*/
-#include "platform.h"
+
#include <stdio.h>
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
diff --git a/src/service/messenger/test_messenger_plugin_cmd_simple_join.c b/src/service/messenger/test_messenger_plugin_cmd_simple_join.c
index 4b2c627bd..08252f067 100644
--- a/src/service/messenger/test_messenger_plugin_cmd_simple_join.c
+++ b/src/service/messenger/test_messenger_plugin_cmd_simple_join.c
@@ -23,6 +23,7 @@
* @brief a plugin to provide the API for running test cases.
* @author Tobias Frisch
*/
+
#include "platform.h"
#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
diff --git a/src/service/nse/Makefile.am b/src/service/nse/Makefile.am
index 7b89ef635..40690e81c 100644
--- a/src/service/nse/Makefile.am
+++ b/src/service/nse/Makefile.am
@@ -28,20 +28,6 @@ libgnunetnse_la_LDFLAGS = \
libexec_PROGRAMS = \
gnunet-service-nse
-#noinst_PROGRAMS = \
-# gnunet-nse-profiler
-
-# FIXME no testbed in TNG
-#gnunet_nse_profiler_SOURCES = \
-# gnunet-nse-profiler.c
-#gnunet_nse_profiler_LDADD = -lm \
-# libgnunetnse.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/service/testing/libgnunettesting.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# $(GN_LIBINTL)
-
gnunet_service_nse_SOURCES = \
gnunet-service-nse.c
gnunet_service_nse_LDADD = \
diff --git a/src/service/nse/gnunet-nse-profiler.c b/src/service/nse/gnunet-nse-profiler.c
deleted file mode 100644
index 4b256bc52..000000000
--- a/src/service/nse/gnunet-nse-profiler.c
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file nse/gnunet-nse-profiler.c
- *
- * @brief Profiling driver for the network size estimation service.
- * Generally, the profiler starts a given number of peers,
- * then churns some off, waits a certain amount of time, then
- * churns again, and repeats.
- * @author Christian Grothoff
- * @author Nathan Evans
- * @author Sree Harsha Totakura
- */
-
-#include "platform.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_nse_service.h"
-
-/**
- * Generic loggins shorthand
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-/**
- * Debug logging shorthand
- */
-#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
-
-
-/**
- * Information we track for a peer in the testbed.
- */
-struct NSEPeer
-{
- /**
- * Prev reference in DLL.
- */
- struct NSEPeer *prev;
-
- /**
- * Next reference in DLL.
- */
- struct NSEPeer *next;
-
- /**
- * Handle with testbed.
- */
- struct GNUNET_TESTBED_Peer *daemon;
-
- /**
- * Testbed operation to connect to NSE service.
- */
- struct GNUNET_TESTBED_Operation *nse_op;
-
- /**
- * Testbed operation to connect to statistics service
- */
- struct GNUNET_TESTBED_Operation *stat_op;
-
- /**
- * Handle to the statistics service
- */
- struct GNUNET_STATISTICS_Handle *sh;
-};
-
-
-/**
- * Operation map entry
- */
-struct OpListEntry
-{
- /**
- * DLL next ptr
- */
- struct OpListEntry *next;
-
- /**
- * DLL prev ptr
- */
- struct OpListEntry *prev;
-
- /**
- * The testbed operation
- */
- struct GNUNET_TESTBED_Operation *op;
-
- /**
- * Depending on whether we start or stop NSE service at the peer set this to 1
- * or -1
- */
- int delta;
-};
-
-
-/**
- * Head of DLL of peers we monitor closely.
- */
-static struct NSEPeer *peer_head;
-
-/**
- * Tail of DLL of peers we monitor closely.
- */
-static struct NSEPeer *peer_tail;
-
-/**
- * Return value from 'main' (0 == success)
- */
-static int ok;
-
-/**
- * Be verbose (configuration option)
- */
-static unsigned int verbose;
-
-/**
- * Name of the file with the hosts to run the test over (configuration option)
- */
-static char *hosts_file;
-
-/**
- * Maximum number of peers in the test.
- */
-static unsigned int num_peers;
-
-/**
- * Total number of rounds to execute.
- */
-static unsigned int num_rounds;
-
-/**
- * Current round we are in.
- */
-static unsigned int current_round;
-
-/**
- * Array of size 'num_rounds' with the requested number of peers in the given round.
- */
-static unsigned int *num_peers_in_round;
-
-/**
- * How many peers are running right now?
- */
-static unsigned int peers_running;
-
-/**
- * Specification for the numbers of peers to have in each round.
- */
-static char *num_peer_spec;
-
-/**
- * Handles to all of the running peers.
- */
-static struct GNUNET_TESTBED_Peer **daemons;
-
-/**
- * Global configuration file
- */
-static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
-
-/**
- * Maximum number of connections to NSE services.
- */
-static unsigned int connection_limit;
-
-/**
- * Total number of connections in the whole network.
- */
-static unsigned int total_connections;
-
-/**
- * File to report results to.
- */
-static struct GNUNET_DISK_FileHandle *output_file;
-
-/**
- * Filename to log results to.
- */
-static char *output_filename;
-
-/**
- * File to log connection info, statistics to.
- */
-static struct GNUNET_DISK_FileHandle *data_file;
-
-/**
- * Filename to log connection info, statistics to.
- */
-static char *data_filename;
-
-/**
- * How long to wait before triggering next round?
- * Default: 60 s.
- */
-static struct GNUNET_TIME_Relative wait_time = { 60 * 1000 };
-
-/**
- * DLL head for operation list
- */
-static struct OpListEntry *oplist_head;
-
-/**
- * DLL tail for operation list
- */
-static struct OpListEntry *oplist_tail;
-
-/**
- * Task running each round of the experiment.
- */
-static struct GNUNET_SCHEDULER_Task *round_task;
-
-
-/**
- * Clean up all of the monitoring connections to NSE and
- * STATISTICS that we keep to selected peers.
- */
-static void
-close_monitor_connections ()
-{
- struct NSEPeer *pos;
- struct OpListEntry *oplist_entry;
-
- while (NULL != (pos = peer_head))
- {
- if (NULL != pos->nse_op)
- GNUNET_TESTBED_operation_done (pos->nse_op);
- if (NULL != pos->stat_op)
- GNUNET_TESTBED_operation_done (pos->stat_op);
- GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos);
- GNUNET_free (pos);
- }
- while (NULL != (oplist_entry = oplist_head))
- {
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, oplist_entry);
- GNUNET_TESTBED_operation_done (oplist_entry->op);
- GNUNET_free (oplist_entry);
- }
-}
-
-
-/**
- * Task run on shutdown; cleans up everything.
- *
- * @param cls unused
- */
-static void
-shutdown_task (void *cls)
-{
- LOG_DEBUG ("Ending test.\n");
- close_monitor_connections ();
- if (NULL != round_task)
- {
- GNUNET_SCHEDULER_cancel (round_task);
- round_task = NULL;
- }
- if (NULL != data_file)
- {
- GNUNET_DISK_file_close (data_file);
- data_file = NULL;
- }
- if (NULL != output_file)
- {
- GNUNET_DISK_file_close (output_file);
- output_file = NULL;
- }
- if (NULL != testing_cfg)
- {
- GNUNET_CONFIGURATION_destroy (testing_cfg);
- testing_cfg = NULL;
- }
-}
-
-
-/**
- * Callback to call when network size estimate is updated.
- *
- * @param cls closure with the 'struct NSEPeer' providing the update
- * @param timestamp server timestamp
- * @param estimate the value of the current network size estimate
- * @param std_dev standard deviation (rounded down to nearest integer)
- * of the size estimation values seen
- */
-static void
-handle_estimate (void *cls,
- struct GNUNET_TIME_Absolute timestamp,
- double estimate,
- double std_dev)
-{
- struct NSEPeer *peer = cls;
- char output_buffer[512];
- size_t size;
-
- if (NULL == output_file)
- {
- fprintf (stderr,
- "Received network size estimate from peer %p. Size: %f std.dev. %f\n",
- peer,
- estimate,
- std_dev);
- return;
- }
- size = GNUNET_snprintf (output_buffer,
- sizeof(output_buffer),
- "%p %u %llu %f %f %f\n",
- peer,
- peers_running,
- (unsigned long long) timestamp.abs_value_us,
- GNUNET_NSE_log_estimate_to_n (estimate),
- estimate,
- std_dev);
- if (size != GNUNET_DISK_file_write (output_file, output_buffer, size))
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
-}
-
-
-/**
- * Adapter function called to establish a connection to
- * NSE service.
- *
- * @param cls closure (the 'struct NSEPeer')
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-nse_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct NSEPeer *current_peer = cls;
-
- return GNUNET_NSE_connect (cfg, &handle_estimate, current_peer);
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * NSE service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-nse_disconnect_adapter (void *cls, void *op_result)
-{
- GNUNET_NSE_disconnect (op_result);
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls `struct NSEPeer`
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static int
-stat_iterator (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- char *output_buffer;
- struct GNUNET_TIME_Absolute now;
- int size;
- unsigned int flag;
-
- GNUNET_assert (NULL != data_file);
- now = GNUNET_TIME_absolute_get ();
- flag = strcasecmp (subsystem, "core");
- if (0 != flag)
- flag = 1;
- size = GNUNET_asprintf (&output_buffer,
- "%llu %llu %u\n",
- (unsigned long long) now.abs_value_us / 1000LL / 1000LL,
- (unsigned long long) value,
- flag);
- if (0 > size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n");
- GNUNET_free (output_buffer);
- return GNUNET_SYSERR;
- }
- if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
- GNUNET_free (output_buffer);
- return GNUNET_SYSERR;
- }
- GNUNET_free (output_buffer);
- return GNUNET_OK;
-}
-
-
-/**
- * Called to open a connection to the peer's statistics
- *
- * @param cls peer context
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-stat_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct NSEPeer *peer = cls;
-
- peer->sh = GNUNET_STATISTICS_create ("nse-profiler", cfg);
- return peer->sh;
-}
-
-
-/**
- * Called to disconnect from peer's statistics service
- *
- * @param cls peer context
- * @param op_result service handle returned from the connect adapter
- */
-static void
-stat_disconnect_adapter (void *cls, void *op_result)
-{
- struct NSEPeer *peer = cls;
-
- GNUNET_break (GNUNET_OK ==
- GNUNET_STATISTICS_watch_cancel (peer->sh,
- "core",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_break (GNUNET_OK ==
- GNUNET_STATISTICS_watch_cancel (peer->sh,
- "nse",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
- peer->sh = NULL;
-}
-
-
-/**
- * Called after successfully opening a connection to a peer's statistics
- * service; we register statistics monitoring for CORE and NSE here.
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-stat_comp_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct GNUNET_STATISTICS_Handle *sh = ca_result;
- struct NSEPeer *peer = cls;
-
- if (NULL != emsg)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
- "core",
- "# peers connected",
- stat_iterator,
- peer));
- GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch (sh,
- "nse",
- "# peers connected",
- stat_iterator,
- peer));
-}
-
-
-/**
- * Task run to connect to the NSE and statistics services to a subset of
- * all of the running peers.
- */
-static void
-connect_nse_service ()
-{
- struct NSEPeer *current_peer;
- unsigned int i;
- unsigned int connections;
-
- if (0 == connection_limit)
- return;
- LOG_DEBUG ("Connecting to nse service of peers\n");
- connections = 0;
- for (i = 0; i < num_peers_in_round[current_round]; i++)
- {
- if ((num_peers_in_round[current_round] > connection_limit) &&
- (0 != (i % (num_peers_in_round[current_round] / connection_limit))))
- continue;
- LOG_DEBUG ("Connecting to nse service of peer %d\n", i);
- current_peer = GNUNET_new (struct NSEPeer);
- current_peer->daemon = daemons[i];
- current_peer->nse_op =
- GNUNET_TESTBED_service_connect (NULL,
- current_peer->daemon,
- "nse",
- NULL,
- NULL,
- &nse_connect_adapter,
- &nse_disconnect_adapter,
- current_peer);
- if (NULL != data_file)
- current_peer->stat_op =
- GNUNET_TESTBED_service_connect (NULL,
- current_peer->daemon,
- "statistics",
- stat_comp_cb,
- current_peer,
- &stat_connect_adapter,
- &stat_disconnect_adapter,
- current_peer);
- GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);
- if (++connections == connection_limit)
- break;
- }
-}
-
-
-/**
- * Task that starts/stops peers to move to the next round.
- *
- * @param cls NULL, unused
- */
-static void
-next_round (void *cls);
-
-
-/**
- * We're at the end of a round. Stop monitoring, write total
- * number of connections to log and get full stats. Then trigger
- * the next round.
- *
- * @param cls unused, NULL
- */
-static void
-finish_round (void *cls)
-{
- LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections);
- close_monitor_connections ();
- round_task = GNUNET_SCHEDULER_add_now (&next_round, NULL);
-}
-
-
-/**
- * We have reached the desired number of peers for the current round.
- * Run it (by connecting and monitoring a few peers and waiting the
- * specified delay before finishing the round).
- */
-static void
-run_round ()
-{
- LOG_DEBUG ("Running round %u\n", current_round);
- connect_nse_service ();
- GNUNET_SCHEDULER_add_delayed (wait_time, &finish_round, NULL);
-}
-
-
-/**
- * Creates an oplist entry and adds it to the oplist DLL
- */
-static struct OpListEntry *
-make_oplist_entry ()
-{
- struct OpListEntry *entry;
-
- entry = GNUNET_new (struct OpListEntry);
- GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
- return entry;
-}
-
-
-/**
- * Callback to be called when NSE service is started or stopped at peers
- *
- * @param cls NULL
- * @param op the operation handle
- * @param emsg NULL on success; otherwise an error description
- */
-static void
-manage_service_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const char *emsg)
-{
- struct OpListEntry *entry = cls;
-
- GNUNET_TESTBED_operation_done (entry->op);
- if (NULL != emsg)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop NSE at a peer\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_assert (0 != entry->delta);
- peers_running += entry->delta;
- GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
- GNUNET_free (entry);
- if (num_peers_in_round[current_round] == peers_running)
- run_round ();
-}
-
-
-/**
- * Adjust the number of running peers to match the required number of running
- * peers for the round
- */
-static void
-adjust_running_peers ()
-{
- struct OpListEntry *entry;
- unsigned int i;
-
- /* start peers if we have too few */
- for (i = peers_running; i < num_peers_in_round[current_round]; i++)
- {
- entry = make_oplist_entry ();
- entry->delta = 1;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- daemons[i],
- "nse",
- &manage_service_cb,
- entry,
- 1);
- }
- /* stop peers if we have too many */
- for (i = num_peers_in_round[current_round]; i < peers_running; i++)
- {
- entry = make_oplist_entry ();
- entry->delta = -1;
- entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
- daemons[i],
- "nse",
- &manage_service_cb,
- entry,
- 0);
- }
-}
-
-
-/**
- * Task run at the end of a round. Disconnect from all monitored
- * peers; then get statistics from *all* peers.
- *
- * @param cls NULL, unused
- */
-static void
-next_round (void *cls)
-{
- round_task = NULL;
- LOG_DEBUG ("Disconnecting nse service of peers\n");
- current_round++;
- if (current_round == num_rounds)
- {
- /* this was the last round, terminate */
- ok = 0;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (num_peers_in_round[current_round] == peers_running)
- {
- /* no need to churn, just run next round */
- run_round ();
- return;
- }
- adjust_running_peers ();
-}
-
-
-/**
- * Function that will be called whenever something in the
- * testbed changes.
- *
- * @param cls closure, NULL
- * @param event information on what is happening
- */
-static void
-master_controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- switch (event->type)
- {
- case GNUNET_TESTBED_ET_CONNECT:
- total_connections++;
- break;
-
- case GNUNET_TESTBED_ET_DISCONNECT:
- total_connections--;
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Signature of a main function for a testcase.
- *
- * @param cls NULL
- * @param h the run handle
- * @param num_peers_ number of peers in 'peers'
- * @param peers handle to peers run in the testbed. NULL upon timeout (see
- * GNUNET_TESTBED_test_run()).
- * @param links_succeeded the number of overlay link connection attempts that
- * succeeded
- * @param links_failed the number of overlay link connection attempts that
- * failed
- */
-static void
-test_master (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers_,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- if (NULL == peers)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- daemons = peers;
- GNUNET_break (num_peers_ == num_peers);
- peers_running = num_peers;
- if (num_peers_in_round[current_round] == peers_running)
- {
- /* no need to churn, just run the starting round */
- run_round ();
- return;
- }
- adjust_running_peers ();
-}
-
-
-/**
- * Actual main function that runs the emulation.
- *
- * @param cls unused
- * @param args remaining args, unused
- * @param cfgfile name of the configuration
- * @param cfg configuration handle
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- char *tok;
- uint64_t event_mask;
- unsigned int num;
-
- ok = 1;
- testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
- LOG_DEBUG ("Starting daemons.\n");
- if (NULL == num_peer_spec)
- {
- fprintf (stderr, "You need to specify the number of peers to run\n");
- return;
- }
- for (tok = strtok (num_peer_spec, ","); NULL != tok; tok = strtok (NULL, ","))
- {
- if (1 != sscanf (tok, "%u", &num))
- {
- fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
- return;
- }
- if (0 == num)
- {
- fprintf (stderr, "Refusing to run a round with 0 peers\n");
- return;
- }
- GNUNET_array_append (num_peers_in_round, num_rounds, num);
- num_peers = GNUNET_MAX (num_peers, num);
- }
- if (0 == num_peers)
- {
- fprintf (stderr, "Refusing to run a testbed with no rounds\n");
- return;
- }
- if ((NULL != data_filename) &&
- (NULL ==
- (data_file = GNUNET_DISK_file_open (data_filename,
- GNUNET_DISK_OPEN_READWRITE
- | GNUNET_DISK_OPEN_TRUNCATE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE))))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", data_filename);
-
- if ((NULL != output_filename) &&
- (NULL ==
- (output_file = GNUNET_DISK_file_open (output_filename,
- GNUNET_DISK_OPEN_READWRITE
- | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE))))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", output_filename);
- event_mask = 0LL;
- event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
- event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
- event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
- event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
- GNUNET_TESTBED_run (hosts_file,
- cfg,
- num_peers,
- event_mask,
- master_controller_cb,
- NULL, /* master_controller_cb cls */
- &test_master,
- NULL); /* test_master cls */
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
-}
-
-
-/**
- * Main function.
- *
- * @return 0 on success
- */
-int
-main (int argc, char *const *argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] =
- { GNUNET_GETOPT_option_uint (
- 'C',
- "connections",
- "COUNT",
- gettext_noop (
- "limit to the number of connections to NSE services, 0 for none"),
- &connection_limit),
- GNUNET_GETOPT_option_string (
- 'd',
- "details",
- "FILENAME",
- gettext_noop (
- "name of the file for writing connection information and statistics"),
- &data_filename),
-
- GNUNET_GETOPT_option_string (
- 'H',
- "hosts",
- "FILENAME",
- gettext_noop (
- "name of the file with the login information for the testbed"),
- &hosts_file),
-
- GNUNET_GETOPT_option_string (
- 'o',
- "output",
- "FILENAME",
- gettext_noop ("name of the file for writing the main results"),
- &output_filename),
-
-
- GNUNET_GETOPT_option_string (
- 'p',
- "peers",
- "NETWORKSIZESPEC",
- gettext_noop (
- "Number of peers to run in each round, separated by commas"),
- &num_peer_spec),
-
- GNUNET_GETOPT_option_increment_uint (
- 'V',
- "verbose",
- gettext_noop ("be verbose (print progress information)"),
- &verbose),
-
- GNUNET_GETOPT_option_relative_time ('w',
- "wait",
- "DELAY",
- gettext_noop ("delay between rounds"),
- &wait_time),
- GNUNET_GETOPT_OPTION_END };
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
- if (
- GNUNET_OK !=
- GNUNET_PROGRAM_run (argc,
- argv,
- "nse-profiler",
- gettext_noop (
- "Measure quality and performance of the NSE service."),
- options,
- &run,
- NULL))
- ok = 1;
- return ok;
-}
-
-
-/* end of nse-profiler.c */
diff --git a/src/service/nse/hostkeys.dat b/src/service/nse/hostkeys.dat
deleted file mode 100644
index ab407c167..000000000
--- a/src/service/nse/hostkeys.dat
+++ /dev/null
Binary files differ
diff --git a/src/service/regex/Makefile.am b/src/service/regex/Makefile.am
index 255988889..0ce42880d 100644
--- a/src/service/regex/Makefile.am
+++ b/src/service/regex/Makefile.am
@@ -52,21 +52,6 @@ libgnunetregex_la_LDFLAGS = \
-version-info 3:1:0
-# FIXME we phased out mysql. If we want to keep, needs rewrite
-#if HAVE_MYSQL
-#noinst_mysql_progs = \
-# gnunet-regex-simulation-profiler
-
-#gnunet_regex_simulation_profiler_SOURCES = \
-# $(REGEX_INTERNAL) gnunet-regex-simulation-profiler.c
-#gnunet_regex_simulation_profiler_LDADD = \
-# libgnunetregexblock.la \
-# $(top_builddir)/src/lib/util/libgnunetutil.la \
-# $(top_builddir)/src/service/dht/libgnunetdht.la \
-# $(top_builddir)/src/lib/block/libgnunetblock.la \
-# $(top_builddir)/src/service/statistics/libgnunetstatistics.la
-#endif
-
noinst_PROGRAMS = $(noinst_mysql_progs) \
perf-regex
@@ -151,5 +136,4 @@ test_regex_graph_api_LDADD = -lm \
EXTRA_DIST = \
- regex_simulation_profiler_test.conf \
test_regex_api_data.conf
diff --git a/src/service/regex/gnunet-regex-simulation-profiler.c b/src/service/regex/gnunet-regex-simulation-profiler.c
deleted file mode 100644
index abdb1abeb..000000000
--- a/src/service/regex/gnunet-regex-simulation-profiler.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2011, 2012 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-
-/**
- * @file regex/gnunet-regex-simulation-profiler.c
- * @brief Regex profiler that dumps all DFAs into a database instead of
- * using the DHT (with cadet).
- * @author Maximilian Szengel
- * @author Christophe Genevey
- *
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "regex_internal_lib.h"
-#include "gnunet_mysql_lib.h"
-#include "gnunet_mysql_compat.h"
-#include "gnunet_my_lib.h"
-#include <mysql/mysql.h>
-
-/**
- * MySQL statement to insert an edge.
- */
-#define INSERT_EDGE_STMT "INSERT IGNORE INTO `%s` " \
- "(`key`, `label`, `to_key`, `accepting`) " \
- "VALUES (?, ?, ?, ?);"
-
-/**
- * MySQL statement to select a key count.
- */
-#define SELECT_KEY_STMT "SELECT COUNT(*) FROM `%s` " \
- "WHERE `key` = ? AND `label` = ?;"
-
-/**
- * Simple struct to keep track of progress, and print a
- * nice little percentage meter for long running tasks.
- */
-struct ProgressMeter
-{
- /**
- * Total number of elements.
- */
- unsigned int total;
-
- /**
- * Interval for printing percentage.
- */
- unsigned int modnum;
-
- /**
- * Number of dots to print.
- */
- unsigned int dotnum;
-
- /**
- * Completed number.
- */
- unsigned int completed;
-
- /**
- * Should the meter be printed?
- */
- int print;
-
- /**
- * String to print on startup.
- */
- char *startup_string;
-};
-
-
-/**
- * Handle for the progress meter
- */
-static struct ProgressMeter *meter;
-
-/**
- * Scan task identifier;
- */
-static struct GNUNET_SCHEDULER_Task *scan_task;
-
-/**
- * Global testing status.
- */
-static int result;
-
-/**
- * MySQL context.
- */
-static struct GNUNET_MYSQL_Context *mysql_ctx;
-
-/**
- * MySQL prepared statement handle.
- */
-static struct GNUNET_MYSQL_StatementHandle *stmt_handle;
-
-/**
- * MySQL prepared statement handle for `key` select.
- */
-static struct GNUNET_MYSQL_StatementHandle *select_stmt_handle;
-
-/**
- * MySQL table name.
- */
-static char *table_name;
-
-/**
- * Policy dir containing files that contain policies.
- */
-static char *policy_dir;
-
-/**
- * Number of policy files.
- */
-static unsigned int num_policy_files;
-
-/**
- * Number of policies.
- */
-static unsigned int num_policies;
-
-/**
- * Maximal path compression length.
- */
-static unsigned int max_path_compression;
-
-/**
- * Number of merged transitions.
- */
-static unsigned long long num_merged_transitions;
-
-/**
- * Number of merged states from different policies.
- */
-static unsigned long long num_merged_states;
-
-/**
- * Prefix to add before every regex we're announcing.
- */
-static char *regex_prefix;
-
-
-/**
- * Create a meter to keep track of the progress of some task.
- *
- * @param total the total number of items to complete
- * @param start_string a string to prefix the meter with (if printing)
- * @param print GNUNET_YES to print the meter, GNUNET_NO to count
- * internally only
- *
- * @return the progress meter
- */
-static struct ProgressMeter *
-create_meter (unsigned int total, char *start_string, int print)
-{
- struct ProgressMeter *ret;
-
- ret = GNUNET_new (struct ProgressMeter);
- ret->print = print;
- ret->total = total;
- ret->modnum = total / 4;
- if (ret->modnum == 0) /* Divide by zero check */
- ret->modnum = 1;
- ret->dotnum = (total / 50) + 1;
- if (start_string != NULL)
- ret->startup_string = GNUNET_strdup (start_string);
- else
- ret->startup_string = GNUNET_strdup ("");
-
- return ret;
-}
-
-
-/**
- * Update progress meter (increment by one).
- *
- * @param meter the meter to update and print info for
- *
- * @return GNUNET_YES if called the total requested,
- * GNUNET_NO if more items expected
- */
-static int
-update_meter (struct ProgressMeter *meter)
-{
- if (meter->print == GNUNET_YES)
- {
- if (meter->completed % meter->modnum == 0)
- {
- if (meter->completed == 0)
- {
- fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
- }
- else
- fprintf (stdout, "%d%%",
- (int) (((float) meter->completed / meter->total) * 100));
- }
- else if (meter->completed % meter->dotnum == 0)
- fprintf (stdout, "%s", ".");
-
- if (meter->completed + 1 == meter->total)
- fprintf (stdout, "%d%%]\n", 100);
- fflush (stdout);
- }
- meter->completed++;
-
- if (meter->completed == meter->total)
- return GNUNET_YES;
- if (meter->completed > meter->total)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Progress meter overflow!!\n");
- return GNUNET_NO;
-}
-
-
-/**
- * Reset progress meter.
- *
- * @param meter the meter to reset
- *
- * @return #GNUNET_YES if meter reset,
- * #GNUNET_SYSERR on error
- */
-static int
-reset_meter (struct ProgressMeter *meter)
-{
- if (meter == NULL)
- return GNUNET_SYSERR;
-
- meter->completed = 0;
- return GNUNET_YES;
-}
-
-
-/**
- * Release resources for meter
- *
- * @param meter the meter to free
- */
-static void
-free_meter (struct ProgressMeter *meter)
-{
- GNUNET_free (meter->startup_string);
- GNUNET_free (meter);
-}
-
-
-/**
- * Shutdown task.
- *
- * @param cls NULL
- */
-static void
-do_shutdown (void *cls)
-{
- if (NULL != mysql_ctx)
- {
- GNUNET_MYSQL_context_destroy (mysql_ctx);
- mysql_ctx = NULL;
- }
- if (NULL != meter)
- {
- free_meter (meter);
- meter = NULL;
- }
-}
-
-
-/**
- * Abort task to run on test timed out.
- *
- * FIXME: this doesn't actually work, it used to cancel
- * the already running 'scan_task', but now that should
- * always be NULL and do nothing. We instead need to set
- * a global variable and abort scan_task internally, not
- * via scheduler.
- *
- * @param cls NULL
- */
-static void
-do_abort (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n");
- if (NULL != scan_task)
- {
- GNUNET_SCHEDULER_cancel (scan_task);
- scan_task = NULL;
- }
- result = GNUNET_SYSERR;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Iterator over all states that inserts each state into the MySQL db.
- *
- * @param cls closure.
- * @param key hash for current state.
- * @param proof proof for current state.
- * @param accepting #GNUNET_YES if this is an accepting state, #GNUNET_NO if not.
- * @param num_edges number of edges leaving current state.
- * @param edges edges leaving current state.
- */
-static void
-regex_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- const char *proof,
- int accepting,
- unsigned int num_edges,
- const struct REGEX_BLOCK_Edge *edges)
-{
- unsigned int i;
- int result;
-
- uint32_t iaccepting = (uint32_t) accepting;
- uint64_t total;
-
- GNUNET_assert (NULL != mysql_ctx);
-
- for (i = 0; i < num_edges; i++)
- {
- struct GNUNET_MY_QueryParam params_select[] = {
- GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_string (edges[i].label),
- GNUNET_MY_query_param_end
- };
-
- struct GNUNET_MY_ResultSpec results_select[] = {
- GNUNET_MY_result_spec_uint64 (&total),
- GNUNET_MY_result_spec_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- select_stmt_handle,
- params_select);
-
- if (GNUNET_SYSERR == result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql select statement\n");
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return;
- }
-
- result =
- GNUNET_MY_extract_result (select_stmt_handle,
- results_select);
-
- if (GNUNET_SYSERR == result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error extracting result mysql select statement\n");
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return;
- }
-
- if ((-1 != total) && (total > 0) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n",
- (unsigned long long) total,
- GNUNET_h2s (key), edges[i].label);
- }
-
- struct GNUNET_MY_QueryParam params_stmt[] = {
- GNUNET_MY_query_param_auto_from_type (&key),
- GNUNET_MY_query_param_string (edges[i].label),
- GNUNET_MY_query_param_auto_from_type (&edges[i].destination),
- GNUNET_MY_query_param_uint32 (&iaccepting),
- GNUNET_MY_query_param_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- stmt_handle,
- params_stmt);
-
- if (0 == result)
- {
- char *key_str = GNUNET_strdup (GNUNET_h2s (key));
- char *to_key_str = GNUNET_strdup (GNUNET_h2s (&edges[i].destination));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Merged (%s, %s, %s, %i)\n",
- key_str,
- edges[i].label,
- to_key_str,
- accepting);
-
- GNUNET_free (key_str);
- GNUNET_free (to_key_str);
- num_merged_transitions++;
- }
- else if (-1 != total)
- {
- num_merged_states++;
- }
-
- if ((GNUNET_SYSERR == result) || ((1 != result) && (0 != result) ))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n",
- result);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- }
- }
-
- if (0 == num_edges)
- {
- struct GNUNET_MY_QueryParam params_stmt[] = {
- GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_string (""),
- GNUNET_MY_query_param_fixed_size (NULL, 0),
- GNUNET_MY_query_param_uint32 (&iaccepting),
- GNUNET_MY_query_param_end
- };
-
- result =
- GNUNET_MY_exec_prepared (mysql_ctx,
- stmt_handle,
- params_stmt);
-
- if ((1 != result) && (0 != result) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n",
- result);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- }
- }
-}
-
-
-/**
- * Announce a regex by creating the DFA and iterating over each state, inserting
- * each state into a MySQL database.
- *
- * @param regex regular expression.
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure.
- */
-static int
-announce_regex (const char *regex)
-{
- struct REGEX_INTERNAL_Automaton *dfa;
-
- dfa =
- REGEX_INTERNAL_construct_dfa (regex,
- strlen (regex),
- max_path_compression);
-
- if (NULL == dfa)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create DFA for regex %s\n",
- regex);
- GNUNET_SCHEDULER_add_now (&do_abort, NULL);
- return GNUNET_SYSERR;
- }
- REGEX_INTERNAL_iterate_all_edges (dfa,
- &regex_iterator, NULL);
- REGEX_INTERNAL_automaton_destroy (dfa);
-
- return GNUNET_OK;
-}
-
-
-/**
- * Function called with a filename.
- *
- * @param cls closure
- * @param filename complete filename (absolute path)
- * @return #GNUNET_OK to continue to iterate,
- * #GNUNET_SYSERR to abort iteration with error!
- */
-static int
-policy_filename_cb (void *cls, const char *filename)
-{
- char *regex;
- char *data;
- char *buf;
- uint64_t filesize;
- unsigned int offset;
-
- GNUNET_assert (NULL != filename);
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Announcing regexes from file %s\n",
- filename);
-
- if (GNUNET_YES != GNUNET_DISK_file_test (filename))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Could not find policy file %s\n",
- filename);
- return GNUNET_OK;
- }
- if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename, &filesize,
- GNUNET_YES, GNUNET_YES))
- filesize = 0;
- if (0 == filesize)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Policy file %s is empty.\n",
- filename);
- return GNUNET_OK;
- }
- data = GNUNET_malloc (filesize);
- if (filesize != GNUNET_DISK_fn_read (filename, data, filesize))
- {
- GNUNET_free (data);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Could not read policy file %s.\n",
- filename);
- return GNUNET_OK;
- }
-
- update_meter (meter);
-
- buf = data;
- offset = 0;
- regex = NULL;
- while (offset < (filesize - 1))
- {
- offset++;
- if (((data[offset] == '\n')) && (buf != &data[offset]))
- {
- data[offset] = '|';
- num_policies++;
- buf = &data[offset + 1];
- }
- else if ((data[offset] == '\n') || (data[offset] == '\0'))
- buf = &data[offset + 1];
- }
- data[offset] = '\0';
- GNUNET_asprintf (&regex, "%s(%s)", regex_prefix, data);
- GNUNET_assert (NULL != regex);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Announcing regex: %s\n", regex);
-
- if (GNUNET_OK != announce_regex (regex))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not announce regex %s\n",
- regex);
- }
- GNUNET_free (regex);
- GNUNET_free (data);
- return GNUNET_OK;
-}
-
-
-/**
- * Iterate over files contained in policy_dir.
- *
- * @param cls NULL
- */
-static void
-do_directory_scan (void *cls)
-{
- struct GNUNET_TIME_Absolute start_time;
- struct GNUNET_TIME_Relative duration;
- char *stmt;
-
- /* Create an MySQL prepared statement for the inserts */
- scan_task = NULL;
- GNUNET_asprintf (&stmt, INSERT_EDGE_STMT, table_name);
- stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt);
- GNUNET_free (stmt);
-
- GNUNET_asprintf (&stmt, SELECT_KEY_STMT, table_name);
- select_stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt);
- GNUNET_free (stmt);
-
- GNUNET_assert (NULL != stmt_handle);
-
- meter = create_meter (num_policy_files,
- "Announcing policy files\n",
- GNUNET_YES);
- start_time = GNUNET_TIME_absolute_get ();
- GNUNET_DISK_directory_scan (policy_dir,
- &policy_filename_cb,
- stmt_handle);
- duration = GNUNET_TIME_absolute_get_duration (start_time);
- reset_meter (meter);
- free_meter (meter);
- meter = NULL;
-
- printf ("Announced %u files containing %u policies in %s\n"
- "Duplicate transitions: %llu\nMerged states: %llu\n",
- num_policy_files,
- num_policies,
- GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_NO),
- num_merged_transitions,
- num_merged_states);
- result = GNUNET_OK;
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param config configuration
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *config)
-{
- if (NULL == args[0])
- {
- fprintf (stderr,
- _ ("No policy directory specified on command line. Exiting.\n"));
- result = GNUNET_SYSERR;
- return;
- }
- if (GNUNET_YES !=
- GNUNET_DISK_directory_test (args[0], GNUNET_YES))
- {
- fprintf (stderr,
- _ ("Specified policies directory does not exist. Exiting.\n"));
- result = GNUNET_SYSERR;
- return;
- }
- policy_dir = args[0];
-
- num_policy_files = GNUNET_DISK_directory_scan (policy_dir,
- NULL, NULL);
- meter = NULL;
-
- if (NULL == table_name)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No table name specified, using default \"NFA\".\n");
- table_name = "NFA";
- }
-
- mysql_ctx = GNUNET_MYSQL_context_create (config, "regex-mysql");
- if (NULL == mysql_ctx)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create mysql context\n");
- result = GNUNET_SYSERR;
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (config,
- "regex-mysql",
- "REGEX_PREFIX",
- &regex_prefix))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "regex-mysql",
- "REGEX_PREFIX");
- result = GNUNET_SYSERR;
- return;
- }
-
- result = GNUNET_OK;
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
- scan_task = GNUNET_SCHEDULER_add_now (&do_directory_scan, NULL);
-}
-
-
-/**
- * Main function.
- *
- * @param argc argument count
- * @param argv argument values
- * @return 0 on success
- */
-int
-main (int argc, char *const *argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_string ('t',
- "table",
- "TABLENAME",
- gettext_noop (
- "name of the table to write DFAs"),
- &table_name),
-
- GNUNET_GETOPT_option_uint ('p',
- "max-path-compression",
- "MAX_PATH_COMPRESSION",
- gettext_noop ("maximum path compression length"),
- &max_path_compression),
-
- GNUNET_GETOPT_OPTION_END
- };
- int ret;
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
-
- result = GNUNET_SYSERR;
- ret =
- GNUNET_PROGRAM_run (argc, argv,
- "gnunet-regex-simulationprofiler [OPTIONS] policy-dir",
- _ ("Profiler for regex library"), options, &run, NULL);
- if (GNUNET_OK != ret)
- return ret;
- if (GNUNET_OK != result)
- return 1;
- return 0;
-}
diff --git a/src/service/regex/regex_simulation_profiler_test.conf b/src/service/regex/regex_simulation_profiler_test.conf
deleted file mode 100644
index 9384aa249..000000000
--- a/src/service/regex/regex_simulation_profiler_test.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[regex-mysql]
-DATABASE = regex
-USER = gnunet
-PASSWORD =
-HOST = localhost
-PORT = 3306
-REGEX_PREFIX = GNVPN-0001-PAD
diff --git a/src/service/rest/openid_plugin.c b/src/service/rest/openid_plugin.c
index a4f082d2a..61904494b 100644
--- a/src/service/rest/openid_plugin.c
+++ b/src/service/rest/openid_plugin.c
@@ -242,7 +242,7 @@
* How long to wait for a consume in userinfo endpoint
*/
#define CONSUME_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS,2)
+ GNUNET_TIME_UNIT_SECONDS,2)
/**
* OIDC ignored parameter array
@@ -1022,16 +1022,16 @@ login_redirect (void *cls)
"&%s=%s",
OIDC_CLIENT_ID_KEY,
handle->oidc->client_id);
- GNUNET_STRINGS_urlencode (handle->oidc->redirect_uri,
- strlen (handle->oidc->redirect_uri),
+ GNUNET_STRINGS_urlencode (strlen (handle->oidc->redirect_uri),
+ handle->oidc->redirect_uri,
&tmp);
GNUNET_buffer_write_fstr (&buf,
"&%s=%s",
OIDC_REDIRECT_URI_KEY,
tmp);
GNUNET_free (tmp);
- GNUNET_STRINGS_urlencode (handle->oidc->scope,
- strlen (handle->oidc->scope),
+ GNUNET_STRINGS_urlencode (strlen (handle->oidc->scope),
+ handle->oidc->scope,
&tmp);
GNUNET_buffer_write_fstr (&buf,
"&%s=%s",
@@ -1040,8 +1040,8 @@ login_redirect (void *cls)
GNUNET_free (tmp);
if (NULL != handle->oidc->state)
{
- GNUNET_STRINGS_urlencode (handle->oidc->state,
- strlen (handle->oidc->state),
+ GNUNET_STRINGS_urlencode (strlen (handle->oidc->state),
+ handle->oidc->state,
&tmp);
GNUNET_buffer_write_fstr (&buf,
"&%s=%s",
@@ -1065,8 +1065,8 @@ login_redirect (void *cls)
}
if (NULL != handle->oidc->claims)
{
- GNUNET_STRINGS_urlencode (handle->oidc->claims,
- strlen (handle->oidc->claims),
+ GNUNET_STRINGS_urlencode (strlen (handle->oidc->claims),
+ handle->oidc->claims,
&tmp);
GNUNET_buffer_write_fstr (&buf,
"&%s=%s",
diff --git a/src/service/seti/Makefile.am b/src/service/seti/Makefile.am
index 00923d56d..3c0c66ed8 100644
--- a/src/service/seti/Makefile.am
+++ b/src/service/seti/Makefile.am
@@ -17,22 +17,9 @@ endif
libexec_PROGRAMS = \
gnunet-service-seti
-noinst_PROGRAMS = \
- gnunet-seti-profiler
-
lib_LTLIBRARIES = \
libgnunetseti.la
-gnunet_seti_profiler_SOURCES = \
- gnunet-seti-profiler.c
-gnunet_seti_profiler_LDADD = \
- $(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
- libgnunetseti.la \
- $(top_builddir)/src/service/testing/libgnunettesting.la \
- $(GN_LIBINTL)
-
-
gnunet_service_seti_SOURCES = \
gnunet-service-seti.c \
gnunet-service-seti_protocol.h
diff --git a/src/service/seti/gnunet-seti-profiler.c b/src/service/seti/gnunet-seti-profiler.c
deleted file mode 100644
index b8230bcfc..000000000
--- a/src/service/seti/gnunet-seti-profiler.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2013, 2020 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file set/gnunet-seti-profiler.c
- * @brief profiling tool for set intersection
- * @author Florian Dold
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-#include "gnunet_seti_service.h"
-#include "gnunet_testbed_service.h"
-
-
-static int ret;
-
-static unsigned int num_a = 5;
-static unsigned int num_b = 5;
-static unsigned int num_c = 20;
-
-const static struct GNUNET_CONFIGURATION_Handle *config;
-
-struct SetInfo
-{
- char *id;
- struct GNUNET_SETI_Handle *set;
- struct GNUNET_SETI_OperationHandle *oh;
- struct GNUNET_CONTAINER_MultiHashMap *sent;
- struct GNUNET_CONTAINER_MultiHashMap *received;
- int done;
-} info1, info2;
-
-static struct GNUNET_CONTAINER_MultiHashMap *common_sent;
-
-static struct GNUNET_HashCode app_id;
-
-static struct GNUNET_PeerIdentity local_peer;
-
-static struct GNUNET_SETI_ListenHandle *set_listener;
-
-static unsigned int use_intersection;
-
-static unsigned int element_size = 32;
-
-/**
- * Handle to the statistics service.
- */
-static struct GNUNET_STATISTICS_Handle *statistics;
-
-/**
- * The profiler will write statistics
- * for all peers to the file with this name.
- */
-static char *statistics_filename;
-
-/**
- * The profiler will write statistics
- * for all peers to this file.
- */
-static FILE *statistics_file;
-
-
-static int
-map_remove_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_CONTAINER_MultiHashMap *m = cls;
- int ret;
-
- GNUNET_assert (NULL != key);
-
- ret = GNUNET_CONTAINER_multihashmap_remove_all (m, key);
- if (GNUNET_OK != ret)
- printf ("spurious element\n");
- return GNUNET_YES;
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls closure
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static int
-statistics_result (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- if (NULL != statistics_file)
- {
- fprintf (statistics_file, "%s\t%s\t%lu\n", subsystem, name, (unsigned
- long) value);
- }
- return GNUNET_OK;
-}
-
-
-static void
-statistics_done (void *cls,
- int success)
-{
- GNUNET_assert (GNUNET_YES == success);
- if (NULL != statistics_file)
- fclose (statistics_file);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-check_all_done (void)
-{
- if ((info1.done == GNUNET_NO) || (info2.done == GNUNET_NO))
- return;
-
- GNUNET_CONTAINER_multihashmap_iterate (info1.received, map_remove_iterator,
- info2.sent);
- GNUNET_CONTAINER_multihashmap_iterate (info2.received, map_remove_iterator,
- info1.sent);
-
- printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info1.sent));
- printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info2.sent));
-
- if (NULL == statistics_filename)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- statistics_file = fopen (statistics_filename, "w");
- GNUNET_STATISTICS_get (statistics, NULL, NULL,
- &statistics_done,
- &statistics_result, NULL);
-}
-
-
-static void
-set_result_cb (void *cls,
- const struct GNUNET_SETI_Element *element,
- uint64_t current_size,
- enum GNUNET_SETI_Status status)
-{
- struct SetInfo *info = cls;
- struct GNUNET_HashCode hash;
-
- GNUNET_assert (GNUNET_NO == info->done);
- switch (status)
- {
- case GNUNET_SETI_STATUS_DONE:
- info->done = GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "set intersection done\n");
- check_all_done ();
- info->oh = NULL;
- return;
- case GNUNET_SETI_STATUS_FAILURE:
- info->oh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "failure\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
- case GNUNET_SETI_STATUS_ADD_LOCAL:
- GNUNET_CRYPTO_hash (element->data,
- element->size,
- &hash);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "set %s: keep element %s\n",
- info->id,
- GNUNET_h2s (&hash));
- break;
- case GNUNET_SETI_STATUS_DEL_LOCAL:
- GNUNET_CRYPTO_hash (element->data,
- element->size,
- &hash);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "set %s: remove element %s\n",
- info->id,
- GNUNET_h2s (&hash));
- return;
- default:
- GNUNET_assert (0);
- }
-
- if (element->size != element_size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "wrong element size: %u, expected %u\n",
- element->size,
- (unsigned int) sizeof(struct GNUNET_HashCode));
- GNUNET_assert (0);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "set %s: got element (%s)\n",
- info->id, GNUNET_h2s (element->data));
- GNUNET_assert (NULL != element->data);
- {
- struct GNUNET_HashCode data_hash;
-
- GNUNET_CRYPTO_hash (element->data,
- element_size,
- &data_hash);
- GNUNET_CONTAINER_multihashmap_put (info->received,
- &data_hash,
- NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-}
-
-
-static void
-set_listen_cb (void *cls,
- const struct GNUNET_PeerIdentity *other_peer,
- const struct GNUNET_MessageHeader *context_msg,
- struct GNUNET_SETI_Request *request)
-{
- /* max. 1 option plus terminator */
- struct GNUNET_SETI_Option opts[2] = { { 0 } };
- unsigned int n_opts = 0;
-
- if (NULL == request)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "listener failed\n");
- return;
- }
- GNUNET_assert (NULL == info2.oh);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "set listen cb called\n");
- if (use_intersection)
- {
- opts[n_opts++] = (struct GNUNET_SETI_Option) { .type =
- GNUNET_SETI_OPTION_RETURN_INTERSECTION };
- }
- opts[n_opts].type = GNUNET_SETI_OPTION_END;
- info2.oh = GNUNET_SETI_accept (request,
- opts,
- &set_result_cb,
- &info2);
- GNUNET_SETI_commit (info2.oh,
- info2.set);
-}
-
-
-static int
-set_insert_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_SETI_Handle *set = cls;
- struct GNUNET_SETI_Element el;
-
- el.element_type = 0;
- el.data = value;
- el.size = element_size;
- GNUNET_SETI_add_element (set, &el, NULL, NULL);
- return GNUNET_YES;
-}
-
-
-static void
-handle_shutdown (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutting down set profiler\n");
- if (NULL != set_listener)
- {
- GNUNET_SETI_listen_cancel (set_listener);
- set_listener = NULL;
- }
- if (NULL != info1.oh)
- {
- GNUNET_SETI_operation_cancel (info1.oh);
- info1.oh = NULL;
- }
- if (NULL != info2.oh)
- {
- GNUNET_SETI_operation_cancel (info2.oh);
- info2.oh = NULL;
- }
- if (NULL != info1.set)
- {
- GNUNET_SETI_destroy (info1.set);
- info1.set = NULL;
- }
- if (NULL != info2.set)
- {
- GNUNET_SETI_destroy (info2.set);
- info2.set = NULL;
- }
- GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- unsigned int i;
- struct GNUNET_HashCode hash;
- /* max. 1 option plus terminator */
- struct GNUNET_SETI_Option opts[2] = { { 0 } };
- unsigned int n_opts = 0;
-
- config = cfg;
-
- GNUNET_assert (element_size > 0);
-
- if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "could not retrieve host identity\n");
- ret = 0;
- return;
- }
- statistics = GNUNET_STATISTICS_create ("set-profiler", cfg);
- GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
- info1.id = "a";
- info2.id = "b";
- info1.sent = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.sent = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
- common_sent = GNUNET_CONTAINER_multihashmap_create (num_c + 1, GNUNET_NO);
- info1.received = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.received = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
- for (i = 0; i < num_a; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_b; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_c; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &app_id);
-
- info1.set = GNUNET_SETI_create (config);
- info2.set = GNUNET_SETI_create (config);
- GNUNET_CONTAINER_multihashmap_iterate (info1.sent,
- &set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (info2.sent,
- &set_insert_iterator,
- info2.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent,
- &set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent,
- &set_insert_iterator,
- info2.set);
-
- set_listener = GNUNET_SETI_listen (config,
- &app_id,
- &set_listen_cb,
- NULL);
- if (use_intersection)
- {
- opts[n_opts++] = (struct GNUNET_SETI_Option) { .type =
- GNUNET_SETI_OPTION_RETURN_INTERSECTION };
- }
- opts[n_opts].type = GNUNET_SETI_OPTION_END;
-
- info1.oh = GNUNET_SETI_prepare (&local_peer,
- &app_id,
- NULL,
- opts,
- set_result_cb,
- &info1);
- GNUNET_SETI_commit (info1.oh,
- info1.set);
- GNUNET_SETI_destroy (info1.set);
- info1.set = NULL;
-}
-
-
-static void
-pre_run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- if (0 != GNUNET_TESTING_peer_run ("set-profiler",
- cfgfile,
- &run, NULL))
- ret = 2;
-}
-
-
-int
-main (int argc, char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('A',
- "num-first",
- NULL,
- gettext_noop ("number of values"),
- &num_a),
- GNUNET_GETOPT_option_uint ('B',
- "num-second",
- NULL,
- gettext_noop ("number of values"),
- &num_b),
- GNUNET_GETOPT_option_uint ('C',
- "num-common",
- NULL,
- gettext_noop ("number of values"),
- &num_c),
- GNUNET_GETOPT_option_uint ('i',
- "use-intersection",
- NULL,
- gettext_noop (
- "return intersection instead of delta"),
- &use_intersection),
- GNUNET_GETOPT_option_uint ('w',
- "element-size",
- NULL,
- gettext_noop ("element size"),
- &element_size),
- GNUNET_GETOPT_option_filename ('s',
- "statistics",
- "FILENAME",
- gettext_noop ("write statistics to file"),
- &statistics_filename),
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run2 (argc, argv,
- "gnunet-seti-profiler",
- "help",
- options,
- &pre_run,
- NULL,
- GNUNET_YES);
- return ret;
-}
diff --git a/src/service/setu/Makefile.am b/src/service/setu/Makefile.am
index f0cf9fdbc..bdbc78f44 100644
--- a/src/service/setu/Makefile.am
+++ b/src/service/setu/Makefile.am
@@ -15,8 +15,7 @@ if USE_COVERAGE
endif
noinst_PROGRAMS = \
- gnunet-setu-ibf-profiler \
- gnunet-setu-profiler
+ gnunet-setu-ibf-profiler
libexec_PROGRAMS = \
gnunet-service-setu
@@ -24,16 +23,6 @@ libexec_PROGRAMS = \
lib_LTLIBRARIES = \
libgnunetsetu.la
-gnunet_setu_profiler_SOURCES = \
- gnunet-setu-profiler.c
-gnunet_setu_profiler_LDADD = \
- $(top_builddir)/src/lib/util/libgnunetutil.la \
- $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
- libgnunetsetu.la \
- $(top_builddir)/src/service/testing/libgnunettesting.la \
- $(GN_LIBINTL)
-
-
gnunet_setu_ibf_profiler_SOURCES = \
gnunet-setu-ibf-profiler.c \
ibf.c
diff --git a/src/service/setu/gnunet-setu-profiler.c b/src/service/setu/gnunet-setu-profiler.c
deleted file mode 100644
index 8d6a2dc8c..000000000
--- a/src/service/setu/gnunet-setu-profiler.c
+++ /dev/null
@@ -1,499 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file setu/gnunet-setu-profiler.c
- * @brief profiling tool for set
- * @author Florian Dold
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_statistics_service.h"
-#include "gnunet_setu_service.h"
-#include "gnunet_testbed_service.h"
-
-
-static int ret;
-
-static unsigned int num_a = 5;
-static unsigned int num_b = 5;
-static unsigned int num_c = 20;
-
-static char *op_str = "union";
-
-const static struct GNUNET_CONFIGURATION_Handle *config;
-
-struct SetInfo
-{
- char *id;
- struct GNUNET_SETU_Handle *set;
- struct GNUNET_SETU_OperationHandle *oh;
- struct GNUNET_CONTAINER_MultiHashMap *sent;
- struct GNUNET_CONTAINER_MultiHashMap *received;
- int done;
-} info1, info2;
-
-static struct GNUNET_CONTAINER_MultiHashMap *common_sent;
-
-static struct GNUNET_HashCode app_id;
-
-static struct GNUNET_PeerIdentity local_peer;
-
-static struct GNUNET_SETU_ListenHandle *set_listener;
-
-static int byzantine;
-static unsigned int force_delta;
-static unsigned int force_full;
-static unsigned int element_size = 32;
-
-/**
- * Handle to the statistics service.
- */
-static struct GNUNET_STATISTICS_Handle *statistics;
-
-/**
- * The profiler will write statistics
- * for all peers to the file with this name.
- */
-static char *statistics_filename;
-
-/**
- * The profiler will write statistics
- * for all peers to this file.
- */
-static FILE *statistics_file;
-
-
-static int
-map_remove_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_CONTAINER_MultiHashMap *m = cls;
- int ret;
-
- GNUNET_assert (NULL != key);
-
- ret = GNUNET_CONTAINER_multihashmap_remove_all (m, key);
- if (GNUNET_OK != ret)
- printf ("spurious element\n");
- return GNUNET_YES;
-}
-
-
-/**
- * Callback function to process statistic values.
- *
- * @param cls closure
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- * @param value the current value
- * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
- * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
- */
-static int
-statistics_result (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- if (NULL != statistics_file)
- {
- fprintf (statistics_file, "%s\t%s\t%lu\n", subsystem, name, (unsigned
- long) value);
- }
- return GNUNET_OK;
-}
-
-
-static void
-statistics_done (void *cls,
- int success)
-{
- GNUNET_assert (GNUNET_YES == success);
- if (NULL != statistics_file)
- fclose (statistics_file);
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-check_all_done (void)
-{
- if ((info1.done == GNUNET_NO) || (info2.done == GNUNET_NO))
- return;
-
- GNUNET_CONTAINER_multihashmap_iterate (info1.received, map_remove_iterator,
- info2.sent);
- GNUNET_CONTAINER_multihashmap_iterate (info2.received, map_remove_iterator,
- info1.sent);
-
- printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info1.sent));
- printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
- info2.sent));
-
- if (NULL == statistics_filename)
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- statistics_file = fopen (statistics_filename, "w");
- GNUNET_STATISTICS_get (statistics, NULL, NULL,
- &statistics_done,
- &statistics_result, NULL);
-}
-
-
-static void
-set_result_cb (void *cls,
- const struct GNUNET_SETU_Element *element,
- uint64_t current_size,
- enum GNUNET_SETU_Status status)
-{
- struct SetInfo *info = cls;
-
- GNUNET_assert (GNUNET_NO == info->done);
- switch (status)
- {
- case GNUNET_SETU_STATUS_DONE:
- info->done = GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s done\n", info->id);
- check_all_done ();
- info->oh = NULL;
- return;
-
- case GNUNET_SETU_STATUS_FAILURE:
- info->oh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failure\n");
- GNUNET_SCHEDULER_shutdown ();
- return;
-
- case GNUNET_SETU_STATUS_ADD_LOCAL:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: local element\n", info->id);
- break;
- default:
- GNUNET_assert (0);
- }
-
- if (element->size != element_size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "wrong element size: %u, expected %u\n",
- element->size,
- (unsigned int) sizeof(struct GNUNET_HashCode));
- GNUNET_assert (0);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n",
- info->id, GNUNET_h2s (element->data));
- GNUNET_assert (NULL != element->data);
- struct GNUNET_HashCode data_hash;
- GNUNET_CRYPTO_hash (element->data, element_size, &data_hash);
- GNUNET_CONTAINER_multihashmap_put (info->received,
- &data_hash, NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
-}
-
-
-static void
-set_listen_cb (void *cls,
- const struct GNUNET_PeerIdentity *other_peer,
- const struct GNUNET_MessageHeader *context_msg,
- struct GNUNET_SETU_Request *request)
-{
- /* max. 2 options plus terminator */
- struct GNUNET_SETU_Option opts[3] = { { 0 } };
- unsigned int n_opts = 0;
-
- if (NULL == request)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "listener failed\n");
- return;
- }
- GNUNET_assert (NULL == info2.oh);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "set listen cb called\n");
- if (byzantine)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_BYZANTINE };
- }
- GNUNET_assert (! (force_full && force_delta));
- if (force_full)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_FORCE_FULL };
- }
- if (force_delta)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_FORCE_DELTA };
- }
-
- opts[n_opts].type = 0;
- info2.oh = GNUNET_SETU_accept (request,
- opts,
- set_result_cb, &info2);
- GNUNET_SETU_commit (info2.oh, info2.set);
-}
-
-
-static int
-set_insert_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_SETU_Handle *set = cls;
- struct GNUNET_SETU_Element el;
-
- el.element_type = 0;
- el.data = value;
- el.size = element_size;
- GNUNET_SETU_add_element (set, &el, NULL, NULL);
- return GNUNET_YES;
-}
-
-
-static void
-handle_shutdown (void *cls)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Shutting down set profiler\n");
- if (NULL != set_listener)
- {
- GNUNET_SETU_listen_cancel (set_listener);
- set_listener = NULL;
- }
- if (NULL != info1.oh)
- {
- GNUNET_SETU_operation_cancel (info1.oh);
- info1.oh = NULL;
- }
- if (NULL != info2.oh)
- {
- GNUNET_SETU_operation_cancel (info2.oh);
- info2.oh = NULL;
- }
- if (NULL != info1.set)
- {
- GNUNET_SETU_destroy (info1.set);
- info1.set = NULL;
- }
- if (NULL != info2.set)
- {
- GNUNET_SETU_destroy (info2.set);
- info2.set = NULL;
- }
- GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
-}
-
-
-static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- unsigned int i;
- struct GNUNET_HashCode hash;
- /* max. 2 options plus terminator */
- struct GNUNET_SETU_Option opts[3] = { { 0 } };
- unsigned int n_opts = 0;
-
- config = cfg;
-
- GNUNET_assert (element_size > 0);
-
- if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n");
- ret = 0;
- return;
- }
-
- statistics = GNUNET_STATISTICS_create ("set-profiler", cfg);
-
- GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL);
-
- info1.id = "a";
- info2.id = "b";
-
- info1.sent = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.sent = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
- common_sent = GNUNET_CONTAINER_multihashmap_create (num_c + 1, GNUNET_NO);
-
- info1.received = GNUNET_CONTAINER_multihashmap_create (num_a + 1, GNUNET_NO);
- info2.received = GNUNET_CONTAINER_multihashmap_create (num_b + 1, GNUNET_NO);
-
- for (i = 0; i < num_a; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_b; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- for (i = 0; i < num_c; i++)
- {
- char *data = GNUNET_malloc (element_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size);
- GNUNET_CRYPTO_hash (data, element_size, &hash);
- GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, data,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
- }
-
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &app_id);
-
- /* FIXME: also implement intersection etc. */
- info1.set = GNUNET_SETU_create (config);
- info2.set = GNUNET_SETU_create (config);
-
- GNUNET_CONTAINER_multihashmap_iterate (info1.sent, set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (info2.sent, set_insert_iterator,
- info2.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent, set_insert_iterator,
- info1.set);
- GNUNET_CONTAINER_multihashmap_iterate (common_sent, set_insert_iterator,
- info2.set);
-
- set_listener = GNUNET_SETU_listen (config,
- &app_id,
- &set_listen_cb,
- NULL);
-
-
- if (byzantine)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_BYZANTINE };
- }
- GNUNET_assert (! (force_full && force_delta));
- if (force_full)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_FORCE_FULL };
- }
- if (force_delta)
- {
- opts[n_opts++] = (struct GNUNET_SETU_Option) { .type =
- GNUNET_SETU_OPTION_FORCE_DELTA };
- }
-
- opts[n_opts].type = 0;
-
- info1.oh = GNUNET_SETU_prepare (&local_peer, &app_id, NULL,
- opts,
- set_result_cb, &info1);
- GNUNET_SETU_commit (info1.oh, info1.set);
- GNUNET_SETU_destroy (info1.set);
- info1.set = NULL;
-}
-
-
-static void
-pre_run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- if (0 != GNUNET_TESTING_peer_run ("set-profiler",
- cfgfile,
- &run, NULL))
- ret = 2;
-}
-
-
-int
-main (int argc, char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint ('A',
- "num-first",
- NULL,
- gettext_noop ("number of values"),
- &num_a),
-
- GNUNET_GETOPT_option_uint ('B',
- "num-second",
- NULL,
- gettext_noop ("number of values"),
- &num_b),
-
- GNUNET_GETOPT_option_flag ('b',
- "byzantine",
- gettext_noop ("use byzantine mode"),
- &byzantine),
-
- GNUNET_GETOPT_option_uint ('f',
- "force-full",
- NULL,
- gettext_noop ("force sending full set"),
- &force_full),
-
- GNUNET_GETOPT_option_uint ('d',
- "force-delta",
- NULL,
- gettext_noop ("number delta operation"),
- &force_delta),
-
- GNUNET_GETOPT_option_uint ('C',
- "num-common",
- NULL,
- gettext_noop ("number of values"),
- &num_c),
-
- GNUNET_GETOPT_option_string ('x',
- "operation",
- NULL,
- gettext_noop ("operation to execute"),
- &op_str),
-
- GNUNET_GETOPT_option_uint ('w',
- "element-size",
- NULL,
- gettext_noop ("element size"),
- &element_size),
-
- GNUNET_GETOPT_option_filename ('s',
- "statistics",
- "FILENAME",
- gettext_noop ("write statistics to file"),
- &statistics_filename),
-
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler",
- "help",
- options, &pre_run, NULL, GNUNET_YES);
- return ret;
-}