aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am39
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c13
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_v2.c262
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c262
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel_send.c262
-rw-r--r--src/transport/test_transport_port_forward.c85
-rw-r--r--src/transport/test_transport_simple_send.c86
-rw-r--r--src/transport/test_transport_simple_send_v2.c83
-rwxr-xr-xsrc/transport/test_transport_simple_send_v2.sh2
-rw-r--r--src/transport/transport-testing-cmds.h233
-rw-r--r--src/transport/transport-testing-ng.h107
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c56
-rw-r--r--src/transport/transport_api_cmd_connecting_peers_v2.c242
-rw-r--r--src/transport/transport_api_cmd_send_simple_v2.c156
-rw-r--r--src/transport/transport_api_cmd_start_peer.c36
-rw-r--r--src/transport/transport_api_cmd_start_peer_v2.c607
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c2
17 files changed, 2415 insertions, 118 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 4ea3b58c4..8bd35b5a3 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -161,11 +161,13 @@ libgnunettransporttesting_la_LDFLAGS = \
161 161
162libgnunettransporttesting2_la_SOURCES = \ 162libgnunettransporttesting2_la_SOURCES = \
163 transport_api_cmd_connecting_peers.c \ 163 transport_api_cmd_connecting_peers.c \
164 transport_api_cmd_connecting_peers_v2.c \
164 transport_api_cmd_start_peer.c \ 165 transport_api_cmd_start_peer.c \
166 transport_api_cmd_start_peer_v2.c \
165 transport_api_cmd_stop_peer.c \ 167 transport_api_cmd_stop_peer.c \
166 transport_api_cmd_send_simple.c \ 168 transport_api_cmd_send_simple.c \
169 transport_api_cmd_send_simple_v2.c \
167 transport-testing2.c transport-testing2.h \ 170 transport-testing2.c transport-testing2.h \
168 transport-testing-ng.h \
169 transport-testing-cmds.h \ 171 transport-testing-cmds.h \
170 transport-testing-filenames2.c \ 172 transport-testing-filenames2.c \
171 transport-testing-loggers2.c \ 173 transport-testing-loggers2.c \
@@ -391,7 +393,8 @@ plugin_LTLIBRARIES = \
391 $(HTTPS_SERVER_PLUGIN_LA) \ 393 $(HTTPS_SERVER_PLUGIN_LA) \
392 $(WLAN_PLUGIN_LA) \ 394 $(WLAN_PLUGIN_LA) \
393 $(BT_PLUGIN_LA) \ 395 $(BT_PLUGIN_LA) \
394 libgnunet_test_transport_plugin_cmd_simple_send.la 396 libgnunet_test_transport_plugin_cmd_simple_send.la \
397 libgnunet_test_transport_plugin_cmd_simple_send_v2.la
395 398
396libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \ 399libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \
397 test_transport_plugin_cmd_simple_send.c 400 test_transport_plugin_cmd_simple_send.c
@@ -410,6 +413,23 @@ libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \
410libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ 413libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \
411 $(GN_PLUGIN_LDFLAGS) 414 $(GN_PLUGIN_LDFLAGS)
412 415
416libgnunet_test_transport_plugin_cmd_simple_send_v2_la_SOURCES = \
417 test_transport_plugin_cmd_simple_send_v2.c
418libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \
419 libgnunettransporttesting2.la \
420 libgnunettransportapplication.la \
421 libgnunettransport.la \
422 $(top_builddir)/src/testing/libgnunettesting.la \
423 $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
424 $(top_builddir)/src/statistics/libgnunetstatistics.la \
425 $(top_builddir)/src/hello/libgnunethello.la \
426 $(top_builddir)/src/ats/libgnunetats.la \
427 $(top_builddir)/src/arm/libgnunetarm.la \
428 $(top_builddir)/src/util/libgnunetutil.la \
429 $(LTLIBINTL)
430libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LDFLAGS = \
431 $(GN_PLUGIN_LDFLAGS)
432
413if HAVE_EXPERIMENTAL 433if HAVE_EXPERIMENTAL
414plugin_LTLIBRARIES += \ 434plugin_LTLIBRARIES += \
415 libgnunet_plugin_transport_udp.la 435 libgnunet_plugin_transport_udp.la
@@ -557,6 +577,7 @@ libgnunet_plugin_transport_https_server_la_CFLAGS = \
557if HAVE_TESTING 577if HAVE_TESTING
558check_PROGRAMS = \ 578check_PROGRAMS = \
559 test_transport_simple_send \ 579 test_transport_simple_send \
580 test_transport_simple_send_v2 \
560 test_transport_address_switch_tcp \ 581 test_transport_address_switch_tcp \
561 test_transport_testing_startstop \ 582 test_transport_testing_startstop \
562 test_transport_testing_restart \ 583 test_transport_testing_restart \
@@ -706,6 +727,7 @@ endif
706if HAVE_EXPERIMENTAL 727if HAVE_EXPERIMENTAL
707TESTS += \ 728TESTS += \
708 test_transport_simple_send \ 729 test_transport_simple_send \
730 test_transport_simple_send_v2 \
709 test_transport_address_switch_udp \ 731 test_transport_address_switch_udp \
710 test_plugin_udp \ 732 test_plugin_udp \
711 test_transport_api_udp \ 733 test_transport_api_udp \
@@ -724,7 +746,8 @@ endif
724endif 746endif
725 747
726check_SCRIPTS= \ 748check_SCRIPTS= \
727 test_transport_simple_send.sh 749 test_transport_simple_send.sh \
750 test_transport_simple_send_v2.sh
728 751
729test_transport_simple_send_SOURCES = \ 752test_transport_simple_send_SOURCES = \
730 test_transport_simple_send.c 753 test_transport_simple_send.c
@@ -736,6 +759,16 @@ test_transport_simple_send_LDADD = \
736 libgnunettransport.la \ 759 libgnunettransport.la \
737 libgnunettransporttesting.la 760 libgnunettransporttesting.la
738 761
762test_transport_simple_send_v2_SOURCES = \
763 test_transport_simple_send_v2.c
764test_transport_simple_send_v2_LDADD = \
765 $(top_builddir)/src/testing/libgnunettesting.la \
766 $(top_builddir)/src/util/libgnunetutil.la \
767 $(top_builddir)/src/testbed/libgnunettestbed.la \
768 $(top_builddir)/src/hello/libgnunethello.la \
769 libgnunettransport.la \
770 libgnunettransporttesting.la
771
739test_transport_testing_startstop_SOURCES = \ 772test_transport_testing_startstop_SOURCES = \
740 test_transport_testing_startstop.c 773 test_transport_testing_startstop.c
741test_transport_testing_startstop_LDADD = \ 774test_transport_testing_startstop_LDADD = \
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 4b5018b60..1dc44c945 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -144,7 +144,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
144 144
145 GNUNET_asprintf (&cfgname, 145 GNUNET_asprintf (&cfgname,
146 "test_transport_api2_tcp_node%s.conf", 146 "test_transport_api2_tcp_node%s.conf",
147 n); 147 "1");
148 148
149 LOG (GNUNET_ERROR_TYPE_ERROR, 149 LOG (GNUNET_ERROR_TYPE_ERROR,
150 "plugin cfgname: %s\n", 150 "plugin cfgname: %s\n",
@@ -154,6 +154,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
154 "node ip: %s\n", 154 "node ip: %s\n",
155 node_ip); 155 node_ip);
156 156
157 LOG (GNUNET_ERROR_TYPE_ERROR,
158 "m: %s n: %s\n",
159 m,
160 n);
161
157 GNUNET_asprintf (&testdir, 162 GNUNET_asprintf (&testdir,
158 "%s%s%s", 163 "%s%s%s",
159 BASE_DIR, 164 BASE_DIR,
@@ -180,6 +185,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
180 m, 185 m,
181 n, 186 n,
182 local_m, 187 local_m,
188 node_ip,
183 handlers, 189 handlers,
184 cfgname), 190 cfgname),
185 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", 191 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
@@ -187,7 +193,10 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
187 GNUNET_TESTING_cmd_block_until_all_peers_started ("block", 193 GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
188 &are_all_peers_started), 194 &are_all_peers_started),
189 GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", 195 GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
190 "start-peer"), 196 "start-peer",
197 "system-create",
198 (atoi (n) - 1) * atoi (local_m) + atoi (
199 m)),
191 GNUNET_TRANSPORT_cmd_send_simple ("send-simple", 200 GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
192 m, 201 m,
193 n, 202 n,
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_v2.c b/src/transport/test_transport_plugin_cmd_simple_send_v2.c
new file mode 100644
index 000000000..ce1245296
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_simple_send_v2.c
@@ -0,0 +1,262 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testbed/plugin_cmd_simple_send.c
23 * @brief a plugin to provide the API for running test cases.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_transport_application_service.h"
30#include "transport-testing2.h"
31#include "transport-testing-cmds.h"
32
33/**
34 * Generic logging shortcut
35 */
36#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
37
38#define BASE_DIR "testdir"
39
40#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
41
42/**
43 * The name for a specific test environment directory.
44 *
45 */
46char *testdir;
47
48/**
49 * The name for the configuration file of the specific node.
50 *
51 */
52char *cfgname;
53
54/**
55 * Flag indicating if all peers have been started.
56 *
57 */
58unsigned int are_all_peers_started;
59
60
61/**
62 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
63 * received.
64 *
65 */
66static int
67check_test (void *cls,
68 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
69{
70 return GNUNET_OK;
71}
72
73
74/**
75 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
76 * being received.
77 *
78 */
79static void
80handle_test (void *cls,
81 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
82{
83 LOG (GNUNET_ERROR_TYPE_ERROR,
84 "message received\n");
85}
86
87
88/**
89 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
90 * being received.
91 *
92 */
93static int
94check_test2 (void *cls,
95 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
96{
97 return GNUNET_OK;
98}
99
100
101/**
102 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
103 * being received.
104 *
105 */
106static void
107handle_test2 (void *cls,
108 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
109{
110 LOG (GNUNET_ERROR_TYPE_ERROR,
111 "message received\n");
112}
113
114
115/**
116 * Callback to set the flag indicating all peers started. Will be called via the plugin api.
117 *
118 */
119static void
120all_peers_started ()
121{
122 are_all_peers_started = GNUNET_YES;
123 LOG (GNUNET_ERROR_TYPE_ERROR,
124 "setting are_all_peers_started: %d\n",
125 are_all_peers_started);
126}
127
128
129/**
130 * Function to start a local test case.
131 *
132 * @param write_message Callback to send a message to the master loop.
133 * @param router_ip Global address of the network namespace.
134 * @param node_ip Local address of a node i a network namespace.
135 * @param m The number of the node in a network namespace.
136 * @param n The number of the network namespace.
137 * @param local_m The number of nodes in a network namespace.
138 */
139static void
140start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
141 char *node_ip,
142 char *m,
143 char *n,
144 char *local_m)
145{
146
147 unsigned int n_int, m_int, local_m_int, num;
148
149 struct GNUNET_TESTING_NetjailTopology *topology =
150 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
151
152 sscanf (m, "%u", &m_int);
153 sscanf (n, "%u", &n_int);
154 sscanf (local_m, "%u", &local_m_int);
155
156
157 if (0 == m_int)
158 num = n_int;
159 else
160 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
161
162 GNUNET_asprintf (&cfgname,
163 "test_transport_api2_tcp_node1.conf");
164
165 LOG (GNUNET_ERROR_TYPE_ERROR,
166 "plugin cfgname: %s\n",
167 cfgname);
168
169 LOG (GNUNET_ERROR_TYPE_ERROR,
170 "node ip: %s\n",
171 node_ip);
172
173 GNUNET_asprintf (&testdir,
174 "%s%s%s",
175 BASE_DIR,
176 m,
177 n);
178
179 struct GNUNET_MQ_MessageHandler handlers[] = {
180 GNUNET_MQ_hd_var_size (test,
181 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
182 struct GNUNET_TRANSPORT_TESTING_TestMessage,
183 NULL),
184 GNUNET_MQ_hd_var_size (test2,
185 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
186 struct GNUNET_TRANSPORT_TESTING_TestMessage,
187 NULL),
188 GNUNET_MQ_handler_end ()
189 };
190
191 struct GNUNET_TESTING_Command commands[] = {
192 GNUNET_TESTING_cmd_system_create ("system-create",
193 testdir),
194 GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
195 "system-create",
196 num,
197 node_ip,
198 handlers,
199 cfgname),
200 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
201 write_message),
202 GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
203 &are_all_peers_started),
204 GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
205 "start-peer",
206 "system-create",
207 num),
208 GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
209 "start-peer",
210 num),
211 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
212 "start-peer"),
213 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
214 "system-create"),
215 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
216 write_message)
217 };
218
219 GNUNET_TESTING_run (NULL,
220 commands,
221 GNUNET_TIME_UNIT_FOREVER_REL);
222
223}
224
225
226/**
227 * Entry point for the plugin.
228 *
229 * @param cls NULL
230 * @return the exported block API
231 */
232void *
233libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
234{
235 struct GNUNET_TESTING_PluginFunctions *api;
236
237 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
238 api->start_testcase = &start_testcase;
239 api->all_peers_started = &all_peers_started;
240 return api;
241}
242
243
244/**
245 * Exit point from the plugin.
246 *
247 * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
248 * @return NULL
249 */
250void *
251libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
252{
253 struct GNUNET_TESTING_PluginFunctions *api = cls;
254
255 GNUNET_free (api);
256 GNUNET_free (testdir);
257 GNUNET_free (cfgname);
258 return NULL;
259}
260
261
262/* end of plugin_cmd_simple_send.c */
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c b/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c
new file mode 100644
index 000000000..ce1245296
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c
@@ -0,0 +1,262 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testbed/plugin_cmd_simple_send.c
23 * @brief a plugin to provide the API for running test cases.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_transport_application_service.h"
30#include "transport-testing2.h"
31#include "transport-testing-cmds.h"
32
33/**
34 * Generic logging shortcut
35 */
36#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
37
38#define BASE_DIR "testdir"
39
40#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
41
42/**
43 * The name for a specific test environment directory.
44 *
45 */
46char *testdir;
47
48/**
49 * The name for the configuration file of the specific node.
50 *
51 */
52char *cfgname;
53
54/**
55 * Flag indicating if all peers have been started.
56 *
57 */
58unsigned int are_all_peers_started;
59
60
61/**
62 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
63 * received.
64 *
65 */
66static int
67check_test (void *cls,
68 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
69{
70 return GNUNET_OK;
71}
72
73
74/**
75 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
76 * being received.
77 *
78 */
79static void
80handle_test (void *cls,
81 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
82{
83 LOG (GNUNET_ERROR_TYPE_ERROR,
84 "message received\n");
85}
86
87
88/**
89 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
90 * being received.
91 *
92 */
93static int
94check_test2 (void *cls,
95 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
96{
97 return GNUNET_OK;
98}
99
100
101/**
102 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
103 * being received.
104 *
105 */
106static void
107handle_test2 (void *cls,
108 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
109{
110 LOG (GNUNET_ERROR_TYPE_ERROR,
111 "message received\n");
112}
113
114
115/**
116 * Callback to set the flag indicating all peers started. Will be called via the plugin api.
117 *
118 */
119static void
120all_peers_started ()
121{
122 are_all_peers_started = GNUNET_YES;
123 LOG (GNUNET_ERROR_TYPE_ERROR,
124 "setting are_all_peers_started: %d\n",
125 are_all_peers_started);
126}
127
128
129/**
130 * Function to start a local test case.
131 *
132 * @param write_message Callback to send a message to the master loop.
133 * @param router_ip Global address of the network namespace.
134 * @param node_ip Local address of a node i a network namespace.
135 * @param m The number of the node in a network namespace.
136 * @param n The number of the network namespace.
137 * @param local_m The number of nodes in a network namespace.
138 */
139static void
140start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
141 char *node_ip,
142 char *m,
143 char *n,
144 char *local_m)
145{
146
147 unsigned int n_int, m_int, local_m_int, num;
148
149 struct GNUNET_TESTING_NetjailTopology *topology =
150 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
151
152 sscanf (m, "%u", &m_int);
153 sscanf (n, "%u", &n_int);
154 sscanf (local_m, "%u", &local_m_int);
155
156
157 if (0 == m_int)
158 num = n_int;
159 else
160 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
161
162 GNUNET_asprintf (&cfgname,
163 "test_transport_api2_tcp_node1.conf");
164
165 LOG (GNUNET_ERROR_TYPE_ERROR,
166 "plugin cfgname: %s\n",
167 cfgname);
168
169 LOG (GNUNET_ERROR_TYPE_ERROR,
170 "node ip: %s\n",
171 node_ip);
172
173 GNUNET_asprintf (&testdir,
174 "%s%s%s",
175 BASE_DIR,
176 m,
177 n);
178
179 struct GNUNET_MQ_MessageHandler handlers[] = {
180 GNUNET_MQ_hd_var_size (test,
181 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
182 struct GNUNET_TRANSPORT_TESTING_TestMessage,
183 NULL),
184 GNUNET_MQ_hd_var_size (test2,
185 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
186 struct GNUNET_TRANSPORT_TESTING_TestMessage,
187 NULL),
188 GNUNET_MQ_handler_end ()
189 };
190
191 struct GNUNET_TESTING_Command commands[] = {
192 GNUNET_TESTING_cmd_system_create ("system-create",
193 testdir),
194 GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
195 "system-create",
196 num,
197 node_ip,
198 handlers,
199 cfgname),
200 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
201 write_message),
202 GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
203 &are_all_peers_started),
204 GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
205 "start-peer",
206 "system-create",
207 num),
208 GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
209 "start-peer",
210 num),
211 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
212 "start-peer"),
213 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
214 "system-create"),
215 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
216 write_message)
217 };
218
219 GNUNET_TESTING_run (NULL,
220 commands,
221 GNUNET_TIME_UNIT_FOREVER_REL);
222
223}
224
225
226/**
227 * Entry point for the plugin.
228 *
229 * @param cls NULL
230 * @return the exported block API
231 */
232void *
233libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
234{
235 struct GNUNET_TESTING_PluginFunctions *api;
236
237 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
238 api->start_testcase = &start_testcase;
239 api->all_peers_started = &all_peers_started;
240 return api;
241}
242
243
244/**
245 * Exit point from the plugin.
246 *
247 * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
248 * @return NULL
249 */
250void *
251libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
252{
253 struct GNUNET_TESTING_PluginFunctions *api = cls;
254
255 GNUNET_free (api);
256 GNUNET_free (testdir);
257 GNUNET_free (cfgname);
258 return NULL;
259}
260
261
262/* end of plugin_cmd_simple_send.c */
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel_send.c b/src/transport/test_transport_plugin_cmd_udp_backchannel_send.c
new file mode 100644
index 000000000..ce1245296
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel_send.c
@@ -0,0 +1,262 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testbed/plugin_cmd_simple_send.c
23 * @brief a plugin to provide the API for running test cases.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_transport_application_service.h"
30#include "transport-testing2.h"
31#include "transport-testing-cmds.h"
32
33/**
34 * Generic logging shortcut
35 */
36#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
37
38#define BASE_DIR "testdir"
39
40#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
41
42/**
43 * The name for a specific test environment directory.
44 *
45 */
46char *testdir;
47
48/**
49 * The name for the configuration file of the specific node.
50 *
51 */
52char *cfgname;
53
54/**
55 * Flag indicating if all peers have been started.
56 *
57 */
58unsigned int are_all_peers_started;
59
60
61/**
62 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
63 * received.
64 *
65 */
66static int
67check_test (void *cls,
68 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
69{
70 return GNUNET_OK;
71}
72
73
74/**
75 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
76 * being received.
77 *
78 */
79static void
80handle_test (void *cls,
81 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
82{
83 LOG (GNUNET_ERROR_TYPE_ERROR,
84 "message received\n");
85}
86
87
88/**
89 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
90 * being received.
91 *
92 */
93static int
94check_test2 (void *cls,
95 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
96{
97 return GNUNET_OK;
98}
99
100
101/**
102 * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
103 * being received.
104 *
105 */
106static void
107handle_test2 (void *cls,
108 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
109{
110 LOG (GNUNET_ERROR_TYPE_ERROR,
111 "message received\n");
112}
113
114
115/**
116 * Callback to set the flag indicating all peers started. Will be called via the plugin api.
117 *
118 */
119static void
120all_peers_started ()
121{
122 are_all_peers_started = GNUNET_YES;
123 LOG (GNUNET_ERROR_TYPE_ERROR,
124 "setting are_all_peers_started: %d\n",
125 are_all_peers_started);
126}
127
128
129/**
130 * Function to start a local test case.
131 *
132 * @param write_message Callback to send a message to the master loop.
133 * @param router_ip Global address of the network namespace.
134 * @param node_ip Local address of a node i a network namespace.
135 * @param m The number of the node in a network namespace.
136 * @param n The number of the network namespace.
137 * @param local_m The number of nodes in a network namespace.
138 */
139static void
140start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
141 char *node_ip,
142 char *m,
143 char *n,
144 char *local_m)
145{
146
147 unsigned int n_int, m_int, local_m_int, num;
148
149 struct GNUNET_TESTING_NetjailTopology *topology =
150 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
151
152 sscanf (m, "%u", &m_int);
153 sscanf (n, "%u", &n_int);
154 sscanf (local_m, "%u", &local_m_int);
155
156
157 if (0 == m_int)
158 num = n_int;
159 else
160 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
161
162 GNUNET_asprintf (&cfgname,
163 "test_transport_api2_tcp_node1.conf");
164
165 LOG (GNUNET_ERROR_TYPE_ERROR,
166 "plugin cfgname: %s\n",
167 cfgname);
168
169 LOG (GNUNET_ERROR_TYPE_ERROR,
170 "node ip: %s\n",
171 node_ip);
172
173 GNUNET_asprintf (&testdir,
174 "%s%s%s",
175 BASE_DIR,
176 m,
177 n);
178
179 struct GNUNET_MQ_MessageHandler handlers[] = {
180 GNUNET_MQ_hd_var_size (test,
181 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
182 struct GNUNET_TRANSPORT_TESTING_TestMessage,
183 NULL),
184 GNUNET_MQ_hd_var_size (test2,
185 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
186 struct GNUNET_TRANSPORT_TESTING_TestMessage,
187 NULL),
188 GNUNET_MQ_handler_end ()
189 };
190
191 struct GNUNET_TESTING_Command commands[] = {
192 GNUNET_TESTING_cmd_system_create ("system-create",
193 testdir),
194 GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
195 "system-create",
196 num,
197 node_ip,
198 handlers,
199 cfgname),
200 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
201 write_message),
202 GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
203 &are_all_peers_started),
204 GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
205 "start-peer",
206 "system-create",
207 num),
208 GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
209 "start-peer",
210 num),
211 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
212 "start-peer"),
213 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
214 "system-create"),
215 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
216 write_message)
217 };
218
219 GNUNET_TESTING_run (NULL,
220 commands,
221 GNUNET_TIME_UNIT_FOREVER_REL);
222
223}
224
225
226/**
227 * Entry point for the plugin.
228 *
229 * @param cls NULL
230 * @return the exported block API
231 */
232void *
233libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
234{
235 struct GNUNET_TESTING_PluginFunctions *api;
236
237 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
238 api->start_testcase = &start_testcase;
239 api->all_peers_started = &all_peers_started;
240 return api;
241}
242
243
244/**
245 * Exit point from the plugin.
246 *
247 * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
248 * @return NULL
249 */
250void *
251libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
252{
253 struct GNUNET_TESTING_PluginFunctions *api = cls;
254
255 GNUNET_free (api);
256 GNUNET_free (testdir);
257 GNUNET_free (cfgname);
258 return NULL;
259}
260
261
262/* end of plugin_cmd_simple_send.c */
diff --git a/src/transport/test_transport_port_forward.c b/src/transport/test_transport_port_forward.c
new file mode 100644
index 000000000..b0f0b113e
--- /dev/null
+++ b/src/transport/test_transport_port_forward.c
@@ -0,0 +1,85 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file transport/test_transport_port_forward.c
23 * @brief Test case executing a script which sends a test UDP message from a nated peer
24 * to a gloabl known peer. There is a tcp port forwarding in place towards the
25 * natted peer to test the backchannel functionality of the TNG service.
26 * @author t3sserakt
27 */
28#include "platform.h"
29#include "gnunet_testing_ng_lib.h"
30#include "gnunet_util_lib.h"
31
32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
33
34/**
35 * Return value of the test.
36 *
37 */
38static unsigned int rv = 0;
39
40
41/**
42 * Main function to run the test cases.
43 *
44 * @param cls not used.
45 *
46 */
47static void
48run (void *cls)
49{
50 const char *topology_config = "test_topology_port_forward.conf";
51
52 struct GNUNET_TESTING_Command commands[] = {
53 GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start",
54 topology_config),
55 GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed",
56 topology_config,
57 &rv),
58 GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed",
59 "netjail-start-testbed",
60 topology_config),
61 GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop",
62 topology_config),
63 GNUNET_TESTING_cmd_end ()
64 };
65
66 GNUNET_TESTING_run (NULL,
67 commands,
68 TIMEOUT);
69}
70
71
72int
73main (int argc,
74 char *const *argv)
75{
76 GNUNET_log_setup ("test-netjail",
77 "DEBUG",
78 NULL);
79 GNUNET_SCHEDULER_run (&run,
80 NULL);
81
82 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
83 "Test finished!\n");
84 return rv;
85}
diff --git a/src/transport/test_transport_simple_send.c b/src/transport/test_transport_simple_send.c
new file mode 100644
index 000000000..924990d0a
--- /dev/null
+++ b/src/transport/test_transport_simple_send.c
@@ -0,0 +1,86 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file transport/test_transport_api_cmd_simple_send.c
23 * @brief Test case executing a script which sends a test message between two peers.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29
30#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
31
32/**
33 * Return value of the test.
34 *
35 */
36static unsigned int rv = 0;
37
38
39/**
40 * Main function to run the test cases.
41 *
42 * @param cls not used.
43 *
44 */
45static void
46run (void *cls)
47{
48 struct GNUNET_TESTING_Command commands[] = {
49 GNUNET_TESTING_cmd_netjail_start ("netjail-start",
50 "2",
51 "1"),
52 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
53 "2",
54 "1",
55 "libgnunet_test_transport_plugin_cmd_simple_send",
56 &rv),
57 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
58 "netjail-start-testbed",
59 "2",
60 "1"),
61 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
62 "2",
63 "1"),
64 GNUNET_TESTING_cmd_end ()
65 };
66
67 GNUNET_TESTING_run (NULL,
68 commands,
69 TIMEOUT);
70}
71
72
73int
74main (int argc,
75 char *const *argv)
76{
77 GNUNET_log_setup ("test-netjail",
78 "DEBUG",
79 NULL);
80 GNUNET_SCHEDULER_run (&run,
81 NULL);
82
83 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
84 "Test finished!\n");
85 return rv;
86}
diff --git a/src/transport/test_transport_simple_send_v2.c b/src/transport/test_transport_simple_send_v2.c
new file mode 100644
index 000000000..aeac1bfb6
--- /dev/null
+++ b/src/transport/test_transport_simple_send_v2.c
@@ -0,0 +1,83 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file transport/test_transport_api_cmd_simple_send.c
23 * @brief Test case executing a script which sends a test message between two peers.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29
30#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
31
32#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
33
34/**
35 * Return value of the test.
36 *
37 */
38static unsigned int rv = 0;
39
40
41/**
42 * Main function to run the test cases.
43 *
44 * @param cls not used.
45 *
46 */
47static void
48run (void *cls)
49{
50 struct GNUNET_TESTING_Command commands[] = {
51 GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start",
52 TOPOLOGY_CONFIG),
53 GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed",
54 TOPOLOGY_CONFIG,
55 &rv),
56 GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed",
57 "netjail-start-testbed",
58 TOPOLOGY_CONFIG),
59 GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop",
60 TOPOLOGY_CONFIG),
61 GNUNET_TESTING_cmd_end ()
62 };
63
64 GNUNET_TESTING_run (NULL,
65 commands,
66 TIMEOUT);
67}
68
69
70int
71main (int argc,
72 char *const *argv)
73{
74 GNUNET_log_setup ("test-netjail",
75 "DEBUG",
76 NULL);
77 GNUNET_SCHEDULER_run (&run,
78 NULL);
79
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Test finished!\n");
82 return rv;
83}
diff --git a/src/transport/test_transport_simple_send_v2.sh b/src/transport/test_transport_simple_send_v2.sh
new file mode 100755
index 000000000..8462d1849
--- /dev/null
+++ b/src/transport/test_transport_simple_send_v2.sh
@@ -0,0 +1,2 @@
1#!/bin/bash
2exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_simple_send_v2"
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index 1461a3d4d..f9ebafade 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -28,12 +28,195 @@
28#define TRANSPORT_TESTING_CMDS_H 28#define TRANSPORT_TESTING_CMDS_H
29#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
30 30
31
32struct StartPeerState_v2
33{
34 /**
35 * The ip of a node.
36 */
37 char *node_ip;
38
39 /**
40 * Receive callback
41 */
42 struct GNUNET_MQ_MessageHandler *handlers;
43
44 const char *cfgname;
45
46 /**
47 * Peer's configuration
48 */
49 struct GNUNET_CONFIGURATION_Handle *cfg;
50
51 struct GNUNET_TESTING_Peer *peer;
52
53 /**
54 * Peer identity
55 */
56 struct GNUNET_PeerIdentity id;
57
58 /**
59 * Peer's transport service handle
60 */
61 struct GNUNET_TRANSPORT_CoreHandle *th;
62
63 /**
64 * Application handle
65 */
66 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
67
68 /**
69 * Peer's PEERSTORE Handle
70 */
71 struct GNUNET_PEERSTORE_Handle *ph;
72
73 /**
74 * Hello get task
75 */
76 struct GNUNET_SCHEDULER_Task *rh_task;
77
78 /**
79 * Peer's transport get hello handle to retrieve peer's HELLO message
80 */
81 struct GNUNET_PEERSTORE_IterateContext *pic;
82
83 /**
84 * Hello
85 */
86 char *hello;
87
88 /**
89 * Hello size
90 */
91 size_t hello_size;
92
93 char *m;
94
95 char *n;
96
97 char *local_m;
98
99 unsigned int finished;
100
101 const char *system_label;
102
103 /**
104 * An unique number to identify the peer
105 */
106 unsigned int no;
107
108 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
109
110 struct GNUNET_TESTING_System *tl_system;
111
112};
113
114
115struct StartPeerState
116{
117 /**
118 * The ip of a node.
119 */
120 char *node_ip;
121
122 /**
123 * Receive callback
124 */
125 struct GNUNET_MQ_MessageHandler *handlers;
126
127 const char *cfgname;
128
129 /**
130 * Peer's configuration
131 */
132 struct GNUNET_CONFIGURATION_Handle *cfg;
133
134 struct GNUNET_TESTING_Peer *peer;
135
136 /**
137 * Peer identity
138 */
139 struct GNUNET_PeerIdentity id;
140
141 /**
142 * Peer's transport service handle
143 */
144 struct GNUNET_TRANSPORT_CoreHandle *th;
145
146 /**
147 * Application handle
148 */
149 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
150
151 /**
152 * Peer's PEERSTORE Handle
153 */
154 struct GNUNET_PEERSTORE_Handle *ph;
155
156 /**
157 * Hello get task
158 */
159 struct GNUNET_SCHEDULER_Task *rh_task;
160
161 /**
162 * Peer's transport get hello handle to retrieve peer's HELLO message
163 */
164 struct GNUNET_PEERSTORE_IterateContext *pic;
165
166 /**
167 * Hello
168 */
169 char *hello;
170
171 /**
172 * Hello size
173 */
174 size_t hello_size;
175
176 char *m;
177
178 char *n;
179
180 char *local_m;
181
182 unsigned int finished;
183
184 const char *system_label;
185
186 /**
187 * An unique number to identify the peer
188 */
189 unsigned int no;
190
191 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
192
193 struct GNUNET_TESTING_System *tl_system;
194
195};
196
197
198int
199GNUNET_TRANSPORT_get_trait_state (const struct
200 GNUNET_TESTING_Command
201 *cmd,
202 struct StartPeerState **sps);
203
204
205struct GNUNET_TESTING_Command
206GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label,
207 const char *system_label,
208 uint32_t no,
209 char *node_ip,
210 struct GNUNET_MQ_MessageHandler *handlers,
211 const char *cfgname);
212
31struct GNUNET_TESTING_Command 213struct GNUNET_TESTING_Command
32GNUNET_TRANSPORT_cmd_start_peer (const char *label, 214GNUNET_TRANSPORT_cmd_start_peer (const char *label,
33 const char *system_label, 215 const char *system_label,
34 char *m, 216 char *m,
35 char *n, 217 char *n,
36 char *local_m, 218 char *local_m,
219 char *node_ip,
37 struct GNUNET_MQ_MessageHandler *handlers, 220 struct GNUNET_MQ_MessageHandler *handlers,
38 const char *cfgname); 221 const char *cfgname);
39 222
@@ -43,7 +226,15 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
43 226
44struct GNUNET_TESTING_Command 227struct GNUNET_TESTING_Command
45GNUNET_TRANSPORT_cmd_connect_peers (const char *label, 228GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
46 const char *start_peer_label); 229 const char *start_peer_label,
230 const char *create_label,
231 uint32_t num);
232
233struct GNUNET_TESTING_Command
234GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label,
235 const char *start_peer_label,
236 const char *create_label,
237 uint32_t num);
47 238
48struct GNUNET_TESTING_Command 239struct GNUNET_TESTING_Command
49GNUNET_TRANSPORT_cmd_send_simple (const char *label, 240GNUNET_TRANSPORT_cmd_send_simple (const char *label,
@@ -52,6 +243,21 @@ GNUNET_TRANSPORT_cmd_send_simple (const char *label,
52 uint32_t num, 243 uint32_t num,
53 const char *start_peer_label); 244 const char *start_peer_label);
54 245
246/**
247 * Create command.
248 *
249 * @param label name for command.
250 * @param m The number of the local node of the actual network namespace.
251 * @param n The number of the actual namespace.
252 * @param num Number globally identifying the node.
253 * @param start_peer_label Label of the cmd to start a peer.
254 * @return command.
255 */
256struct GNUNET_TESTING_Command
257GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label,
258 const char *start_peer_label,
259 uint32_t num);
260
55int 261int
56GNUNET_TRANSPORT_get_trait_peer_id (const struct 262GNUNET_TRANSPORT_get_trait_peer_id (const struct
57 GNUNET_TESTING_Command *cmd, 263 GNUNET_TESTING_Command *cmd,
@@ -65,6 +271,16 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
65 GNUNET_CONTAINER_MultiShortmap * 271 GNUNET_CONTAINER_MultiShortmap *
66 * 272 *
67 connected_peers_map); 273 connected_peers_map);
274
275int
276GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct
277 GNUNET_TESTING_Command
278 *cmd,
279 struct
280 GNUNET_CONTAINER_MultiShortmap
281 *
282 *
283 connected_peers_map);
68int 284int
69GNUNET_TRANSPORT_get_trait_hello_size (const struct 285GNUNET_TRANSPORT_get_trait_hello_size (const struct
70 GNUNET_TESTING_Command 286 GNUNET_TESTING_Command
@@ -77,5 +293,20 @@ GNUNET_TRANSPORT_get_trait_hello (const struct
77 *cmd, 293 *cmd,
78 char **hello); 294 char **hello);
79 295
296
297int
298GNUNET_TRANSPORT_get_trait_application_handle (const struct
299 GNUNET_TESTING_Command *cmd,
300 struct
301 GNUNET_TRANSPORT_ApplicationHandle
302 **ah);
303
304int
305GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct
306 GNUNET_TESTING_Command *cmd,
307 struct
308 GNUNET_TRANSPORT_ApplicationHandle
309 **ah);
310
80#endif 311#endif
81/* end of transport_testing.h */ 312/* end of transport_testing.h */
diff --git a/src/transport/transport-testing-ng.h b/src/transport/transport-testing-ng.h
deleted file mode 100644
index cd4e1f3fe..000000000
--- a/src/transport/transport-testing-ng.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @author t3sserakt
23 */
24
25struct StartPeerState
26{
27 /**
28 * Receive callback
29 */
30 struct GNUNET_MQ_MessageHandler *handlers;
31
32 const char *cfgname;
33
34 /**
35 * Peer's configuration
36 */
37 struct GNUNET_CONFIGURATION_Handle *cfg;
38
39 struct GNUNET_TESTING_Peer *peer;
40
41 /**
42 * Peer identity
43 */
44 struct GNUNET_PeerIdentity id;
45
46 /**
47 * Peer's transport service handle
48 */
49 struct GNUNET_TRANSPORT_CoreHandle *th;
50
51 /**
52 * Application handle
53 */
54 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
55
56 /**
57 * Peer's PEERSTORE Handle
58 */
59 struct GNUNET_PEERSTORE_Handle *ph;
60
61 /**
62 * Hello get task
63 */
64 struct GNUNET_SCHEDULER_Task *rh_task;
65
66 /**
67 * Peer's transport get hello handle to retrieve peer's HELLO message
68 */
69 struct GNUNET_PEERSTORE_IterateContext *pic;
70
71 /**
72 * Hello
73 */
74 char *hello;
75
76 /**
77 * Hello size
78 */
79 size_t hello_size;
80
81 char *m;
82
83 char *n;
84
85 char *local_m;
86
87 unsigned int finished;
88
89 const char *system_label;
90
91 /**
92 * An unique number to identify the peer
93 */
94 unsigned int no;
95
96 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
97
98 struct GNUNET_TESTING_System *tl_system;
99
100};
101
102
103int
104GNUNET_TRANSPORT_get_trait_state (const struct
105 GNUNET_TESTING_Command
106 *cmd,
107 struct StartPeerState **sps);
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 34b3d5925..09ca9e54c 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -42,6 +42,15 @@
42 */ 42 */
43struct ConnectPeersState 43struct ConnectPeersState
44{ 44{
45 // Label of the cmd which started the test system.
46 const char *create_label;
47
48 /**
49 * Number globally identifying the node.
50 *
51 */
52 uint32_t num;
53
45 /** 54 /**
46 * Label of the cmd to start a peer. 55 * Label of the cmd to start a peer.
47 * 56 *
@@ -66,6 +75,13 @@ connect_peers_run (void *cls,
66 struct GNUNET_TESTING_Interpreter *is) 75 struct GNUNET_TESTING_Interpreter *is)
67{ 76{
68 struct ConnectPeersState *cps = cls; 77 struct ConnectPeersState *cps = cls;
78 const struct GNUNET_TESTING_Command *system_cmd;
79 struct GNUNET_TESTING_System *tl_system;
80 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
81 GNUNET_CRYPTO_EddsaPrivateKey);
82 struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
83 GNUNET_CRYPTO_EddsaPublicKey);
84 ;
69 const struct GNUNET_TESTING_Command *peer1_cmd; 85 const struct GNUNET_TESTING_Command *peer1_cmd;
70 // const struct GNUNET_TESTING_Command *peer2_cmd; 86 // const struct GNUNET_TESTING_Command *peer2_cmd;
71 struct GNUNET_TRANSPORT_ApplicationHandle *ah; 87 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
@@ -77,6 +93,8 @@ connect_peers_run (void *cls,
77 enum GNUNET_NetworkType nt = 0; 93 enum GNUNET_NetworkType nt = 0;
78 char *peer_id; 94 char *peer_id;
79 struct GNUNET_PeerIdentity *id; 95 struct GNUNET_PeerIdentity *id;
96 struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
97 uint32_t num;
80 98
81 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); 99 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
82 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, 100 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -88,9 +106,22 @@ connect_peers_run (void *cls,
88 GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, 106 GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
89 &id); 107 &id);
90 108
91 if (strstr (hello, "60002") != NULL) 109 system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
110 GNUNET_TESTING_get_trait_test_system (system_cmd,
111 &tl_system);
112
113 if (2 == cps->num)
114 num = 1;
115 else
116 num = 2;
117
118
119
120
121 // if (strstr (hello, "60002") != NULL)
122 if (2 == num)
92 { 123 {
93 addr = "tcp-192.168.15.2:60003"; 124 addr = "tcp-192.168.15.2:60002";
94 peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; 125 peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
95 } 126 }
96 else 127 else
@@ -99,10 +130,25 @@ connect_peers_run (void *cls,
99 peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; 130 peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
100 } 131 }
101 132
133 priv_key = GNUNET_TESTING_hostkey_get (tl_system,
134 num,
135 other);
136
137 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
138 pub_key);
139
102 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, 140 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
103 strlen (peer_id), 141 strlen (peer_id),
104 &peer->public_key); 142 &peer->public_key);
105 143
144 peer->public_key = *pub_key;
145
146 LOG (GNUNET_ERROR_TYPE_ERROR,
147 "\nnum: %u\n peer_id: %s\n pub_key %s\n",
148 num,
149 peer_id,
150 GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
151
106 cps->id = peer; 152 cps->id = peer;
107 153
108 // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. 154 // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers.
@@ -210,12 +256,16 @@ connect_peers_cleanup (void *cls,
210 */ 256 */
211struct GNUNET_TESTING_Command 257struct GNUNET_TESTING_Command
212GNUNET_TRANSPORT_cmd_connect_peers (const char *label, 258GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
213 const char *start_peer_label) 259 const char *start_peer_label,
260 const char *create_label,
261 uint32_t num)
214{ 262{
215 struct ConnectPeersState *cps; 263 struct ConnectPeersState *cps;
216 264
217 cps = GNUNET_new (struct ConnectPeersState); 265 cps = GNUNET_new (struct ConnectPeersState);
218 cps->start_peer_label = start_peer_label; 266 cps->start_peer_label = start_peer_label;
267 cps->num = num;
268 cps->create_label = create_label;
219 269
220 270
221 struct GNUNET_TESTING_Command cmd = { 271 struct GNUNET_TESTING_Command cmd = {
diff --git a/src/transport/transport_api_cmd_connecting_peers_v2.c b/src/transport/transport_api_cmd_connecting_peers_v2.c
new file mode 100644
index 000000000..0d286b714
--- /dev/null
+++ b/src/transport/transport_api_cmd_connecting_peers_v2.c
@@ -0,0 +1,242 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_start_peer.c
23 * @brief cmd to start a peer.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_transport_application_service.h"
30#include "gnunet_hello_lib.h"
31#include "gnunet_transport_service.h"
32#include "transport-testing-cmds.h"
33
34/**
35 * Generic logging shortcut
36 */
37#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
38
39#define CONNECT_ADDRESS_TEMPLATE "tcp-192.168.15.%u:60002"
40
41/**
42 * Struct to store information needed in callbacks.
43 *
44 */
45struct ConnectPeersState
46{
47 // Label of the cmd which started the test system.
48 const char *create_label;
49
50 /**
51 * Number globally identifying the node.
52 *
53 */
54 uint32_t num;
55
56 /**
57 * Label of the cmd to start a peer.
58 *
59 */
60 const char *start_peer_label;
61
62 /**
63 * The peer identity of this peer.
64 *
65 */
66 struct GNUNET_PeerIdentity *id;
67};
68
69
70/**
71 * The run method of this cmd will connect to peers.
72 *
73 */
74static void
75connect_peers_run (void *cls,
76 const struct GNUNET_TESTING_Command *cmd,
77 struct GNUNET_TESTING_Interpreter *is)
78{
79 struct ConnectPeersState *cps = cls;
80 const struct GNUNET_TESTING_Command *system_cmd;
81 struct GNUNET_TESTING_System *tl_system;
82 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
83 GNUNET_CRYPTO_EddsaPrivateKey);
84 struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
85 GNUNET_CRYPTO_EddsaPublicKey);
86 const struct GNUNET_TESTING_Command *peer1_cmd;
87 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
88 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
89 char *addr;
90 enum GNUNET_NetworkType nt = 0;
91 struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
92 uint32_t num;
93
94 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
95 GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd,
96 &ah);
97
98 system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
99 GNUNET_TESTING_get_trait_test_system (system_cmd,
100 &tl_system);
101
102 if (1 == cps->num)
103 {
104 num = 2;
105 // addr = "tcp-192.168.15.2:60002";
106 }
107 else
108 {
109 num = 1;
110 // addr = "tcp-192.168.15.1:60002";
111 }
112
113 GNUNET_asprintf (&addr,
114 CONNECT_ADDRESS_TEMPLATE,
115 num);
116
117 priv_key = GNUNET_TESTING_hostkey_get (tl_system,
118 num,
119 other);
120
121 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
122 pub_key);
123
124
125 peer->public_key = *pub_key;
126
127 LOG (GNUNET_ERROR_TYPE_ERROR,
128 "num: %u pub_key %s\n",
129 num,
130 GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
131
132 cps->id = peer;
133
134 GNUNET_TRANSPORT_application_validate (ah,
135 peer,
136 nt,
137 addr);
138}
139
140
141/**
142 * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer.
143 *
144 */
145static int
146connect_peers_finish (void *cls,
147 GNUNET_SCHEDULER_TaskCallback cont,
148 void *cont_cls)
149{
150 struct ConnectPeersState *cps = cls;
151 const struct GNUNET_TESTING_Command *peer1_cmd;
152 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
153 unsigned int ret;
154 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
155 struct GNUNET_HashCode hc;
156 int node_number;
157
158 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
159 GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (peer1_cmd,
160 &connected_peers_map);
161
162 node_number = 1;
163 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
164
165 // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
166 memcpy (key,
167 &hc,
168 sizeof (*key));
169 ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map,
170 key);
171
172 if (GNUNET_YES == ret)
173 {
174 cont (cont_cls);
175 }
176
177 GNUNET_free (key);
178 return ret;
179}
180
181
182/**
183 * Trait function of this cmd does nothing.
184 *
185 */
186static int
187connect_peers_traits (void *cls,
188 const void **ret,
189 const char *trait,
190 unsigned int index)
191{
192 return GNUNET_OK;
193}
194
195
196/**
197 * The cleanup function of this cmd frees resources the cmd allocated.
198 *
199 */
200static void
201connect_peers_cleanup (void *cls,
202 const struct GNUNET_TESTING_Command *cmd)
203{
204 struct ConnectPeersState *cps = cls;
205
206 GNUNET_free (cps->id);
207 GNUNET_free (cps);
208}
209
210
211/**
212 * Create command.
213 *
214 * @param label name for command.
215 * @param start_peer_label Label of the cmd to start a peer.
216 * @return command.
217 */
218struct GNUNET_TESTING_Command
219GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label,
220 const char *start_peer_label,
221 const char *create_label,
222 uint32_t num)
223{
224 struct ConnectPeersState *cps;
225
226 cps = GNUNET_new (struct ConnectPeersState);
227 cps->start_peer_label = start_peer_label;
228 cps->num = num;
229 cps->create_label = create_label;
230
231
232 struct GNUNET_TESTING_Command cmd = {
233 .cls = cps,
234 .label = label,
235 .run = &connect_peers_run,
236 .finish = &connect_peers_finish,
237 .cleanup = &connect_peers_cleanup,
238 .traits = &connect_peers_traits
239 };
240
241 return cmd;
242}
diff --git a/src/transport/transport_api_cmd_send_simple_v2.c b/src/transport/transport_api_cmd_send_simple_v2.c
new file mode 100644
index 000000000..d43c0b425
--- /dev/null
+++ b/src/transport/transport_api_cmd_send_simple_v2.c
@@ -0,0 +1,156 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_start_peer.c
23 * @brief cmd to start a peer.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "transport-testing2.h"
30#include "transport-testing-cmds.h"
31
32/**
33 * Struct to hold information for callbacks.
34 *
35 */
36struct SendSimpleState
37{
38 /**
39 * Number globally identifying the node.
40 *
41 */
42 uint32_t num;
43
44 /**
45 * Label of the cmd to start a peer.
46 *
47 */
48 const char *start_peer_label;
49};
50
51
52/**
53 * Trait function of this cmd does nothing.
54 *
55 */
56static int
57send_simple_traits (void *cls,
58 const void **ret,
59 const char *trait,
60 unsigned int index)
61{
62 return GNUNET_OK;
63}
64
65
66/**
67 * The cleanup function of this cmd frees resources the cmd allocated.
68 *
69 */
70static void
71send_simple_cleanup (void *cls,
72 const struct GNUNET_TESTING_Command *cmd)
73{
74 struct SendSimpleState *sss = cls;
75
76 GNUNET_free (sss);
77}
78
79
80/**
81 * The run method of this cmd will send a simple message to the connected peer.
82 *
83 */
84static void
85send_simple_run (void *cls,
86 const struct GNUNET_TESTING_Command *cmd,
87 struct GNUNET_TESTING_Interpreter *is)
88{
89 struct SendSimpleState *sss = cls;
90 struct GNUNET_MQ_Envelope *env;
91 struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
92 struct GNUNET_MQ_Handle *mq;
93 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
94 const struct GNUNET_TESTING_Command *peer1_cmd;
95 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
96 struct GNUNET_HashCode hc;
97 int node_number;
98
99 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
100 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
101 &connected_peers_map);
102
103 node_number = 1;
104 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
105 memcpy (key,
106 &hc,
107 sizeof (*key));
108
109 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
110 key);
111
112 env = GNUNET_MQ_msg_extra (test,
113 2600 - sizeof(*test),
114 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
115 test->num = htonl (sss->num);
116 memset (&test[1],
117 sss->num,
118 2600 - sizeof(*test));
119 GNUNET_MQ_send (mq,
120 env);
121 GNUNET_free (key);
122
123}
124
125
126/**
127 * Create command.
128 *
129 * @param label name for command.
130 * @param m The number of the local node of the actual network namespace.
131 * @param n The number of the actual namespace.
132 * @param num Number globally identifying the node.
133 * @param start_peer_label Label of the cmd to start a peer.
134 * @return command.
135 */
136struct GNUNET_TESTING_Command
137GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label,
138 const char *start_peer_label,
139 uint32_t num)
140{
141 struct SendSimpleState *sss;
142
143 sss = GNUNET_new (struct SendSimpleState);
144 sss->num = num;
145 sss->start_peer_label = start_peer_label;
146
147 struct GNUNET_TESTING_Command cmd = {
148 .cls = sss,
149 .label = label,
150 .run = &send_simple_run,
151 .cleanup = &send_simple_cleanup,
152 .traits = &send_simple_traits
153 };
154
155 return cmd;
156}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 729d981c0..f4e92944b 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -29,7 +29,7 @@
29#include "gnunet_peerstore_service.h" 29#include "gnunet_peerstore_service.h"
30#include "gnunet_transport_core_service.h" 30#include "gnunet_transport_core_service.h"
31#include "gnunet_transport_application_service.h" 31#include "gnunet_transport_application_service.h"
32#include "transport-testing-ng.h" 32#include "transport-testing-cmds.h"
33 33
34/** 34/**
35 * Generic logging shortcut 35 * Generic logging shortcut
@@ -185,6 +185,10 @@ start_peer_run (void *cls,
185 struct GNUNET_PeerIdentity dummy; 185 struct GNUNET_PeerIdentity dummy;
186 const struct GNUNET_TESTING_Command *system_cmd; 186 const struct GNUNET_TESTING_Command *system_cmd;
187 struct GNUNET_TESTING_System *tl_system; 187 struct GNUNET_TESTING_System *tl_system;
188 char *home;
189 char *transport_unix_path;
190 char *communicator_unix_path;
191 char *bindto;
188 192
189 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) 193 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
190 { 194 {
@@ -200,6 +204,34 @@ start_peer_run (void *cls,
200 GNUNET_assert (GNUNET_OK == 204 GNUNET_assert (GNUNET_OK ==
201 GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname)); 205 GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
202 206
207 GNUNET_asprintf (&home,
208 "$GNUNET_TMP/test-transport/api-tcp-p%u",
209 sps->no);
210
211 GNUNET_asprintf (&transport_unix_path,
212 "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
213 sps->no);
214
215 GNUNET_asprintf (&communicator_unix_path,
216 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
217 sps->no);
218
219 GNUNET_asprintf (&bindto,
220 "%s:60002",
221 sps->node_ip);
222
223
224 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
225 home);
226 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
227 transport_unix_path);
228 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
229 "BINDTO",
230 bindto);
231 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
232 "UNIXPATH",
233 communicator_unix_path);
234
203 system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label); 235 system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label);
204 GNUNET_TESTING_get_trait_test_system (system_cmd, 236 GNUNET_TESTING_get_trait_test_system (system_cmd,
205 &tl_system); 237 &tl_system);
@@ -536,6 +568,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
536 char *m, 568 char *m,
537 char *n, 569 char *n,
538 char *local_m, 570 char *local_m,
571 char *node_ip,
539 struct GNUNET_MQ_MessageHandler *handlers, 572 struct GNUNET_MQ_MessageHandler *handlers,
540 const char *cfgname) 573 const char *cfgname)
541{ 574{
@@ -552,6 +585,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
552 sps->system_label = system_label; 585 sps->system_label = system_label;
553 sps->connected_peers_map = connected_peers_map; 586 sps->connected_peers_map = connected_peers_map;
554 sps->cfgname = cfgname; 587 sps->cfgname = cfgname;
588 sps->node_ip = node_ip;
555 589
556 if (NULL != handlers) 590 if (NULL != handlers)
557 { 591 {
diff --git a/src/transport/transport_api_cmd_start_peer_v2.c b/src/transport/transport_api_cmd_start_peer_v2.c
new file mode 100644
index 000000000..0e39bd915
--- /dev/null
+++ b/src/transport/transport_api_cmd_start_peer_v2.c
@@ -0,0 +1,607 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_start_peer.c
23 * @brief cmd to start a peer.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_peerstore_service.h"
30#include "gnunet_transport_core_service.h"
31#include "gnunet_transport_application_service.h"
32#include "transport-testing-cmds.h"
33
34/**
35 * Generic logging shortcut
36 */
37#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
38
39
40static void
41retrieve_hello (void *cls);
42
43
44/**
45 * Callback delivering the hello of this peer from peerstore.
46 *
47 */
48static void
49hello_iter_cb (void *cb_cls,
50 const struct GNUNET_PEERSTORE_Record *record,
51 const char *emsg)
52{
53 struct StartPeerState_v2 *sps = cb_cls;
54 if (NULL == record)
55 {
56 sps->pic = NULL;
57 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
58 return;
59 }
60 // Check record type et al?
61 sps->hello_size = record->value_size;
62 sps->hello = GNUNET_malloc (sps->hello_size);
63 memcpy (sps->hello, record->value, sps->hello_size);
64 sps->hello[sps->hello_size - 1] = '\0';
65
66 GNUNET_PEERSTORE_iterate_cancel (sps->pic);
67 sps->pic = NULL;
68 sps->finished = GNUNET_YES;
69}
70
71
72/**
73 * Function to start the retrieval task to retrieve the hello of this peer
74 * from the peerstore.
75 *
76 */
77static void
78retrieve_hello (void *cls)
79{
80 struct StartPeerState_v2 *sps = cls;
81 sps->rh_task = NULL;
82 sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
83 "transport",
84 &sps->id,
85 GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
86 hello_iter_cb,
87 sps);
88
89}
90
91
92/**
93 * This function checks StartPeerState_v2#finished, which is set when the hello was retrieved.
94 *
95 */
96static int
97start_peer_finish (void *cls,
98 GNUNET_SCHEDULER_TaskCallback cont,
99 void *cont_cls)
100{
101 struct StartPeerState_v2 *sps = cls;
102
103 if (GNUNET_YES == sps->finished)
104 {
105 cont (cont_cls);
106 }
107
108 return sps->finished;
109}
110
111
112/**
113 * Disconnect callback for the connection to the core service.
114 *
115 */
116static void
117notify_disconnect (void *cls,
118 const struct GNUNET_PeerIdentity *peer,
119 void *handler_cls)
120{
121 struct StartPeerState_v2 *sps = cls;
122
123 LOG (GNUNET_ERROR_TYPE_DEBUG,
124 "Peer %s disconnected from peer %u (`%s')\n",
125 GNUNET_i2s (peer),
126 sps->no,
127 GNUNET_i2s (&sps->id));
128
129}
130
131
132/**
133 * Connect callback for the connection to the core service.
134 *
135 */
136static void *
137notify_connect (void *cls,
138 const struct GNUNET_PeerIdentity *peer,
139 struct GNUNET_MQ_Handle *mq)
140{
141 struct StartPeerState_v2 *sps = cls;
142 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
143 struct GNUNET_HashCode hc;
144 int node_number;
145
146 void *ret = NULL;
147
148
149 LOG (GNUNET_ERROR_TYPE_DEBUG,
150 "Peer %s connected to peer %u (`%s')\n",
151 GNUNET_i2s (peer),
152 sps->no,
153 GNUNET_i2s (&sps->id));
154
155 // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
156 node_number = 1;
157 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
158
159
160 memcpy (key,
161 &hc,
162 sizeof (*key));
163 GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map,
164 key,
165 mq,
166 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
167
168 GNUNET_free (key);
169 // TODO what does the handler function need?
170 return ret;
171}
172
173
174/**
175 * The run method of this cmd will start all services of a peer to test the transport service.
176 *
177 */
178static void
179start_peer_run (void *cls,
180 const struct GNUNET_TESTING_Command *cmd,
181 struct GNUNET_TESTING_Interpreter *is)
182{
183 struct StartPeerState_v2 *sps = cls;
184 char *emsg = NULL;
185 struct GNUNET_PeerIdentity dummy;
186 const struct GNUNET_TESTING_Command *system_cmd;
187 struct GNUNET_TESTING_System *tl_system;
188 char *home;
189 char *transport_unix_path;
190 char *communicator_unix_path;
191 char *bindto;
192
193 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
194 {
195 LOG (GNUNET_ERROR_TYPE_ERROR,
196 "File not found: `%s'\n",
197 sps->cfgname);
198 GNUNET_TESTING_interpreter_fail ();
199 return;
200 }
201
202
203 sps->cfg = GNUNET_CONFIGURATION_create ();
204 GNUNET_assert (GNUNET_OK ==
205 GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
206
207 GNUNET_asprintf (&home,
208 "$GNUNET_TMP/test-transport/api-tcp-p%u",
209 sps->no);
210
211 GNUNET_asprintf (&transport_unix_path,
212 "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
213 sps->no);
214
215 GNUNET_asprintf (&communicator_unix_path,
216 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
217 sps->no);
218
219 GNUNET_asprintf (&bindto,
220 "%s:60002",
221 sps->node_ip);
222
223
224 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
225 home);
226 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
227 transport_unix_path);
228 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
229 "BINDTO",
230 bindto);
231 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
232 "UNIXPATH",
233 communicator_unix_path);
234
235 system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label);
236 GNUNET_TESTING_get_trait_test_system (system_cmd,
237 &tl_system);
238
239 sps->tl_system = tl_system;
240
241 if (GNUNET_SYSERR ==
242 GNUNET_TESTING_configuration_create (tl_system,
243 sps->cfg))
244 {
245 LOG (GNUNET_ERROR_TYPE_ERROR,
246 "Testing library failed to create unique configuration based on `%s'\n",
247 sps->cfgname);
248 GNUNET_CONFIGURATION_destroy (sps->cfg);
249 GNUNET_TESTING_interpreter_fail ();
250 return;
251 }
252
253 sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system,
254 sps->cfg,
255 sps->no,
256 NULL,
257 &emsg);
258 if (NULL == sps->peer)
259 {
260 LOG (GNUNET_ERROR_TYPE_ERROR,
261 "Testing library failed to create unique configuration based on `%s': `%s'\n",
262 sps->cfgname,
263 emsg);
264 GNUNET_free (emsg);
265 GNUNET_TESTING_interpreter_fail ();
266 return;
267 }
268
269 if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer))
270 {
271 LOG (GNUNET_ERROR_TYPE_ERROR,
272 "Testing library failed to create unique configuration based on `%s'\n",
273 sps->cfgname);
274 GNUNET_free (emsg);
275 GNUNET_TESTING_interpreter_fail ();
276 return;
277 }
278
279 memset (&dummy,
280 '\0',
281 sizeof(dummy));
282
283 GNUNET_TESTING_peer_get_identity (sps->peer,
284 &sps->id);
285
286 if (0 == memcmp (&dummy,
287 &sps->id,
288 sizeof(struct GNUNET_PeerIdentity)))
289 {
290 LOG (GNUNET_ERROR_TYPE_ERROR,
291 "Testing library failed to obtain peer identity for peer %u\n",
292 sps->no);
293 GNUNET_free (emsg);
294 GNUNET_TESTING_interpreter_fail ();
295 return;
296 }
297 LOG (GNUNET_ERROR_TYPE_DEBUG,
298 "Peer %u configured with identity `%s'\n",
299 sps->no,
300 GNUNET_i2s_full (&sps->id));
301
302 sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg,
303 NULL,
304 sps->handlers,
305 sps,
306 &notify_connect,
307 &notify_disconnect);
308 if (NULL == sps->th)
309 {
310 LOG (GNUNET_ERROR_TYPE_ERROR,
311 "Failed to connect to transport service for peer `%s': `%s'\n",
312 sps->cfgname,
313 emsg);
314 GNUNET_free (emsg);
315 GNUNET_TESTING_interpreter_fail ();
316 return;
317 }
318
319 sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
320 if (NULL == sps->th)
321 {
322 LOG (GNUNET_ERROR_TYPE_ERROR,
323 "Failed to connect to peerstore service for peer `%s': `%s'\n",
324 sps->cfgname,
325 emsg);
326 GNUNET_free (emsg);
327 GNUNET_TESTING_interpreter_fail ();
328 return;
329 }
330
331 sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
332 if (NULL == sps->ah)
333 {
334 LOG (GNUNET_ERROR_TYPE_ERROR,
335 "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n",
336 sps->cfgname,
337 emsg);
338 GNUNET_free (emsg);
339 GNUNET_TESTING_interpreter_fail ();
340 return;
341 }
342 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
343}
344
345
346/**
347 * The cleanup function of this cmd frees resources the cmd allocated.
348 *
349 */
350static void
351start_peer_cleanup (void *cls,
352 const struct GNUNET_TESTING_Command *cmd)
353{
354 struct StartPeerState_v2 *sps = cls;
355
356 if (NULL != sps->handlers)
357 {
358 GNUNET_free (sps->handlers);
359 sps->handlers = NULL;
360 }
361 if (NULL != sps->cfg)
362 {
363 GNUNET_CONFIGURATION_destroy (sps->cfg);
364 sps->cfg = NULL;
365 }
366 GNUNET_free (sps->hello);
367 GNUNET_free (sps->connected_peers_map);
368 GNUNET_free (sps);
369}
370
371
372/**
373 * This function prepares an array with traits.
374 *
375 */
376static int
377start_peer_traits (void *cls,
378 const void **ret,
379 const char *trait,
380 unsigned int index)
381{
382 struct StartPeerState_v2 *sps = cls;
383 struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
384 struct GNUNET_PeerIdentity *id = &sps->id;
385 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
386 sps->connected_peers_map;
387 char *hello = sps->hello;
388 size_t hello_size = sps->hello_size;
389
390
391 struct GNUNET_TESTING_Trait traits[] = {
392 {
393 .index = 0,
394 .trait_name = "application_handle",
395 .ptr = (const void *) ah,
396 },
397 {
398 .index = 1,
399 .trait_name = "peer_id",
400 .ptr = (const void *) id,
401 },
402 {
403 .index = 2,
404 .trait_name = "connected_peers_map",
405 .ptr = (const void *) connected_peers_map,
406 },
407 {
408 .index = 3,
409 .trait_name = "hello",
410 .ptr = (const void *) hello,
411 },
412 {
413 .index = 4,
414 .trait_name = "hello_size",
415 .ptr = (const void *) hello_size,
416 },
417 {
418 .index = 5,
419 .trait_name = "state",
420 .ptr = (const void *) sps,
421 },
422 GNUNET_TESTING_trait_end ()
423 };
424
425 return GNUNET_TESTING_get_trait (traits,
426 ret,
427 trait,
428 index);
429}
430
431
432/**
433 * Function to get the trait with the struct StartPeerState_v2.
434 *
435 * @param[out] sps struct StartPeerState_v2.
436 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
437 *
438 */
439int
440GNUNET_TRANSPORT_get_trait_state_v2 (const struct
441 GNUNET_TESTING_Command
442 *cmd,
443 struct StartPeerState_v2 **sps)
444{
445 return cmd->traits (cmd->cls,
446 (const void **) sps,
447 "state",
448 (unsigned int) 5);
449}
450
451
452/**
453 * Function to get the trait with the size of the hello.
454 *
455 * @param[out] hello_size size of hello.
456 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
457 *
458 */
459int
460GNUNET_TRANSPORT_get_trait_hello_size_v2 (const struct
461 GNUNET_TESTING_Command
462 *cmd,
463 size_t **hello_size)
464{
465 return cmd->traits (cmd->cls,
466 (const void **) hello_size,
467 "hello_size",
468 (unsigned int) 4);
469}
470
471
472/**
473 * Function to get the trait with the hello.
474 *
475 * @param[out] hello The hello for the peer.
476 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
477 *
478 */
479int
480GNUNET_TRANSPORT_get_trait_hello_v2 (const struct
481 GNUNET_TESTING_Command
482 *cmd,
483 char **hello)
484{
485 return cmd->traits (cmd->cls,
486 (const void **) hello,
487 "hello",
488 (unsigned int) 3);
489}
490
491
492/**
493 * Function to get the trait with the map of connected peers.
494 *
495 * @param[out] connected_peers_map The map with connected peers.
496 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
497 *
498 */
499int
500GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct
501 GNUNET_TESTING_Command
502 *cmd,
503 struct
504 GNUNET_CONTAINER_MultiShortmap
505 *
506 *
507 connected_peers_map)
508{
509 return cmd->traits (cmd->cls,
510 (const void **) connected_peers_map,
511 "connected_peers_map",
512 (unsigned int) 2);
513}
514
515
516/**
517 * Function to get the trait with the transport application handle.
518 *
519 * @param[out] ah The application handle.
520 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
521 */
522int
523GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct
524 GNUNET_TESTING_Command *cmd,
525 struct
526 GNUNET_TRANSPORT_ApplicationHandle
527 **ah)
528{
529 return cmd->traits (cmd->cls,
530 (const void **) ah,
531 "application_handle",
532 (unsigned int) 0);
533}
534
535
536/**
537 * Function to get the trait with the peer id.
538 *
539 * @param[out] id The peer id.
540 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
541 */
542int
543GNUNET_TRANSPORT_get_trait_peer_id_v2 (const struct
544 GNUNET_TESTING_Command *cmd,
545 struct GNUNET_PeerIdentity **id)
546{
547 return cmd->traits (cmd->cls,
548 (const void **) id,
549 "peer_id",
550 (unsigned int) 1);
551}
552
553
554/**
555 * Create command.
556 *
557 * @param label name for command.
558 * @param system_label Label of the cmd to setup a test environment.
559 * @param m The number of the local node of the actual network namespace.
560 * @param n The number of the actual namespace.
561 * @param local_m Number of local nodes in each namespace.
562 * @param handlers Handler for messages received by this peer.
563 * @param cfgname Configuration file name for this peer.
564 * @return command.
565 */
566struct GNUNET_TESTING_Command
567GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label,
568 const char *system_label,
569 uint32_t no,
570 char *node_ip,
571 struct GNUNET_MQ_MessageHandler *handlers,
572 const char *cfgname)
573{
574 struct StartPeerState_v2 *sps;
575 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
576 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
577 unsigned int i;
578
579 sps = GNUNET_new (struct StartPeerState_v2);
580 sps->no = no;
581 sps->system_label = system_label;
582 sps->connected_peers_map = connected_peers_map;
583 sps->cfgname = cfgname;
584 sps->node_ip = node_ip;
585
586 if (NULL != handlers)
587 {
588 for (i = 0; NULL != handlers[i].cb; i++)
589 ;
590 sps->handlers = GNUNET_new_array (i + 1,
591 struct GNUNET_MQ_MessageHandler);
592 GNUNET_memcpy (sps->handlers,
593 handlers,
594 i * sizeof(struct GNUNET_MQ_MessageHandler));
595 }
596
597 struct GNUNET_TESTING_Command cmd = {
598 .cls = sps,
599 .label = label,
600 .run = &start_peer_run,
601 .finish = &start_peer_finish,
602 .cleanup = &start_peer_cleanup,
603 .traits = &start_peer_traits
604 };
605
606 return cmd;
607}
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index 7a0050a63..4d7228378 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -29,7 +29,7 @@
29#include "gnunet_peerstore_service.h" 29#include "gnunet_peerstore_service.h"
30#include "gnunet_transport_core_service.h" 30#include "gnunet_transport_core_service.h"
31#include "gnunet_transport_application_service.h" 31#include "gnunet_transport_application_service.h"
32#include "transport-testing-ng.h" 32#include "transport-testing-cmds.h"
33 33
34/** 34/**
35 * Generic logging shortcut 35 * Generic logging shortcut