aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.buildbot/install.sh2
-rw-r--r--ChangeLog156
-rw-r--r--configure.ac12
-rw-r--r--doc/handbook/chapters/developer.texi215
-rw-r--r--doc/handbook/chapters/keyconcepts.texi25
-rw-r--r--doc/handbook/chapters/user.texi161
-rw-r--r--doc/handbook/images/messenger_room.pngbin0 -> 76244 bytes
-rw-r--r--doc/handbook/images/messenger_room.svg501
-rw-r--r--po/POTFILES.in25
-rw-r--r--src/Makefile.am6
-rw-r--r--src/arm/arm_api.c8
-rw-r--r--src/cadet/gnunet-service-cadet.c3
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c1
-rw-r--r--src/gns/Makefile.am3
-rw-r--r--src/gns/gnunet-bcd.c22
-rw-r--r--src/gns/gnunet-dns2gns.c8
-rw-r--r--src/gns/gnunet-gns-proxy.c23
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c1
-rw-r--r--src/gns/gnunet-service-gns_resolver.c27
-rw-r--r--src/gns/plugin_rest_gns.c4
-rw-r--r--src/gnsrecord/gnsrecord_misc.c17
-rw-r--r--src/gnsrecord/gnunet-gnsrecord-tvg.c2
-rw-r--r--src/include/gnunet_testbed_ng_service.h247
-rw-r--r--src/include/gnunet_testbed_service.h2
-rw-r--r--src/messenger/Makefile.am39
-rwxr-xr-x[-rw-r--r--]src/messenger/gnunet-messenger.c14
-rwxr-xr-x[-rw-r--r--]src/messenger/gnunet-service-messenger.c4
-rwxr-xr-x[-rw-r--r--]src/messenger/gnunet-service-messenger_member.c10
-rwxr-xr-x[-rw-r--r--]src/messenger/gnunet-service-messenger_message_store.c10
-rwxr-xr-x[-rw-r--r--]src/messenger/gnunet-service-messenger_operation_store.c4
-rwxr-xr-x[-rw-r--r--]src/messenger/messenger_api_contact_store.c9
-rwxr-xr-x[-rw-r--r--]src/messenger/messenger_api_message.c2
-rwxr-xr-x[-rw-r--r--]src/messenger/messenger_api_room.c16
-rwxr-xr-x[-rw-r--r--]src/messenger/messenger_api_room.h6
-rw-r--r--src/namestore/gnunet-service-namestore.c16
-rw-r--r--src/namestore/namestore_api.c6
-rw-r--r--src/namestore/plugin_rest_namestore.c2
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c4
-rw-r--r--src/peerstore/peerstore_api.c5
-rw-r--r--src/peerstore/test_peerstore_api_sync.c87
-rw-r--r--src/reclaim/gnunet-service-reclaim.c5
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c15
-rw-r--r--src/reclaim/oidc_helper.c14
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c50
-rw-r--r--src/reclaim/plugin_rest_reclaim.c131
-rw-r--r--src/reclaim/reclaim_api.c20
-rw-r--r--src/rest/plugin_rest_copying.c6
-rw-r--r--src/revocation/gnunet-revocation.c14
-rw-r--r--src/revocation/gnunet-service-revocation.c12
-rw-r--r--src/revocation/plugin_block_revocation.c9
-rw-r--r--src/revocation/revocation_api.c9
-rw-r--r--src/rps/gnunet-rps-profiler.c7
-rw-r--r--src/rps/gnunet-service-rps.c18
-rw-r--r--src/rps/gnunet-service-rps_custommap.c9
-rw-r--r--src/rps/rps-test_util.c16
-rw-r--r--src/testbed/Makefile.am3
-rw-r--r--src/testbed/testbed_api_cmd_controller.c294
-rw-r--r--src/testbed/testbed_api_cmd_peer.c249
-rw-r--r--src/testbed/testbed_api_cmd_service.c140
-rw-r--r--src/testing/testing_api_cmd_hello_world_birth.c6
-rw-r--r--src/transport/gnunet-communicator-tcp.c48
-rw-r--r--src/transport/gnunet-communicator-udp.c13
-rw-r--r--src/transport/gnunet-service-tng.c7
-rw-r--r--src/transport/transport-testing-communicator.c5
-rw-r--r--src/util/Makefile.am18
-rw-r--r--src/util/configuration.c1
-rw-r--r--src/util/container_meta_data.c7
-rw-r--r--src/util/crypto_rsa.c1
-rw-r--r--src/util/gnunet-crypto-tvg.c124
-rw-r--r--src/util/os_installation.c5
70 files changed, 2621 insertions, 340 deletions
diff --git a/.buildbot/install.sh b/.buildbot/install.sh
index b22f3aae0..8ddd77ec0 100755
--- a/.buildbot/install.sh
+++ b/.buildbot/install.sh
@@ -1,3 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2 2
3cd doc/tutorial; make tutorial.html &> /dev/null; cd -
4cd doc/doxygen; make full &> /dev/null; cd -
3make install 5make install
diff --git a/ChangeLog b/ChangeLog
index 2faef1c9e..9c05a51a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,159 @@
1Thu, 18 Mar 2021 18:44:46 +0100 (7d85c27e9)
2Fixed setu tests and state maschine - Elias Summermatter
3
4Thu, 18 Mar 2021 17:55:24 +0100 (8cd1e1929)
5Fixed some bug in the statemaschin implementation of setu - Elias Summermatter
6
7Thu, 18 Mar 2021 16:07:40 +0100 (c4ccd7550)
8Setu tests use gnunet internal functions to generate randum elements - Elias Summermatter
9
10Thu, 18 Mar 2021 11:48:42 +0100 (f9ae0c23c)
11Added working test with randum set - Elias Summermatter
12
13Thu, 18 Mar 2021 08:45:31 +0100 (0d6237ae0)
14Added some randum elemet generation test for setu - Elias Summermatter
15
16Sun, 14 Mar 2021 14:04:00 +0100 (b47586e76)
17add packaging notice; fix #5633 - Martin Schanzenbach
18
19Tue, 9 Mar 2021 18:26:28 +0100 (0b2c0f22f)
20IDENTITY: Fix wrong key construction for anonymous ECDSA identity - Martin Schanzenbach
21
22Tue, 2 Mar 2021 17:16:18 +0100 (45ceb4fdf)
23add base32 encoder/decoder - Christian Grothoff
24
25Sun, 28 Feb 2021 13:51:25 +0100 (4cffc642c)
26build: do not redefine AM_MAKEINFOHTMLFLAGS - Martin Schanzenbach
27
28Sun, 28 Feb 2021 11:15:55 +0100 (eb8ca760c)
29GANA: Use GANA generated header for GNS record types. Update handbook - Martin Schanzenbach
30
31Tue, 23 Feb 2021 14:29:47 +0100 (d528f6cfb)
32HELLO: Fix netdb.h nonsense with h_addr - Martin Schanzenbach
33
34Tue, 23 Feb 2021 10:42:57 +0100 (74a234f0b)
35HANDBOOK: Add some info on TNG - Martin Schanzenbach
36
37Sun, 21 Feb 2021 20:56:47 +0100 (05040a491)
38HELLO: Add test for NG API; fix extraction more - Martin Schanzenbach
39
40Sun, 21 Feb 2021 16:44:51 +0100 (783a12b3c)
41HELLO-TNG: Fix parsing; sill broken - Martin Schanzenbach
42
43Sun, 21 Feb 2021 11:46:16 +0100 (f5439c229)
44TNG: Add queue update handling - Martin Schanzenbach
45
46Sun, 21 Feb 2021 10:53:34 +0100 (a3971a93c)
47Add struct names for FS events. #6743 - Martin Schanzenbach
48
49Thu, 18 Feb 2021 16:51:47 +0100 (8095b1a1b)
50SetU move check to union - Elias Summermatter
51
52Wed, 17 Feb 2021 18:00:43 +0100 (08adc88b4)
53Setu integrated new phase full receiving as described in rfc draft - Elias Summermatter
54
55Wed, 17 Feb 2021 17:32:23 +0100 (d5bf65f2b)
56Renamed Phase Expect IBF Cont -> Expect IBF Last - Elias Summermatter
57
58Wed, 17 Feb 2021 17:26:35 +0100 (d852cb5a6)
59Renamed Phase Done -> Finished - Elias Summermatter
60
61Wed, 17 Feb 2021 17:04:15 +0100 (be8897e14)
62Renamed Phase inventory passive -> passive decoding - Elias Summermatter
63
64Wed, 17 Feb 2021 15:57:46 +0100 (333459251)
65Renamed Phase inventory active -> active decoding & Added idea folder to git ignore - Elias Summermatter
66
67Sat, 30 Jan 2021 16:36:14 -0500 (5b152adc0)
68use AS_VERSION_COMPARE instead of AX_COMPARE_VERSION - Thien-Thi Nguyen
69
70Sat, 30 Jan 2021 08:37:12 -0500 (de1b87ea3)
71fix #6722: use AX_COMPARE_VERSION - Thien-Thi Nguyen
72
73Sat, 30 Jan 2021 12:41:15 +0100 (a5f200d53)
74fix #6690 - Christian Grothoff
75
76Thu, 28 Jan 2021 22:28:01 +0100 (a2169368b)
77implement #6716 - Christian Grothoff
78
79Thu, 7 Jan 2021 22:22:48 +0100 (4769344a7)
80convert to GMT, not localtime in GNUNET_TIME_year_to_time - Christian Grothoff
81
82Thu, 7 Jan 2021 10:26:54 +0100 (5b10ad755)
83properly document return value of GNUNET_PROGRAM_run - Christian Grothoff
84
85Sat, 2 Jan 2021 13:47:16 +0100 (eab08cec9)
86do not output synthetic paths - Christian Grothoff
87
88Sat, 2 Jan 2021 11:24:26 +0100 (0d4337da2)
89fix /proc/PID/maps parser format string - Christian Grothoff
90
91Thu, 31 Dec 2020 09:12:43 +0100 (ebd853c83)
92do not use atomic write for configuration file, we may not have permissions to do this, also should not be necessary - Christian Grothoff
93
94Wed, 30 Dec 2020 20:58:55 +0900 (c0465ff92)
95RECLAIM: Fix quirky OIDC address handling - Martin Schanzenbach
96
97Sat, 26 Dec 2020 14:15:58 +0900 (75a3a90fb)
98RECLAIM: automatically purge dangling references - Martin Schanzenbach
99
100Sat, 19 Dec 2020 18:43:38 +0100 (3636ea628)
101change GNUNET_DISK_fn_write() to always do atomic writes and to NOT overwrite existing files; also change the return value to not return the size of the written file but GNUNET_OK on success, and integrate creating the directory if needed; breaks API, hence bumping libgnunetutil version - Christian Grothoff
102
103Tue, 15 Dec 2020 04:54:32 -0500 (407765df1)
104include Configuration Handbook in gnunet.info - Thien-Thi Nguyen
105
106Tue, 15 Dec 2020 03:43:27 -0500 (db9d81947)
107add pxref to ‘Config file format’ - Thien-Thi Nguyen
108
109Tue, 15 Dec 2020 03:26:26 -0500 (52986bf33)
110[doc] Add section "Config file format" - Thien-Thi Nguyen
111
112Wed, 9 Dec 2020 23:00:07 +0100 (7d9592f20)
113add GNUNET_CRYPTO_hash_context_copy() function - Christian Grothoff
114
115Tue, 8 Dec 2020 16:50:27 +0900 (7ce054864)
116RECLAIM: Return userinfo claims from cache - Martin Schanzenbach
117
118Fri, 4 Dec 2020 17:36:35 +0100 (1346641a1)
119gnunet-crypto-tvg: fix bogus label - Florian Dold
120
121Fri, 4 Dec 2020 17:22:38 +0100 (4c10ff3b4)
122gnunet-crypto-tvg: add verification mode - Florian Dold
123
124Fri, 4 Dec 2020 14:52:45 +0100 (1a3070b15)
125gnunet-crypto-tvg: output JSON, fix memleaks - Florian Dold
126
127Sat, 21 Nov 2020 22:58:44 +0000 (d2e10ef67)
128rps: fix another 'format not a string literal' warning - Daniel Golle
129
130Mon, 16 Nov 2020 23:57:08 +0100 (91e8c2ff2)
131rps: deal with currently unused code - Julius Bünger
132
133Mon, 16 Nov 2020 23:36:12 +0100 (d30ec0f1f)
134rps: comment ill-defined code - Julius Bünger
135
136Mon, 16 Nov 2020 22:59:12 +0100 (0950b1df7)
137rps: properly initialise memory - Julius Bünger
138
139Mon, 16 Nov 2020 22:56:47 +0100 (266823196)
140rps: use proper signedness - Julius Bünger
141
142Mon, 16 Nov 2020 22:56:27 +0100 (89ea76819)
143rps: use correct buffer sizes - Julius Bünger
144
145Mon, 16 Nov 2020 22:55:49 +0100 (607211bb7)
146rps: use correct types in format strings - Julius Bünger
147
148Mon, 16 Nov 2020 22:53:30 +0100 (0108f132a)
149rps: get rid of warnings about harmless uninitialized variables - Julius Bünger
150
151Mon, 16 Nov 2020 04:54:21 +0100 (41000a00c)
152rps: fix sources for multiple warnings - Julius Bünger
153
154Sat, 14 Nov 2020 19:02:01 +0000 (ea18ebde8)
155rps: fix format not a string literal and no format arguments - Daniel Golle
156
1Sat, 14 Nov 2020 10:57:31 +0900 (de83cfe23) 157Sat, 14 Nov 2020 10:57:31 +0900 (de83cfe23)
2Updating ChangeLog for 0.14.0 - Martin Schanzenbach 158Updating ChangeLog for 0.14.0 - Martin Schanzenbach
3 159
diff --git a/configure.ac b/configure.ac
index 28c616069..f72039d09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,8 +416,16 @@ gcrypt=0
416NEED_LIBGCRYPT_API=1 416NEED_LIBGCRYPT_API=1
417NEED_LIBGCRYPT_VERSION=1.6.0 417NEED_LIBGCRYPT_VERSION=1.6.0
418 418
419 419# Check if we have libgcrypt >= 1.9. Some things do not work with it
420AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION", gcrypt=1) 420gcrypt19=0
421AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:1.9.0",
422 [AC_MSG_WARN(["Some subsystems do not work with gcrypt >=1.9.0"])
423 gcrypt=1
424 gcrypt19=1],
425 [AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION", gcrypt=1)]
426)
427AM_CONDITIONAL(HAVE_NOLIBGCRYPT19,
428 [test "$gcrypt19" = 0])
421AC_CHECK_DECLS([gcry_mpi_set_opaque_copy], [], [], [[#include <gcrypt.h>]]) 429AC_CHECK_DECLS([gcry_mpi_set_opaque_copy], [], [], [[#include <gcrypt.h>]])
422 430
423AS_IF([test $gcrypt = 0], 431AS_IF([test $gcrypt = 0],
diff --git a/doc/handbook/chapters/developer.texi b/doc/handbook/chapters/developer.texi
index 8bc8c8005..8b0085cce 100644
--- a/doc/handbook/chapters/developer.texi
+++ b/doc/handbook/chapters/developer.texi
@@ -83,6 +83,7 @@ new chapters, sections or insightful comments.
83* REST Subsystem:: 83* REST Subsystem::
84* RPS Subsystem:: 84* RPS Subsystem::
85* TRANSPORT-NG Subsystem:: 85* TRANSPORT-NG Subsystem::
86* MESSENGER Subsystem::
86@end menu 87@end menu
87 88
88@node Developer Introduction 89@node Developer Introduction
@@ -9705,3 +9706,217 @@ other peers. The semantics of the backchannel message are up to the
9705communicators which use them. 9706communicators which use them.
9706TRANSPORT may fail transmitting backchannel messages, and TRANSPORT will not 9707TRANSPORT may fail transmitting backchannel messages, and TRANSPORT will not
9707attempt to retransmit them. 9708attempt to retransmit them.
9709
9710@cindex MESSENGER Subsystem
9711@cindex MESSENGER
9712@cindex messenger
9713@node MESSENGER Subsystem
9714@section MESSENGER Subsystem
9715
9716The MESSENGER subsystem is responsible for secure end-to-end communication in
9717groups of nodes in the GNUnet overlay network. MESSENGER builds on the CADET
9718subsystem which provides a reliable and secure end-to-end communication between
9719the nodes inside of these groups.
9720
9721Additionally to the CADET security benefits, MESSENGER provides following
9722properties designed for application level usage:
9723
9724@itemize @bullet
9725@item MESSENGER provides integrity by signing the messages with the users
9726 provided ego
9727@item MESSENGER adds (optional) forward secrecy by replacing the key pair of the
9728 used ego and signing the propagation of the new one with old one (chaining
9729 egos)
9730@item MESSENGER provides verification of a original sender by checking against
9731 all used egos from a member which are currently in active use (active use
9732 depends on the state of a member session)
9733@item MESSENGER offsers (optional) decentralized message forwarding between all
9734 nodes in a group to improve availability and prevent MITM-attacks
9735@item MESSENGER handles new connections and disconnections from nodes in the
9736 group by reconnecting them preserving an efficient structure for message
9737 distribution (ensuring availability and accountablity)
9738@item MESSENGER provides replay protection (messages can be uniquely identified
9739 via SHA-512, include a timestamp and the hash of the last message)
9740@item MESSENGER allows detection for dropped messages by chaining them (messages
9741 refer to the last message by their hash) improving accountability
9742@item MESSENGER allows requesting messages from other peers explicitly to ensure
9743 availibility
9744@item MESSENGER provides confidentiality by padding messages to few different
9745 sizes (512 bytes, 4096 bytes, 32768 bytes and maximal message size from
9746 CADET)
9747@item MESSENGER adds (optional) confidentiality with ECDHE to exchange and use
9748 symmetric encryption, encrypting with both AES-256 and Twofish but
9749 allowing only selected members to decrypt (using the receivers ego for
9750 ECDHE)
9751@end itemize
9752
9753Also MESSENGER provides multiple features with privacy in mind:
9754
9755@itemize @bullet
9756@item MESSENGER allows deleting messages from all peers in the group by the
9757 original sender (uses the MESSENGER provided verification)
9758@item MESSENGER allows using the publically known anonymous ego instead of any
9759 unique identifying ego
9760@item MESSENGER allows your node to decide between acting as host of the used
9761 messaging room (sharing your peer's identity with all nodes in the group)
9762 or acting as guest (sharing your peer's identity only with the nodes you
9763 explicitly open a connection to)
9764@item MESSENGER handles members independantly of the peer's identity making
9765 forwarded messages indistinguishable from directly received ones (
9766 complicating the tracking of messages and identifying its origin)
9767@item MESSENGER allows names of members being not unique (also names are
9768 optional)
9769@item MESSENGER does not include information about the selected receiver of an
9770 explicitly encrypted message in its header, complicating it for other
9771 members to draw conclusions from communication partners
9772@end itemize
9773
9774@menu
9775* libgnunetmessenger::
9776* Member sessions::
9777@end menu
9778
9779@node libgnunetmessenger
9780@subsection libgnunetmessenger
9781
9782The MESSENGER API (defined in @file{gnunet_messenger_service.h}) allows P2P
9783applications built using GNUnet to communicate with specified kinds of messages
9784in a group. It provides applications the ability to send and receive encrypted
9785messages to any group of peers participating in GNUnet in a decentralized way (
9786without even knowing all peers's identities).
9787
9788MESSENGER delivers messages to other peers in "rooms". A room uses a variable
9789amount of CADET "channels" which will all be used for message distribution. Each
9790channel can represent an outgoing connection opened by entering a room with
9791@code{GNUNET_MESSENGER_enter_room} or an incoming connection if the room was
9792opened before via @code{GNUNET_MESSENGER_open_room}.
9793
9794@image{images/messenger_room,6in,,Room structure}
9795
9796To enter a room you have to specify the "door" (peer's identity of a peer which
9797has opened the room) and the key of the room (which is identical to a CADET
9798"port"). To open a room you have to specify only the key to use. When opening a
9799room you automatically distribute a PEER-message sharing your peer's identity in
9800the room.
9801
9802Entering or opening a room can also be combined in any order. In any case you
9803will automatically get a unique member ID and send a JOIN-message notifying
9804others about your entry and your public key from your selected ego.
9805
9806The ego can be selected by name with the initial @code{GNUNET_MESSENGER_connect}
9807besides setting a (identity-)callback for each change/confirmation of the used
9808ego and a (message-)callback which gets called every time a message gets sent or
9809received in the room. Once the identity-callback got called you can check your
9810used ego with @code{GNUNET_MESSENGER_get_key} providing only its public key. The
9811function returns NULL if the anonymous ego is used. If the ego should be
9812replaced with a newly generated one, you can use @code{GNUNET_MESSENGER_update}
9813to ensure proper chaining of used egos.
9814
9815Also once the identity-callback got called you can check your used name with
9816@code{GNUNET_MESSENGER_get_name} and potentially change or set a name via
9817@code{GNUNET_MESSENGER_set_name}. A name is for example required to create a new
9818ego with @code{GNUNET_MESSENGER_update}. Also any change in ego or name will
9819automatically be distributed in the room with a NAME- or KEY-message
9820respectively.
9821
9822To send a message a message inside of a room you can use
9823@code{GNUNET_MESSENGER_send_message}. If you specify a selected contact as
9824receiver, the message gets encrypted automatically and will be sent as PRIVATE-
9825message instead.
9826
9827To request a potentially missed message or to get a specific message after its
9828original call of the message-callback, you can use
9829@code{GNUNET_MESSENGER_get_message}. Additionally once a message was distributed
9830to application level and the message-callback got called, you can get the
9831contact respresenting a message's sender respectively with
9832@code{GNUNET_MESSENGER_get_sender}. This allows getting name and the public key
9833of any sender currently in use with @code{GNUNET_MESSENGER_contact_get_name}
9834and @code{GNUNET_MESSENGER_contact_get_key}. It is also possible to iterate
9835through all current members of a room with
9836@code{GNUNET_MESSENGER_iterate_members} using a callback.
9837
9838To leave a room you can use @code{GNUNET_MESSENGER_close_room} which will also
9839close the rooms connections once all applications on the same peer have left
9840the room. Leaving a room will also send a LEAVE-message closing a member session
9841on all connected peers before any connection will be closed. Leaving a room is
9842however not required for any application to keep your member session open
9843between multiple sessions of the actual application.
9844
9845Finally, when an application no longer wants to use CADET, it should call
9846@code{GNUNET_MESSENGER_disconnect}. You don't have to explicitly close the used
9847rooms or leave them.
9848
9849Here is a little summary to the kinds of messages you can send manually:
9850
9851@menu
9852* MERGE-message::
9853* INVITE-message::
9854* TEXT-message::
9855* FILE-message::
9856* DELETE-message::
9857@end menu
9858
9859@node MERGE-message
9860@subsubsection MERGE-message
9861
9862MERGE-messages will generally be sent automatically to reduce the amount of
9863parallel chained messages. This is necessary to close a member session for
9864example. You can also send MERGE-messages manually if required to merge two
9865chains of messages.
9866
9867@node INVITE-message
9868@subsubsection INVITE-message
9869
9870INVITE-messages can be used to invite other members in a room to a different
9871room, sharing one potential door and the required key to enter the room. This
9872kind of message is typically sent as encrypted PRIVATE-message to selected
9873members because it doesn't make much sense to invite all members from one room
9874to another considering a rooms key doesn't specify its usage.
9875
9876@node TEXT-message
9877@subsubsection TEXT-message
9878
9879TEXT-messages can be used to send simple text-based messages and should be
9880considered as being in readable form without complex decoding. The text has to
9881end with a NULL-terminator character and should be in UTF-8 encoding for most
9882compatibility.
9883
9884@node FILE-message
9885@subsubsection FILE-message
9886
9887FILE-messages can be used to share files inside of a room. They do not contain
9888the actual file being shared but its original hash, filename, URI to download
9889the file and a symmetric key to decrypt the downloaded file.
9890
9891It is recommended to use the FS subsystem and the FILE-messages in combination.
9892
9893@node DELETE-message
9894@subsubsection DELETE-message
9895
9896DELETE-messages can be used to delete messages selected with its hash. You can
9897also select any custom delay relative to the time of sending the DELETE-message.
9898Deletion will only be processed on each peer in a room if the sender is
9899authorized.
9900
9901The only information of a deleted message which being kept will be the chained
9902hashes connecting the message graph for potential traversion. For example the
9903check for completion of a member session requires this information.
9904
9905@node Member sessions
9906@subsection Member sessions
9907
9908A member session is a triple of the room key, the member ID and the public key
9909of the member's ego. Member sessions allow that a member can change their ID or
9910their ego once at a time without loosing the ability to delete old messages or
9911identifying the original sender of a message. On every change of ID or EGO a
9912session will be marked as closed. So every session chain will only contain one
9913open session with the current ID and public key.
9914
9915If a session is marked as closed the MESSENGER service will check from the first
9916message opening a session to its last one closing the session for completion. If
9917a the service can confirm that there is no message still missing which was sent
9918from the closed member session, it will be marked as completed.
9919
9920A completed member session is not able to verify any incoming message to ensure
9921forward secrecy preventing others from using old stolen egos.
9922
diff --git a/doc/handbook/chapters/keyconcepts.texi b/doc/handbook/chapters/keyconcepts.texi
index eb95dbf78..f429997bf 100644
--- a/doc/handbook/chapters/keyconcepts.texi
+++ b/doc/handbook/chapters/keyconcepts.texi
@@ -152,6 +152,7 @@ and @pxref{Deniability}.
152 152
153@menu 153@menu
154* How file-sharing achieves Anonymity:: 154* How file-sharing achieves Anonymity::
155* How messaging provides Anonymity::
155@end menu 156@end menu
156 157
157Providing anonymity for users is the central goal for the anonymous 158Providing anonymity for users is the central goal for the anonymous
@@ -231,6 +232,30 @@ GAP --- practical anonymous networking. In Proceedings of
231Designing Privacy Enhancing Technologies, 2003. 232Designing Privacy Enhancing Technologies, 2003.
232(@uref{https://git.gnunet.org/bibliography.git/plain/docs/aff.pdf, https://git.gnunet.org/bibliography.git/plain/docs/aff.pdf}) 233(@uref{https://git.gnunet.org/bibliography.git/plain/docs/aff.pdf, https://git.gnunet.org/bibliography.git/plain/docs/aff.pdf})
233 234
235@cindex How messaging provides Anonymity
236@node How messaging provides Anonymity
237@subsection How messaging provides Anonymity
238
239While the file-sharing tries to achieve anonymity through hiding actions in
240other traffic, the messaging service provides a weaker form of protection
241against identification.
242
243The messaging service allows the use of an anonymous ego for the signing and
244verification process of messages instead of a unique ego. This anonymous ego is
245a publically known key pair which is shared between all peers in GNUnet.
246
247Using this ego only ensures that individual messages alone can't identify its
248sender inside of a messenger room. It should be clarified that the route of
249the traffic for each message can still be tracked to identify the senders peer
250inside of a messenger room if the threat agent controls certain peers hosting
251the room.
252
253Also opening a room in the messenger service will potentially match your peer
254identity with the internal member identity from the messenger service. So
255despite using the anonymous ego you can reveal your peer identity. This means
256to decrease the chance of being identified, it is recommended to enter rooms but
257you should not open them for others.
258
234@cindex Deniability 259@cindex Deniability
235@node Deniability 260@node Deniability
236@section Deniability 261@section Deniability
diff --git a/doc/handbook/chapters/user.texi b/doc/handbook/chapters/user.texi
index 5d5d2fe14..b5889891b 100644
--- a/doc/handbook/chapters/user.texi
+++ b/doc/handbook/chapters/user.texi
@@ -28,6 +28,7 @@ always welcome.
28* The GNU Name System:: 28* The GNU Name System::
29* reclaimID Identity Provider:: 29* reclaimID Identity Provider::
30* Using the Virtual Public Network:: 30* Using the Virtual Public Network::
31* Using the GNUnet Messenger::
31@end menu 32@end menu
32 33
33@node Start and stop GNUnet 34@node Start and stop GNUnet
@@ -253,7 +254,6 @@ and development.
253@subsection Creating a Business Card 254@subsection Creating a Business Card
254@c FIXME: Which parts of texlive are needed? Some systems offer a modular 255@c FIXME: Which parts of texlive are needed? Some systems offer a modular
255@c texlive (smaller size). 256@c texlive (smaller size).
256
257Before we can really use GNS, you should create a business card. 257Before we can really use GNS, you should create a business card.
258Note that this requires having @command{LaTeX} installed on your system. 258Note that this requires having @command{LaTeX} installed on your system.
259If you are using a Debian GNU/Linux based operating system, the 259If you are using a Debian GNU/Linux based operating system, the
@@ -261,6 +261,19 @@ following command should install the required components.
261Keep in mind that this @b{requires 3GB} of downloaded data and possibly 261Keep in mind that this @b{requires 3GB} of downloaded data and possibly
262@b{even more} when unpacked. On a GNU Guix based system texlive 2017 has 262@b{even more} when unpacked. On a GNU Guix based system texlive 2017 has
263returns a DAG size of 5032.4 MiB. 263returns a DAG size of 5032.4 MiB.
264The packages which are confirmed to be required are:
265
266@itemize @bullet
267@item texlive-units
268@item texlive-labels
269@item texlive-pst-barcode
270@item texlive-luatex85
271@item texlive-preview
272@item texlive-pdfcrop
273@item texlive-koma-script
274@end itemize
275
276
264@b{We welcome any help in identifying the required components of the 277@b{We welcome any help in identifying the required components of the
265TexLive Distribution. This way we could just state the required components 278TexLive Distribution. This way we could just state the required components
266without pulling in the full distribution of TexLive.} 279without pulling in the full distribution of TexLive.}
@@ -2323,3 +2336,149 @@ service offered by that peer, you can create an IP tunnel to
2323that peer by specifying the peer's identity, service name and 2336that peer by specifying the peer's identity, service name and
2324protocol (--tcp or --udp) and you will again receive an IP address 2337protocol (--tcp or --udp) and you will again receive an IP address
2325that will terminate at the respective peer's service. 2338that will terminate at the respective peer's service.
2339
2340@node Using the GNUnet Messenger
2341@section Using the GNUnet Messenger
2342
2343The GNUnet Messenger subsystem allows decentralized message-based
2344communication inside of so called rooms. Each room can be hosted by
2345a variable amount of peers. Every member of a room has the possibility
2346to host the room on its own peer. A peer allows any amount of members
2347to join a room. The amount of members in a room is not restricted.
2348
2349Messages in a room will be distributed between all peers hosting the
2350room or being internally (in context of the messenger service) connected
2351to a hosting peer. All received or sent messages will be stored on any
2352peer locally which is hosting the respective room or is internally
2353connected to such a hosting peer.
2354
2355The Messenger service is built on the CADET subsystem to make internal
2356connections between peers using a reliable and encrypted transmission.
2357Additionally the service uses a discrete padding to few different sizes.
2358So kinds of messages and potential content can't be identified by the
2359size of traffic from any attacker being unable to break the encryption
2360of the transmission layer.
2361
2362Another feature is additional end-to-end encryption for selected messages
2363which uses the public key of another member (the receiver) to encrypt
2364the message. Therefore it is ensured that only the selected member can
2365read its content. This will also use additional padding.
2366
2367@menu
2368* Current state::
2369* Entering a room::
2370* Opening a room::
2371* Messaging in a room::
2372* Private messaging::
2373@end menu
2374
2375@node Current state
2376@subsection Current state
2377
2378Currently there is only a simplistic CLI application available to use the
2379messenger service. You can use this application with the
2380@command{gnunet-messenger} command.
2381
2382This application was designed for testing purposes and it does not provide
2383full functionality in the current state. It is planned to replace this CLI
2384application in later stages with a fully featured one using a client-side
2385library designed for messenger applications.
2386
2387@node Entering a room
2388@subsection Entering a room
2389
2390You can enter any room by its ROOMKEY and any PEERIDENTITY of a hosting peer.
2391Optionally you can provide any IDENTITY which can represent a local ego by
2392its name.
2393
2394@example
2395$ gnunet-messenger [-e IDENTITY] -d PEERIDENTITY -r ROOMKEY
2396@end example
2397
2398A PEERIDENTITY gets entered in encoded form. You can get your own peer ID by
2399using the @command{gnunet-peerinfo} command:
2400
2401@example
2402$ gnunet-peerinfo -s
2403@end example
2404
2405A ROOMKEY gets entered in readable text form. The service will then hash the
2406entered ROOMKEY and use the result as shared secret for transmission through
2407the CADET submodule. You can also optionally leave out the '-r' paramter and
2408the ROOMKEY to use the zeroed hash instead.
2409
2410If no IDENTITY is provided you will not send any name to others, you will be
2411referred as "anonymous" instead and use the anonymous ego. If you provide any
2412IDENTITY a matching ego will be used to sign your messages. If there is no
2413matching ego you will use the anonymous ego instead. The provided IDENTITY will
2414be distributed as your name for the service in any case.
2415
2416@node Opening a room
2417@subsection Opening a room
2418
2419You can open any room in a similar way to entering it. You just have to leave
2420out the '-d' parameter and the PEERIDENTITY of the hosting peer.
2421
2422@example
2423$ gnunet-messenger [-e IDENTITY] -r ROOMKEY
2424@end example
2425
2426Providing ROOMKEY and IDENTITY is identical to entering a room. Opening a room
2427will also make your peer to a host of this room. So others can enter the room
2428through your peer if they have the required ROOMKEY and your peer ID.
2429
2430If you want to use the zeroed hash as shared secret key for the room you can
2431also leave it out as well:
2432
2433@example
2434$ gnunet-messenger
2435@end example
2436
2437@node Messaging in a room
2438@subsection Messaging in a room
2439
2440Once joined a room by entering it or opening it you can write text-based
2441messages which will be distributed between all internally conntected peers. All
2442sent messages will be displayed in the same way as received messages.
2443
2444This relates to the internal handling of sent and received messages being mostly
2445identical on application layer. Every handled message will be represented
2446visually depending on its kind, content and sender. A sender can usually be
2447identified by the encoded member ID or their name.
2448
2449@example
2450[17X37K] * 'anonymous' says: "hey"
2451@end example
2452
2453@node Private messaging
2454@subsection Private messaging
2455
2456As referred in the introduction the service allows sending private messages with
2457additional end-to-end encryption. These messages will be visually represented
2458by messages of the kind 'PRIVATE' in case they can't be decrypted with your used
2459ego. Members who can't decrypt the message can potentially only identify its
2460sender but they can't identify its receiver.
2461
2462@example
2463[17X37K] ~ message: PRIVATE
2464@end example
2465
2466If they can be decrypted they will appear as their secret message instead
2467but marked visually.
2468
2469@example
2470[17X37K] ** 'anonymous' says: "hey"
2471@end example
2472
2473Currently you can only activate sending such encrypted text messages instead of
2474usual text messages by adding the '-p' parameter:
2475
2476@example
2477$ gnunet-messenger [-e IDENTITY] -d PEERIDENTITY -r ROOMKEY -p
2478@end example
2479
2480Notice that you can only send such encrypted messages to members who use an ego
2481which is not publically known as the anonymous ego to ensure transparency. If
2482any user could decrypt these messages they would not be private. So as receiver
2483of such messages the IDENTITY is required and it has to match a local ego.
2484
diff --git a/doc/handbook/images/messenger_room.png b/doc/handbook/images/messenger_room.png
new file mode 100644
index 000000000..8b3590cf8
--- /dev/null
+++ b/doc/handbook/images/messenger_room.png
Binary files differ
diff --git a/doc/handbook/images/messenger_room.svg b/doc/handbook/images/messenger_room.svg
new file mode 100644
index 000000000..6bd8d425c
--- /dev/null
+++ b/doc/handbook/images/messenger_room.svg
@@ -0,0 +1,501 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg
3 xmlns:dc="http://purl.org/dc/elements/1.1/"
4 xmlns:cc="http://creativecommons.org/ns#"
5 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6 xmlns:svg="http://www.w3.org/2000/svg"
7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 width="598.63586mm"
11 height="519.30621mm"
12 viewBox="0 0 598.63586 519.30621"
13 version="1.1"
14 id="svg8"
15 inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
16 sodipodi:docname="messenger_room.svg"
17 inkscape:export-filename="./messenger_room.png"
18 inkscape:export-xdpi="50"
19 inkscape:export-ydpi="50">
20 <defs
21 id="defs2" />
22 <sodipodi:namedview
23 id="base"
24 pagecolor="#ffffff"
25 bordercolor="#666666"
26 borderopacity="1.0"
27 inkscape:pageopacity="0.0"
28 inkscape:pageshadow="2"
29 inkscape:zoom="0.35"
30 inkscape:cx="1617.1523"
31 inkscape:cy="893.76504"
32 inkscape:document-units="mm"
33 inkscape:current-layer="layer3"
34 inkscape:document-rotation="0"
35 showgrid="false"
36 fit-margin-top="10"
37 fit-margin-bottom="10"
38 fit-margin-right="10"
39 fit-margin-left="10"
40 lock-margins="true"
41 inkscape:window-width="2560"
42 inkscape:window-height="1376"
43 inkscape:window-x="0"
44 inkscape:window-y="0"
45 inkscape:window-maximized="1" />
46 <metadata
47 id="metadata5">
48 <rdf:RDF>
49 <cc:Work
50 rdf:about="">
51 <dc:format>image/svg+xml</dc:format>
52 <dc:type
53 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
54 <dc:title></dc:title>
55 </cc:Work>
56 </rdf:RDF>
57 </metadata>
58 <g
59 inkscape:groupmode="layer"
60 id="layer2"
61 inkscape:label="Layer 2"
62 style="display:inline"
63 transform="translate(192.28493,120.40152)">
64 <path
65 style="fill:none;stroke:#000000;stroke-width:3.365;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
66 d="M 26.206579,156.45999 97.162749,89.570022 199.7759,120.1979 181.87666,217.7128 89.324169,236.23068 Z"
67 id="path915" />
68 <path
69 style="fill:none;stroke:#000000;stroke-width:2.665;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
70 d="m 181.87666,217.7128 66.26913,94.14707"
71 id="path1063" />
72 <path
73 style="fill:none;stroke:#000000;stroke-width:2.665;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:2.665, 5.33;stroke-dashoffset:0;stroke-opacity:1"
74 d="M 309.85632,121.37022 199.7759,120.1979"
75 id="path1065" />
76 <path
77 style="fill:none;stroke:#000000;stroke-width:2.665;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
78 d="M 248.9298,18.638951 199.7759,120.1979"
79 id="path1067" />
80 <path
81 style="fill:none;stroke:#000000;stroke-width:2.665;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
82 d="M -76.608095,107.38658 26.206579,156.45999"
83 id="path1069" />
84 </g>
85 <g
86 inkscape:groupmode="layer"
87 id="layer4"
88 inkscape:label="Layer 4"
89 style="display:inline"
90 transform="translate(192.28493,120.40152)">
91 <path
92 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
93 d="m -137.76937,77.365523 61.161275,30.021057"
94 id="path1225" />
95 <path
96 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
97 d="M -20.546549,199.60834 26.206579,156.45999"
98 id="path1227" />
99 <path
100 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
101 d="M 58.558255,290.12036 89.324168,236.23068 125.2681,294.74464"
102 id="path1229" />
103 <path
104 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
105 d="m 260.56143,374.91842 -12.41564,-63.05855 67.7611,18.91507"
106 id="path1231" />
107 <path
108 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
109 d="M 237.39119,194.89545 181.87666,217.7128"
110 id="path1233" />
111 <path
112 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
113 d="M 199.7759,120.1979 177.22801,54.184954"
114 id="path1235" />
115 <path
116 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
117 d="m 309.85632,121.37022 61.96594,-12.96636"
118 id="path1237" />
119 <path
120 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
121 d="M 248.9298,18.638951 229.25585,-38.546188"
122 id="path1239" />
123 <path
124 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
125 d="m 55.073787,29.185372 42.088961,60.38465"
126 id="path1241" />
127 <path
128 style="fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1.865, 3.73;stroke-dashoffset:0;stroke-opacity:1"
129 d="M -76.608095,107.38658 -138.56518,130.6705"
130 id="path1243" />
131 </g>
132 <g
133 inkscape:label="Layer 1"
134 inkscape:groupmode="layer"
135 id="layer1"
136 transform="translate(192.28493,120.40152)">
137 <circle
138 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
139 id="path833"
140 cx="96.685127"
141 cy="88.539452"
142 r="20" />
143 <circle
144 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
145 id="path833-3"
146 cx="195.51556"
147 cy="120.85936"
148 r="20" />
149 <circle
150 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
151 id="path833-5"
152 cx="183.12799"
153 cy="214.72444"
154 r="20" />
155 <circle
156 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
157 id="path833-6"
158 cx="92.202576"
159 cy="236.97336"
160 r="20" />
161 <circle
162 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
163 id="path833-2"
164 cx="26.400755"
165 cy="158.9449"
166 r="20" />
167 <circle
168 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
169 id="path833-3-1"
170 cx="309.42667"
171 cy="120.44005"
172 r="20" />
173 <circle
174 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
175 id="path833-3-2"
176 cx="248.5799"
177 cy="19.344702"
178 r="20" />
179 <circle
180 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
181 id="path833-3-7"
182 cx="-74.235405"
183 cy="107.76899"
184 r="20" />
185 <circle
186 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
187 id="path833-3-0"
188 cx="249.89246"
189 cy="310.73776"
190 r="20" />
191 <path
192 style="display:inline;fill:none;stroke:#000000;stroke-width:1.865;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
193 d="m 318.33679,228.47452 61.96594,-12.96636"
194 id="path1237-2" />
195 <circle
196 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.265;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:6.265, 12.53;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill"
197 id="path833-3-1-8"
198 cx="317.90714"
199 cy="227.54434"
200 r="20" />
201 <rect
202 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2.82, 5.64;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill"
203 id="rect1071-62-9"
204 width="28.700562"
205 height="22.81683"
206 x="366.24039"
207 y="204.47328" />
208 <text
209 xml:space="preserve"
210 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
211 x="315.72601"
212 y="231.38942"
213 id="text1307-7-3-3-94-3"><tspan
214 sodipodi:role="line"
215 id="tspan1305-6-0-0-6-6"
216 x="315.72601"
217 y="231.38942"
218 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">J</tspan></text>
219 </g>
220 <g
221 inkscape:groupmode="layer"
222 id="layer3"
223 inkscape:label="Layer 3"
224 transform="translate(192.28493,120.40152)">
225 <rect
226 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
227 id="rect1071"
228 width="28.700562"
229 height="22.81683"
230 x="41.152424"
231 y="17.00181" />
232 <rect
233 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
234 id="rect1071-6"
235 width="28.700562"
236 height="22.81683"
237 x="163.24538"
238 y="40.93095" />
239 <rect
240 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
241 id="rect1071-0"
242 width="28.700562"
243 height="22.81683"
244 x="217.0302"
245 y="-48.476658" />
246 <rect
247 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
248 id="rect1071-62"
249 width="28.700562"
250 height="22.81683"
251 x="357.75992"
252 y="97.368996" />
253 <rect
254 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
255 id="rect1071-61"
256 width="28.700562"
257 height="22.81683"
258 x="221.61465"
259 y="183.89601" />
260 <rect
261 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
262 id="rect1071-8"
263 width="28.700562"
264 height="22.81683"
265 x="302.37604"
266 y="319.27646" />
267 <rect
268 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
269 id="rect1071-7"
270 width="28.700562"
271 height="22.81683"
272 x="244.56342"
273 y="364.67789" />
274 <rect
275 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
276 id="rect1071-9"
277 width="28.700562"
278 height="22.81683"
279 x="43.508121"
280 y="279.02939" />
281 <rect
282 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
283 id="rect1071-2"
284 width="28.700562"
285 height="22.81683"
286 x="110.22536"
287 y="283.7334" />
288 <rect
289 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
290 id="rect1071-02"
291 width="28.700562"
292 height="22.81683"
293 x="-35.267426"
294 y="187.65363" />
295 <rect
296 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
297 id="rect1071-3"
298 width="28.700562"
299 height="22.81683"
300 x="-151.39322"
301 y="66.069321" />
302 <rect
303 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.82;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2.82, 5.64;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill"
304 id="rect1071-3-7"
305 width="28.700562"
306 height="22.81683"
307 x="-154.87178"
308 y="119.88663" />
309 <g
310 id="g1600"
311 transform="translate(-2.9470331,-51.038598)">
312 <circle
313 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3.78727;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
314 id="path833-6-5"
315 cx="-161.17276"
316 cy="336.83234"
317 r="12.09027" />
318 <text
319 xml:space="preserve"
320 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
321 x="-140.58682"
322 y="342.66354"
323 id="text1307"><tspan
324 sodipodi:role="line"
325 id="tspan1305"
326 x="-140.58682"
327 y="342.66354"
328 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">Peer</tspan></text>
329 </g>
330 <g
331 id="g1594"
332 transform="translate(-2.9470331,-54.443235)">
333 <rect
334 style="opacity:0.999;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.96946;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke markers fill"
335 id="rect1071-9-9"
336 width="20.044254"
337 height="15.935102"
338 x="-171.19489"
339 y="365.45282" />
340 <text
341 xml:space="preserve"
342 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
343 x="-140.78059"
344 y="379.28705"
345 id="text1307-7"><tspan
346 sodipodi:role="line"
347 id="tspan1305-6"
348 x="-140.78059"
349 y="379.28705"
350 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">Application</tspan></text>
351 </g>
352 <text
353 xml:space="preserve"
354 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
355 x="90.401619"
356 y="94.499252"
357 id="text1307-7-3"><tspan
358 sodipodi:role="line"
359 id="tspan1305-6-0"
360 x="90.401619"
361 y="94.499252"
362 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">A</tspan></text>
363 <text
364 xml:space="preserve"
365 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
366 x="189.63115"
367 y="126.74821"
368 id="text1307-7-3-3"><tspan
369 sodipodi:role="line"
370 id="tspan1305-6-0-0"
371 x="189.63115"
372 y="126.74821"
373 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">C</tspan></text>
374 <text
375 xml:space="preserve"
376 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
377 x="178.83551"
378 y="220.59999"
379 id="text1307-7-3-3-9"><tspan
380 sodipodi:role="line"
381 id="tspan1305-6-0-0-2"
382 x="178.83551"
383 y="220.59999"
384 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">F</tspan></text>
385 <text
386 xml:space="preserve"
387 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
388 x="85.772736"
389 y="242.86221"
390 id="text1307-7-3-3-5"><tspan
391 sodipodi:role="line"
392 id="tspan1305-6-0-0-4"
393 x="85.772736"
394 y="242.86221"
395 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">G</tspan></text>
396 <text
397 xml:space="preserve"
398 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
399 x="19.824577"
400 y="164.8027"
401 id="text1307-7-3-3-0"><tspan
402 sodipodi:role="line"
403 id="tspan1305-6-0-0-5"
404 x="19.824577"
405 y="164.8027"
406 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">H</tspan></text>
407 <text
408 xml:space="preserve"
409 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
410 x="303.32053"
411 y="126.29786"
412 id="text1307-7-3-3-94"><tspan
413 sodipodi:role="line"
414 id="tspan1305-6-0-0-6"
415 x="303.32053"
416 y="126.29786"
417 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">D</tspan></text>
418 <text
419 xml:space="preserve"
420 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
421 x="243.4848"
422 y="25.202511"
423 id="text1307-7-3-3-92"><tspan
424 sodipodi:role="line"
425 id="tspan1305-6-0-0-24"
426 x="243.4848"
427 y="25.202511"
428 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">B</tspan></text>
429 <text
430 xml:space="preserve"
431 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
432 x="247.20479"
433 y="316.59558"
434 id="text1307-7-3-3-7"><tspan
435 sodipodi:role="line"
436 id="tspan1305-6-0-0-7"
437 x="247.20479"
438 y="316.59558"
439 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">I</tspan></text>
440 <text
441 xml:space="preserve"
442 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
443 x="-79.01123"
444 y="113.64454"
445 id="text1307-7-3-3-54"><tspan
446 sodipodi:role="line"
447 id="tspan1305-6-0-0-8"
448 x="-79.01123"
449 y="113.64454"
450 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">E</tspan></text>
451 <g
452 id="g1589"
453 transform="translate(-4.3496791,-53.330521)">
454 <path
455 style="fill:none;stroke:#000000;stroke-width:2.62782;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2.62782, 5.25564;stroke-dashoffset:1.05113;stroke-opacity:1"
456 d="m -176.62134,400.99519 30.89715,0.38084"
457 id="path1521" />
458 <text
459 xml:space="preserve"
460 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
461 x="-137.64647"
462 y="406.95029"
463 id="text1307-7-2"><tspan
464 sodipodi:role="line"
465 id="tspan1305-6-1"
466 x="-137.64647"
467 y="406.95029"
468 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">Inactive</tspan></text>
469 </g>
470 <g
471 id="g1583"
472 transform="translate(-4.3496791,-49.693534)">
473 <path
474 style="fill:none;stroke:#000000;stroke-width:2.62782;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.05113;stroke-opacity:1"
475 d="m -176.62134,420.37019 30.89715,0.38084"
476 id="path1521-0" />
477 <text
478 xml:space="preserve"
479 style="font-size:18.1632px;line-height:34.0561px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.340559"
480 x="-138.78186"
481 y="426.42728"
482 id="text1307-7-0"><tspan
483 sodipodi:role="line"
484 id="tspan1305-6-5"
485 x="-138.78186"
486 y="426.42728"
487 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.1632px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.340559">Active</tspan></text>
488 </g>
489 <text
490 xml:space="preserve"
491 style="font-size:50.8px;line-height:95.25px;font-family:Primer;-inkscape-font-specification:Primer;letter-spacing:0px;word-spacing:0px;stroke-width:0.264583"
492 x="42.997746"
493 y="-77.287262"
494 id="text1604"><tspan
495 sodipodi:role="line"
496 id="tspan1602"
497 x="42.997746"
498 y="-77.287262"
499 style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:50.8px;font-family:'Linux Libertine Capitals';-inkscape-font-specification:'Linux Libertine Capitals';stroke-width:0.264583">Room</tspan></text>
500 </g>
501</svg>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b2fa88d73..b3849abbd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -207,25 +207,33 @@ src/json/json_mhd.c
207src/messenger/gnunet-messenger.c 207src/messenger/gnunet-messenger.c
208src/messenger/gnunet-service-messenger.c 208src/messenger/gnunet-service-messenger.c
209src/messenger/gnunet-service-messenger_basement.c 209src/messenger/gnunet-service-messenger_basement.c
210src/messenger/gnunet-service-messenger_contact.c 210src/messenger/gnunet-service-messenger_ego_store.c
211src/messenger/gnunet-service-messenger_handle.c 211src/messenger/gnunet-service-messenger_handle.c
212src/messenger/gnunet-service-messenger_list_handles.c 212src/messenger/gnunet-service-messenger_list_handles.c
213src/messenger/gnunet-service-messenger_list_messages.c 213src/messenger/gnunet-service-messenger_list_messages.c
214src/messenger/gnunet-service-messenger_member.c
215src/messenger/gnunet-service-messenger_member_session.c
216src/messenger/gnunet-service-messenger_member_store.c
214src/messenger/gnunet-service-messenger_message_handle.c 217src/messenger/gnunet-service-messenger_message_handle.c
215src/messenger/gnunet-service-messenger_message_kind.c 218src/messenger/gnunet-service-messenger_message_kind.c
216src/messenger/gnunet-service-messenger_message_recv.c 219src/messenger/gnunet-service-messenger_message_recv.c
217src/messenger/gnunet-service-messenger_message_send.c 220src/messenger/gnunet-service-messenger_message_send.c
218src/messenger/gnunet-service-messenger_message_store.c 221src/messenger/gnunet-service-messenger_message_store.c
222src/messenger/gnunet-service-messenger_operation.c
223src/messenger/gnunet-service-messenger_operation_store.c
219src/messenger/gnunet-service-messenger_room.c 224src/messenger/gnunet-service-messenger_room.c
220src/messenger/gnunet-service-messenger_service.c 225src/messenger/gnunet-service-messenger_service.c
221src/messenger/gnunet-service-messenger_tunnel.c 226src/messenger/gnunet-service-messenger_tunnel.c
222src/messenger/gnunet-service-messenger_util.c
223src/messenger/messenger_api.c 227src/messenger/messenger_api.c
224src/messenger/messenger_api_contact.c 228src/messenger/messenger_api_contact.c
229src/messenger/messenger_api_contact_store.c
225src/messenger/messenger_api_handle.c 230src/messenger/messenger_api_handle.c
226src/messenger/messenger_api_list_tunnels.c 231src/messenger/messenger_api_list_tunnels.c
227src/messenger/messenger_api_message.c 232src/messenger/messenger_api_message.c
228src/messenger/messenger_api_room.c 233src/messenger/messenger_api_room.c
234src/messenger/messenger_api_util.c
235src/messenger/testing_messenger_barrier.c
236src/messenger/testing_messenger_setup.c
229src/my/my.c 237src/my/my.c
230src/my/my_query_helper.c 238src/my/my_query_helper.c
231src/my/my_result_helper.c 239src/my/my_result_helper.c
@@ -399,6 +407,9 @@ src/testbed/gnunet_mpi_test.c
399src/testbed/gnunet_testbed_mpi_spawn.c 407src/testbed/gnunet_testbed_mpi_spawn.c
400src/testbed/testbed_api.c 408src/testbed/testbed_api.c
401src/testbed/testbed_api_barriers.c 409src/testbed/testbed_api_barriers.c
410src/testbed/testbed_api_cmd_controller.c
411src/testbed/testbed_api_cmd_peer.c
412src/testbed/testbed_api_cmd_service.c
402src/testbed/testbed_api_hosts.c 413src/testbed/testbed_api_hosts.c
403src/testbed/testbed_api_operations.c 414src/testbed/testbed_api_operations.c
404src/testbed/testbed_api_peers.c 415src/testbed/testbed_api_peers.c
@@ -412,6 +423,13 @@ src/testbed/testbed_api_underlay.c
412src/testing/gnunet-testing.c 423src/testing/gnunet-testing.c
413src/testing/list-keys.c 424src/testing/list-keys.c
414src/testing/testing.c 425src/testing/testing.c
426src/testing/testing_api_cmd_batch.c
427src/testing/testing_api_cmd_hello_world.c
428src/testing/testing_api_cmd_hello_world_birth.c
429src/testing/testing_api_loop.c
430src/testing/testing_api_trait_cmd.c
431src/testing/testing_api_trait_process.c
432src/testing/testing_api_traits.c
415src/topology/friends.c 433src/topology/friends.c
416src/topology/gnunet-daemon-topology.c 434src/topology/gnunet-daemon-topology.c
417src/transport/gnunet-communicator-tcp.c 435src/transport/gnunet-communicator-tcp.c
@@ -508,6 +526,7 @@ src/util/dnsparser.c
508src/util/dnsstub.c 526src/util/dnsstub.c
509src/util/getopt.c 527src/util/getopt.c
510src/util/getopt_helpers.c 528src/util/getopt_helpers.c
529src/util/gnunet-base32.c
511src/util/gnunet-config-diff.c 530src/util/gnunet-config-diff.c
512src/util/gnunet-config.c 531src/util/gnunet-config.c
513src/util/gnunet-crypto-tvg.c 532src/util/gnunet-crypto-tvg.c
@@ -550,7 +569,5 @@ src/vpn/vpn_api.c
550src/zonemaster/gnunet-service-zonemaster-monitor.c 569src/zonemaster/gnunet-service-zonemaster-monitor.c
551src/zonemaster/gnunet-service-zonemaster.c 570src/zonemaster/gnunet-service-zonemaster.c
552src/fs/fs_api.h 571src/fs/fs_api.h
553src/include/gnunet_identity_service.h
554src/include/gnunet_messenger_service.h
555src/testbed/testbed_api.h 572src/testbed/testbed_api.h
556src/testbed/testbed_api_operations.h 573src/testbed/testbed_api_operations.h
diff --git a/src/Makefile.am b/src/Makefile.am
index d8a869acb..564923e28 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,6 +45,10 @@ if HAVE_POSTGRESQL
45 POSTGRES_DIR = pq 45 POSTGRES_DIR = pq
46endif 46endif
47 47
48if HAVE_NOLIBGCRYPT19
49 SCALARPRODUCT_DIR = scalarproduct
50endif
51
48REST_DIR = rest 52REST_DIR = rest
49 53
50 54
@@ -93,7 +97,7 @@ SUBDIRS = \
93 seti \ 97 seti \
94 setu \ 98 setu \
95 consensus \ 99 consensus \
96 scalarproduct \ 100 $(SCALARPRODUCT_DIR) \
97 revocation \ 101 revocation \
98 vpn \ 102 vpn \
99 gns \ 103 gns \
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index 899b6f152..2ec913a0a 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -951,7 +951,8 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
951 * 2) We're not connected to ARM. 951 * 2) We're not connected to ARM.
952 * Cancel any reconnection attempts temporarily, then perform 952 * Cancel any reconnection attempts temporarily, then perform
953 * a service test. 953 * a service test.
954 */if (GNUNET_YES == h->currently_up) 954 */
955 if (GNUNET_YES == h->currently_up)
955 { 956 {
956 LOG (GNUNET_ERROR_TYPE_DEBUG, 957 LOG (GNUNET_ERROR_TYPE_DEBUG,
957 "ARM is already running\n"); 958 "ARM is already running\n");
@@ -970,7 +971,8 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
970 yet complete the MQ handshake. However, given that users 971 yet complete the MQ handshake. However, given that users
971 are unlikely to hammer 'gnunet-arm -s' on a busy system, 972 are unlikely to hammer 'gnunet-arm -s' on a busy system,
972 the above check should catch 99.99% of the cases where ARM 973 the above check should catch 99.99% of the cases where ARM
973 is already running. */LOG (GNUNET_ERROR_TYPE_DEBUG, 974 is already running. */
975 LOG (GNUNET_ERROR_TYPE_DEBUG,
974 "Starting ARM service\n"); 976 "Starting ARM service\n");
975 if (NULL == (sig = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE))) 977 if (NULL == (sig = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE)))
976 { 978 {
@@ -1003,13 +1005,13 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
1003 op->rfd, 1005 op->rfd,
1004 &notify_starting, 1006 &notify_starting,
1005 op); 1007 op);
1008 GNUNET_DISK_pipe_close (sig);
1006 } 1009 }
1007 else 1010 else
1008 { 1011 {
1009 op->async = GNUNET_SCHEDULER_add_now (&notify_starting, 1012 op->async = GNUNET_SCHEDULER_add_now (&notify_starting,
1010 op); 1013 op);
1011 } 1014 }
1012 GNUNET_DISK_pipe_close (sig);
1013 return op; 1015 return op;
1014} 1016}
1015 1017
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index 2d3b548dd..c8d69e43d 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -1027,7 +1027,8 @@ handle_drop_message (void *cls,
1027 ch = lookup_channel (c, 1027 ch = lookup_channel (c,
1028 message->ccn); 1028 message->ccn);
1029 1029
1030 GCCH_assign_type_to_drop (ch, message); 1030 if (NULL != ch)
1031 GCCH_assign_type_to_drop (ch, message);
1031 1032
1032 GNUNET_SERVICE_client_continue (c->client); 1033 GNUNET_SERVICE_client_continue (c->client);
1033} 1034}
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index 6b22ae2b4..ae5d9210f 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -1858,6 +1858,7 @@ GCCH_handle_local_data (struct CadetChannel *ch,
1858 } 1858 }
1859 else 1859 else
1860 { 1860 {
1861 GNUNET_free (env);
1861 GNUNET_break (0); 1862 GNUNET_break (0);
1862 return GNUNET_SYSERR; 1863 return GNUNET_SYSERR;
1863 } 1864 }
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 9f03311e1..3aaa734f2 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -80,9 +80,7 @@ bin_PROGRAMS = \
80noinst_PROGRAMS = \ 80noinst_PROGRAMS = \
81 gnunet-gns-benchmark 81 gnunet-gns-benchmark
82 82
83if LINUX
84bin_PROGRAMS += gnunet-bcd 83bin_PROGRAMS += gnunet-bcd
85endif
86 84
87REST_PLUGIN = libgnunet_plugin_rest_gns.la 85REST_PLUGIN = libgnunet_plugin_rest_gns.la
88 86
@@ -156,6 +154,7 @@ gnunet_bcd_SOURCES = \
156 gnunet-bcd.c 154 gnunet-bcd.c
157gnunet_bcd_LDADD = \ 155gnunet_bcd_LDADD = \
158 $(top_builddir)/src/util/libgnunetutil.la \ 156 $(top_builddir)/src/util/libgnunetutil.la \
157 $(top_builddir)/src/identity/libgnunetidentity.la \
159 $(GN_LIBINTL) $(MHD_LIBS) 158 $(GN_LIBINTL) $(MHD_LIBS)
160gnunet_bcd_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) 159gnunet_bcd_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
161 160
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c
index f71f477ef..a2e94089c 100644
--- a/src/gns/gnunet-bcd.c
+++ b/src/gns/gnunet-bcd.c
@@ -27,6 +27,7 @@
27#include "platform.h" 27#include "platform.h"
28#include <microhttpd.h> 28#include <microhttpd.h>
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_identity_service.h"
30#include "gnunet_mhd_compat.h" 31#include "gnunet_mhd_compat.h"
31 32
32/** 33/**
@@ -148,7 +149,7 @@ access_handler_callback (void *cls,
148 char *p; 149 char *p;
149 char *tmp; 150 char *tmp;
150 char *deffile; 151 char *deffile;
151 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 152 struct GNUNET_IDENTITY_PublicKey pub;
152 size_t slen; 153 size_t slen;
153 FILE *f; 154 FILE *f;
154 struct stat st; 155 struct stat st;
@@ -166,9 +167,8 @@ access_handler_callback (void *cls,
166 MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "gnskey"); 167 MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "gnskey");
167 if ((NULL == gnskey) || 168 if ((NULL == gnskey) ||
168 (GNUNET_OK != 169 (GNUNET_OK !=
169 GNUNET_CRYPTO_ecdsa_public_key_from_string (gnskey, 170 GNUNET_IDENTITY_public_key_from_string (gnskey,
170 strlen (gnskey), 171 &pub)))
171 &pub)))
172 { 172 {
173 return MHD_queue_response (connection, 173 return MHD_queue_response (connection,
174 MHD_HTTP_OK, 174 MHD_HTTP_OK,
@@ -218,10 +218,10 @@ access_handler_callback (void *cls,
218 (NULL == gns_nick) ? "" : gns_nick); 218 (NULL == gns_nick) ? "" : gns_nick);
219 fclose (f); 219 fclose (f);
220 GNUNET_asprintf ( 220 GNUNET_asprintf (
221 &p, 221 &p,
222 "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null", 222 "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null",
223 tmp, 223 tmp,
224 resfile); 224 resfile);
225 GNUNET_free (deffile); 225 GNUNET_free (deffile);
226 ret = system (p); 226 ret = system (p);
227 if (WIFSIGNALED (ret) || (0 != WEXITSTATUS (ret))) 227 if (WIFSIGNALED (ret) || (0 != WEXITSTATUS (ret)))
@@ -506,7 +506,7 @@ main (int argc, char *const *argv)
506 "port", 506 "port",
507 "PORT", 507 "PORT",
508 gettext_noop ( 508 gettext_noop (
509 "Run HTTP serve on port PORT (default is 8888)"), 509 "Run HTTP serve on port PORT (default is 8888)"),
510 &port), 510 &port),
511 GNUNET_GETOPT_OPTION_END 511 GNUNET_GETOPT_OPTION_END
512 }; 512 };
@@ -523,8 +523,8 @@ main (int argc, char *const *argv)
523 options, 523 options,
524 &run, 524 &run,
525 NULL)) 525 NULL))
526 ? 0 526 ? 0
527 : 1; 527 : 1;
528 GNUNET_free_nz ((void *) argv); 528 GNUNET_free_nz ((void *) argv);
529 return ret; 529 return ret;
530} 530}
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 0a9b7c861..06f4c9841 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -309,6 +309,14 @@ dns_result_processor (void *cls,
309 } 309 }
310 request->packet = GNUNET_DNSPARSER_parse ((char *) dns, 310 request->packet = GNUNET_DNSPARSER_parse ((char *) dns,
311 r); 311 r);
312 if (NULL == request->packet)
313 {
314 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
315 _ ("Failed to parse DNS response!\n"));
316 GNUNET_SCHEDULER_cancel (request->timeout_task);
317 do_timeout (request);
318 return;
319 }
312 GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); 320 GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup);
313 send_response (request); 321 send_response (request);
314} 322}
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 833a8da01..d02f0f576 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -1841,6 +1841,7 @@ create_response (void *cls,
1841 char *curlurl; 1841 char *curlurl;
1842 char ipstring[INET6_ADDRSTRLEN]; 1842 char ipstring[INET6_ADDRSTRLEN];
1843 char ipaddr[INET6_ADDRSTRLEN + 2]; 1843 char ipaddr[INET6_ADDRSTRLEN + 2];
1844 char *curl_hosts;
1844 const struct sockaddr *sa; 1845 const struct sockaddr *sa;
1845 const struct sockaddr_in *s4; 1846 const struct sockaddr_in *s4;
1846 const struct sockaddr_in6 *s6; 1847 const struct sockaddr_in6 *s6;
@@ -1900,6 +1901,14 @@ create_response (void *cls,
1900 GNUNET_break (0); 1901 GNUNET_break (0);
1901 return MHD_NO; 1902 return MHD_NO;
1902 } 1903 }
1904 GNUNET_asprintf (&curl_hosts,
1905 "%s:%d:%s",
1906 s5r->leho,
1907 port,
1908 ipaddr);
1909 s5r->hosts = curl_slist_append (NULL,
1910 curl_hosts);
1911 GNUNET_free (curl_hosts);
1903 } 1912 }
1904 else 1913 else
1905 { 1914 {
@@ -1949,21 +1958,13 @@ create_response (void *cls,
1949 * Pre-populate cache to resolve Hostname. 1958 * Pre-populate cache to resolve Hostname.
1950 * This is necessary as the DNS name in the CURLOPT_URL is used 1959 * This is necessary as the DNS name in the CURLOPT_URL is used
1951 * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication 1960 * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication
1952 */if (NULL != s5r->leho) 1961 */
1962 if ((NULL != s5r->leho) &&
1963 (NULL != s5r->hosts))
1953 { 1964 {
1954 char *curl_hosts;
1955
1956 GNUNET_asprintf (&curl_hosts,
1957 "%s:%d:%s",
1958 s5r->leho,
1959 port,
1960 ipaddr);
1961 s5r->hosts = curl_slist_append (NULL,
1962 curl_hosts);
1963 curl_easy_setopt (s5r->curl, 1965 curl_easy_setopt (s5r->curl,
1964 CURLOPT_RESOLVE, 1966 CURLOPT_RESOLVE,
1965 s5r->hosts); 1967 s5r->hosts);
1966 GNUNET_free (curl_hosts);
1967 } 1968 }
1968 if (s5r->is_gns) 1969 if (s5r->is_gns)
1969 { 1970 {
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index b53f4af6b..255f85598 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -323,7 +323,6 @@ handle_dns_request (void *cls,
323 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 323 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
324 "Received malformed DNS packet, leaving it untouched.\n"); 324 "Received malformed DNS packet, leaving it untouched.\n");
325 GNUNET_DNS_request_forward (rh); 325 GNUNET_DNS_request_forward (rh);
326 GNUNET_DNSPARSER_free_packet (p);
327 return; 326 return;
328 } 327 }
329 328
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 49c1b340a..2f8a55804 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -764,6 +764,7 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh)
764 rd[i].data = pos->data; 764 rd[i].data = pos->data;
765 rd[i].data_size = pos->data_size; 765 rd[i].data_size = pos->data_size;
766 rd[i].record_type = pos->record_type; 766 rd[i].record_type = pos->record_type;
767 rd[i].flags = GNUNET_GNSRECORD_RF_NONE;
767 /** 768 /**
768 * If this is a LEHO, we added this before. It must be a supplemental 769 * If this is a LEHO, we added this before. It must be a supplemental
769 * record #LSD0001 770 * record #LSD0001
@@ -772,12 +773,11 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh)
772 rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL; 773 rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
773 if (0 == pos->expiration_time) 774 if (0 == pos->expiration_time)
774 { 775 {
775 rd[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 776 rd[i].flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
776 rd[i].expiration_time = 0; 777 rd[i].expiration_time = 0;
777 } 778 }
778 else 779 else
779 { 780 {
780 rd[i].flags = GNUNET_GNSRECORD_RF_NONE;
781 rd[i].expiration_time = pos->expiration_time; 781 rd[i].expiration_time = pos->expiration_time;
782 } 782 }
783 i++; 783 i++;
@@ -1764,6 +1764,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1764 /** 1764 /**
1765 * Records other than GNS2DNS not allowed 1765 * Records other than GNS2DNS not allowed
1766 */ 1766 */
1767 if (NULL != ns)
1768 GNUNET_free (ns);
1767 return GNUNET_SYSERR; 1769 return GNUNET_SYSERR;
1768 } 1770 }
1769 off = 0; 1771 off = 0;
@@ -1771,15 +1773,22 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1771 rd[i].data_size, 1773 rd[i].data_size,
1772 &off); 1774 &off);
1773 ip = GNUNET_strdup (&((const char *) rd[i].data)[off]); 1775 ip = GNUNET_strdup (&((const char *) rd[i].data)[off]);
1776 if ((NULL == n) ||
1777 (NULL == ip))
1778 {
1779 GNUNET_break_op (0);
1780 if (NULL != n)
1781 GNUNET_free (n);
1782 if (NULL != ip)
1783 GNUNET_free (ip);
1784 continue;
1785 }
1786
1774 off += strlen (ip) + 1; 1787 off += strlen (ip) + 1;
1775 1788
1776 if ((NULL == n) || 1789 if (off != rd[i].data_size)
1777 (NULL == ip) ||
1778 (off != rd[i].data_size))
1779 { 1790 {
1780 GNUNET_break_op (0); 1791 GNUNET_break_op (0);
1781 GNUNET_free (n);
1782 GNUNET_free (ip);
1783 continue; 1792 continue;
1784 } 1793 }
1785 /* resolve 'ip' to determine the IP(s) of the DNS 1794 /* resolve 'ip' to determine the IP(s) of the DNS
@@ -1909,6 +1918,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1909 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1918 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1910 _ ("Name `%s' cannot be converted to IDNA."), 1919 _ ("Name `%s' cannot be converted to IDNA."),
1911 tmp); 1920 tmp);
1921 GNUNET_free (tmp);
1922 GNUNET_free (ac);
1912 return GNUNET_SYSERR; 1923 return GNUNET_SYSERR;
1913 } 1924 }
1914 GNUNET_free (tmp); 1925 GNUNET_free (tmp);
@@ -1922,6 +1933,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1922 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1933 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1923 _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"), 1934 _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"),
1924 ac->label); 1935 ac->label);
1936 GNUNET_free (ac->label);
1937 GNUNET_free (ac);
1925 return GNUNET_SYSERR; 1938 return GNUNET_SYSERR;
1926 } 1939 }
1927 continue_with_gns2dns (ac); 1940 continue_with_gns2dns (ac);
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 2ccb5be2b..3a35c9999 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -270,7 +270,9 @@ handle_gns_response (void *cls,
270 result = json_dumps (result_obj, 0); 270 result = json_dumps (result_obj, 0);
271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); 271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
272 resp = GNUNET_REST_create_response (result); 272 resp = GNUNET_REST_create_response (result);
273 MHD_add_response_header (resp, "Content-Type", "application/json"); 273 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
274 "Content-Type",
275 "application/json"));
274 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 276 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
275 GNUNET_free (result); 277 GNUNET_free (result);
276 json_decref (result_obj); 278 json_decref (result_obj);
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 82c38f19a..b907eed27 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -296,15 +296,20 @@ GNUNET_GNSRECORD_data_from_identity (const struct
296 size_t *data_size, 296 size_t *data_size,
297 uint32_t *type) 297 uint32_t *type)
298{ 298{
299 char *tmp;
299 *type = ntohl (key->type); 300 *type = ntohl (key->type);
300 *data_size = GNUNET_IDENTITY_key_get_length (key); 301 *data_size = GNUNET_IDENTITY_key_get_length (key);
301 if (0 == *data_size) 302 if (0 == *data_size)
302 return GNUNET_SYSERR; 303 return GNUNET_SYSERR;
303 *data = GNUNET_malloc (*data_size); 304 tmp = GNUNET_malloc (*data_size);
304 return (GNUNET_IDENTITY_write_key_to_buffer (key, *data, *data_size) == 305 if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size)
305 *data_size? 306 != *data_size) {
306 GNUNET_OK : 307 GNUNET_free (tmp);
307 GNUNET_SYSERR); 308 *data_size = 0;
309 return GNUNET_SYSERR;
310 }
311 *data = tmp;
312 return GNUNET_OK;
308} 313}
309 314
310 315
@@ -350,7 +355,7 @@ GNUNET_GNSRECORD_block_get_expiration (const struct
350 case GNUNET_GNSRECORD_TYPE_PKEY: 355 case GNUNET_GNSRECORD_TYPE_PKEY:
351 return GNUNET_TIME_absolute_ntoh (block->ecdsa_block.expiration_time); 356 return GNUNET_TIME_absolute_ntoh (block->ecdsa_block.expiration_time);
352 default: 357 default:
353 return GNUNET_TIME_absolute_get_zero_ (); 358 GNUNET_break (0); /* Hopefully we never get here, but we might */
354 } 359 }
355 return GNUNET_TIME_absolute_get_zero_ (); 360 return GNUNET_TIME_absolute_get_zero_ ();
356 361
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c
index 47b13bdab..d6b35544c 100644
--- a/src/gnsrecord/gnunet-gnsrecord-tvg.c
+++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c
@@ -172,7 +172,7 @@ run (void *cls,
172 fprintf (stdout, "RRBLOCK:\n"); 172 fprintf (stdout, "RRBLOCK:\n");
173 print_bytes (rrblock, block_size, 8); 173 print_bytes (rrblock, block_size, 8);
174 fprintf (stdout, "\n"); 174 fprintf (stdout, "\n");
175 175 GNUNET_free (rdata);
176} 176}
177 177
178 178
diff --git a/src/include/gnunet_testbed_ng_service.h b/src/include/gnunet_testbed_ng_service.h
new file mode 100644
index 000000000..a6f30889f
--- /dev/null
+++ b/src/include/gnunet_testbed_ng_service.h
@@ -0,0 +1,247 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @author t3sserakt
23 *
24 * @file
25 * API for writing tests and creating large-scale emulation testbeds for GNUnet with command pattern.
26 *
27 * @defgroup testbed Testbed service
28 * Writing tests and creating large-scale emulation testbeds for GNUnet with command pattern.
29 *
30 * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-NG-Subsystem)
31 *
32 * @{
33 */
34
35#ifndef GNUNET_TESTBED_NG_SERVICE_H
36#define GNUNET_TESTBED_NG_SERVICE_H
37
38#include "gnunet_util_lib.h"
39#include "gnunet_testing_ng_lib.h"
40
41struct ServiceState
42{
43 /**
44 * Handle to operation
45 */
46 struct GNUNET_TESTBED_Operation *operation;
47
48 /**
49 * Flag indicating if service is ready.
50 */
51 int service_ready;
52
53 /**
54 * Abort task identifier
55 */
56 struct GNUNET_SCHEDULER_Task *abort_task;
57
58 /**
59 * Label of peer command.
60 */
61 const char *peer_label;
62
63 /**
64 * Name of service to start.
65 */
66 const char *servicename;
67};
68
69struct PeerCmdState
70{
71 /**
72 * The label of a controller command.
73 */
74 const char *controller_label;
75
76 /**
77 * Handle to operation
78 */
79 struct GNUNET_TESTBED_Operation *operation;
80
81 /**
82 * Name of the host, use "NULL" for localhost.
83 */
84 const char *hostname;
85
86 /**
87 * Username to use for the login; may be NULL.
88 */
89 const char *username;
90
91 /**
92 * Port number to use for ssh; use 0 to let ssh decide.
93 */
94 uint16_t port;
95
96 /**
97 * The configuration to use as a template while starting a controller
98 * on this host. Operation queue sizes specific to a host are also
99 * read from this configuration handle.
100 */
101 struct GNUNET_CONFIGURATION_Handle *cfg;
102
103 /**
104 * The host to run peers and controllers on
105 */
106 struct GNUNET_TESTBED_Host *host;
107
108 /**
109 * Abort task identifier
110 */
111 struct GNUNET_SCHEDULER_Task *abort_task;
112
113 /**
114 * Handle for host registration
115 */
116 struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
117
118 /**
119 * Flag indicating if peer is ready.
120 */
121 int peer_ready;
122
123 /**
124 * Flag indicating controller is going down.
125 */
126 int peer_going_down;
127
128 /**
129 * Interpreter state.
130 */
131 struct GNUNET_TESTING_Interpreter *is;
132
133 /**
134 * Peer to start
135 */
136 struct GNUNET_TESTBED_Peer *peer;
137};
138
139struct ControllerState
140{
141 /**
142 * The ip address of the controller which will be set as TRUSTED
143 * HOST(all connections form this ip are permitted by the testbed) when
144 * starting testbed controller at host. This can either be a single ip
145 * address or a network address in CIDR notation.
146 */
147 const char *trusted_ip;
148
149 /**
150 * Name of the host, use "NULL" for localhost.
151 */
152 const char *hostname;
153
154 /**
155 * Username to use for the login; may be NULL.
156 */
157 const char *username;
158
159 /**
160 * Port number to use for ssh; use 0 to let ssh decide.
161 */
162 uint16_t port;
163
164 /**
165 * The configuration to use as a template while starting a controller
166 * on this host. Operation queue sizes specific to a host are also
167 * read from this configuration handle.
168 */
169 struct GNUNET_CONFIGURATION_Handle *cfg;
170
171 /**
172 * The host to run peers and controllers on
173 */
174 struct GNUNET_TESTBED_Host *host;
175
176 /**
177 * The controller process
178 */
179 struct GNUNET_TESTBED_ControllerProc *cp;
180
181 /**
182 * The controller handle
183 */
184 struct GNUNET_TESTBED_Controller *controller;
185
186 /**
187 * A bit mask with set of events to call the controller for.
188 */
189 uint64_t event_mask;
190
191 /**
192 * Abort task identifier
193 */
194 struct GNUNET_SCHEDULER_Task *abort_task;
195
196 /**
197 * Handle for host registration
198 */
199 struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
200
201 /**
202 * Flag indicating if host create with controller is ready.
203 */
204 int host_ready;
205
206 /**
207 * Flag indicating controller is going down.
208 */
209 int controller_going_down;
210
211 /**
212 * Interpreter state.
213 */
214 struct GNUNET_TESTING_Interpreter *is;
215};
216
217/**
218 * Offer data from trait
219 *
220 * @param cmd command to extract the controller from.
221 * @param pt pointer to controller.
222 * @return #GNUNET_OK on success.
223 */
224int
225GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd,
226 struct GNUNET_TESTBED_Controller **
227 controller);
228
229struct GNUNET_TESTING_Command
230GNUNET_TESTBED_cmd_controller (const char *label,
231 const char *trusted_ip,
232 const char *hostname,
233 const char *username,
234 uint16_t port,
235 struct GNUNET_CONFIGURATION_Handle *cfg,
236 uint64_t event_mask);
237
238void
239GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs);
240
241void
242GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps);
243
244void
245GNUNET_TESTBED_shutdown_service (struct ServiceState *ss);
246
247#endif
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index 70cbfa90d..acdfb2034 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -27,7 +27,7 @@
27 * @defgroup testbed Testbed service 27 * @defgroup testbed Testbed service
28 * Writing tests and creating large-scale emulation testbeds for GNUnet. 28 * Writing tests and creating large-scale emulation testbeds for GNUnet.
29 * 29 *
30 * @see [Documentation](https://gnunet.org/gnunet-testbed-subsystem) 30 * @see [Documentation](https://docs.gnunet.org/handbook/gnunet.html#TESTBED-Subsystem)
31 * 31 *
32 * @{ 32 * @{
33 */ 33 */
diff --git a/src/messenger/Makefile.am b/src/messenger/Makefile.am
index 1ebfbe5ed..2bb9ad922 100644
--- a/src/messenger/Makefile.am
+++ b/src/messenger/Makefile.am
@@ -25,35 +25,23 @@ bin_PROGRAMS = \
25 gnunet-messenger 25 gnunet-messenger
26 26
27lib_LTLIBRARIES = \ 27lib_LTLIBRARIES = \
28 libgnunetmessenger_common.la \
29 libgnunetmessenger.la \ 28 libgnunetmessenger.la \
30 $(EXP_LIB) 29 $(EXP_LIB)
31 30
32libgnunetmessenger_common_la_SOURCES = \ 31libgnunetmessenger_la_SOURCES = \
32 messenger_api.c \
33 messenger_api_ego.h \ 33 messenger_api_ego.h \
34 messenger_api_contact.c messenger_api_contact.h \ 34 messenger_api_contact.c messenger_api_contact.h \
35 messenger_api_contact_store.c messenger_api_contact_store.h \ 35 messenger_api_contact_store.c messenger_api_contact_store.h \
36 messenger_api_message.c messenger_api_message.h \ 36 messenger_api_message.c messenger_api_message.h \
37 messenger_api_list_tunnels.c messenger_api_list_tunnels.h \ 37 messenger_api_list_tunnels.c messenger_api_list_tunnels.h \
38 messenger_api_util.c messenger_api_util.h 38 messenger_api_util.c messenger_api_util.h \
39libgnunetmessenger_common_la_LIBADD = \
40 $(top_builddir)/src/util/libgnunetutil.la \
41 $(top_builddir)/src/cadet/libgnunetcadet.la \
42 $(top_builddir)/src/identity/libgnunetidentity.la \
43 $(XLIB) \
44 $(LTLIBINTL)
45libgnunetmessenger_common_la_LDFLAGS = \
46 $(GN_LIB_LDFLAGS) \
47 -version-info 0:0:0
48
49libgnunetmessenger_la_SOURCES = \
50 messenger_api.c \
51 messenger_api_handle.c messenger_api_handle.h \ 39 messenger_api_handle.c messenger_api_handle.h \
52 messenger_api_room.c messenger_api_room.h 40 messenger_api_room.c messenger_api_room.h
53libgnunetmessenger_la_LIBADD = \ 41libgnunetmessenger_la_LIBADD = \
54 $(top_builddir)/src/util/libgnunetutil.la \ 42 $(top_builddir)/src/util/libgnunetutil.la \
43 $(top_builddir)/src/cadet/libgnunetcadet.la \
55 $(top_builddir)/src/identity/libgnunetidentity.la \ 44 $(top_builddir)/src/identity/libgnunetidentity.la \
56 libgnunetmessenger_common.la \
57 $(XLIB) \ 45 $(XLIB) \
58 $(LTLIBINTL) 46 $(LTLIBINTL)
59libgnunetmessenger_la_LDFLAGS = \ 47libgnunetmessenger_la_LDFLAGS = \
@@ -63,10 +51,8 @@ libgnunetmessenger_la_LDFLAGS = \
63gnunet_messenger_SOURCES = \ 51gnunet_messenger_SOURCES = \
64 gnunet-messenger.c 52 gnunet-messenger.c
65gnunet_messenger_LDADD = \ 53gnunet_messenger_LDADD = \
66 libgnunetmessenger_common.la \
67 libgnunetmessenger.la \ 54 libgnunetmessenger.la \
68 $(top_builddir)/src/util/libgnunetutil.la \ 55 $(top_builddir)/src/util/libgnunetutil.la
69 $(top_builddir)/src/identity/libgnunetidentity.la
70gnunet_messenger_LDFLAGS = \ 56gnunet_messenger_LDFLAGS = \
71 $(GN_LIBINTL) 57 $(GN_LIBINTL)
72 58
@@ -91,11 +77,10 @@ gnunet_service_messenger_SOURCES = \
91 gnunet-service-messenger_room.c gnunet-service-messenger_room.h \ 77 gnunet-service-messenger_room.c gnunet-service-messenger_room.h \
92 gnunet-service-messenger_tunnel.c gnunet-service-messenger_tunnel.h 78 gnunet-service-messenger_tunnel.c gnunet-service-messenger_tunnel.h
93gnunet_service_messenger_LDADD = \ 79gnunet_service_messenger_LDADD = \
80 libgnunetmessenger.la \
94 $(top_builddir)/src/util/libgnunetutil.la \ 81 $(top_builddir)/src/util/libgnunetutil.la \
95 $(top_builddir)/src/cadet/libgnunetcadet.la \ 82 $(top_builddir)/src/cadet/libgnunetcadet.la \
96 $(top_builddir)/src/identity/libgnunetidentity.la \ 83 $(top_builddir)/src/identity/libgnunetidentity.la \
97 libgnunetmessenger_common.la \
98 libgnunetmessenger.la \
99 $(GN_LIBINTL) 84 $(GN_LIBINTL)
100 85
101check_PROGRAMS = \ 86check_PROGRAMS = \
@@ -121,7 +106,6 @@ endif
121test_messenger_api_SOURCES = \ 106test_messenger_api_SOURCES = \
122 test_messenger.c 107 test_messenger.c
123test_messenger_api_LDADD = \ 108test_messenger_api_LDADD = \
124 libgnunetmessenger_common.la \
125 libgnunetmessenger.la \ 109 libgnunetmessenger.la \
126 $(top_builddir)/src/testing/libgnunettesting.la \ 110 $(top_builddir)/src/testing/libgnunettesting.la \
127 $(top_builddir)/src/util/libgnunetutil.la 111 $(top_builddir)/src/util/libgnunetutil.la
@@ -129,7 +113,6 @@ test_messenger_api_LDADD = \
129test_messenger_anonymous_SOURCES = \ 113test_messenger_anonymous_SOURCES = \
130 test_messenger_anonymous.c 114 test_messenger_anonymous.c
131test_messenger_anonymous_LDADD = \ 115test_messenger_anonymous_LDADD = \
132 libgnunetmessenger_common.la \
133 libgnunetmessenger.la \ 116 libgnunetmessenger.la \
134 $(top_builddir)/src/testing/libgnunettesting.la \ 117 $(top_builddir)/src/testing/libgnunettesting.la \
135 $(top_builddir)/src/util/libgnunetutil.la 118 $(top_builddir)/src/util/libgnunetutil.la
@@ -139,7 +122,6 @@ test_messenger_sync_client_SOURCES = \
139 testing_messenger_barrier.c testing_messenger_barrier.h \ 122 testing_messenger_barrier.c testing_messenger_barrier.h \
140 testing_messenger_setup.c testing_messenger_setup.h 123 testing_messenger_setup.c testing_messenger_setup.h
141test_messenger_sync_client_LDADD = \ 124test_messenger_sync_client_LDADD = \
142 libgnunetmessenger_common.la \
143 libgnunetmessenger.la \ 125 libgnunetmessenger.la \
144 $(top_builddir)/src/testbed/libgnunettestbed.la \ 126 $(top_builddir)/src/testbed/libgnunettestbed.la \
145 $(top_builddir)/src/testing/libgnunettesting.la \ 127 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -150,7 +132,6 @@ test_messenger_async_client_SOURCES = \
150 testing_messenger_barrier.c testing_messenger_barrier.h \ 132 testing_messenger_barrier.c testing_messenger_barrier.h \
151 testing_messenger_setup.c testing_messenger_setup.h 133 testing_messenger_setup.c testing_messenger_setup.h
152test_messenger_async_client_LDADD = \ 134test_messenger_async_client_LDADD = \
153 libgnunetmessenger_common.la \
154 libgnunetmessenger.la \ 135 libgnunetmessenger.la \
155 $(top_builddir)/src/testbed/libgnunettestbed.la \ 136 $(top_builddir)/src/testbed/libgnunettestbed.la \
156 $(top_builddir)/src/testing/libgnunettesting.la \ 137 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -161,7 +142,6 @@ test_messenger_worst_client_SOURCES = \
161 testing_messenger_barrier.c testing_messenger_barrier.h \ 142 testing_messenger_barrier.c testing_messenger_barrier.h \
162 testing_messenger_setup.c testing_messenger_setup.h 143 testing_messenger_setup.c testing_messenger_setup.h
163test_messenger_worst_client_LDADD = \ 144test_messenger_worst_client_LDADD = \
164 libgnunetmessenger_common.la \
165 libgnunetmessenger.la \ 145 libgnunetmessenger.la \
166 $(top_builddir)/src/testbed/libgnunettestbed.la \ 146 $(top_builddir)/src/testbed/libgnunettestbed.la \
167 $(top_builddir)/src/testing/libgnunettesting.la \ 147 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -172,7 +152,6 @@ test_messenger_sync_p2p_SOURCES = \
172 testing_messenger_barrier.c testing_messenger_barrier.h \ 152 testing_messenger_barrier.c testing_messenger_barrier.h \
173 testing_messenger_setup.c testing_messenger_setup.h 153 testing_messenger_setup.c testing_messenger_setup.h
174test_messenger_sync_p2p_LDADD = \ 154test_messenger_sync_p2p_LDADD = \
175 libgnunetmessenger_common.la \
176 libgnunetmessenger.la \ 155 libgnunetmessenger.la \
177 $(top_builddir)/src/testbed/libgnunettestbed.la \ 156 $(top_builddir)/src/testbed/libgnunettestbed.la \
178 $(top_builddir)/src/testing/libgnunettesting.la \ 157 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -183,7 +162,6 @@ test_messenger_async_p2p_SOURCES = \
183 testing_messenger_barrier.c testing_messenger_barrier.h \ 162 testing_messenger_barrier.c testing_messenger_barrier.h \
184 testing_messenger_setup.c testing_messenger_setup.h 163 testing_messenger_setup.c testing_messenger_setup.h
185test_messenger_async_p2p_LDADD = \ 164test_messenger_async_p2p_LDADD = \
186 libgnunetmessenger_common.la \
187 libgnunetmessenger.la \ 165 libgnunetmessenger.la \
188 $(top_builddir)/src/testbed/libgnunettestbed.la \ 166 $(top_builddir)/src/testbed/libgnunettestbed.la \
189 $(top_builddir)/src/testing/libgnunettesting.la \ 167 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -194,7 +172,6 @@ test_messenger_worst_p2p_SOURCES = \
194 testing_messenger_barrier.c testing_messenger_barrier.h \ 172 testing_messenger_barrier.c testing_messenger_barrier.h \
195 testing_messenger_setup.c testing_messenger_setup.h 173 testing_messenger_setup.c testing_messenger_setup.h
196test_messenger_worst_p2p_LDADD = \ 174test_messenger_worst_p2p_LDADD = \
197 libgnunetmessenger_common.la \
198 libgnunetmessenger.la \ 175 libgnunetmessenger.la \
199 $(top_builddir)/src/testbed/libgnunettestbed.la \ 176 $(top_builddir)/src/testbed/libgnunettestbed.la \
200 $(top_builddir)/src/testing/libgnunettesting.la \ 177 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -205,7 +182,6 @@ test_messenger_server_SOURCES = \
205 testing_messenger_barrier.c testing_messenger_barrier.h \ 182 testing_messenger_barrier.c testing_messenger_barrier.h \
206 testing_messenger_setup.c testing_messenger_setup.h 183 testing_messenger_setup.c testing_messenger_setup.h
207test_messenger_server_LDADD = \ 184test_messenger_server_LDADD = \
208 libgnunetmessenger_common.la \
209 libgnunetmessenger.la \ 185 libgnunetmessenger.la \
210 $(top_builddir)/src/testbed/libgnunettestbed.la \ 186 $(top_builddir)/src/testbed/libgnunettestbed.la \
211 $(top_builddir)/src/testing/libgnunettesting.la \ 187 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -216,7 +192,6 @@ test_messenger_growth_SOURCES = \
216 testing_messenger_barrier.c testing_messenger_barrier.h \ 192 testing_messenger_barrier.c testing_messenger_barrier.h \
217 testing_messenger_setup.c testing_messenger_setup.h 193 testing_messenger_setup.c testing_messenger_setup.h
218test_messenger_growth_LDADD = \ 194test_messenger_growth_LDADD = \
219 libgnunetmessenger_common.la \
220 libgnunetmessenger.la \ 195 libgnunetmessenger.la \
221 $(top_builddir)/src/testbed/libgnunettestbed.la \ 196 $(top_builddir)/src/testbed/libgnunettestbed.la \
222 $(top_builddir)/src/testing/libgnunettesting.la \ 197 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -227,7 +202,6 @@ test_messenger_ring_SOURCES = \
227 testing_messenger_barrier.c testing_messenger_barrier.h \ 202 testing_messenger_barrier.c testing_messenger_barrier.h \
228 testing_messenger_setup.c testing_messenger_setup.h 203 testing_messenger_setup.c testing_messenger_setup.h
229test_messenger_ring_LDADD = \ 204test_messenger_ring_LDADD = \
230 libgnunetmessenger_common.la \
231 libgnunetmessenger.la \ 205 libgnunetmessenger.la \
232 $(top_builddir)/src/testbed/libgnunettestbed.la \ 206 $(top_builddir)/src/testbed/libgnunettestbed.la \
233 $(top_builddir)/src/testing/libgnunettesting.la \ 207 $(top_builddir)/src/testing/libgnunettesting.la \
@@ -238,7 +212,6 @@ test_messenger_adapt_SOURCES = \
238 testing_messenger_barrier.c testing_messenger_barrier.h \ 212 testing_messenger_barrier.c testing_messenger_barrier.h \
239 testing_messenger_setup.c testing_messenger_setup.h 213 testing_messenger_setup.c testing_messenger_setup.h
240test_messenger_adapt_LDADD = \ 214test_messenger_adapt_LDADD = \
241 libgnunetmessenger_common.la \
242 libgnunetmessenger.la \ 215 libgnunetmessenger.la \
243 $(top_builddir)/src/testbed/libgnunettestbed.la \ 216 $(top_builddir)/src/testbed/libgnunettestbed.la \
244 $(top_builddir)/src/testing/libgnunettesting.la \ 217 $(top_builddir)/src/testing/libgnunettesting.la \
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c
index 737bb83c8..094ae398d 100644..100755
--- a/src/messenger/gnunet-messenger.c
+++ b/src/messenger/gnunet-messenger.c
@@ -229,18 +229,12 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
229 if (room_key) 229 if (room_key)
230 GNUNET_CRYPTO_hash (room_key, strlen (room_key), &key); 230 GNUNET_CRYPTO_hash (room_key, strlen (room_key), &key);
231 231
232 struct GNUNET_PeerIdentity door_peer;
232 struct GNUNET_PeerIdentity *door = NULL; 233 struct GNUNET_PeerIdentity *door = NULL;
233 234
234 if (door_id) 235 if ((door_id) &&
235 { 236 (GNUNET_OK == GNUNET_CRYPTO_eddsa_public_key_from_string (door_id, strlen (door_id), &(door_peer.public_key))))
236 door = GNUNET_new(struct GNUNET_PeerIdentity); 237 door = &door_peer;
237
238 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (door_id, strlen (door_id), &(door->public_key)))
239 {
240 GNUNET_free(door);
241 door = NULL;
242 }
243 }
244 238
245 const char *name = GNUNET_MESSENGER_get_name (handle); 239 const char *name = GNUNET_MESSENGER_get_name (handle);
246 240
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index 187b65ed5..76fb31d95 100644..100755
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -191,7 +191,7 @@ check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
191 const uint16_t length = full_length - sizeof(*msg); 191 const uint16_t length = full_length - sizeof(*msg);
192 const char *buffer = ((const char*) msg) + sizeof(*msg); 192 const char *buffer = ((const char*) msg) + sizeof(*msg);
193 193
194 uint16_t key_length = 0; 194 ssize_t key_length = 0;
195 195
196 if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE)) 196 if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE))
197 goto check_for_message; 197 goto check_for_message;
@@ -231,7 +231,7 @@ handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
231 const char *buffer = ((const char*) msg) + sizeof(*msg); 231 const char *buffer = ((const char*) msg) + sizeof(*msg);
232 232
233 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); 233 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
234 uint16_t key_length = 0; 234 ssize_t key_length = 0;
235 235
236 struct GNUNET_IDENTITY_PublicKey public_key; 236 struct GNUNET_IDENTITY_PublicKey public_key;
237 237
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c
index 6e39cec13..7f00e8438 100644..100755
--- a/src/messenger/gnunet-service-messenger_member.c
+++ b/src/messenger/gnunet-service-messenger_member.c
@@ -335,7 +335,11 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN
335 struct GNUNET_HashCode hash; 335 struct GNUNET_HashCode hash;
336 GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); 336 GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash);
337 337
338 GNUNET_CONTAINER_multihashmap_put(member->sessions, &hash, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 338 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
339 member->sessions, &hash, session,
340 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
341 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Adding a member session failed: %s\n",
342 GNUNET_h2s(&hash));
339} 343}
340 344
341void 345void
@@ -348,7 +352,9 @@ remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MES
348 struct GNUNET_HashCode hash; 352 struct GNUNET_HashCode hash;
349 GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash); 353 GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash);
350 354
351 GNUNET_CONTAINER_multihashmap_remove(member->sessions, &hash, session); 355 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(member->sessions, &hash, session))
356 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Removing a member session failed: %s\n",
357 GNUNET_h2s(&hash));
352} 358}
353 359
354struct GNUNET_MESSENGER_ClosureIterateSessions { 360struct GNUNET_MESSENGER_ClosureIterateSessions {
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c
index 1f3d262ac..b143c6c98 100644..100755
--- a/src/messenger/gnunet-service-messenger_message_store.c
+++ b/src/messenger/gnunet-service-messenger_message_store.c
@@ -158,6 +158,8 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha
158 struct GNUNET_MESSENGER_MessageLinkStorage storage; 158 struct GNUNET_MESSENGER_MessageLinkStorage storage;
159 struct GNUNET_MESSENGER_MessageLink *link = NULL; 159 struct GNUNET_MESSENGER_MessageLink *link = NULL;
160 160
161 memset(&storage, 0, sizeof(storage));
162
161 do 163 do
162 { 164 {
163 if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) || 165 if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) ||
@@ -311,6 +313,8 @@ save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir
311 save.store = store; 313 save.store = store;
312 save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission); 314 save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission);
313 315
316 GNUNET_free(filename);
317
314 if (!save.storage) 318 if (!save.storage)
315 goto save_entries; 319 goto save_entries;
316 320
@@ -324,7 +328,6 @@ close_links:
324 GNUNET_DISK_file_close (save.storage); 328 GNUNET_DISK_file_close (save.storage);
325 329
326save_entries: 330save_entries:
327 GNUNET_free(filename);
328 GNUNET_asprintf (&filename, "%s%s", directory, "entries.store"); 331 GNUNET_asprintf (&filename, "%s%s", directory, "entries.store");
329 332
330 save.store = store; 333 save.store = store;
@@ -417,7 +420,10 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU
417 420
418 if ((GNUNET_YES != decoding) || (GNUNET_CRYPTO_hash_cmp (hash, &check) != 0)) 421 if ((GNUNET_YES != decoding) || (GNUNET_CRYPTO_hash_cmp (hash, &check) != 0))
419 { 422 {
420 GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry); 423 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry))
424 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Corrupted entry could not be removed from store: %s\n",
425 GNUNET_h2s(hash));
426
421 store->rewrite_entries = GNUNET_YES; 427 store->rewrite_entries = GNUNET_YES;
422 428
423 goto free_message; 429 goto free_message;
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c
index 05985ef84..a32fbad2c 100644..100755
--- a/src/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/messenger/gnunet-service-messenger_operation_store.c
@@ -184,7 +184,9 @@ cancel_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
184 184
185 stop_operation(op); 185 stop_operation(op);
186 186
187 GNUNET_CONTAINER_multihashmap_remove(store->operations, hash, op); 187 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(store->operations, hash, op))
188 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Canceled operation could not be removed: %s\n",
189 GNUNET_h2s(hash));
188 190
189 destroy_operation(op); 191 destroy_operation(op);
190} 192}
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c
index 5238b2c58..6a517c2e0 100644..100755
--- a/src/messenger/messenger_api_contact_store.c
+++ b/src/messenger/messenger_api_contact_store.c
@@ -155,8 +155,10 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET
155 store, next_context, &hash 155 store, next_context, &hash
156 ); 156 );
157 157
158 GNUNET_CONTAINER_multihashmap_put (map, &hash, contact, 158 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (map, &hash, contact,
159 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 159 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
160 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Updating a contact failed: %s\n",
161 GNUNET_h2s(&hash));
160 } 162 }
161} 163}
162 164
@@ -176,7 +178,8 @@ remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET
176 ); 178 );
177 179
178 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (map, &hash, contact)) 180 if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (map, &hash, contact))
179 return; 181 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Removing a contact failed: %s\n",
182 GNUNET_h2s(&hash));
180 183
181 destroy_contact (contact); 184 destroy_contact (contact);
182} 185}
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index d88859186..0d885f9ee 100644..100755
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -590,7 +590,7 @@ int
590decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, 590decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer,
591 int include_signature, uint16_t *padding) 591 int include_signature, uint16_t *padding)
592{ 592{
593 GNUNET_assert((message) && (buffer)); 593 GNUNET_assert((message) && (buffer) && (length >= sizeof(message->header)));
594 594
595 uint16_t offset = 0; 595 uint16_t offset = 0;
596 596
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c
index df141ca12..5b7edee60 100644..100755
--- a/src/messenger/messenger_api_room.c
+++ b/src/messenger/messenger_api_room.c
@@ -106,7 +106,7 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H
106 return (entry? entry->sender : NULL); 106 return (entry? entry->sender : NULL);
107} 107}
108 108
109static void 109static struct GNUNET_MESSENGER_Contact*
110handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 110handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
111 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 111 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
112{ 112{
@@ -124,6 +124,8 @@ handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
124 (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put(room->members, &(message->header.sender_id), sender, 124 (GNUNET_OK == GNUNET_CONTAINER_multishortmap_put(room->members, &(message->header.sender_id), sender,
125 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))) 125 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)))
126 increase_contact_rc(sender); 126 increase_contact_rc(sender);
127
128 return sender;
127} 129}
128 130
129static void 131static void
@@ -140,7 +142,7 @@ handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGE
140 struct GNUNET_MESSENGER_ContactStore *store = get_handle_contact_store(room->handle); 142 struct GNUNET_MESSENGER_ContactStore *store = get_handle_contact_store(room->handle);
141 143
142 if (GNUNET_YES == decrease_contact_rc(sender)) 144 if (GNUNET_YES == decrease_contact_rc(sender))
143 remove_store_contact(store, sender, &context); 145 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "A contact does not share any room with you anymore!\n");
144} 146}
145 147
146static void 148static void
@@ -216,17 +218,17 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG
216 } 218 }
217} 219}
218 220
219void 221struct GNUNET_MESSENGER_Contact*
220handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 222handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
221 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 223 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
222{ 224{
223 if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) 225 if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash))
224 return; 226 return sender;
225 227
226 switch (message->header.kind) 228 switch (message->header.kind)
227 { 229 {
228 case GNUNET_MESSENGER_KIND_JOIN: 230 case GNUNET_MESSENGER_KIND_JOIN:
229 handle_join_message (room, sender, message, hash); 231 sender = handle_join_message (room, sender, message, hash);
230 break; 232 break;
231 case GNUNET_MESSENGER_KIND_LEAVE: 233 case GNUNET_MESSENGER_KIND_LEAVE:
232 handle_leave_message (room, sender, message, hash); 234 handle_leave_message (room, sender, message, hash);
@@ -253,7 +255,7 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
253 struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_new(struct GNUNET_MESSENGER_RoomMessageEntry); 255 struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_new(struct GNUNET_MESSENGER_RoomMessageEntry);
254 256
255 if (!entry) 257 if (!entry)
256 return; 258 return sender;
257 259
258 entry->sender = sender; 260 entry->sender = sender;
259 entry->message = copy_message (message); 261 entry->message = copy_message (message);
@@ -264,6 +266,8 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
264 destroy_message (entry->message); 266 destroy_message (entry->message);
265 GNUNET_free(entry); 267 GNUNET_free(entry);
266 } 268 }
269
270 return sender;
267} 271}
268 272
269struct GNUNET_MESSENGER_MemberCall 273struct GNUNET_MESSENGER_MemberCall
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
index 9455fd43b..eb41cf740 100644..100755
--- a/src/messenger/messenger_api_room.h
+++ b/src/messenger/messenger_api_room.h
@@ -100,12 +100,16 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H
100 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update 100 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update
101 * members and its information. The function also stores the message in map locally for access afterwards. 101 * members and its information. The function also stores the message in map locally for access afterwards.
102 * 102 *
103 * The contact of the message's sender could be updated or even created. It may not be freed or destroyed though!
104 * (The contact may still be in use for old messages...)
105 *
103 * @param[in/out] room Room 106 * @param[in/out] room Room
104 * @param[in/out] sender Contact of sender 107 * @param[in/out] sender Contact of sender
105 * @param[in] message Message 108 * @param[in] message Message
106 * @param[in] hash Hash of message 109 * @param[in] hash Hash of message
110 * @return Contact of sender
107 */ 111 */
108void 112struct GNUNET_MESSENGER_Contact*
109handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 113handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
110 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); 114 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
111 115
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index d6774b37b..79210939f 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -743,13 +743,14 @@ send_lookup_response (struct NamestoreClient *nc,
743 nick->flags = 743 nick->flags =
744 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 744 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
745 merge_with_nick_records (nick, rd_count, rd, &res_count, &res); 745 merge_with_nick_records (nick, rd_count, rd, &res_count, &res);
746 GNUNET_free (nick);
747 } 746 }
748 else 747 else
749 { 748 {
750 res_count = rd_count; 749 res_count = rd_count;
751 res = (struct GNUNET_GNSRECORD_Data *) rd; 750 res = (struct GNUNET_GNSRECORD_Data *) rd;
752 } 751 }
752 if (NULL != nick)
753 GNUNET_free (nick);
753 754
754 GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res)); 755 GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res));
755 756
@@ -758,12 +759,16 @@ send_lookup_response (struct NamestoreClient *nc,
758 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res); 759 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res);
759 if (rd_ser_len < 0) 760 if (rd_ser_len < 0)
760 { 761 {
762 if (rd != res)
763 GNUNET_free (res);
761 GNUNET_break (0); 764 GNUNET_break (0);
762 GNUNET_SERVICE_client_drop (nc->client); 765 GNUNET_SERVICE_client_drop (nc->client);
763 return; 766 return;
764 } 767 }
765 if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg)) 768 if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg))
766 { 769 {
770 if (rd != res)
771 GNUNET_free (res);
767 GNUNET_break (0); 772 GNUNET_break (0);
768 GNUNET_SERVICE_client_drop (nc->client); 773 GNUNET_SERVICE_client_drop (nc->client);
769 return; 774 return;
@@ -920,12 +925,15 @@ refresh_block (struct NamestoreClient *nc,
920 nick->flags = 925 nick->flags =
921 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; 926 (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE;
922 merge_with_nick_records (nick, rd_count, rd, &res_count, &res); 927 merge_with_nick_records (nick, rd_count, rd, &res_count, &res);
923 GNUNET_free (nick);
924 } 928 }
929 if (NULL != nick)
930 GNUNET_free (nick);
925 if (0 == res_count) 931 if (0 == res_count)
926 { 932 {
927 if (NULL != nc) 933 if (NULL != nc)
928 send_store_response (nc, GNUNET_OK, rid); 934 send_store_response (nc, GNUNET_OK, rid);
935 if (rd != res)
936 GNUNET_free (res);
929 return; /* no data, no need to update cache */ 937 return; /* no data, no need to update cache */
930 } 938 }
931 if (GNUNET_YES == disable_namecache) 939 if (GNUNET_YES == disable_namecache)
@@ -936,6 +944,8 @@ refresh_block (struct NamestoreClient *nc,
936 GNUNET_NO); 944 GNUNET_NO);
937 if (NULL != nc) 945 if (NULL != nc)
938 send_store_response (nc, GNUNET_OK, rid); 946 send_store_response (nc, GNUNET_OK, rid);
947 if (rd != res)
948 GNUNET_free (res);
939 return; 949 return;
940 } 950 }
941 exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res); 951 exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res);
@@ -970,6 +980,8 @@ refresh_block (struct NamestoreClient *nc,
970 &finish_cache_operation, 980 &finish_cache_operation,
971 cop); 981 cop);
972 GNUNET_free (block); 982 GNUNET_free (block);
983 if (rd != res)
984 GNUNET_free (res);
973} 985}
974 986
975 987
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index c845b5019..2d5327e06 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -690,6 +690,12 @@ handle_zone_to_name_response (void *cls,
690 690
691 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n"); 691 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n");
692 qe = find_qe (h, ntohl (msg->gns_header.r_id)); 692 qe = find_qe (h, ntohl (msg->gns_header.r_id));
693 if (NULL == qe)
694 {
695 LOG (GNUNET_ERROR_TYPE_WARNING,
696 "Response queue already gone...\n");
697 return;
698 }
693 res = ntohs (msg->res); 699 res = ntohs (msg->res);
694 switch (res) 700 switch (res)
695 { 701 {
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index edcbeb874..ae93e5eff 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -375,6 +375,8 @@ get_egoentry_namestore (struct RequestHandle *handle, char *name)
375 if (NULL == name) 375 if (NULL == name)
376 return NULL; 376 return NULL;
377 tmp = strtok (copy, "/"); 377 tmp = strtok (copy, "/");
378 if (NULL == tmp)
379 return NULL;
378 for (ego_entry = ego_head; NULL != ego_entry; 380 for (ego_entry = ego_head; NULL != ego_entry;
379 ego_entry = ego_entry->next) 381 ego_entry = ego_entry->next)
380 { 382 {
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c
index 4bbc7442e..f969a175b 100644
--- a/src/peerinfo-tool/plugin_rest_peerinfo.c
+++ b/src/peerinfo-tool/plugin_rest_peerinfo.c
@@ -379,7 +379,9 @@ peerinfo_list_finished (void *cls)
379 result_str = json_dumps (handle->response, 0); 379 result_str = json_dumps (handle->response, 0);
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
381 resp = GNUNET_REST_create_response (result_str); 381 resp = GNUNET_REST_create_response (result_str);
382 MHD_add_response_header (resp, "Content-Type", "application/json"); 382 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
383 "Content-Type",
384 "application/json"));
383 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 385 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
384 GNUNET_free (result_str); 386 GNUNET_free (result_str);
385 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 387 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index db5aee0d5..196d44faa 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -823,7 +823,12 @@ reconnect (void *cls)
823 &handle_client_error, 823 &handle_client_error,
824 h); 824 h);
825 if (NULL == h->mq) 825 if (NULL == h->mq)
826 {
827 h->reconnect_task =
828 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
829 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
826 return; 830 return;
831 }
827 LOG (GNUNET_ERROR_TYPE_DEBUG, 832 LOG (GNUNET_ERROR_TYPE_DEBUG,
828 "Resending pending requests after reconnect.\n"); 833 "Resending pending requests after reconnect.\n");
829 if (NULL != h->watches) 834 if (NULL != h->watches)
diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c
index 4c826c654..5057c98b5 100644
--- a/src/peerstore/test_peerstore_api_sync.c
+++ b/src/peerstore/test_peerstore_api_sync.c
@@ -67,6 +67,24 @@ static const char *val = "test_peerstore_api_store_val";
67 67
68 68
69/** 69/**
70 * Timeout
71 */
72#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
73
74/**
75 * Timeout task
76 */
77static struct GNUNET_SCHEDULER_Task *to;
78
79/**
80 * Iterate handle
81 */
82static struct GNUNET_PEERSTORE_IterateContext *it;
83
84static void
85test_cont (void *cls);
86
87/**
70 * Function that should be called with the result of the 88 * Function that should be called with the result of the
71 * lookup, and finally once with NULL to signal the end 89 * lookup, and finally once with NULL to signal the end
72 * of the iteration. 90 * of the iteration.
@@ -89,9 +107,24 @@ iterate_cb (void *cls,
89 GNUNET_break (NULL == emsg); 107 GNUNET_break (NULL == emsg);
90 if (NULL == record) 108 if (NULL == record)
91 { 109 {
92 GNUNET_PEERSTORE_disconnect (h, 110 it = NULL;
93 GNUNET_NO); 111 if (0 == ok)
94 GNUNET_SCHEDULER_shutdown (); 112 {
113 GNUNET_PEERSTORE_disconnect (h,
114 GNUNET_NO);
115 if (NULL != to)
116 {
117 GNUNET_SCHEDULER_cancel (to);
118 to = NULL;
119 }
120 GNUNET_SCHEDULER_shutdown ();
121 return;
122 }
123 /**
124 * Try again
125 */
126 GNUNET_SCHEDULER_add_now (&test_cont,
127 NULL);
95 return; 128 return;
96 } 129 }
97 rec_val = record->value; 130 rec_val = record->value;
@@ -100,6 +133,22 @@ iterate_cb (void *cls,
100} 133}
101 134
102 135
136static void
137timeout_task (void *cls)
138{
139 to = NULL;
140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
141 "Timeout reached\n");
142 if (NULL != it)
143 GNUNET_PEERSTORE_iterate_cancel (it);
144 it = NULL;
145 GNUNET_PEERSTORE_disconnect (h,
146 GNUNET_NO);
147 GNUNET_SCHEDULER_shutdown ();
148 return;
149}
150
151
103/** 152/**
104 * Run the 2nd stage of the test where we fetch the 153 * Run the 2nd stage of the test where we fetch the
105 * data that should have been stored. 154 * data that should have been stored.
@@ -109,12 +158,11 @@ iterate_cb (void *cls,
109static void 158static void
110test_cont (void *cls) 159test_cont (void *cls)
111{ 160{
112 h = GNUNET_PEERSTORE_connect (cfg); 161 it = GNUNET_PEERSTORE_iterate (h,
113 GNUNET_PEERSTORE_iterate (h, 162 subsystem,
114 subsystem, 163 &pid, key,
115 &pid, key, 164 &iterate_cb,
116 &iterate_cb, 165 NULL);
117 NULL);
118} 166}
119 167
120 168
@@ -122,10 +170,9 @@ static void
122disc_cont (void *cls) 170disc_cont (void *cls)
123{ 171{
124 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES); 172 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
125 h = NULL; 173 h = GNUNET_PEERSTORE_connect (cfg);
126 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 174 GNUNET_SCHEDULER_add_now (&test_cont,
127 &test_cont, 175 NULL);
128 NULL);
129} 176}
130 177
131 178
@@ -133,12 +180,17 @@ static void
133store_cont (void *cls, int success) 180store_cont (void *cls, int success)
134{ 181{
135 ok = success; 182 ok = success;
183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
184 "Success: %s\n",
185 (GNUNET_SYSERR == ok) ? "no" : "yes");
136 /* We need to wait a little bit to give the disconnect 186 /* We need to wait a little bit to give the disconnect
137 a chance to actually finish the operation; otherwise, 187 a chance to actually finish the operation; otherwise,
138 the test may fail non-deterministically if the new 188 the test may fail non-deterministically if the new
139 connection is faster than the cleanup routine of the 189 connection is faster than the cleanup routine of the
140 old one. */GNUNET_SCHEDULER_add_now (&disc_cont, 190 old one. */
141 NULL); 191 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
192 &disc_cont,
193 NULL);
142} 194}
143 195
144 196
@@ -174,7 +226,10 @@ run (void *cls,
174{ 226{
175 cfg = c; 227 cfg = c;
176 memset (&pid, 1, sizeof(pid)); 228 memset (&pid, 1, sizeof(pid));
177 test1 (); 229 to = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
230 &timeout_task,
231 NULL);
232 GNUNET_SCHEDULER_add_now (&test1, NULL);
178} 233}
179 234
180 235
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 913b667b7..04c12735b 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -731,9 +731,12 @@ static int
731check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) 731check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
732{ 732{
733 uint16_t size; 733 uint16_t size;
734 size_t attrs_len;
734 735
735 size = ntohs (im->header.size); 736 size = ntohs (im->header.size);
736 if (size <= sizeof(struct IssueTicketMessage)) 737 attrs_len = ntohs (im->attr_len);
738
739 if (attrs_len > size - sizeof(struct IssueTicketMessage))
737 { 740 {
738 GNUNET_break (0); 741 GNUNET_break (0);
739 return GNUNET_SYSERR; 742 return GNUNET_SYSERR;
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index ef2303bd7..48b3fe214 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -690,7 +690,10 @@ rvk_move_attr_cb (void *cls,
690 return; 690 return;
691 } 691 }
692 GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id); 692 GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id);
693 new_label = NULL; 693 new_label =
694 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
695 sizeof (rvk->move_attr->new_id));
696
694 attr_data = NULL; 697 attr_data = NULL;
695 // new_rd = *rd; 698 // new_rd = *rd;
696 for (int i = 0; i < rd_count; i++) 699 for (int i = 0; i < rd_count; i++)
@@ -714,9 +717,6 @@ rvk_move_attr_cb (void *cls,
714 new_rd[i].record_type = rd[i].record_type; 717 new_rd[i].record_type = rd[i].record_type;
715 new_rd[i].flags = rd[i].flags; 718 new_rd[i].flags = rd[i].flags;
716 new_rd[i].expiration_time = rd[i].expiration_time; 719 new_rd[i].expiration_time = rd[i].expiration_time;
717 new_label =
718 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
719 sizeof (rvk->move_attr->new_id));
720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
721 GNUNET_free (claim); 721 GNUNET_free (claim);
722 } 722 }
@@ -738,9 +738,6 @@ rvk_move_attr_cb (void *cls,
738 new_rd[i].record_type = rd[i].record_type; 738 new_rd[i].record_type = rd[i].record_type;
739 new_rd[i].flags = rd[i].flags; 739 new_rd[i].flags = rd[i].flags;
740 new_rd[i].expiration_time = rd[i].expiration_time; 740 new_rd[i].expiration_time = rd[i].expiration_time;
741 new_label =
742 GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
743 sizeof (rvk->move_attr->new_id));
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", 741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n",
745 new_label); 742 new_label);
746 GNUNET_free (credential); 743 GNUNET_free (credential);
@@ -1400,7 +1397,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1400 attrs_record, 1397 attrs_record,
1401 &store_ticket_issue_cont, 1398 &store_ticket_issue_cont,
1402 ih); 1399 ih);
1403 for (j = 0; j > i; j++) 1400 for (j = 0; j < i; j++)
1404 { 1401 {
1405 if (attrs_record[j].record_type 1402 if (attrs_record[j].record_type
1406 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION) 1403 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION)
@@ -1585,7 +1582,7 @@ filter_tickets_cb (void *cls,
1585 cleanup_issue_handle (tih); 1582 cleanup_issue_handle (tih);
1586 return; 1583 return;
1587 } 1584 }
1588 1585 GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations);
1589 // ticket not found in current record, checking next record set 1586 // ticket not found in current record, checking next record set
1590 GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1); 1587 GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1);
1591} 1588}
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index bd3a8ee05..7b24ee598 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -839,11 +839,17 @@ int
839OIDC_access_token_parse (const char *token, 839OIDC_access_token_parse (const char *token,
840 struct GNUNET_RECLAIM_Ticket **ticket) 840 struct GNUNET_RECLAIM_Ticket **ticket)
841{ 841{
842 if (sizeof (struct GNUNET_RECLAIM_Ticket) != 842 size_t sret;
843 GNUNET_STRINGS_base64_decode (token, 843 char *decoded;
844 strlen (token), 844 sret = GNUNET_STRINGS_base64_decode (token,
845 (void**) ticket)) 845 strlen (token),
846 (void**) &decoded);
847 if (sizeof (struct GNUNET_RECLAIM_Ticket) != sret)
848 {
849 GNUNET_free (decoded);
846 return GNUNET_SYSERR; 850 return GNUNET_SYSERR;
851 }
852 *ticket = (struct GNUNET_RECLAIM_Ticket *) decoded;
847 return GNUNET_OK; 853 return GNUNET_OK;
848} 854}
849 855
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 0ee61755b..c6259d745 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -686,7 +686,10 @@ do_userinfo_error (void *cls)
686 handle->emsg, 686 handle->emsg,
687 (NULL != handle->edesc) ? handle->edesc : ""); 687 (NULL != handle->edesc) ? handle->edesc : "");
688 resp = GNUNET_REST_create_response (""); 688 resp = GNUNET_REST_create_response ("");
689 MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); 689 GNUNET_assert (MHD_NO !=
690 MHD_add_response_header (resp,
691 MHD_HTTP_HEADER_WWW_AUTHENTICATE,
692 "Bearer"));
690 handle->proc (handle->proc_cls, resp, handle->response_code); 693 handle->proc (handle->proc_cls, resp, handle->response_code);
691 cleanup_handle (handle); 694 cleanup_handle (handle);
692 GNUNET_free (error); 695 GNUNET_free (error);
@@ -713,7 +716,8 @@ do_redirect_error (void *cls)
713 (NULL != handle->oidc->state) ? "&state=" : "", 716 (NULL != handle->oidc->state) ? "&state=" : "",
714 (NULL != handle->oidc->state) ? handle->oidc->state : ""); 717 (NULL != handle->oidc->state) ? handle->oidc->state : "");
715 resp = GNUNET_REST_create_response (""); 718 resp = GNUNET_REST_create_response ("");
716 MHD_add_response_header (resp, "Location", redirect); 719 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
720 "Location", redirect));
717 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); 721 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
718 cleanup_handle (handle); 722 cleanup_handle (handle);
719 GNUNET_free (redirect); 723 GNUNET_free (redirect);
@@ -1022,7 +1026,8 @@ oidc_ticket_issue_cb (void *cls,
1022 handle->oidc->state); 1026 handle->oidc->state);
1023 } 1027 }
1024 resp = GNUNET_REST_create_response (""); 1028 resp = GNUNET_REST_create_response ("");
1025 MHD_add_response_header (resp, "Location", redirect_uri); 1029 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1030 "Location", redirect_uri));
1026 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); 1031 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
1027 cleanup_handle (handle); 1032 cleanup_handle (handle);
1028 GNUNET_free (redirect_uri); 1033 GNUNET_free (redirect_uri);
@@ -1381,7 +1386,8 @@ build_redirect (void *cls)
1381 handle->oidc->state); 1386 handle->oidc->state);
1382 } 1387 }
1383 resp = GNUNET_REST_create_response (""); 1388 resp = GNUNET_REST_create_response ("");
1384 MHD_add_response_header (resp, "Location", redirect_uri); 1389 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1390 "Location", redirect_uri));
1385 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); 1391 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
1386 cleanup_handle (handle); 1392 cleanup_handle (handle);
1387 GNUNET_free (redirect_uri); 1393 GNUNET_free (redirect_uri);
@@ -1764,8 +1770,12 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle,
1764 "%s;Max-Age=%d", 1770 "%s;Max-Age=%d",
1765 cookie, 1771 cookie,
1766 OIDC_COOKIE_EXPIRATION); 1772 OIDC_COOKIE_EXPIRATION);
1767 MHD_add_response_header (resp, "Set-Cookie", header_val); 1773 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1768 MHD_add_response_header (resp, "Access-Control-Allow-Methods", "POST"); 1774 "Set-Cookie", header_val));
1775 GNUNET_assert (MHD_NO !=
1776 MHD_add_response_header (resp,
1777 "Access-Control-Allow-Methods",
1778 "POST"));
1769 GNUNET_CRYPTO_hash (cookie, strlen (cookie), &cache_key); 1779 GNUNET_CRYPTO_hash (cookie, strlen (cookie), &cache_key);
1770 1780
1771 if (0 != strcmp (json_string_value (identity), "Denied")) 1781 if (0 != strcmp (json_string_value (identity), "Denied"))
@@ -1880,7 +1890,8 @@ parse_credentials_post_body (struct RequestHandle *handle,
1880 } 1890 }
1881 pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, 1891 pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map,
1882 &cache_key); 1892 &cache_key);
1883 if (NULL == pass) { 1893 if (NULL == pass)
1894 {
1884 GNUNET_free (*client_id); 1895 GNUNET_free (*client_id);
1885 *client_id = NULL; 1896 *client_id = NULL;
1886 return GNUNET_SYSERR; 1897 return GNUNET_SYSERR;
@@ -2134,6 +2145,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2134 GNUNET_free (code); 2145 GNUNET_free (code);
2135 if (NULL != nonce) 2146 if (NULL != nonce)
2136 GNUNET_free (nonce); 2147 GNUNET_free (nonce);
2148 GNUNET_RECLAIM_attribute_list_destroy (cl);
2149 GNUNET_RECLAIM_presentation_list_destroy (pl);
2137 GNUNET_SCHEDULER_add_now (&do_error, handle); 2150 GNUNET_SCHEDULER_add_now (&do_error, handle);
2138 return; 2151 return;
2139 } 2152 }
@@ -2149,6 +2162,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2149 handle->edesc = GNUNET_strdup ("No signing secret configured!"); 2162 handle->edesc = GNUNET_strdup ("No signing secret configured!");
2150 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 2163 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2151 GNUNET_free (code); 2164 GNUNET_free (code);
2165 GNUNET_RECLAIM_attribute_list_destroy (cl);
2166 GNUNET_RECLAIM_presentation_list_destroy (pl);
2152 if (NULL != nonce) 2167 if (NULL != nonce)
2153 GNUNET_free (nonce); 2168 GNUNET_free (nonce);
2154 GNUNET_SCHEDULER_add_now (&do_error, handle); 2169 GNUNET_SCHEDULER_add_now (&do_error, handle);
@@ -2191,9 +2206,14 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2191 &json_response); 2206 &json_response);
2192 2207
2193 resp = GNUNET_REST_create_response (json_response); 2208 resp = GNUNET_REST_create_response (json_response);
2194 MHD_add_response_header (resp, "Cache-Control", "no-store"); 2209 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
2195 MHD_add_response_header (resp, "Pragma", "no-cache"); 2210 "Cache-Control",
2196 MHD_add_response_header (resp, "Content-Type", "application/json"); 2211 "no-store"));
2212 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
2213 "Pragma", "no-cache"));
2214 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
2215 "Content-Type",
2216 "application/json"));
2197 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2217 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
2198 GNUNET_RECLAIM_attribute_list_destroy (cl); 2218 GNUNET_RECLAIM_attribute_list_destroy (cl);
2199 GNUNET_RECLAIM_presentation_list_destroy (pl); 2219 GNUNET_RECLAIM_presentation_list_destroy (pl);
@@ -2665,8 +2685,14 @@ oidc_config_cors (struct GNUNET_REST_RequestHandle *con_handle,
2665 2685
2666 // For now, independent of path return all options 2686 // For now, independent of path return all options
2667 resp = GNUNET_REST_create_response (NULL); 2687 resp = GNUNET_REST_create_response (NULL);
2668 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); 2688 GNUNET_assert (MHD_NO !=
2669 MHD_add_response_header (resp, "Access-Control-Allow-Origin", "*"); 2689 MHD_add_response_header (resp,
2690 "Access-Control-Allow-Methods",
2691 allow_methods));
2692 GNUNET_assert (MHD_NO !=
2693 MHD_add_response_header (resp,
2694 "Access-Control-Allow-Origin",
2695 "*"));
2670 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2696 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
2671 cleanup_handle (handle); 2697 cleanup_handle (handle);
2672 return; 2698 return;
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 84456b386..39d24ea61 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -353,14 +353,18 @@ finished_cont (void *cls, int32_t success, const char *emsg)
353 struct MHD_Response *resp; 353 struct MHD_Response *resp;
354 354
355 handle->idp_op = NULL; 355 handle->idp_op = NULL;
356 resp = GNUNET_REST_create_response (emsg);
357 MHD_add_response_header (resp, "Content-Type", "application/json");
358 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
359 if (GNUNET_OK != success) 356 if (GNUNET_OK != success)
360 { 357 {
361 GNUNET_SCHEDULER_add_now (&do_error, handle); 358 GNUNET_SCHEDULER_add_now (&do_error, handle);
362 return; 359 return;
363 } 360 }
361 resp = GNUNET_REST_create_response (emsg);
362 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
363 "Content-Type",
364 "application/json"));
365 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
366 "Access-Control-Allow-Methods",
367 allow_methods));
364 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 368 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
365 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 369 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
366} 370}
@@ -372,13 +376,15 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg)
372 struct RequestHandle *handle = cls; 376 struct RequestHandle *handle = cls;
373 struct MHD_Response *resp; 377 struct MHD_Response *resp;
374 378
375 resp = GNUNET_REST_create_response (emsg);
376 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
377 if (GNUNET_OK != success) 379 if (GNUNET_OK != success)
378 { 380 {
379 GNUNET_SCHEDULER_add_now (&do_error, handle); 381 GNUNET_SCHEDULER_add_now (&do_error, handle);
380 return; 382 return;
381 } 383 }
384 resp = GNUNET_REST_create_response (emsg);
385 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
386 "Access-Control-Allow-Methods",
387 allow_methods));
382 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 388 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
383 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 389 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
384} 390}
@@ -399,7 +405,10 @@ return_response (void *cls)
399 result_str = json_dumps (handle->resp_object, 0); 405 result_str = json_dumps (handle->resp_object, 0);
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
401 resp = GNUNET_REST_create_response (result_str); 407 resp = GNUNET_REST_create_response (result_str);
402 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); 408 GNUNET_assert (MHD_NO !=
409 MHD_add_response_header (resp,
410 "Access-Control-Allow-Methods",
411 allow_methods));
403 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 412 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
404 GNUNET_free (result_str); 413 GNUNET_free (result_str);
405 cleanup_handle (handle); 414 cleanup_handle (handle);
@@ -461,8 +470,8 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
461 470
462static void 471static void
463add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, 472add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
464 const char *url, 473 const char *url,
465 void *cls) 474 void *cls)
466{ 475{
467 struct RequestHandle *handle = cls; 476 struct RequestHandle *handle = cls;
468 const struct GNUNET_IDENTITY_PrivateKey *identity_priv; 477 const struct GNUNET_IDENTITY_PrivateKey *identity_priv;
@@ -513,7 +522,15 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
513 handle->rest_handle->data, 522 handle->rest_handle->data,
514 handle->rest_handle->data_size); 523 handle->rest_handle->data_size);
515 data_json = json_loads (term_data, JSON_DECODE_ANY, &err); 524 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
516 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL); 525 if (GNUNET_OK != GNUNET_JSON_parse (data_json, attrspec, NULL, NULL))
526 {
527 json_decref (data_json);
528 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
529 "Unable to parse JSON from %s\n",
530 term_data);
531 GNUNET_SCHEDULER_add_now (&do_error, handle);
532 return;
533 }
517 json_decref (data_json); 534 json_decref (data_json);
518 if (NULL == attribute) 535 if (NULL == attribute)
519 { 536 {
@@ -530,11 +547,11 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
530 GNUNET_RECLAIM_id_generate (&attribute->id); 547 GNUNET_RECLAIM_id_generate (&attribute->id);
531 exp = GNUNET_TIME_UNIT_HOURS; 548 exp = GNUNET_TIME_UNIT_HOURS;
532 handle->idp_op = GNUNET_RECLAIM_credential_store (idp, 549 handle->idp_op = GNUNET_RECLAIM_credential_store (idp,
533 identity_priv, 550 identity_priv,
534 attribute, 551 attribute,
535 &exp, 552 &exp,
536 &finished_cont, 553 &finished_cont,
537 handle); 554 handle);
538 GNUNET_JSON_parse_free (attrspec); 555 GNUNET_JSON_parse_free (attrspec);
539} 556}
540 557
@@ -545,8 +562,8 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
545 */ 562 */
546static void 563static void
547cred_collect (void *cls, 564cred_collect (void *cls,
548 const struct GNUNET_IDENTITY_PublicKey *identity, 565 const struct GNUNET_IDENTITY_PublicKey *identity,
549 const struct GNUNET_RECLAIM_Credential *cred) 566 const struct GNUNET_RECLAIM_Credential *cred)
550{ 567{
551 struct RequestHandle *handle = cls; 568 struct RequestHandle *handle = cls;
552 struct GNUNET_RECLAIM_AttributeList *attrs; 569 struct GNUNET_RECLAIM_AttributeList *attrs;
@@ -565,8 +582,8 @@ cred_collect (void *cls,
565 attrs = GNUNET_RECLAIM_credential_get_attributes (cred); 582 attrs = GNUNET_RECLAIM_credential_get_attributes (cred);
566 issuer = GNUNET_RECLAIM_credential_get_issuer (cred); 583 issuer = GNUNET_RECLAIM_credential_get_issuer (cred);
567 tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type, 584 tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type,
568 cred->data, 585 cred->data,
569 cred->data_size); 586 cred->data_size);
570 cred_obj = json_object (); 587 cred_obj = json_object ();
571 json_object_set_new (cred_obj, "value", json_string (tmp_value)); 588 json_object_set_new (cred_obj, "value", json_string (tmp_value));
572 json_object_set_new (cred_obj, "name", json_string (cred->name)); 589 json_object_set_new (cred_obj, "name", json_string (cred->name));
@@ -578,7 +595,7 @@ cred_collect (void *cls,
578 GNUNET_free (issuer); 595 GNUNET_free (issuer);
579 } 596 }
580 if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred, 597 if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred,
581 &exp)) 598 &exp))
582 { 599 {
583 json_object_set_new (cred_obj, "expiration", json_integer ( 600 json_object_set_new (cred_obj, "expiration", json_integer (
584 exp.abs_value_us)); 601 exp.abs_value_us));
@@ -613,7 +630,8 @@ cred_collect (void *cls,
613 json_object_set_new (cred_obj, "attributes", attr_arr); 630 json_object_set_new (cred_obj, "attributes", attr_arr);
614 } 631 }
615 json_array_append_new (handle->resp_object, cred_obj); 632 json_array_append_new (handle->resp_object, cred_obj);
616 GNUNET_RECLAIM_attribute_list_destroy (attrs); 633 if (NULL != attrs)
634 GNUNET_RECLAIM_attribute_list_destroy (attrs);
617 GNUNET_RECLAIM_get_credentials_next (handle->cred_it); 635 GNUNET_RECLAIM_get_credentials_next (handle->cred_it);
618} 636}
619 637
@@ -627,8 +645,8 @@ cred_collect (void *cls,
627 */ 645 */
628static void 646static void
629list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, 647list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
630 const char *url, 648 const char *url,
631 void *cls) 649 void *cls)
632{ 650{
633 struct RequestHandle *handle = cls; 651 struct RequestHandle *handle = cls;
634 const struct GNUNET_IDENTITY_PrivateKey *priv_key; 652 const struct GNUNET_IDENTITY_PrivateKey *priv_key;
@@ -664,14 +682,14 @@ list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
664 } 682 }
665 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 683 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
666 handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp, 684 handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp,
667 priv_key, 685 priv_key,
668 &collect_error_cb, 686 &collect_error_cb,
669 handle, 687 handle,
670 &cred_collect, 688 &cred_collect,
671 handle, 689 handle,
672 & 690 &
673 collect_finished_cb, 691 collect_finished_cb,
674 handle); 692 handle);
675} 693}
676 694
677 695
@@ -684,8 +702,8 @@ list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
684 */ 702 */
685static void 703static void
686delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, 704delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
687 const char *url, 705 const char *url,
688 void *cls) 706 void *cls)
689{ 707{
690 struct RequestHandle *handle = cls; 708 struct RequestHandle *handle = cls;
691 const struct GNUNET_IDENTITY_PrivateKey *priv_key; 709 const struct GNUNET_IDENTITY_PrivateKey *priv_key;
@@ -734,10 +752,10 @@ delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle,
734 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); 752 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
735 attr.name = ""; 753 attr.name = "";
736 handle->idp_op = GNUNET_RECLAIM_credential_delete (idp, 754 handle->idp_op = GNUNET_RECLAIM_credential_delete (idp,
737 priv_key, 755 priv_key,
738 &attr, 756 &attr,
739 &delete_finished_cb, 757 &delete_finished_cb,
740 handle); 758 handle);
741 GNUNET_free (identity_id_str); 759 GNUNET_free (identity_id_str);
742} 760}
743 761
@@ -900,8 +918,8 @@ parse_jwt (const struct GNUNET_RECLAIM_Credential *cred,
900 json_error_t *json_err = NULL; 918 json_error_t *json_err = NULL;
901 919
902 jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type, 920 jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type,
903 cred->data, 921 cred->data,
904 cred->data_size); 922 cred->data_size);
905 char *jwt_body = strtok (jwt_string, delim); 923 char *jwt_body = strtok (jwt_string, delim);
906 jwt_body = strtok (NULL, delim); 924 jwt_body = strtok (NULL, delim);
907 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), 925 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
@@ -1424,25 +1442,24 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1424 static const struct GNUNET_REST_RequestHandler handlers[] = 1442 static const struct GNUNET_REST_RequestHandler handlers[] =
1425 { { MHD_HTTP_METHOD_GET, 1443 { { MHD_HTTP_METHOD_GET,
1426 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont }, 1444 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont },
1427 { MHD_HTTP_METHOD_POST, 1445 { MHD_HTTP_METHOD_POST,
1428 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &add_attribute_cont }, 1446 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &add_attribute_cont },
1429 { MHD_HTTP_METHOD_DELETE, 1447 { MHD_HTTP_METHOD_DELETE,
1430 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, 1448 GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont },
1431 { MHD_HTTP_METHOD_GET, 1449 { MHD_HTTP_METHOD_GET,
1432 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont }, 1450 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont },
1433 { MHD_HTTP_METHOD_POST, 1451 { MHD_HTTP_METHOD_POST,
1434 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont }, 1452 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont },
1435 { MHD_HTTP_METHOD_DELETE, 1453 { MHD_HTTP_METHOD_DELETE,
1436 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont }, 1454 GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont },
1437 { MHD_HTTP_METHOD_GET, 1455 { MHD_HTTP_METHOD_GET,
1438 GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, 1456 GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont },
1439 { MHD_HTTP_METHOD_POST, 1457 { MHD_HTTP_METHOD_POST,
1440 GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont }, 1458 GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont },
1441 { MHD_HTTP_METHOD_POST, 1459 { MHD_HTTP_METHOD_POST,
1442 GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont }, 1460 GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont },
1443 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont }, 1461 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1444 GNUNET_REST_HANDLER_END 1462 GNUNET_REST_HANDLER_END};
1445 };
1446 1463
1447 handle->response_code = 0; 1464 handle->response_code = 0;
1448 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1465 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index f4f2b946a..c08cc868c 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -651,18 +651,15 @@ handle_consume_ticket_result (void *cls,
651 le->attribute, NULL); 651 le->attribute, NULL);
652 } 652 }
653 } 653 }
654 if (NULL != attrs)
655 GNUNET_RECLAIM_attribute_list_destroy (attrs);
656 if (NULL != pl)
657 GNUNET_RECLAIM_presentation_list_destroy (pl);
658 attrs = NULL;
659 pl = NULL;
660 } 654 }
661 op->atr_cb (op->cls, NULL, NULL, NULL); 655 op->atr_cb (op->cls, NULL, NULL, NULL);
662 } 656 }
657 if (NULL != attrs)
658 GNUNET_RECLAIM_attribute_list_destroy (attrs);
659 if (NULL != pl)
660 GNUNET_RECLAIM_presentation_list_destroy (pl);
663 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); 661 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
664 free_op (op); 662 free_op (op);
665 GNUNET_free (attrs);
666 return; 663 return;
667 } 664 }
668 GNUNET_assert (0); 665 GNUNET_assert (0);
@@ -804,7 +801,7 @@ check_credential_result (void *cls, const struct CredentialResultMessage *msg)
804 */ 801 */
805static void 802static void
806handle_credential_result (void *cls, const struct 803handle_credential_result (void *cls, const struct
807 CredentialResultMessage *msg) 804 CredentialResultMessage *msg)
808{ 805{
809 static struct GNUNET_IDENTITY_PrivateKey identity_dummy; 806 static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
810 struct GNUNET_RECLAIM_Handle *h = cls; 807 struct GNUNET_RECLAIM_Handle *h = cls;
@@ -871,6 +868,7 @@ handle_credential_result (void *cls, const struct
871 GNUNET_assert (0); 868 GNUNET_assert (0);
872} 869}
873 870
871
874/** 872/**
875 * Handle an incoming message of type 873 * Handle an incoming message of type
876 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT 874 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
@@ -925,7 +923,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
925 if (NULL != op) 923 if (NULL != op)
926 { 924 {
927 if (0 < pres_len) 925 if (0 < pres_len)
928 pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1], 926 pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*) &msg[1],
929 pres_len); 927 pres_len);
930 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); 928 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
931 if (0 == 929 if (0 ==
@@ -1485,7 +1483,7 @@ GNUNET_RECLAIM_get_credentials_start (
1485 */ 1483 */
1486void 1484void
1487GNUNET_RECLAIM_get_credentials_next (struct 1485GNUNET_RECLAIM_get_credentials_next (struct
1488 GNUNET_RECLAIM_CredentialIterator *ait) 1486 GNUNET_RECLAIM_CredentialIterator *ait)
1489{ 1487{
1490 struct GNUNET_RECLAIM_Handle *h = ait->h; 1488 struct GNUNET_RECLAIM_Handle *h = ait->h;
1491 struct CredentialIterationNextMessage *msg; 1489 struct CredentialIterationNextMessage *msg;
@@ -1507,7 +1505,7 @@ GNUNET_RECLAIM_get_credentials_next (struct
1507 */ 1505 */
1508void 1506void
1509GNUNET_RECLAIM_get_credentials_stop (struct 1507GNUNET_RECLAIM_get_credentials_stop (struct
1510 GNUNET_RECLAIM_CredentialIterator *ait) 1508 GNUNET_RECLAIM_CredentialIterator *ait)
1511{ 1509{
1512 struct GNUNET_RECLAIM_Handle *h = ait->h; 1510 struct GNUNET_RECLAIM_Handle *h = ait->h;
1513 struct GNUNET_MQ_Envelope *env; 1511 struct GNUNET_MQ_Envelope *env;
diff --git a/src/rest/plugin_rest_copying.c b/src/rest/plugin_rest_copying.c
index 6d074d3d1..52783a81a 100644
--- a/src/rest/plugin_rest_copying.c
+++ b/src/rest/plugin_rest_copying.c
@@ -138,9 +138,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
138 struct RequestHandle *handle = cls; 138 struct RequestHandle *handle = cls;
139 139
140 resp = GNUNET_REST_create_response (NULL); 140 resp = GNUNET_REST_create_response (NULL);
141 MHD_add_response_header (resp, 141 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
142 "Access-Control-Allow-Methods", 142 "Access-Control-Allow-Methods",
143 MHD_HTTP_METHOD_GET); 143 MHD_HTTP_METHOD_GET));
144 handle->proc (handle->proc_cls, 144 handle->proc (handle->proc_cls,
145 resp, 145 resp,
146 MHD_HTTP_OK); 146 MHD_HTTP_OK);
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c
index b5737158b..99fecdd35 100644
--- a/src/revocation/gnunet-revocation.c
+++ b/src/revocation/gnunet-revocation.c
@@ -307,17 +307,9 @@ calculate_pow (void *cls)
307 return; 307 return;
308 } 308 }
309 pow_passes++; 309 pow_passes++;
310 /** 310 pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
311 * Otherwise CTRL-C does not work 311 &calculate_pow,
312 */ 312 ph);
313 if (0 == pow_passes % 128)
314 pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
315 &calculate_pow,
316 ph);
317 else
318 pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
319 &calculate_pow,
320 ph);
321 313
322} 314}
323 315
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index 863289aae..6f70720ba 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -306,12 +306,19 @@ publicize_rm (const struct RevokeMessage *rm)
306 struct RevokeMessage *cp; 306 struct RevokeMessage *cp;
307 struct GNUNET_HashCode hc; 307 struct GNUNET_HashCode hc;
308 struct GNUNET_SETU_Element e; 308 struct GNUNET_SETU_Element e;
309 ssize_t pklen;
309 const struct GNUNET_IDENTITY_PublicKey *pk; 310 const struct GNUNET_IDENTITY_PublicKey *pk;
310 311
311 struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; 312 struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1];
312 pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; 313 pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
314 pklen = GNUNET_IDENTITY_key_get_length (pk);
315 if (0 > pklen)
316 {
317 GNUNET_break_op (0);
318 return GNUNET_SYSERR;
319 }
313 GNUNET_CRYPTO_hash (pk, 320 GNUNET_CRYPTO_hash (pk,
314 GNUNET_IDENTITY_key_get_length (pk), 321 pklen,
315 &hc); 322 &hc);
316 if (GNUNET_YES == 323 if (GNUNET_YES ==
317 GNUNET_CONTAINER_multihashmap_contains (revocation_map, 324 GNUNET_CONTAINER_multihashmap_contains (revocation_map,
@@ -384,7 +391,8 @@ check_revoke_message (void *cls,
384 uint16_t size; 391 uint16_t size;
385 392
386 size = ntohs (rm->header.size); 393 size = ntohs (rm->header.size);
387 if (size <= sizeof(struct RevokeMessage)) 394 if (size <= sizeof(struct RevokeMessage) ||
395 (size > UINT16_MAX))
388 { 396 {
389 GNUNET_break (0); 397 GNUNET_break (0);
390 return GNUNET_SYSERR; 398 return GNUNET_SYSERR;
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c
index 3c9344a49..1928d09cd 100644
--- a/src/revocation/plugin_block_revocation.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -134,6 +134,7 @@ block_plugin_revocation_evaluate (void *cls,
134{ 134{
135 struct InternalContext *ic = cls; 135 struct InternalContext *ic = cls;
136 struct GNUNET_HashCode chash; 136 struct GNUNET_HashCode chash;
137 ssize_t pklen;
137 const struct RevokeMessage *rm = reply_block; 138 const struct RevokeMessage *rm = reply_block;
138 139
139 if (NULL == reply_block) 140 if (NULL == reply_block)
@@ -153,8 +154,14 @@ block_plugin_revocation_evaluate (void *cls,
153 GNUNET_break_op (0); 154 GNUNET_break_op (0);
154 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 155 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
155 } 156 }
157 pklen = GNUNET_IDENTITY_key_get_length (pk);
158 if (0 > pklen)
159 {
160 GNUNET_break_op (0);
161 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
162 }
156 GNUNET_CRYPTO_hash (pk, 163 GNUNET_CRYPTO_hash (pk,
157 GNUNET_IDENTITY_key_get_length (pk), 164 pklen,
158 &chash); 165 &chash);
159 if (GNUNET_YES == 166 if (GNUNET_YES ==
160 GNUNET_BLOCK_GROUP_bf_test_and_set (group, 167 GNUNET_BLOCK_GROUP_bf_test_and_set (group,
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index 5cf191847..e2f871c23 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -492,6 +492,7 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
492 unsigned int tmp_score = 0; 492 unsigned int tmp_score = 0;
493 unsigned int epochs; 493 unsigned int epochs;
494 uint64_t pow_val; 494 uint64_t pow_val;
495 ssize_t pklen;
495 const struct GNUNET_IDENTITY_PublicKey *pk; 496 const struct GNUNET_IDENTITY_PublicKey *pk;
496 497
497 pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; 498 pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
@@ -517,9 +518,15 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow,
517 GNUNET_memcpy (&buf[sizeof(uint64_t)], 518 GNUNET_memcpy (&buf[sizeof(uint64_t)],
518 &pow->timestamp, 519 &pow->timestamp,
519 sizeof (uint64_t)); 520 sizeof (uint64_t));
521 pklen = GNUNET_IDENTITY_key_get_length (pk);
522 if (0 > pklen)
523 {
524 GNUNET_break (0);
525 return GNUNET_NO;
526 }
520 GNUNET_memcpy (&buf[sizeof(uint64_t) * 2], 527 GNUNET_memcpy (&buf[sizeof(uint64_t) * 2],
521 pk, 528 pk,
522 GNUNET_IDENTITY_key_get_length (pk)); 529 pklen);
523 for (unsigned int i = 0; i < POW_COUNT; i++) 530 for (unsigned int i = 0; i < POW_COUNT; i++)
524 { 531 {
525 pow_val = GNUNET_ntohll (pow->pow[i]); 532 pow_val = GNUNET_ntohll (pow->pow[i]);
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 82aeffb79..908dcca17 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -3067,9 +3067,10 @@ run (void *cls,
3067 } 3067 }
3068 else 3068 else
3069 { 3069 {
3070 duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3070 duration = GNUNET_TIME_relative_multiply (
3071 (timeout.rel_value_us / 1000000) 3071 GNUNET_TIME_UNIT_SECONDS,
3072 * 0.75); 3072 ( (double) timeout.rel_value_us / (double) 1000000)
3073 * 0.75);
3073 } 3074 }
3074 } 3075 }
3075 else 3076 else
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index dc4c5dab7..56eab288e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -965,8 +965,6 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx)
965 channel_ctx->destruction_task = NULL; 965 channel_ctx->destruction_task = NULL;
966 } 966 }
967 967
968 GNUNET_free (channel_ctx);
969
970 if (NULL == peer_ctx) 968 if (NULL == peer_ctx)
971 return; 969 return;
972 if (channel_ctx == peer_ctx->send_channel_ctx) 970 if (channel_ctx == peer_ctx->send_channel_ctx)
@@ -978,6 +976,7 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx)
978 { 976 {
979 peer_ctx->recv_channel_ctx = NULL; 977 peer_ctx->recv_channel_ctx = NULL;
980 } 978 }
979 GNUNET_free (channel_ctx);
981} 980}
982 981
983 982
@@ -2637,7 +2636,7 @@ insert_in_sampler (void *cls,
2637 } 2636 }
2638#ifdef TO_FILE 2637#ifdef TO_FILE
2639 sub->num_observed_peers++; 2638 sub->num_observed_peers++;
2640 GNUNET_CONTAINER_multipeermap_put 2639 (void) GNUNET_CONTAINER_multipeermap_put
2641 (sub->observed_unique_peers, 2640 (sub->observed_unique_peers,
2642 peer, 2641 peer,
2643 NULL, 2642 NULL,
@@ -2802,7 +2801,7 @@ clean_peer (struct Sub *sub,
2802 peer))) && 2801 peer))) &&
2803 (GNUNET_NO == View_contains_peer (sub->view, peer)) && 2802 (GNUNET_NO == View_contains_peer (sub->view, peer)) &&
2804 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) && 2803 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) &&
2805 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) && 2804 (GNUNET_NO == CustomPeerMap_contains_peer (sub->pull_map, peer)) &&
2806 (0 == RPS_sampler_count_id (sub->sampler, peer)) && 2805 (0 == RPS_sampler_count_id (sub->sampler, peer)) &&
2807 (GNUNET_YES == check_removable (get_peer_ctx (sub->peer_map, peer)))) 2806 (GNUNET_YES == check_removable (get_peer_ctx (sub->peer_map, peer))))
2808 { /* We can safely remove this peer */ 2807 { /* We can safely remove this peer */
@@ -2836,13 +2835,20 @@ cleanup_destroyed_channel (void *cls,
2836 (void) channel; 2835 (void) channel;
2837 2836
2838 channel_ctx->channel = NULL; 2837 channel_ctx->channel = NULL;
2839 remove_channel_ctx (channel_ctx);
2840 if ((NULL != peer_ctx) && 2838 if ((NULL != peer_ctx) &&
2841 (peer_ctx->send_channel_ctx == channel_ctx) && 2839 (peer_ctx->send_channel_ctx == channel_ctx) &&
2842 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) ) 2840 (GNUNET_YES == check_sending_channel_needed (peer_ctx)) )
2843 { 2841 {
2842 remove_channel_ctx (channel_ctx);
2844 remove_peer (peer_ctx->sub, &peer_ctx->peer_id); 2843 remove_peer (peer_ctx->sub, &peer_ctx->peer_id);
2845 } 2844 }
2845 else
2846 {
2847 /* We need this if-else construct because we need to make sure the channel
2848 * (context) is cleaned up before removing the peer, but still neet to
2849 * compare it while checking the condition */
2850 remove_channel_ctx (channel_ctx);
2851 }
2846} 2852}
2847 2853
2848 2854
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 54e361d32..392c29397 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -206,6 +206,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
206 struct GNUNET_PeerIdentity *p; 206 struct GNUNET_PeerIdentity *p;
207 uint32_t *last_index; 207 uint32_t *last_index;
208 struct GNUNET_PeerIdentity *last_p; 208 struct GNUNET_PeerIdentity *last_p;
209 int ret;
209 210
210 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map, 211 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map,
211 peer)) 212 peer))
@@ -234,9 +235,11 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
234 last_p); 235 last_p);
235 GNUNET_assert (NULL != last_index); 236 GNUNET_assert (NULL != last_index);
236 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); 237 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index);
237 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, 238 ret = GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
238 *index, last_p, 239 *index,
239 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 240 last_p,
241 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
242 GNUNET_assert (GNUNET_OK == ret);
240 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, 243 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
241 *last_index); 244 *last_index);
242 *last_index = *index; 245 *last_index = *index;
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 497225973..6dee20c95 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -152,12 +152,16 @@ close_all_files ()
152{ 152{
153 int ret; 153 int ret;
154 154
155 ret = GNUNET_CONTAINER_multihashmap_iterate (open_files, 155 if (NULL != open_files)
156 close_files_iter, 156 {
157 NULL); 157 ret = GNUNET_CONTAINER_multihashmap_iterate (open_files,
158 GNUNET_CONTAINER_multihashmap_destroy (open_files); 158 close_files_iter,
159 open_files = NULL; 159 NULL);
160 return ret; 160 GNUNET_CONTAINER_multihashmap_destroy (open_files);
161 open_files = NULL;
162 return ret;
163 }
164 return GNUNET_YES;
161} 165}
162 166
163 167
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 7c1e217bb..7a59670cb 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -94,6 +94,9 @@ lib_LTLIBRARIES = \
94libgnunettestbed_la_SOURCES = \ 94libgnunettestbed_la_SOURCES = \
95 testbed_api.c testbed_api.h testbed.h \ 95 testbed_api.c testbed_api.h testbed.h \
96 testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \ 96 testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \
97 testbed_api_cmd_controller.c \
98 testbed_api_cmd_peer.c \
99 testbed_api_cmd_service.c \
97 testbed_api_operations.c testbed_api_operations.h \ 100 testbed_api_operations.c testbed_api_operations.h \
98 testbed_api_peers.c testbed_api_peers.h \ 101 testbed_api_peers.c testbed_api_peers.h \
99 testbed_api_services.c \ 102 testbed_api_services.c \
diff --git a/src/testbed/testbed_api_cmd_controller.c b/src/testbed/testbed_api_cmd_controller.c
new file mode 100644
index 000000000..d65f41760
--- /dev/null
+++ b/src/testbed/testbed_api_cmd_controller.c
@@ -0,0 +1,294 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testbed/testbed_api_cmd_controller.c
23 * @brief Command to create a controller.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet-service-testbed.h"
30#include "testbed_api_hosts.h"
31#include "gnunet_testbed_ng_service.h"
32
33
34/**
35 * Generic logging shortcut
36 */
37#define LOG(kind, ...) \
38 GNUNET_log (kind, __VA_ARGS__)
39
40
41/**
42 * abort task to run on test timed out
43 *
44 * @param cls NULL
45 * @param tc the task context
46 */
47static void
48do_abort (void *cls)
49{
50 struct ControllerState *cs = cls;
51
52 if (GNUNET_NO == cs->host_ready)
53 {
54 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
55 cs->abort_task = NULL;
56 GNUNET_TESTBED_shutdown_controller (cs);
57 }
58}
59
60
61/**
62*
63*
64* @param cls closure
65* @param cmd current CMD being cleaned up.
66*/
67static void
68controller_cleanup (void *cls,
69 const struct GNUNET_TESTING_Command *cmd)
70{
71 (void) cls;
72}
73
74
75/**
76 * Signature of the event handler function called by the
77 * respective event controller.
78 *
79 * @param cls closure
80 * @param event information about the event
81 */
82static void
83controller_cb (void *cls,
84 const struct GNUNET_TESTBED_EventInformation *event)
85{
86 struct ControllerState *cs = cls;
87
88 if (NULL != event->details.operation_finished.emsg)
89 {
90 LOG (GNUNET_ERROR_TYPE_ERROR, "There was an operation error: %s\n",
91 event->details.operation_finished.emsg);
92 GNUNET_TESTBED_shutdown_controller (cs);
93 }
94 else if (NULL == event->details.operation_finished.generic)
95 {
96 GNUNET_TESTBED_operation_done (event->op);
97 }
98}
99
100
101/**
102 * Callback which will be called to after a host registration succeeded or failed
103 *
104 * @param cls the host which has been registered
105 * @param emsg the error message; NULL if host registration is successful
106 */
107static void
108registration_comp (void *cls,
109 const char *emsg)
110{
111 struct ControllerState *cs = cls;
112
113 if (NULL != emsg)
114 {
115 LOG (GNUNET_ERROR_TYPE_ERROR,
116 "There was an error during host registration: %s\n",
117 emsg);
118 GNUNET_TESTBED_shutdown_controller (cs);
119 }
120 else
121 {
122 cs->reg_handle = NULL;
123 cs->host_ready = GNUNET_YES;
124 GNUNET_TESTING_interpreter_next (cs->is);
125 }
126}
127
128
129/**
130 * Callback to signal successfull startup of the controller process
131 *
132 * @param cls the closure from GNUNET_TESTBED_controller_start()
133 * @param cfg the configuration with which the controller has been started;
134 * NULL if status is not #GNUNET_OK
135 * @param status #GNUNET_OK if the startup is successfull; #GNUNET_SYSERR if not,
136 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
137 */
138static void
139controller_status_cb (void *cls,
140 const struct GNUNET_CONFIGURATION_Handle *cfg_,
141 int status)
142{
143 struct ControllerState *cs = cls;
144
145 if (GNUNET_OK != status)
146 {
147 cs->cp = NULL;
148 return;
149 }
150
151 cs->controller =
152 GNUNET_TESTBED_controller_connect (cs->host, cs->event_mask, &controller_cb,
153 cs);
154 cs->reg_handle =
155 GNUNET_TESTBED_register_host (cs->controller, cs->host, &registration_comp,
156 cs);
157}
158
159
160static void
161controller_run (void *cls,
162 const struct GNUNET_TESTING_Command *cmd,
163 struct GNUNET_TESTING_Interpreter *is)
164{
165 struct ControllerState *cs = cls;
166
167 cs->is = is;
168 cs->host = GNUNET_TESTBED_host_create (cs->hostname, cs->username, cs->cfg,
169 cs->port);
170 cs->cp = GNUNET_TESTBED_controller_start (cs->trusted_ip,
171 cs->host,
172 &controller_status_cb,
173 cs);
174 cs->abort_task =
175 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
176 (GNUNET_TIME_UNIT_MINUTES, 5),
177 &do_abort,
178 cs);
179}
180
181/**
182*
183*
184* @param cls closure.
185* @param[out] ret result
186* @param trait name of the trait.
187* @param index index number of the object to offer.
188* @return #GNUNET_OK on success.
189*/
190static int
191controller_traits (void *cls,
192 const void **ret,
193 const char *trait,
194 unsigned int index)
195{
196 (void) cls;
197
198 struct ControllerState *cs = cls;
199
200
201 struct GNUNET_TESTING_Trait traits[] = {
202 {
203 .index = 0,
204 .trait_name = "controller",
205 .ptr = (const void *) cs->controller,
206 },
207 GNUNET_TESTING_trait_end ()
208 };
209
210 return GNUNET_TESTING_get_trait (traits,
211 ret,
212 trait,
213 index);
214 return GNUNET_OK;
215}
216
217
218/**
219 * Offer data from trait
220 *
221 * @param cmd command to extract the controller from.
222 * @param pt pointer to controller.
223 * @return #GNUNET_OK on success.
224 */
225int
226GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd,
227 struct GNUNET_TESTBED_Controller **
228 controller)
229{
230 return cmd->traits (cmd->cls,
231 (const void **) controller,
232 "controller",
233 (unsigned int) 0);
234}
235
236
237/**
238 * Shutdown nicely
239 *
240 * @param cs controller state.
241 */
242void
243GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs)
244{
245 LOG (GNUNET_ERROR_TYPE_DEBUG,
246 "Shutting down...\n");
247
248 cs->controller_going_down = GNUNET_YES;
249
250 if (NULL != cs->abort_task)
251 GNUNET_SCHEDULER_cancel (cs->abort_task);
252 if (NULL != cs->reg_handle)
253 GNUNET_TESTBED_cancel_registration (cs->reg_handle);
254 if (NULL != cs->controller)
255 GNUNET_TESTBED_controller_disconnect (cs->controller);
256 if (NULL != cs->cfg)
257 GNUNET_CONFIGURATION_destroy (cs->cfg);
258 if (NULL != cs->cp)
259 GNUNET_TESTBED_controller_stop (cs->cp);
260 if (NULL != cs->host)
261 GNUNET_TESTBED_host_destroy (cs->host);
262}
263
264
265
266struct GNUNET_TESTING_Command
267GNUNET_TESTBED_cmd_controller (const char *label,
268 const char *trusted_ip,
269 const char *hostname,
270 const char *username,
271 uint16_t port,
272 struct GNUNET_CONFIGURATION_Handle *cfg,
273 uint64_t event_mask)
274{
275 struct ControllerState *cs;
276
277 cs = GNUNET_new (struct ControllerState);
278 cs->event_mask = event_mask;
279 cs->trusted_ip = trusted_ip;
280 cs->hostname = hostname;
281 cs->username = username;
282 cs->port = port;
283 cs->cfg = cfg;
284
285 struct GNUNET_TESTING_Command cmd = {
286 .cls = cs,
287 .label = label,
288 .run = &controller_run,
289 .cleanup = &controller_cleanup,
290 .traits = &controller_traits
291 };
292
293 return cmd;
294}
diff --git a/src/testbed/testbed_api_cmd_peer.c b/src/testbed/testbed_api_cmd_peer.c
new file mode 100644
index 000000000..4a727bc94
--- /dev/null
+++ b/src/testbed/testbed_api_cmd_peer.c
@@ -0,0 +1,249 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21
22/**
23 * @file testbed/testbed_api_cmd_controller.c
24 * @brief Command to create a controller.
25 * @author t3sserakt
26 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_testing_ng_lib.h"
30#include "gnunet_testbed_ng_service.h"
31#include "gnunet-service-testbed.h"
32#include "testbed_api_peers.h"
33
34
35/**
36 * Generic logging shortcut
37 */
38#define LOG(kind, ...) \
39 GNUNET_log (kind, __VA_ARGS__)
40
41
42/**
43*
44*
45* @param cls closure.
46* @param[out] ret result
47* @param trait name of the trait.
48* @param index index number of the object to offer.
49* @return #GNUNET_OK on success.
50*/
51static int
52peer_traits (void *cls,
53 const void **ret,
54 const char *trait,
55 unsigned int index)
56{
57 (void) cls;
58 return GNUNET_OK;
59}
60
61
62/**
63*
64*
65* @param cls closure
66* @param cmd current CMD being cleaned up.
67*/
68static void
69peer_cleanup (void *cls,
70 const struct GNUNET_TESTING_Command *cmd)
71{
72 (void) cls;
73}
74
75
76/**
77 * abort task to run on test timed out
78 *
79 * @param cls NULL
80 * @param tc the task context
81 */
82static void
83do_abort (void *cls)
84{
85 struct PeerCmdState *ps = cls;
86
87 if (GNUNET_NO == ps->peer_ready)
88 {
89 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
90 ps->abort_task = NULL;
91 GNUNET_TESTBED_shutdown_peer (ps);
92 }
93}
94
95
96/**
97 * Functions of this signature are called when a peer has been successfully
98 * created
99 *
100 * @param cls the closure from GNUNET_TESTBED_peer_create()
101 * @param emsg MAY contain an error description, if starting peer failed.
102 */
103static void
104peer_started_cb (void *cls,
105 const char *emsg)
106{
107 struct PeerCmdState *ps = cls;
108
109 GNUNET_TESTBED_operation_done (ps->operation);
110 if (NULL == emsg)
111 {
112 ps->peer_ready = GNUNET_YES;
113 GNUNET_TESTING_interpreter_next (ps->is);
114 }
115 else
116 {
117 LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error starting a peer: %s\n",
118 emsg);
119 }
120
121}
122
123
124/**
125 * Functions of this signature are called when a peer has been successfully
126 * created
127 *
128 * @param cls the closure from GNUNET_TESTBED_peer_create()
129 * @param peer the handle for the created peer; NULL on any error during
130 * creation
131 * @param emsg NULL if peer is not NULL; else MAY contain the error description
132 */
133static void
134peer_create_cb (void *cls,
135 struct GNUNET_TESTBED_Peer *peer,
136 const char *emsg)
137{
138 struct PeerCmdState *ps = cls;
139
140 ps->peer = peer;
141 GNUNET_TESTBED_operation_done (ps->operation);
142 ps->operation = GNUNET_TESTBED_peer_start (NULL,
143 peer,
144 &peer_started_cb,
145 ps);
146}
147
148
149static void
150peer_run (void *cls,
151 const struct GNUNET_TESTING_Command *cmd,
152 struct GNUNET_TESTING_Interpreter *is)
153{
154 struct PeerCmdState *ps = cls;
155 const struct GNUNET_TESTING_Command *controller_cmd;
156 struct GNUNET_TESTBED_Controller *controller;
157
158 ps->is = is;
159 controller_cmd = GNUNET_TESTING_interpreter_lookup_command (
160 ps->controller_label);
161 GNUNET_TESTBED_get_trait_controller (controller_cmd,
162 &controller);
163 ps->host = GNUNET_TESTBED_host_create (ps->hostname, ps->username, ps->cfg,
164 ps->port);
165 ps->operation =
166 GNUNET_TESTBED_peer_create (controller,
167 ps->host,
168 ps->cfg,
169 &peer_create_cb,
170 ps);
171
172 ps->abort_task =
173 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
174 (GNUNET_TIME_UNIT_MINUTES, 5),
175 &do_abort,
176 ps);
177}
178
179
180void
181peer_stopped_cb (void *cls,
182 const char *emsg)
183{
184 struct PeerCmdState *ps = cls;
185
186 if (NULL != emsg)
187 {
188 LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error stopping a peer: %s\n",
189 emsg);
190 }
191 GNUNET_TESTBED_operation_done (ps->operation);
192 GNUNET_TESTBED_peer_destroy (ps->peer);
193}
194
195
196/**
197 * Shutdown nicely
198 *
199 * @param cs controller state.
200 */
201void
202GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps)
203{
204 LOG (GNUNET_ERROR_TYPE_DEBUG,
205 "Shutting down...\n");
206
207 ps->peer_going_down = GNUNET_YES;
208
209 if (NULL != ps->abort_task)
210 GNUNET_SCHEDULER_cancel (ps->abort_task);
211 if (NULL != ps->cfg)
212 GNUNET_CONFIGURATION_destroy (ps->cfg);
213 if (NULL != ps->host)
214 GNUNET_TESTBED_host_destroy (ps->host);
215
216 GNUNET_TESTBED_operation_done (ps->operation);
217 ps->operation = GNUNET_TESTBED_peer_stop (NULL, ps->peer, peer_stopped_cb,
218 ps);
219
220}
221
222
223struct GNUNET_TESTING_Command
224GNUNET_TESTBED_cmd_peer (const char *label,
225 const char *controller_label,
226 const char *hostname,
227 const char *username,
228 uint16_t port,
229 struct GNUNET_CONFIGURATION_Handle *cfg)
230{
231 struct PeerCmdState *ps;
232
233 ps = GNUNET_new (struct PeerCmdState);
234 ps->hostname = hostname;
235 ps->username = username;
236 ps->port = port;
237 ps->cfg = cfg;
238 ps->controller_label = controller_label;
239
240 struct GNUNET_TESTING_Command cmd = {
241 .cls = ps,
242 .label = label,
243 .run = &peer_run,
244 .cleanup = &peer_cleanup,
245 .traits = &peer_traits
246 };
247
248 return cmd;
249}
diff --git a/src/testbed/testbed_api_cmd_service.c b/src/testbed/testbed_api_cmd_service.c
new file mode 100644
index 000000000..58b3309de
--- /dev/null
+++ b/src/testbed/testbed_api_cmd_service.c
@@ -0,0 +1,140 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testbed/testbed_api_cmd_controller.c
23 * @brief Command to create a controller.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet-service-testbed.h"
30#include "testbed_api_hosts.h"
31#include "gnunet_testbed_ng_service.h"
32
33/**
34 * Generic logging shortcut
35 */
36#define LOG(kind, ...) \
37 GNUNET_log (kind, __VA_ARGS__)
38
39
40/**
41 * abort task to run on test timed out
42 *
43 * @param cls NULL
44 * @param tc the task context
45 */
46static void
47do_abort (void *cls)
48{
49 struct ServiceState *ss = cls;
50
51 if (GNUNET_NO == ss->service_ready)
52 {
53 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
54 ss->abort_task = NULL;
55 GNUNET_TESTBED_shutdown_service (ss);
56 }
57}
58
59/**
60*
61*
62* @param cls closure
63* @param cmd current CMD being cleaned up.
64*/
65static void
66service_cleanup (void *cls,
67 const struct GNUNET_TESTING_Command *cmd)
68{
69 (void) cls;
70}
71
72/**
73*
74*
75* @param cls closure.
76* @param[out] ret result
77* @param trait name of the trait.
78* @param index index number of the object to offer.
79* @return #GNUNET_OK on success.
80*/
81static int
82service_traits (void *cls,
83 const void **ret,
84 const char *trait,
85 unsigned int index)
86{
87 (void) cls;
88 return GNUNET_OK;
89}
90
91static void
92service_run (void *cls,
93 const struct GNUNET_TESTING_Command *cmd,
94 struct GNUNET_TESTING_Interpreter *is)
95{
96 struct ServiceState *ss = cls;
97
98 // TODO this is unfinished code!
99 ss->operation =
100 GNUNET_TESTBED_service_connect (NULL, NULL, NULL,
101 NULL, NULL,
102 NULL,
103 NULL, NULL);
104
105}
106
107/**
108 * Shutdown nicely
109 *
110 * @param cs service state.
111 */
112void
113GNUNET_TESTBED_shutdown_service (struct ServiceState *cs)
114{
115 LOG (GNUNET_ERROR_TYPE_DEBUG,
116 "Shutting down...\n");
117}
118
119
120struct GNUNET_TESTING_Command
121GNUNET_TESTBED_cmd_service (const char *label,
122 const char *peer_label,
123 const char *servicename)
124{
125 struct ServiceState *ss;
126
127 ss = GNUNET_new (struct ServiceState);
128 ss->servicename = servicename;
129 ss->peer_label = peer_label;
130
131 struct GNUNET_TESTING_Command cmd = {
132 .cls = ss,
133 .label = label,
134 .run = &service_run,
135 .cleanup = &service_cleanup,
136 .traits = &service_traits
137 };
138
139 return cmd;
140}
diff --git a/src/testing/testing_api_cmd_hello_world_birth.c b/src/testing/testing_api_cmd_hello_world_birth.c
index 546b30212..0faf93cd8 100644
--- a/src/testing/testing_api_cmd_hello_world_birth.c
+++ b/src/testing/testing_api_cmd_hello_world_birth.c
@@ -118,10 +118,8 @@ hello_world_birth_run (void *cls,
118/** 118/**
119 * Offer data from trait 119 * Offer data from trait
120 * 120 *
121 * @param cmd command to extract the url from. 121 * @param cmd command to extract the message from.
122 * @param pt which url is to be picked, in case 122 * @param pt pointer to message.
123 * multiple are offered.
124 * @param[out] url where to write the url.
125 * @return #GNUNET_OK on success. 123 * @return #GNUNET_OK on success.
126 */ 124 */
127int 125int
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index c8a4c0375..9dd2797df 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -877,12 +877,14 @@ queue_destroy (struct Queue *queue)
877{ 877{
878 struct ListenTask *lt = NULL; 878 struct ListenTask *lt = NULL;
879 struct GNUNET_HashCode h_sock; 879 struct GNUNET_HashCode h_sock;
880 int sockfd;
880 881
881 GNUNET_CRYPTO_hash (queue->listen_sock, 882 sockfd = GNUNET_NETWORK_get_fd (queue->listen_sock);
882 sizeof(queue->listen_sock), 883 GNUNET_CRYPTO_hash (&sockfd,
884 sizeof(int),
883 &h_sock); 885 &h_sock);
884 886
885 lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock); 887 lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
886 888
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
888 "Disconnecting queue for peer `%s'\n", 890 "Disconnecting queue for peer `%s'\n",
@@ -1263,7 +1265,8 @@ rekey_monotime_cb (void *cls,
1263 pid, 1265 pid,
1264 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, 1266 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY,
1265 rekey_monotonic_time, 1267 rekey_monotonic_time,
1266 sizeof(rekey_monotonic_time), 1268 sizeof(*
1269 rekey_monotonic_time),
1267 GNUNET_TIME_UNIT_FOREVER_ABS, 1270 GNUNET_TIME_UNIT_FOREVER_ABS,
1268 GNUNET_PEERSTORE_STOREOPTION_REPLACE, 1271 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
1269 &rekey_monotime_store_cb, 1272 &rekey_monotime_store_cb,
@@ -1413,18 +1416,18 @@ handshake_ack_monotime_cb (void *cls,
1413 queue_finish (queue); 1416 queue_finish (queue);
1414 return; 1417 return;
1415 } 1418 }
1416 queue->handshake_ack_monotime_sc = GNUNET_PEERSTORE_store (peerstore, 1419 queue->handshake_ack_monotime_sc =
1417 "transport_tcp_communicator", 1420 GNUNET_PEERSTORE_store (peerstore,
1418 pid, 1421 "transport_tcp_communicator",
1419 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK, 1422 pid,
1420 handshake_ack_monotonic_time, 1423 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK,
1421 sizeof( 1424 handshake_ack_monotonic_time,
1422 handshake_ack_monotonic_time), 1425 sizeof(*handshake_ack_monotonic_time),
1423 GNUNET_TIME_UNIT_FOREVER_ABS, 1426 GNUNET_TIME_UNIT_FOREVER_ABS,
1424 GNUNET_PEERSTORE_STOREOPTION_REPLACE, 1427 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
1425 & 1428 &
1426 handshake_ack_monotime_store_cb, 1429 handshake_ack_monotime_store_cb,
1427 queue); 1430 queue);
1428} 1431}
1429 1432
1430 1433
@@ -3255,6 +3258,7 @@ init_socket (struct sockaddr *addr,
3255 socklen_t sto_len; 3258 socklen_t sto_len;
3256 struct GNUNET_NETWORK_Handle *listen_sock; 3259 struct GNUNET_NETWORK_Handle *listen_sock;
3257 struct ListenTask *lt; 3260 struct ListenTask *lt;
3261 int sockfd;
3258 struct GNUNET_HashCode h_sock; 3262 struct GNUNET_HashCode h_sock;
3259 3263
3260 if (NULL == addr) 3264 if (NULL == addr)
@@ -3343,8 +3347,9 @@ init_socket (struct sockaddr *addr,
3343 3347
3344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3345 "creating hash\n"); 3349 "creating hash\n");
3346 GNUNET_CRYPTO_hash (lt->listen_sock, 3350 sockfd = GNUNET_NETWORK_get_fd (lt->listen_sock);
3347 sizeof(lt->listen_sock), 3351 GNUNET_CRYPTO_hash (&sockfd,
3352 sizeof(int),
3348 &h_sock); 3353 &h_sock);
3349 3354
3350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3355 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3564,6 +3569,7 @@ run (void *cls,
3564 peerstore = GNUNET_PEERSTORE_connect (cfg); 3569 peerstore = GNUNET_PEERSTORE_connect (cfg);
3565 if (NULL == peerstore) 3570 if (NULL == peerstore)
3566 { 3571 {
3572 GNUNET_free (bindto);
3567 GNUNET_break (0); 3573 GNUNET_break (0);
3568 GNUNET_SCHEDULER_shutdown (); 3574 GNUNET_SCHEDULER_shutdown ();
3569 return; 3575 return;
@@ -3596,7 +3602,6 @@ run (void *cls,
3596 GNUNET_free (po); 3602 GNUNET_free (po);
3597 nat_register (); 3603 nat_register ();
3598 GNUNET_free (bindto); 3604 GNUNET_free (bindto);
3599
3600 return; 3605 return;
3601 } 3606 }
3602 3607
@@ -3609,8 +3614,8 @@ run (void *cls,
3609 in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); 3614 in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port);
3610 init_socket (in, in_len); 3615 init_socket (in, in_len);
3611 nat_register (); 3616 nat_register ();
3617 GNUNET_free (start);
3612 GNUNET_free (bindto); 3618 GNUNET_free (bindto);
3613
3614 return; 3619 return;
3615 } 3620 }
3616 3621
@@ -3620,8 +3625,8 @@ run (void *cls,
3620 in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); 3625 in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port);
3621 init_socket (in, in_len); 3626 init_socket (in, in_len);
3622 nat_register (); 3627 nat_register ();
3628 GNUNET_free (start);
3623 GNUNET_free (bindto); 3629 GNUNET_free (bindto);
3624
3625 return; 3630 return;
3626 } 3631 }
3627 3632
@@ -3635,6 +3640,7 @@ run (void *cls,
3635 &init_socket_resolv, 3640 &init_socket_resolv,
3636 &port); 3641 &port);
3637 GNUNET_free (bindto); 3642 GNUNET_free (bindto);
3643 GNUNET_free (start);
3638} 3644}
3639 3645
3640 3646
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 415dc4b48..d75f4ae00 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1492,16 +1492,9 @@ add_acks (struct SharedSecret *ss, int acks_to_add)
1492 1492
1493 struct ReceiverAddress *receiver = ss->receiver; 1493 struct ReceiverAddress *receiver = ss->receiver;
1494 1494
1495 if (NULL == ss) 1495 GNUNET_assert (NULL != ss);
1496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1496 GNUNET_assert (NULL != receiver);
1497 "secret NULL!\n"); 1497 GNUNET_assert (NULL != receiver->d_qh);
1498
1499 if (NULL == receiver)
1500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1501 "Receiver NULL!\n");
1502 if (NULL == receiver->d_qh)
1503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1504 "Queue NULL!\n");
1505 1498
1506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1507 "Tell transport we have %u more acks!\n", 1500 "Tell transport we have %u more acks!\n",
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 3cba49250..cbf795eea 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -6976,7 +6976,6 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6976 if (MAX_DV_HOPS_ALLOWED == nhops) 6976 if (MAX_DV_HOPS_ALLOWED == nhops)
6977 { 6977 {
6978 /* At limit, we're out of here! */ 6978 /* At limit, we're out of here! */
6979 finish_cmc_handling (cmc);
6980 return; 6979 return;
6981 } 6980 }
6982 6981
@@ -9640,11 +9639,13 @@ handle_add_queue_message (void *cls,
9640 { 9639 {
9641 if (queue->qid != aqm->qid) 9640 if (queue->qid != aqm->qid)
9642 continue; 9641 continue;
9643 neighbour = queue->neighbour;
9644 break; 9642 break;
9645 } 9643 }
9646 if (NULL == queue) 9644
9645 if (NULL != queue)
9647 { 9646 {
9647 neighbour = queue->neighbour;
9648 } else {
9648 neighbour = lookup_neighbour (&aqm->receiver); 9649 neighbour = lookup_neighbour (&aqm->receiver);
9649 if (NULL == neighbour) 9650 if (NULL == neighbour)
9650 { 9651 {
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c
index de356fb9c..040f16d5d 100644
--- a/src/transport/transport-testing-communicator.c
+++ b/src/transport/transport-testing-communicator.c
@@ -548,6 +548,11 @@ handle_update_queue_message (void *cls,
548 tc_queue = tc_queue->next; 548 tc_queue = tc_queue->next;
549 } 549 }
550 } 550 }
551 if (NULL == tc_queue)
552 {
553 GNUNET_SERVICE_client_continue (client->client);
554 return;
555 }
551 GNUNET_assert (tc_queue->qid == msg->qid); 556 GNUNET_assert (tc_queue->qid == msg->qid);
552 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); 557 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
553 tc_queue->nt = msg->nt; 558 tc_queue->nt = msg->nt;
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 6b9e083a7..e2614e5e3 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -25,6 +25,11 @@ if ENABLE_BENCHMARK
25 PTHREAD = -lpthread 25 PTHREAD = -lpthread
26endif 26endif
27 27
28if HAVE_NOLIBGCRYPT19
29 DLOG = crypto_ecc_dlog.c
30 DLOG_TEST = test_crypto_ecc_dlog
31endif
32
28gnunet_config_diff_SOURCES = \ 33gnunet_config_diff_SOURCES = \
29 gnunet-config-diff.c 34 gnunet-config-diff.c
30gnunet_config_diff_LDADD = \ 35gnunet_config_diff_LDADD = \
@@ -58,7 +63,7 @@ libgnunetutil_la_SOURCES = \
58 crypto_symmetric.c \ 63 crypto_symmetric.c \
59 crypto_crc.c \ 64 crypto_crc.c \
60 crypto_ecc.c \ 65 crypto_ecc.c \
61 crypto_ecc_dlog.c \ 66 $(DLOG) \
62 crypto_ecc_setup.c \ 67 crypto_ecc_setup.c \
63 crypto_hash.c \ 68 crypto_hash.c \
64 crypto_hash_file.c \ 69 crypto_hash_file.c \
@@ -248,7 +253,6 @@ libgnunet_plugin_test_la_LDFLAGS = \
248if HAVE_BENCHMARKS 253if HAVE_BENCHMARKS
249 BENCHMARKS = \ 254 BENCHMARKS = \
250 perf_crypto_hash \ 255 perf_crypto_hash \
251 perf_crypto_ecc_dlog \
252 perf_crypto_rsa \ 256 perf_crypto_rsa \
253 perf_crypto_paillier \ 257 perf_crypto_paillier \
254 perf_crypto_symmetric \ 258 perf_crypto_symmetric \
@@ -256,6 +260,10 @@ if HAVE_BENCHMARKS
256 perf_malloc \ 260 perf_malloc \
257 perf_mq \ 261 perf_mq \
258 perf_scheduler 262 perf_scheduler
263
264if HAVE_NOLIBGCRYPT19
265 BENCHMARKS += perf_crypto_ecc_dlog
266endif
259endif 267endif
260 268
261if HAVE_SSH_KEY 269if HAVE_SSH_KEY
@@ -287,7 +295,7 @@ check_PROGRAMS = \
287 test_crypto_ecdhe \ 295 test_crypto_ecdhe \
288 test_crypto_ecdh_eddsa \ 296 test_crypto_ecdh_eddsa \
289 test_crypto_ecdh_ecdsa \ 297 test_crypto_ecdh_ecdsa \
290 test_crypto_ecc_dlog \ 298 $(DLOG_TEST) \
291 test_crypto_hash \ 299 test_crypto_hash \
292 test_crypto_hash_context \ 300 test_crypto_hash_context \
293 test_crypto_hkdf \ 301 test_crypto_hkdf \
@@ -448,11 +456,13 @@ test_crypto_eddsa_LDADD = \
448 libgnunetutil.la \ 456 libgnunetutil.la \
449 $(LIBGCRYPT_LIBS) 457 $(LIBGCRYPT_LIBS)
450 458
459if HAVE_NOLIBGCRYPT19
451test_crypto_ecc_dlog_SOURCES = \ 460test_crypto_ecc_dlog_SOURCES = \
452 test_crypto_ecc_dlog.c 461 test_crypto_ecc_dlog.c
453test_crypto_ecc_dlog_LDADD = \ 462test_crypto_ecc_dlog_LDADD = \
454 libgnunetutil.la \ 463 libgnunetutil.la \
455 $(LIBGCRYPT_LIBS) 464 $(LIBGCRYPT_LIBS)
465endif
456 466
457test_crypto_ecdhe_SOURCES = \ 467test_crypto_ecdhe_SOURCES = \
458 test_crypto_ecdhe.c 468 test_crypto_ecdhe.c
@@ -595,11 +605,13 @@ perf_crypto_hash_SOURCES = \
595perf_crypto_hash_LDADD = \ 605perf_crypto_hash_LDADD = \
596 libgnunetutil.la 606 libgnunetutil.la
597 607
608if HAVE_NOLIBGCRYPT19
598perf_crypto_ecc_dlog_SOURCES = \ 609perf_crypto_ecc_dlog_SOURCES = \
599 perf_crypto_ecc_dlog.c 610 perf_crypto_ecc_dlog.c
600perf_crypto_ecc_dlog_LDADD = \ 611perf_crypto_ecc_dlog_LDADD = \
601 libgnunetutil.la \ 612 libgnunetutil.la \
602 -lgcrypt 613 -lgcrypt
614endif
603 615
604perf_crypto_rsa_SOURCES = \ 616perf_crypto_rsa_SOURCES = \
605 perf_crypto_rsa.c 617 perf_crypto_rsa.c
diff --git a/src/util/configuration.c b/src/util/configuration.c
index bda643b83..3294d11f4 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -606,6 +606,7 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
606 if (NULL == h) 606 if (NULL == h)
607 { 607 {
608 GNUNET_free (fn); 608 GNUNET_free (fn);
609 GNUNET_free (cfg_buf);
609 return GNUNET_SYSERR; 610 return GNUNET_SYSERR;
610 } 611 }
611 if (((ssize_t) size) != 612 if (((ssize_t) size) !=
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c
index b66a7b258..efaac1136 100644
--- a/src/util/container_meta_data.c
+++ b/src/util/container_meta_data.c
@@ -964,6 +964,9 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
964 { 964 {
965 /* does not fit! */ 965 /* does not fit! */
966 GNUNET_free (ent); 966 GNUNET_free (ent);
967 if (NULL != cdata)
968 GNUNET_free (cdata);
969 cdata = NULL;
967 return GNUNET_SYSERR; 970 return GNUNET_SYSERR;
968 } 971 }
969 972
@@ -976,9 +979,9 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
976 if (NULL != pos->mime_type) 979 if (NULL != pos->mime_type)
977 left -= strlen (pos->mime_type) + 1; 980 left -= strlen (pos->mime_type) + 1;
978 981
979 GNUNET_free (cdata); 982 if (NULL != cdata)
983 GNUNET_free (cdata);
980 cdata = NULL; 984 cdata = NULL;
981
982 i++; 985 i++;
983 } 986 }
984 GNUNET_free (ent); 987 GNUNET_free (ent);
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 63232cab6..5e4c4d1e6 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -863,6 +863,7 @@ rsa_sign_mpi (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
863 __FILE__, 863 __FILE__,
864 __LINE__, 864 __LINE__,
865 gcry_strerror (rc)); 865 gcry_strerror (rc));
866 gcry_sexp_release (data);
866 GNUNET_break (0); 867 GNUNET_break (0);
867 return NULL; 868 return NULL;
868 } 869 }
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c
index 8949f427c..28e44e28b 100644
--- a/src/util/gnunet-crypto-tvg.c
+++ b/src/util/gnunet-crypto-tvg.c
@@ -128,6 +128,7 @@ d2j (json_t *vec,
128 json_object_set_new (vec, label, json); 128 json_object_set_new (vec, label, json);
129} 129}
130 130
131
131/** 132/**
132 * Add a number to a test vector. 133 * Add a number to a test vector.
133 * 134 *
@@ -138,8 +139,8 @@ d2j (json_t *vec,
138 */ 139 */
139static void 140static void
140uint2j (json_t *vec, 141uint2j (json_t *vec,
141 const char *label, 142 const char *label,
142 unsigned int num) 143 unsigned int num)
143{ 144{
144 json_t *json = json_integer (num); 145 json_t *json = json_integer (num);
145 146
@@ -154,7 +155,7 @@ expect_data_fixed (json_t *vec,
154 size_t expect_len) 155 size_t expect_len)
155{ 156{
156 const char *s = json_string_value (json_object_get (vec, name)); 157 const char *s = json_string_value (json_object_get (vec, name));
157 158
158 if (NULL == s) 159 if (NULL == s)
159 return GNUNET_NO; 160 return GNUNET_NO;
160 161
@@ -166,6 +167,7 @@ expect_data_fixed (json_t *vec,
166 return GNUNET_OK; 167 return GNUNET_OK;
167} 168}
168 169
170
169static int 171static int
170expect_data_dynamic (json_t *vec, 172expect_data_dynamic (json_t *vec,
171 const char *name, 173 const char *name,
@@ -173,6 +175,7 @@ expect_data_dynamic (json_t *vec,
173 size_t *ret_len) 175 size_t *ret_len)
174{ 176{
175 const char *s = json_string_value (json_object_get (vec, name)); 177 const char *s = json_string_value (json_object_get (vec, name));
178 char *tmp;
176 size_t len; 179 size_t len;
177 180
178 if (NULL == s) 181 if (NULL == s)
@@ -181,10 +184,14 @@ expect_data_dynamic (json_t *vec,
181 len = (strlen (s) * 5) / 8; 184 len = (strlen (s) * 5) / 8;
182 if (NULL != ret_len) 185 if (NULL != ret_len)
183 *ret_len = len; 186 *ret_len = len;
184 *data = GNUNET_malloc (len); 187 tmp = GNUNET_malloc (len);
185 188
186 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (s, strlen (s), *data, len)) 189 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (s, strlen (s), tmp, len))
190 {
191 GNUNET_free (tmp);
187 return GNUNET_NO; 192 return GNUNET_NO;
193 }
194 *data = tmp;
188 return GNUNET_OK; 195 return GNUNET_OK;
189} 196}
190 197
@@ -197,7 +204,7 @@ expect_data_dynamic (json_t *vec,
197 * 204 *
198 * @returns GNUNET_OK if the vector is okay 205 * @returns GNUNET_OK if the vector is okay
199 */ 206 */
200static int 207static int
201checkvec (const char *operation, 208checkvec (const char *operation,
202 json_t *vec) 209 json_t *vec)
203{ 210{
@@ -220,10 +227,11 @@ checkvec (const char *operation,
220 return GNUNET_SYSERR; 227 return GNUNET_SYSERR;
221 } 228 }
222 if (GNUNET_OK != expect_data_fixed (vec, 229 if (GNUNET_OK != expect_data_fixed (vec,
223 "output", 230 "output",
224 &hash_out, 231 &hash_out,
225 sizeof (hash_out))) 232 sizeof (hash_out)))
226 { 233 {
234 GNUNET_free (data);
227 GNUNET_break (0); 235 GNUNET_break (0);
228 return GNUNET_NO; 236 return GNUNET_NO;
229 } 237 }
@@ -232,9 +240,11 @@ checkvec (const char *operation,
232 240
233 if (0 != GNUNET_memcmp (&hc, &hash_out)) 241 if (0 != GNUNET_memcmp (&hc, &hash_out))
234 { 242 {
243 GNUNET_free (data);
235 GNUNET_break (0); 244 GNUNET_break (0);
236 return GNUNET_NO; 245 return GNUNET_NO;
237 } 246 }
247 GNUNET_free (data);
238 } 248 }
239 else if (0 == strcmp (operation, "ecc_ecdh")) 249 else if (0 == strcmp (operation, "ecc_ecdh"))
240 { 250 {
@@ -245,33 +255,33 @@ checkvec (const char *operation,
245 struct GNUNET_HashCode skm_comp; 255 struct GNUNET_HashCode skm_comp;
246 256
247 if (GNUNET_OK != expect_data_fixed (vec, 257 if (GNUNET_OK != expect_data_fixed (vec,
248 "priv1", 258 "priv1",
249 &priv1, 259 &priv1,
250 sizeof (priv1))) 260 sizeof (priv1)))
251 { 261 {
252 GNUNET_break (0); 262 GNUNET_break (0);
253 return GNUNET_NO; 263 return GNUNET_NO;
254 } 264 }
255 if (GNUNET_OK != expect_data_fixed (vec, 265 if (GNUNET_OK != expect_data_fixed (vec,
256 "priv2", 266 "priv2",
257 &priv2, 267 &priv2,
258 sizeof (priv2))) 268 sizeof (priv2)))
259 { 269 {
260 GNUNET_break (0); 270 GNUNET_break (0);
261 return GNUNET_NO; 271 return GNUNET_NO;
262 } 272 }
263 if (GNUNET_OK != expect_data_fixed (vec, 273 if (GNUNET_OK != expect_data_fixed (vec,
264 "pub1", 274 "pub1",
265 &pub1, 275 &pub1,
266 sizeof (pub1))) 276 sizeof (pub1)))
267 { 277 {
268 GNUNET_break (0); 278 GNUNET_break (0);
269 return GNUNET_NO; 279 return GNUNET_NO;
270 } 280 }
271 if (GNUNET_OK != expect_data_fixed (vec, 281 if (GNUNET_OK != expect_data_fixed (vec,
272 "skm", 282 "skm",
273 &skm, 283 &skm,
274 sizeof (skm))) 284 sizeof (skm)))
275 { 285 {
276 GNUNET_break (0); 286 GNUNET_break (0);
277 return GNUNET_NO; 287 return GNUNET_NO;
@@ -407,6 +417,8 @@ checkvec (const char *operation,
407 &ikm, 417 &ikm,
408 &ikm_len)) 418 &ikm_len))
409 { 419 {
420 GNUNET_free (out);
421 GNUNET_free (out_comp);
410 GNUNET_break (0); 422 GNUNET_break (0);
411 return GNUNET_SYSERR; 423 return GNUNET_SYSERR;
412 } 424 }
@@ -416,6 +428,9 @@ checkvec (const char *operation,
416 &salt, 428 &salt,
417 &salt_len)) 429 &salt_len))
418 { 430 {
431 GNUNET_free (out);
432 GNUNET_free (out_comp);
433 GNUNET_free (ikm);
419 GNUNET_break (0); 434 GNUNET_break (0);
420 return GNUNET_SYSERR; 435 return GNUNET_SYSERR;
421 } 436 }
@@ -425,6 +440,10 @@ checkvec (const char *operation,
425 &ctx, 440 &ctx,
426 &ctx_len)) 441 &ctx_len))
427 { 442 {
443 GNUNET_free (out);
444 GNUNET_free (out_comp);
445 GNUNET_free (ikm);
446 GNUNET_free (salt);
428 GNUNET_break (0); 447 GNUNET_break (0);
429 return GNUNET_SYSERR; 448 return GNUNET_SYSERR;
430 } 449 }
@@ -442,10 +461,19 @@ checkvec (const char *operation,
442 461
443 if (0 != memcmp (out, out_comp, out_len)) 462 if (0 != memcmp (out, out_comp, out_len))
444 { 463 {
464 GNUNET_free (out);
465 GNUNET_free (out_comp);
466 GNUNET_free (ikm);
467 GNUNET_free (salt);
468 GNUNET_free (ctx);
445 GNUNET_break (0); 469 GNUNET_break (0);
446 return GNUNET_NO; 470 return GNUNET_NO;
447 } 471 }
448 472 GNUNET_free (out);
473 GNUNET_free (out_comp);
474 GNUNET_free (ikm);
475 GNUNET_free (salt);
476 GNUNET_free (ctx);
449 } 477 }
450 else if (0 == strcmp (operation, "eddsa_ecdh")) 478 else if (0 == strcmp (operation, "eddsa_ecdh"))
451 { 479 {
@@ -562,6 +590,7 @@ checkvec (const char *operation,
562 &public_enc_data, 590 &public_enc_data,
563 &public_enc_len)) 591 &public_enc_len))
564 { 592 {
593 GNUNET_free (blinded_data);
565 GNUNET_break (0); 594 GNUNET_break (0);
566 return GNUNET_SYSERR; 595 return GNUNET_SYSERR;
567 } 596 }
@@ -571,6 +600,8 @@ checkvec (const char *operation,
571 &secret_enc_data, 600 &secret_enc_data,
572 &secret_enc_len)) 601 &secret_enc_len))
573 { 602 {
603 GNUNET_free (blinded_data);
604 GNUNET_free (public_enc_data);
574 GNUNET_break (0); 605 GNUNET_break (0);
575 return GNUNET_SYSERR; 606 return GNUNET_SYSERR;
576 } 607 }
@@ -580,6 +611,9 @@ checkvec (const char *operation,
580 &sig_enc_data, 611 &sig_enc_data,
581 &sig_enc_length)) 612 &sig_enc_length))
582 { 613 {
614 GNUNET_free (blinded_data);
615 GNUNET_free (public_enc_data);
616 GNUNET_free (secret_enc_data);
583 GNUNET_break (0); 617 GNUNET_break (0);
584 return GNUNET_SYSERR; 618 return GNUNET_SYSERR;
585 } 619 }
@@ -601,6 +635,11 @@ checkvec (const char *operation,
601 blinded_data_comp, 635 blinded_data_comp,
602 blinded_len)) ) 636 blinded_len)) )
603 { 637 {
638 GNUNET_free (blinded_data);
639 GNUNET_free (public_enc_data);
640 GNUNET_free (secret_enc_data);
641 GNUNET_free (sig_enc_data);
642 GNUNET_free (skey);
604 GNUNET_break (0); 643 GNUNET_break (0);
605 return GNUNET_NO; 644 return GNUNET_NO;
606 } 645 }
@@ -611,14 +650,27 @@ checkvec (const char *operation,
611 pkey)); 650 pkey));
612 public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey, 651 public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey,
613 &public_enc_data); 652 &public_enc_data);
614 sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig, &sig_enc_data_comp); 653 sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig,
654 &sig_enc_data_comp);
615 655
616 if ( (sig_enc_length != sig_enc_length_comp) || 656 if ( (sig_enc_length != sig_enc_length_comp) ||
617 (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) )) 657 (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) ))
618 { 658 {
659 GNUNET_free (blinded_sig);
660 GNUNET_free (blinded_data);
661 GNUNET_free (public_enc_data);
662 GNUNET_free (secret_enc_data);
663 GNUNET_free (sig_enc_data);
664 GNUNET_free (skey);
619 GNUNET_break (0); 665 GNUNET_break (0);
620 return GNUNET_NO; 666 return GNUNET_NO;
621 } 667 }
668 GNUNET_free (blinded_sig);
669 GNUNET_free (blinded_data);
670 GNUNET_free (public_enc_data);
671 GNUNET_free (secret_enc_data);
672 GNUNET_free (sig_enc_data);
673 GNUNET_free (skey);
622 } 674 }
623 else 675 else
624 { 676 {
@@ -629,6 +681,7 @@ checkvec (const char *operation,
629 return GNUNET_OK; 681 return GNUNET_OK;
630} 682}
631 683
684
632/** 685/**
633 * Check test vectors from stdin. 686 * Check test vectors from stdin.
634 * 687 *
@@ -656,7 +709,7 @@ check_vectors ()
656 return 1; 709 return 1;
657 } 710 }
658 vectors = json_object_get (vecfile, "vectors"); 711 vectors = json_object_get (vecfile, "vectors");
659 if (!json_is_array (vectors)) 712 if (! json_is_array (vectors))
660 { 713 {
661 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bad vectors\n"); 714 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bad vectors\n");
662 json_decref (vecfile); 715 json_decref (vecfile);
@@ -692,6 +745,7 @@ check_vectors ()
692 } 745 }
693} 746}
694 747
748
695/** 749/**
696 * Output test vectors. 750 * Output test vectors.
697 * 751 *
@@ -868,20 +922,20 @@ output_vectors ()
868 GNUNET_CRYPTO_ecdh_eddsa (&priv_ecdhe, &pub_eddsa, &key_material); 922 GNUNET_CRYPTO_ecdh_eddsa (&priv_ecdhe, &pub_eddsa, &key_material);
869 923
870 d2j (vec, "priv_ecdhe", 924 d2j (vec, "priv_ecdhe",
871 &priv_ecdhe, 925 &priv_ecdhe,
872 sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); 926 sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey));
873 d2j (vec, "pub_ecdhe", 927 d2j (vec, "pub_ecdhe",
874 &pub_ecdhe, 928 &pub_ecdhe,
875 sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); 929 sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
876 d2j (vec, "priv_eddsa", 930 d2j (vec, "priv_eddsa",
877 &priv_eddsa, 931 &priv_eddsa,
878 sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); 932 sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
879 d2j (vec, "pub_eddsa", 933 d2j (vec, "pub_eddsa",
880 &pub_eddsa, 934 &pub_eddsa,
881 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); 935 sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
882 d2j (vec, "key_material", 936 d2j (vec, "key_material",
883 &key_material, 937 &key_material,
884 sizeof (struct GNUNET_HashCode)); 938 sizeof (struct GNUNET_HashCode));
885 } 939 }
886 940
887 { 941 {
@@ -968,6 +1022,7 @@ output_vectors ()
968 GNUNET_free (blinded_data); 1022 GNUNET_free (blinded_data);
969 GNUNET_free (sig_enc_data); 1023 GNUNET_free (sig_enc_data);
970 GNUNET_free (blinded_sig_enc_data); 1024 GNUNET_free (blinded_sig_enc_data);
1025 GNUNET_free (secret_enc_data);
971 } 1026 }
972 1027
973 json_dumpf (vecfile, stdout, JSON_INDENT (2)); 1028 json_dumpf (vecfile, stdout, JSON_INDENT (2));
@@ -977,6 +1032,7 @@ output_vectors ()
977 return 0; 1032 return 0;
978} 1033}
979 1034
1035
980/** 1036/**
981 * Main function that will be run. 1037 * Main function that will be run.
982 * 1038 *
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index d1e5e0da5..02d4d439d 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -736,7 +736,12 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
736 "SUID_BINARY_PATH", 736 "SUID_BINARY_PATH",
737 &path); 737 &path);
738 if ((NULL == path) || (0 == strlen (path))) 738 if ((NULL == path) || (0 == strlen (path)))
739 {
740 if (NULL != path)
741 GNUNET_free (path);
742 cache = NULL;
739 return GNUNET_OS_get_libexec_binary_path (progname); 743 return GNUNET_OS_get_libexec_binary_path (progname);
744 }
740 path_len = strlen (path); 745 path_len = strlen (path);
741 GNUNET_asprintf (&binary, 746 GNUNET_asprintf (&binary,
742 "%s%s%s", 747 "%s%s%s",