summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am82
-rw-r--r--src/transport/gnunet-communicator-tcp.c136
-rw-r--r--src/transport/gnunet-communicator-udp.c149
-rw-r--r--src/transport/gnunet-service-tng.c358
-rw-r--r--src/transport/tcp_service_legacy.c14
-rw-r--r--src/transport/test_transport_api2_tcp_node1.conf10
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c274
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_broadcast.c398
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_dv.c375
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_v2.c234
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c356
-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
-rwxr-xr-xsrc/transport/test_transport_simple_send.sh10
-rwxr-xr-xsrc/transport/test_transport_simple_send_broadcast.sh11
-rw-r--r--src/transport/test_transport_simple_send_broadcast_topo.conf4
-rwxr-xr-xsrc/transport/test_transport_simple_send_dv.sh11
-rwxr-xr-xsrc/transport/test_transport_simple_send_string.sh19
-rw-r--r--src/transport/test_transport_simple_send_topo.conf6
-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/test_transport_start_with_config.c121
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh12
-rw-r--r--src/transport/test_transport_udp_backchannel_topo.conf7
-rw-r--r--src/transport/transport-testing-cmds.h312
-rw-r--r--src/transport/transport_api2_communication.c9
-rw-r--r--src/transport/transport_api2_core.c5
-rw-r--r--src/transport/transport_api_cmd_backchannel_check.c602
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c294
-rw-r--r--src/transport/transport_api_cmd_connecting_peers_v2.c242
-rw-r--r--src/transport/transport_api_cmd_send_simple.c164
-rw-r--r--src/transport/transport_api_cmd_send_simple_v2.c156
-rw-r--r--src/transport/transport_api_cmd_start_peer.c300
-rw-r--r--src/transport/transport_api_cmd_start_peer_v2.c607
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c37
-rw-r--r--src/transport/transport_api_traits.c32
38 files changed, 3239 insertions, 2888 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 561ac5e60..751bc40c1 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -123,16 +123,15 @@ endif
noinst_PROGRAMS = \
+ test_transport_start_with_config \
gnunet-transport-profiler \
gnunet-communicator-udp \
$(WLAN_BIN_SENDER) \
$(WLAN_BIN_RECEIVER)
-if HAVE_TESTING
TESTING_LIBS = \
libgnunettransporttesting.la \
libgnunettransporttesting2.la
-endif
lib_LTLIBRARIES = \
libgnunettransport.la \
@@ -160,13 +159,12 @@ libgnunettransporttesting_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
libgnunettransporttesting2_la_SOURCES = \
+ transport_api_traits.c \
transport_api_cmd_connecting_peers.c \
- transport_api_cmd_connecting_peers_v2.c \
+ transport_api_cmd_backchannel_check.c \
transport_api_cmd_start_peer.c \
- transport_api_cmd_start_peer_v2.c \
transport_api_cmd_stop_peer.c \
transport_api_cmd_send_simple.c \
- transport_api_cmd_send_simple_v2.c \
transport-testing2.c transport-testing2.h \
transport-testing-cmds.h \
transport-testing-filenames2.c \
@@ -394,7 +392,26 @@ plugin_LTLIBRARIES = \
$(WLAN_PLUGIN_LA) \
$(BT_PLUGIN_LA) \
libgnunet_test_transport_plugin_cmd_simple_send.la \
- libgnunet_test_transport_plugin_cmd_simple_send_v2.la
+ libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \
+ libgnunet_test_transport_plugin_cmd_simple_send_dv.la \
+ libgnunet_test_transport_plugin_cmd_udp_backchannel.la
+
+libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \
+ test_transport_plugin_cmd_udp_backchannel.c
+libgnunet_test_transport_plugin_cmd_udp_backchannel_la_LIBADD = \
+ libgnunettransporttesting2.la \
+ libgnunettransportapplication.la \
+ libgnunettransportcore.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_test_transport_plugin_cmd_udp_backchannel_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \
test_transport_plugin_cmd_simple_send.c
@@ -413,9 +430,26 @@ libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \
libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-libgnunet_test_transport_plugin_cmd_simple_send_v2_la_SOURCES = \
- test_transport_plugin_cmd_simple_send_v2.c
-libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \
+libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_SOURCES = \
+ test_transport_plugin_cmd_simple_send_broadcast.c
+libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_LIBADD = \
+ libgnunettransporttesting2.la \
+ libgnunettransportapplication.la \
+ libgnunettransportcore.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_test_transport_plugin_cmd_simple_send_dv_la_SOURCES = \
+ test_transport_plugin_cmd_simple_send_dv.c
+libgnunet_test_transport_plugin_cmd_simple_send_dv_la_LIBADD = \
libgnunettransporttesting2.la \
libgnunettransportapplication.la \
libgnunettransportcore.la \
@@ -427,7 +461,7 @@ libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \
$(top_builddir)/src/arm/libgnunetarm.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(LTLIBINTL)
-libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LDFLAGS = \
+libgnunet_test_transport_plugin_cmd_simple_send_dv_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
if HAVE_EXPERIMENTAL
@@ -574,10 +608,7 @@ libgnunet_plugin_transport_https_server_la_LDFLAGS = \
libgnunet_plugin_transport_https_server_la_CFLAGS = \
$(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS
-if HAVE_TESTING
check_PROGRAMS = \
- test_transport_simple_send \
- test_transport_simple_send_v2 \
test_transport_address_switch_tcp \
test_transport_testing_startstop \
test_transport_testing_restart \
@@ -661,7 +692,6 @@ check_PROGRAMS += \
test_communicator_backchannel-udp \
test_communicator_bidirect-tcp
endif
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
@@ -726,8 +756,6 @@ test_transport_api_slow_ats
endif
if HAVE_EXPERIMENTAL
TESTS += \
- test_transport_simple_send \
- test_transport_simple_send_v2 \
test_transport_address_switch_udp \
test_plugin_udp \
test_transport_api_udp \
@@ -746,25 +774,16 @@ endif
endif
check_SCRIPTS= \
+ test_transport_simple_send_string.sh \
test_transport_simple_send.sh \
- test_transport_simple_send_v2.sh
-
-test_transport_simple_send_SOURCES = \
- test_transport_simple_send.c
-test_transport_simple_send_LDADD = \
- $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testbed/libgnunettestbed.la \
- $(top_builddir)/src/hello/libgnunethello.la \
- libgnunettransportcore.la \
- libgnunettransporttesting2.la
+ test_transport_simple_send_broadcast.sh \
+ test_transport_udp_backchannel.sh
-test_transport_simple_send_v2_SOURCES = \
- test_transport_simple_send_v2.c
-test_transport_simple_send_v2_LDADD = \
+test_transport_start_with_config_SOURCES = \
+ test_transport_start_with_config.c
+test_transport_start_with_config_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testbed/libgnunettestbed.la \
$(top_builddir)/src/hello/libgnunethello.la \
libgnunettransportcore.la \
libgnunettransporttesting2.la
@@ -1500,6 +1519,7 @@ test_transport_api_slow_ats_LDADD = \
EXTRA_DIST = \
+$(check_SCRIPTS) \
gnunet-transport-certificate-creation.in \
communicator-unix.conf \
test_plugin_hostkey \
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index d8bf7c1a8..2a5e33e2b 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -1119,6 +1119,10 @@ pass_plaintext_to_core (struct Queue *queue,
const struct GNUNET_MessageHeader *hdr = plaintext;
int ret;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "pass message from %s to core\n",
+ GNUNET_i2s (&queue->target));
+
if (ntohs (hdr->size) != plaintext_len)
{
/* NOTE: If we ever allow multiple CORE messages in one
@@ -1132,6 +1136,8 @@ pass_plaintext_to_core (struct Queue *queue,
ADDRESS_VALIDITY_PERIOD,
&core_read_finished_cb,
queue);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "passed to core\n");
if (GNUNET_OK == ret)
queue->backpressure++;
GNUNET_break (GNUNET_NO != ret); /* backpressure not working!? */
@@ -1795,7 +1801,7 @@ try_handle_plaintext (struct Queue *queue)
queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch,
&queue->target,
foreign_addr,
- UINT32_MAX, /* no MTU */
+ UINT16_MAX, /* no MTU */
GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED,
0, /* Priority */
queue->nt,
@@ -2004,7 +2010,8 @@ queue_read (void *cls)
* @return The struct sockaddr *.
*/
static struct sockaddr *
-tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
+tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len,
+ struct sockaddr_in6 v6,
unsigned int port)
{
struct sockaddr *in;
@@ -2031,7 +2038,8 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
* @return The struct sockaddr *.
*/
static struct sockaddr *
-tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4,
+tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len,
+ struct sockaddr_in v4,
unsigned int port)
{
struct sockaddr *in;
@@ -2116,7 +2124,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
static char *
extract_address (const char *bindto)
{
-
+ char *addr;
char *start;
char *token;
char *cp;
@@ -2141,6 +2149,7 @@ extract_address (const char *bindto)
{
start++; /* skip over '['*/
cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
+ addr = GNUNET_strdup (start);
}
else
{
@@ -2148,23 +2157,21 @@ extract_address (const char *bindto)
if (strlen (bindto) == strlen (token))
{
token = strtok_r (cp, ":", &rest);
+ addr = GNUNET_strdup (token);
}
else
{
token++;
res = GNUNET_strdup (token);
- GNUNET_free (cp);
- return res;
+ addr = GNUNET_strdup (res);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "extract address 3\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "extract address with start %s\n",
- start);
-
- return GNUNET_strdup (start);
+ "tcp address: %s\n",
+ addr);
+ GNUNET_free (cp);
+ return addr;
}
@@ -2235,6 +2242,7 @@ extract_port (const char *addr_and_port)
GNUNET_free (cp);
return 0;
}
+ GNUNET_free (cp);
}
else
{
@@ -2244,7 +2252,6 @@ extract_port (const char *addr_and_port)
port = 0;
}
-
return port;
}
@@ -2265,9 +2272,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
struct sockaddr_in6 v6;
char *start;
- // cp = GNUNET_strdup (bindto);
start = extract_address (bindto);
-
+ // FIXME: check NULL == start
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"start %s\n",
start);
@@ -2444,7 +2450,7 @@ boot_queue (struct Queue *queue)
* Generate and transmit our ephemeral key and the signature for
* the initial KX with the other peer. Must be called first, before
* any other bytes are ever written to the output buffer. Note that
- * our cipher must already be initialized when calling this function.
+ * our cipher must already be initialized when calling thi function.
* Helper function for #start_initial_kx_out().
*
* @param queue queue to do KX for
@@ -2550,11 +2556,17 @@ handshake_monotime_cb (void *cls,
handshake_monotonic_time = &queue->handshake_monotonic_time;
pid = &queue->target;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp handshake with us %s\n",
+ GNUNET_i2s (&my_identity));
if (NULL == record)
{
queue->handshake_monotime_get = NULL;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp handshake from peer %s\n",
+ GNUNET_i2s (pid));
if (sizeof(*mtbe) != record->value_size)
{
GNUNET_break (0);
@@ -2604,6 +2616,7 @@ decrypt_and_check_tc (struct Queue *queue,
char *ibuf)
{
struct TcpHandshakeSignature ths;
+ enum GNUNET_GenericReturnValue ret;
GNUNET_assert (
0 ==
@@ -2619,18 +2632,20 @@ decrypt_and_check_tc (struct Queue *queue,
memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey));
ths.monotonic_time = tc->monotonic_time;
ths.challenge = tc->challenge;
- queue->handshake_monotime_get =
- GNUNET_PEERSTORE_iterate (peerstore,
- "transport_tcp_communicator",
- &queue->target,
- GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
- &handshake_monotime_cb,
- queue);
- return GNUNET_CRYPTO_eddsa_verify (
+ ret = GNUNET_CRYPTO_eddsa_verify (
GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE,
&ths,
&tc->sender_sig,
&tc->sender.public_key);
+ if (GNUNET_YES == ret)
+ queue->handshake_monotime_get =
+ GNUNET_PEERSTORE_iterate (peerstore,
+ "transport_tcp_communicator",
+ &queue->target,
+ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
+ &handshake_monotime_cb,
+ queue);
+ return ret;
}
@@ -2725,6 +2740,9 @@ proto_read_kx (void *cls)
queue->listen_sock = pq->listen_sock;
queue->sock = pq->sock;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "created queue with target %s\n",
+ GNUNET_i2s (&queue->target));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"start kx proto\n");
@@ -2984,6 +3002,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
queue->sock = sock;
queue->cs = GNUNET_TRANSPORT_CS_OUTBOUND;
boot_queue (queue);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "booted queue with target %s\n",
+ GNUNET_i2s (&queue->target));
// queue->mq_awaits_continue = GNUNET_YES;
queue->read_task =
GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
@@ -3254,7 +3275,7 @@ init_socket (struct sockaddr *addr,
return GNUNET_SYSERR;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"address %s\n",
GNUNET_a2s (addr, in_len));
@@ -3388,35 +3409,35 @@ init_socket (struct sockaddr *addr,
static void
nat_register ()
{
-
struct sockaddr **saddrs;
socklen_t *saddr_lens;
int i;
- struct Addresses *pos;
-
+ size_t len;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"starting nat register!\n");
-
+ len = 0;
i = 0;
- saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *));
-
- saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t));
-
- for (pos = addrs_head; NULL != pos; pos = pos->next)
+ saddrs = GNUNET_malloc ((addrs_lens) * sizeof(struct sockaddr *));
+ saddr_lens = GNUNET_malloc ((addrs_lens) * sizeof(socklen_t));
+ for (struct Addresses *pos = addrs_head; NULL != pos; pos = pos->next)
{
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"registering address %s\n",
GNUNET_a2s (addrs_head->addr, addrs_head->addr_len));
saddr_lens[i] = addrs_head->addr_len;
+ len += saddr_lens[i];
saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]);
-
i++;
-
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "registering addresses %lu %lu %lu %lu\n",
+ (addrs_lens) * sizeof(struct sockaddr *),
+ (addrs_lens) * sizeof(socklen_t),
+ len,
+ sizeof(COMMUNICATOR_CONFIG_SECTION));
nat = GNUNET_NAT_register (cfg,
COMMUNICATOR_CONFIG_SECTION,
IPPROTO_TCP,
@@ -3426,9 +3447,6 @@ nat_register ()
&nat_address_cb,
NULL /* FIXME: support reversal: #5529 */,
NULL /* closure */);
-
- i = 0;
-
for (i = addrs_lens - 1; i >= 0; i--)
GNUNET_free (saddrs[i]);
GNUNET_free (saddrs);
@@ -3461,7 +3479,7 @@ init_socket_resolv (void *cls,
struct sockaddr *in;
(void) cls;
- if (NULL != addr)
+ if (NULL != addr)
{
if (AF_INET == addr->sa_family)
{
@@ -3495,7 +3513,6 @@ init_socket_resolv (void *cls,
return;
}
nat_register ();
-
}
}
@@ -3567,25 +3584,19 @@ run (void *cls,
if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy))
{
po = tcp_address_to_sockaddr_port_only (bindto, &bind_port);
-
addr_len_ipv4 = po->addr_len_ipv4;
-
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"address po %s\n",
GNUNET_a2s (po->addr_ipv4, addr_len_ipv4));
-
if (NULL != po->addr_ipv4)
{
init_socket (po->addr_ipv4, addr_len_ipv4);
}
-
if (NULL != po->addr_ipv6)
{
addr_len_ipv6 = po->addr_len_ipv6;
init_socket (po->addr_ipv6, addr_len_ipv6);
}
-
GNUNET_free (po);
nat_register ();
GNUNET_free (bindto);
@@ -3593,7 +3604,7 @@ run (void *cls,
}
start = extract_address (bindto);
-
+ // FIXME: check for NULL == start...
if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
{
bind_port = extract_port (bindto);
@@ -3617,10 +3628,9 @@ run (void *cls,
return;
}
-
bind_port = extract_port (bindto);
-
- resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":",
+ resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto,
+ ":",
&rest),
AF_UNSPEC,
GNUNET_TIME_UNIT_MINUTES,
@@ -3646,16 +3656,22 @@ main (int argc, char *const *argv)
};
int ret;
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Starting tcp communicator\n");
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
- ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-communicator-tcp",
- _ ("GNUnet TCP communicator"),
- options,
- &run,
- NULL))
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-communicator-tcp",
+ _ ("GNUnet TCP communicator"),
+ options,
+ &run,
+ NULL))
? 0
: 1;
GNUNET_free_nz ((void *) argv);
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index ef7b1d6c0..201e94e80 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1494,7 +1494,27 @@ add_acks (struct SharedSecret *ss, int acks_to_add)
GNUNET_assert (NULL != ss);
GNUNET_assert (NULL != receiver);
- GNUNET_assert (NULL != receiver->d_qh);
+
+ if (NULL == receiver->d_qh)
+ {
+ receiver->d_qh =
+ GNUNET_TRANSPORT_communicator_mq_add (ch,
+ &receiver->target,
+ receiver->foreign_addr,
+ receiver->d_mtu,
+ acks_to_add,
+ 1, /* Priority */
+ receiver->nt,
+ GNUNET_TRANSPORT_CS_OUTBOUND,
+ receiver->d_mq);
+ }
+ else
+ {
+ GNUNET_TRANSPORT_communicator_mq_update (ch,
+ receiver->d_qh,
+ acks_to_add,
+ 1);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tell transport we have %u more acks!\n",
@@ -1502,10 +1522,7 @@ add_acks (struct SharedSecret *ss, int acks_to_add)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%u kce for rekeying.\n",
receiver->number_rekeying_kce);
- GNUNET_TRANSPORT_communicator_mq_update (ch,
- receiver->d_qh,
- acks_to_add,
- 1);
+
// Until here for alternativ 1
/* move ss to head to avoid discarding it anytime soon! */
@@ -1744,7 +1761,7 @@ kce_generate_cb (void *cls)
if (((GNUNET_NO == ss->sender->rekeying) && (ss->sender->acks_available <
KCN_TARGET) ) ||
((ss->sender->ss_rekey == ss) && (GNUNET_YES == ss->sender->rekeying) &&
- (ss->sender->acks_available < 128)))
+ (ss->sender->acks_available < KCN_TARGET)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1754,20 +1771,24 @@ kce_generate_cb (void *cls)
for (int i = 0; i < GENERATE_AT_ONCE; i++)
kce_generate (ss, ++ss->sequence_allowed);
- ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed (
- WORKING_QUEUE_INTERVALL,
- kce_generate_cb,
- ss);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "We have enough keys.\n");
- ss_finished = ss;
- ss->sender->kce_task_finished = GNUNET_YES;
+ if (KCN_TARGET > ss->sender->acks_available)
+ {
+ ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed (
+ WORKING_QUEUE_INTERVALL,
+ kce_generate_cb,
+ ss);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "We have enough keys.\n");
+ ss_finished = ss;
+ ss->sender->kce_task_finished = GNUNET_YES;
+ }
}
+
}
@@ -1850,7 +1871,17 @@ consider_ss_ack (struct SharedSecret *ss, int initial)
kce_generate (ss, ++ss->sequence_allowed);
}*/
- if (((NULL != kce_task) && kce_task_finished) || (GNUNET_NO == initial))
+ if (NULL != kce_task)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "kce_task is not NULL\n");
+ if (kce_task_finished)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "kce_task_finished: GNUNET_YES\n");
+ if (initial)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "initial: GNUNET_YES\n");
+
+ if ( kce_task_finished || (GNUNET_NO == initial))
{
struct UDPAck ack;
struct SharedSecret *ss_tell;
@@ -1877,8 +1908,7 @@ consider_ss_ack (struct SharedSecret *ss, int initial)
if (GNUNET_NO != initial)
{
destroy_all_secrets (ss, GNUNET_YES);
- kce_task = NULL;
- kce_task_finished = GNUNET_NO;
+ ss->sender->kce_task_finished = GNUNET_NO;
}
}
else if ((NULL == kce_task) && ((KCN_THRESHOLD >
@@ -2232,6 +2262,7 @@ static void
sock_read (void *cls)
{
struct sockaddr_storage sa;
+ struct sockaddr_in *addr_verify;
socklen_t salen = sizeof(sa);
char buf[UINT16_MAX];
ssize_t rcvd;
@@ -2311,12 +2342,29 @@ sock_read (void *cls)
{
const struct UDPBroadcast *ub;
struct UdpBroadcastSignature uhs;
+ struct GNUNET_PeerIdentity sender;
+ addr_verify = GNUNET_memdup (&sa, salen);
+ addr_verify->sin_port = 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "received UDPBroadcast from %s\n",
+ GNUNET_a2s ((const struct sockaddr *) addr_verify, salen));
ub = (const struct UDPBroadcast *) buf;
uhs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST);
uhs.purpose.size = htonl (sizeof(uhs));
uhs.sender = ub->sender;
- GNUNET_CRYPTO_hash (&sa, salen, &uhs.h_address);
+ sender = ub->sender;
+ if (0 == memcmp (&sender, &my_identity, sizeof (struct
+ GNUNET_PeerIdentity)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received our own broadcast\n");
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "checking UDPBroadcastSignature for %s\n",
+ GNUNET_i2s (&sender));
+ GNUNET_CRYPTO_hash ((struct sockaddr *) addr_verify, salen, &uhs.h_address);
if (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST,
&uhs,
@@ -2332,10 +2380,23 @@ sock_read (void *cls)
/* use our own mechanism to determine network type */
nt =
GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen);
- GNUNET_TRANSPORT_application_validate (ah, &ub->sender, nt, addr_s);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating address %s received from UDPBroadcast\n",
+ GNUNET_i2s (&sender));
+ GNUNET_TRANSPORT_application_validate (ah, &sender, nt, addr_s);
GNUNET_free (addr_s);
return;
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "VerifyingPeer %s is verifying UDPBroadcast\n",
+ GNUNET_i2s (&my_identity));
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Verifying UDPBroadcast from %s failed\n",
+ GNUNET_i2s (&ub->sender));
+ }
+ GNUNET_free (addr_verify);
/* continue with KX, mostly for statistics... */
}
@@ -2678,8 +2739,10 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq,
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending KX to %s\n", GNUNET_a2s (receiver->address,
- receiver->address_len));
+ "Sending KX with payload size %u to %s\n",
+ msize,
+ GNUNET_a2s (receiver->address,
+ receiver->address_len));
GNUNET_MQ_impl_send_continue (mq);
}
@@ -2940,7 +3003,8 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending UDPBox %u acks left\n",
+ "Sending UDPBox with payload size %u, %u acks left\n",
+ msize,
receiver->acks_available);
GNUNET_MQ_impl_send_continue (mq);
receiver->acks_available--;
@@ -3135,17 +3199,6 @@ setup_receiver_mq (struct ReceiverAddress *receiver)
receiver->nt,
GNUNET_TRANSPORT_CS_OUTBOUND,
receiver->kx_mq);
- receiver->d_qh =
- GNUNET_TRANSPORT_communicator_mq_add (ch,
- &receiver->target,
- receiver->foreign_addr,
- receiver->d_mtu,
- 0, /* Initialize with 0 acks */
- 1, /* Priority */
- receiver->nt,
- GNUNET_TRANSPORT_CS_OUTBOUND,
- receiver->d_mq);
-
}
@@ -3455,7 +3508,7 @@ ifc_broadcast (void *cls)
delay.rel_value_us =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, delay.rel_value_us);
bi->broadcast_task =
- GNUNET_SCHEDULER_add_delayed (INTERFACE_SCAN_FREQUENCY, &ifc_broadcast, bi);
+ GNUNET_SCHEDULER_add_delayed (delay, &ifc_broadcast, bi);
switch (bi->sa->sa_family)
{
@@ -3472,6 +3525,12 @@ ifc_broadcast (void *cls)
sizeof(int)))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
"setsockopt");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "creating UDPBroadcast from %s\n",
+ GNUNET_i2s (&(bi->bcm.sender)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "sending UDPBroadcast to add %s\n",
+ GNUNET_a2s (bi->ba, bi->salen));
sent = GNUNET_NETWORK_socket_sendto (udp_sock,
&bi->bcm,
sizeof(bi->bcm),
@@ -3499,6 +3558,8 @@ ifc_broadcast (void *cls)
dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr;
dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "sending UDPBroadcast\n");
sent = GNUNET_NETWORK_socket_sendto (udp_sock,
&bi->bcm,
sizeof(bi->bcm),
@@ -3586,6 +3647,9 @@ iface_proc (void *cls,
ubs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST);
ubs.purpose.size = htonl (sizeof(ubs));
ubs.sender = my_identity;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "creating UDPBroadcastSignature for %s\n",
+ GNUNET_a2s (addr, addrlen));
GNUNET_CRYPTO_hash (addr, addrlen, &ubs.h_address);
GNUNET_CRYPTO_eddsa_sign (my_private_key,
&ubs,
@@ -3755,9 +3819,11 @@ run (void *cls,
GNUNET_free (bindto);
in = (struct sockaddr *) &in_sto;
in_len = sto_len;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Bound to `%s'\n",
- GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len));
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Bound to `%s'\n",
+ GNUNET_a2s ((const struct sockaddr *) &in_sto,
+ sto_len));
switch (in->sa_family)
{
case AF_INET:
@@ -3853,6 +3919,9 @@ main (int argc, char *const *argv)
};
int ret;
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Starting udp communicator\n");
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index a7e2a8c04..f67bc0db5 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -1736,6 +1736,11 @@ struct Queue
const char *address;
/**
+ * Is this queue of unlimited length.
+ */
+ unsigned int unlimited_length;
+
+ /**
* Task scheduled for the time when this queue can (likely) transmit the
* next message.
*/
@@ -1787,6 +1792,11 @@ struct Queue
unsigned int queue_length;
/**
+ * Capacity of the queue.
+ */
+ uint64_t q_capacity;
+
+ /**
* Queue priority
*/
uint32_t priority;
@@ -3446,6 +3456,35 @@ transmit_on_queue (void *cls);
/**
+ * Check if the communicator has another queue with higher prio ready for sending.
+ */
+static unsigned int
+check_for_queue_with_higher_prio (struct Queue *queue, struct Queue *queue_head)
+{
+ for (struct Queue *s = queue_head; NULL != s;
+ s = s->next_client)
+ {
+ if (s->tc->details.communicator.address_prefix !=
+ queue->tc->details.communicator.address_prefix)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "queue address %s qid %u compare with queue: address %s qid %u\n",
+ queue->address,
+ queue->qid,
+ s->address,
+ s->qid);
+ if ((s->priority > queue->priority) && (0 < s->q_capacity) &&
+ (QUEUE_LENGTH_LIMIT > s->queue_length) )
+ return GNUNET_YES;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Lower prio\n");
+ }
+ }
+ return GNUNET_NO;
+}
+
+
+/**
* Called whenever something changed that might effect when we
* try to do the next transmission on @a queue using #transmit_on_queue().
*
@@ -3456,6 +3495,11 @@ static void
schedule_transmit_on_queue (struct Queue *queue,
enum GNUNET_SCHEDULER_Priority p)
{
+ if (check_for_queue_with_higher_prio (queue,
+ queue->tc->details.communicator.
+ queue_head))
+ return;
+
if (queue->tc->details.communicator.total_queue_length >=
COMMUNICATOR_TOTAL_QUEUE_LIMIT)
{
@@ -3480,6 +3524,19 @@ schedule_transmit_on_queue (struct Queue *queue,
queue->idle = GNUNET_NO;
return;
}
+ if (0 == queue->q_capacity)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmission throttled due to communicator message queue qid %u has capacity %lu.\n",
+ queue->qid,
+ queue->q_capacity);
+ GNUNET_STATISTICS_update (GST_stats,
+ "# Transmission throttled due to message queue capacity",
+ 1,
+ GNUNET_NO);
+ queue->idle = GNUNET_NO;
+ return;
+ }
/* queue might indeed be ready, schedule it */
if (NULL != queue->transmit_task)
GNUNET_SCHEDULER_cancel (queue->transmit_task);
@@ -3582,8 +3639,9 @@ free_queue (struct Queue *queue)
tc->details.communicator.queue_head,
tc->details.communicator.queue_tail,
queue);
- maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >=
- tc->details.communicator.total_queue_length);
+ maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT <=
+ tc->details.communicator.
+ total_queue_length);
while (NULL != (qe = queue->queue_head))
{
GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe);
@@ -3597,7 +3655,7 @@ free_queue (struct Queue *queue)
GNUNET_free (qe);
}
GNUNET_assert (0 == queue->queue_length);
- if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT <
+ if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT >
tc->details.communicator.total_queue_length))
{
/* Communicator dropped below threshold, resume all _other_ queues */
@@ -4223,18 +4281,36 @@ queue_send_msg (struct Queue *queue,
if (NULL != pm)
{
qe->pm = pm;
- GNUNET_assert (NULL == pm->qe);
+ // TODO Why do we have a retransmission. When we know, make decision if we still want this.
+ // GNUNET_assert (NULL == pm->qe);
+ /*if (NULL != pm->qe)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Retransmitting message <%llu> remove pm from qe with MID: %llu \n",
+ pm->logging_uuid,
+ (unsigned long long) pm->qe->mid);
+ pm->qe->pm = NULL;
+ }*/
pm->qe = qe;
}
GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe);
GNUNET_assert (CT_COMMUNICATOR == queue->tc->type);
queue->queue_length++;
queue->tc->details.communicator.total_queue_length++;
+ if (GNUNET_NO == queue->unlimited_length)
+ queue->q_capacity--;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Queue %s with qid %u has capacity %lu\n",
+ queue->address,
+ queue->qid,
+ queue->q_capacity);
if (COMMUNICATOR_TOTAL_QUEUE_LIMIT ==
queue->tc->details.communicator.total_queue_length)
queue->idle = GNUNET_NO;
if (QUEUE_LENGTH_LIMIT == queue->queue_length)
queue->idle = GNUNET_NO;
+ if (0 == queue->q_capacity)
+ queue->idle = GNUNET_NO;
GNUNET_MQ_send (queue->tc->mq, env);
}
}
@@ -4662,18 +4738,28 @@ send_dv_to_neighbour (void *cls,
* @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed
*/
static struct GNUNET_TIME_Relative
-route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
+route_control_message_without_fc (struct VirtualLink *vl,
+// route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
const struct GNUNET_MessageHeader *hdr,
enum RouteMessageOptions options)
{
- struct VirtualLink *vl;
+ // struct VirtualLink *vl;
struct Neighbour *n;
struct DistanceVector *dv;
struct GNUNET_TIME_Relative rtt1;
struct GNUNET_TIME_Relative rtt2;
+ const struct GNUNET_PeerIdentity *target = &vl->target;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to route message of type %u to %s without fc\n",
+ ntohs (hdr->type),
+ GNUNET_i2s (target));
- vl = lookup_virtual_link (target);
+ // TODO Do this elsewhere. vl should be given as parameter to method.
+ // vl = lookup_virtual_link (target);
GNUNET_assert (NULL != vl);
+ if (NULL == vl)
+ return GNUNET_TIME_UNIT_FOREVER_REL;
n = vl->n;
dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL;
if (0 == (options & RMO_UNCONFIRMED_ALLOWED))
@@ -4718,6 +4804,10 @@ route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
rtt2 = GNUNET_TIME_UNIT_FOREVER_REL;
if (NULL != n)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Try to route message of type %u to %s without fc via neighbour\n",
+ ntohs (hdr->type),
+ GNUNET_i2s (target));
rtt1 = route_via_neighbour (n, hdr, options);
}
if (NULL != dv)
@@ -4804,7 +4894,7 @@ consider_sending_fc (void *cls)
fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used);
fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size);
fc.sender_time = GNUNET_TIME_absolute_hton (monotime);
- rtt = route_control_message_without_fc (&vl->target, &fc.header, RMO_NONE);
+ rtt = route_control_message_without_fc (vl, &fc.header, RMO_NONE);
if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us)
{
rtt = GNUNET_TIME_UNIT_SECONDS;
@@ -4889,7 +4979,9 @@ check_vl_transmission (struct VirtualLink *vl)
schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queue busy or invalid\n");
+ "Neighbour Queue QID: %u (%u) busy or invalid\n",
+ queue->qid,
+ queue->idle);
}
}
/* Notify queues via DV that we are interested */
@@ -4910,6 +5002,11 @@ check_vl_transmission (struct VirtualLink *vl)
(queue->validated_until.abs_value_us > now.abs_value_us))
schedule_transmit_on_queue (queue,
GNUNET_SCHEDULER_PRIORITY_BACKGROUND);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV Queue QID: %u (%u) busy or invalid\n",
+ queue->qid,
+ queue->idle);
}
}
}
@@ -4991,13 +5088,16 @@ handle_communicator_backchannel (
void *cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
{
+ struct Neighbour *n;
+ struct VirtualLink *vl;
struct TransportClient *tc = cls;
const struct GNUNET_MessageHeader *inbox =
(const struct GNUNET_MessageHeader *) &cb[1];
uint16_t isize = ntohs (inbox->size);
const char *is = ((const char *) &cb[1]) + isize;
+ size_t slen = strlen (is) + 1;
char
- mbuf[isize
+ mbuf[slen + isize
+ sizeof(struct
TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN;
struct TransportBackchannelEncapsulationMessage *be =
@@ -5006,9 +5106,10 @@ handle_communicator_backchannel (
/* 0-termination of 'is' was checked already in
#check_communicator_backchannel() */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Preparing backchannel transmission to %s:%s of type %u\n",
+ "Preparing backchannel transmission to %s:%s of type %u and size %u\n",
GNUNET_i2s (&cb->pid),
is,
+ ntohs (inbox->type),
ntohs (inbox->size));
/* encapsulate and encrypt message */
be->header.type =
@@ -5019,7 +5120,22 @@ handle_communicator_backchannel (
+ isize],
is,
strlen (is) + 1);
- route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED);
+ // route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED);
+ vl = lookup_virtual_link (&cb->pid);
+ if (NULL != vl)
+ {
+ route_control_message_without_fc (vl, &be->header, RMO_DV_ALLOWED);
+ }
+ else
+ {
+ /* Use route via neighbour */
+ n = lookup_neighbour (&cb->pid);
+ if (NULL != n)
+ route_via_neighbour (
+ n,
+ &be->header,
+ RMO_NONE);
+ }
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -5264,6 +5380,11 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
uint16_t size = ntohs (mh->size);
int have_core;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handling raw message of type %u with %u bytes\n",
+ (unsigned int) ntohs (mh->type),
+ (unsigned int) ntohs (mh->size));
+
if ((size > UINT16_MAX - sizeof(struct InboundMessage)) ||
(size < sizeof(struct GNUNET_MessageHeader)))
{
@@ -5290,6 +5411,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
1,
GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "CORE messages of type %u with %u bytes dropped (virtual link still down)\n",
+ (unsigned int) ntohs (mh->type),
+ (unsigned int) ntohs (mh->size));
finish_cmc_handling (cmc);
return;
}
@@ -5299,7 +5424,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
"# CORE messages dropped (FC arithmetic overflow)",
1,
GNUNET_NO);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "CORE messages of type %u with %u bytes dropped (FC arithmetic overflow)\n",
+ (unsigned int) ntohs (mh->type),
+ (unsigned int) ntohs (mh->size));
finish_cmc_handling (cmc);
return;
}
@@ -5309,6 +5437,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
"# CORE messages dropped (FC window overflow)",
1,
GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "CORE messages of type %u with %u bytes dropped (FC window overflow)\n",
+ (unsigned int) ntohs (mh->type),
+ (unsigned int) ntohs (mh->size));
finish_cmc_handling (cmc);
return;
}
@@ -5345,6 +5477,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
perspective of the other peer! */
vl->incoming_fc_window_size_used += size;
/* TODO-M1 */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Dropped message of type %u with %u bytes to CORE: no CORE client connected!",
+ (unsigned int) ntohs (mh->type),
+ (unsigned int) ntohs (mh->size));
finish_cmc_handling (cmc);
return;
}
@@ -5423,9 +5559,11 @@ destroy_ack_cummulator (void *cls)
static void
transmit_cummulative_ack_cb (void *cls)
{
+ struct Neighbour *n;
+ struct VirtualLink *vl;
struct AcknowledgementCummulator *ac = cls;
char buf[sizeof(struct TransportReliabilityAckMessage)
- + ac->ack_counter
+ + ac->ack_counter + ac->num_acks
* sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN;
struct TransportReliabilityAckMessage *ack =
(struct TransportReliabilityAckMessage *) buf;
@@ -5436,12 +5574,12 @@ transmit_cummulative_ack_cb (void *cls)
"Sending ACK with %u components to %s\n",
ac->ack_counter,
GNUNET_i2s (&ac->target));
- GNUNET_assert (0 < ac->ack_counter);
+ GNUNET_assert (0 <= ac->ack_counter);
ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK);
ack->header.size =
htons (sizeof(*ack)
+ ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP));
- ack->ack_counter = htonl (ac->ack_counter++);
+ ack->ack_counter = htonl (ac->ack_counter += ac->num_acks);
ap = (struct TransportCummulativeAckPayloadP *) &ack[1];
for (unsigned int i = 0; i < ac->ack_counter; i++)
{
@@ -5449,7 +5587,28 @@ transmit_cummulative_ack_cb (void *cls)
ap[i].ack_delay = GNUNET_TIME_relative_hton (
GNUNET_TIME_absolute_get_duration (ac->ack_uuids[i].receive_time));
}
- route_control_message_without_fc (&ac->target, &ack->header, RMO_DV_ALLOWED);
+ /*route_control_message_without_fc (
+ &ac->target,
+ &ack->header,
+ RMO_DV_ALLOWED);*/
+ vl = lookup_virtual_link (&ac->target);
+ if (NULL != vl)
+ {
+ route_control_message_without_fc (
+ vl,
+ &ack->header,
+ RMO_DV_ALLOWED);
+ }
+ else
+ {
+ /* Use route via neighbour */
+ n = lookup_neighbour (&ac->target);
+ if (NULL != n)
+ route_via_neighbour (
+ n,
+ &ack->header,
+ RMO_NONE);
+ }
ac->num_acks = 0;
ac->task = GNUNET_SCHEDULER_add_delayed (ACK_CUMMULATOR_TIMEOUT,
&destroy_ack_cummulator,
@@ -6074,6 +6233,15 @@ handle_backchannel_encapsulation (
(const struct GNUNET_MessageHeader *) &be[1];
uint16_t isize = ntohs (inbox->size);
const char *target_communicator = ((const char *) inbox) + isize;
+ char *sender;
+ char *self;
+
+ GNUNET_asprintf (&sender,
+ "%s",
+ GNUNET_i2s (&cmc->im.sender));
+ GNUNET_asprintf (&self,
+ "%s",
+ GNUNET_i2s (&GST_my_identity));
/* Find client providing this communicator */
for (tc = clients_head; NULL != tc; tc = tc->next)
@@ -6095,8 +6263,9 @@ handle_backchannel_encapsulation (
}
/* Finally, deliver backchannel message to communicator */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delivering backchannel message from %s of type %u to %s\n",
- GNUNET_i2s (&cmc->im.sender),
+ "Delivering backchannel message from %s to %s of type %u to %s\n",
+ sender,
+ self,
ntohs (inbox->type),
target_communicator);
env = GNUNET_MQ_msg_extra (
@@ -6431,6 +6600,8 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
const struct DVPathEntryP *hops,
struct GNUNET_TIME_Absolute in_time)
{
+ struct Neighbour *n;
+ struct VirtualLink *vl;
struct DVPathEntryP *dhops;
char buf[sizeof(struct TransportDVLearnMessage)
+ (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN;
@@ -6462,18 +6633,34 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
struct DvHopPS dhp = {
.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
.purpose.size = htonl (sizeof(dhp)),
- .pred = dhops[nhops - 1].hop,
+ .pred = (0 == nhops) ? msg->initiator : dhops[nhops - 1].hop,
.succ = *next_hop,
.challenge = msg->challenge
};
-
GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
&dhp,
&dhops[nhops].hop_sig);
}
- route_control_message_without_fc (next_hop,
+ /*route_control_message_without_fc (next_hop,
&fwd->header,
- RMO_UNCONFIRMED_ALLOWED);
+ RMO_UNCONFIRMED_ALLOWED);*/
+ vl = lookup_virtual_link (next_hop);
+ if (NULL != vl)
+ {
+ route_control_message_without_fc (vl,
+ &fwd->header,
+ RMO_UNCONFIRMED_ALLOWED);
+ }
+ else
+ {
+ /* Use route via neighbour */
+ n = lookup_neighbour (next_hop);
+ if (NULL != n)
+ route_via_neighbour (
+ n,
+ &fwd->header,
+ RMO_UNCONFIRMED_ALLOWED);
+ }
}
@@ -6752,7 +6939,14 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
struct GNUNET_TIME_Absolute in_time;
struct Neighbour *n;
- nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message sender %s\n",
+ GNUNET_i2s (&cmc->im.sender));
+
+ nhops = ntohs (dvl->num_hops); /* 0 = sender is initiator */
bi_history = ntohs (dvl->bidirectional);
hops = (const struct DVPathEntryP *) &dvl[1];
if (0 == nhops)
@@ -6767,6 +6961,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
}
else
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message last hop %s\n",
+ GNUNET_i2s (&hops[nhops - 1].hop));
/* sanity check */
if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender))
{
@@ -6782,6 +6979,10 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
cc); // FIXME: add bi-directional flag to cc?
in_time = GNUNET_TIME_absolute_get ();
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "2 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
+
/* continue communicator here, everything else can happen asynchronous! */
finish_cmc_handling (cmc);
@@ -6792,6 +6993,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
(GNUNET_TIME_absolute_ntoh (dvl->monotonic_time).abs_value_us <
n->last_dv_learn_monotime.abs_value_us))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn from %s discarded due to time travel",
+ GNUNET_i2s (&dvl->initiator));
GNUNET_STATISTICS_update (GST_stats,
"# DV learn discarded due to time travel",
1,
@@ -6803,6 +7007,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&dvl->challenge,
&dvl->init_sig))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn signature from %s invalid",
+ GNUNET_i2s (&dvl->initiator));
GNUNET_break_op (0);
return;
}
@@ -6824,6 +7031,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
n);
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "3 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
/* OPTIMIZE-FIXME: asynchronously (!) verify signatures!,
If signature verification load too high, implement random drop strategy */
for (unsigned int i = 0; i < nhops; i++)
@@ -6842,11 +7052,29 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&hops[i].hop_sig,
&hops[i].hop.public_key))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn from %s signature of hop %u invalid\n",
+ GNUNET_i2s (&dvl->initiator),
+ i);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "signature of hop %s invalid\n",
+ GNUNET_i2s (&hops[i].hop));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "pred %s\n",
+ GNUNET_i2s (&dhp.pred));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "succ %s\n",
+ GNUNET_i2s (&dhp.succ));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "hash %s\n",
+ GNUNET_sh2s (&dhp.challenge.value));
GNUNET_break_op (0);
return;
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "4 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (GNUNET_EXTRA_LOGGING > 0)
{
char *path;
@@ -6871,7 +7099,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
GNUNET_i2s (&GST_my_identity));
GNUNET_free (path);
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "5 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
do_fwd = GNUNET_YES;
if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator))
{
@@ -6916,6 +7146,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
do_fwd = GNUNET_NO;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "6 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (bi_hop)
{
/* last hop was bi-directional, we could learn something here! */
@@ -6972,13 +7205,18 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
}
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "7 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (MAX_DV_HOPS_ALLOWED == nhops)
{
/* At limit, we're out of here! */
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "8 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
/* Forward to initiator, if path non-trivial and possible */
bi_history = (bi_history << 1) | (bi_hop ? 1 : 0);
did_initiator = GNUNET_NO;
@@ -7032,6 +7270,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&dv_neighbour_transmission,
&nsc);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "9 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
}
@@ -7810,7 +8051,8 @@ handle_validation_challenge (
vl = lookup_virtual_link (&sender);
if (NULL != vl)
{
- route_control_message_without_fc (&cmc->im.sender,
+ // route_control_message_without_fc (&cmc->im.sender,
+ route_control_message_without_fc (vl,
&tvr.header,
RMO_ANYTHING_GOES | RMO_REDUNDANT);
}
@@ -8407,14 +8649,15 @@ fragment_message (struct Queue *queue,
struct PendingMessage *ff;
uint16_t mtu;
- mtu = (0 == queue->mtu)
+ mtu = (UINT16_MAX == queue->mtu)
? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)
: queue->mtu;
set_pending_message_uuid (pm);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Fragmenting message %llu <%llu> to %s for MTU %u\n",
+ "Fragmenting message %llu <%llu> with size %u to %s for MTU %u\n",
(unsigned long long) pm->msg_uuid.uuid,
pm->logging_uuid,
+ pm->bytes_msg,
GNUNET_i2s (&pm->vl->target),
(unsigned int) mtu);
pa = prepare_pending_acknowledgement (queue, dvh, pm);
@@ -8700,7 +8943,7 @@ select_best_pending_from_link (struct PendingMessageScoreContext *sc,
GNUNET_TRANSPORT_SendMessageTo))
||
(NULL != pos->head_frag /* fragments already exist, should
- respect that even if MTU is 0 for
+ respect that even if MTU is UINT16_MAX for
this queue */))
{
frag = GNUNET_YES;
@@ -9069,12 +9312,17 @@ handle_send_message_ack (void *cls,
qep = qep->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "QueueEntry MID: %llu, Ack MID: %llu\n",
+ "QueueEntry MID: %llu on queue QID: %llu, Ack MID: %llu\n",
(unsigned long long) qep->mid,
+ (unsigned long long) queue->qid,
(unsigned long long) sma->mid);
if (qep->mid != sma->mid)
continue;
qe = qep;
+ if ((NULL != qe->pm)&&(qe->pm->qe != qe))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "For pending message %llu we had retransmissions.\n",
+ qe->pm->logging_uuid);
break;
}
}
@@ -9125,12 +9373,26 @@ handle_send_message_ack (void *cls,
GNUNET_NO);
schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
}
+ else if (1 == qe->queue->q_capacity)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmission rescheduled due to communicator message queue with qid %u has capacity %lu.\n",
+ qe->queue->qid,
+ qe->queue->q_capacity);
+ /* message queue has capacity; only resume this one queue */
+ /* queue dropped below threshold; only resume this one queue */
+ GNUNET_STATISTICS_update (GST_stats,
+ "# Transmission throttled due to message queue capacity",
+ -1,
+ GNUNET_NO);
+ schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
+ }
if (NULL != (pm = qe->pm))
{
struct VirtualLink *vl;
- GNUNET_assert (qe == pm->qe);
+ // GNUNET_assert (qe == pm->qe);
pm->qe = NULL;
/* If waiting for this communicator may have blocked transmission
of pm on other queues for this neighbour, force schedule
@@ -9671,16 +9933,20 @@ handle_add_queue_message (void *cls,
addr_len = ntohs (aqm->header.size) - sizeof(*aqm);
addr = (const char *) &aqm[1];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "New queue %s to %s available with QID %llu\n",
+ "New queue %s to %s available with QID %llu and q_len %lu \n",
addr,
GNUNET_i2s (&aqm->receiver),
- (unsigned long long) aqm->qid);
+ (unsigned long long) aqm->qid,
+ GNUNET_ntohll (aqm->q_len));
queue = GNUNET_malloc (sizeof(struct Queue) + addr_len);
queue->tc = tc;
queue->address = (const char *) &queue[1];
queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL;
queue->qid = aqm->qid;
queue->neighbour = neighbour;
+ if (GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED == GNUNET_ntohll (aqm->q_len))
+ queue->unlimited_length = GNUNET_YES;
+ queue->q_capacity = GNUNET_ntohll (aqm->q_len);
memcpy (&queue[1], addr, addr_len);
/* notify monitors about new queue */
{
@@ -9752,10 +10018,14 @@ handle_update_queue_message (void *cls,
target_queue->mtu = ntohl (msg->mtu);
target_queue->cs = msg->cs;
target_queue->priority = ntohl (msg->priority);
- /* The update message indicates how many _additional_
- * messages the queue should be able to handle
+ /* The update message indicates how many messages
+ * the queue should be able to handle.
*/
- target_queue->queue_length += GNUNET_ntohll (msg->q_len);
+ if (GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED == GNUNET_ntohll (msg->q_len))
+ target_queue->unlimited_length = GNUNET_YES;
+ else
+ target_queue->unlimited_length = GNUNET_NO;
+ target_queue->q_capacity = GNUNET_ntohll (msg->q_len);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -10179,8 +10449,18 @@ static void
shutdown_task (void *cls)
{
in_shutdown = GNUNET_YES;
+
if (NULL == clients_head)
- do_shutdown (cls);
+ {
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "client still connected: %u\n",
+ tc->type);
+ }
+ }
+ do_shutdown (cls);
+
}
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c
index 8606b353b..65b090187 100644
--- a/src/transport/tcp_service_legacy.c
+++ b/src/transport/tcp_service_legacy.c
@@ -29,7 +29,7 @@
#include "gnunet_constants.h"
#include "gnunet_resolver_service.h"
-#if HAVE_MALLINFO
+#if HAVE_MALLINFO2
#include <malloc.h>
#include "gauger.h"
#endif
@@ -1450,7 +1450,7 @@ shutdown:
LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write");
GNUNET_break (0 == close (sctx.ready_confirm_fd));
}
-#if HAVE_MALLINFO
+#if HAVE_MALLINFO2
{
char *counter;
@@ -1462,9 +1462,9 @@ shutdown:
"GAUGER_HEAP",
&counter)))
{
- struct mallinfo mi;
+ struct mallinfo2 mi;
- mi = mallinfo ();
+ mi = mallinfo2 ();
GAUGER (service_name, counter, mi.usmblks, "blocks");
GNUNET_free (counter);
}
@@ -1599,7 +1599,7 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
{
unsigned int i;
-#if HAVE_MALLINFO
+#if HAVE_MALLINFO2
{
char *counter;
@@ -1611,9 +1611,9 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
"GAUGER_HEAP",
&counter)))
{
- struct mallinfo mi;
+ struct mallinfo2 mi;
- mi = mallinfo ();
+ mi = mallinfo2 ();
GAUGER (sctx->service_name, counter, mi.usmblks, "blocks");
GNUNET_free (counter);
}
diff --git a/src/transport/test_transport_api2_tcp_node1.conf b/src/transport/test_transport_api2_tcp_node1.conf
index a867ea81a..e38744949 100644
--- a/src/transport/test_transport_api2_tcp_node1.conf
+++ b/src/transport/test_transport_api2_tcp_node1.conf
@@ -5,7 +5,7 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/
[transport]
BINARY = gnunet-service-tng
PLUGINS = tcp
-#PREFIX = valgrind --log-file=/tmp/vg_peer1-%p
+# PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_peer1-%p
UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock
[communicator-tcp]
@@ -15,6 +15,14 @@ DISABLE_V6 = YES
IMMEDIATE_START = YES
UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
#PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p
+#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
+
+[communicator-udp]
+BINARY = gnunet-communicator-udp
+BINDTO = 192.168.15.1:60002
+DISABLE_V6 = YES
+IMMEDIATE_START = YES
+UNIXPATH = $GNUNET_RUNTIME_DIR/udp-comm-p1.sock
[peerstore]
IMMEDIATE_START = YES
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 35aa07ecd..154c0abca 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -25,6 +25,7 @@
*/
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_application_service.h"
#include "transport-testing2.h"
@@ -37,28 +38,41 @@
#define BASE_DIR "testdir"
-/**
- * The name for a specific test environment directory.
- *
- */
-char *testdir;
+#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-/**
- * The name for the configuration file of the specific node.
- *
- */
-char *cfgname;
+struct TestState
+{
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ TESTING_CMD_HELPER_write_cb write_message;
-/**
- * Flag indicating if all peers have been started.
- *
- */
-unsigned int are_all_peers_started;
+ /**
+ * The name for a specific test environment directory.
+ *
+ */
+ char *testdir;
-/**
- * Flag indicating a received message.
- */
-unsigned int message_received;
+ /**
+ * The name for the configuration file of the specific node.
+ *
+ */
+ char *cfgname;
+
+ /**
+ * The complete topology information.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+};
+
+static struct GNUNET_TESTING_Command block_send;
+
+static struct GNUNET_TESTING_Command block_receive;
+
+static struct GNUNET_TESTING_Command connect_peers;
+
+static struct GNUNET_TESTING_Command local_prepared;
/**
@@ -83,50 +97,107 @@ static void
handle_test (void *cls,
const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
- message_received = GNUNET_YES;
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_TESTING_get_trait_async_context (&block_receive,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
}
/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
+ * Callback to set the flag indicating all peers started. Will be called via the plugin api.
*
*/
-static int
-check_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+static void
+all_peers_started ()
{
- return GNUNET_OK;
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_TESTING_get_trait_async_context (&block_send,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
}
/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
+ * Function called with the final result of the test.
*
+ * @param cls the `struct MainParams`
+ * @param rv #GNUNET_OK if the test passed
*/
static void
-handle_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+handle_result (void *cls,
+ enum GNUNET_GenericReturnValue rv)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
+ struct TestState *ts = cls;
+ struct GNUNET_MessageHeader *reply;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Local test exits with status %d\n",
+ rv);
+ reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message prepared\n");
+ ts->write_message (reply,
+ ntohs (reply->size));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message send\n");
+ GNUNET_free (ts->testdir);
+ GNUNET_free (ts->cfgname);
+ GNUNET_TESTING_free_topology (ts->topology);
+ GNUNET_free (ts);
}
/**
- * Callback to set the flag indicating all peers started. Will be called via the plugin api.
+ * Callback from start peer cmd for signaling a peer got connected.
*
*/
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ const struct ConnectPeersState *cps;
+ const struct GNUNET_TESTING_Command *cmd;
+
+ cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ "connect-peers");
+ GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
+ &cps);
+ void *ret = NULL;
+
+ cps->notify_connect (is,
+ peer);
+ return ret;
+}
+
+
+/**
+ * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
+ */
static void
-all_peers_started ()
+all_local_tests_prepared ()
{
- are_all_peers_started = GNUNET_YES;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "setting are_all_peers_started: %d\n",
- are_all_peers_started);
+ const struct LocalPreparedState *lfs;
+
+ GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
+ &lfs);
+ GNUNET_assert (NULL != &lfs->ac);
+ if (NULL == lfs->ac.cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac);
+ else
+ GNUNET_TESTING_async_finish ((struct
+ GNUNET_TESTING_AsyncContext *) &lfs->ac);
}
@@ -145,27 +216,65 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
char *node_ip,
char *m,
char *n,
- char *local_m)
+ char *local_m,
+ char *topology_data,
+ unsigned int *read_file)
{
- GNUNET_asprintf (&cfgname,
- "test_transport_api2_tcp_node%s.conf",
- "1");
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ unsigned int n_int;
+ unsigned int m_int;
+ unsigned int local_m_int;
+ unsigned int num;
+ struct TestState *ts = GNUNET_new (struct TestState);
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ if (GNUNET_YES == *read_file)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read from file\n");
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ }
+ else
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+
+ ts->topology = topology;
+
+ sscanf (m, "%u", &m_int);
+ sscanf (n, "%u", &n_int);
+ sscanf (local_m, "%u", &local_m_int);
+
+ if (0 == n_int)
+ num = m_int;
+ else
+ num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
+
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block");
+ block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block-receive");
+ connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
+ "start-peer",
+ "system-create",
+ num,
+ topology,
+ 0);
+ local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
+ "local-test-prepared",
+ write_message);
+
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_transport_api2_tcp_node1.conf");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin cfgname: %s\n",
- cfgname);
+ ts->cfgname);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node ip: %s\n",
node_ip);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "m: %s n: %s\n",
- m,
- n);
-
- GNUNET_asprintf (&testdir,
+ GNUNET_asprintf (&ts->testdir,
"%s%s%s",
BASE_DIR,
m,
@@ -175,53 +284,45 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
GNUNET_MQ_hd_var_size (test,
GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_hd_var_size (test2,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
+ ts),
GNUNET_MQ_handler_end ()
};
struct GNUNET_TESTING_Command commands[] = {
GNUNET_TESTING_cmd_system_create ("system-create",
- testdir),
+ ts->testdir),
GNUNET_TRANSPORT_cmd_start_peer ("start-peer",
"system-create",
- m,
- n,
- local_m,
+ num,
node_ip,
handlers,
- cfgname),
+ ts->cfgname,
+ notify_connect,
+ GNUNET_NO),
GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
write_message),
- GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
- &are_all_peers_started),
- GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
- "start-peer",
- "system-create",
- (atoi (n) - 1) * atoi (local_m) + atoi (
- m)),
+ block_send,
+ connect_peers,
GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
- m,
- n,
- (atoi (n) - 1) * atoi (local_m) + atoi (
- m),
- "start-peer"),
- GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive",
- &message_received),
+ "start-peer",
+ "system-create",
+ num,
+ topology),
+ block_receive,
+ local_prepared,
GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
"start-peer"),
GNUNET_TESTING_cmd_system_destroy ("system-destroy",
"system-create"),
- GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
- write_message)
+ GNUNET_TESTING_cmd_end ()
};
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ ts->write_message = write_message;
+
+ GNUNET_TESTING_run (commands,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &handle_result,
+ ts);
}
@@ -237,9 +338,14 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api;
+ GNUNET_log_setup ("simple-send",
+ "DEBUG",
+ NULL);
+
api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
api->start_testcase = &start_testcase;
api->all_peers_started = &all_peers_started;
+ api->all_local_tests_prepared = all_local_tests_prepared;
return api;
}
@@ -256,8 +362,6 @@ libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
struct GNUNET_TESTING_PluginFunctions *api = cls;
GNUNET_free (api);
- GNUNET_free (testdir);
- GNUNET_free (cfgname);
return NULL;
}
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
new file mode 100644
index 000000000..9d6844be1
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -0,0 +1,398 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testbed/plugin_cmd_simple_send_broadcast.c
+ * @brief a plugin to provide the API for running test cases.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+#define BASE_DIR "testdir"
+
+#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
+
+struct TestState
+{
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ TESTING_CMD_HELPER_write_cb write_message;
+
+ /**
+ * The name for a specific test environment directory.
+ *
+ */
+ char *testdir;
+
+ /**
+ * The name for the configuration file of the specific node.
+ *
+ */
+ char *cfgname;
+
+ /**
+ * The complete topology information.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+};
+
+static struct GNUNET_TESTING_Command block_send;
+
+static struct GNUNET_TESTING_Command block_receive;
+
+static struct GNUNET_TESTING_Command connect_peers;
+
+static struct GNUNET_TESTING_Command local_prepared;
+
+/**
+ * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
+ * received.
+ *
+ */
+static int
+check_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
+ * being received.
+ *
+ */
+static void
+handle_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_TESTING_get_trait_async_context (&block_receive,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if ((GNUNET_NO == ac->finished) && (NULL == ac->cont))
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else if (GNUNET_NO == ac->finished)
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+}
+
+
+/**
+ * Callback to set the flag indicating all peers started. Will be called via the plugin api.
+ *
+ */
+static void
+all_peers_started ()
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received message\n");
+ GNUNET_TESTING_get_trait_async_context (&block_send,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+}
+
+
+/**
+ * Function called with the final result of the test.
+ *
+ * @param cls the `struct MainParams`
+ * @param rv #GNUNET_OK if the test passed
+ */
+static void
+handle_result (void *cls,
+ enum GNUNET_GenericReturnValue rv)
+{
+ struct TestState *ts = cls;
+ struct GNUNET_MessageHeader *reply;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Local test exits with status %d\n",
+ rv);
+ reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message prepared\n");
+ ts->write_message (reply,
+ ntohs (reply->size));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message send\n");
+ GNUNET_free (ts->testdir);
+ GNUNET_free (ts->cfgname);
+ GNUNET_TESTING_free_topology (ts->topology);
+ GNUNET_free (ts);
+}
+
+
+/**
+ * Callback from start peer cmd for signaling a peer got connected.
+ *
+ */
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+ void *ret = NULL;
+ const struct GNUNET_TESTING_Command *cmd;
+ struct BlockState *bs;
+
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "notify_connect\n");
+
+ GNUNET_TESTING_get_trait_async_context (&connect_peers,
+ &ac);
+
+ if (NULL != ac->is)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "notify_connect running\n");
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+ }
+ else
+ {
+ cmd = GNUNET_TESTING_interpreter_lookup_future_command (is,
+ "connect-peers");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %s\n",
+ cmd->label);
+ GNUNET_TESTING_get_trait_block_state (
+ cmd,
+ (const struct BlockState **) &bs);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %u\n",
+ bs->asynchronous_finish);
+ bs->asynchronous_finish = GNUNET_YES;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %u\n",
+ bs->asynchronous_finish);
+ }
+
+ return ret;
+}
+
+
+/**
+ * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
+ */
+static void
+all_local_tests_prepared ()
+{
+ const struct LocalPreparedState *lfs;
+
+ GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
+ &lfs);
+ GNUNET_assert (NULL != &lfs->ac);
+ if (NULL == lfs->ac.cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac);
+ else
+ GNUNET_TESTING_async_finish ((struct
+ GNUNET_TESTING_AsyncContext *) &lfs->ac);
+}
+
+
+/**
+ * Function to start a local test case.
+ *
+ * @param write_message Callback to send a message to the master loop.
+ * @param router_ip Global address of the network namespace.
+ * @param node_ip Local address of a node i a network namespace.
+ * @param m The number of the node in a network namespace.
+ * @param n The number of the network namespace.
+ * @param local_m The number of nodes in a network namespace.
+ */
+static void
+start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
+ char *node_ip,
+ char *m,
+ char *n,
+ char *local_m,
+ char *topology_data,
+ unsigned int *read_file)
+{
+ unsigned int n_int;
+ unsigned int m_int;
+ unsigned int local_m_int;
+ unsigned int num;
+ struct TestState *ts = GNUNET_new (struct TestState);
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+
+
+ if (GNUNET_YES == *read_file)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read from file\n");
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ }
+ else
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+
+ ts->topology = topology;
+
+ sscanf (m, "%u", &m_int);
+ sscanf (n, "%u", &n_int);
+ sscanf (local_m, "%u", &local_m_int);
+
+ if (0 == n_int)
+ num = m_int;
+ else
+ num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
+
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
+ block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block-receive");
+ connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "connect-peers");
+ local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
+ "local-test-prepared",
+ write_message);
+
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_transport_api2_tcp_node1.conf");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "plugin cfgname: %s\n",
+ ts->cfgname);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "node ip: %s\n",
+ node_ip);
+
+ GNUNET_asprintf (&ts->testdir,
+ "%s%s%s",
+ BASE_DIR,
+ m,
+ n);
+
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (test,
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ struct GNUNET_TRANSPORT_TESTING_TestMessage,
+ ts),
+ GNUNET_MQ_handler_end ()
+ };
+
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_system_create ("system-create",
+ ts->testdir),
+ GNUNET_TRANSPORT_cmd_start_peer ("start-peer",
+ "system-create",
+ num,
+ node_ip,
+ handlers,
+ ts->cfgname,
+ notify_connect,
+ GNUNET_YES),
+ GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
+ write_message),
+ block_send,
+ connect_peers,
+ GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
+ "start-peer",
+ "system-create",
+ num,
+ topology),
+ block_receive,
+ local_prepared,
+ GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
+ "start-peer"),
+ GNUNET_TESTING_cmd_system_destroy ("system-destroy",
+ "system-create"),
+ GNUNET_TESTING_cmd_end ()
+ };
+
+ ts->write_message = write_message;
+
+ GNUNET_TESTING_run (commands,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &handle_result,
+ ts);
+
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_test_transport_plugin_cmd_simple_send_broadcast_init (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api;
+
+ GNUNET_log_setup ("simple-send",
+ "DEBUG",
+ NULL);
+
+ api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
+ api->start_testcase = &start_testcase;
+ api->all_peers_started = &all_peers_started;
+ api->all_local_tests_prepared = all_local_tests_prepared;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
+ * @return NULL
+ */
+void *
+libgnunet_test_transport_plugin_cmd_simple_send_broadcast_done (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* end of plugin_cmd_simple_send_broadcast.c */
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
new file mode 100644
index 000000000..e73e5a0b2
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -0,0 +1,375 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testbed/plugin_cmd_simple_send_broadcast.c
+ * @brief a plugin to provide the API for running test cases.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+#define BASE_DIR "testdir"
+
+#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
+
+struct TestState
+{
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ TESTING_CMD_HELPER_write_cb write_message;
+
+ /**
+ * The name for a specific test environment directory.
+ *
+ */
+ char *testdir;
+
+ /**
+ * The name for the configuration file of the specific node.
+ *
+ */
+ char *cfgname;
+
+ /**
+ * The complete topology information.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+};
+
+static struct GNUNET_TESTING_Command block_send;
+
+static struct GNUNET_TESTING_Command block_receive;
+
+static struct GNUNET_TESTING_Command connect_peers;
+
+static struct GNUNET_TESTING_Command local_prepared;
+
+/**
+ * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
+ * received.
+ *
+ */
+static int
+check_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
+ * being received.
+ *
+ */
+static void
+handle_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received test message\n");
+ GNUNET_TESTING_get_trait_async_context (&block_receive,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+}
+
+
+/**
+ * Callback to set the flag indicating all peers started. Will be called via the plugin api.
+ *
+ */
+static void
+all_peers_started ()
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received message\n");
+ GNUNET_TESTING_get_trait_async_context (&block_send,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+}
+
+
+/**
+ * Function called with the final result of the test.
+ *
+ * @param cls the `struct MainParams`
+ * @param rv #GNUNET_OK if the test passed
+ */
+static void
+handle_result (void *cls,
+ enum GNUNET_GenericReturnValue rv)
+{
+ struct TestState *ts = cls;
+ struct GNUNET_MessageHeader *reply;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Local test exits with status %d\n",
+ rv);
+ reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message prepared\n");
+ ts->write_message (reply,
+ ntohs (reply->size));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message send\n");
+ GNUNET_free (ts->testdir);
+ GNUNET_free (ts->cfgname);
+ GNUNET_TESTING_free_topology (ts->topology);
+ GNUNET_free (ts);
+}
+
+
+/**
+ * Callback from start peer cmd for signaling a peer got connected.
+ *
+ */
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ const struct ConnectPeersState *cps;
+ const struct GNUNET_TESTING_Command *cmd;
+ void *ret = NULL;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "notify_connect peer %s\n",
+ GNUNET_i2s (peer));
+ cmd = GNUNET_TESTING_interpreter_lookup_command_all (is,
+ "connect-peers");
+ GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
+ &cps);
+ cps->notify_connect (is,
+ peer);
+
+ return ret;
+}
+
+
+/**
+ * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
+ */
+static void
+all_local_tests_prepared ()
+{
+ const struct LocalPreparedState *lfs;
+
+ GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
+ &lfs);
+ GNUNET_assert (NULL != &lfs->ac);
+ if (NULL == lfs->ac.cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac);
+ else
+ GNUNET_TESTING_async_finish ((struct
+ GNUNET_TESTING_AsyncContext *) &lfs->ac);
+}
+
+
+/**
+ * Function to start a local test case.
+ *
+ * @param write_message Callback to send a message to the master loop.
+ * @param router_ip Global address of the network namespace.
+ * @param node_ip Local address of a node i a network namespace.
+ * @param m The number of the node in a network namespace.
+ * @param n The number of the network namespace.
+ * @param local_m The number of nodes in a network namespace.
+ */
+static void
+start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
+ char *node_ip,
+ char *m,
+ char *n,
+ char *local_m,
+ char *topology_data,
+ unsigned int *read_file)
+{
+ unsigned int n_int;
+ unsigned int m_int;
+ unsigned int local_m_int;
+ unsigned int num;
+ struct TestState *ts = GNUNET_new (struct TestState);
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+
+
+ if (GNUNET_YES == *read_file)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read from file\n");
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ }
+ else
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+
+ ts->topology = topology;
+
+ sscanf (m, "%u", &m_int);
+ sscanf (n, "%u", &n_int);
+ sscanf (local_m, "%u", &local_m_int);
+
+ if (0 == n_int)
+ num = m_int;
+ else
+ num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
+
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
+ block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block-receive");
+ connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
+ "start-peer",
+ "system-create",
+ num,
+ topology,
+ 8);
+ local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
+ "local-test-prepared",
+ write_message);
+
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_transport_api2_tcp_node1.conf");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "plugin cfgname: %s\n",
+ ts->cfgname);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "node ip: %s\n",
+ node_ip);
+
+ GNUNET_asprintf (&ts->testdir,
+ "%s%s%s",
+ BASE_DIR,
+ m,
+ n);
+
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (test,
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ struct GNUNET_TRANSPORT_TESTING_TestMessage,
+ ts),
+ GNUNET_MQ_handler_end ()
+ };
+
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_system_create ("system-create",
+ ts->testdir),
+ GNUNET_TRANSPORT_cmd_start_peer ("start-peer",
+ "system-create",
+ num,
+ node_ip,
+ handlers,
+ ts->cfgname,
+ notify_connect,
+ GNUNET_YES),
+ GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
+ write_message),
+ block_send,
+ connect_peers,
+ GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
+ "start-peer",
+ "system-create",
+ num,
+ topology),
+ block_receive,
+ local_prepared,
+ GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
+ "start-peer"),
+ GNUNET_TESTING_cmd_system_destroy ("system-destroy",
+ "system-create"),
+ GNUNET_TESTING_cmd_end ()
+ };
+
+ ts->write_message = write_message;
+
+ GNUNET_TESTING_run (commands,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &handle_result,
+ ts);
+
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_test_transport_plugin_cmd_simple_send_dv_init (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api;
+
+ GNUNET_log_setup ("simple-send",
+ "DEBUG",
+ NULL);
+
+ api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
+ api->start_testcase = &start_testcase;
+ api->all_peers_started = &all_peers_started;
+ api->all_local_tests_prepared = all_local_tests_prepared;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
+ * @return NULL
+ */
+void *
+libgnunet_test_transport_plugin_cmd_simple_send_dv_done (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* end of plugin_cmd_simple_send_broadcast.c */
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_v2.c b/src/transport/test_transport_plugin_cmd_simple_send_v2.c
deleted file mode 100644
index c79b5c7e2..000000000
--- a/src/transport/test_transport_plugin_cmd_simple_send_v2.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/plugin_cmd_simple_send.c
- * @brief a plugin to provide the API for running test cases.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_transport_application_service.h"
-#include "transport-testing2.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-#define BASE_DIR "testdir"
-
-#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-
-/**
- * The name for a specific test environment directory.
- *
- */
-char *testdir;
-
-/**
- * The name for the configuration file of the specific node.
- *
- */
-char *cfgname;
-
-/**
- * Flag indicating if all peers have been started.
- *
- */
-unsigned int are_all_peers_started;
-
-/**
- * Flag indicating a received message.
- */
-unsigned int message_received;
-
-
-/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
- * received.
- *
- */
-static int
-check_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
- * being received.
- *
- */
-static void
-handle_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- message_received = GNUNET_YES;
-}
-
-
-/**
- * Callback to set the flag indicating all peers started. Will be called via the plugin api.
- *
- */
-static void
-all_peers_started ()
-{
- are_all_peers_started = GNUNET_YES;
-}
-
-
-/**
- * Function to start a local test case.
- *
- * @param write_message Callback to send a message to the master loop.
- * @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
- * @param m The number of the node in a network namespace.
- * @param n The number of the network namespace.
- * @param local_m The number of nodes in a network namespace.
- */
-static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
- char *node_ip,
- char *m,
- char *n,
- char *local_m)
-{
-
- unsigned int n_int, m_int, local_m_int, num;
-
- struct GNUNET_TESTING_NetjailTopology *topology =
- GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
-
- sscanf (m, "%u", &m_int);
- sscanf (n, "%u", &n_int);
- sscanf (local_m, "%u", &local_m_int);
-
-
- if (0 == m_int)
- num = n_int;
- else
- num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
-
- GNUNET_asprintf (&cfgname,
- "test_transport_api2_tcp_node1.conf");
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "plugin cfgname: %s\n",
- cfgname);
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "node ip: %s\n",
- node_ip);
-
- GNUNET_asprintf (&testdir,
- "%s%s%s",
- BASE_DIR,
- m,
- n);
-
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (test,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_handler_end ()
- };
-
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_system_create ("system-create",
- testdir),
- GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
- "system-create",
- num,
- node_ip,
- handlers,
- cfgname),
- GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
- write_message),
- GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
- &are_all_peers_started),
- GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
- "start-peer",
- "system-create",
- num),
- GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
- "start-peer",
- num),
- GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive",
- &message_received),
- GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
- "start-peer"),
- GNUNET_TESTING_cmd_system_destroy ("system-destroy",
- "system-create"),
- GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
- write_message)
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
-
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api;
-
- api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
- api->start_testcase = &start_testcase;
- api->all_peers_started = &all_peers_started;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
- * @return NULL
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- GNUNET_free (testdir);
- GNUNET_free (cfgname);
- return NULL;
-}
-
-
-/* end of plugin_cmd_simple_send.c */
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
new file mode 100644
index 000000000..537832e61
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -0,0 +1,356 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testbed/plugin_cmd_simple_send.c
+ * @brief a plugin to provide the API for running test cases.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+#define BASE_DIR "testdir"
+
+#define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf"
+
+struct TestState
+{
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ TESTING_CMD_HELPER_write_cb write_message;
+
+ /**
+ * The name for a specific test environment directory.
+ *
+ */
+ char *testdir;
+
+ /**
+ * The name for the configuration file of the specific node.
+ *
+ */
+ char *cfgname;
+
+ /**
+ * The complete topology information.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+};
+
+static struct GNUNET_TESTING_Command block_send;
+
+static struct GNUNET_TESTING_Command connect_peers;
+
+static struct GNUNET_TESTING_Command local_prepared;
+
+
+/**
+ * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
+ * received.
+ *
+ */
+static int
+check_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
+ * being received.
+ *
+ */
+static void
+handle_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ // struct GNUNET_TESTING_AsyncContext *ac;
+
+ /*GNUNET_TESTING_get_trait_async_context (&block_receive,
+ &ac);
+ if ((NULL == ac) || (NULL == ac->cont))
+ GNUNET_TESTING_async_fail (ac);
+ else
+ GNUNET_TESTING_async_finish (ac);*/
+}
+
+
+/**
+ * Callback to set the flag indicating all peers started. Will be called via the plugin api.
+ *
+ */
+static void
+all_peers_started ()
+{
+ const struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_TESTING_get_trait_async_context (&block_send,
+ &ac);
+ GNUNET_assert (NULL != ac);
+ if ((NULL == ac->cont))
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac);
+ else
+ GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac);
+}
+
+
+/**
+* Function called with the final result of the test.
+*
+* @param cls the `struct MainParams`
+* @param rv #GNUNET_OK if the test passed
+*/
+static void
+handle_result (void *cls,
+ enum GNUNET_GenericReturnValue rv)
+{
+ struct TestState *ts = cls;
+ struct GNUNET_MessageHeader *reply;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Local test exits with status %d\n",
+ rv);
+ reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "message prepared\n");
+ ts->write_message (reply,
+ ntohs (reply->size));
+
+ GNUNET_free (ts->testdir);
+ GNUNET_free (ts->cfgname);
+ GNUNET_TESTING_free_topology (ts->topology);
+ GNUNET_free (ts);
+}
+
+
+/**
+ * Callback from start peer cmd for signaling a peer got connected.
+ *
+ */
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ const struct ConnectPeersState *cps;
+
+ GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers,
+ &cps);
+ void *ret = NULL;
+
+ cps->notify_connect (is,
+ peer);
+ return ret;
+}
+
+/**
+ * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
+ */
+static void
+all_local_tests_prepared ()
+{
+ const struct LocalPreparedState *lfs;
+
+ GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
+ &lfs);
+ GNUNET_assert (NULL != &lfs->ac);
+ if (NULL == lfs->ac.cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac);
+ else
+ GNUNET_TESTING_async_finish ((struct
+ GNUNET_TESTING_AsyncContext *) &lfs->ac);
+}
+
+/**
+ * Function to start a local test case.
+ *
+ * @param write_message Callback to send a message to the master loop.
+ * @param router_ip Global address of the network namespace.
+ * @param node_ip Local address of a node i a network namespace.
+ * @param m The number of the node in a network namespace.
+ * @param n The number of the network namespace.
+ * @param local_m The number of nodes in a network namespace.
+ */
+static void
+start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
+ char *node_ip,
+ char *m,
+ char *n,
+ char *local_m,
+ char *topology_data,
+ unsigned int *read_file)
+{
+
+ unsigned int n_int;
+ unsigned int m_int;
+ unsigned int local_m_int;
+ unsigned int num;
+ struct TestState *ts = GNUNET_new (struct TestState);
+
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ if (GNUNET_YES == *read_file)
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ else
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+
+ ts->topology = topology;
+
+ sscanf (m, "%u", &m_int);
+ sscanf (n, "%u", &n_int);
+ sscanf (local_m, "%u", &local_m_int);
+
+
+ if (0 == n_int)
+ num = m_int;
+ else
+ num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
+
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block");
+ connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
+ "start-peer",
+ "system-create",
+ num,
+ topology,
+ 0);
+ local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
+ "local-test-prepared",
+ write_message);
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_transport_api2_tcp_node1.conf");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "plugin cfgname: %s\n",
+ ts->cfgname);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "node ip: %s\n",
+ node_ip);
+
+ GNUNET_asprintf (&ts->testdir,
+ "%s%s%s",
+ BASE_DIR,
+ m,
+ n);
+
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (test,
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ struct GNUNET_TRANSPORT_TESTING_TestMessage,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
+
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_system_create ("system-create",
+ ts->testdir),
+ GNUNET_TRANSPORT_cmd_start_peer ("start-peer",
+ "system-create",
+ num,
+ node_ip,
+ handlers,
+ ts->cfgname,
+ notify_connect,
+ GNUNET_NO),
+ GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
+ write_message),
+ block_send,
+ connect_peers,
+ GNUNET_TRANSPORT_cmd_backchannel_check ("backchannel-check",
+ "start-peer",
+ "system-create",
+ num,
+ m_int,
+ n_int,
+ topology),
+ local_prepared,
+ GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
+ "start-peer"),
+ GNUNET_TESTING_cmd_system_destroy ("system-destroy",
+ "system-create"),
+ GNUNET_TESTING_cmd_end ()
+ };
+
+ ts->write_message = write_message;
+
+ GNUNET_TESTING_run (commands,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &handle_result,
+ ts);
+
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_test_transport_plugin_cmd_udp_backchannel_init (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api;
+
+ GNUNET_log_setup ("udp-backchannel",
+ "DEBUG",
+ NULL);
+
+ api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
+ api->start_testcase = &start_testcase;
+ api->all_peers_started = &all_peers_started;
+ api->all_local_tests_prepared = all_local_tests_prepared;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
+ * @return NULL
+ */
+void *
+libgnunet_test_transport_plugin_cmd_udp_backchannel_done (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* 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
deleted file mode 100644
index ce1245296..000000000
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/plugin_cmd_simple_send.c
- * @brief a plugin to provide the API for running test cases.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_transport_application_service.h"
-#include "transport-testing2.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-#define BASE_DIR "testdir"
-
-#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-
-/**
- * The name for a specific test environment directory.
- *
- */
-char *testdir;
-
-/**
- * The name for the configuration file of the specific node.
- *
- */
-char *cfgname;
-
-/**
- * Flag indicating if all peers have been started.
- *
- */
-unsigned int are_all_peers_started;
-
-
-/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
- * received.
- *
- */
-static int
-check_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
- * being received.
- *
- */
-static void
-handle_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
-}
-
-
-/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
- *
- */
-static int
-check_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
- *
- */
-static void
-handle_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
-}
-
-
-/**
- * Callback to set the flag indicating all peers started. Will be called via the plugin api.
- *
- */
-static void
-all_peers_started ()
-{
- are_all_peers_started = GNUNET_YES;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "setting are_all_peers_started: %d\n",
- are_all_peers_started);
-}
-
-
-/**
- * Function to start a local test case.
- *
- * @param write_message Callback to send a message to the master loop.
- * @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
- * @param m The number of the node in a network namespace.
- * @param n The number of the network namespace.
- * @param local_m The number of nodes in a network namespace.
- */
-static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
- char *node_ip,
- char *m,
- char *n,
- char *local_m)
-{
-
- unsigned int n_int, m_int, local_m_int, num;
-
- struct GNUNET_TESTING_NetjailTopology *topology =
- GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
-
- sscanf (m, "%u", &m_int);
- sscanf (n, "%u", &n_int);
- sscanf (local_m, "%u", &local_m_int);
-
-
- if (0 == m_int)
- num = n_int;
- else
- num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
-
- GNUNET_asprintf (&cfgname,
- "test_transport_api2_tcp_node1.conf");
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "plugin cfgname: %s\n",
- cfgname);
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "node ip: %s\n",
- node_ip);
-
- GNUNET_asprintf (&testdir,
- "%s%s%s",
- BASE_DIR,
- m,
- n);
-
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (test,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_hd_var_size (test2,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_handler_end ()
- };
-
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_system_create ("system-create",
- testdir),
- GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
- "system-create",
- num,
- node_ip,
- handlers,
- cfgname),
- GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
- write_message),
- GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
- &are_all_peers_started),
- GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
- "start-peer",
- "system-create",
- num),
- GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
- "start-peer",
- num),
- GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
- "start-peer"),
- GNUNET_TESTING_cmd_system_destroy ("system-destroy",
- "system-create"),
- GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
- write_message)
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
-
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api;
-
- api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
- api->start_testcase = &start_testcase;
- api->all_peers_started = &all_peers_started;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
- * @return NULL
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- GNUNET_free (testdir);
- GNUNET_free (cfgname);
- return NULL;
-}
-
-
-/* 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
deleted file mode 100644
index ce1245296..000000000
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel_send.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/plugin_cmd_simple_send.c
- * @brief a plugin to provide the API for running test cases.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_transport_application_service.h"
-#include "transport-testing2.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-#define BASE_DIR "testdir"
-
-#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-
-/**
- * The name for a specific test environment directory.
- *
- */
-char *testdir;
-
-/**
- * The name for the configuration file of the specific node.
- *
- */
-char *cfgname;
-
-/**
- * Flag indicating if all peers have been started.
- *
- */
-unsigned int are_all_peers_started;
-
-
-/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
- * received.
- *
- */
-static int
-check_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
- * being received.
- *
- */
-static void
-handle_test (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
-}
-
-
-/**
- * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
- *
- */
-static int
-check_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
- * being received.
- *
- */
-static void
-handle_test2 (void *cls,
- const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
-{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "message received\n");
-}
-
-
-/**
- * Callback to set the flag indicating all peers started. Will be called via the plugin api.
- *
- */
-static void
-all_peers_started ()
-{
- are_all_peers_started = GNUNET_YES;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "setting are_all_peers_started: %d\n",
- are_all_peers_started);
-}
-
-
-/**
- * Function to start a local test case.
- *
- * @param write_message Callback to send a message to the master loop.
- * @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
- * @param m The number of the node in a network namespace.
- * @param n The number of the network namespace.
- * @param local_m The number of nodes in a network namespace.
- */
-static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
- char *node_ip,
- char *m,
- char *n,
- char *local_m)
-{
-
- unsigned int n_int, m_int, local_m_int, num;
-
- struct GNUNET_TESTING_NetjailTopology *topology =
- GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
-
- sscanf (m, "%u", &m_int);
- sscanf (n, "%u", &n_int);
- sscanf (local_m, "%u", &local_m_int);
-
-
- if (0 == m_int)
- num = n_int;
- else
- num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
-
- GNUNET_asprintf (&cfgname,
- "test_transport_api2_tcp_node1.conf");
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "plugin cfgname: %s\n",
- cfgname);
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "node ip: %s\n",
- node_ip);
-
- GNUNET_asprintf (&testdir,
- "%s%s%s",
- BASE_DIR,
- m,
- n);
-
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (test,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_hd_var_size (test2,
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
- struct GNUNET_TRANSPORT_TESTING_TestMessage,
- NULL),
- GNUNET_MQ_handler_end ()
- };
-
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_system_create ("system-create",
- testdir),
- GNUNET_TRANSPORT_cmd_start_peer_v2 ("start-peer",
- "system-create",
- num,
- node_ip,
- handlers,
- cfgname),
- GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
- write_message),
- GNUNET_TESTING_cmd_block_until_all_peers_started ("block",
- &are_all_peers_started),
- GNUNET_TRANSPORT_cmd_connect_peers_v2 ("connect-peers",
- "start-peer",
- "system-create",
- num),
- GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple",
- "start-peer",
- num),
- GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
- "start-peer"),
- GNUNET_TESTING_cmd_system_destroy ("system-destroy",
- "system-create"),
- GNUNET_TESTING_cmd_local_test_finished ("local-test-finished",
- write_message)
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
-
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api;
-
- api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
- api->start_testcase = &start_testcase;
- api->all_peers_started = &all_peers_started;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init
- * @return NULL
- */
-void *
-libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- GNUNET_free (testdir);
- GNUNET_free (cfgname);
- return NULL;
-}
-
-
-/* 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
deleted file mode 100644
index d3233c2da..000000000
--- a/src/transport/test_transport_port_forward.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file transport/test_transport_port_forward.c
- * @brief Test case executing a script which sends a test UDP message from a nated peer
- * to a global known peer. There is a tcp port forwarding in place towards the
- * natted peer to test the backchannel functionality of the TNG service.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
-
-/**
- * Return value of the test.
- *
- */
-static unsigned int rv = 0;
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- *
- */
-static void
-run (void *cls)
-{
- const char *topology_config = "test_topology_port_forward.conf";
-
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start",
- topology_config),
- GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed",
- topology_config,
- &rv),
- GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed",
- "netjail-start-testbed",
- topology_config),
- GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop",
- topology_config),
- GNUNET_TESTING_cmd_end ()
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- TIMEOUT);
-}
-
-
-int
-main (int argc,
- char *const *argv)
-{
- GNUNET_log_setup ("test-netjail",
- "DEBUG",
- NULL);
- GNUNET_SCHEDULER_run (&run,
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test finished!\n");
- return rv;
-}
diff --git a/src/transport/test_transport_simple_send.c b/src/transport/test_transport_simple_send.c
deleted file mode 100644
index 924990d0a..000000000
--- a/src/transport/test_transport_simple_send.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file transport/test_transport_api_cmd_simple_send.c
- * @brief Test case executing a script which sends a test message between two peers.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
-
-/**
- * Return value of the test.
- *
- */
-static unsigned int rv = 0;
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- *
- */
-static void
-run (void *cls)
-{
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_netjail_start ("netjail-start",
- "2",
- "1"),
- GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
- "2",
- "1",
- "libgnunet_test_transport_plugin_cmd_simple_send",
- &rv),
- GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
- "netjail-start-testbed",
- "2",
- "1"),
- GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
- "2",
- "1"),
- GNUNET_TESTING_cmd_end ()
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- TIMEOUT);
-}
-
-
-int
-main (int argc,
- char *const *argv)
-{
- GNUNET_log_setup ("test-netjail",
- "DEBUG",
- NULL);
- GNUNET_SCHEDULER_run (&run,
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test finished!\n");
- return rv;
-}
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh
index 25d5b6797..3d5266622 100755
--- a/src/transport/test_transport_simple_send.sh
+++ b/src/transport/test_transport_simple_send.sh
@@ -1,2 +1,10 @@
#!/bin/bash
-exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_simple_send"
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
+ exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf"
+else
+ echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+fi
diff --git a/src/transport/test_transport_simple_send_broadcast.sh b/src/transport/test_transport_simple_send_broadcast.sh
new file mode 100755
index 000000000..f264b1203
--- /dev/null
+++ b/src/transport/test_transport_simple_send_broadcast.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
+ # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_simple_send_broadcast_topo.conf"
+ exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_broadcast_topo.conf"
+else
+ echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+fi
diff --git a/src/transport/test_transport_simple_send_broadcast_topo.conf b/src/transport/test_transport_simple_send_broadcast_topo.conf
new file mode 100644
index 000000000..aa4964f81
--- /dev/null
+++ b/src/transport/test_transport_simple_send_broadcast_topo.conf
@@ -0,0 +1,4 @@
+M:2
+N:1
+X:0
+T:libgnunet_test_transport_plugin_cmd_simple_send_broadcast \ No newline at end of file
diff --git a/src/transport/test_transport_simple_send_dv.sh b/src/transport/test_transport_simple_send_dv.sh
new file mode 100755
index 000000000..fa127cfa4
--- /dev/null
+++ b/src/transport/test_transport_simple_send_dv.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
+ # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_distance_vector_topo.conf"
+ exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_topo.conf"
+else
+ echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+fi
diff --git a/src/transport/test_transport_simple_send_string.sh b/src/transport/test_transport_simple_send_string.sh
new file mode 100755
index 000000000..b2bd05d5f
--- /dev/null
+++ b/src/transport/test_transport_simple_send_string.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+string=$(cat << EOF
+M:2
+N:1
+X:0
+T:libgnunet_test_transport_plugin_cmd_simple_send
+P:1:1|{connect:{P:1:2:tcp}}
+P:1:2|{connect:{P:1:1:tcp}}
+EOF
+ )
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
+ exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'"
+else
+ echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+fi
diff --git a/src/transport/test_transport_simple_send_topo.conf b/src/transport/test_transport_simple_send_topo.conf
new file mode 100644
index 000000000..2c16201f5
--- /dev/null
+++ b/src/transport/test_transport_simple_send_topo.conf
@@ -0,0 +1,6 @@
+M:2
+N:1
+X:0
+T:libgnunet_test_transport_plugin_cmd_simple_send
+P:1:1|{connect:{P:1:2:tcp}}
+P:1:2|{connect:{P:1:1:tcp}} \ No newline at end of file
diff --git a/src/transport/test_transport_simple_send_v2.c b/src/transport/test_transport_simple_send_v2.c
deleted file mode 100644
index aeac1bfb6..000000000
--- a/src/transport/test_transport_simple_send_v2.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file transport/test_transport_api_cmd_simple_send.c
- * @brief Test case executing a script which sends a test message between two peers.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
-
-#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
-
-/**
- * Return value of the test.
- *
- */
-static unsigned int rv = 0;
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- *
- */
-static void
-run (void *cls)
-{
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start",
- TOPOLOGY_CONFIG),
- GNUNET_TESTING_cmd_netjail_start_testing_system_v2 ("netjail-start-testbed",
- TOPOLOGY_CONFIG,
- &rv),
- GNUNET_TESTING_cmd_stop_testing_system_v2 ("stop-testbed",
- "netjail-start-testbed",
- TOPOLOGY_CONFIG),
- GNUNET_TESTING_cmd_netjail_stop_v2 ("netjail-stop",
- TOPOLOGY_CONFIG),
- GNUNET_TESTING_cmd_end ()
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- TIMEOUT);
-}
-
-
-int
-main (int argc,
- char *const *argv)
-{
- GNUNET_log_setup ("test-netjail",
- "DEBUG",
- NULL);
- GNUNET_SCHEDULER_run (&run,
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test finished!\n");
- return rv;
-}
diff --git a/src/transport/test_transport_simple_send_v2.sh b/src/transport/test_transport_simple_send_v2.sh
deleted file mode 100755
index 8462d1849..000000000
--- a/src/transport/test_transport_simple_send_v2.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_simple_send_v2"
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c
new file mode 100644
index 000000000..c3411becc
--- /dev/null
+++ b/src/transport/test_transport_start_with_config.c
@@ -0,0 +1,121 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file transport/test_transport_start_with_config.c
+ * @brief Generic program to start testcases in an configurable topology.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "transport-testing-cmds.h"
+#include "gnunet_util_lib.h"
+
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
+
+
+int
+main (int argc,
+ char *const *argv)
+{
+ char *topology_data;
+ char *topology_data_script;
+ struct GNUNET_TESTING_NetjailTopology *topology;
+ unsigned int read_file = GNUNET_YES;
+ int ret;
+ char *rest = NULL;
+ char *token;
+ size_t single_line_len;
+ size_t data_len;
+
+ GNUNET_log_setup ("test-netjail",
+ "DEBUG",
+ NULL);
+
+ if (0 == strcmp ("-s", argv[1]))
+ {
+ data_len = strlen (argv[2]);
+ topology_data = GNUNET_malloc (data_len);
+ topology_data_script = GNUNET_malloc (data_len);
+ token = strtok_r (argv[2], "\n", &rest);
+ while (NULL != token)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "token1 %s\n",
+ token);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "token2 %s\n",
+ token);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "topology_data %s\n",
+ topology_data);
+ strcat (topology_data_script, token);
+ strcat (topology_data_script, " ");
+ strcat (topology_data, token);
+ strcat (topology_data, "\n");
+ token = strtok_r (NULL, "\n", &rest);
+ }
+ single_line_len = strlen (topology_data);
+ topology_data_script [single_line_len - 1] = '\0';
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "read from string\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "topology_data %s\n",
+ topology_data);
+ read_file = GNUNET_NO;
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+ }
+ else
+ {
+ topology_data = argv[1];
+ topology_data_script = argv[1];
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ }
+
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_netjail_start ("netjail-start",
+ topology_data_script,
+ &read_file),
+ GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
+ topology,
+ &read_file,
+ topology_data_script),
+ GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
+ "netjail-start-testbed",
+ topology),
+ GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
+ topology_data_script,
+ &read_file),
+ GNUNET_TESTING_cmd_end ()
+ };
+
+ ret = GNUNET_TESTING_main (commands,
+ TIMEOUT);
+
+ if (0 == strcmp ("-s", argv[1]))
+ {
+ GNUNET_free (topology_data_script);
+ GNUNET_free (topology_data);
+ }
+ GNUNET_TESTING_free_topology (topology);
+
+ return ret;
+}
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh
new file mode 100755
index 000000000..1b0e283b5
--- /dev/null
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
+#exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
+exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; GNUNET_FORCE_LOG='transport;;;;DEBUG' GNUNET_FORCE_LOGFILE='test.out' ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
+# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
+else
+ echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+fi
diff --git a/src/transport/test_transport_udp_backchannel_topo.conf b/src/transport/test_transport_udp_backchannel_topo.conf
new file mode 100644
index 000000000..ad35bde0a
--- /dev/null
+++ b/src/transport/test_transport_udp_backchannel_topo.conf
@@ -0,0 +1,7 @@
+M:1
+N:1
+X:1
+T:libgnunet_test_transport_plugin_cmd_udp_backchannel
+K:1|{connect:{P:1:1:tcp}}
+R:1|{tcp_port:1}|{udp_port:0}
+P:1:1|{connect:{K:1:udp}}
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index f9ebafade..af6f47962 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -29,92 +29,84 @@
#include "gnunet_testing_lib.h"
-struct StartPeerState_v2
-{
- /**
- * The ip of a node.
- */
- char *node_ip;
+typedef void *
+(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer);
+/**
+ * Struct to store information needed in callbacks.
+ *
+ */
+struct ConnectPeersState
+{
/**
- * Receive callback
+ * Context for our asynchronous completion.
*/
- struct GNUNET_MQ_MessageHandler *handlers;
+ struct GNUNET_TESTING_AsyncContext ac;
- const char *cfgname;
+ GNUNET_TRANSPORT_notify_connect_cb notify_connect;
/**
- * Peer's configuration
+ * The testing system of this node.
*/
- struct GNUNET_CONFIGURATION_Handle *cfg;
+ const struct GNUNET_TESTING_System *tl_system;
- struct GNUNET_TESTING_Peer *peer;
+ // Label of the cmd which started the test system.
+ const char *create_label;
/**
- * Peer identity
+ * Number globally identifying the node.
+ *
*/
- struct GNUNET_PeerIdentity id;
+ uint32_t num;
/**
- * Peer's transport service handle
+ * Label of the cmd to start a peer.
+ *
*/
- struct GNUNET_TRANSPORT_CoreHandle *th;
+ const char *start_peer_label;
/**
- * Application handle
+ * The topology of the test setup.
*/
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+ struct GNUNET_TESTING_NetjailTopology *topology;
/**
- * Peer's PEERSTORE Handle
+ * Connections to other peers.
*/
- struct GNUNET_PEERSTORE_Handle *ph;
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
- /**
- * Hello get task
- */
- struct GNUNET_SCHEDULER_Task *rh_task;
+ struct GNUNET_TESTING_Interpreter *is;
/**
- * Peer's transport get hello handle to retrieve peer's HELLO message
+ * Number of connections.
*/
- struct GNUNET_PEERSTORE_IterateContext *pic;
+ unsigned int con_num;
/**
- * Hello
+ * Number of additional connects this cmd will wait for not triggered by this cmd.
*/
- char *hello;
+ unsigned int additional_connects;
/**
- * Hello size
- */
- size_t hello_size;
-
- char *m;
-
- char *n;
-
- char *local_m;
-
- unsigned int finished;
-
- const char *system_label;
+ * Number of connections we already have a notification for.
+ */
+ unsigned int con_num_notified;
/**
- * An unique number to identify the peer
+ * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
*/
- unsigned int no;
-
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- struct GNUNET_TESTING_System *tl_system;
-
+ unsigned int additional_connects_notified;
};
-
struct StartPeerState
{
/**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
* The ip of a node.
*/
char *node_ip;
@@ -179,8 +171,6 @@ struct StartPeerState
char *local_m;
- unsigned int finished;
-
const char *system_label;
/**
@@ -190,123 +180,167 @@ struct StartPeerState
struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
- struct GNUNET_TESTING_System *tl_system;
-
-};
+ const struct GNUNET_TESTING_System *tl_system;
+ GNUNET_TRANSPORT_notify_connect_cb notify_connect;
-int
-GNUNET_TRANSPORT_get_trait_state (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct StartPeerState **sps);
-
+ /**
+ * Flag indicating, if udp broadcast should be switched on.
+ */
+ unsigned int broadcast;
+};
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label,
- const char *system_label,
- uint32_t no,
- char *node_ip,
- struct GNUNET_MQ_MessageHandler *handlers,
- const char *cfgname);
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param system_label Label of the cmd to setup a test environment.
+ * @param m The number of the local node of the actual network namespace.
+ * @param n The number of the actual namespace.
+ * @param local_m Number of local nodes in each namespace.
+ * @param handlers Handler for messages received by this peer.
+ * @param cfgname Configuration file name for this peer.
+ * @param notify_connect Method which will be called, when a peer connects.
+ * @param broadcast Flag indicating, if broadcast should be switched on.
+ * @return command.
+ */
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_start_peer (const char *label,
const char *system_label,
- char *m,
- char *n,
- char *local_m,
+ uint32_t no,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
- const char *cfgname);
+ const char *cfgname,
+ GNUNET_TRANSPORT_notify_connect_cb
+ notify_connect,
+ unsigned int broadcast);
+
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
const char *start_label);
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num);
+/**
+ * Create command
+ *
+ * @param label name for command
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
+ * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
+ * @return command.
+ */
struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num);
+GNUNET_TRANSPORT_cmd_connect_peers (
+ const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int additional_connects);
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
+ * @return command.
+ */
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_send_simple (const char *label,
- char *m,
- char *n,
+ const char *start_peer_label,
+ const char *create_label,
uint32_t num,
- const char *start_peer_label);
+ struct GNUNET_TESTING_NetjailTopology *
+ topology);
+
/**
* Create command.
*
* @param label name for command.
- * @param m The number of the local node of the actual network namespace.
- * @param n The number of the actual namespace.
- * @param num Number globally identifying the node.
* @param start_peer_label Label of the cmd to start a peer.
+ * @param create_label Label of the cmd to create the testing system.
+ * @param num Number globally identifying the node.
+ * @param node_n The number of the node in a network namespace.
+ * @param namespace_n The number of the network namespace.
+ * @param The topology for the test setup.
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label,
- const char *start_peer_label,
- uint32_t num);
-
-int
-GNUNET_TRANSPORT_get_trait_peer_id (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_PeerIdentity **id);
-
-int
-GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiShortmap *
- *
- connected_peers_map);
-
-int
-GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiShortmap
- *
- *
- connected_peers_map);
-int
-GNUNET_TRANSPORT_get_trait_hello_size (const struct
- GNUNET_TESTING_Command
- *cmd,
- size_t **hello_size);
-
-int
-GNUNET_TRANSPORT_get_trait_hello (const struct
- GNUNET_TESTING_Command
- *cmd,
- char **hello);
-
-
-int
-GNUNET_TRANSPORT_get_trait_application_handle (const struct
- GNUNET_TESTING_Command *cmd,
- struct
- GNUNET_TRANSPORT_ApplicationHandle
- **ah);
-
-int
-GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct
- GNUNET_TESTING_Command *cmd,
- struct
- GNUNET_TRANSPORT_ApplicationHandle
- **ah);
+GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ unsigned int node_n,
+ unsigned int namespace_n,
+ struct GNUNET_TESTING_NetjailTopology *
+ topology);
+
+
+/**
+ * Create headers for a trait with name @a name for
+ * statically allocated data of type @a type.
+ */
+#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TRANSPORT_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ type **ret); \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TRANSPORT_make_trait_ ## name ( \
+ type * value);
+
+
+/**
+ * Create C implementation for a trait with name @a name for statically
+ * allocated data of type @a type.
+ */
+#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TRANSPORT_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ type **ret) \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
+ GNUNET_S (name), \
+ 0); \
+ } \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TRANSPORT_make_trait_ ## name ( \
+ type * value) \
+ { \
+ struct GNUNET_TESTING_Trait ret = { \
+ .trait_name = GNUNET_S (name), \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
+ }
+
+
+/**
+ * Call #op on all simple traits.
+ */
+#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
+ op (peer_id, const struct GNUNET_PeerIdentity) \
+ op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
+ op (hello_size, const size_t) \
+ op (hello, const char) \
+ op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
+ op (connect_peer_state, const struct ConnectPeersState) \
+ op (state, const struct StartPeerState)
+
+GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
+
#endif
/* end of transport_testing.h */
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index 446add6f6..2a80db87b 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -904,6 +904,10 @@ GNUNET_TRANSPORT_communicator_receive (
struct GNUNET_TRANSPORT_IncomingMessage *im;
uint16_t msize;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "communicator receive\n");
+
if (NULL == ch->mq)
return GNUNET_SYSERR;
if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
@@ -986,6 +990,9 @@ GNUNET_TRANSPORT_communicator_mq_add (
{
struct GNUNET_TRANSPORT_QueueHandle *qh;
+ // Do not notify the service if there is no intial capacity.
+ GNUNET_assert (0 < q_len);
+
qh = GNUNET_new (struct GNUNET_TRANSPORT_QueueHandle);
qh->ch = ch;
qh->peer = *peer;
@@ -1106,7 +1113,7 @@ GNUNET_TRANSPORT_communicator_address_remove (
*/
void
GNUNET_TRANSPORT_communicator_address_remove_all (
- struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
+ struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
{
for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
ai = ai->next)
diff --git a/src/transport/transport_api2_core.c b/src/transport/transport_api2_core.c
index 002af81fc..8cd0b7c8c 100644
--- a/src/transport/transport_api2_core.c
+++ b/src/transport/transport_api2_core.c
@@ -244,7 +244,8 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
struct GNUNET_TRANSPORT_CoreHandle *h = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Error receiving from transport service, disconnecting temporarily.\n");
+ "Error %u received from transport service, disconnecting temporarily.\n",
+ error);
disconnect_and_schedule_reconnect (h);
}
@@ -522,6 +523,8 @@ check_recv (void *cls, const struct InboundMessage *im)
const struct GNUNET_MessageHeader *imm;
uint16_t size;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "check_recv\n");
size = ntohs (im->header.size) - sizeof(*im);
if (size < sizeof(struct GNUNET_MessageHeader))
{
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c
new file mode 100644
index 000000000..1bec3abd3
--- /dev/null
+++ b/src/transport/transport_api_cmd_backchannel_check.c
@@ -0,0 +1,602 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing_api_cmd_backchannel_check.c
+ * @brief cmd to start a peer.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "gnunet_hello_lib.h"
+#include "gnunet_transport_service.h"
+#include "transport-testing-cmds.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+#define UDP "udp"
+
+/**
+ * Maximum length allowed for line input.
+ */
+#define MAX_LINE_LENGTH 1024
+
+/**
+ * Struct to store information needed in callbacks.
+ *
+ */
+struct CheckState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The number of the node in a network namespace.
+ */
+ unsigned int node_n;
+
+ /**
+ * The number of the network namespace.
+ */
+ unsigned int namespace_n;
+
+ /**
+ * The testing system of this node.
+ */
+ const struct GNUNET_TESTING_System *tl_system;
+
+ // Label of the cmd which started the test system.
+ const char *create_label;
+
+ /**
+ * Number globally identifying the node.
+ *
+ */
+ uint32_t num;
+
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
+
+ /**
+ * The topology of the test setup.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ /**
+ * Connections to other peers.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+
+ /**
+ * Number of connections.
+ */
+ unsigned int con_num;
+
+ /**
+ * Number of received backchannel messages.
+ */
+ unsigned int received_backchannel_msgs;
+
+ /**
+ * Array with search strings.
+ */
+ char **search_string;
+
+ /**
+ * File handle for log file.
+ */
+ struct GNUNET_DISK_FileHandle *fh;
+
+ /**
+ * Task which handles the reading
+ */
+ struct GNUNET_SCHEDULER_Task *task;
+
+ /**
+ * Stream to read log file lines.
+ */
+ FILE *stream;
+};
+
+/**
+ *
+ * @param cls The cmd state CheckState.
+ */
+static void
+read_from_log (void *cls)
+{
+ struct CheckState *cs = cls;
+ char line[MAX_LINE_LENGTH + 1];
+ char *search_string;
+
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read_from_log\n");
+
+ cs->fh = GNUNET_DISK_file_open ("test.out",
+ GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_USER_READ);
+
+ cs->task = NULL;
+
+ /* read message from line and handle it */
+ cs->stream = fdopen (cs->fh->fd, "r");
+ memset (line, 0, MAX_LINE_LENGTH + 1);
+
+ // fgets (line, MAX_LINE_LENGTH, cs->stream);
+ // while (NULL != line && 0 != strcmp (line, ""))// '\0' != line[0])
+ while (NULL != fgets (line, MAX_LINE_LENGTH, cs->stream))
+ {
+ /*LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "cs->received_backchannel_msgs: %u\n",
+ cs->received_backchannel_msgs);*/
+ /*if (NULL == strstr (line, "line"))
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "line: %s",
+ line);*/
+
+
+ for (int i = 0; i < cs->con_num; i++)
+ {
+ search_string = cs->search_string[i];
+ /*LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "search %u %u: %s %p\n",
+ i,
+ cs->con_num,
+ cs->search_string[i],
+ cs->search_string);
+ fprintf (stderr,
+ line);*/
+ if (NULL != strstr (line,
+ search_string))
+ // "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp"))
+ // cs->search_string[i]))
+ {
+ cs->received_backchannel_msgs++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "received_backchannel_msgs %u con_num %u\n",
+ cs->received_backchannel_msgs,
+ cs->con_num);
+ if (cs->received_backchannel_msgs == cs->con_num)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "search finished %lu %lu %u\n",
+ strlen (cs->search_string[i]),
+ strlen (
+ "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp"),
+ strcmp (
+ "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp",
+ cs->search_string[i]));
+ GNUNET_TESTING_async_finish (&cs->ac);
+ fclose (cs->stream);
+ return;
+ }
+ }
+ }
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read_from_log end\n");
+ fclose (cs->stream);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
+ &read_from_log,
+ cs);
+ /*if (NULL == fgets (line, MAX_LINE_LENGTH, cs->stream))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read null\n");
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &read_from_log,
+ cs);
+ return;
+ }*/
+ /*else {
+ cs->task =
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+ cs->fh,
+ &read_from_log,
+ cs);
+
+
+ }*/
+}
+
+
+static enum GNUNET_GenericReturnValue
+will_the_other_node_connect_via_udp (
+ struct CheckState *cs,
+ const struct GNUNET_TESTING_NetjailNode *node)
+// struct GNUNET_TESTING_NodeConnection *connection)
+{
+ // struct GNUNET_TESTING_NetjailTopology *topology = cs->topology;
+ // unsigned int node_n = connection->node_n;
+ // unsigned int namespace_n = connection->namespace_n;
+ // struct GNUNET_HashCode hc;
+ // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
+ // struct GNUNET_HashCode hc_namespace;
+ /*struct GNUNET_ShortHashCode *key_namespace = GNUNET_new (struct
+ GNUNET_ShortHashCode);*/
+ // struct GNUNET_TESTING_NetjailNode *node;
+ struct GNUNET_TESTING_NodeConnection *pos_connection;
+ struct GNUNET_TESTING_AddressPrefix *pos_prefix;
+ // struct GNUNET_TESTING_NetjailNamespace *namespace;
+ // struct GNUNET_CONTAINER_MultiShortmap *map;
+
+ /* if (0 == connection->namespace_n) */
+ /* { */
+ /* map = topology->map_globals; */
+ /* } */
+ /* else */
+ /* { */
+ /* GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc_namespace); */
+ /* memcpy (key_namespace, */
+ /* &hc_namespace, */
+ /* sizeof (*key_namespace)); */
+ /* if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( */
+ /* topology->map_namespaces, */
+ /* key_namespace)) */
+ /* { */
+ /* namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, */
+ /* key_namespace); */
+ /* map = namespace->nodes; */
+ /* } */
+ /* else */
+ /* GNUNET_assert (0); */
+ /* } */
+
+ /* GNUNET_CRYPTO_hash (&node_n, sizeof(node_n), &hc); */
+ /* memcpy (key, */
+ /* &hc, */
+ /* sizeof (*key)); */
+ /* if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( */
+ /* map, */
+ /* key)) */
+ /* { */
+ /* node = GNUNET_CONTAINER_multishortmap_get (cs->topology->map_globals, */
+ /* key); */
+ /* for (pos_connection = node->node_connections_head; NULL != pos_connection; */
+ /* pos_connection = pos_connection->next) */
+ /* { */
+ /* if ((node->namespace_n == pos_connection->namespace_n) && */
+ /* (node->node_n == pos_connection->node_n) ) */
+ /* { */
+ /* for (pos_prefix = pos_connection->address_prefixes_head; NULL != */
+ /* pos_prefix; */
+ /* pos_prefix = */
+ /* pos_prefix->next) */
+ /* { */
+ /* if (0 == strcmp (UDP, pos_prefix->address_prefix)) */
+ /* { */
+ /* return GNUNET_YES; */
+ /* } */
+ /* } */
+ /* } */
+ /* } */
+ /* } */
+
+ for (pos_connection = node->node_connections_head; NULL != pos_connection;
+ pos_connection = pos_connection->next)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "connect via udp %u %u %u %u\n",
+ node->namespace_n,
+ cs->namespace_n,
+ node->node_n,
+ cs->node_n);
+ if ((pos_connection->namespace_n == cs->namespace_n) &&
+ (pos_connection->node_n == cs->node_n) )
+ {
+ for (pos_prefix = pos_connection->address_prefixes_head; NULL !=
+ pos_prefix;
+ pos_prefix =
+ pos_prefix->next)
+ {
+ if (0 == strcmp (UDP, pos_prefix->address_prefix))
+ {
+ return GNUNET_YES;
+ }
+ }
+ }
+ }
+
+ return GNUNET_NO;
+}
+
+static void
+add_search_string (struct CheckState *cs, const struct
+ GNUNET_TESTING_NetjailNode *node)
+{
+ unsigned int num;
+ struct GNUNET_PeerIdentity *peer;
+ struct GNUNET_PeerIdentity *us;
+ char *buf;
+ char *part_one = "Delivering backchannel message from ";
+ char *part_two = " to ";
+ char *part_three = " of type 1460 to udp";
+ char *peer_id;
+ char *us_id;
+
+ if (0 == node->namespace_n)
+ num = node->node_n;
+ else
+ num = (node->namespace_n - 1) * cs->topology->nodes_m + node->node_n
+ + cs->topology->nodes_x;
+
+ // num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology);
+ peer = GNUNET_TESTING_get_pub_key (num, cs->tl_system);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "peer: %s num %u\n",
+ GNUNET_i2s (peer),
+ num);
+ us = GNUNET_TESTING_get_pub_key (cs->num, cs->tl_system);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "us: %s cs->num %d\n",
+ GNUNET_i2s (us),
+ cs->num);
+
+ GNUNET_asprintf (&peer_id,
+ "%s",
+ GNUNET_i2s (peer));
+ GNUNET_asprintf (&us_id,
+ "%s",
+ GNUNET_i2s (us));
+
+ if (0 < GNUNET_asprintf (&buf,
+ "%s%s%s%s%s",
+ part_one,
+ us_id,
+ part_two,
+ peer_id,
+ part_three))
+ {
+ GNUNET_array_append (cs->search_string,
+ cs->con_num,
+ buf);
+ /*LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "con_num: %u search: %s %p\n",
+ cs->con_num,
+ cs->search_string[cs->con_num - 1],
+ cs->search_string);*/
+ }
+ else
+ GNUNET_assert (0);
+}
+
+
+/**
+ * The run method of this cmd will connect to peers.
+ *
+ */
+static void
+backchannel_check_run (void *cls,
+ struct GNUNET_TESTING_Interpreter *is)
+{
+ struct CheckState *cs = cls;
+ // char *buf;
+ // char *part_one = "Delivering backchannel message from ";
+ // char *part_two = " of type 1460 to udp";
+ const struct GNUNET_TESTING_Command *system_cmd;
+ const struct GNUNET_TESTING_System *tl_system;
+ const struct GNUNET_TESTING_Command *peer1_cmd;
+ const struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+ // struct GNUNET_PeerIdentity *peer;
+ // uint32_t num;
+ // struct GNUNET_TESTING_NodeConnection *pos_connection;
+ // unsigned int con_num = 0;
+ struct GNUNET_CONTAINER_MultiShortmapIterator *node_it;
+ struct GNUNET_CONTAINER_MultiShortmapIterator *namespace_it;
+ struct GNUNET_ShortHashCode node_key;
+ struct GNUNET_ShortHashCode namespace_key;
+ const struct GNUNET_TESTING_NetjailNode *node;
+ const struct GNUNET_TESTING_NetjailNamespace *namespace;
+
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ cs->start_peer_label);
+ GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
+ &ah);
+
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ cs->create_label);
+ GNUNET_TESTING_get_trait_test_system (system_cmd,
+ &tl_system);
+
+ cs->tl_system = tl_system;
+
+ cs->node_connections_head = GNUNET_TESTING_get_connections (cs->num,
+ cs->topology);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "check run\n");
+
+
+ node_it = GNUNET_CONTAINER_multishortmap_iterator_create (
+ cs->topology->map_globals);
+
+ while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (node_it,
+ &node_key,
+ (const
+ void**) &
+ node))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "namespace_n %u node_n %u\n",
+ node->namespace_n,
+ node->node_n);
+ if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node))
+ {
+ add_search_string (cs, node);
+ }
+ }
+ namespace_it = GNUNET_CONTAINER_multishortmap_iterator_create (
+ cs->topology->map_namespaces);
+ while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (
+ namespace_it,
+ &namespace_key,
+ (const
+ void**) &namespace))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "namespace_n %u\n",
+ node->namespace_n);
+ node_it = GNUNET_CONTAINER_multishortmap_iterator_create (
+ namespace->nodes);
+ while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (node_it,
+ &node_key,
+ (const
+ void**)
+ &node))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "namespace_n %u node_n %u\n",
+ node->namespace_n,
+ node->node_n);
+ if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node))
+ {
+ add_search_string (cs, node);
+ }
+ }
+ }
+ /* for (pos_connection = cs->node_connections_head; NULL != pos_connection; */
+ /* pos_connection = pos_connection->next) */
+ /* { */
+
+ /* if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node)) */
+ /* { */
+ /* num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology); */
+ /* peer = GNUNET_TESTING_get_pub_key (num, tl_system); */
+ /* LOG (GNUNET_ERROR_TYPE_DEBUG, */
+ /* "peer: %s\n", */
+ /* GNUNET_i2s (peer)); */
+
+ /* if (0 < GNUNET_asprintf (&buf, */
+ /* "%s%s%s", */
+ /* part_one, */
+ /* GNUNET_i2s (peer), */
+ /* part_two)) */
+ /* { */
+ /* GNUNET_array_append (cs->search_string, */
+ /* con_num, */
+ /* buf); */
+ /* /\*LOG (GNUNET_ERROR_TYPE_DEBUG, */
+ /* "con_num: %u search: %s %p\n", */
+ /* con_num, */
+ /* cs->search_string[con_num - 1], */
+ /* cs->search_string);*\/ */
+ /* } */
+ /* else */
+ /* GNUNET_assert (0); */
+ /* } */
+
+
+ /* } */
+ // cs->con_num = con_num;
+ if (0 != cs->con_num)
+ {
+ cs->task =
+ GNUNET_SCHEDULER_add_now (&read_from_log,
+ cs);
+ }
+ else
+ GNUNET_TESTING_async_finish (&cs->ac);
+
+}
+
+
+/**
+ * Trait function of this cmd does nothing.
+ *
+ */
+static int
+backchannel_check_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
+static void
+backchannel_check_cleanup (void *cls)
+{
+ struct ConnectPeersState *cs = cls;
+
+ GNUNET_free (cs);
+}
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_label Label of the cmd to create the testing system.
+ * @param num Number globally identifying the node.
+ * @param node_n The number of the node in a network namespace.
+ * @param namespace_n The number of the network namespace.
+ * @param The topology for the test setup.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ unsigned int node_n,
+ unsigned int namespace_n,
+ struct GNUNET_TESTING_NetjailTopology *
+ topology)
+{
+ struct CheckState *cs;
+
+ cs = GNUNET_new (struct CheckState);
+ cs->start_peer_label = start_peer_label;
+ cs->num = num;
+ cs->create_label = create_label;
+ cs->topology = topology;
+ cs->node_n = node_n;
+ cs->namespace_n = namespace_n;
+
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = cs,
+ .label = label,
+ .run = &backchannel_check_run,
+ .ac = &cs->ac,
+ .cleanup = &backchannel_check_cleanup,
+ .traits = &backchannel_check_traits
+ };
+
+ return cmd;
+}
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 09ca9e54c..fc925675d 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_transport_service.h"
@@ -37,228 +38,177 @@
#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
/**
- * Struct to store information needed in callbacks.
- *
- */
-struct ConnectPeersState
-{
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The peer identity of this peer.
- *
- */
- struct GNUNET_PeerIdentity *id;
-};
-
-
-/**
* The run method of this cmd will connect to peers.
*
*/
static void
connect_peers_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct ConnectPeersState *cps = cls;
const struct GNUNET_TESTING_Command *system_cmd;
- struct GNUNET_TESTING_System *tl_system;
- struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
- GNUNET_CRYPTO_EddsaPrivateKey);
- struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
- GNUNET_CRYPTO_EddsaPublicKey);
- ;
+ const struct GNUNET_TESTING_System *tl_system;
+
+
const struct GNUNET_TESTING_Command *peer1_cmd;
- // const struct GNUNET_TESTING_Command *peer2_cmd;
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
- struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
+ const struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+ struct GNUNET_PeerIdentity *peer;
char *addr;
- // struct GNUNET_TIME_Absolute t;
- char *hello;
- // size_t *hello_size;
enum GNUNET_NetworkType nt = 0;
- char *peer_id;
- struct GNUNET_PeerIdentity *id;
- struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
uint32_t num;
+ struct GNUNET_TESTING_NodeConnection *pos_connection;
+ struct GNUNET_TESTING_AddressPrefix *pos_prefix;
+ unsigned int con_num = 0;
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
+ cps->is = is;
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ cps->start_peer_label);
GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
&ah);
- GNUNET_TRANSPORT_get_trait_hello (peer1_cmd,
- &hello);
-
- GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
- &id);
-
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ cps->create_label);
GNUNET_TESTING_get_trait_test_system (system_cmd,
&tl_system);
- if (2 == cps->num)
- num = 1;
- else
- num = 2;
-
+ cps->tl_system = tl_system;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "cps->num: %u \n",
+ cps->num);
+ cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num,
+ cps->topology);
- // if (strstr (hello, "60002") != NULL)
- if (2 == num)
+ for (pos_connection = cps->node_connections_head; NULL != pos_connection;
+ pos_connection = pos_connection->next)
{
- addr = "tcp-192.168.15.2:60002";
- peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
+ con_num++;
+ num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology);
+ for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix;
+ pos_prefix =
+ pos_prefix->next)
+ {
+ addr = GNUNET_TESTING_get_address (pos_connection,
+ pos_prefix->address_prefix);
+ if (NULL != addr)
+ {
+ peer = GNUNET_TESTING_get_pub_key (num, tl_system);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating peer number %u with identity %s\n",
+ num,
+ GNUNET_i2s (peer));
+ GNUNET_TRANSPORT_application_validate ((struct
+ GNUNET_TRANSPORT_ApplicationHandle
+ *) ah,
+ peer,
+ nt,
+ addr);
+ GNUNET_free (peer);
+ GNUNET_free (addr);
+ }
+ }
}
- else
- {
- addr = "tcp-192.168.15.1:60002";
- peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
- }
-
- priv_key = GNUNET_TESTING_hostkey_get (tl_system,
- num,
- other);
-
- GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
- pub_key);
-
- GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
- strlen (peer_id),
- &peer->public_key);
-
- peer->public_key = *pub_key;
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "\nnum: %u\n peer_id: %s\n pub_key %s\n",
- num,
- peer_id,
- GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
-
- cps->id = peer;
-
- // 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.
- // ---------------------------------------------
- /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
- GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd,
- &id);
- GNUNET_TRANSPORT_get_trait_hello (peer2_cmd,
- &hello);
- GNUNET_TRANSPORT_get_trait_hello_size (peer2_cmd,
- &hello_size);
-
- addr = GNUNET_HELLO_extract_address (hello,
- *hello_size,
- id,
- &nt,
- &t);*/
-
- // ----------------------------------------------
-
-
- GNUNET_TRANSPORT_application_validate (ah,
- peer,
- nt,
- addr);
+ cps->con_num = con_num;
}
/**
- * 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.
+ * Callback from start peer cmd for signaling a peer got connected.
*
*/
-static int
-connect_peers_finish (void *cls,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
{
- struct ConnectPeersState *cps = cls;
- const struct GNUNET_TESTING_Command *peer1_cmd;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
- unsigned int ret;
- struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
- struct GNUNET_HashCode hc;
- int node_number;
-
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
-
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
-
- // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
- memcpy (key,
- &hc,
- sizeof (*key));
- ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map,
- key);
-
- if (GNUNET_YES == ret)
+ const struct GNUNET_TESTING_Command *cmd;
+ struct ConnectPeersState *cps;
+ struct GNUNET_PeerIdentity *peer_connection;
+ struct GNUNET_TESTING_NodeConnection *pos_connection;
+ unsigned int num;
+ unsigned int con_num;
+ void *ret = NULL;
+
+ cmd = GNUNET_TESTING_interpreter_lookup_command_all (is,
+ "connect-peers");
+ cps = cmd->cls;
+ con_num = cps->con_num_notified;
+ for (pos_connection = cps->node_connections_head; NULL != pos_connection;
+ pos_connection = pos_connection->next)
{
- cont (cont_cls);
+ num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology);
+ peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system);
+ if (0 == GNUNET_memcmp (peer,
+ peer_connection))
+ cps->con_num_notified++;
+ GNUNET_free (peer_connection);
}
+ if (cps->con_num == con_num)
+ cps->additional_connects_notified++;
- GNUNET_free (key);
+ if (cps->con_num + cps->additional_connects == cps->con_num_notified
+ + cps->additional_connects_notified)
+ {
+ GNUNET_TESTING_async_finish (&cps->ac);
+ }
return ret;
}
/**
- * Trait function of this cmd does nothing.
+ * The cleanup function of this cmd frees resources the cmd allocated.
*
*/
-static int
-connect_peers_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+static void
+connect_peers_cleanup (void *cls)
{
- return GNUNET_OK;
+ struct ConnectPeersState *cps = cls;
+
+ GNUNET_free (cps);
}
/**
- * The cleanup function of this cmd frees resources the cmd allocated.
+ * This function prepares an array with traits.
*
*/
-static void
-connect_peers_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+enum GNUNET_GenericReturnValue
+connect_peers_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
{
struct ConnectPeersState *cps = cls;
-
- GNUNET_free (cps->id);
- GNUNET_free (cps);
+ struct GNUNET_TESTING_Trait traits[] = {
+ GNUNET_TRANSPORT_make_trait_connect_peer_state ((const void *) cps),
+ GNUNET_TESTING_trait_end ()
+ };
+ return GNUNET_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
}
/**
- * Create command.
+ * Create command
*
- * @param label name for command.
+ * @param label name for command
* @param start_peer_label Label of the cmd to start a peer.
+ * @param create_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
+ * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
* @return command.
*/
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
const char *start_peer_label,
const char *create_label,
- uint32_t num)
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *
+ topology,
+ unsigned int additional_connects)
{
struct ConnectPeersState *cps;
@@ -266,16 +216,20 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
cps->start_peer_label = start_peer_label;
cps->num = num;
cps->create_label = create_label;
+ cps->topology = topology;
+ cps->notify_connect = notify_connect;
+ cps->additional_connects = additional_connects;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = cps,
- .label = label,
- .run = &connect_peers_run,
- .finish = &connect_peers_finish,
- .cleanup = &connect_peers_cleanup,
- .traits = &connect_peers_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = cps,
+ .label = label,
+ .run = &connect_peers_run,
+ .ac = &cps->ac,
+ .cleanup = &connect_peers_cleanup,
+ .traits = &connect_peers_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/transport/transport_api_cmd_connecting_peers_v2.c b/src/transport/transport_api_cmd_connecting_peers_v2.c
deleted file mode 100644
index 0d286b714..000000000
--- a/src/transport/transport_api_cmd_connecting_peers_v2.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing_api_cmd_start_peer.c
- * @brief cmd to start a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_transport_application_service.h"
-#include "gnunet_hello_lib.h"
-#include "gnunet_transport_service.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-#define CONNECT_ADDRESS_TEMPLATE "tcp-192.168.15.%u:60002"
-
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct ConnectPeersState
-{
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The peer identity of this peer.
- *
- */
- struct GNUNET_PeerIdentity *id;
-};
-
-
-/**
- * The run method of this cmd will connect to peers.
- *
- */
-static void
-connect_peers_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct ConnectPeersState *cps = cls;
- const struct GNUNET_TESTING_Command *system_cmd;
- struct GNUNET_TESTING_System *tl_system;
- struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
- GNUNET_CRYPTO_EddsaPrivateKey);
- struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
- GNUNET_CRYPTO_EddsaPublicKey);
- const struct GNUNET_TESTING_Command *peer1_cmd;
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
- struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
- char *addr;
- enum GNUNET_NetworkType nt = 0;
- struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
- uint32_t num;
-
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
- GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd,
- &ah);
-
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
- GNUNET_TESTING_get_trait_test_system (system_cmd,
- &tl_system);
-
- if (1 == cps->num)
- {
- num = 2;
- // addr = "tcp-192.168.15.2:60002";
- }
- else
- {
- num = 1;
- // addr = "tcp-192.168.15.1:60002";
- }
-
- GNUNET_asprintf (&addr,
- CONNECT_ADDRESS_TEMPLATE,
- num);
-
- priv_key = GNUNET_TESTING_hostkey_get (tl_system,
- num,
- other);
-
- GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
- pub_key);
-
-
- peer->public_key = *pub_key;
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "num: %u pub_key %s\n",
- num,
- GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
-
- cps->id = peer;
-
- GNUNET_TRANSPORT_application_validate (ah,
- peer,
- nt,
- addr);
-}
-
-
-/**
- * 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.
- *
- */
-static int
-connect_peers_finish (void *cls,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
-{
- struct ConnectPeersState *cps = cls;
- const struct GNUNET_TESTING_Command *peer1_cmd;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
- unsigned int ret;
- struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
- struct GNUNET_HashCode hc;
- int node_number;
-
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (peer1_cmd,
- &connected_peers_map);
-
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
-
- // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
- memcpy (key,
- &hc,
- sizeof (*key));
- ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map,
- key);
-
- if (GNUNET_YES == ret)
- {
- cont (cont_cls);
- }
-
- GNUNET_free (key);
- return ret;
-}
-
-
-/**
- * Trait function of this cmd does nothing.
- *
- */
-static int
-connect_peers_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * The cleanup function of this cmd frees resources the cmd allocated.
- *
- */
-static void
-connect_peers_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- struct ConnectPeersState *cps = cls;
-
- GNUNET_free (cps->id);
- GNUNET_free (cps);
-}
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param start_peer_label Label of the cmd to start a peer.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num)
-{
- struct ConnectPeersState *cps;
-
- cps = GNUNET_new (struct ConnectPeersState);
- cps->start_peer_label = start_peer_label;
- cps->num = num;
- cps->create_label = create_label;
-
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = cps,
- .label = label,
- .run = &connect_peers_run,
- .finish = &connect_peers_finish,
- .cleanup = &connect_peers_cleanup,
- .traits = &connect_peers_traits
- };
-
- return cmd;
-}
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index f9e515c0f..ade0cc914 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -26,111 +26,151 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "transport-testing2.h"
#include "transport-testing-cmds.h"
/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+/**
* Struct to hold information for callbacks.
*
*/
struct SendSimpleState
{
/**
- * The number of the local node of the actual network namespace.
+ * Number globally identifying the node.
*
*/
- char *m;
+ uint32_t num;
/**
- * The number of the actual namespace.
+ * Label of the cmd to start a peer.
*
*/
- char *n;
+ const char *start_peer_label;
/**
- * Number globally identifying the node.
+ * Label of the cmd which started the test system.
*
*/
- uint32_t num;
+ const char *create_label;
/**
- * Label of the cmd to start a peer.
- *
+ * The topology we get the connected nodes from.
*/
- const char *start_peer_label;
+ struct GNUNET_TESTING_NetjailTopology *topology;
};
/**
- * Trait function of this cmd does nothing.
+ * The cleanup function of this cmd frees resources the cmd allocated.
*
*/
-static int
-send_simple_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+static void
+send_simple_cleanup (void *cls)
{
- return GNUNET_OK;
+ struct SendSimpleState *sss = cls;
+
+ GNUNET_free (sss);
}
-/**
- * The cleanup function of this cmd frees resources the cmd allocated.
- *
- */
-static void
-send_simple_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+static int
+send_simple_cb (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct SendSimpleState *sss = cls;
+ struct GNUNET_MQ_Handle *mq = value;
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
- GNUNET_free (sss);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending simple test message\n");
+
+ env = GNUNET_MQ_msg_extra (test,
+ 1000 - sizeof(*test),
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
+ test->num = htonl (sss->num);
+ memset (&test[1],
+ sss->num,
+ 1000 - sizeof(*test));
+ GNUNET_MQ_send (mq,
+ env);
+ return GNUNET_OK;
}
/**
- * The run method of this cmd will send a simple message to the connected peer.
+ * The run method of this cmd will send a simple message to the connected peers.
*
*/
static void
send_simple_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct SendSimpleState *sss = cls;
- struct GNUNET_MQ_Envelope *env;
- struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
- struct GNUNET_MQ_Handle *mq;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+ const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
const struct GNUNET_TESTING_Command *peer1_cmd;
- struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
+ // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
struct GNUNET_HashCode hc;
- int node_number;
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+ struct GNUNET_PeerIdentity *peer;
+ struct GNUNET_CRYPTO_EddsaPublicKey public_key;
+ uint32_t num;
+ struct GNUNET_TESTING_NodeConnection *pos_connection;
+ const struct GNUNET_TESTING_Command *system_cmd;
+ const struct GNUNET_TESTING_System *tl_system;
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ sss->start_peer_label);
GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
&connected_peers_map);
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
- memcpy (key,
- &hc,
- sizeof (*key));
-
- mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
- key);
-
- env = GNUNET_MQ_msg_extra (test,
- 2600 - sizeof(*test),
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
- test->num = htonl (sss->num);
- memset (&test[1],
- sss->num,
- 2600 - sizeof(*test));
- GNUNET_MQ_send (mq,
- env);
- GNUNET_free (key);
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ sss->create_label);
+ GNUNET_TESTING_get_trait_test_system (system_cmd,
+ &tl_system);
+
+ node_connections_head = GNUNET_TESTING_get_connections (sss->num,
+ sss->topology);
+
+ GNUNET_CONTAINER_multishortmap_iterate (
+ (struct GNUNET_CONTAINER_MultiShortmap *)
+ connected_peers_map, send_simple_cb,
+ sss);
+ /*for (int i = 0; i < 1; i++)
+ {
+ for (pos_connection = node_connections_head; NULL != pos_connection;
+ pos_connection = pos_connection->next)
+ {
+ num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
+ peer = GNUNET_TESTING_get_pub_key (num, tl_system);
+ public_key = peer->public_key;
+ GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
+
+ memcpy (key,
+ &hc,
+ sizeof (*key));
+ mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
+ key);
+ env = GNUNET_MQ_msg_extra (test,
+ 1000 - sizeof(*test),
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
+ test->num = htonl (sss->num);
+ memset (&test[1],
+ sss->num,
+ 1000 - sizeof(*test));
+ GNUNET_MQ_send (mq,
+ env);
+ }
+ }*/
+
+ // GNUNET_free (key);
}
@@ -139,33 +179,33 @@ send_simple_run (void *cls,
* Create command.
*
* @param label name for command.
- * @param m The number of the local node of the actual network namespace.
- * @param n The number of the actual namespace.
- * @param num Number globally identifying the node.
* @param start_peer_label Label of the cmd to start a peer.
+ * @param start_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
* @return command.
*/
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_send_simple (const char *label,
- char *m,
- char *n,
+ const char *start_peer_label,
+ const char *create_label,
uint32_t num,
- const char *start_peer_label)
+ struct GNUNET_TESTING_NetjailTopology *
+ topology)
{
struct SendSimpleState *sss;
sss = GNUNET_new (struct SendSimpleState);
- sss->m = m;
- sss->n = n;
sss->num = num;
sss->start_peer_label = start_peer_label;
+ sss->create_label = create_label;
+ sss->topology = topology;
struct GNUNET_TESTING_Command cmd = {
.cls = sss,
.label = label,
.run = &send_simple_run,
- .cleanup = &send_simple_cleanup,
- .traits = &send_simple_traits
+ .cleanup = &send_simple_cleanup
};
return cmd;
diff --git a/src/transport/transport_api_cmd_send_simple_v2.c b/src/transport/transport_api_cmd_send_simple_v2.c
deleted file mode 100644
index d43c0b425..000000000
--- a/src/transport/transport_api_cmd_send_simple_v2.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing_api_cmd_start_peer.c
- * @brief cmd to start a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "transport-testing2.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Struct to hold information for callbacks.
- *
- */
-struct SendSimpleState
-{
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-};
-
-
-/**
- * Trait function of this cmd does nothing.
- *
- */
-static int
-send_simple_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * The cleanup function of this cmd frees resources the cmd allocated.
- *
- */
-static void
-send_simple_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- struct SendSimpleState *sss = cls;
-
- GNUNET_free (sss);
-}
-
-
-/**
- * The run method of this cmd will send a simple message to the connected peer.
- *
- */
-static void
-send_simple_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct SendSimpleState *sss = cls;
- struct GNUNET_MQ_Envelope *env;
- struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
- struct GNUNET_MQ_Handle *mq;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
- const struct GNUNET_TESTING_Command *peer1_cmd;
- struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
- struct GNUNET_HashCode hc;
- int node_number;
-
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
-
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
- memcpy (key,
- &hc,
- sizeof (*key));
-
- mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
- key);
-
- env = GNUNET_MQ_msg_extra (test,
- 2600 - sizeof(*test),
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
- test->num = htonl (sss->num);
- memset (&test[1],
- sss->num,
- 2600 - sizeof(*test));
- GNUNET_MQ_send (mq,
- env);
- GNUNET_free (key);
-
-}
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param m The number of the local node of the actual network namespace.
- * @param n The number of the actual namespace.
- * @param num Number globally identifying the node.
- * @param start_peer_label Label of the cmd to start a peer.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label,
- const char *start_peer_label,
- uint32_t num)
-{
- struct SendSimpleState *sss;
-
- sss = GNUNET_new (struct SendSimpleState);
- sss->num = num;
- sss->start_peer_label = start_peer_label;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = sss,
- .label = label,
- .run = &send_simple_run,
- .cleanup = &send_simple_cleanup,
- .traits = &send_simple_traits
- };
-
- return cmd;
-}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index f4e92944b..be2ea25b4 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_core_service.h"
#include "gnunet_transport_application_service.h"
@@ -65,7 +66,7 @@ hello_iter_cb (void *cb_cls,
GNUNET_PEERSTORE_iterate_cancel (sps->pic);
sps->pic = NULL;
- sps->finished = GNUNET_YES;
+ GNUNET_TESTING_async_finish (&sps->ac);
}
@@ -90,26 +91,6 @@ retrieve_hello (void *cls)
/**
- * This function checks StartPeerState#finished, which is set when the hello was retrieved.
- *
- */
-static int
-start_peer_finish (void *cls,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
-{
- struct StartPeerState *sps = cls;
-
- if (GNUNET_YES == sps->finished)
- {
- cont (cont_cls);
- }
-
- return sps->finished;
-}
-
-
-/**
* Disconnect callback for the connection to the core service.
*
*/
@@ -141,20 +122,19 @@ notify_connect (void *cls,
struct StartPeerState *sps = cls;
struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
struct GNUNET_HashCode hc;
- int node_number;
+ struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
void *ret = NULL;
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %s connected to peer %u (`%s')\n",
- GNUNET_i2s (peer),
- sps->no,
+ "This Peer %s \n",
GNUNET_i2s (&sps->id));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %s connected to peer number %u\n",
+ GNUNET_i2s (peer),
+ sps->no);
- // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
+ GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
memcpy (key,
@@ -166,6 +146,10 @@ notify_connect (void *cls,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_free (key);
+
+ sps->notify_connect (sps->ac.is,
+ peer);
+
// TODO what does the handler function need?
return ret;
}
@@ -177,25 +161,26 @@ notify_connect (void *cls,
*/
static void
start_peer_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct StartPeerState *sps = cls;
char *emsg = NULL;
struct GNUNET_PeerIdentity dummy;
const struct GNUNET_TESTING_Command *system_cmd;
- struct GNUNET_TESTING_System *tl_system;
+ const struct GNUNET_TESTING_System *tl_system;
char *home;
char *transport_unix_path;
- char *communicator_unix_path;
+ char *tcp_communicator_unix_path;
+ char *udp_communicator_unix_path;
char *bindto;
+ char *bindto_udp;
if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"File not found: `%s'\n",
sps->cfgname);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -212,7 +197,11 @@ start_peer_run (void *cls,
"$GNUNET_RUNTIME_DIR/tng-p%u.sock",
sps->no);
- GNUNET_asprintf (&communicator_unix_path,
+ GNUNET_asprintf (&tcp_communicator_unix_path,
+ "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
+ sps->no);
+
+ GNUNET_asprintf (&udp_communicator_unix_path,
"$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
sps->no);
@@ -220,6 +209,17 @@ start_peer_run (void *cls,
"%s:60002",
sps->node_ip);
+ GNUNET_asprintf (&bindto_udp,
+ "2086");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "node_ip %s\n",
+ bindto);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "bind_udp %s\n",
+ GNUNET_YES == sps->broadcast ?
+ bindto_udp : bindto);
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
home);
@@ -228,29 +228,44 @@ start_peer_run (void *cls,
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
"BINDTO",
bindto);
+ GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
+ "BINDTO",
+ GNUNET_YES == sps->broadcast ?
+ bindto_udp : bindto);
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
"UNIXPATH",
- communicator_unix_path);
+ tcp_communicator_unix_path);
+ GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
+ "UNIXPATH",
+ udp_communicator_unix_path);
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label);
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ sps->system_label);
GNUNET_TESTING_get_trait_test_system (system_cmd,
&tl_system);
sps->tl_system = tl_system;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Creating testing library with key number %u\n",
+ sps->no);
+
if (GNUNET_SYSERR ==
- GNUNET_TESTING_configuration_create (tl_system,
+ GNUNET_TESTING_configuration_create ((struct
+ GNUNET_TESTING_System *) tl_system,
sps->cfg))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Testing library failed to create unique configuration based on `%s'\n",
sps->cfgname);
GNUNET_CONFIGURATION_destroy (sps->cfg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
- sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system,
+ sps->peer = GNUNET_TESTING_peer_configure ((struct
+ GNUNET_TESTING_System *) sps->
+ tl_system,
sps->cfg,
sps->no,
NULL,
@@ -258,11 +273,12 @@ start_peer_run (void *cls,
if (NULL == sps->peer)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on `%s': `%s'\n",
+ "Testing library failed to create unique configuration based on `%s': `%s' with key number %u\n",
sps->cfgname,
- emsg);
+ emsg,
+ sps->no);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -272,7 +288,7 @@ start_peer_run (void *cls,
"Testing library failed to create unique configuration based on `%s'\n",
sps->cfgname);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -291,7 +307,7 @@ start_peer_run (void *cls,
"Testing library failed to obtain peer identity for peer %u\n",
sps->no);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -312,7 +328,7 @@ start_peer_run (void *cls,
sps->cfgname,
emsg);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -324,7 +340,7 @@ start_peer_run (void *cls,
sps->cfgname,
emsg);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -336,10 +352,16 @@ start_peer_run (void *cls,
sps->cfgname,
emsg);
GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
+ GNUNET_free (home);
+ GNUNET_free (transport_unix_path);
+ GNUNET_free (tcp_communicator_unix_path);
+ GNUNET_free (udp_communicator_unix_path);
+ GNUNET_free (bindto);
+ GNUNET_free (bindto_udp);
}
@@ -348,8 +370,7 @@ start_peer_run (void *cls,
*
*/
static void
-start_peer_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+start_peer_cleanup (void *cls)
{
struct StartPeerState *sps = cls;
@@ -389,36 +410,14 @@ start_peer_traits (void *cls,
struct GNUNET_TESTING_Trait traits[] = {
- {
- .index = 0,
- .trait_name = "application_handle",
- .ptr = (const void *) ah,
- },
- {
- .index = 1,
- .trait_name = "peer_id",
- .ptr = (const void *) id,
- },
- {
- .index = 2,
- .trait_name = "connected_peers_map",
- .ptr = (const void *) connected_peers_map,
- },
- {
- .index = 3,
- .trait_name = "hello",
- .ptr = (const void *) hello,
- },
- {
- .index = 4,
- .trait_name = "hello_size",
- .ptr = (const void *) hello_size,
- },
- {
- .index = 5,
- .trait_name = "state",
- .ptr = (const void *) sps,
- },
+ GNUNET_TRANSPORT_make_trait_application_handle ((const void *) ah),
+ GNUNET_TRANSPORT_make_trait_peer_id ((const void *) id),
+ GNUNET_TRANSPORT_make_trait_connected_peers_map ((const
+ void *)
+ connected_peers_map),
+ GNUNET_TRANSPORT_make_trait_hello ((const void *) hello),
+ GNUNET_TRANSPORT_make_trait_hello_size ((const void *) hello_size),
+ GNUNET_TRANSPORT_make_trait_state ((const void *) sps),
GNUNET_TESTING_trait_end ()
};
@@ -430,127 +429,6 @@ start_peer_traits (void *cls,
/**
- * Function to get the trait with the struct StartPeerState.
- *
- * @param[out] sps struct StartPeerState.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_state (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct StartPeerState **sps)
-{
- return cmd->traits (cmd->cls,
- (const void **) sps,
- "state",
- (unsigned int) 5);
-}
-
-
-/**
- * Function to get the trait with the size of the hello.
- *
- * @param[out] hello_size size of hello.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_hello_size (const struct
- GNUNET_TESTING_Command
- *cmd,
- size_t **hello_size)
-{
- return cmd->traits (cmd->cls,
- (const void **) hello_size,
- "hello_size",
- (unsigned int) 4);
-}
-
-
-/**
- * Function to get the trait with the hello.
- *
- * @param[out] hello The hello for the peer.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_hello (const struct
- GNUNET_TESTING_Command
- *cmd,
- char **hello)
-{
- return cmd->traits (cmd->cls,
- (const void **) hello,
- "hello",
- (unsigned int) 3);
-}
-
-
-/**
- * Function to get the trait with the map of connected peers.
- *
- * @param[out] connected_peers_map The map with connected peers.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiShortmap *
- *
- connected_peers_map)
-{
- return cmd->traits (cmd->cls,
- (const void **) connected_peers_map,
- "connected_peers_map",
- (unsigned int) 2);
-}
-
-
-/**
- * Function to get the trait with the transport application handle.
- *
- * @param[out] ah The application handle.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- */
-int
-GNUNET_TRANSPORT_get_trait_application_handle (const struct
- GNUNET_TESTING_Command *cmd,
- struct
- GNUNET_TRANSPORT_ApplicationHandle
- **ah)
-{
- return cmd->traits (cmd->cls,
- (const void **) ah,
- "application_handle",
- (unsigned int) 0);
-}
-
-
-/**
- * Function to get the trait with the peer id.
- *
- * @param[out] id The peer id.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- */
-int
-GNUNET_TRANSPORT_get_trait_peer_id (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_PeerIdentity **id)
-{
- return cmd->traits (cmd->cls,
- (const void **) id,
- "peer_id",
- (unsigned int) 1);
-}
-
-
-/**
* Create command.
*
* @param label name for command.
@@ -560,17 +438,20 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct
* @param local_m Number of local nodes in each namespace.
* @param handlers Handler for messages received by this peer.
* @param cfgname Configuration file name for this peer.
+ * @param notify_connect Method which will be called, when a peer connects.
+ * @param broadcast Flag indicating, if broadcast should be switched on.
* @return command.
*/
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_start_peer (const char *label,
const char *system_label,
- char *m,
- char *n,
- char *local_m,
+ uint32_t no,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
- const char *cfgname)
+ const char *cfgname,
+ GNUNET_TRANSPORT_notify_connect_cb
+ notify_connect,
+ unsigned int broadcast)
{
struct StartPeerState *sps;
struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -578,14 +459,13 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
unsigned int i;
sps = GNUNET_new (struct StartPeerState);
- sps->m = m;
- sps->n = n;
- sps->local_m = local_m;
- sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m);
+ sps->no = no;
sps->system_label = system_label;
sps->connected_peers_map = connected_peers_map;
sps->cfgname = cfgname;
sps->node_ip = node_ip;
+ sps->notify_connect = notify_connect;
+ sps->broadcast = broadcast;
if (NULL != handlers)
{
@@ -602,7 +482,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
.cls = sps,
.label = label,
.run = &start_peer_run,
- .finish = &start_peer_finish,
+ .ac = &sps->ac,
.cleanup = &start_peer_cleanup,
.traits = &start_peer_traits
};
diff --git a/src/transport/transport_api_cmd_start_peer_v2.c b/src/transport/transport_api_cmd_start_peer_v2.c
deleted file mode 100644
index 0e39bd915..000000000
--- a/src/transport/transport_api_cmd_start_peer_v2.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing_api_cmd_start_peer.c
- * @brief cmd to start a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_peerstore_service.h"
-#include "gnunet_transport_core_service.h"
-#include "gnunet_transport_application_service.h"
-#include "transport-testing-cmds.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-
-static void
-retrieve_hello (void *cls);
-
-
-/**
- * Callback delivering the hello of this peer from peerstore.
- *
- */
-static void
-hello_iter_cb (void *cb_cls,
- const struct GNUNET_PEERSTORE_Record *record,
- const char *emsg)
-{
- struct StartPeerState_v2 *sps = cb_cls;
- if (NULL == record)
- {
- sps->pic = NULL;
- sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
- return;
- }
- // Check record type et al?
- sps->hello_size = record->value_size;
- sps->hello = GNUNET_malloc (sps->hello_size);
- memcpy (sps->hello, record->value, sps->hello_size);
- sps->hello[sps->hello_size - 1] = '\0';
-
- GNUNET_PEERSTORE_iterate_cancel (sps->pic);
- sps->pic = NULL;
- sps->finished = GNUNET_YES;
-}
-
-
-/**
- * Function to start the retrieval task to retrieve the hello of this peer
- * from the peerstore.
- *
- */
-static void
-retrieve_hello (void *cls)
-{
- struct StartPeerState_v2 *sps = cls;
- sps->rh_task = NULL;
- sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
- "transport",
- &sps->id,
- GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
- hello_iter_cb,
- sps);
-
-}
-
-
-/**
- * This function checks StartPeerState_v2#finished, which is set when the hello was retrieved.
- *
- */
-static int
-start_peer_finish (void *cls,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
-{
- struct StartPeerState_v2 *sps = cls;
-
- if (GNUNET_YES == sps->finished)
- {
- cont (cont_cls);
- }
-
- return sps->finished;
-}
-
-
-/**
- * Disconnect callback for the connection to the core service.
- *
- */
-static void
-notify_disconnect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- void *handler_cls)
-{
- struct StartPeerState_v2 *sps = cls;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %s disconnected from peer %u (`%s')\n",
- GNUNET_i2s (peer),
- sps->no,
- GNUNET_i2s (&sps->id));
-
-}
-
-
-/**
- * Connect callback for the connection to the core service.
- *
- */
-static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
-{
- struct StartPeerState_v2 *sps = cls;
- struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
- struct GNUNET_HashCode hc;
- int node_number;
-
- void *ret = NULL;
-
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %s connected to peer %u (`%s')\n",
- GNUNET_i2s (peer),
- sps->no,
- GNUNET_i2s (&sps->id));
-
- // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
- node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
-
-
- memcpy (key,
- &hc,
- sizeof (*key));
- GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map,
- key,
- mq,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-
- GNUNET_free (key);
- // TODO what does the handler function need?
- return ret;
-}
-
-
-/**
- * The run method of this cmd will start all services of a peer to test the transport service.
- *
- */
-static void
-start_peer_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct StartPeerState_v2 *sps = cls;
- char *emsg = NULL;
- struct GNUNET_PeerIdentity dummy;
- const struct GNUNET_TESTING_Command *system_cmd;
- struct GNUNET_TESTING_System *tl_system;
- char *home;
- char *transport_unix_path;
- char *communicator_unix_path;
- char *bindto;
-
- if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "File not found: `%s'\n",
- sps->cfgname);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
-
- sps->cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
-
- GNUNET_asprintf (&home,
- "$GNUNET_TMP/test-transport/api-tcp-p%u",
- sps->no);
-
- GNUNET_asprintf (&transport_unix_path,
- "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
- sps->no);
-
- GNUNET_asprintf (&communicator_unix_path,
- "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
- sps->no);
-
- GNUNET_asprintf (&bindto,
- "%s:60002",
- sps->node_ip);
-
-
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
- home);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
- transport_unix_path);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
- "BINDTO",
- bindto);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
- "UNIXPATH",
- communicator_unix_path);
-
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label);
- GNUNET_TESTING_get_trait_test_system (system_cmd,
- &tl_system);
-
- sps->tl_system = tl_system;
-
- if (GNUNET_SYSERR ==
- GNUNET_TESTING_configuration_create (tl_system,
- sps->cfg))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on `%s'\n",
- sps->cfgname);
- GNUNET_CONFIGURATION_destroy (sps->cfg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
- sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system,
- sps->cfg,
- sps->no,
- NULL,
- &emsg);
- if (NULL == sps->peer)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on `%s': `%s'\n",
- sps->cfgname,
- emsg);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
- if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on `%s'\n",
- sps->cfgname);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
- memset (&dummy,
- '\0',
- sizeof(dummy));
-
- GNUNET_TESTING_peer_get_identity (sps->peer,
- &sps->id);
-
- if (0 == memcmp (&dummy,
- &sps->id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to obtain peer identity for peer %u\n",
- sps->no);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u configured with identity `%s'\n",
- sps->no,
- GNUNET_i2s_full (&sps->id));
-
- sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg,
- NULL,
- sps->handlers,
- sps,
- &notify_connect,
- &notify_disconnect);
- if (NULL == sps->th)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to transport service for peer `%s': `%s'\n",
- sps->cfgname,
- emsg);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
- sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
- if (NULL == sps->th)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to peerstore service for peer `%s': `%s'\n",
- sps->cfgname,
- emsg);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
-
- sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
- if (NULL == sps->ah)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n",
- sps->cfgname,
- emsg);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail ();
- return;
- }
- sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
-}
-
-
-/**
- * The cleanup function of this cmd frees resources the cmd allocated.
- *
- */
-static void
-start_peer_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- struct StartPeerState_v2 *sps = cls;
-
- if (NULL != sps->handlers)
- {
- GNUNET_free (sps->handlers);
- sps->handlers = NULL;
- }
- if (NULL != sps->cfg)
- {
- GNUNET_CONFIGURATION_destroy (sps->cfg);
- sps->cfg = NULL;
- }
- GNUNET_free (sps->hello);
- GNUNET_free (sps->connected_peers_map);
- GNUNET_free (sps);
-}
-
-
-/**
- * This function prepares an array with traits.
- *
- */
-static int
-start_peer_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- struct StartPeerState_v2 *sps = cls;
- struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
- struct GNUNET_PeerIdentity *id = &sps->id;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
- sps->connected_peers_map;
- char *hello = sps->hello;
- size_t hello_size = sps->hello_size;
-
-
- struct GNUNET_TESTING_Trait traits[] = {
- {
- .index = 0,
- .trait_name = "application_handle",
- .ptr = (const void *) ah,
- },
- {
- .index = 1,
- .trait_name = "peer_id",
- .ptr = (const void *) id,
- },
- {
- .index = 2,
- .trait_name = "connected_peers_map",
- .ptr = (const void *) connected_peers_map,
- },
- {
- .index = 3,
- .trait_name = "hello",
- .ptr = (const void *) hello,
- },
- {
- .index = 4,
- .trait_name = "hello_size",
- .ptr = (const void *) hello_size,
- },
- {
- .index = 5,
- .trait_name = "state",
- .ptr = (const void *) sps,
- },
- GNUNET_TESTING_trait_end ()
- };
-
- return GNUNET_TESTING_get_trait (traits,
- ret,
- trait,
- index);
-}
-
-
-/**
- * Function to get the trait with the struct StartPeerState_v2.
- *
- * @param[out] sps struct StartPeerState_v2.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_state_v2 (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct StartPeerState_v2 **sps)
-{
- return cmd->traits (cmd->cls,
- (const void **) sps,
- "state",
- (unsigned int) 5);
-}
-
-
-/**
- * Function to get the trait with the size of the hello.
- *
- * @param[out] hello_size size of hello.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_hello_size_v2 (const struct
- GNUNET_TESTING_Command
- *cmd,
- size_t **hello_size)
-{
- return cmd->traits (cmd->cls,
- (const void **) hello_size,
- "hello_size",
- (unsigned int) 4);
-}
-
-
-/**
- * Function to get the trait with the hello.
- *
- * @param[out] hello The hello for the peer.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_hello_v2 (const struct
- GNUNET_TESTING_Command
- *cmd,
- char **hello)
-{
- return cmd->traits (cmd->cls,
- (const void **) hello,
- "hello",
- (unsigned int) 3);
-}
-
-
-/**
- * Function to get the trait with the map of connected peers.
- *
- * @param[out] connected_peers_map The map with connected peers.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-int
-GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiShortmap
- *
- *
- connected_peers_map)
-{
- return cmd->traits (cmd->cls,
- (const void **) connected_peers_map,
- "connected_peers_map",
- (unsigned int) 2);
-}
-
-
-/**
- * Function to get the trait with the transport application handle.
- *
- * @param[out] ah The application handle.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- */
-int
-GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct
- GNUNET_TESTING_Command *cmd,
- struct
- GNUNET_TRANSPORT_ApplicationHandle
- **ah)
-{
- return cmd->traits (cmd->cls,
- (const void **) ah,
- "application_handle",
- (unsigned int) 0);
-}
-
-
-/**
- * Function to get the trait with the peer id.
- *
- * @param[out] id The peer id.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- */
-int
-GNUNET_TRANSPORT_get_trait_peer_id_v2 (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_PeerIdentity **id)
-{
- return cmd->traits (cmd->cls,
- (const void **) id,
- "peer_id",
- (unsigned int) 1);
-}
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param system_label Label of the cmd to setup a test environment.
- * @param m The number of the local node of the actual network namespace.
- * @param n The number of the actual namespace.
- * @param local_m Number of local nodes in each namespace.
- * @param handlers Handler for messages received by this peer.
- * @param cfgname Configuration file name for this peer.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label,
- const char *system_label,
- uint32_t no,
- char *node_ip,
- struct GNUNET_MQ_MessageHandler *handlers,
- const char *cfgname)
-{
- struct StartPeerState_v2 *sps;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
- GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
- unsigned int i;
-
- sps = GNUNET_new (struct StartPeerState_v2);
- sps->no = no;
- sps->system_label = system_label;
- sps->connected_peers_map = connected_peers_map;
- sps->cfgname = cfgname;
- sps->node_ip = node_ip;
-
- if (NULL != handlers)
- {
- for (i = 0; NULL != handlers[i].cb; i++)
- ;
- sps->handlers = GNUNET_new_array (i + 1,
- struct GNUNET_MQ_MessageHandler);
- GNUNET_memcpy (sps->handlers,
- handlers,
- i * sizeof(struct GNUNET_MQ_MessageHandler));
- }
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = sps,
- .label = label,
- .run = &start_peer_run,
- .finish = &start_peer_finish,
- .cleanup = &start_peer_cleanup,
- .traits = &start_peer_traits
- };
-
- return cmd;
-}
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index 4d7228378..4ca730add 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_core_service.h"
#include "gnunet_transport_application_service.h"
@@ -54,38 +55,34 @@ struct StopPeerState
*/
static void
stop_peer_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct StopPeerState *stop_ps = cls;
- struct StartPeerState *sps;
+ const struct StartPeerState *sps;
const struct GNUNET_TESTING_Command *start_cmd;
- start_cmd = GNUNET_TESTING_interpreter_lookup_command (stop_ps->start_label);
+ start_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ stop_ps->start_label);
GNUNET_TRANSPORT_get_trait_state (start_cmd,
&sps);
if (NULL != sps->pic)
{
GNUNET_PEERSTORE_iterate_cancel (sps->pic);
- sps->pic = NULL;
}
if (NULL != sps->th)
{
GNUNET_TRANSPORT_core_disconnect (sps->th);
- sps->th = NULL;
}
if (NULL != sps->ah)
{
GNUNET_TRANSPORT_application_done (sps->ah);
- sps->ah = NULL;
}
if (NULL != sps->ph)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting from PEERSTORE service\n");
GNUNET_PEERSTORE_disconnect (sps->ph, GNUNET_NO);
- sps->ph = NULL;
}
if (NULL != sps->peer)
{
@@ -98,12 +95,9 @@ stop_peer_run (void *cls,
GNUNET_i2s (&sps->id));
}
GNUNET_TESTING_peer_destroy (sps->peer);
- sps->peer = NULL;
}
if (NULL != sps->rh_task)
GNUNET_SCHEDULER_cancel (sps->rh_task);
- sps->rh_task = NULL;
-
}
@@ -112,8 +106,7 @@ stop_peer_run (void *cls,
*
*/
static void
-stop_peer_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+stop_peer_cleanup (void *cls)
{
struct StopPeerState *sps = cls;
@@ -150,14 +143,14 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
sps = GNUNET_new (struct StopPeerState);
sps->start_label = start_label;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = sps,
- .label = label,
- .run = &stop_peer_run,
- .cleanup = &stop_peer_cleanup,
- .traits = &stop_peer_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = sps,
+ .label = label,
+ .run = &stop_peer_run,
+ .cleanup = &stop_peer_cleanup,
+ .traits = &stop_peer_traits
+ };
+ return cmd;
+ }
}
diff --git a/src/transport/transport_api_traits.c b/src/transport/transport_api_traits.c
new file mode 100644
index 000000000..7e66cc3d1
--- /dev/null
+++ b/src/transport/transport_api_traits.c
@@ -0,0 +1,32 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file transport/test_transport_start_with_config.c
+ * @brief Generic program to start testcases in an configurable topology.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "transport-testing-cmds.h"
+#include "gnunet_util_lib.h"
+
+GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT)