diff options
Diffstat (limited to 'src/transport/test_transport_api_monitor_peers.c')
-rw-r--r-- | src/transport/test_transport_api_monitor_peers.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c index 90c96829d..4731e41e2 100644 --- a/src/transport/test_transport_api_monitor_peers.c +++ b/src/transport/test_transport_api_monitor_peers.c | |||
@@ -57,15 +57,15 @@ static struct GNUNET_SCHEDULER_Task * die_task; | |||
57 | 57 | ||
58 | static struct GNUNET_SCHEDULER_Task * send_task; | 58 | static struct GNUNET_SCHEDULER_Task * send_task; |
59 | 59 | ||
60 | static struct PeerContext *p1; | 60 | static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1; |
61 | 61 | ||
62 | static struct PeerContext *p2; | 62 | static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2; |
63 | 63 | ||
64 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; | 64 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
65 | 65 | ||
66 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 66 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
67 | 67 | ||
68 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; | 68 | static struct GNUNET_TRANSPORT_TESTING_Handle *tth; |
69 | 69 | ||
70 | static char *cfg_file_p1; | 70 | static char *cfg_file_p1; |
71 | 71 | ||
@@ -107,10 +107,10 @@ end () | |||
107 | th = NULL; | 107 | th = NULL; |
108 | 108 | ||
109 | if (NULL != p1) | 109 | if (NULL != p1) |
110 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 110 | GNUNET_TRANSPORT_TESTING_stop_peer (p1); |
111 | p1 = NULL; | 111 | p1 = NULL; |
112 | if (NULL != p2) | 112 | if (NULL != p2) |
113 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 113 | GNUNET_TRANSPORT_TESTING_stop_peer (p2); |
114 | p2 = NULL; | 114 | p2 = NULL; |
115 | 115 | ||
116 | if (NULL != pmc_p1) | 116 | if (NULL != pmc_p1) |
@@ -143,7 +143,7 @@ end_badly (void *cls) | |||
143 | if (cc != NULL) | 143 | if (cc != NULL) |
144 | { | 144 | { |
145 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | 145 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); |
146 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 146 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc); |
147 | cc = NULL; | 147 | cc = NULL; |
148 | } | 148 | } |
149 | 149 | ||
@@ -181,11 +181,11 @@ end_badly (void *cls) | |||
181 | } | 181 | } |
182 | 182 | ||
183 | if (p1 != NULL) | 183 | if (p1 != NULL) |
184 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 184 | GNUNET_TRANSPORT_TESTING_stop_peer (p1); |
185 | else | 185 | else |
186 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); | 186 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); |
187 | if (p2 != NULL) | 187 | if (p2 != NULL) |
188 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 188 | GNUNET_TRANSPORT_TESTING_stop_peer (p2); |
189 | else | 189 | else |
190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); | 190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); |
191 | 191 | ||
@@ -197,8 +197,8 @@ static void | |||
197 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 197 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
198 | const struct GNUNET_MessageHeader *message) | 198 | const struct GNUNET_MessageHeader *message) |
199 | { | 199 | { |
200 | struct PeerContext *p = cls; | 200 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
201 | struct PeerContext *t = NULL; | 201 | struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL; |
202 | 202 | ||
203 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 203 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
204 | t = p1; | 204 | t = p1; |
@@ -219,7 +219,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
219 | static size_t | 219 | static size_t |
220 | notify_ready (void *cls, size_t size, void *buf) | 220 | notify_ready (void *cls, size_t size, void *buf) |
221 | { | 221 | { |
222 | struct PeerContext *p = cls; | 222 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
223 | struct GNUNET_MessageHeader *hdr; | 223 | struct GNUNET_MessageHeader *hdr; |
224 | 224 | ||
225 | th = NULL; | 225 | th = NULL; |
@@ -294,8 +294,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
294 | static int c; | 294 | static int c; |
295 | 295 | ||
296 | c++; | 296 | c++; |
297 | struct PeerContext *p = cls; | 297 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
298 | struct PeerContext *t = NULL; | 298 | struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL; |
299 | 299 | ||
300 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 300 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
301 | { | 301 | { |
@@ -323,7 +323,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
323 | static void | 323 | static void |
324 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 324 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
325 | { | 325 | { |
326 | struct PeerContext *p = cls; | 326 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
327 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 327 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
328 | 328 | ||
329 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 329 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -339,9 +339,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
339 | 339 | ||
340 | 340 | ||
341 | static void | 341 | static void |
342 | testing_connect_cb (struct PeerContext *p1, | 342 | testing_connect_cb (void *cls) |
343 | struct PeerContext *p2, | ||
344 | void *cls) | ||
345 | { | 343 | { |
346 | cc = NULL; | 344 | cc = NULL; |
347 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 345 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
@@ -357,7 +355,7 @@ testing_connect_cb (struct PeerContext *p1, | |||
357 | 355 | ||
358 | 356 | ||
359 | static void | 357 | static void |
360 | start_cb (struct PeerContext *p, void *cls) | 358 | start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls) |
361 | { | 359 | { |
362 | static int started; | 360 | static int started; |
363 | 361 | ||
@@ -378,7 +376,9 @@ start_cb (struct PeerContext *p, void *cls) | |||
378 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | 376 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); |
379 | GNUNET_free (sender_c); | 377 | GNUNET_free (sender_c); |
380 | 378 | ||
381 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 379 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, |
380 | p2, | ||
381 | &testing_connect_cb, | ||
382 | NULL); | 382 | NULL); |
383 | 383 | ||
384 | } | 384 | } |
@@ -446,9 +446,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
446 | s_connected = GNUNET_NO; | 446 | s_connected = GNUNET_NO; |
447 | s_sending = GNUNET_NO; | 447 | s_sending = GNUNET_NO; |
448 | 448 | ||
449 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 449 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
450 | ¬ify_receive, ¬ify_connect, | 450 | cfg_file_p1, |
451 | ¬ify_disconnect, &start_cb, | 451 | 1, |
452 | ¬ify_receive, | ||
453 | ¬ify_connect, | ||
454 | ¬ify_disconnect, | ||
455 | &start_cb, | ||
452 | NULL); | 456 | NULL); |
453 | pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg, | 457 | pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg, |
454 | NULL, | 458 | NULL, |
@@ -457,9 +461,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
457 | NULL); | 461 | NULL); |
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n"); | 462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n"); |
459 | 463 | ||
460 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 464 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
461 | ¬ify_receive, ¬ify_connect, | 465 | cfg_file_p2, |
462 | ¬ify_disconnect, &start_cb, | 466 | 2, |
467 | ¬ify_receive, | ||
468 | ¬ify_connect, | ||
469 | ¬ify_disconnect, | ||
470 | &start_cb, | ||
463 | NULL); | 471 | NULL); |
464 | pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg, | 472 | pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg, |
465 | NULL, | 473 | NULL, |
@@ -507,18 +515,18 @@ main (int argc, char *argv[]) | |||
507 | 515 | ||
508 | ok = 1; | 516 | ok = 1; |
509 | 517 | ||
510 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | 518 | test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]); |
511 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); | 519 | test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__); |
512 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, | 520 | test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], |
513 | &test_plugin); | 521 | test_source); |
514 | 522 | ||
515 | GNUNET_log_setup (test_name, | 523 | GNUNET_log_setup (test_name, |
516 | "WARNING", | 524 | "WARNING", |
517 | NULL); | 525 | NULL); |
518 | tth = GNUNET_TRANSPORT_TESTING_init (); | 526 | tth = GNUNET_TRANSPORT_TESTING_init (); |
519 | 527 | ||
520 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); | 528 | cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1); |
521 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); | 529 | cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2); |
522 | 530 | ||
523 | ret = check (); | 531 | ret = check (); |
524 | 532 | ||