aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
committert3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
commit6fb788ca2ec44837ea10a36be7fd0030fb08955b (patch)
treecba4a385aa8ab914d02db9a702f6c6230aa89a2a /src/transport
parent1609d627e509043a946f611d7589105cfae2364d (diff)
downloadgnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.tar.gz
gnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.zip
- fixed coverity issues
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c29
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c62
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c17
-rwxr-xr-xsrc/transport/test_transport_simple_send.sh7
-rw-r--r--src/transport/test_transport_simple_send_topo.conf4
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh5
-rw-r--r--src/transport/transport-testing-cmds.h17
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c23
-rw-r--r--src/transport/transport_api_cmd_send_simple.c119
-rw-r--r--src/transport/transport_api_cmd_start_peer.c14
10 files changed, 191 insertions, 106 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 025326de7..0bf919787 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -2119,10 +2119,9 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2119 * @param bindto String we extract the address part from. 2119 * @param bindto String we extract the address part from.
2120 * @return The extracted address string. 2120 * @return The extracted address string.
2121 */ 2121 */
2122static char * 2122static void
2123extract_address (const char *bindto) 2123extract_address (const char *bindto, char **addr)
2124{ 2124{
2125
2126 char *start; 2125 char *start;
2127 char *token; 2126 char *token;
2128 char *cp; 2127 char *cp;
@@ -2147,6 +2146,7 @@ extract_address (const char *bindto)
2147 { 2146 {
2148 start++; /* skip over '['*/ 2147 start++; /* skip over '['*/
2149 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 2148 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
2149 *addr = GNUNET_strdup (start);
2150 } 2150 }
2151 else 2151 else
2152 { 2152 {
@@ -2154,23 +2154,20 @@ extract_address (const char *bindto)
2154 if (strlen (bindto) == strlen (token)) 2154 if (strlen (bindto) == strlen (token))
2155 { 2155 {
2156 token = strtok_r (cp, ":", &rest); 2156 token = strtok_r (cp, ":", &rest);
2157 *addr = strdup (token);
2157 } 2158 }
2158 else 2159 else
2159 { 2160 {
2160 token++; 2161 token++;
2161 res = GNUNET_strdup (token); 2162 res = GNUNET_strdup (token);
2162 GNUNET_free (cp); 2163 *addr = GNUNET_strdup (res);
2163 return res;
2164 } 2164 }
2165 } 2165 }
2166 2166
2167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2168 "extract address 3\n"); 2168 "tcp address: %s\n",
2169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2169 *addr);
2170 "extract address with start %s\n", 2170 GNUNET_free (cp);
2171 start);
2172
2173 return GNUNET_strdup (start);
2174} 2171}
2175 2172
2176 2173
@@ -2241,6 +2238,7 @@ extract_port (const char *addr_and_port)
2241 GNUNET_free (cp); 2238 GNUNET_free (cp);
2242 return 0; 2239 return 0;
2243 } 2240 }
2241 GNUNET_free (cp);
2244 } 2242 }
2245 else 2243 else
2246 { 2244 {
@@ -2250,7 +2248,6 @@ extract_port (const char *addr_and_port)
2250 port = 0; 2248 port = 0;
2251 } 2249 }
2252 2250
2253
2254 return port; 2251 return port;
2255} 2252}
2256 2253
@@ -2269,10 +2266,11 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2269 unsigned int port; 2266 unsigned int port;
2270 struct sockaddr_in v4; 2267 struct sockaddr_in v4;
2271 struct sockaddr_in6 v6; 2268 struct sockaddr_in6 v6;
2272 char *start; 2269 char *start = GNUNET_malloc (sizeof(bindto));
2273 2270
2274 // cp = GNUNET_strdup (bindto); 2271 // cp = GNUNET_strdup (bindto);
2275 start = extract_address (bindto); 2272 start = GNUNET_malloc (sizeof(bindto));
2273 extract_address (bindto, &start);
2276 2274
2277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2278 "start %s\n", 2276 "start %s\n",
@@ -3604,7 +3602,8 @@ run (void *cls,
3604 return; 3602 return;
3605 } 3603 }
3606 3604
3607 start = extract_address (bindto); 3605 start = GNUNET_malloc (sizeof(bindto));
3606 extract_address (bindto, &start);
3608 3607
3609 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 3608 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
3610 { 3609 {
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index f0b47084b..c374fc2d0 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -58,6 +58,11 @@ struct TestState
58 * 58 *
59 */ 59 */
60 char *cfgname; 60 char *cfgname;
61
62 /**
63 * The complete topology information.
64 */
65 struct GNUNET_TESTING_NetjailTopology *topology;
61}; 66};
62 67
63static struct GNUNET_TESTING_Command block_send; 68static struct GNUNET_TESTING_Command block_send;
@@ -66,6 +71,8 @@ static struct GNUNET_TESTING_Command block_receive;
66 71
67static struct GNUNET_TESTING_Command connect_peers; 72static struct GNUNET_TESTING_Command connect_peers;
68 73
74static struct GNUNET_TESTING_Command local_prepared;
75
69 76
70/** 77/**
71 * 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
@@ -93,7 +100,8 @@ handle_test (void *cls,
93 100
94 GNUNET_TESTING_get_trait_async_context (&block_receive, 101 GNUNET_TESTING_get_trait_async_context (&block_receive,
95 &ac); 102 &ac);
96 if ((NULL == ac) || (NULL == ac->cont)) 103 GNUNET_assert (NULL != ac);
104 if (NULL == ac->cont)
97 GNUNET_TESTING_async_fail (ac); 105 GNUNET_TESTING_async_fail (ac);
98 else 106 else
99 GNUNET_TESTING_async_finish (ac); 107 GNUNET_TESTING_async_finish (ac);
@@ -111,7 +119,8 @@ all_peers_started ()
111 119
112 GNUNET_TESTING_get_trait_async_context (&block_send, 120 GNUNET_TESTING_get_trait_async_context (&block_send,
113 &ac); 121 &ac);
114 if ((NULL == ac) || (NULL == ac->cont)) 122 GNUNET_assert (NULL != ac);
123 if (NULL == ac->cont)
115 GNUNET_TESTING_async_fail (ac); 124 GNUNET_TESTING_async_fail (ac);
116 else 125 else
117 GNUNET_TESTING_async_finish (ac); 126 GNUNET_TESTING_async_finish (ac);
@@ -136,10 +145,15 @@ handle_result (void *cls,
136 rv); 145 rv);
137 reply = GNUNET_TESTING_send_local_test_finished_msg (rv); 146 reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
138 147
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
149 "message prepared\n");
139 ts->write_message (reply, 150 ts->write_message (reply,
140 ntohs (reply->size)); 151 ntohs (reply->size));
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 "message send\n");
141 GNUNET_free (ts->testdir); 154 GNUNET_free (ts->testdir);
142 GNUNET_free (ts->cfgname); 155 GNUNET_free (ts->cfgname);
156 GNUNET_TESTING_free_topology (ts->topology);
143 GNUNET_free (ts); 157 GNUNET_free (ts);
144} 158}
145 159
@@ -167,6 +181,24 @@ notify_connect (void *cls,
167 181
168 182
169/** 183/**
184 * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
185 */
186static void
187all_local_tests_prepared ()
188{
189 struct LocalPreparedState *lfs;
190
191 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
192 &lfs);
193 GNUNET_assert (NULL != &lfs->ac);
194 if (NULL == lfs->ac.cont)
195 GNUNET_TESTING_async_fail (&lfs->ac);
196 else
197 GNUNET_TESTING_async_finish (&lfs->ac);
198}
199
200
201/**
170 * Function to start a local test case. 202 * Function to start a local test case.
171 * 203 *
172 * @param write_message Callback to send a message to the master loop. 204 * @param write_message Callback to send a message to the master loop.
@@ -192,8 +224,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
192 struct GNUNET_TESTING_NetjailTopology *topology = 224 struct GNUNET_TESTING_NetjailTopology *topology =
193 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 225 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
194 226
195 if (0 == m_int) 227 ts->topology = topology;
196 num = n_int; 228
229 sscanf (m, "%u", &m_int);
230 sscanf (n, "%u", &n_int);
231 sscanf (local_m, "%u", &local_m_int);
232
233 if (0 == n_int)
234 num = m_int;
197 else 235 else
198 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; 236 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
199 237
@@ -205,13 +243,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
205 "system-create", 243 "system-create",
206 num, 244 num,
207 topology); 245 topology);
246 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
247 "local-test-prepared",
248 write_message);
208 249
209 250
210
211 sscanf (m, "%u", &m_int);
212 sscanf (n, "%u", &n_int);
213 sscanf (local_m, "%u", &local_m_int);
214
215 GNUNET_asprintf (&ts->cfgname, 251 GNUNET_asprintf (&ts->cfgname,
216 "test_transport_api2_tcp_node1.conf"); 252 "test_transport_api2_tcp_node1.conf");
217 253
@@ -253,8 +289,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
253 connect_peers, 289 connect_peers,
254 GNUNET_TRANSPORT_cmd_send_simple ("send-simple", 290 GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
255 "start-peer", 291 "start-peer",
256 num), 292 "system-create",
293 num,
294 topology),
257 block_receive, 295 block_receive,
296 local_prepared,
258 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", 297 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
259 "start-peer"), 298 "start-peer"),
260 GNUNET_TESTING_cmd_system_destroy ("system-destroy", 299 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
@@ -262,6 +301,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
262 GNUNET_TESTING_cmd_end () 301 GNUNET_TESTING_cmd_end ()
263 }; 302 };
264 303
304 ts->write_message = write_message;
305
265 GNUNET_TESTING_run (commands, 306 GNUNET_TESTING_run (commands,
266 GNUNET_TIME_UNIT_FOREVER_REL, 307 GNUNET_TIME_UNIT_FOREVER_REL,
267 &handle_result, 308 &handle_result,
@@ -288,6 +329,7 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
288 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); 329 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
289 api->start_testcase = &start_testcase; 330 api->start_testcase = &start_testcase;
290 api->all_peers_started = &all_peers_started; 331 api->all_peers_started = &all_peers_started;
332 api->all_local_tests_prepared = all_local_tests_prepared;
291 return api; 333 return api;
292} 334}
293 335
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index ee6dc0274..f3afbec48 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -58,11 +58,17 @@ struct TestState
58 * 58 *
59 */ 59 */
60 char *cfgname; 60 char *cfgname;
61
62 /**
63 * The complete topology information.
64 */
65 struct GNUNET_TESTING_NetjailTopology *topology;
61}; 66};
62 67
63static struct GNUNET_TESTING_Command block_send; 68static struct GNUNET_TESTING_Command block_send;
64 69
65static struct GNUNET_TESTING_Command connect_peers; 70static struct GNUNET_TESTING_Command connect_peers;
71
66static struct GNUNET_TESTING_Command local_prepared; 72static struct GNUNET_TESTING_Command local_prepared;
67 73
68 74
@@ -110,7 +116,8 @@ all_peers_started ()
110 116
111 GNUNET_TESTING_get_trait_async_context (&block_send, 117 GNUNET_TESTING_get_trait_async_context (&block_send,
112 &ac); 118 &ac);
113 if ((NULL == ac) || (NULL == ac->cont)) 119 GNUNET_assert (NULL != ac);
120 if ((NULL == ac->cont))
114 GNUNET_TESTING_async_fail (ac); 121 GNUNET_TESTING_async_fail (ac);
115 else 122 else
116 GNUNET_TESTING_async_finish (ac); 123 GNUNET_TESTING_async_finish (ac);
@@ -142,6 +149,7 @@ handle_result (void *cls,
142 149
143 GNUNET_free (ts->testdir); 150 GNUNET_free (ts->testdir);
144 GNUNET_free (ts->cfgname); 151 GNUNET_free (ts->cfgname);
152 GNUNET_TESTING_free_topology (ts->topology);
145 GNUNET_free (ts); 153 GNUNET_free (ts);
146} 154}
147 155
@@ -174,10 +182,11 @@ static void
174all_local_tests_prepared () 182all_local_tests_prepared ()
175{ 183{
176 struct LocalPreparedState *lfs; 184 struct LocalPreparedState *lfs;
185
177 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, 186 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
178 &lfs); 187 &lfs);
179 188 GNUNET_assert (NULL != &lfs->ac);
180 if ((NULL == &lfs->ac) || (NULL == lfs->ac.cont)) 189 if (NULL == lfs->ac.cont)
181 GNUNET_TESTING_async_fail (&lfs->ac); 190 GNUNET_TESTING_async_fail (&lfs->ac);
182 else 191 else
183 GNUNET_TESTING_async_finish (&lfs->ac); 192 GNUNET_TESTING_async_finish (&lfs->ac);
@@ -210,6 +219,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
210 struct GNUNET_TESTING_NetjailTopology *topology = 219 struct GNUNET_TESTING_NetjailTopology *topology =
211 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 220 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
212 221
222 ts->topology = topology;
223
213 sscanf (m, "%u", &m_int); 224 sscanf (m, "%u", &m_int);
214 sscanf (n, "%u", &n_int); 225 sscanf (n, "%u", &n_int);
215 sscanf (local_m, "%u", &local_m_int); 226 sscanf (local_m, "%u", &local_m_int);
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh
index 2dd269fcc..7e3ee032f 100755
--- a/src/transport/test_transport_simple_send.sh
+++ b/src/transport/test_transport_simple_send.sh
@@ -1,2 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf" 2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
3 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf"
4else
5 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
6 exit 78
7fi
diff --git a/src/transport/test_transport_simple_send_topo.conf b/src/transport/test_transport_simple_send_topo.conf
index f878f9719..2c16201f5 100644
--- a/src/transport/test_transport_simple_send_topo.conf
+++ b/src/transport/test_transport_simple_send_topo.conf
@@ -1,4 +1,6 @@
1M:2 1M:2
2N:1 2N:1
3X:0 3X:0
4T:libgnunet_test_transport_plugin_cmd_simple_send \ No newline at end of file 4T:libgnunet_test_transport_plugin_cmd_simple_send
5P:1:1|{connect:{P:1:2:tcp}}
6P:1:2|{connect:{P:1:1:tcp}} \ No newline at end of file
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh
index 0c37be469..9c0b11fad 100755
--- a/src/transport/test_transport_udp_backchannel.sh
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -1,4 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
2#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" 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"
3exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./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"
4# 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" 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"
6else
7 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 exit 78
9fi
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index d6bb46f7d..10729990d 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -63,12 +63,6 @@ struct ConnectPeersState
63 const char *start_peer_label; 63 const char *start_peer_label;
64 64
65 /** 65 /**
66 * The peer identity of this peer.
67 *
68 */
69 struct GNUNET_PeerIdentity *id;
70
71 /**
72 * The topology of the test setup. 66 * The topology of the test setup.
73 */ 67 */
74 struct GNUNET_TESTING_NetjailTopology *topology; 68 struct GNUNET_TESTING_NetjailTopology *topology;
@@ -222,16 +216,19 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
222 * Create command. 216 * Create command.
223 * 217 *
224 * @param label name for command. 218 * @param label name for command.
225 * @param m The number of the local node of the actual network namespace.
226 * @param n The number of the actual namespace.
227 * @param num Number globally identifying the node.
228 * @param start_peer_label Label of the cmd to start a peer. 219 * @param start_peer_label Label of the cmd to start a peer.
220 * @param start_peer_label Label of the cmd which started the test system.
221 * @param num Number globally identifying the node.
222 * @param The topology for the test setup.
229 * @return command. 223 * @return command.
230 */ 224 */
231struct GNUNET_TESTING_Command 225struct GNUNET_TESTING_Command
232GNUNET_TRANSPORT_cmd_send_simple (const char *label, 226GNUNET_TRANSPORT_cmd_send_simple (const char *label,
233 const char *start_peer_label, 227 const char *start_peer_label,
234 uint32_t num); 228 const char *create_label,
229 uint32_t num,
230 struct GNUNET_TESTING_NetjailTopology *
231 topology);
235 232
236 233
237/** 234/**
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 017d1bca3..2eb1b0914 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -72,6 +72,10 @@ connect_peers_run (void *cls,
72 72
73 cps->tl_system = tl_system; 73 cps->tl_system = tl_system;
74 74
75 LOG (GNUNET_ERROR_TYPE_DEBUG,
76 "cps->num: %u \n",
77 cps->num);
78
75 cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num, 79 cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num,
76 cps->topology); 80 cps->topology);
77 81
@@ -84,28 +88,15 @@ connect_peers_run (void *cls,
84 pos_prefix = 88 pos_prefix =
85 pos_prefix->next) 89 pos_prefix->next)
86 { 90 {
87
88 LOG (GNUNET_ERROR_TYPE_ERROR,
89 "prefix: %s\n",
90 pos_prefix->address_prefix);
91
92 addr = GNUNET_TESTING_get_address (pos_connection, 91 addr = GNUNET_TESTING_get_address (pos_connection,
93 pos_prefix->address_prefix); 92 pos_prefix->address_prefix);
94
95 peer = GNUNET_TESTING_get_pub_key (num, tl_system); 93 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
96
97 LOG (GNUNET_ERROR_TYPE_ERROR,
98 "num: %u pub_key %s addr: %s\n",
99 num,
100 GNUNET_CRYPTO_eddsa_public_key_to_string (&(peer->public_key)),
101 addr);
102
103 cps->id = peer;
104
105 GNUNET_TRANSPORT_application_validate (ah, 94 GNUNET_TRANSPORT_application_validate (ah,
106 peer, 95 peer,
107 nt, 96 nt,
108 addr); 97 addr);
98 GNUNET_free (peer);
99 GNUNET_free (addr);
109 } 100 }
110 } 101 }
111 cps->con_num = con_num; 102 cps->con_num = con_num;
@@ -136,6 +127,7 @@ notify_connect (void *cls,
136 if (0 == GNUNET_memcmp (peer, 127 if (0 == GNUNET_memcmp (peer,
137 peer_connection)) 128 peer_connection))
138 con_num++; 129 con_num++;
130 GNUNET_free (peer_connection);
139 } 131 }
140 132
141 133
@@ -156,7 +148,6 @@ connect_peers_cleanup (void *cls)
156{ 148{
157 struct ConnectPeersState *cps = cls; 149 struct ConnectPeersState *cps = cls;
158 150
159 GNUNET_free (cps->id);
160 GNUNET_free (cps); 151 GNUNET_free (cps);
161} 152}
162 153
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 0631f7051..9c34c50d7 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -46,21 +46,18 @@ struct SendSimpleState
46 * 46 *
47 */ 47 */
48 const char *start_peer_label; 48 const char *start_peer_label;
49};
50 49
50 /**
51 * Label of the cmd which started the test system.
52 *
53 */
54 const char *create_label;
51 55
52/** 56 /**
53 * Trait function of this cmd does nothing. 57 * The topology we get the connected nodes from.
54 * 58 */
55 */ 59 struct GNUNET_TESTING_NetjailTopology *topology;
56static int 60};
57send_simple_traits (void *cls,
58 const void **ret,
59 const char *trait,
60 unsigned int index)
61{
62 return GNUNET_OK;
63}
64 61
65 62
66/** 63/**
@@ -77,7 +74,7 @@ send_simple_cleanup (void *cls)
77 74
78 75
79/** 76/**
80 * The run method of this cmd will send a simple message to the connected peer. 77 * The run method of this cmd will send a simple message to the connected peers.
81 * 78 *
82 */ 79 */
83static void 80static void
@@ -92,31 +89,54 @@ send_simple_run (void *cls,
92 const struct GNUNET_TESTING_Command *peer1_cmd; 89 const struct GNUNET_TESTING_Command *peer1_cmd;
93 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 90 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
94 struct GNUNET_HashCode hc; 91 struct GNUNET_HashCode hc;
95 int node_number; 92 struct GNUNET_TESTING_NodeConnection *node_connections_head;
93 struct GNUNET_PeerIdentity *peer;
94 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
95 uint32_t num;
96 struct GNUNET_TESTING_NodeConnection *pos_connection;
97 const struct GNUNET_TESTING_Command *system_cmd;
98 struct GNUNET_TESTING_System *tl_system;
96 99
97 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 100 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
98 sss->start_peer_label); 101 sss->start_peer_label);
99 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, 102 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
100 &connected_peers_map); 103 &connected_peers_map);
101 104
102 node_number = 1; 105 system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
103 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); 106 sss->create_label);
104 memcpy (key, 107 GNUNET_TESTING_get_trait_test_system (system_cmd,
105 &hc, 108 &tl_system);
106 sizeof (*key)); 109
107 110 node_connections_head = GNUNET_TESTING_get_connections (sss->num,
108 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, 111 sss->topology);
109 key); 112
110 113 for (int i = 0; i < 1; i++)
111 env = GNUNET_MQ_msg_extra (test, 114 {
112 2600 - sizeof(*test), 115 for (pos_connection = node_connections_head; NULL != pos_connection;
113 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); 116 pos_connection = pos_connection->next)
114 test->num = htonl (sss->num); 117 {
115 memset (&test[1], 118 num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
116 sss->num, 119 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
117 2600 - sizeof(*test)); 120 public_key = peer->public_key;
118 GNUNET_MQ_send (mq, 121 GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
119 env); 122
123 memcpy (key,
124 &hc,
125 sizeof (*key));
126 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
127 key);
128 env = GNUNET_MQ_msg_extra (test,
129 1000 - sizeof(*test),
130 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
131 test->num = htonl (sss->num);
132 memset (&test[1],
133 sss->num,
134 1000 - sizeof(*test));
135 GNUNET_MQ_send (mq,
136 env);
137 }
138 }
139
120 GNUNET_free (key); 140 GNUNET_free (key);
121 141
122} 142}
@@ -126,31 +146,34 @@ send_simple_run (void *cls,
126 * Create command. 146 * Create command.
127 * 147 *
128 * @param label name for command. 148 * @param label name for command.
129 * @param m The number of the local node of the actual network namespace.
130 * @param n The number of the actual namespace.
131 * @param num Number globally identifying the node.
132 * @param start_peer_label Label of the cmd to start a peer. 149 * @param start_peer_label Label of the cmd to start a peer.
150 * @param start_peer_label Label of the cmd which started the test system.
151 * @param num Number globally identifying the node.
152 * @param The topology for the test setup.
133 * @return command. 153 * @return command.
134 */ 154 */
135struct GNUNET_TESTING_Command 155struct GNUNET_TESTING_Command
136GNUNET_TRANSPORT_cmd_send_simple (const char *label, 156GNUNET_TRANSPORT_cmd_send_simple (const char *label,
137 const char *start_peer_label, 157 const char *start_peer_label,
138 uint32_t num) 158 const char *create_label,
159 uint32_t num,
160 struct GNUNET_TESTING_NetjailTopology *
161 topology)
139{ 162{
140 struct SendSimpleState *sss; 163 struct SendSimpleState *sss;
141 164
142 sss = GNUNET_new (struct SendSimpleState); 165 sss = GNUNET_new (struct SendSimpleState);
143 sss->num = num; 166 sss->num = num;
144 sss->start_peer_label = start_peer_label; 167 sss->start_peer_label = start_peer_label;
145 { 168 sss->create_label = create_label;
146 struct GNUNET_TESTING_Command cmd = { 169 sss->topology = topology;
147 .cls = sss, 170
148 .label = label, 171 struct GNUNET_TESTING_Command cmd = {
149 .run = &send_simple_run, 172 .cls = sss,
150 .cleanup = &send_simple_cleanup, 173 .label = label,
151 .traits = &send_simple_traits 174 .run = &send_simple_run,
152 }; 175 .cleanup = &send_simple_cleanup
153 176 };
154 return cmd; 177
155 } 178 return cmd;
156} 179}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index dc19f10eb..a026d48cc 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -235,6 +235,10 @@ start_peer_run (void *cls,
235 235
236 sps->tl_system = tl_system; 236 sps->tl_system = tl_system;
237 237
238 LOG (GNUNET_ERROR_TYPE_ERROR,
239 "Creating testing library with key number %u\n",
240 sps->no);
241
238 if (GNUNET_SYSERR == 242 if (GNUNET_SYSERR ==
239 GNUNET_TESTING_configuration_create (tl_system, 243 GNUNET_TESTING_configuration_create (tl_system,
240 sps->cfg)) 244 sps->cfg))
@@ -255,9 +259,10 @@ start_peer_run (void *cls,
255 if (NULL == sps->peer) 259 if (NULL == sps->peer)
256 { 260 {
257 LOG (GNUNET_ERROR_TYPE_ERROR, 261 LOG (GNUNET_ERROR_TYPE_ERROR,
258 "Testing library failed to create unique configuration based on `%s': `%s'\n", 262 "Testing library failed to create unique configuration based on `%s': `%s' with key number %u\n",
259 sps->cfgname, 263 sps->cfgname,
260 emsg); 264 emsg,
265 sps->no);
261 GNUNET_free (emsg); 266 GNUNET_free (emsg);
262 GNUNET_TESTING_interpreter_fail (is); 267 GNUNET_TESTING_interpreter_fail (is);
263 return; 268 return;
@@ -337,6 +342,11 @@ start_peer_run (void *cls,
337 return; 342 return;
338 } 343 }
339 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); 344 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
345 GNUNET_free (home);
346 GNUNET_free (transport_unix_path);
347 GNUNET_free (tcp_communicator_unix_path);
348 GNUNET_free (udp_communicator_unix_path);
349 GNUNET_free (bindto);
340} 350}
341 351
342 352