diff options
-rw-r--r-- | src/testing/testing.c | 10 | ||||
-rw-r--r-- | src/transport/Makefile.am | 18 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 7 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 4 | ||||
-rw-r--r-- | src/transport/test_transport_api2_tcp_node1.conf | 2 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send.c | 3 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | 367 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_udp_backchannel.c | 3 | ||||
-rwxr-xr-x | src/transport/test_transport_simple_send_broadcast.sh | 7 | ||||
-rw-r--r-- | src/transport/test_transport_simple_send_broadcast_topo.conf | 4 | ||||
-rw-r--r-- | src/transport/transport-testing-cmds.h | 21 | ||||
-rw-r--r-- | src/transport/transport_api2_core.c | 5 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_send_simple.c | 44 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer.c | 23 |
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 | |||
2122 | sizeof (*hkey)); | 2122 | sizeof (*hkey)); |
2123 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | 2123 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, |
2124 | hkey); | 2124 | hkey); |
2125 | node_connections = node->node_connections_head; | 2125 | if (NULL != node) |
2126 | node_connections = node->node_connections_head; | ||
2126 | } | 2127 | } |
2127 | else | 2128 | else |
2128 | { | 2129 | { |
2129 | namespace_n = (unsigned int) ceil ((double) (num - topology->nodes_x) | 2130 | namespace_n = (unsigned int) ceil ((double) (num - topology->nodes_x) |
2130 | / topology->nodes_m); | 2131 | / topology->nodes_m); |
2131 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2132 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2132 | "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", | 2133 | "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", |
2133 | num, | 2134 | num, |
2134 | topology->nodes_x, | 2135 | topology->nodes_x, |
@@ -2141,6 +2142,8 @@ GNUNET_TESTING_get_connections (unsigned int num, struct | |||
2141 | sizeof (*hkey)); | 2142 | sizeof (*hkey)); |
2142 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | 2143 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, |
2143 | hkey); | 2144 | hkey); |
2145 | if (NULL == namespace) | ||
2146 | return NULL; | ||
2144 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); | 2147 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); |
2145 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2148 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
2146 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); | 2149 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); |
@@ -2149,7 +2152,8 @@ GNUNET_TESTING_get_connections (unsigned int num, struct | |||
2149 | sizeof (*hkey)); | 2152 | sizeof (*hkey)); |
2150 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | 2153 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, |
2151 | hkey); | 2154 | hkey); |
2152 | node_connections = node->node_connections_head; | 2155 | if (NULL != node) |
2156 | node_connections = node->node_connections_head; | ||
2153 | } | 2157 | } |
2154 | 2158 | ||
2155 | GNUNET_free (hkey); | 2159 | 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 = \ | |||
390 | $(WLAN_PLUGIN_LA) \ | 390 | $(WLAN_PLUGIN_LA) \ |
391 | $(BT_PLUGIN_LA) \ | 391 | $(BT_PLUGIN_LA) \ |
392 | libgnunet_test_transport_plugin_cmd_simple_send.la \ | 392 | libgnunet_test_transport_plugin_cmd_simple_send.la \ |
393 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \ | ||
393 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la | 394 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la |
394 | 395 | ||
395 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ | 396 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ |
@@ -426,6 +427,23 @@ libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ | |||
426 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ | 427 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ |
427 | $(GN_PLUGIN_LDFLAGS) | 428 | $(GN_PLUGIN_LDFLAGS) |
428 | 429 | ||
430 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_SOURCES = \ | ||
431 | test_transport_plugin_cmd_simple_send_broadcast.c | ||
432 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_LIBADD = \ | ||
433 | libgnunettransporttesting2.la \ | ||
434 | libgnunettransportapplication.la \ | ||
435 | libgnunettransportcore.la \ | ||
436 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
437 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
438 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
439 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
440 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
441 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
442 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
443 | $(LTLIBINTL) | ||
444 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast_la_LDFLAGS = \ | ||
445 | $(GN_PLUGIN_LDFLAGS) | ||
446 | |||
429 | if HAVE_EXPERIMENTAL | 447 | if HAVE_EXPERIMENTAL |
430 | plugin_LTLIBRARIES += \ | 448 | plugin_LTLIBRARIES += \ |
431 | libgnunet_plugin_transport_udp.la | 449 | 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) | |||
2354 | uhs.purpose.size = htonl (sizeof(uhs)); | 2354 | uhs.purpose.size = htonl (sizeof(uhs)); |
2355 | uhs.sender = ub->sender; | 2355 | uhs.sender = ub->sender; |
2356 | sender = ub->sender; | 2356 | sender = ub->sender; |
2357 | if (0 == memcmp (&sender, &my_identity, sizeof (struct | ||
2358 | GNUNET_PeerIdentity))) | ||
2359 | { | ||
2360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2361 | "Received our own broadcast\n"); | ||
2362 | return; | ||
2363 | } | ||
2357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2358 | "checking UDPBroadcastSignature for %s\n", | 2365 | "checking UDPBroadcastSignature for %s\n", |
2359 | GNUNET_i2s (&sender)); | 2366 | 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) | |||
5574 | "Sending ACK with %u components to %s\n", | 5574 | "Sending ACK with %u components to %s\n", |
5575 | ac->ack_counter, | 5575 | ac->ack_counter, |
5576 | GNUNET_i2s (&ac->target)); | 5576 | GNUNET_i2s (&ac->target)); |
5577 | GNUNET_assert (0 < ac->ack_counter); | 5577 | GNUNET_assert (0 <= ac->ack_counter); |
5578 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); | 5578 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); |
5579 | ack->header.size = | 5579 | ack->header.size = |
5580 | htons (sizeof(*ack) | 5580 | htons (sizeof(*ack) |
5581 | + ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP)); | 5581 | + ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP)); |
5582 | ack->ack_counter = htonl (ac->ack_counter++); | 5582 | ack->ack_counter = htonl (ac->ack_counter += ac->num_acks); |
5583 | ap = (struct TransportCummulativeAckPayloadP *) &ack[1]; | 5583 | ap = (struct TransportCummulativeAckPayloadP *) &ack[1]; |
5584 | for (unsigned int i = 0; i < ac->ack_counter; i++) | 5584 | for (unsigned int i = 0; i < ac->ack_counter; i++) |
5585 | { | 5585 | { |
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/ | |||
5 | [transport] | 5 | [transport] |
6 | BINARY = gnunet-service-tng | 6 | BINARY = gnunet-service-tng |
7 | PLUGINS = tcp | 7 | PLUGINS = tcp |
8 | #PREFIX = valgrind --log-file=/tmp/vg_peer1-%p | 8 | # PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/vg_peer1-%p |
9 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock | 9 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock |
10 | 10 | ||
11 | [communicator-tcp] | 11 | [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, | |||
293 | node_ip, | 293 | node_ip, |
294 | handlers, | 294 | handlers, |
295 | ts->cfgname, | 295 | ts->cfgname, |
296 | notify_connect), | 296 | notify_connect, |
297 | GNUNET_NO), | ||
297 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | 298 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", |
298 | write_message), | 299 | write_message), |
299 | block_send, | 300 | 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 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testbed/plugin_cmd_simple_send_broadcast.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_testing_netjail_lib.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_transport_application_service.h" | ||
31 | #include "transport-testing2.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | #define BASE_DIR "testdir" | ||
40 | |||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
42 | |||
43 | struct TestState | ||
44 | { | ||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The name for a specific test environment directory. | ||
53 | * | ||
54 | */ | ||
55 | char *testdir; | ||
56 | |||
57 | /** | ||
58 | * The name for the configuration file of the specific node. | ||
59 | * | ||
60 | */ | ||
61 | char *cfgname; | ||
62 | |||
63 | /** | ||
64 | * The complete topology information. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
67 | }; | ||
68 | |||
69 | static struct GNUNET_TESTING_Command block_send; | ||
70 | |||
71 | static struct GNUNET_TESTING_Command block_receive; | ||
72 | |||
73 | static struct GNUNET_TESTING_Command connect_peers; | ||
74 | |||
75 | static struct GNUNET_TESTING_Command local_prepared; | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | ||
80 | * received. | ||
81 | * | ||
82 | */ | ||
83 | static int | ||
84 | check_test (void *cls, | ||
85 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
86 | { | ||
87 | return GNUNET_OK; | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE | ||
93 | * being received. | ||
94 | * | ||
95 | */ | ||
96 | static void | ||
97 | handle_test (void *cls, | ||
98 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
99 | { | ||
100 | struct GNUNET_TESTING_AsyncContext *ac; | ||
101 | |||
102 | GNUNET_TESTING_get_trait_async_context (&block_receive, | ||
103 | &ac); | ||
104 | GNUNET_assert (NULL != ac); | ||
105 | if (NULL == ac->cont) | ||
106 | GNUNET_TESTING_async_fail (ac); | ||
107 | else | ||
108 | GNUNET_TESTING_async_finish (ac); | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | ||
114 | * | ||
115 | */ | ||
116 | static void | ||
117 | all_peers_started () | ||
118 | { | ||
119 | struct GNUNET_TESTING_AsyncContext *ac; | ||
120 | |||
121 | GNUNET_TESTING_get_trait_async_context (&block_send, | ||
122 | &ac); | ||
123 | GNUNET_assert (NULL != ac); | ||
124 | if (NULL == ac->cont) | ||
125 | GNUNET_TESTING_async_fail (ac); | ||
126 | else | ||
127 | GNUNET_TESTING_async_finish (ac); | ||
128 | } | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Function called with the final result of the test. | ||
133 | * | ||
134 | * @param cls the `struct MainParams` | ||
135 | * @param rv #GNUNET_OK if the test passed | ||
136 | */ | ||
137 | static void | ||
138 | handle_result (void *cls, | ||
139 | enum GNUNET_GenericReturnValue rv) | ||
140 | { | ||
141 | struct TestState *ts = cls; | ||
142 | struct GNUNET_MessageHeader *reply; | ||
143 | |||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
145 | "Local test exits with status %d\n", | ||
146 | rv); | ||
147 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | ||
148 | |||
149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
150 | "message prepared\n"); | ||
151 | ts->write_message (reply, | ||
152 | ntohs (reply->size)); | ||
153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
154 | "message send\n"); | ||
155 | GNUNET_free (ts->testdir); | ||
156 | GNUNET_free (ts->cfgname); | ||
157 | GNUNET_TESTING_free_topology (ts->topology); | ||
158 | GNUNET_free (ts); | ||
159 | } | ||
160 | |||
161 | |||
162 | /** | ||
163 | * Callback from start peer cmd for signaling a peer got connected. | ||
164 | * | ||
165 | */ | ||
166 | static void * | ||
167 | notify_connect (void *cls, | ||
168 | const struct GNUNET_PeerIdentity *peer, | ||
169 | struct GNUNET_MQ_Handle *mq) | ||
170 | { | ||
171 | struct GNUNET_TESTING_AsyncContext *ac; | ||
172 | |||
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
174 | "notify_connect\n"); | ||
175 | |||
176 | GNUNET_TESTING_get_trait_async_context (&connect_peers, | ||
177 | &ac); | ||
178 | void *ret = NULL; | ||
179 | |||
180 | GNUNET_assert (NULL != ac); | ||
181 | if (NULL == ac->cont) | ||
182 | GNUNET_TESTING_async_fail (ac); | ||
183 | else | ||
184 | GNUNET_TESTING_async_finish (ac); | ||
185 | |||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. | ||
192 | */ | ||
193 | static void | ||
194 | all_local_tests_prepared () | ||
195 | { | ||
196 | struct LocalPreparedState *lfs; | ||
197 | |||
198 | GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, | ||
199 | &lfs); | ||
200 | GNUNET_assert (NULL != &lfs->ac); | ||
201 | if (NULL == lfs->ac.cont) | ||
202 | GNUNET_TESTING_async_fail (&lfs->ac); | ||
203 | else | ||
204 | GNUNET_TESTING_async_finish (&lfs->ac); | ||
205 | } | ||
206 | |||
207 | |||
208 | /** | ||
209 | * Function to start a local test case. | ||
210 | * | ||
211 | * @param write_message Callback to send a message to the master loop. | ||
212 | * @param router_ip Global address of the network namespace. | ||
213 | * @param node_ip Local address of a node i a network namespace. | ||
214 | * @param m The number of the node in a network namespace. | ||
215 | * @param n The number of the network namespace. | ||
216 | * @param local_m The number of nodes in a network namespace. | ||
217 | */ | ||
218 | static void | ||
219 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | ||
220 | char *node_ip, | ||
221 | char *m, | ||
222 | char *n, | ||
223 | char *local_m, | ||
224 | char *topology_data, | ||
225 | unsigned int *read_file) | ||
226 | { | ||
227 | |||
228 | unsigned int n_int; | ||
229 | unsigned int m_int; | ||
230 | unsigned int local_m_int; | ||
231 | unsigned int num; | ||
232 | struct TestState *ts = GNUNET_new (struct TestState); | ||
233 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
234 | |||
235 | if (GNUNET_YES == *read_file) | ||
236 | { | ||
237 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
238 | "read from file\n"); | ||
239 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); | ||
240 | } | ||
241 | else | ||
242 | topology = GNUNET_TESTING_get_topo_from_string (topology_data); | ||
243 | |||
244 | ts->topology = topology; | ||
245 | |||
246 | sscanf (m, "%u", &m_int); | ||
247 | sscanf (n, "%u", &n_int); | ||
248 | sscanf (local_m, "%u", &local_m_int); | ||
249 | |||
250 | if (0 == n_int) | ||
251 | num = m_int; | ||
252 | else | ||
253 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | ||
254 | |||
255 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | ||
256 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
257 | "block-receive"); | ||
258 | connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger ("connect-peers"); | ||
259 | local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( | ||
260 | "local-test-prepared", | ||
261 | write_message); | ||
262 | |||
263 | |||
264 | GNUNET_asprintf (&ts->cfgname, | ||
265 | "test_transport_api2_tcp_node1.conf"); | ||
266 | |||
267 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
268 | "plugin cfgname: %s\n", | ||
269 | ts->cfgname); | ||
270 | |||
271 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
272 | "node ip: %s\n", | ||
273 | node_ip); | ||
274 | |||
275 | GNUNET_asprintf (&ts->testdir, | ||
276 | "%s%s%s", | ||
277 | BASE_DIR, | ||
278 | m, | ||
279 | n); | ||
280 | |||
281 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
282 | GNUNET_MQ_hd_var_size (test, | ||
283 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | ||
284 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
285 | ts), | ||
286 | GNUNET_MQ_handler_end () | ||
287 | }; | ||
288 | |||
289 | struct GNUNET_TESTING_Command commands[] = { | ||
290 | GNUNET_TESTING_cmd_system_create ("system-create", | ||
291 | ts->testdir), | ||
292 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer", | ||
293 | "system-create", | ||
294 | num, | ||
295 | node_ip, | ||
296 | handlers, | ||
297 | ts->cfgname, | ||
298 | notify_connect, | ||
299 | GNUNET_YES), | ||
300 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | ||
301 | write_message), | ||
302 | block_send, | ||
303 | connect_peers, | ||
304 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", | ||
305 | "start-peer", | ||
306 | "system-create", | ||
307 | num, | ||
308 | topology), | ||
309 | block_receive, | ||
310 | local_prepared, | ||
311 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | ||
312 | "start-peer"), | ||
313 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | ||
314 | "system-create"), | ||
315 | GNUNET_TESTING_cmd_end () | ||
316 | }; | ||
317 | |||
318 | ts->write_message = write_message; | ||
319 | |||
320 | GNUNET_TESTING_run (commands, | ||
321 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
322 | &handle_result, | ||
323 | ts); | ||
324 | |||
325 | } | ||
326 | |||
327 | |||
328 | /** | ||
329 | * Entry point for the plugin. | ||
330 | * | ||
331 | * @param cls NULL | ||
332 | * @return the exported block API | ||
333 | */ | ||
334 | void * | ||
335 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast_init (void *cls) | ||
336 | { | ||
337 | struct GNUNET_TESTING_PluginFunctions *api; | ||
338 | |||
339 | GNUNET_log_setup ("simple-send", | ||
340 | "DEBUG", | ||
341 | NULL); | ||
342 | |||
343 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | ||
344 | api->start_testcase = &start_testcase; | ||
345 | api->all_peers_started = &all_peers_started; | ||
346 | api->all_local_tests_prepared = all_local_tests_prepared; | ||
347 | return api; | ||
348 | } | ||
349 | |||
350 | |||
351 | /** | ||
352 | * Exit point from the plugin. | ||
353 | * | ||
354 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init | ||
355 | * @return NULL | ||
356 | */ | ||
357 | void * | ||
358 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast_done (void *cls) | ||
359 | { | ||
360 | struct GNUNET_TESTING_PluginFunctions *api = cls; | ||
361 | |||
362 | GNUNET_free (api); | ||
363 | return NULL; | ||
364 | } | ||
365 | |||
366 | |||
367 | /* 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, | |||
282 | node_ip, | 282 | node_ip, |
283 | handlers, | 283 | handlers, |
284 | ts->cfgname, | 284 | ts->cfgname, |
285 | notify_connect), | 285 | notify_connect, |
286 | GNUNET_NO), | ||
286 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", | 287 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready", |
287 | write_message), | 288 | write_message), |
288 | block_send, | 289 | 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 @@ | |||
1 | #!/bin/bash | ||
2 | if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then | ||
3 | 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" | ||
4 | else | ||
5 | 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" | ||
6 | exit 78 | ||
7 | 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 @@ | |||
1 | M:2 | ||
2 | N:1 | ||
3 | X:0 | ||
4 | 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 | |||
165 | 165 | ||
166 | GNUNET_TRANSPORT_NotifyConnect notify_connect; | 166 | GNUNET_TRANSPORT_NotifyConnect notify_connect; |
167 | 167 | ||
168 | /** | ||
169 | * Flag indicating, if udp broadcast should be switched on. | ||
170 | */ | ||
171 | unsigned int broadcast; | ||
168 | }; | 172 | }; |
169 | 173 | ||
170 | 174 | ||
@@ -188,6 +192,20 @@ GNUNET_TRANSPORT_get_trait_state (const struct | |||
188 | struct StartPeerState **sps); | 192 | struct StartPeerState **sps); |
189 | 193 | ||
190 | 194 | ||
195 | /** | ||
196 | * Create command. | ||
197 | * | ||
198 | * @param label name for command. | ||
199 | * @param system_label Label of the cmd to setup a test environment. | ||
200 | * @param m The number of the local node of the actual network namespace. | ||
201 | * @param n The number of the actual namespace. | ||
202 | * @param local_m Number of local nodes in each namespace. | ||
203 | * @param handlers Handler for messages received by this peer. | ||
204 | * @param cfgname Configuration file name for this peer. | ||
205 | * @param notify_connect Method which will be called, when a peer connects. | ||
206 | * @param broadcast Flag indicating, if broadcast should be switched on. | ||
207 | * @return command. | ||
208 | */ | ||
191 | struct GNUNET_TESTING_Command | 209 | struct GNUNET_TESTING_Command |
192 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, | 210 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, |
193 | const char *system_label, | 211 | const char *system_label, |
@@ -195,7 +213,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
195 | char *node_ip, | 213 | char *node_ip, |
196 | struct GNUNET_MQ_MessageHandler *handlers, | 214 | struct GNUNET_MQ_MessageHandler *handlers, |
197 | const char *cfgname, | 215 | const char *cfgname, |
198 | GNUNET_TRANSPORT_NotifyConnect notify_connect); | 216 | GNUNET_TRANSPORT_NotifyConnect notify_connect, |
217 | unsigned int broadcast); | ||
199 | 218 | ||
200 | 219 | ||
201 | struct GNUNET_TESTING_Command | 220 | 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) | |||
244 | struct GNUNET_TRANSPORT_CoreHandle *h = cls; | 244 | struct GNUNET_TRANSPORT_CoreHandle *h = cls; |
245 | 245 | ||
246 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 246 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
247 | "Error receiving from transport service, disconnecting temporarily.\n"); | 247 | "Error %u received from transport service, disconnecting temporarily.\n", |
248 | error); | ||
248 | disconnect_and_schedule_reconnect (h); | 249 | disconnect_and_schedule_reconnect (h); |
249 | } | 250 | } |
250 | 251 | ||
@@ -522,6 +523,8 @@ check_recv (void *cls, const struct InboundMessage *im) | |||
522 | const struct GNUNET_MessageHeader *imm; | 523 | const struct GNUNET_MessageHeader *imm; |
523 | uint16_t size; | 524 | uint16_t size; |
524 | 525 | ||
526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
527 | "check_recv\n"); | ||
525 | size = ntohs (im->header.size) - sizeof(*im); | 528 | size = ntohs (im->header.size) - sizeof(*im); |
526 | if (size < sizeof(struct GNUNET_MessageHeader)) | 529 | if (size < sizeof(struct GNUNET_MessageHeader)) |
527 | { | 530 | { |
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 @@ | |||
31 | #include "transport-testing-cmds.h" | 31 | #include "transport-testing-cmds.h" |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Generic logging shortcut | ||
35 | */ | ||
36 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
37 | |||
38 | /** | ||
34 | * Struct to hold information for callbacks. | 39 | * Struct to hold information for callbacks. |
35 | * | 40 | * |
36 | */ | 41 | */ |
@@ -74,6 +79,32 @@ send_simple_cleanup (void *cls) | |||
74 | } | 79 | } |
75 | 80 | ||
76 | 81 | ||
82 | static int | ||
83 | send_simple_cb (void *cls, | ||
84 | const struct GNUNET_ShortHashCode *key, | ||
85 | void *value) | ||
86 | { | ||
87 | struct SendSimpleState *sss = cls; | ||
88 | struct GNUNET_MQ_Handle *mq = value; | ||
89 | struct GNUNET_MQ_Envelope *env; | ||
90 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; | ||
91 | |||
92 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
93 | "Sending simple test message\n"); | ||
94 | |||
95 | env = GNUNET_MQ_msg_extra (test, | ||
96 | 1000 - sizeof(*test), | ||
97 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); | ||
98 | test->num = htonl (sss->num); | ||
99 | memset (&test[1], | ||
100 | sss->num, | ||
101 | 1000 - sizeof(*test)); | ||
102 | GNUNET_MQ_send (mq, | ||
103 | env); | ||
104 | return GNUNET_OK; | ||
105 | } | ||
106 | |||
107 | |||
77 | /** | 108 | /** |
78 | * The run method of this cmd will send a simple message to the connected peers. | 109 | * The run method of this cmd will send a simple message to the connected peers. |
79 | * | 110 | * |
@@ -83,12 +114,9 @@ send_simple_run (void *cls, | |||
83 | struct GNUNET_TESTING_Interpreter *is) | 114 | struct GNUNET_TESTING_Interpreter *is) |
84 | { | 115 | { |
85 | struct SendSimpleState *sss = cls; | 116 | struct SendSimpleState *sss = cls; |
86 | struct GNUNET_MQ_Envelope *env; | ||
87 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; | ||
88 | struct GNUNET_MQ_Handle *mq; | ||
89 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 117 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
90 | const struct GNUNET_TESTING_Command *peer1_cmd; | 118 | const struct GNUNET_TESTING_Command *peer1_cmd; |
91 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | 119 | // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); |
92 | struct GNUNET_HashCode hc; | 120 | struct GNUNET_HashCode hc; |
93 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | 121 | struct GNUNET_TESTING_NodeConnection *node_connections_head; |
94 | struct GNUNET_PeerIdentity *peer; | 122 | struct GNUNET_PeerIdentity *peer; |
@@ -111,7 +139,9 @@ send_simple_run (void *cls, | |||
111 | node_connections_head = GNUNET_TESTING_get_connections (sss->num, | 139 | node_connections_head = GNUNET_TESTING_get_connections (sss->num, |
112 | sss->topology); | 140 | sss->topology); |
113 | 141 | ||
114 | for (int i = 0; i < 1; i++) | 142 | GNUNET_CONTAINER_multishortmap_iterate (connected_peers_map, send_simple_cb, |
143 | sss); | ||
144 | /*for (int i = 0; i < 1; i++) | ||
115 | { | 145 | { |
116 | for (pos_connection = node_connections_head; NULL != pos_connection; | 146 | for (pos_connection = node_connections_head; NULL != pos_connection; |
117 | pos_connection = pos_connection->next) | 147 | pos_connection = pos_connection->next) |
@@ -136,9 +166,9 @@ send_simple_run (void *cls, | |||
136 | GNUNET_MQ_send (mq, | 166 | GNUNET_MQ_send (mq, |
137 | env); | 167 | env); |
138 | } | 168 | } |
139 | } | 169 | }*/ |
140 | 170 | ||
141 | GNUNET_free (key); | 171 | // GNUNET_free (key); |
142 | 172 | ||
143 | } | 173 | } |
144 | 174 | ||
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, | |||
126 | 126 | ||
127 | void *ret = NULL; | 127 | void *ret = NULL; |
128 | 128 | ||
129 | |||
130 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 129 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
131 | "Peer %s connected to peer %u (`%s')\n", | 130 | "This Peer %s \n", |
132 | GNUNET_i2s (peer), | ||
133 | sps->no, | ||
134 | GNUNET_i2s (&sps->id)); | 131 | GNUNET_i2s (&sps->id)); |
132 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
133 | "Peer %s connected to peer number %u\n", | ||
134 | GNUNET_i2s (peer), | ||
135 | sps->no); | ||
135 | 136 | ||
136 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); | 137 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); |
137 | 138 | ||
@@ -216,6 +217,11 @@ start_peer_run (void *cls, | |||
216 | "node_ip %s\n", | 217 | "node_ip %s\n", |
217 | bindto); | 218 | bindto); |
218 | 219 | ||
220 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
221 | "bind_udp %s\n", | ||
222 | GNUNET_YES == sps->broadcast ? | ||
223 | bindto_udp : bindto); | ||
224 | |||
219 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", | 225 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", |
220 | home); | 226 | home); |
221 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH", | 227 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH", |
@@ -225,7 +231,8 @@ start_peer_run (void *cls, | |||
225 | bindto); | 231 | bindto); |
226 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | 232 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", |
227 | "BINDTO", | 233 | "BINDTO", |
228 | bindto); | 234 | GNUNET_YES == sps->broadcast ? |
235 | bindto_udp : bindto); | ||
229 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | 236 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", |
230 | "UNIXPATH", | 237 | "UNIXPATH", |
231 | tcp_communicator_unix_path); | 238 | tcp_communicator_unix_path); |
@@ -571,6 +578,8 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct | |||
571 | * @param local_m Number of local nodes in each namespace. | 578 | * @param local_m Number of local nodes in each namespace. |
572 | * @param handlers Handler for messages received by this peer. | 579 | * @param handlers Handler for messages received by this peer. |
573 | * @param cfgname Configuration file name for this peer. | 580 | * @param cfgname Configuration file name for this peer. |
581 | * @param notify_connect Method which will be called, when a peer connects. | ||
582 | * @param broadcast Flag indicating, if broadcast should be switched on. | ||
574 | * @return command. | 583 | * @return command. |
575 | */ | 584 | */ |
576 | struct GNUNET_TESTING_Command | 585 | struct GNUNET_TESTING_Command |
@@ -580,7 +589,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
580 | char *node_ip, | 589 | char *node_ip, |
581 | struct GNUNET_MQ_MessageHandler *handlers, | 590 | struct GNUNET_MQ_MessageHandler *handlers, |
582 | const char *cfgname, | 591 | const char *cfgname, |
583 | GNUNET_TRANSPORT_NotifyConnect notify_connect) | 592 | GNUNET_TRANSPORT_NotifyConnect notify_connect, |
593 | unsigned int broadcast) | ||
584 | { | 594 | { |
585 | struct StartPeerState *sps; | 595 | struct StartPeerState *sps; |
586 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | 596 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = |
@@ -594,6 +604,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
594 | sps->cfgname = cfgname; | 604 | sps->cfgname = cfgname; |
595 | sps->node_ip = node_ip; | 605 | sps->node_ip = node_ip; |
596 | sps->notify_connect = notify_connect; | 606 | sps->notify_connect = notify_connect; |
607 | sps->broadcast = broadcast; | ||
597 | 608 | ||
598 | if (NULL != handlers) | 609 | if (NULL != handlers) |
599 | { | 610 | { |