summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testing/testing.c10
-rw-r--r--src/transport/Makefile.am18
-rw-r--r--src/transport/gnunet-communicator-udp.c7
-rw-r--r--src/transport/gnunet-service-tng.c4
-rw-r--r--src/transport/test_transport_api2_tcp_node1.conf2
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c3
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_broadcast.c367
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c3
-rwxr-xr-xsrc/transport/test_transport_simple_send_broadcast.sh7
-rw-r--r--src/transport/test_transport_simple_send_broadcast_topo.conf4
-rw-r--r--src/transport/transport-testing-cmds.h21
-rw-r--r--src/transport/transport_api2_core.c5
-rw-r--r--src/transport/transport_api_cmd_send_simple.c44
-rw-r--r--src/transport/transport_api_cmd_start_peer.c23
14 files changed, 495 insertions, 23 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 4ccf93c6b..ced04e65d 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -2122,13 +2122,14 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
sizeof (*hkey));
node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
hkey);
- node_connections = node->node_connections_head;
+ if (NULL != node)
+ node_connections = node->node_connections_head;
}
else
{
namespace_n = (unsigned int) ceil ((double) (num - topology->nodes_x)
/ topology->nodes_m);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n",
num,
topology->nodes_x,
@@ -2141,6 +2142,8 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
sizeof (*hkey));
namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
hkey);
+ if (NULL == namespace)
+ return NULL;
node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1);
hkey = GNUNET_new (struct GNUNET_ShortHashCode);
GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc);
@@ -2149,7 +2152,8 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
sizeof (*hkey));
node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
hkey);
- node_connections = node->node_connections_head;
+ if (NULL != node)
+ node_connections = node->node_connections_head;
}
GNUNET_free (hkey);
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 5fe8229e7..f17be359e 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -390,6 +390,7 @@ plugin_LTLIBRARIES = \
$(WLAN_PLUGIN_LA) \
$(BT_PLUGIN_LA) \
libgnunet_test_transport_plugin_cmd_simple_send.la \
+ libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \
libgnunet_test_transport_plugin_cmd_udp_backchannel.la
libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \
@@ -426,6 +427,23 @@ 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_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)
+
if HAVE_EXPERIMENTAL
plugin_LTLIBRARIES += \
libgnunet_plugin_transport_udp.la
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index b7a3b4082..201e94e80 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -2354,6 +2354,13 @@ sock_read (void *cls)
uhs.purpose.size = htonl (sizeof(uhs));
uhs.sender = ub->sender;
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));
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 84199a75f..cda888dd5 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5574,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++)
{
diff --git a/src/transport/test_transport_api2_tcp_node1.conf b/src/transport/test_transport_api2_tcp_node1.conf
index 11306fd6a..807a9360a 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]
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 2c987e601..6829daf84 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -293,7 +293,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
node_ip,
handlers,
ts->cfgname,
- notify_connect),
+ notify_connect,
+ GNUNET_NO),
GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
write_message),
block_send,
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..986fe6014
--- /dev/null
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -0,0 +1,367 @@
+/*
+ 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)
+{
+ 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 (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 ()
+{
+ 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 (ac);
+ else
+ GNUNET_TESTING_async_finish (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 (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_MQ_Handle *mq)
+{
+ struct GNUNET_TESTING_AsyncContext *ac;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "notify_connect\n");
+
+ GNUNET_TESTING_get_trait_async_context (&connect_peers,
+ &ac);
+ void *ret = NULL;
+
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail (ac);
+ else
+ GNUNET_TESTING_async_finish (ac);
+
+ 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 ()
+{
+ 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 (&lfs->ac);
+ else
+ GNUNET_TESTING_async_finish (&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_ERROR,
+ "plugin cfgname: %s\n",
+ ts->cfgname);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "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_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index db320844f..11cd177c4 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -282,7 +282,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
node_ip,
handlers,
ts->cfgname,
- notify_connect),
+ notify_connect,
+ GNUNET_NO),
GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
write_message),
block_send,
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..6e455f0d5
--- /dev/null
+++ b/src/transport/test_transport_simple_send_broadcast.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ "$(sysctl -n 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_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/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index 10729990d..5d0b902f6 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -165,6 +165,10 @@ struct StartPeerState
GNUNET_TRANSPORT_NotifyConnect notify_connect;
+ /**
+ * Flag indicating, if udp broadcast should be switched on.
+ */
+ unsigned int broadcast;
};
@@ -188,6 +192,20 @@ GNUNET_TRANSPORT_get_trait_state (const struct
struct StartPeerState **sps);
+/**
+ * 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,
@@ -195,7 +213,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
const char *cfgname,
- GNUNET_TRANSPORT_NotifyConnect notify_connect);
+ GNUNET_TRANSPORT_NotifyConnect notify_connect,
+ unsigned int broadcast);
struct GNUNET_TESTING_Command
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_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 790139cce..8b37dbf90 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -31,6 +31,11 @@
#include "transport-testing-cmds.h"
/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+/**
* Struct to hold information for callbacks.
*
*/
@@ -74,6 +79,32 @@ send_simple_cleanup (void *cls)
}
+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;
+
+ 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 peers.
*
@@ -83,12 +114,9 @@ send_simple_run (void *cls,
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_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
struct GNUNET_HashCode hc;
struct GNUNET_TESTING_NodeConnection *node_connections_head;
struct GNUNET_PeerIdentity *peer;
@@ -111,7 +139,9 @@ send_simple_run (void *cls,
node_connections_head = GNUNET_TESTING_get_connections (sss->num,
sss->topology);
- for (int i = 0; i < 1; i++)
+ GNUNET_CONTAINER_multishortmap_iterate (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)
@@ -136,9 +166,9 @@ send_simple_run (void *cls,
GNUNET_MQ_send (mq,
env);
}
- }
+ }*/
- GNUNET_free (key);
+ // GNUNET_free (key);
}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 60f416f85..da833f1b1 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -126,12 +126,13 @@ notify_connect (void *cls,
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);
GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
@@ -216,6 +217,11 @@ start_peer_run (void *cls,
"node_ip %s\n",
bindto);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "bind_udp %s\n",
+ GNUNET_YES == sps->broadcast ?
+ bindto_udp : bindto);
+
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
home);
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
@@ -225,7 +231,8 @@ start_peer_run (void *cls,
bindto);
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
"BINDTO",
- bindto);
+ GNUNET_YES == sps->broadcast ?
+ bindto_udp : bindto);
GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
"UNIXPATH",
tcp_communicator_unix_path);
@@ -571,6 +578,8 @@ 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
@@ -580,7 +589,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
const char *cfgname,
- GNUNET_TRANSPORT_NotifyConnect notify_connect)
+ GNUNET_TRANSPORT_NotifyConnect notify_connect,
+ unsigned int broadcast)
{
struct StartPeerState *sps;
struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -594,6 +604,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
sps->cfgname = cfgname;
sps->node_ip = node_ip;
sps->notify_connect = notify_connect;
+ sps->broadcast = broadcast;
if (NULL != handlers)
{