aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_transport_plugin_cmd_nat_upnp.c3
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c3
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_dv.c5
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_performance.c5
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c3
-rw-r--r--src/transport/transport-testing-cmds.h173
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c48
-rw-r--r--src/transport/transport_api_cmd_start_peer.c20
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c2
9 files changed, 62 insertions, 200 deletions
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c b/src/transport/test_transport_plugin_cmd_nat_upnp.c
index 1b02fbfc2..5c5e71e85 100644
--- a/src/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -286,7 +286,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
286 "system-create", 286 "system-create",
287 num, 287 num,
288 topology, 288 topology,
289 0); 289 0,
290 GNUNET_YES);
290 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 291 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
291 "local-test-prepared", 292 "local-test-prepared",
292 write_message); 293 write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 375796dff..0c9bfa890 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -263,7 +263,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
263 "system-create", 263 "system-create",
264 num, 264 num,
265 topology, 265 topology,
266 0); 266 0,
267 GNUNET_YES);
267 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 268 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
268 "local-test-prepared", 269 "local-test-prepared",
269 write_message); 270 write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
index 55ab4a48f..ac3e8b24b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -89,7 +89,7 @@ handle_test (void *cls,
89 unsigned int connected; 89 unsigned int connected;
90 struct GNUNET_TESTING_BlockState *bs; 90 struct GNUNET_TESTING_BlockState *bs;
91 struct GNUNET_TRANSPORT_CoreHandle *ch; 91 struct GNUNET_TRANSPORT_CoreHandle *ch;
92 const struct StartPeerState *sps; 92 const struct GNUNET_TESTING_StartPeerState *sps;
93 93
94 94
95 GNUNET_TRANSPORT_get_trait_state (&start_peer, 95 GNUNET_TRANSPORT_get_trait_state (&start_peer,
@@ -325,7 +325,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
325 "system-create", 325 "system-create",
326 num, 326 num,
327 topology, 327 topology,
328 topology->additional_connects); 328 topology->additional_connects,
329 GNUNET_YES);
329 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 330 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
330 "local-test-prepared", 331 "local-test-prepared",
331 write_message); 332 write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_performance.c b/src/transport/test_transport_plugin_cmd_simple_send_performance.c
index 013a3c2b2..931801d77 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_performance.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_performance.c
@@ -111,7 +111,7 @@ handle_test (void *cls,
111 struct GNUNET_TIME_Relative time_traveled; 111 struct GNUNET_TIME_Relative time_traveled;
112 uint32_t num; 112 uint32_t num;
113 struct GNUNET_TRANSPORT_CoreHandle *ch; 113 struct GNUNET_TRANSPORT_CoreHandle *ch;
114 const struct StartPeerState *sps; 114 const struct GNUNET_TESTING_StartPeerState *sps;
115 115
116 116
117 GNUNET_TRANSPORT_get_trait_state (&start_peer, 117 GNUNET_TRANSPORT_get_trait_state (&start_peer,
@@ -393,7 +393,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
393 "system-create", 393 "system-create",
394 num, 394 num,
395 topology, 395 topology,
396 0); 396 0,
397 GNUNET_YES);
397 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 398 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
398 "local-test-prepared", 399 "local-test-prepared",
399 write_message); 400 write_message);
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 5e931fbe3..5f411e20e 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -255,7 +255,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
255 "system-create", 255 "system-create",
256 num, 256 num,
257 topology, 257 topology,
258 0); 258 0,
259 GNUNET_YES);
259 local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( 260 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
260 "local-test-prepared", 261 "local-test-prepared",
261 write_message); 262 write_message);
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index 6e3c761f2..6b6fcf4f1 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -33,175 +33,7 @@ typedef void *
33(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is, 33(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
34 const struct GNUNET_PeerIdentity *peer); 34 const struct GNUNET_PeerIdentity *peer);
35 35
36/**
37 * Struct to store information needed in callbacks.
38 *
39 */
40struct ConnectPeersState
41{
42 /**
43 * Context for our asynchronous completion.
44 */
45 struct GNUNET_TESTING_AsyncContext ac;
46
47 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
48
49 /**
50 * The testing system of this node.
51 */
52 const struct GNUNET_TESTING_System *tl_system;
53
54 // Label of the cmd which started the test system.
55 const char *create_label;
56
57 /**
58 * Number globally identifying the node.
59 *
60 */
61 uint32_t num;
62
63 /**
64 * Label of the cmd to start a peer.
65 *
66 */
67 const char *start_peer_label;
68
69 /**
70 * The topology of the test setup.
71 */
72 struct GNUNET_TESTING_NetjailTopology *topology;
73
74 /**
75 * Connections to other peers.
76 */
77 struct GNUNET_TESTING_NodeConnection *node_connections_head;
78
79 struct GNUNET_TESTING_Interpreter *is;
80
81 /**
82 * Number of connections.
83 */
84 unsigned int con_num;
85
86 /**
87 * Number of additional connects this cmd will wait for not triggered by this cmd.
88 */
89 unsigned int additional_connects;
90
91 /**
92 * Number of connections we already have a notification for.
93 */
94 unsigned int con_num_notified;
95
96 /**
97 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
98 */
99 unsigned int additional_connects_notified;
100};
101
102struct StartPeerState
103{
104 /**
105 * Context for our asynchronous completion.
106 */
107 struct GNUNET_TESTING_AsyncContext ac;
108
109 /**
110 * The ip of a node.
111 */
112 char *node_ip;
113
114 /**
115 * Receive callback
116 */
117 struct GNUNET_MQ_MessageHandler *handlers;
118
119 /**
120 * GNUnet configuration file used to start a peer.
121 */
122 char *cfgname;
123
124 /**
125 * Peer's configuration
126 */
127 struct GNUNET_CONFIGURATION_Handle *cfg;
128
129 /**
130 * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
131 */
132 struct GNUNET_TESTING_Peer *peer;
133
134 /**
135 * Peer identity
136 */
137 struct GNUNET_PeerIdentity id;
138
139 /**
140 * Peer's transport service handle
141 */
142 struct GNUNET_TRANSPORT_CoreHandle *th;
143 36
144 /**
145 * Application handle
146 */
147 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
148
149 /**
150 * Peer's PEERSTORE Handle
151 */
152 struct GNUNET_PEERSTORE_Handle *ph;
153
154 /**
155 * Hello get task
156 */
157 struct GNUNET_SCHEDULER_Task *rh_task;
158
159 /**
160 * Peer's transport get hello handle to retrieve peer's HELLO message
161 */
162 struct GNUNET_PEERSTORE_IterateContext *pic;
163
164 /**
165 * Hello
166 */
167 char *hello;
168
169 /**
170 * Hello size
171 */
172 size_t hello_size;
173
174 /**
175 * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
176 */
177 char *system_label;
178
179 /**
180 * An unique number to identify the peer
181 */
182 unsigned int no;
183
184 /**
185 * A map with struct GNUNET_MQ_Handle values for each peer this peer
186 * is connected to.
187 */
188 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
189
190 /**
191 * Test setup for this peer.
192 */
193 const struct GNUNET_TESTING_System *tl_system;
194
195 /**
196 * Callback which is called on neighbour connect events.
197 */
198 GNUNET_TRANSPORT_notify_connect_cb notify_connect;
199
200 /**
201 * Flag indicating, if udp broadcast should be switched on.
202 */
203 enum GNUNET_GenericReturnValue broadcast;
204};
205 37
206struct TestState 38struct TestState
207{ 39{
@@ -283,7 +115,8 @@ GNUNET_TRANSPORT_cmd_connect_peers (
283 const char *create_label, 115 const char *create_label,
284 uint32_t num, 116 uint32_t num,
285 struct GNUNET_TESTING_NetjailTopology *topology, 117 struct GNUNET_TESTING_NetjailTopology *topology,
286 unsigned int additional_connects); 118 unsigned int additional_connects,
119 unsigned int wait_for_connect);
287 120
288 121
289/** 122/**
@@ -402,7 +235,7 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
402 op (hello, const char) \ 235 op (hello, const char) \
403 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \ 236 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
404 op (connect_peer_state, const struct ConnectPeersState) \ 237 op (connect_peer_state, const struct ConnectPeersState) \
405 op (state, const struct StartPeerState) \ 238 op (state, const struct GNUNET_TESTING_StartPeerState) \
406 op (broadcast, const enum GNUNET_GenericReturnValue) 239 op (broadcast, const enum GNUNET_GenericReturnValue)
407 240
408GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT) 241GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 7feecbcc7..8ff206a23 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -65,8 +65,21 @@ connect_peers_run (void *cls,
65 cps->is = is; 65 cps->is = is;
66 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 66 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
67 cps->start_peer_label); 67 cps->start_peer_label);
68 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, 68 if (GNUNET_YES == cps->wait_for_connect)
69 &ah); 69 {
70 LOG (GNUNET_ERROR_TYPE_DEBUG,
71 "Wait for connect.\n");
72 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
73 &ah);
74 }
75 else
76 {
77 LOG (GNUNET_ERROR_TYPE_DEBUG,
78 "Not waiting for connect.\n");
79 GNUNET_TESTING_get_trait_application_handle (peer1_cmd,
80 &ah);
81 }
82
70 GNUNET_TRANSPORT_get_trait_broadcast (peer1_cmd, 83 GNUNET_TRANSPORT_get_trait_broadcast (peer1_cmd,
71 &broadcast); 84 &broadcast);
72 85
@@ -139,12 +152,13 @@ connect_peers_run (void *cls,
139 } 152 }
140 peer = GNUNET_TESTING_get_peer (num, tl_system); 153 peer = GNUNET_TESTING_get_peer (num, tl_system);
141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
142 "validating peer number %u with identity %s and address %s %u %s\n", 155 "validating peer number %u with identity %s and address %s %u %s and handle %p\n",
143 num, 156 num,
144 GNUNET_i2s (peer), 157 GNUNET_i2s (peer),
145 addr_and_port, 158 addr_and_port,
146 *broadcast, 159 *broadcast,
147 pos_prefix->address_prefix); 160 pos_prefix->address_prefix,
161 ah);
148 GNUNET_TRANSPORT_application_validate ((struct 162 GNUNET_TRANSPORT_application_validate ((struct
149 GNUNET_TRANSPORT_ApplicationHandle 163 GNUNET_TRANSPORT_ApplicationHandle
150 *) ah, 164 *) ah,
@@ -252,7 +266,8 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
252 uint32_t num, 266 uint32_t num,
253 struct GNUNET_TESTING_NetjailTopology * 267 struct GNUNET_TESTING_NetjailTopology *
254 topology, 268 topology,
255 unsigned int additional_connects) 269 unsigned int additional_connects,
270 unsigned int wait_for_connect)
256{ 271{
257 struct ConnectPeersState *cps; 272 struct ConnectPeersState *cps;
258 unsigned int node_additional_connects; 273 unsigned int node_additional_connects;
@@ -275,11 +290,20 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
275 cps->topology = topology; 290 cps->topology = topology;
276 cps->notify_connect = notify_connect; 291 cps->notify_connect = notify_connect;
277 cps->additional_connects = additional_connects; 292 cps->additional_connects = additional_connects;
278 293 cps->wait_for_connect = wait_for_connect;
279 return GNUNET_TESTING_command_new (cps, 294
280 label, 295 if (GNUNET_YES == wait_for_connect)
281 &connect_peers_run, 296 return GNUNET_TESTING_command_new (cps,
282 &connect_peers_cleanup, 297 label,
283 &connect_peers_traits, 298 &connect_peers_run,
284 &cps->ac); 299 &connect_peers_cleanup,
300 &connect_peers_traits,
301 &cps->ac);
302 else
303 return GNUNET_TESTING_command_new (cps,
304 label,
305 &connect_peers_run,
306 &connect_peers_cleanup,
307 &connect_peers_traits,
308 NULL);
285} 309}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 1f8ef2f8f..c4098e26d 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -51,7 +51,7 @@ hello_iter_cb (void *cb_cls,
51 const struct GNUNET_PEERSTORE_Record *record, 51 const struct GNUNET_PEERSTORE_Record *record,
52 const char *emsg) 52 const char *emsg)
53{ 53{
54 struct StartPeerState *sps = cb_cls; 54 struct GNUNET_TESTING_StartPeerState *sps = cb_cls;
55 if (NULL == record) 55 if (NULL == record)
56 { 56 {
57 sps->pic = NULL; 57 sps->pic = NULL;
@@ -81,7 +81,7 @@ hello_iter_cb (void *cb_cls,
81static void 81static void
82retrieve_hello (void *cls) 82retrieve_hello (void *cls)
83{ 83{
84 struct StartPeerState *sps = cls; 84 struct GNUNET_TESTING_StartPeerState *sps = cls;
85 sps->rh_task = NULL; 85 sps->rh_task = NULL;
86 sps->pic = GNUNET_PEERSTORE_iterate (sps->ph, 86 sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
87 "transport", 87 "transport",
@@ -102,7 +102,7 @@ notify_disconnect (void *cls,
102 const struct GNUNET_PeerIdentity *peer, 102 const struct GNUNET_PeerIdentity *peer,
103 void *handler_cls) 103 void *handler_cls)
104{ 104{
105 struct StartPeerState *sps = cls; 105 struct GNUNET_TESTING_StartPeerState *sps = cls;
106 106
107 LOG (GNUNET_ERROR_TYPE_DEBUG, 107 LOG (GNUNET_ERROR_TYPE_DEBUG,
108 "Peer %s disconnected from peer %u (`%s')\n", 108 "Peer %s disconnected from peer %u (`%s')\n",
@@ -122,7 +122,7 @@ notify_connect (void *cls,
122 const struct GNUNET_PeerIdentity *peer, 122 const struct GNUNET_PeerIdentity *peer,
123 struct GNUNET_MQ_Handle *mq) 123 struct GNUNET_MQ_Handle *mq)
124{ 124{
125 struct StartPeerState *sps = cls; 125 struct GNUNET_TESTING_StartPeerState *sps = cls;
126 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 126 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
127 struct GNUNET_HashCode hc; 127 struct GNUNET_HashCode hc;
128 struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key; 128 struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
@@ -168,7 +168,7 @@ static void
168start_peer_run (void *cls, 168start_peer_run (void *cls,
169 struct GNUNET_TESTING_Interpreter *is) 169 struct GNUNET_TESTING_Interpreter *is)
170{ 170{
171 struct StartPeerState *sps = cls; 171 struct GNUNET_TESTING_StartPeerState *sps = cls;
172 char *emsg = NULL; 172 char *emsg = NULL;
173 struct GNUNET_PeerIdentity dummy; 173 struct GNUNET_PeerIdentity dummy;
174 const struct GNUNET_TESTING_Command *system_cmd; 174 const struct GNUNET_TESTING_Command *system_cmd;
@@ -339,7 +339,7 @@ start_peer_run (void *cls,
339 } 339 }
340 340
341 sps->ph = GNUNET_PEERSTORE_connect (sps->cfg); 341 sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
342 if (NULL == sps->th) 342 if (NULL == sps->ph)
343 { 343 {
344 LOG (GNUNET_ERROR_TYPE_ERROR, 344 LOG (GNUNET_ERROR_TYPE_ERROR,
345 "Failed to connect to peerstore service for peer `%s': `%s'\n", 345 "Failed to connect to peerstore service for peer `%s': `%s'\n",
@@ -378,7 +378,7 @@ start_peer_run (void *cls,
378static void 378static void
379start_peer_cleanup (void *cls) 379start_peer_cleanup (void *cls)
380{ 380{
381 struct StartPeerState *sps = cls; 381 struct GNUNET_TESTING_StartPeerState *sps = cls;
382 382
383 if (NULL != sps->handlers) 383 if (NULL != sps->handlers)
384 { 384 {
@@ -410,7 +410,7 @@ start_peer_traits (void *cls,
410 const char *trait, 410 const char *trait,
411 unsigned int index) 411 unsigned int index)
412{ 412{
413 struct StartPeerState *sps = cls; 413 struct GNUNET_TESTING_StartPeerState *sps = cls;
414 struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; 414 struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
415 struct GNUNET_PeerIdentity *id = &sps->id; 415 struct GNUNET_PeerIdentity *id = &sps->id;
416 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = 416 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -450,12 +450,12 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
450 notify_connect, 450 notify_connect,
451 unsigned int broadcast) 451 unsigned int broadcast)
452{ 452{
453 struct StartPeerState *sps; 453 struct GNUNET_TESTING_StartPeerState *sps;
454 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = 454 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
455 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); 455 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
456 unsigned int i; 456 unsigned int i;
457 457
458 sps = GNUNET_new (struct StartPeerState); 458 sps = GNUNET_new (struct GNUNET_TESTING_StartPeerState);
459 sps->no = no; 459 sps->no = no;
460 sps->system_label = GNUNET_strdup (system_label); 460 sps->system_label = GNUNET_strdup (system_label);
461 sps->connected_peers_map = connected_peers_map; 461 sps->connected_peers_map = connected_peers_map;
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index a80742b5f..60d48c56b 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -58,7 +58,7 @@ stop_peer_run (void *cls,
58 struct GNUNET_TESTING_Interpreter *is) 58 struct GNUNET_TESTING_Interpreter *is)
59{ 59{
60 struct StopPeerState *stop_ps = cls; 60 struct StopPeerState *stop_ps = cls;
61 const struct StartPeerState *sps; 61 const struct GNUNET_TESTING_StartPeerState *sps;
62 const struct GNUNET_TESTING_Command *start_cmd; 62 const struct GNUNET_TESTING_Command *start_cmd;
63 63
64 start_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 64 start_cmd = GNUNET_TESTING_interpreter_lookup_command (is,