aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-25 14:03:13 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-25 14:03:13 +0100
commitfff38c7f0b1bee8302b4e5689c77412d28542398 (patch)
tree4f892bac6cf0cf51b86c11bd6aa65305dd89f877 /src
parentb9644ee3066924eefa8ea2b75fbd20538ad7ce03 (diff)
parentbb8093fd76120ba34f5e36370f9ad6bceb4afe7c (diff)
downloadgnunet-fff38c7f0b1bee8302b4e5689c77412d28542398.tar.gz
gnunet-fff38c7f0b1bee8302b4e5689c77412d28542398.zip
Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/arm/arm_api.c1
-rw-r--r--src/identity/identity_api.c6
-rw-r--r--src/include/gnunet_pq_lib.h19
-rw-r--r--src/include/gnunet_testing_netjail_lib.h91
-rw-r--r--src/include/gnunet_testing_ng_lib.h452
-rw-r--r--src/messenger/gnunet-service-messenger.c4
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c14
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h4
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.c2
-rw-r--r--src/messenger/gnunet-service-messenger_room.c19
-rw-r--r--src/messenger/gnunet-service-messenger_service.c2
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.c2
-rw-r--r--src/messenger/messenger.conf.in1
-rw-r--r--src/messenger/messenger_api.c6
-rw-r--r--src/messenger/messenger_api_handle.c2
-rw-r--r--src/messenger/messenger_api_message.c59
-rw-r--r--src/messenger/messenger_api_message.h15
-rw-r--r--src/nat/nat_api.c43
-rw-r--r--src/pq/pq_prepare.c2
-rw-r--r--src/reclaim/gnunet-reclaim.c5
-rw-r--r--src/testing/gnunet-cmds-helper.c6
-rw-r--r--src/testing/testing.c93
-rw-r--r--src/testing/testing_api_cmd_block_until_external_trigger.c61
-rw-r--r--src/testing/testing_api_cmd_netjail_start.c4
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c4
-rw-r--r--src/testing/testing_api_cmd_netjail_stop.c1
-rw-r--r--src/testing/testing_api_loop.c116
-rw-r--r--src/transport/Makefile.am3
-rw-r--r--src/transport/gnunet-communicator-tcp.c96
-rw-r--r--src/transport/gnunet-service-tng.c2
-rw-r--r--src/transport/test_transport_api2_tcp_node1.conf1
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c22
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_broadcast.c56
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c17
-rwxr-xr-xsrc/transport/test_transport_simple_send.sh5
-rwxr-xr-xsrc/transport/test_transport_simple_send_broadcast.sh6
-rwxr-xr-xsrc/transport/test_transport_simple_send_string.sh7
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh5
-rw-r--r--src/transport/test_transport_udp_backchannel_topo.conf7
-rw-r--r--src/transport/transport-testing-cmds.h11
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c13
-rw-r--r--src/transport/transport_api_cmd_start_peer.c17
-rw-r--r--src/util/mq.c6
-rw-r--r--src/util/program.c11
44 files changed, 633 insertions, 686 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index 5fcbfb0a9..1360ecf14 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -907,6 +907,7 @@ notify_starting (void *cls)
907 op->result_cont (op->cont_cls, 907 op->result_cont (op->cont_cls,
908 GNUNET_ARM_REQUEST_SENT_OK, 908 GNUNET_ARM_REQUEST_SENT_OK,
909 op->starting_ret); 909 op->starting_ret);
910 GNUNET_DISK_file_close(op->rfd);
910 GNUNET_free (op); 911 GNUNET_free (op);
911} 912}
912 913
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 22371f91a..08a975e65 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013, 2016 GNUnet e.V. 3 Copyright (C) 2013, 2016, 2021 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -1020,7 +1020,9 @@ GNUNET_IDENTITY_write_key_to_buffer (const struct
1020 return -1; 1020 return -1;
1021 if (length < 0) 1021 if (length < 0)
1022 return -2; 1022 return -2;
1023 GNUNET_memcpy (buffer, key, length); 1023 GNUNET_memcpy (buffer, &(key->type), sizeof (key->type));
1024 GNUNET_memcpy (buffer + sizeof (key->type), &(key->ecdsa_key), length
1025 - sizeof (key->type));
1024 return length; 1026 return length;
1025} 1027}
1026 1028
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index 6a2227581..6a374f7e2 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -335,7 +335,15 @@ struct GNUNET_PQ_ResultSpec
335 */ 335 */
336#define GNUNET_PQ_result_spec_end \ 336#define GNUNET_PQ_result_spec_end \
337 { \ 337 { \
338 NULL, NULL, NULL, NULL, 0, NULL, NULL \ 338 .conv = NULL, \
339 .cleaner = NULL, \
340 .cls = NULL, \
341 .dst = NULL, \
342 .dst_size = 0, \
343 .fname = NULL, \
344 .result_size = NULL, \
345 .is_nullable = false, \
346 .is_null = NULL \
339 } 347 }
340 348
341 349
@@ -377,7 +385,9 @@ GNUNET_PQ_result_spec_variable_size (const char *name,
377 * @return array entry for the result specification to use 385 * @return array entry for the result specification to use
378 */ 386 */
379struct GNUNET_PQ_ResultSpec 387struct GNUNET_PQ_ResultSpec
380GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size); 388GNUNET_PQ_result_spec_fixed_size (const char *name,
389 void *dst,
390 size_t dst_size);
381 391
382 392
383/** 393/**
@@ -399,7 +409,8 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size);
399 * @return array entry for the result specification to use 409 * @return array entry for the result specification to use
400 */ 410 */
401struct GNUNET_PQ_ResultSpec 411struct GNUNET_PQ_ResultSpec
402GNUNET_PQ_result_spec_string (const char *name, char **dst); 412GNUNET_PQ_result_spec_string (const char *name,
413 char **dst);
403 414
404 415
405/** 416/**
@@ -710,7 +721,7 @@ GNUNET_PQ_make_prepare (const char *name,
710 * @return #GNUNET_OK on success, 721 * @return #GNUNET_OK on success,
711 * #GNUNET_SYSERR on error 722 * #GNUNET_SYSERR on error
712 */ 723 */
713int 724enum GNUNET_GenericReturnValue
714GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db, 725GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
715 const struct GNUNET_PQ_PreparedStatement *ps); 726 const struct GNUNET_PQ_PreparedStatement *ps);
716 727
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
index 3a5e9f749..334f43c88 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -24,8 +24,8 @@
24 * @author Marcello Stanisci 24 * @author Marcello Stanisci
25 * @author t3sserakt 25 * @author t3sserakt
26 */ 26 */
27#ifndef GNUNET_TESTING_NG_LIB_H 27#ifndef GNUNET_TESTING_NETJAIL_LIB_H
28#define GNUNET_TESTING_NG_LIB_H 28#define GNUNET_TESTING_NETJAIL_LIB_H
29 29
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_testing_plugin.h" 31#include "gnunet_testing_plugin.h"
@@ -301,6 +301,28 @@ GNUNET_TESTING_calculate_num (struct
301 301
302 302
303/** 303/**
304 * Struct with information for callbacks.
305 *
306 */
307struct BlockState
308{
309 /**
310 * Context for our asynchronous completion.
311 */
312 struct GNUNET_TESTING_AsyncContext ac;
313
314 /**
315 * The label of this command.
316 */
317 const char *label;
318
319 /**
320 * If this command will block.
321 */
322 unsigned int asynchronous_finish;
323};
324
325/**
304 * Struct to hold information for callbacks. 326 * Struct to hold information for callbacks.
305 * 327 *
306 */ 328 */
@@ -309,7 +331,7 @@ struct LocalPreparedState
309 /** 331 /**
310 * Context for our asynchronous completion. 332 * Context for our asynchronous completion.
311 */ 333 */
312 struct GNUNET_TESTING_AsyncContext *ac; 334 struct GNUNET_TESTING_AsyncContext ac;
313 335
314 /** 336 /**
315 * Callback to write messages to the master loop. 337 * Callback to write messages to the master loop.
@@ -319,11 +341,28 @@ struct LocalPreparedState
319}; 341};
320 342
321 343
344struct GNUNET_TESTING_Command
345GNUNET_TESTING_cmd_system_destroy (const char *label,
346 const char *create_label);
347
348
349struct GNUNET_TESTING_Command
350GNUNET_TESTING_cmd_system_create (const char *label,
351 const char *testdir);
352
353
354int
355GNUNET_TESTING_get_trait_test_system (const struct
356 GNUNET_TESTING_Command *cmd,
357 struct GNUNET_TESTING_System **test_system);
358
359
322/** 360/**
323 * Create command. 361 * Create command.
324 * 362 *
325 * @param label name for command. 363 * @param label name for command.
326 * @param topology_config Configuration file for the test topology. 364 * @param topology_config Configuration file for the test topology.
365 * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
327 * @return command. 366 * @return command.
328 */ 367 */
329struct GNUNET_TESTING_Command 368struct GNUNET_TESTING_Command
@@ -335,27 +374,32 @@ GNUNET_TESTING_cmd_netjail_start (const char *label,
335/** 374/**
336 * Create command. 375 * Create command.
337 * 376 *
338 * @param label Name for the command. 377 * @param label name for command.
339 * @param topology The complete topology information. 378 * @param topology_config Configuration file for the test topology.
379 * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
340 * @return command. 380 * @return command.
341 */ 381 */
342struct GNUNET_TESTING_Command 382struct GNUNET_TESTING_Command
343GNUNET_TESTING_cmd_netjail_start_testing_system ( 383GNUNET_TESTING_cmd_netjail_stop (const char *label,
344 const char *label, 384 char *topology_config,
345 struct GNUNET_TESTING_NetjailTopology *topology); 385 unsigned int *read_file);
346 386
347 387
348/** 388/**
349 * Create command. 389 * Create command.
350 * 390 *
351 * @param label name for command. 391 * @param label Name for the command.
352 * @param topology_config Configuration file for the test topology. 392 * @param topology The complete topology information.
393 * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
394 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
353 * @return command. 395 * @return command.
354 */ 396 */
355struct GNUNET_TESTING_Command 397struct GNUNET_TESTING_Command
356GNUNET_TESTING_cmd_netjail_stop (const char *label, 398GNUNET_TESTING_cmd_netjail_start_testing_system (
357 char *topology_config, 399 const char *label,
358 unsigned int *read_file); 400 struct GNUNET_TESTING_NetjailTopology *topology,
401 unsigned int *read_file,
402 char *topology_data);
359 403
360 404
361/** 405/**
@@ -414,10 +458,19 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (
414 unsigned int *all_peers_started); 458 unsigned int *all_peers_started);
415 459
416 460
461/**
462 * Create command.
463 *
464 * @param label name for command.
465 * @param all_peers_started Flag which will be set from outside.
466 * @param asynchronous_finish If GNUNET_YES this command will not block.
467 * @return command.
468 */
417struct GNUNET_TESTING_Command 469struct GNUNET_TESTING_Command
418GNUNET_TESTING_cmd_block_until_external_trigger ( 470GNUNET_TESTING_cmd_block_until_external_trigger (
419 const char *label); 471 const char *label);
420 472
473
421struct GNUNET_TESTING_Command 474struct GNUNET_TESTING_Command
422GNUNET_TESTING_cmd_send_peer_ready (const char *label, 475GNUNET_TESTING_cmd_send_peer_ready (const char *label,
423 TESTING_CMD_HELPER_write_cb write_message); 476 TESTING_CMD_HELPER_write_cb write_message);
@@ -460,4 +513,16 @@ GNUNET_TESTING_get_trait_local_prepared_state (
460 const struct GNUNET_TESTING_Command *cmd, 513 const struct GNUNET_TESTING_Command *cmd,
461 struct LocalPreparedState **lfs); 514 struct LocalPreparedState **lfs);
462 515
516
517/**
518 * Function to get the trait with the internal command state BlockState.
519 *
520 * * @param[out] ac struct BlockState.
521* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
522 */
523int
524GNUNET_TESTING_get_trait_block_state (
525 const struct GNUNET_TESTING_Command *cmd,
526 struct BlockState **bs);
527
463#endif 528#endif
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 2d040ac21..5011aefd8 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -47,212 +47,6 @@
47 } while (0) 47 } while (0)
48 48
49 49
50/**
51 * Router of a network namespace.
52 * // FIXME: this does not belong here!
53 */
54struct GNUNET_TESTING_NetjailRouter
55{
56 /**
57 * Will tcp be forwarded?
58 */
59 unsigned int tcp_port;
60
61 /**
62 * Will udp be forwarded?
63 */
64 unsigned int udp_port;
65};
66
67
68/**
69 * Enum for the different types of nodes.
70 * // FIXME: this does not belong here!
71 */
72enum GNUNET_TESTING_NODE_TYPE
73{
74 /**
75 * Node in a subnet.
76 */
77 GNUNET_TESTING_SUBNET_NODE,
78
79 /**
80 * Global known node.
81 */
82 GNUNET_TESTING_GLOBAL_NODE
83};
84
85
86// FIXME: this does not belong here!
87struct GNUNET_TESTING_AddressPrefix
88{
89 /**
90 * Pointer to the previous prefix in the DLL.
91 */
92 struct GNUNET_TESTING_AddressPrefix *prev;
93
94 /**
95 * Pointer to the next prefix in the DLL.
96 */
97 struct GNUNET_TESTING_AddressPrefix *next;
98
99 /**
100 * The address prefix.
101 */
102 char *address_prefix;
103};
104
105
106// FIXME: this does not belong here!
107struct GNUNET_TESTING_NetjailNode;
108
109/**
110 * Connection to another node.
111 * // FIXME: this does not belong here!
112 */
113struct GNUNET_TESTING_NodeConnection
114{
115 /**
116 * Pointer to the previous connection in the DLL.
117 */
118 struct GNUNET_TESTING_NodeConnection *prev;
119
120 /**
121 * Pointer to the next connection in the DLL.
122 */
123 struct GNUNET_TESTING_NodeConnection *next;
124
125 /**
126 * The number of the subnet of the node this connection points to. This is 0,
127 * if the node is a global known node.
128 */
129 unsigned int namespace_n;
130
131 /**
132 * The number of the node this connection points to.
133 */
134 unsigned int node_n;
135
136 /**
137 * The type of the node this connection points to.
138 */
139 enum GNUNET_TESTING_NODE_TYPE node_type;
140
141 /**
142 * The node which establish the connection
143 */
144 struct GNUNET_TESTING_NetjailNode *node;
145
146 /**
147 * Head of the DLL with the address prefixes for the protocolls this node is reachable.
148 */
149 struct GNUNET_TESTING_AddressPrefix *address_prefixes_head;
150
151 /**
152 * Tail of the DLL with the address prefixes for the protocolls this node is reachable.
153 */
154 struct GNUNET_TESTING_AddressPrefix *address_prefixes_tail;
155};
156
157/**
158 * Node in the netjail topology.
159 * // FIXME: this does not belong here!
160 */
161struct GNUNET_TESTING_NetjailNode
162{
163 /**
164 * Plugin for the test case to be run on this node.
165 */
166 char *plugin;
167
168 /**
169 * Flag indicating if this node is a global known node.
170 */
171 unsigned int is_global;
172
173 /**
174 * The number of the namespace this node is running in.
175 */
176 unsigned int namespace_n;
177
178 /**
179 * The number of this node in the namespace.
180 */
181 unsigned int node_n;
182
183 /**
184 * Head of the DLL with the connections which shall be established to other nodes.
185 */
186 struct GNUNET_TESTING_NodeConnection *node_connections_head;
187
188 /**
189 * Tail of the DLL with the connections which shall be established to other nodes.
190 */
191 struct GNUNET_TESTING_NodeConnection *node_connections_tail;
192};
193
194
195/**
196 * Namespace in a topology.
197 * // FIXME: this does not belong here!
198 */
199struct GNUNET_TESTING_NetjailNamespace
200{
201 /**
202 * The number of the namespace.
203 */
204 unsigned int namespace_n;
205
206 /**
207 * Router of the namespace.
208 */
209 struct GNUNET_TESTING_NetjailRouter *router;
210
211 /**
212 * Hash map containing the nodes in this namespace.
213 */
214 struct GNUNET_CONTAINER_MultiShortmap *nodes;
215};
216
217/**
218 * Toplogy of our netjail setup.
219 * // FIXME: this does not belong here!
220 */
221struct GNUNET_TESTING_NetjailTopology
222{
223
224 /**
225 * Default plugin for the test case to be run on nodes.
226 */
227 char *plugin;
228
229 /**
230 * Number of namespaces.
231 */
232 unsigned int namespaces_n;
233
234 /**
235 * Number of nodes per namespace.
236 */
237 unsigned int nodes_m;
238
239 /**
240 * Number of global known nodes per namespace.
241 */
242 unsigned int nodes_x;
243
244 /**
245 * Hash map containing the namespaces (for natted nodes) of the topology.
246 */
247 struct GNUNET_CONTAINER_MultiShortmap *map_namespaces;
248
249 /**
250 * Hash map containing the global known nodes which are not natted.
251 */
252 struct GNUNET_CONTAINER_MultiShortmap *map_globals;
253};
254
255
256/* ******************* Generic interpreter logic ************ */ 50/* ******************* Generic interpreter logic ************ */
257 51
258/** 52/**
@@ -284,7 +78,7 @@ struct GNUNET_TESTING_AsyncContext
284 78
285 /** 79 /**
286 * Indication if the command finished (#GNUNET_OK). 80 * Indication if the command finished (#GNUNET_OK).
287 * #GNUNET_NO if it is still running, 81 * #GNUNET_NO if it did not finish,
288 * #GNUNET_SYSERR if it failed. 82 * #GNUNET_SYSERR if it failed.
289 */ 83 */
290 enum GNUNET_GenericReturnValue finished; 84 enum GNUNET_GenericReturnValue finished;
@@ -411,6 +205,20 @@ struct GNUNET_TESTING_Command
411 205
412/** 206/**
413 * Lookup command by label. 207 * Lookup command by label.
208 * Only future commands are looked up.
209 *
210 * @param is interpreter to lookup command in
211 * @param label label of the command to lookup.
212 * @return the command, if it is found, or NULL.
213 */
214const struct GNUNET_TESTING_Command *
215GNUNET_TESTING_interpreter_lookup_future_command (
216 struct GNUNET_TESTING_Interpreter *is,
217 const char *label);
218
219
220/**
221 * Lookup command by label.
414 * 222 *
415 * @param is interpreter to lookup command in 223 * @param is interpreter to lookup command in
416 * @param label label of the command to lookup. 224 * @param label label of the command to lookup.
@@ -569,6 +377,39 @@ GNUNET_TESTING_has_in_name (const char *prog,
569 377
570/* ************** Specific interpreter commands ************ */ 378/* ************** Specific interpreter commands ************ */
571 379
380
381/**
382 * Returns the actual running command.
383 *
384 * @param is Global state of the interpreter, used by a command
385 * to access information about other commands.
386 * @return The actual running command.
387 */
388struct GNUNET_TESTING_Command *
389GNUNET_TESTING_interpreter_get_current_command (
390 struct GNUNET_TESTING_Interpreter *is);
391
392
393/**
394 * Check if the command is running.
395 *
396 * @param cmd The command to check.
397 * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running.
398 */
399enum GNUNET_GenericReturnValue
400GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command);
401
402
403/**
404 * Check if a command is finished.
405 *
406 * @param cmd The command to check.
407 * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished.
408 */
409enum GNUNET_GenericReturnValue
410GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command);
411
412
572/** 413/**
573 * Create a "signal" CMD. 414 * Create a "signal" CMD.
574 * 415 *
@@ -1062,201 +903,4 @@ GNUNET_TESTING_make_trait_relative_time (
1062 unsigned int index, 903 unsigned int index,
1063 const struct GNUNET_TIME_Relative *time); 904 const struct GNUNET_TIME_Relative *time);
1064 905
1065
1066// FIXME: move these commands into a separate libgnunetestingnetjail lib or so!
1067
1068/**
1069 * Struct to hold information for callbacks.
1070 *
1071 */
1072struct LocalPreparedState
1073{
1074 /**
1075 * Context for our asynchronous completion.
1076 */
1077 struct GNUNET_TESTING_AsyncContext ac;
1078
1079 /**
1080 * Callback to write messages to the master loop.
1081 *
1082 */
1083 TESTING_CMD_HELPER_write_cb write_message;
1084};
1085
1086
1087/**
1088 * Offer data from trait
1089 *
1090 * @param cmd command to extract the url from.
1091 * @param pt which url is to be picked, in case
1092 * multiple are offered.
1093 * @param[out] url where to write the url.
1094 * @return #GNUNET_OK on success.
1095 */
1096int
1097GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
1098 char **what_am_i);
1099
1100
1101int
1102GNUNET_TESTING_get_trait_test_system (const struct
1103 GNUNET_TESTING_Command *cmd,
1104 struct GNUNET_TESTING_System **test_system);
1105
1106
1107struct GNUNET_TESTING_Command
1108GNUNET_TESTING_cmd_system_create (const char *label,
1109 const char *testdir);
1110
1111
1112struct GNUNET_TESTING_Command
1113GNUNET_TESTING_cmd_system_destroy (const char *label,
1114 const char *create_label);
1115
1116
1117/**
1118 * Create command.
1119 *
1120 * @param label name for command.
1121 * @param topology_config Configuration file for the test topology.
1122 * @return command.
1123 */
1124struct GNUNET_TESTING_Command
1125GNUNET_TESTING_cmd_netjail_start (const char *label,
1126 char *topology_config,
1127 unsigned int *read_file);
1128
1129
1130/**
1131 * Create command.
1132 *
1133 * @param label Name for the command.
1134 * @param topology The complete topology information.
1135 * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
1136 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
1137 * @return command.
1138 */
1139struct GNUNET_TESTING_Command
1140GNUNET_TESTING_cmd_netjail_start_testing_system (
1141 const char *label,
1142 struct GNUNET_TESTING_NetjailTopology *topology,
1143 unsigned int *read_file,
1144 char *topology_data);
1145
1146
1147/**
1148 * Create command.
1149 *
1150 * @param label name for command.
1151 * @param topology_config Configuration file for the test topology.
1152 * @return command.
1153 */
1154struct GNUNET_TESTING_Command
1155GNUNET_TESTING_cmd_netjail_stop (const char *label,
1156 char *topology_config,
1157 unsigned int *read_file);
1158
1159
1160/**
1161 * Create command.
1162 *
1163 * @param label name for command.
1164 * @param helper_start_label label of the cmd to start the test system.
1165 * @param topology The complete topology information.
1166 * @return command.
1167 */
1168struct GNUNET_TESTING_Command
1169GNUNET_TESTING_cmd_stop_testing_system (
1170 const char *label,
1171 const char *helper_start_label,
1172 struct GNUNET_TESTING_NetjailTopology *topology);
1173
1174
1175/**
1176 * Create a GNUNET_CMDS_LOCAL_FINISHED message.
1177 *
1178 * @param rv The result of the local test as GNUNET_GenericReturnValue.
1179 * @return The GNUNET_CMDS_LOCAL_FINISHED message.
1180*/
1181struct GNUNET_MessageHeader *
1182GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv);
1183
1184
1185/**
1186 * Function to get the trait with the async context.
1187 *
1188 * @param[out] ac GNUNET_TESTING_AsyncContext.
1189 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
1190 */
1191int
1192GNUNET_TESTING_get_trait_async_context (
1193 const struct GNUNET_TESTING_Command *cmd,
1194 struct GNUNET_TESTING_AsyncContext **ac);
1195
1196
1197/**
1198 * Offer handles to testing cmd helper from trait
1199 *
1200 * @param cmd command to extract the message from.
1201 * @param pt pointer to message.
1202 * @return #GNUNET_OK on success.
1203 */
1204enum GNUNET_GenericReturnValue
1205GNUNET_TESTING_get_trait_helper_handles (
1206 const struct GNUNET_TESTING_Command *cmd,
1207 struct GNUNET_HELPER_Handle ***helper);
1208
1209
1210struct GNUNET_TESTING_Command
1211GNUNET_TESTING_cmd_block_until_all_peers_started (
1212 const char *label,
1213 unsigned int *all_peers_started);
1214
1215
1216struct GNUNET_TESTING_Command
1217GNUNET_TESTING_cmd_block_until_external_trigger (
1218 const char *label);
1219
1220struct GNUNET_TESTING_Command
1221GNUNET_TESTING_cmd_send_peer_ready (const char *label,
1222 TESTING_CMD_HELPER_write_cb write_message);
1223
1224
1225/**
1226 * Create command.
1227 *
1228 * @param label name for command.
1229 * @param write_message Callback to write messages to the master loop.
1230 * @return command.
1231 */
1232struct GNUNET_TESTING_Command
1233GNUNET_TESTING_cmd_local_test_finished (
1234 const char *label,
1235 TESTING_CMD_HELPER_write_cb write_message);
1236
1237/**
1238 * Create command.
1239 *
1240 * @param label name for command.
1241 * @param write_message Callback to write messages to the master loop.
1242 * @param all_local_tests_prepared Flag which will be set from outside.
1243 * @return command.
1244 */
1245struct GNUNET_TESTING_Command
1246GNUNET_TESTING_cmd_local_test_prepared (const char *label,
1247 TESTING_CMD_HELPER_write_cb
1248 write_message);
1249
1250/**
1251 * Function to get the trait with the struct LocalPreparedState.
1252 *
1253 * @param[out] lfs struct LocalPreparedState.
1254 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
1255 *
1256 */
1257enum GNUNET_GenericReturnValue
1258GNUNET_TESTING_get_trait_local_prepared_state (
1259 const struct GNUNET_TESTING_Command *cmd,
1260 struct LocalPreparedState **lfs);
1261
1262#endif 906#endif
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index a994e16ee..546f4c0d2 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -221,7 +221,7 @@ check_for_message:
221 221
222 struct GNUNET_MESSENGER_Message message; 222 struct GNUNET_MESSENGER_Message message;
223 223
224 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)) 224 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO))
225 return GNUNET_NO; 225 return GNUNET_NO;
226 226
227 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL)) 227 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL))
@@ -310,7 +310,7 @@ callback_found_message (void *cls,
310 struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash); 310 struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
311 311
312 if (session) 312 if (session)
313 notify_handle_message (msg_client->handle, get_room_key(room), session, message, hash); 313 notify_handle_message (msg_client->handle, room, session, message, hash);
314} 314}
315 315
316static void 316static void
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index 2095f8b29..fa6830697 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -501,14 +501,14 @@ get_next_member_session_contect(const struct GNUNET_MESSENGER_MemberSession *ses
501 501
502static const struct GNUNET_MESSENGER_MemberSession* 502static const struct GNUNET_MESSENGER_MemberSession*
503get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, 503get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
504 struct GNUNET_MESSENGER_SrvRoom *room,
504 const struct GNUNET_HashCode *key) 505 const struct GNUNET_HashCode *key)
505{ 506{
506 GNUNET_assert((handle) && (key) && (handle->service)); 507 GNUNET_assert((handle) && (room) && (key) && (handle->service));
507 508
508 const struct GNUNET_ShortHashCode *id = get_handle_member_id(handle, key); 509 const struct GNUNET_ShortHashCode *id = get_handle_member_id(handle, key);
509 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room(handle->service, key);
510 510
511 if ((!id) || (!room)) 511 if (!id)
512 return NULL; 512 return NULL;
513 513
514 struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room); 514 struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room);
@@ -524,12 +524,14 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
524 524
525void 525void
526notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, 526notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
527 const struct GNUNET_HashCode *key, 527 struct GNUNET_MESSENGER_SrvRoom *room,
528 const struct GNUNET_MESSENGER_MemberSession *session, 528 const struct GNUNET_MESSENGER_MemberSession *session,
529 const struct GNUNET_MESSENGER_Message *message, 529 const struct GNUNET_MESSENGER_Message *message,
530 const struct GNUNET_HashCode *hash) 530 const struct GNUNET_HashCode *hash)
531{ 531{
532 GNUNET_assert((handle) && (key) && (session) && (message) && (hash)); 532 GNUNET_assert((handle) && (room) && (session) && (message) && (hash));
533
534 const struct GNUNET_HashCode *key = get_room_key(room);
533 535
534 if ((!handle->mq) || (!get_handle_member_id (handle, key))) 536 if ((!handle->mq) || (!get_handle_member_id (handle, key)))
535 { 537 {
@@ -575,7 +577,7 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
575 577
576 msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE; 578 msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE;
577 579
578 if (get_handle_member_session(handle, key) == session) 580 if (get_handle_member_session(handle, room, key) == session)
579 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT; 581 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT;
580 582
581 if (private_message) 583 if (private_message)
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h
index 97a984721..4438570b9 100644
--- a/src/messenger/gnunet-service-messenger_handle.h
+++ b/src/messenger/gnunet-service-messenger_handle.h
@@ -219,14 +219,14 @@ send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
219 * Notifies the handle that a new message was received or sent. 219 * Notifies the handle that a new message was received or sent.
220 * 220 *
221 * @param[in/out] handle Handle 221 * @param[in/out] handle Handle
222 * @param[in] key Key of room 222 * @param[in] room Room of the message
223 * @param[in] session Member session 223 * @param[in] session Member session
224 * @param[in] message Message 224 * @param[in] message Message
225 * @param[in] hash Hash of message 225 * @param[in] hash Hash of message
226 */ 226 */
227void 227void
228notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, 228notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
229 const struct GNUNET_HashCode *key, 229 struct GNUNET_MESSENGER_SrvRoom *room,
230 const struct GNUNET_MESSENGER_MemberSession *session, 230 const struct GNUNET_MESSENGER_MemberSession *session,
231 const struct GNUNET_MESSENGER_Message *message, 231 const struct GNUNET_MESSENGER_Message *message,
232 const struct GNUNET_HashCode *hash); 232 const struct GNUNET_HashCode *hash);
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c
index 56448997a..ce20ac924 100644
--- a/src/messenger/gnunet-service-messenger_message_store.c
+++ b/src/messenger/gnunet-service-messenger_message_store.c
@@ -427,7 +427,7 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store,
427 return NULL; 427 return NULL;
428 428
429 if ((GNUNET_DISK_file_read (store->storage_messages, buffer, entry->length) != entry->length) || 429 if ((GNUNET_DISK_file_read (store->storage_messages, buffer, entry->length) != entry->length) ||
430 (entry->length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))) 430 (entry->length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES)))
431 goto free_buffer; 431 goto free_buffer;
432 432
433 message = create_message (GNUNET_MESSENGER_KIND_UNKNOWN); 433 message = create_message (GNUNET_MESSENGER_KIND_UNKNOWN);
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index 920abb10e..d34665511 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -212,7 +212,9 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room,
212 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_room_key (room)), 212 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_room_key (room)),
213 GNUNET_sh2s (get_member_id(member))); 213 GNUNET_sh2s (get_member_id(member)));
214 214
215 if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), get_member_id(member))) 215 const struct GNUNET_ShortHashCode *member_id = get_member_id(member);
216
217 if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), member_id))
216 return GNUNET_NO; 218 return GNUNET_NO;
217 219
218 struct GNUNET_MESSENGER_Message *message = create_message_join (get_handle_ego (handle)); 220 struct GNUNET_MESSENGER_Message *message = create_message_join (get_handle_ego (handle));
@@ -224,6 +226,7 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room,
224 return GNUNET_NO; 226 return GNUNET_NO;
225 } 227 }
226 228
229 GNUNET_memcpy(&(message->header.sender_id), member_id, sizeof(*member_id));
227 return send_room_message (room, handle, message); 230 return send_room_message (room, handle, message);
228} 231}
229 232
@@ -262,7 +265,7 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify,
262 const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash)); 265 const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash));
263 266
264 if (message) 267 if (message)
265 notify_handle_message (notify->handle, get_room_key(notify->room), session, message, &(element->hash)); 268 notify_handle_message (notify->handle, notify->room, session, message, &(element->hash));
266 } 269 }
267} 270}
268 271
@@ -359,12 +362,7 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room,
359 const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room)); 362 const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
360 363
361 struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); 364 struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
362 struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, member_id); 365 struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, member_id);
363
364 if (member)
365 goto exit_open_room;
366
367 member = add_store_member(member_store, member_id);
368 366
369 if ((GNUNET_NO == join_room (room, handle, member)) && (room->port)) 367 if ((GNUNET_NO == join_room (room, handle, member)) && (room->port))
370 { 368 {
@@ -376,8 +374,9 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room,
376 return GNUNET_NO; 374 return GNUNET_NO;
377 } 375 }
378 376
379exit_open_room: 377 struct GNUNET_MESSENGER_Message *peer_msg = create_message_peer (room->service);
380 return (room->port ? send_room_message (room, handle, create_message_peer (room->service)) : GNUNET_NO); 378 GNUNET_memcpy(&(peer_msg->header.sender_id), member_id, sizeof(*member_id));
379 return (room->port ? send_room_message (room, handle, peer_msg) : GNUNET_NO);
381} 380}
382 381
383int 382int
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c
index 91165cf63..b53b72af8 100644
--- a/src/messenger/gnunet-service-messenger_service.c
+++ b/src/messenger/gnunet-service-messenger_service.c
@@ -313,7 +313,7 @@ handle_service_message (struct GNUNET_MESSENGER_Service *service,
313 313
314 while (element) 314 while (element)
315 { 315 {
316 notify_handle_message (element->handle, get_room_key(room), session, message, hash); 316 notify_handle_message (element->handle, room, session, message, hash);
317 element = element->next; 317 element = element->next;
318 } 318 }
319} 319}
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c
index c21f298b3..45c10c1af 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/messenger/gnunet-service-messenger_tunnel.c
@@ -122,7 +122,7 @@ check_tunnel_message (void *cls,
122 122
123 struct GNUNET_MESSENGER_Message message; 123 struct GNUNET_MESSENGER_Message message;
124 124
125 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)) 125 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES))
126 { 126 {
127 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Message too short! (%d)\n", length); 127 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Message too short! (%d)\n", length);
128 return GNUNET_SYSERR; 128 return GNUNET_SYSERR;
diff --git a/src/messenger/messenger.conf.in b/src/messenger/messenger.conf.in
index 59e11b166..6b54550ea 100644
--- a/src/messenger/messenger.conf.in
+++ b/src/messenger/messenger.conf.in
@@ -1,5 +1,6 @@
1[messenger] 1[messenger]
2START_ON_DEMAND = YES 2START_ON_DEMAND = YES
3RUN_PER_USER = YES
3PORT = 2097 4PORT = 2097
4HOSTNAME = localhost 5HOSTNAME = localhost
5BINARY = gnunet-service-messenger 6BINARY = gnunet-service-messenger
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index c9b143662..2db841315 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -208,7 +208,7 @@ check_recv_message (void *cls,
208 208
209 struct GNUNET_MESSENGER_Message message; 209 struct GNUNET_MESSENGER_Message message;
210 210
211 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)) 211 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES))
212 return GNUNET_NO; 212 return GNUNET_NO;
213 213
214 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL)) 214 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL))
@@ -255,8 +255,10 @@ handle_recv_message (void *cls,
255 255
256 handle_room_message (room, contact, &message, hash); 256 handle_room_message (room, contact, &message, hash);
257 257
258 const struct GNUNET_MESSENGER_Message *stored_message = get_room_message(room, hash);
259
258 if (handle->msg_callback) 260 if (handle->msg_callback)
259 handle->msg_callback (handle->msg_cls, room, contact, &message, hash, flags); 261 handle->msg_callback (handle->msg_cls, room, contact, stored_message, hash, flags);
260 } 262 }
261 else 263 else
262 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found\n"); 264 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found\n");
diff --git a/src/messenger/messenger_api_handle.c b/src/messenger/messenger_api_handle.c
index 516807e13..242389040 100644
--- a/src/messenger/messenger_api_handle.c
+++ b/src/messenger/messenger_api_handle.c
@@ -98,7 +98,7 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle)
98 98
99 clear_contact_store(get_handle_contact_store(handle)); 99 clear_contact_store(get_handle_contact_store(handle));
100 100
101 GNUNET_free(handle->name); 101 GNUNET_free(handle);
102} 102}
103 103
104void 104void
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index 4e64cc22f..496c98dbf 100644
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -229,13 +229,18 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
229typedef uint32_t kind_t; 229typedef uint32_t kind_t;
230 230
231uint16_t 231uint16_t
232get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind) 232get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind,
233 int include_header)
233{ 234{
234 uint16_t length = 0; 235 uint16_t length = 0;
235 236
236 length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp); 237 if (GNUNET_YES == include_header)
237 length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id); 238 {
238 length += member_size(struct GNUNET_MESSENGER_Message, header.previous); 239 length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp);
240 length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id);
241 length += member_size(struct GNUNET_MESSENGER_Message, header.previous);
242 }
243
239 length += sizeof(kind_t); 244 length += sizeof(kind_t);
240 245
241 return length + get_message_body_kind_size (kind); 246 return length + get_message_body_kind_size (kind);
@@ -279,16 +284,16 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind,
279 284
280uint16_t 285uint16_t
281get_message_size (const struct GNUNET_MESSENGER_Message *message, 286get_message_size (const struct GNUNET_MESSENGER_Message *message,
282 int include_signature) 287 int include_header)
283{ 288{
284 GNUNET_assert(message); 289 GNUNET_assert(message);
285 290
286 uint16_t length = 0; 291 uint16_t length = 0;
287 292
288 if (GNUNET_YES == include_signature) 293 if (GNUNET_YES == include_header)
289 length += GNUNET_IDENTITY_signature_get_length(&(message->header.signature)); 294 length += GNUNET_IDENTITY_signature_get_length(&(message->header.signature));
290 295
291 length += get_message_kind_size (message->header.kind); 296 length += get_message_kind_size (message->header.kind, include_header);
292 length += get_message_body_size (message->header.kind, &(message->body)); 297 length += get_message_body_size (message->header.kind, &(message->body));
293 298
294 return length; 299 return length;
@@ -314,7 +319,7 @@ calc_usual_padding ()
314 uint16_t kind_size; 319 uint16_t kind_size;
315 320
316 for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) { 321 for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) {
317 kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i); 322 kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, GNUNET_YES);
318 323
319 if (kind_size > padding) 324 if (kind_size > padding)
320 padding = kind_size; 325 padding = kind_size;
@@ -464,20 +469,24 @@ void
464encode_message (const struct GNUNET_MESSENGER_Message *message, 469encode_message (const struct GNUNET_MESSENGER_Message *message,
465 uint16_t length, 470 uint16_t length,
466 char *buffer, 471 char *buffer,
467 int include_signature) 472 int include_header)
468{ 473{
469 GNUNET_assert((message) && (buffer)); 474 GNUNET_assert((message) && (buffer));
470 475
471 uint16_t offset = 0; 476 uint16_t offset = 0;
472 477
473 if (GNUNET_YES == include_signature) 478 if (GNUNET_YES == include_header)
474 encode_step_signature(buffer, offset, &(message->header.signature), length); 479 encode_step_signature(buffer, offset, &(message->header.signature), length);
475 480
476 const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind); 481 const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind);
477 482
478 encode_step(buffer, offset, &(message->header.timestamp)); 483 if (GNUNET_YES == include_header)
479 encode_step(buffer, offset, &(message->header.sender_id)); 484 {
480 encode_step(buffer, offset, &(message->header.previous)); 485 encode_step(buffer, offset, &(message->header.timestamp));
486 encode_step(buffer, offset, &(message->header.sender_id));
487 encode_step(buffer, offset, &(message->header.previous));
488 }
489
481 encode_step(buffer, offset, &kind); 490 encode_step(buffer, offset, &kind);
482 491
483 encode_message_body (message->header.kind, &(message->body), length, buffer, offset); 492 encode_message_body (message->header.kind, &(message->body), length, buffer, offset);
@@ -619,14 +628,18 @@ int
619decode_message (struct GNUNET_MESSENGER_Message *message, 628decode_message (struct GNUNET_MESSENGER_Message *message,
620 uint16_t length, 629 uint16_t length,
621 const char *buffer, 630 const char *buffer,
622 int include_signature, 631 int include_header,
623 uint16_t *padding) 632 uint16_t *padding)
624{ 633{
625 GNUNET_assert((message) && (buffer) && (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))); 634 GNUNET_assert(
635 (message) &&
636 (buffer) &&
637 (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
638 );
626 639
627 uint16_t offset = 0; 640 uint16_t offset = 0;
628 641
629 if (GNUNET_YES == include_signature) 642 if (GNUNET_YES == include_header)
630 { 643 {
631 ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer( 644 ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer(
632 &(message->header.signature), buffer, length - offset 645 &(message->header.signature), buffer, length - offset
@@ -640,19 +653,23 @@ decode_message (struct GNUNET_MESSENGER_Message *message,
640 653
641 const uint16_t count = length - offset; 654 const uint16_t count = length - offset;
642 655
643 if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN)) 656 if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
644 return GNUNET_NO; 657 return GNUNET_NO;
645 658
646 kind_t kind; 659 kind_t kind;
647 660
648 decode_step(buffer, offset, &(message->header.timestamp)); 661 if (GNUNET_YES == include_header)
649 decode_step(buffer, offset, &(message->header.sender_id)); 662 {
650 decode_step(buffer, offset, &(message->header.previous)); 663 decode_step(buffer, offset, &(message->header.timestamp));
664 decode_step(buffer, offset, &(message->header.sender_id));
665 decode_step(buffer, offset, &(message->header.previous));
666 }
667
651 decode_step(buffer, offset, &kind); 668 decode_step(buffer, offset, &kind);
652 669
653 message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind); 670 message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind);
654 671
655 if (count < get_message_kind_size (message->header.kind)) 672 if (count < get_message_kind_size (message->header.kind, include_header))
656 return GNUNET_NO; 673 return GNUNET_NO;
657 674
658 const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset); 675 const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset);
diff --git a/src/messenger/messenger_api_message.h b/src/messenger/messenger_api_message.h
index 21161c134..46c5cb024 100644
--- a/src/messenger/messenger_api_message.h
+++ b/src/messenger/messenger_api_message.h
@@ -90,21 +90,23 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message);
90 * Returns the minimal size in bytes to encode a message of a specific <i>kind</i>. 90 * Returns the minimal size in bytes to encode a message of a specific <i>kind</i>.
91 * 91 *
92 * @param[in] kind Kind of message 92 * @param[in] kind Kind of message
93 * @param[in] include_header Flag to include header
93 * @return Minimal size to encode 94 * @return Minimal size to encode
94 */ 95 */
95uint16_t 96uint16_t
96get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind); 97get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind,
98 int include_header);
97 99
98/** 100/**
99 * Returns the exact size in bytes to encode a given <i>message</i>. 101 * Returns the exact size in bytes to encode a given <i>message</i>.
100 * 102 *
101 * @param[in] message Message 103 * @param[in] message Message
102 * @param[in] encode_signature Flag to include signature 104 * @param[in] include_header Flag to include header
103 * @return Size to encode 105 * @return Size to encode
104 */ 106 */
105uint16_t 107uint16_t
106get_message_size (const struct GNUNET_MESSENGER_Message *message, 108get_message_size (const struct GNUNET_MESSENGER_Message *message,
107 int include_signature); 109 int include_header);
108 110
109/** 111/**
110 * Encodes a given <i>message</i> into a <i>buffer</i> of a maximal <i>length</i> in bytes. 112 * Encodes a given <i>message</i> into a <i>buffer</i> of a maximal <i>length</i> in bytes.
@@ -112,13 +114,13 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message,
112 * @param[in] message Message 114 * @param[in] message Message
113 * @param[in] length Maximal length to encode 115 * @param[in] length Maximal length to encode
114 * @param[out] buffer Buffer 116 * @param[out] buffer Buffer
115 * @param[in] encode_signature Flag to include signature 117 * @param[in] include_header Flag to include header
116 */ 118 */
117void 119void
118encode_message (const struct GNUNET_MESSENGER_Message *message, 120encode_message (const struct GNUNET_MESSENGER_Message *message,
119 uint16_t length, 121 uint16_t length,
120 char *buffer, 122 char *buffer,
121 int include_signature); 123 int include_header);
122 124
123/** 125/**
124 * Decodes a <i>message</i> from a given <i>buffer</i> of a maximal <i>length</i> in bytes. 126 * Decodes a <i>message</i> from a given <i>buffer</i> of a maximal <i>length</i> in bytes.
@@ -131,6 +133,7 @@ encode_message (const struct GNUNET_MESSENGER_Message *message,
131 * @param[out] message Message 133 * @param[out] message Message
132 * @param[in] length Maximal length to decode 134 * @param[in] length Maximal length to decode
133 * @param[in] buffer Buffer 135 * @param[in] buffer Buffer
136 * @param[in] include_header Flag to include header
134 * @param[out] padding Padding 137 * @param[out] padding Padding
135 * @return #GNUNET_YES on success, otherwise #GNUNET_NO 138 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
136 */ 139 */
@@ -138,7 +141,7 @@ int
138decode_message (struct GNUNET_MESSENGER_Message *message, 141decode_message (struct GNUNET_MESSENGER_Message *message,
139 uint16_t length, 142 uint16_t length,
140 const char *buffer, 143 const char *buffer,
141 int include_signature, 144 int include_header,
142 uint16_t *padding); 145 uint16_t *padding);
143 146
144/** 147/**
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index 4622b1428..20e7b6ec6 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -311,7 +311,8 @@ handle_address_change_notification (
311 * @param error details about the error 311 * @param error details about the error
312 */ 312 */
313static void 313static void
314mq_error_handler (void *cls, enum GNUNET_MQ_Error error) 314mq_error_handler (void *cls,
315 enum GNUNET_MQ_Error error)
315{ 316{
316 struct GNUNET_NAT_Handle *nh = cls; 317 struct GNUNET_NAT_Handle *nh = cls;
317 318
@@ -328,29 +329,36 @@ static void
328do_connect (void *cls) 329do_connect (void *cls)
329{ 330{
330 struct GNUNET_NAT_Handle *nh = cls; 331 struct GNUNET_NAT_Handle *nh = cls;
331 struct GNUNET_MQ_MessageHandler handlers[] = 332 struct GNUNET_MQ_MessageHandler handlers[] = {
332 { GNUNET_MQ_hd_var_size (connection_reversal_request, 333 GNUNET_MQ_hd_var_size (
333 GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED, 334 connection_reversal_request,
334 struct 335 GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED,
335 GNUNET_NAT_ConnectionReversalRequestedMessage, 336 struct GNUNET_NAT_ConnectionReversalRequestedMessage,
336 nh), 337 nh),
337 GNUNET_MQ_hd_var_size (address_change_notification, 338 GNUNET_MQ_hd_var_size (
338 GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE, 339 address_change_notification,
339 struct GNUNET_NAT_AddressChangeNotificationMessage, 340 GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE,
340 nh), 341 struct GNUNET_NAT_AddressChangeNotificationMessage,
341 GNUNET_MQ_handler_end () }; 342 nh),
343 GNUNET_MQ_handler_end ()
344 };
342 struct GNUNET_MQ_Envelope *env; 345 struct GNUNET_MQ_Envelope *env;
343 346
344 nh->reconnect_task = NULL; 347 nh->reconnect_task = NULL;
345 nh->mq = 348 nh->mq =
346 GNUNET_CLIENT_connect (nh->cfg, "nat", handlers, &mq_error_handler, nh); 349 GNUNET_CLIENT_connect (nh->cfg,
350 "nat",
351 handlers,
352 &mq_error_handler,
353 nh);
347 if (NULL == nh->mq) 354 if (NULL == nh->mq)
348 { 355 {
349 reconnect (nh); 356 reconnect (nh);
350 return; 357 return;
351 } 358 }
352 env = GNUNET_MQ_msg_copy (nh->reg); 359 env = GNUNET_MQ_msg_copy (nh->reg);
353 GNUNET_MQ_send (nh->mq, env); 360 GNUNET_MQ_send (nh->mq,
361 env);
354} 362}
355 363
356 364
@@ -396,8 +404,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
396 len += addrlens[i]; 404 len += addrlens[i];
397 str_len = strlen (config_section) + 1; 405 str_len = strlen (config_section) + 1;
398 len += str_len; 406 len += str_len;
399 if ((len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) || 407 if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) ||
400 (num_addrs > UINT16_MAX)) 408 (num_addrs > UINT16_MAX) ||
409 (str_len > UINT16_MAX) )
401 { 410 {
402 GNUNET_break (0); 411 GNUNET_break (0);
403 return NULL; 412 return NULL;
@@ -475,7 +484,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
475 * @return #GNUNET_YES if @a data is a STUN packet, 484 * @return #GNUNET_YES if @a data is a STUN packet,
476 * #GNUNET_NO if the packet is invalid (not a stun packet) 485 * #GNUNET_NO if the packet is invalid (not a stun packet)
477 */ 486 */
478static int 487static enum GNUNET_GenericReturnValue
479test_stun_packet (const void *data, size_t len) 488test_stun_packet (const void *data, size_t len)
480{ 489{
481 const struct stun_header *hdr; 490 const struct stun_header *hdr;
diff --git a/src/pq/pq_prepare.c b/src/pq/pq_prepare.c
index 63087456f..76fc5c374 100644
--- a/src/pq/pq_prepare.c
+++ b/src/pq/pq_prepare.c
@@ -58,7 +58,7 @@ GNUNET_PQ_make_prepare (const char *name,
58 * @return #GNUNET_OK on success, 58 * @return #GNUNET_OK on success,
59 * #GNUNET_SYSERR on error 59 * #GNUNET_SYSERR on error
60 */ 60 */
61int 61enum GNUNET_GenericReturnValue
62GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db, 62GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
63 const struct GNUNET_PQ_PreparedStatement *ps) 63 const struct GNUNET_PQ_PreparedStatement *ps)
64{ 64{
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index cefb66b8f..da5f90409 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -521,7 +521,7 @@ iter_cb (void *cls,
521 char *id; 521 char *id;
522 const char *attr_type; 522 const char *attr_type;
523 523
524 if ((NULL != attr_name) && (NULL != claim)) 524 if ((NULL != attr_name) && (NULL == claim))
525 { 525 {
526 if (0 == strcasecmp (attr_name, attr->name)) 526 if (0 == strcasecmp (attr_name, attr->name))
527 { 527 {
@@ -530,6 +530,7 @@ iter_cb (void *cls,
530 attr->type, 530 attr->type,
531 attr->data, 531 attr->data,
532 attr->data_size); 532 attr->data_size);
533 claim->id = attr->id;
533 } 534 }
534 } 535 }
535 else if (issue_attrs) 536 else if (issue_attrs)
@@ -830,7 +831,7 @@ main (int argc, char *const argv[])
830 GNUNET_GETOPT_option_string ('a', 831 GNUNET_GETOPT_option_string ('a',
831 "add", 832 "add",
832 "NAME", 833 "NAME",
833 gettext_noop ("Add an attribute NAME"), 834 gettext_noop ("Add or update an attribute NAME"),
834 &attr_name), 835 &attr_name),
835 GNUNET_GETOPT_option_string ('d', 836 GNUNET_GETOPT_option_string ('d',
836 "delete", 837 "delete",
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index f90cc3cc4..5ff7c04ea 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -415,8 +415,6 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
415 plugin->n, plugin->local_m, ni->topology_data, 415 plugin->n, plugin->local_m, ni->topology_data,
416 ni->read_file); 416 ni->read_file);
417 417
418 GNUNET_free (binary);
419
420 msg_length = sizeof(struct GNUNET_CMDS_HelperReply); 418 msg_length = sizeof(struct GNUNET_CMDS_HelperReply);
421 reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); 419 reply = GNUNET_new (struct GNUNET_CMDS_HelperReply);
422 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); 420 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY);
@@ -424,6 +422,10 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
424 422
425 write_message ((struct GNUNET_MessageHeader *) reply, msg_length); 423 write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
426 424
425 GNUNET_free (binary);
426 GNUNET_free (router_ip);
427 GNUNET_free (plugin_name);
428
427 return GNUNET_OK; 429 return GNUNET_OK;
428 } 430 }
429 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( 431 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
diff --git a/src/testing/testing.c b/src/testing/testing.c
index ced04e65d..9e664292b 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1838,7 +1838,7 @@ get_first_string_value (char *line)
1838 memcpy (copy, line, slen); 1838 memcpy (copy, line, slen);
1839 token = strtok_r (copy, ":", &rest); 1839 token = strtok_r (copy, ":", &rest);
1840 token = strtok_r (NULL, ":", &rest); 1840 token = strtok_r (NULL, ":", &rest);
1841 LOG (GNUNET_ERROR_TYPE_ERROR, 1841 LOG (GNUNET_ERROR_TYPE_DEBUG,
1842 "first token %s\n", 1842 "first token %s\n",
1843 token); 1843 token);
1844 slen_token = strlen (token); 1844 slen_token = strlen (token);
@@ -1924,7 +1924,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1924 node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE; 1924 node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE;
1925 token = strtok_r (NULL, ":", &rest); 1925 token = strtok_r (NULL, ":", &rest);
1926 GNUNET_assert (1 == sscanf (token, "%u", &node_n)); 1926 GNUNET_assert (1 == sscanf (token, "%u", &node_n));
1927 LOG (GNUNET_ERROR_TYPE_ERROR, 1927 LOG (GNUNET_ERROR_TYPE_DEBUG,
1928 "node_n %u\n", 1928 "node_n %u\n",
1929 node_n); 1929 node_n);
1930 node_connection->node_n = node_n; 1930 node_connection->node_n = node_n;
@@ -1939,7 +1939,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1939 token = strtok_r (NULL, ":", &rest); 1939 token = strtok_r (NULL, ":", &rest);
1940 sscanf (token, "%u", &node_n); 1940 sscanf (token, "%u", &node_n);
1941 node_connection->node_n = node_n; 1941 node_connection->node_n = node_n;
1942 LOG (GNUNET_ERROR_TYPE_ERROR, 1942 LOG (GNUNET_ERROR_TYPE_DEBUG,
1943 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n", 1943 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
1944 node_n, 1944 node_n,
1945 namespace_n, 1945 namespace_n,
@@ -1963,14 +1963,14 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1963 memcpy (prefix->address_prefix, token, slen); 1963 memcpy (prefix->address_prefix, token, slen);
1964 } 1964 }
1965 1965
1966 LOG (GNUNET_ERROR_TYPE_ERROR, 1966 LOG (GNUNET_ERROR_TYPE_DEBUG,
1967 "address_prefix %s\n", 1967 "address_prefix %s\n",
1968 prefix->address_prefix); 1968 prefix->address_prefix);
1969 1969
1970 GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, 1970 GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head,
1971 node_connection->address_prefixes_tail, 1971 node_connection->address_prefixes_tail,
1972 prefix); 1972 prefix);
1973 LOG (GNUNET_ERROR_TYPE_ERROR, 1973 LOG (GNUNET_ERROR_TYPE_DEBUG,
1974 "address_prefix %s\n", 1974 "address_prefix %s\n",
1975 prefix->address_prefix); 1975 prefix->address_prefix);
1976 } 1976 }
@@ -2028,7 +2028,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2028 struct GNUNET_TESTING_NodeConnection *pos_connection; 2028 struct GNUNET_TESTING_NodeConnection *pos_connection;
2029 struct GNUNET_TESTING_AddressPrefix *pos_prefix; 2029 struct GNUNET_TESTING_AddressPrefix *pos_prefix;
2030 2030
2031 LOG (GNUNET_ERROR_TYPE_ERROR, 2031 LOG (GNUNET_ERROR_TYPE_DEBUG,
2032 "plugin: %s space: %u node: %u global: %u\n", 2032 "plugin: %s space: %u node: %u global: %u\n",
2033 node->plugin, 2033 node->plugin,
2034 node->namespace_n, 2034 node->namespace_n,
@@ -2039,7 +2039,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2039 pos_connection = pos_connection->next) 2039 pos_connection = pos_connection->next)
2040 { 2040 {
2041 2041
2042 LOG (GNUNET_ERROR_TYPE_ERROR, 2042 LOG (GNUNET_ERROR_TYPE_DEBUG,
2043 "namespace_n: %u node_n: %u node_type: %u\n", 2043 "namespace_n: %u node_n: %u node_type: %u\n",
2044 pos_connection->namespace_n, 2044 pos_connection->namespace_n,
2045 pos_connection->node_n, 2045 pos_connection->node_n,
@@ -2049,7 +2049,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2049 pos_prefix = 2049 pos_prefix =
2050 pos_prefix->next) 2050 pos_prefix->next)
2051 { 2051 {
2052 LOG (GNUNET_ERROR_TYPE_ERROR, 2052 LOG (GNUNET_ERROR_TYPE_DEBUG,
2053 "prefix: %s\n", 2053 "prefix: %s\n",
2054 pos_prefix->address_prefix); 2054 pos_prefix->address_prefix);
2055 } 2055 }
@@ -2071,7 +2071,7 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2071static int 2071static int
2072log_topo (struct GNUNET_TESTING_NetjailTopology *topology) 2072log_topo (struct GNUNET_TESTING_NetjailTopology *topology)
2073{ 2073{
2074 LOG (GNUNET_ERROR_TYPE_ERROR, 2074 LOG (GNUNET_ERROR_TYPE_DEBUG,
2075 "plugin: %s spaces: %u nodes: %u known: %u\n", 2075 "plugin: %s spaces: %u nodes: %u known: %u\n",
2076 topology->plugin, 2076 topology->plugin,
2077 topology->namespaces_n, 2077 topology->namespaces_n,
@@ -2218,6 +2218,8 @@ free_nodes_cb (void *cls,
2218 GNUNET_free (pos_connection); 2218 GNUNET_free (pos_connection);
2219 pos_connection = tmp_connection; 2219 pos_connection = tmp_connection;
2220 } 2220 }
2221 GNUNET_free (node->plugin);
2222 GNUNET_free (node);
2221 return GNUNET_OK; 2223 return GNUNET_OK;
2222} 2224}
2223 2225
@@ -2248,8 +2250,11 @@ GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology)
2248{ 2250{
2249 GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, 2251 GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces,
2250 free_namespaces_cb, NULL); 2252 free_namespaces_cb, NULL);
2253 GNUNET_CONTAINER_multishortmap_destroy (topology->map_namespaces);
2251 GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb, 2254 GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb,
2252 NULL); 2255 NULL);
2256 GNUNET_CONTAINER_multishortmap_destroy (topology->map_globals);
2257 GNUNET_free (topology->plugin);
2253 GNUNET_free (topology); 2258 GNUNET_free (topology);
2254} 2259}
2255 2260
@@ -2294,7 +2299,7 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
2294 char *addr; 2299 char *addr;
2295 char *template; 2300 char *template;
2296 2301
2297 LOG (GNUNET_ERROR_TYPE_ERROR, 2302 LOG (GNUNET_ERROR_TYPE_DEBUG,
2298 "node_n: %u\n", 2303 "node_n: %u\n",
2299 connection->node_n); 2304 connection->node_n);
2300 2305
@@ -2374,7 +2379,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2374 char *key = NULL; 2379 char *key = NULL;
2375 unsigned int out; 2380 unsigned int out;
2376 char *rest = NULL; 2381 char *rest = NULL;
2377 char *value; 2382 char *value = NULL;
2378 char *value2; 2383 char *value2;
2379 int ret; 2384 int ret;
2380 struct GNUNET_TESTING_NetjailTopology *topo; 2385 struct GNUNET_TESTING_NetjailTopology *topo;
@@ -2384,9 +2389,6 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2384 struct GNUNET_ShortHashCode *hkey; 2389 struct GNUNET_ShortHashCode *hkey;
2385 struct GNUNET_HashCode hc; 2390 struct GNUNET_HashCode hc;
2386 2391
2387 LOG (GNUNET_ERROR_TYPE_DEBUG,
2388 "data %s\n",
2389 data);
2390 token = strtok_r (data, "\n", &rest); 2392 token = strtok_r (data, "\n", &rest);
2391 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); 2393 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
2392 topo->map_namespaces = 2394 topo->map_namespaces =
@@ -2399,46 +2401,46 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2399 if (NULL != key) 2401 if (NULL != key)
2400 free (key); 2402 free (key);
2401 key = get_key (token); 2403 key = get_key (token);
2402 LOG (GNUNET_ERROR_TYPE_ERROR, 2404 LOG (GNUNET_ERROR_TYPE_DEBUG,
2403 "In the loop with token: %s beginning with %s\n", 2405 "In the loop with token: %s beginning with %s\n",
2404 token, 2406 token,
2405 key); 2407 key);
2406 if (0 == strcmp (key, "M")) 2408 if (0 == strcmp (key, "M"))
2407 { 2409 {
2408 LOG (GNUNET_ERROR_TYPE_ERROR, 2410 LOG (GNUNET_ERROR_TYPE_DEBUG,
2409 "Get first Value for M.\n"); 2411 "Get first Value for M.\n");
2410 out = get_first_value (token); 2412 out = get_first_value (token);
2411 LOG (GNUNET_ERROR_TYPE_ERROR, 2413 LOG (GNUNET_ERROR_TYPE_DEBUG,
2412 "M: %u\n", 2414 "M: %u\n",
2413 out); 2415 out);
2414 topo->nodes_m = out; 2416 topo->nodes_m = out;
2415 } 2417 }
2416 else if (0 == strcmp (key, "N")) 2418 else if (0 == strcmp (key, "N"))
2417 { 2419 {
2418 LOG (GNUNET_ERROR_TYPE_ERROR, 2420 LOG (GNUNET_ERROR_TYPE_DEBUG,
2419 "Get first Value for N.\n"); 2421 "Get first Value for N.\n");
2420 out = get_first_value (token); 2422 out = get_first_value (token);
2421 LOG (GNUNET_ERROR_TYPE_ERROR, 2423 LOG (GNUNET_ERROR_TYPE_DEBUG,
2422 "N: %u\n", 2424 "N: %u\n",
2423 out); 2425 out);
2424 topo->namespaces_n = out; 2426 topo->namespaces_n = out;
2425 } 2427 }
2426 else if (0 == strcmp (key, "X")) 2428 else if (0 == strcmp (key, "X"))
2427 { 2429 {
2428 LOG (GNUNET_ERROR_TYPE_ERROR, 2430 LOG (GNUNET_ERROR_TYPE_DEBUG,
2429 "Get first Value for X.\n"); 2431 "Get first Value for X.\n");
2430 out = get_first_value (token); 2432 out = get_first_value (token);
2431 LOG (GNUNET_ERROR_TYPE_ERROR, 2433 LOG (GNUNET_ERROR_TYPE_DEBUG,
2432 "X: %u\n", 2434 "X: %u\n",
2433 out); 2435 out);
2434 topo->nodes_x = out; 2436 topo->nodes_x = out;
2435 } 2437 }
2436 else if (0 == strcmp (key, "T")) 2438 else if (0 == strcmp (key, "T"))
2437 { 2439 {
2438 LOG (GNUNET_ERROR_TYPE_ERROR, 2440 LOG (GNUNET_ERROR_TYPE_DEBUG,
2439 "Get first string value for T.\n"); 2441 "Get first string value for T.\n");
2440 value = get_first_string_value (token); 2442 value = get_first_string_value (token);
2441 LOG (GNUNET_ERROR_TYPE_ERROR, 2443 LOG (GNUNET_ERROR_TYPE_DEBUG,
2442 "value: %s\n", 2444 "value: %s\n",
2443 value); 2445 value);
2444 topo->plugin = value; 2446 topo->plugin = value;
@@ -2448,10 +2450,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2448 hkey = GNUNET_new (struct GNUNET_ShortHashCode); 2450 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2449 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); 2451 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2450 2452
2451 LOG (GNUNET_ERROR_TYPE_ERROR, 2453 LOG (GNUNET_ERROR_TYPE_DEBUG,
2452 "Get first Value for K.\n"); 2454 "Get first Value for K.\n");
2453 out = get_first_value (token); 2455 out = get_first_value (token);
2454 LOG (GNUNET_ERROR_TYPE_ERROR, 2456 LOG (GNUNET_ERROR_TYPE_DEBUG,
2455 "K: %u\n", 2457 "K: %u\n",
2456 out); 2458 out);
2457 node->node_n = out; 2459 node->node_n = out;
@@ -2470,10 +2472,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2470 hkey, 2472 hkey,
2471 node, 2473 node,
2472 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2474 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2473 LOG (GNUNET_ERROR_TYPE_ERROR, 2475 LOG (GNUNET_ERROR_TYPE_DEBUG,
2474 "Get value for key value on K.\n"); 2476 "Get value for key value on K.\n");
2475 value = get_value ("plugin", token); 2477 value = get_value ("plugin", token);
2476 LOG (GNUNET_ERROR_TYPE_ERROR, 2478 LOG (GNUNET_ERROR_TYPE_DEBUG,
2477 "value: %s\n", 2479 "value: %s\n",
2478 value); 2480 value);
2479 node->plugin = value; 2481 node->plugin = value;
@@ -2485,10 +2487,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2485 router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); 2487 router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
2486 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); 2488 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2487 2489
2488 LOG (GNUNET_ERROR_TYPE_ERROR, 2490 LOG (GNUNET_ERROR_TYPE_DEBUG,
2489 "Get first Value for R.\n"); 2491 "Get first Value for R.\n");
2490 out = get_first_value (token); 2492 out = get_first_value (token);
2491 LOG (GNUNET_ERROR_TYPE_ERROR, 2493 LOG (GNUNET_ERROR_TYPE_DEBUG,
2492 "R: %u\n", 2494 "R: %u\n",
2493 out); 2495 out);
2494 node->node_n = out; 2496 node->node_n = out;
@@ -2496,22 +2498,22 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2496 memcpy (hkey, 2498 memcpy (hkey,
2497 &hc, 2499 &hc,
2498 sizeof (*hkey)); 2500 sizeof (*hkey));
2499 LOG (GNUNET_ERROR_TYPE_ERROR, 2501 LOG (GNUNET_ERROR_TYPE_DEBUG,
2500 "Get value for key tcp_port on R.\n"); 2502 "Get value for key tcp_port on R.\n");
2501 value = get_value ("tcp_port", token); 2503 value = get_value ("tcp_port", token);
2502 LOG (GNUNET_ERROR_TYPE_ERROR, 2504 LOG (GNUNET_ERROR_TYPE_DEBUG,
2503 "tcp_port: %s\n", 2505 "tcp_port: %s\n",
2504 value); 2506 value);
2505 ret = sscanf (value, "%u", &(router->tcp_port)); 2507 ret = sscanf (value, "%u", &(router->tcp_port));
2506 2508
2507 GNUNET_break (0 != ret && 1 >= router->tcp_port); 2509 GNUNET_break (0 != ret && 1 >= router->tcp_port);
2508 2510
2509 LOG (GNUNET_ERROR_TYPE_ERROR, 2511 LOG (GNUNET_ERROR_TYPE_DEBUG,
2510 "Get value for key udp_port on R.\n"); 2512 "Get value for key udp_port on R.\n");
2511 value2 = get_value ("udp_port", token); 2513 value2 = get_value ("udp_port", token);
2512 ret = sscanf (value2, "%u", &(router->udp_port)); 2514 ret = sscanf (value2, "%u", &(router->udp_port));
2513 GNUNET_break (0 != ret && 1 >= router->udp_port); 2515 GNUNET_break (0 != ret && 1 >= router->udp_port);
2514 LOG (GNUNET_ERROR_TYPE_ERROR, 2516 LOG (GNUNET_ERROR_TYPE_DEBUG,
2515 "udp_port: %s\n", 2517 "udp_port: %s\n",
2516 value2); 2518 value2);
2517 2519
@@ -2540,10 +2542,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2540 hkey = GNUNET_new (struct GNUNET_ShortHashCode); 2542 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2541 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); 2543 node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2542 2544
2543 LOG (GNUNET_ERROR_TYPE_ERROR, 2545 LOG (GNUNET_ERROR_TYPE_DEBUG,
2544 "Get first Value for P.\n"); 2546 "Get first Value for P.\n");
2545 out = get_first_value (token); 2547 out = get_first_value (token);
2546 LOG (GNUNET_ERROR_TYPE_ERROR, 2548 LOG (GNUNET_ERROR_TYPE_DEBUG,
2547 "P: %u\n", 2549 "P: %u\n",
2548 out); 2550 out);
2549 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2551 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
@@ -2568,10 +2570,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2568 namespace, 2570 namespace,
2569 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2571 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2570 } 2572 }
2571 LOG (GNUNET_ERROR_TYPE_ERROR, 2573 LOG (GNUNET_ERROR_TYPE_DEBUG,
2572 "Get second Value for P.\n"); 2574 "Get second Value for P.\n");
2573 out = get_second_value (token); 2575 out = get_second_value (token);
2574 LOG (GNUNET_ERROR_TYPE_ERROR, 2576 LOG (GNUNET_ERROR_TYPE_DEBUG,
2575 "P: %u\n", 2577 "P: %u\n",
2576 out); 2578 out);
2577 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2579 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
@@ -2591,10 +2593,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2591 hkey, 2593 hkey,
2592 node, 2594 node,
2593 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2595 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2594 LOG (GNUNET_ERROR_TYPE_ERROR, 2596 LOG (GNUNET_ERROR_TYPE_DEBUG,
2595 "Get value for key plugin on P.\n"); 2597 "Get value for key plugin on P.\n");
2596 value = get_value ("plugin", token); 2598 value = get_value ("plugin", token);
2597 LOG (GNUNET_ERROR_TYPE_ERROR, 2599 LOG (GNUNET_ERROR_TYPE_DEBUG,
2598 "plugin: %s\n", 2600 "plugin: %s\n",
2599 value); 2601 value);
2600 node->plugin = value; 2602 node->plugin = value;
@@ -2605,10 +2607,14 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2605 } 2607 }
2606 token = strtok_r (NULL, "\n", &rest); 2608 token = strtok_r (NULL, "\n", &rest);
2607 if (NULL != token) 2609 if (NULL != token)
2608 LOG (GNUNET_ERROR_TYPE_ERROR, 2610 LOG (GNUNET_ERROR_TYPE_DEBUG,
2609 "Next token %s\n", 2611 "Next token %s\n",
2610 token); 2612 token);
2611 } 2613 }
2614 if (NULL != key)
2615 GNUNET_free (key);
2616 /*if (NULL != value)
2617 GNUNET_free (value);*/
2612 2618
2613 return topo; 2619 return topo;
2614} 2620}
@@ -2642,7 +2648,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2642 filename); 2648 filename);
2643 return NULL; 2649 return NULL;
2644 } 2650 }
2645 data = GNUNET_malloc (fs); 2651 data = GNUNET_malloc (fs + 1);
2646 if (fs != GNUNET_DISK_fn_read (filename, data, fs)) 2652 if (fs != GNUNET_DISK_fn_read (filename, data, fs))
2647 { 2653 {
2648 LOG (GNUNET_ERROR_TYPE_ERROR, 2654 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -2653,9 +2659,8 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2653 } 2659 }
2654 2660
2655 LOG (GNUNET_ERROR_TYPE_DEBUG, 2661 LOG (GNUNET_ERROR_TYPE_DEBUG,
2656 "data: %s\n", 2662 "file lenght %lu\n",
2657 data); 2663 fs);
2658
2659 data[fs] = '\0'; 2664 data[fs] = '\0';
2660 2665
2661 topo = GNUNET_TESTING_get_topo_from_string (data); 2666 topo = GNUNET_TESTING_get_topo_from_string (data);
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c
index 7ff554280..9360dd02e 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -33,23 +33,6 @@
33 */ 33 */
34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
35 35
36/**
37 * Struct with information for callbacks.
38 *
39 */
40struct BlockState
41{
42 /**
43 * Context for our asynchronous completion.
44 */
45 struct GNUNET_TESTING_AsyncContext ac;
46
47 /**
48 * The label of this command.
49 */
50 const char *label;
51};
52
53 36
54/** 37/**
55 * The cleanup function of this cmd frees resources the cmd allocated. 38 * The cleanup function of this cmd frees resources the cmd allocated.
@@ -77,6 +60,11 @@ block_until_external_trigger_traits (void *cls,
77 .trait_name = "async_context", 60 .trait_name = "async_context",
78 .ptr = (const void *) ac, 61 .ptr = (const void *) ac,
79 }, 62 },
63 {
64 .index = 1,
65 .trait_name = "block_state",
66 .ptr = (const void *) bs,
67 },
80 GNUNET_TESTING_trait_end () 68 GNUNET_TESTING_trait_end ()
81 }; 69 };
82 70
@@ -88,9 +76,27 @@ block_until_external_trigger_traits (void *cls,
88 76
89 77
90/** 78/**
79 * Function to get the trait with the internal command state BlockState.
80 *
81 * * @param[out] ac struct BlockState.
82* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
83 */
84int
85GNUNET_TESTING_get_trait_block_state (
86 const struct GNUNET_TESTING_Command *cmd,
87 struct BlockState **bs)
88{
89 return cmd->traits (cmd->cls,
90 (const void **) bs,
91 "block_state",
92 (unsigned int) 1);
93}
94
95
96/**
91 * Function to get the trait with the async context. 97 * Function to get the trait with the async context.
92 * 98 *
93 * @param[out] ac GNUNET_TESTING_AsyncContext. 99 * @param[out] ac struct GNUNET_TESTING_AsyncContext.
94 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. 100 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
95 */ 101 */
96int 102int
@@ -114,10 +120,20 @@ block_until_all_peers_started_run (void *cls,
114 struct GNUNET_TESTING_Interpreter *is) 120 struct GNUNET_TESTING_Interpreter *is)
115{ 121{
116 struct BlockState *bs = cls; 122 struct BlockState *bs = cls;
123 struct GNUNET_TESTING_Command *cmd =
124 GNUNET_TESTING_interpreter_get_current_command (is);
117 125
118 LOG (GNUNET_ERROR_TYPE_DEBUG, 126 LOG (GNUNET_ERROR_TYPE_DEBUG,
119 "block %s running!\n", 127 "block %s running %u!\n",
120 bs->label); 128 bs->label,
129 bs->asynchronous_finish);
130 if (GNUNET_YES == bs->asynchronous_finish)
131 {
132 LOG (GNUNET_ERROR_TYPE_DEBUG,
133 "block %s running asynchronous!\n",
134 bs->label);
135 cmd->asynchronous_finish = bs->asynchronous_finish;
136 }
121} 137}
122 138
123 139
@@ -126,15 +142,18 @@ block_until_all_peers_started_run (void *cls,
126 * 142 *
127 * @param label name for command. 143 * @param label name for command.
128 * @param all_peers_started Flag which will be set from outside. 144 * @param all_peers_started Flag which will be set from outside.
145 * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL.
129 * @return command. 146 * @return command.
130 */ 147 */
131struct GNUNET_TESTING_Command 148struct GNUNET_TESTING_Command
132GNUNET_TESTING_cmd_block_until_external_trigger (const char *label) 149GNUNET_TESTING_cmd_block_until_external_trigger (
150 const char *label)
133{ 151{
134 struct BlockState *bs; 152 struct BlockState *bs;
135 153
136 bs = GNUNET_new (struct BlockState); 154 bs = GNUNET_new (struct BlockState);
137 bs->label = label; 155 bs->label = label;
156 bs->asynchronous_finish = GNUNET_NO;
138 { 157 {
139 struct GNUNET_TESTING_Command cmd = { 158 struct GNUNET_TESTING_Command cmd = {
140 .cls = bs, 159 .cls = bs,
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c
index 2ff70c33e..6cd648c3a 100644
--- a/src/testing/testing_api_cmd_netjail_start.c
+++ b/src/testing/testing_api_cmd_netjail_start.c
@@ -193,11 +193,15 @@ netjail_start_run (void *cls,
193 NULL, 193 NULL,
194 script_name, 194 script_name,
195 script_argv); 195 script_argv);
196
196 } 197 }
197 ns->cwh = GNUNET_wait_child (ns->start_proc, 198 ns->cwh = GNUNET_wait_child (ns->start_proc,
198 &child_completed_callback, 199 &child_completed_callback,
199 ns); 200 ns);
200 GNUNET_break (NULL != ns->cwh); 201 GNUNET_break (NULL != ns->cwh);
202 GNUNET_free (read_file);
203 GNUNET_free (script_name);
204 GNUNET_free (data_dir);
201} 205}
202 206
203 207
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 5a005fc25..1709a58d2 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -271,8 +271,8 @@ clear_msg (void *cls, int result)
271 struct TestingSystemCount *tbc = cls; 271 struct TestingSystemCount *tbc = cls;
272 272
273 GNUNET_assert (NULL != tbc->shandle); 273 GNUNET_assert (NULL != tbc->shandle);
274 GNUNET_free (tbc->shandle); 274 /*GNUNET_free (tbc->shandle);
275 tbc->shandle = NULL; 275 tbc->shandle = NULL;*/
276 GNUNET_free (tbc->msg); 276 GNUNET_free (tbc->msg);
277 tbc->msg = NULL; 277 tbc->msg = NULL;
278} 278}
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c
index e3bf7da62..f1b2260ab 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -87,6 +87,7 @@ netjail_stop_cleanup (void *cls)
87 GNUNET_OS_process_destroy (ns->stop_proc); 87 GNUNET_OS_process_destroy (ns->stop_proc);
88 ns->stop_proc = NULL; 88 ns->stop_proc = NULL;
89 } 89 }
90 GNUNET_free (ns);
90} 91}
91 92
92 93
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 3727d2543..e82ec33ab 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -53,6 +53,11 @@ struct GNUNET_TESTING_Interpreter
53 struct GNUNET_TESTING_Command *commands; 53 struct GNUNET_TESTING_Command *commands;
54 54
55 /** 55 /**
56 * Number of GNUNET_TESTING_Command in commands.
57 */
58 unsigned int cmds_n;
59
60 /**
56 * Interpreter task (if one is scheduled). 61 * Interpreter task (if one is scheduled).
57 */ 62 */
58 struct GNUNET_SCHEDULER_Task *task; 63 struct GNUNET_SCHEDULER_Task *task;
@@ -83,21 +88,32 @@ struct GNUNET_TESTING_Interpreter
83 88
84 89
85const struct GNUNET_TESTING_Command * 90const struct GNUNET_TESTING_Command *
86GNUNET_TESTING_interpreter_lookup_command ( 91get_command (struct GNUNET_TESTING_Interpreter *is,
87 struct GNUNET_TESTING_Interpreter *is, 92 const char *label,
88 const char *label) 93 unsigned int future)
89{ 94{
95 int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1;
96 int end_i = GNUNET_NO == future ? 0 : is->ip + 1;
97
98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
99 "start_i: %u end_i: %u\n",
100 start_i,
101 end_i);
90 if (NULL == label) 102 if (NULL == label)
91 { 103 {
92 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 104 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
93 "Attempt to lookup command for empty label\n"); 105 "Attempt to lookup command for empty label\n");
94 return NULL; 106 return NULL;
95 } 107 }
96 /* Search backwards as we most likely reference recent commands */ 108
97 for (int i = is->ip; i >= 0; i--) 109 for (int i = start_i; i >= end_i; i--)
98 { 110 {
99 const struct GNUNET_TESTING_Command *cmd = &is->commands[i]; 111 const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
100 112
113 if (NULL != cmd->label)
114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
115 "label to compare %s\n",
116 cmd->label);
101 /* Give precedence to top-level commands. */ 117 /* Give precedence to top-level commands. */
102 if ( (NULL != cmd->label) && 118 if ( (NULL != cmd->label) &&
103 (0 == strcmp (cmd->label, 119 (0 == strcmp (cmd->label,
@@ -142,6 +158,40 @@ GNUNET_TESTING_interpreter_lookup_command (
142 158
143 159
144/** 160/**
161 * Lookup command by label.
162 * Only future commands are looked up.
163 *
164 * @param is interpreter to lookup command in
165 * @param label label of the command to lookup.
166 * @return the command, if it is found, or NULL.
167 */
168const struct GNUNET_TESTING_Command *
169GNUNET_TESTING_interpreter_lookup_future_command (
170 struct GNUNET_TESTING_Interpreter *is,
171 const char *label)
172{
173 return get_command (is, label, GNUNET_YES);
174}
175
176
177/**
178 * Lookup command by label.
179 * Only commands from current command to commands in the past are looked up.
180 *
181 * @param is interpreter to lookup command in
182 * @param label label of the command to lookup.
183 * @return the command, if it is found, or NULL.
184 */
185const struct GNUNET_TESTING_Command *
186GNUNET_TESTING_interpreter_lookup_command (
187 struct GNUNET_TESTING_Interpreter *is,
188 const char *label)
189{
190 return get_command (is, label, GNUNET_NO);
191}
192
193
194/**
145 * Finish the test run, return the final result. 195 * Finish the test run, return the final result.
146 * 196 *
147 * @param cls the `struct GNUNET_TESTING_Interpreter` 197 * @param cls the `struct GNUNET_TESTING_Interpreter`
@@ -267,6 +317,20 @@ GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
267} 317}
268 318
269 319
320/**
321 * Returns the actual running command.
322 *
323 * @param is Global state of the interpreter, used by a command
324 * to access information about other commands.
325 * @return The actual running command.
326 */
327struct GNUNET_TESTING_Command *
328GNUNET_TESTING_interpreter_get_current_command (
329 struct GNUNET_TESTING_Interpreter *is)
330{
331 return &is->commands[is->ip];
332}
333
270const char * 334const char *
271GNUNET_TESTING_interpreter_get_current_label ( 335GNUNET_TESTING_interpreter_get_current_label (
272 struct GNUNET_TESTING_Interpreter *is) 336 struct GNUNET_TESTING_Interpreter *is)
@@ -300,9 +364,17 @@ interpreter_run (void *cls)
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
301 "Running command `%s'\n", 365 "Running command `%s'\n",
302 cmd->label); 366 cmd->label);
367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
368 "start time of %p expected 0 is `%lu'\n",
369 cmd,
370 cmd->start_time.abs_value_us);
303 cmd->start_time 371 cmd->start_time
304 = cmd->last_req_time 372 = cmd->last_req_time
305 = GNUNET_TIME_absolute_get (); 373 = GNUNET_TIME_absolute_get ();
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
375 "start time of %p expected something is `%lu'\n",
376 cmd,
377 cmd->start_time.abs_value_us);
306 cmd->num_tries = 1; 378 cmd->num_tries = 1;
307 if (NULL != cmd->ac) 379 if (NULL != cmd->ac)
308 { 380 {
@@ -344,6 +416,37 @@ do_timeout (void *cls)
344} 416}
345 417
346 418
419/**
420 * Check if the command is running.
421 *
422 * @param cmd The command to check.
423 * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running.
424 */
425enum GNUNET_GenericReturnValue
426GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command)
427{
428 return 0 != command->start_time.abs_value_us && 0 ==
429 command->finish_time.abs_value_us;
430}
431
432
433/**
434 * Check if a command is finished.
435 *
436 * @param cmd The command to check.
437 * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished.
438 */
439enum GNUNET_GenericReturnValue
440GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command)
441{
442 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
443 struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference (
444 command->finish_time,
445 now);
446 return 0 < diff.rel_value_us;
447}
448
449
347void 450void
348GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, 451GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
349 struct GNUNET_TIME_Relative timeout, 452 struct GNUNET_TIME_Relative timeout,
@@ -359,7 +462,8 @@ GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
359 /* get the number of commands */ 462 /* get the number of commands */
360 for (i = 0; NULL != commands[i].label; i++) 463 for (i = 0; NULL != commands[i].label; i++)
361 ; 464 ;
362 is->commands = GNUNET_new_array (i + 1, 465 is->cmds_n = i + 1;
466 is->commands = GNUNET_new_array (is->cmds_n,
363 struct GNUNET_TESTING_Command); 467 struct GNUNET_TESTING_Command);
364 memcpy (is->commands, 468 memcpy (is->commands,
365 commands, 469 commands,
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index f17be359e..a53f17fe6 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -123,6 +123,7 @@ endif
123 123
124 124
125noinst_PROGRAMS = \ 125noinst_PROGRAMS = \
126 test_transport_start_with_config \
126 gnunet-transport-profiler \ 127 gnunet-transport-profiler \
127 gnunet-communicator-udp \ 128 gnunet-communicator-udp \
128 $(WLAN_BIN_SENDER) \ 129 $(WLAN_BIN_SENDER) \
@@ -589,7 +590,6 @@ libgnunet_plugin_transport_https_server_la_CFLAGS = \
589 $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS 590 $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS
590 591
591check_PROGRAMS = \ 592check_PROGRAMS = \
592 test_transport_start_with_config \
593 test_transport_address_switch_tcp \ 593 test_transport_address_switch_tcp \
594 test_transport_testing_startstop \ 594 test_transport_testing_startstop \
595 test_transport_testing_restart \ 595 test_transport_testing_restart \
@@ -766,7 +766,6 @@ test_transport_start_with_config_SOURCES = \
766test_transport_start_with_config_LDADD = \ 766test_transport_start_with_config_LDADD = \
767 $(top_builddir)/src/testing/libgnunettesting.la \ 767 $(top_builddir)/src/testing/libgnunettesting.la \
768 $(top_builddir)/src/util/libgnunetutil.la \ 768 $(top_builddir)/src/util/libgnunetutil.la \
769 $(top_builddir)/src/testbed/libgnunettestbed.la \
770 $(top_builddir)/src/hello/libgnunethello.la \ 769 $(top_builddir)/src/hello/libgnunethello.la \
771 libgnunettransportcore.la \ 770 libgnunettransportcore.la \
772 libgnunettransporttesting2.la 771 libgnunettransporttesting2.la
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 0bf919787..6f7e67d7b 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -2010,7 +2010,8 @@ queue_read (void *cls)
2010 * @return The struct sockaddr *. 2010 * @return The struct sockaddr *.
2011 */ 2011 */
2012static struct sockaddr * 2012static struct sockaddr *
2013tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, 2013tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len,
2014 struct sockaddr_in6 v6,
2014 unsigned int port) 2015 unsigned int port)
2015{ 2016{
2016 struct sockaddr *in; 2017 struct sockaddr *in;
@@ -2037,7 +2038,8 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
2037 * @return The struct sockaddr *. 2038 * @return The struct sockaddr *.
2038 */ 2039 */
2039static struct sockaddr * 2040static struct sockaddr *
2040tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4, 2041tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len,
2042 struct sockaddr_in v4,
2041 unsigned int port) 2043 unsigned int port)
2042{ 2044{
2043 struct sockaddr *in; 2045 struct sockaddr *in;
@@ -2119,9 +2121,10 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2119 * @param bindto String we extract the address part from. 2121 * @param bindto String we extract the address part from.
2120 * @return The extracted address string. 2122 * @return The extracted address string.
2121 */ 2123 */
2122static void 2124static char *
2123extract_address (const char *bindto, char **addr) 2125extract_address (const char *bindto)
2124{ 2126{
2127 char *addr;
2125 char *start; 2128 char *start;
2126 char *token; 2129 char *token;
2127 char *cp; 2130 char *cp;
@@ -2146,7 +2149,7 @@ extract_address (const char *bindto, char **addr)
2146 { 2149 {
2147 start++; /* skip over '['*/ 2150 start++; /* skip over '['*/
2148 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 2151 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
2149 *addr = GNUNET_strdup (start); 2152 addr = GNUNET_strdup (start);
2150 } 2153 }
2151 else 2154 else
2152 { 2155 {
@@ -2154,20 +2157,21 @@ extract_address (const char *bindto, char **addr)
2154 if (strlen (bindto) == strlen (token)) 2157 if (strlen (bindto) == strlen (token))
2155 { 2158 {
2156 token = strtok_r (cp, ":", &rest); 2159 token = strtok_r (cp, ":", &rest);
2157 *addr = strdup (token); 2160 addr = GNUNET_strdup (token);
2158 } 2161 }
2159 else 2162 else
2160 { 2163 {
2161 token++; 2164 token++;
2162 res = GNUNET_strdup (token); 2165 res = GNUNET_strdup (token);
2163 *addr = GNUNET_strdup (res); 2166 addr = GNUNET_strdup (res);
2164 } 2167 }
2165 } 2168 }
2166 2169
2167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2168 "tcp address: %s\n", 2171 "tcp address: %s\n",
2169 *addr); 2172 addr);
2170 GNUNET_free (cp); 2173 GNUNET_free (cp);
2174 return addr;
2171} 2175}
2172 2176
2173 2177
@@ -2266,12 +2270,10 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2266 unsigned int port; 2270 unsigned int port;
2267 struct sockaddr_in v4; 2271 struct sockaddr_in v4;
2268 struct sockaddr_in6 v6; 2272 struct sockaddr_in6 v6;
2269 char *start = GNUNET_malloc (sizeof(bindto)); 2273 char *start;
2270
2271 // cp = GNUNET_strdup (bindto);
2272 start = GNUNET_malloc (sizeof(bindto));
2273 extract_address (bindto, &start);
2274 2274
2275 start = extract_address (bindto);
2276 // FIXME: check NULL == start
2275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2276 "start %s\n", 2278 "start %s\n",
2277 start); 2279 start);
@@ -3264,7 +3266,7 @@ init_socket (struct sockaddr *addr,
3264 return GNUNET_SYSERR; 3266 return GNUNET_SYSERR;
3265 } 3267 }
3266 3268
3267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3268 "address %s\n", 3270 "address %s\n",
3269 GNUNET_a2s (addr, in_len)); 3271 GNUNET_a2s (addr, in_len));
3270 3272
@@ -3398,35 +3400,35 @@ init_socket (struct sockaddr *addr,
3398static void 3400static void
3399nat_register () 3401nat_register ()
3400{ 3402{
3401
3402 struct sockaddr **saddrs; 3403 struct sockaddr **saddrs;
3403 socklen_t *saddr_lens; 3404 socklen_t *saddr_lens;
3404 int i; 3405 int i;
3405 struct Addresses *pos; 3406 size_t len;
3406
3407 3407
3408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3409 "starting nat register!\n"); 3409 "starting nat register!\n");
3410 3410 len = 0;
3411 i = 0; 3411 i = 0;
3412 saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); 3412 saddrs = GNUNET_malloc ((addrs_lens) * sizeof(struct sockaddr *));
3413 3413 saddr_lens = GNUNET_malloc ((addrs_lens) * sizeof(socklen_t));
3414 saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t)); 3414 for (struct Addresses *pos = addrs_head; NULL != pos; pos = pos->next)
3415
3416 for (pos = addrs_head; NULL != pos; pos = pos->next)
3417 { 3415 {
3418
3419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3420 "registering address %s\n", 3417 "registering address %s\n",
3421 GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); 3418 GNUNET_a2s (addrs_head->addr, addrs_head->addr_len));
3422 3419
3423 saddr_lens[i] = addrs_head->addr_len; 3420 saddr_lens[i] = addrs_head->addr_len;
3421 len += saddr_lens[i];
3424 saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); 3422 saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]);
3425
3426 i++; 3423 i++;
3427
3428 } 3424 }
3429 3425
3426 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3427 "registering addresses %lu %lu %lu %lu\n",
3428 (addrs_lens) * sizeof(struct sockaddr *),
3429 (addrs_lens) * sizeof(socklen_t),
3430 len,
3431 sizeof(COMMUNICATOR_CONFIG_SECTION));
3430 nat = GNUNET_NAT_register (cfg, 3432 nat = GNUNET_NAT_register (cfg,
3431 COMMUNICATOR_CONFIG_SECTION, 3433 COMMUNICATOR_CONFIG_SECTION,
3432 IPPROTO_TCP, 3434 IPPROTO_TCP,
@@ -3436,9 +3438,6 @@ nat_register ()
3436 &nat_address_cb, 3438 &nat_address_cb,
3437 NULL /* FIXME: support reversal: #5529 */, 3439 NULL /* FIXME: support reversal: #5529 */,
3438 NULL /* closure */); 3440 NULL /* closure */);
3439
3440 i = 0;
3441
3442 for (i = addrs_lens - 1; i >= 0; i--) 3441 for (i = addrs_lens - 1; i >= 0; i--)
3443 GNUNET_free (saddrs[i]); 3442 GNUNET_free (saddrs[i]);
3444 GNUNET_free (saddrs); 3443 GNUNET_free (saddrs);
@@ -3471,7 +3470,7 @@ init_socket_resolv (void *cls,
3471 struct sockaddr *in; 3470 struct sockaddr *in;
3472 3471
3473 (void) cls; 3472 (void) cls;
3474 if (NULL != addr) 3473 if (NULL != addr)
3475 { 3474 {
3476 if (AF_INET == addr->sa_family) 3475 if (AF_INET == addr->sa_family)
3477 { 3476 {
@@ -3505,7 +3504,6 @@ init_socket_resolv (void *cls,
3505 return; 3504 return;
3506 } 3505 }
3507 nat_register (); 3506 nat_register ();
3508
3509 } 3507 }
3510} 3508}
3511 3509
@@ -3577,34 +3575,27 @@ run (void *cls,
3577 if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy)) 3575 if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy))
3578 { 3576 {
3579 po = tcp_address_to_sockaddr_port_only (bindto, &bind_port); 3577 po = tcp_address_to_sockaddr_port_only (bindto, &bind_port);
3580
3581 addr_len_ipv4 = po->addr_len_ipv4; 3578 addr_len_ipv4 = po->addr_len_ipv4;
3582
3583
3584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3579 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3585 "address po %s\n", 3580 "address po %s\n",
3586 GNUNET_a2s (po->addr_ipv4, addr_len_ipv4)); 3581 GNUNET_a2s (po->addr_ipv4, addr_len_ipv4));
3587
3588 if (NULL != po->addr_ipv4) 3582 if (NULL != po->addr_ipv4)
3589 { 3583 {
3590 init_socket (po->addr_ipv4, addr_len_ipv4); 3584 init_socket (po->addr_ipv4, addr_len_ipv4);
3591 } 3585 }
3592
3593 if (NULL != po->addr_ipv6) 3586 if (NULL != po->addr_ipv6)
3594 { 3587 {
3595 addr_len_ipv6 = po->addr_len_ipv6; 3588 addr_len_ipv6 = po->addr_len_ipv6;
3596 init_socket (po->addr_ipv6, addr_len_ipv6); 3589 init_socket (po->addr_ipv6, addr_len_ipv6);
3597 } 3590 }
3598
3599 GNUNET_free (po); 3591 GNUNET_free (po);
3600 nat_register (); 3592 nat_register ();
3601 GNUNET_free (bindto); 3593 GNUNET_free (bindto);
3602 return; 3594 return;
3603 } 3595 }
3604 3596
3605 start = GNUNET_malloc (sizeof(bindto)); 3597 start = extract_address (bindto);
3606 extract_address (bindto, &start); 3598 // FIXME: check for NULL == start...
3607
3608 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 3599 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
3609 { 3600 {
3610 bind_port = extract_port (bindto); 3601 bind_port = extract_port (bindto);
@@ -3628,10 +3619,9 @@ run (void *cls,
3628 return; 3619 return;
3629 } 3620 }
3630 3621
3631
3632 bind_port = extract_port (bindto); 3622 bind_port = extract_port (bindto);
3633 3623 resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto,
3634 resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", 3624 ":",
3635 &rest), 3625 &rest),
3636 AF_UNSPEC, 3626 AF_UNSPEC,
3637 GNUNET_TIME_UNIT_MINUTES, 3627 GNUNET_TIME_UNIT_MINUTES,
@@ -3660,17 +3650,19 @@ main (int argc, char *const *argv)
3660 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, 3650 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
3661 "transport", 3651 "transport",
3662 "Starting tcp communicator\n"); 3652 "Starting tcp communicator\n");
3663 3653 if (GNUNET_OK !=
3664 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 3654 GNUNET_STRINGS_get_utf8_args (argc, argv,
3655 &argc, &argv))
3665 return 2; 3656 return 2;
3666 3657
3667 ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc, 3658 ret = (GNUNET_OK ==
3668 argv, 3659 GNUNET_PROGRAM_run (argc,
3669 "gnunet-communicator-tcp", 3660 argv,
3670 _ ("GNUnet TCP communicator"), 3661 "gnunet-communicator-tcp",
3671 options, 3662 _ ("GNUnet TCP communicator"),
3672 &run, 3663 options,
3673 NULL)) 3664 &run,
3665 NULL))
3674 ? 0 3666 ? 0
3675 : 1; 3667 : 1;
3676 GNUNET_free_nz ((void *) argv); 3668 GNUNET_free_nz ((void *) argv);
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index cda888dd5..4483536f0 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5563,7 +5563,7 @@ transmit_cummulative_ack_cb (void *cls)
5563 struct VirtualLink *vl; 5563 struct VirtualLink *vl;
5564 struct AcknowledgementCummulator *ac = cls; 5564 struct AcknowledgementCummulator *ac = cls;
5565 char buf[sizeof(struct TransportReliabilityAckMessage) 5565 char buf[sizeof(struct TransportReliabilityAckMessage)
5566 + ac->ack_counter 5566 + ac->ack_counter + ac->num_acks
5567 * sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN; 5567 * sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN;
5568 struct TransportReliabilityAckMessage *ack = 5568 struct TransportReliabilityAckMessage *ack =
5569 (struct TransportReliabilityAckMessage *) buf; 5569 (struct TransportReliabilityAckMessage *) buf;
diff --git a/src/transport/test_transport_api2_tcp_node1.conf b/src/transport/test_transport_api2_tcp_node1.conf
index 807a9360a..e38744949 100644
--- a/src/transport/test_transport_api2_tcp_node1.conf
+++ b/src/transport/test_transport_api2_tcp_node1.conf
@@ -15,6 +15,7 @@ DISABLE_V6 = YES
15IMMEDIATE_START = YES 15IMMEDIATE_START = YES
16UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock 16UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
17#PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p 17#PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p
18#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
18 19
19[communicator-udp] 20[communicator-udp]
20BINARY = gnunet-communicator-udp 21BINARY = gnunet-communicator-udp
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 6829daf84..476fbdf4f 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -164,19 +164,20 @@ handle_result (void *cls,
164 * 164 *
165 */ 165 */
166static void * 166static void *
167notify_connect (void *cls, 167notify_connect (struct GNUNET_TESTING_Interpreter *is,
168 const struct GNUNET_PeerIdentity *peer, 168 const struct GNUNET_PeerIdentity *peer)
169 struct GNUNET_MQ_Handle *mq)
170{ 169{
171 struct ConnectPeersState *cps; 170 struct ConnectPeersState *cps;
171 const struct GNUNET_TESTING_Command *cmd;
172 172
173 GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers, 173 cmd = GNUNET_TESTING_interpreter_lookup_command (is,
174 "connect-peers");
175 GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
174 &cps); 176 &cps);
175 void *ret = NULL; 177 void *ret = NULL;
176 178
177 cps->notify_connect (cps, 179 cps->notify_connect (is,
178 peer, 180 peer);
179 mq);
180 return ret; 181 return ret;
181} 182}
182 183
@@ -246,7 +247,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
246 else 247 else
247 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; 248 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
248 249
249 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); 250 block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
251 "block");
250 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( 252 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
251 "block-receive"); 253 "block-receive");
252 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", 254 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
@@ -262,11 +264,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
262 GNUNET_asprintf (&ts->cfgname, 264 GNUNET_asprintf (&ts->cfgname,
263 "test_transport_api2_tcp_node1.conf"); 265 "test_transport_api2_tcp_node1.conf");
264 266
265 LOG (GNUNET_ERROR_TYPE_ERROR, 267 LOG (GNUNET_ERROR_TYPE_DEBUG,
266 "plugin cfgname: %s\n", 268 "plugin cfgname: %s\n",
267 ts->cfgname); 269 ts->cfgname);
268 270
269 LOG (GNUNET_ERROR_TYPE_ERROR, 271 LOG (GNUNET_ERROR_TYPE_DEBUG,
270 "node ip: %s\n", 272 "node ip: %s\n",
271 node_ip); 273 node_ip);
272 274
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
index 986fe6014..e2757671b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -74,7 +74,6 @@ static struct GNUNET_TESTING_Command connect_peers;
74 74
75static struct GNUNET_TESTING_Command local_prepared; 75static struct GNUNET_TESTING_Command local_prepared;
76 76
77
78/** 77/**
79 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being 78 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
80 * received. 79 * received.
@@ -164,25 +163,50 @@ handle_result (void *cls,
164 * 163 *
165 */ 164 */
166static void * 165static void *
167notify_connect (void *cls, 166notify_connect (struct GNUNET_TESTING_Interpreter *is,
168 const struct GNUNET_PeerIdentity *peer, 167 const struct GNUNET_PeerIdentity *peer)
169 struct GNUNET_MQ_Handle *mq)
170{ 168{
171 struct GNUNET_TESTING_AsyncContext *ac; 169 struct GNUNET_TESTING_AsyncContext *ac;
170 void *ret = NULL;
171 const struct GNUNET_TESTING_Command *cmd;
172 struct BlockState *bs;
173
172 174
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
174 "notify_connect\n"); 176 "notify_connect\n");
175 177
176 GNUNET_TESTING_get_trait_async_context (&connect_peers, 178 GNUNET_TESTING_get_trait_async_context (&connect_peers,
177 &ac); 179 &ac);
178 void *ret = NULL;
179 180
180 GNUNET_assert (NULL != ac); 181 if (NULL != ac->is)
181 if (NULL == ac->cont) 182 {
182 GNUNET_TESTING_async_fail (ac); 183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
184 "notify_connect running\n");
185 GNUNET_assert (NULL != ac);
186 if (NULL == ac->cont)
187 GNUNET_TESTING_async_fail (ac);
188 else
189 GNUNET_TESTING_async_finish (ac);
190 }
183 else 191 else
184 GNUNET_TESTING_async_finish (ac); 192 {
185 193 cmd = GNUNET_TESTING_interpreter_lookup_future_command (is,
194 "connect-peers");
195
196 LOG (GNUNET_ERROR_TYPE_DEBUG,
197 "block state %s\n",
198 cmd->label);
199 GNUNET_TESTING_get_trait_block_state (cmd,&bs);
200
201 LOG (GNUNET_ERROR_TYPE_DEBUG,
202 "block state %u\n",
203 bs->asynchronous_finish);
204 bs->asynchronous_finish = GNUNET_YES;
205 LOG (GNUNET_ERROR_TYPE_DEBUG,
206 "block state %u\n",
207 bs->asynchronous_finish);
208 }
209
186 return ret; 210 return ret;
187} 211}
188 212
@@ -224,7 +248,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
224 char *topology_data, 248 char *topology_data,
225 unsigned int *read_file) 249 unsigned int *read_file)
226{ 250{
227
228 unsigned int n_int; 251 unsigned int n_int;
229 unsigned int m_int; 252 unsigned int m_int;
230 unsigned int local_m_int; 253 unsigned int local_m_int;
@@ -232,6 +255,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
232 struct TestState *ts = GNUNET_new (struct TestState); 255 struct TestState *ts = GNUNET_new (struct TestState);
233 struct GNUNET_TESTING_NetjailTopology *topology; 256 struct GNUNET_TESTING_NetjailTopology *topology;
234 257
258
259
235 if (GNUNET_YES == *read_file) 260 if (GNUNET_YES == *read_file)
236 { 261 {
237 LOG (GNUNET_ERROR_TYPE_DEBUG, 262 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -255,7 +280,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
255 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); 280 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
256 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( 281 block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
257 "block-receive"); 282 "block-receive");
258 connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger ("connect-peers"); 283 connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger (
284 "connect-peers");
259 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 285 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
260 "local-test-prepared", 286 "local-test-prepared",
261 write_message); 287 write_message);
@@ -264,11 +290,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
264 GNUNET_asprintf (&ts->cfgname, 290 GNUNET_asprintf (&ts->cfgname,
265 "test_transport_api2_tcp_node1.conf"); 291 "test_transport_api2_tcp_node1.conf");
266 292
267 LOG (GNUNET_ERROR_TYPE_ERROR, 293 LOG (GNUNET_ERROR_TYPE_DEBUG,
268 "plugin cfgname: %s\n", 294 "plugin cfgname: %s\n",
269 ts->cfgname); 295 ts->cfgname);
270 296
271 LOG (GNUNET_ERROR_TYPE_ERROR, 297 LOG (GNUNET_ERROR_TYPE_DEBUG,
272 "node ip: %s\n", 298 "node ip: %s\n",
273 node_ip); 299 node_ip);
274 300
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 11cd177c4..c98a3075d 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -160,9 +160,8 @@ handle_result (void *cls,
160 * 160 *
161 */ 161 */
162static void * 162static void *
163notify_connect (void *cls, 163notify_connect (struct GNUNET_TESTING_Interpreter *is,
164 const struct GNUNET_PeerIdentity *peer, 164 const struct GNUNET_PeerIdentity *peer)
165 struct GNUNET_MQ_Handle *mq)
166{ 165{
167 struct ConnectPeersState *cps; 166 struct ConnectPeersState *cps;
168 167
@@ -170,9 +169,8 @@ notify_connect (void *cls,
170 &cps); 169 &cps);
171 void *ret = NULL; 170 void *ret = NULL;
172 171
173 cps->notify_connect (cps, 172 cps->notify_connect (is,
174 peer, 173 peer);
175 mq);
176 return ret; 174 return ret;
177} 175}
178 176
@@ -238,7 +236,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
238 else 236 else
239 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; 237 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
240 238
241 block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); 239 block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
240 "block");
242 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", 241 connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
243 "start-peer", 242 "start-peer",
244 "system-create", 243 "system-create",
@@ -251,11 +250,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
251 GNUNET_asprintf (&ts->cfgname, 250 GNUNET_asprintf (&ts->cfgname,
252 "test_transport_api2_tcp_node1.conf"); 251 "test_transport_api2_tcp_node1.conf");
253 252
254 LOG (GNUNET_ERROR_TYPE_ERROR, 253 LOG (GNUNET_ERROR_TYPE_DEBUG,
255 "plugin cfgname: %s\n", 254 "plugin cfgname: %s\n",
256 ts->cfgname); 255 ts->cfgname);
257 256
258 LOG (GNUNET_ERROR_TYPE_ERROR, 257 LOG (GNUNET_ERROR_TYPE_DEBUG,
259 "node ip: %s\n", 258 "node ip: %s\n",
260 node_ip); 259 node_ip);
261 260
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh
index 7e3ee032f..3d5266622 100755
--- a/src/transport/test_transport_simple_send.sh
+++ b/src/transport/test_transport_simple_send.sh
@@ -1,5 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then 2if ! [ -d "/run/netns" ]; then
3 echo You have to create the directory /run/netns.
4fi
5if [ "$(cat /proc/sys/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_topo.conf" 6 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"
4else 7else
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" 8 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"
diff --git a/src/transport/test_transport_simple_send_broadcast.sh b/src/transport/test_transport_simple_send_broadcast.sh
index 6e455f0d5..f264b1203 100755
--- a/src/transport/test_transport_simple_send_broadcast.sh
+++ b/src/transport/test_transport_simple_send_broadcast.sh
@@ -1,5 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then 2if ! [ -d "/run/netns" ]; then
3 echo You have to create the directory /run/netns.
4fi
5if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
6 # 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"
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" 7 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"
4else 8else
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" 9 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"
diff --git a/src/transport/test_transport_simple_send_string.sh b/src/transport/test_transport_simple_send_string.sh
index 018ea55e8..b2bd05d5f 100755
--- a/src/transport/test_transport_simple_send_string.sh
+++ b/src/transport/test_transport_simple_send_string.sh
@@ -7,8 +7,11 @@ T:libgnunet_test_transport_plugin_cmd_simple_send
7P:1:1|{connect:{P:1:2:tcp}} 7P:1:1|{connect:{P:1:2:tcp}}
8P:1:2|{connect:{P:1:1:tcp}} 8P:1:2|{connect:{P:1:1:tcp}}
9EOF 9EOF
10) 10 )
11if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then 11if ! [ -d "/run/netns" ]; then
12 echo You have to create the directory /run/netns.
13fi
14if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
12 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'" 15 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'"
13else 16else
14 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" 17 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"
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh
index 9c0b11fad..b42186307 100755
--- a/src/transport/test_transport_udp_backchannel.sh
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -1,5 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then 2if ! [ -d "/run/netns" ]; then
3 echo You have to create the directory /run/netns.
4fi
5if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
3#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" 6#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"
4exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" 7exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
5# 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" 8# 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"
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 @@
1M:1
2N:1
3X:1
4T:libgnunet_test_transport_plugin_cmd_udp_backchannel
5K:1|{connect:{P:1:1:tcp}}
6R:1|{tcp_port:1}|{udp_port:0}
7P:1:1|{connect:{K:1:udp}}
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index 5d0b902f6..d2e49c0d3 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -29,6 +29,10 @@
29#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
30 30
31 31
32typedef void *
33(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
34 const struct GNUNET_PeerIdentity *peer);
35
32/** 36/**
33 * Struct to store information needed in callbacks. 37 * Struct to store information needed in callbacks.
34 * 38 *
@@ -40,7 +44,7 @@ struct ConnectPeersState
40 */ 44 */
41 struct GNUNET_TESTING_AsyncContext ac; 45 struct GNUNET_TESTING_AsyncContext ac;
42 46
43 GNUNET_TRANSPORT_NotifyConnect notify_connect; 47 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
44 48
45 /** 49 /**
46 * The testing system of this node. 50 * The testing system of this node.
@@ -163,7 +167,7 @@ struct StartPeerState
163 167
164 struct GNUNET_TESTING_System *tl_system; 168 struct GNUNET_TESTING_System *tl_system;
165 169
166 GNUNET_TRANSPORT_NotifyConnect notify_connect; 170 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
167 171
168 /** 172 /**
169 * Flag indicating, if udp broadcast should be switched on. 173 * Flag indicating, if udp broadcast should be switched on.
@@ -213,7 +217,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
213 char *node_ip, 217 char *node_ip,
214 struct GNUNET_MQ_MessageHandler *handlers, 218 struct GNUNET_MQ_MessageHandler *handlers,
215 const char *cfgname, 219 const char *cfgname,
216 GNUNET_TRANSPORT_NotifyConnect notify_connect, 220 GNUNET_TRANSPORT_notify_connect_cb
221 notify_connect,
217 unsigned int broadcast); 222 unsigned int broadcast);
218 223
219 224
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index b50b63c62..3fef7d687 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -113,17 +113,20 @@ connect_peers_run (void *cls,
113 * 113 *
114 */ 114 */
115static void * 115static void *
116notify_connect (void *cls, 116notify_connect (struct GNUNET_TESTING_Interpreter *is,
117 const struct GNUNET_PeerIdentity *peer, 117 const struct GNUNET_PeerIdentity *peer)
118 struct GNUNET_MQ_Handle *mq)
119{ 118{
120 struct ConnectPeersState *cps = cls; 119 const struct GNUNET_TESTING_Command *cmd;
120 struct ConnectPeersState *cps;
121 struct GNUNET_PeerIdentity *peer_connection; 121 struct GNUNET_PeerIdentity *peer_connection;
122 unsigned int con_num = 0; 122 unsigned int con_num = 0;
123 struct GNUNET_TESTING_NodeConnection *pos_connection; 123 struct GNUNET_TESTING_NodeConnection *pos_connection;
124 unsigned int num; 124 unsigned int num;
125 void *ret = NULL; 125 void *ret = NULL;
126 126
127 cmd = GNUNET_TESTING_interpreter_lookup_command (is,
128 "connect-peers");
129 cps = cmd->cls;
127 for (pos_connection = cps->node_connections_head; NULL != pos_connection; 130 for (pos_connection = cps->node_connections_head; NULL != pos_connection;
128 pos_connection = pos_connection->next) 131 pos_connection = pos_connection->next)
129 { 132 {
@@ -217,7 +220,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
217 cps->num = num; 220 cps->num = num;
218 cps->create_label = create_label; 221 cps->create_label = create_label;
219 cps->topology = topology; 222 cps->topology = topology;
220 cps->notify_connect = &notify_connect; 223 cps->notify_connect = notify_connect;
221 224
222 { 225 {
223 struct GNUNET_TESTING_Command cmd = { 226 struct GNUNET_TESTING_Command cmd = {
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index da833f1b1..52eacabb2 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -147,9 +147,8 @@ notify_connect (void *cls,
147 147
148 GNUNET_free (key); 148 GNUNET_free (key);
149 149
150 sps->notify_connect (cls, 150 sps->notify_connect (sps->ac.is,
151 peer, 151 peer);
152 mq);
153 152
154 // TODO what does the handler function need? 153 // TODO what does the handler function need?
155 return ret; 154 return ret;
@@ -213,11 +212,11 @@ start_peer_run (void *cls,
213 GNUNET_asprintf (&bindto_udp, 212 GNUNET_asprintf (&bindto_udp,
214 "2086"); 213 "2086");
215 214
216 LOG (GNUNET_ERROR_TYPE_ERROR, 215 LOG (GNUNET_ERROR_TYPE_DEBUG,
217 "node_ip %s\n", 216 "node_ip %s\n",
218 bindto); 217 bindto);
219 218
220 LOG (GNUNET_ERROR_TYPE_ERROR, 219 LOG (GNUNET_ERROR_TYPE_DEBUG,
221 "bind_udp %s\n", 220 "bind_udp %s\n",
222 GNUNET_YES == sps->broadcast ? 221 GNUNET_YES == sps->broadcast ?
223 bindto_udp : bindto); 222 bindto_udp : bindto);
@@ -247,7 +246,7 @@ start_peer_run (void *cls,
247 246
248 sps->tl_system = tl_system; 247 sps->tl_system = tl_system;
249 248
250 LOG (GNUNET_ERROR_TYPE_ERROR, 249 LOG (GNUNET_ERROR_TYPE_DEBUG,
251 "Creating testing library with key number %u\n", 250 "Creating testing library with key number %u\n",
252 sps->no); 251 sps->no);
253 252
@@ -255,7 +254,7 @@ start_peer_run (void *cls,
255 GNUNET_TESTING_configuration_create (tl_system, 254 GNUNET_TESTING_configuration_create (tl_system,
256 sps->cfg)) 255 sps->cfg))
257 { 256 {
258 LOG (GNUNET_ERROR_TYPE_ERROR, 257 LOG (GNUNET_ERROR_TYPE_DEBUG,
259 "Testing library failed to create unique configuration based on `%s'\n", 258 "Testing library failed to create unique configuration based on `%s'\n",
260 sps->cfgname); 259 sps->cfgname);
261 GNUNET_CONFIGURATION_destroy (sps->cfg); 260 GNUNET_CONFIGURATION_destroy (sps->cfg);
@@ -359,6 +358,7 @@ start_peer_run (void *cls,
359 GNUNET_free (tcp_communicator_unix_path); 358 GNUNET_free (tcp_communicator_unix_path);
360 GNUNET_free (udp_communicator_unix_path); 359 GNUNET_free (udp_communicator_unix_path);
361 GNUNET_free (bindto); 360 GNUNET_free (bindto);
361 GNUNET_free (bindto_udp);
362} 362}
363 363
364 364
@@ -589,7 +589,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
589 char *node_ip, 589 char *node_ip,
590 struct GNUNET_MQ_MessageHandler *handlers, 590 struct GNUNET_MQ_MessageHandler *handlers,
591 const char *cfgname, 591 const char *cfgname,
592 GNUNET_TRANSPORT_NotifyConnect notify_connect, 592 GNUNET_TRANSPORT_notify_connect_cb
593 notify_connect,
593 unsigned int broadcast) 594 unsigned int broadcast)
594{ 595{
595 struct StartPeerState *sps; 596 struct StartPeerState *sps;
diff --git a/src/util/mq.c b/src/util/mq.c
index 9b59cd338..b09837459 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -273,7 +273,7 @@ GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers,
273 break; 273 break;
274 } 274 }
275 } 275 }
276 done: 276done:
277 if (GNUNET_NO == handled) 277 if (GNUNET_NO == handled)
278 { 278 {
279 LOG (GNUNET_ERROR_TYPE_INFO, 279 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -670,7 +670,9 @@ GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr)
670 670
671 mqm = GNUNET_malloc (sizeof(*mqm) + size); 671 mqm = GNUNET_malloc (sizeof(*mqm) + size);
672 mqm->mh = (struct GNUNET_MessageHeader *) &mqm[1]; 672 mqm->mh = (struct GNUNET_MessageHeader *) &mqm[1];
673 GNUNET_memcpy (mqm->mh, hdr, size); 673 GNUNET_memcpy (mqm->mh,
674 hdr,
675 size);
674 return mqm; 676 return mqm;
675} 677}
676 678
diff --git a/src/util/program.c b/src/util/program.c
index b9da14572..08effa19b 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -89,9 +89,13 @@ program_main (void *cls)
89 struct CommandContext *cc = cls; 89 struct CommandContext *cc = cls;
90 90
91 GNUNET_SPEEDUP_start_ (cc->cfg); 91 GNUNET_SPEEDUP_start_ (cc->cfg);
92 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 92 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
93 NULL);
93 GNUNET_RESOLVER_connect (cc->cfg); 94 GNUNET_RESOLVER_connect (cc->cfg);
94 cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); 95 cc->task (cc->task_cls,
96 cc->args,
97 cc->cfgfile,
98 cc->cfg);
95} 99}
96 100
97 101
@@ -103,7 +107,8 @@ program_main (void *cls)
103 * @param a2 second command line option 107 * @param a2 second command line option
104 */ 108 */
105static int 109static int
106cmd_sorter (const void *a1, const void *a2) 110cmd_sorter (const void *a1,
111 const void *a2)
107{ 112{
108 const struct GNUNET_GETOPT_CommandLineOption *c1 = a1; 113 const struct GNUNET_GETOPT_CommandLineOption *c1 = a1;
109 const struct GNUNET_GETOPT_CommandLineOption *c2 = a2; 114 const struct GNUNET_GETOPT_CommandLineOption *c2 = a2;