aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_plugin_transport.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-17 10:45:23 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-17 10:45:23 +0000
commit7e065c18499688141eb68513058131a49344cac1 (patch)
treee441b44c8f0db8a4f214775e4945039cc820cf2f /src/transport/test_plugin_transport.c
parentb3ad920b6e0107c3da946fe1f2f720955dbac151 (diff)
downloadgnunet-7e065c18499688141eb68513058131a49344cac1.tar.gz
gnunet-7e065c18499688141eb68513058131a49344cac1.zip
fixing #1551/#2503
Diffstat (limited to 'src/transport/test_plugin_transport.c')
-rw-r--r--src/transport/test_plugin_transport.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index e6a016c51..6882f919c 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -139,6 +139,7 @@ struct AddressWrapper
139 char *addrstring; 139 char *addrstring;
140}; 140};
141 141
142
142static void 143static void
143end () 144end ()
144{ 145{
@@ -186,6 +187,7 @@ end ()
186 } 187 }
187} 188}
188 189
190
189static void 191static void
190end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 192end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
191{ 193{
@@ -245,6 +247,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245 ok = 1; 247 ok = 1;
246} 248}
247 249
250
248static void 251static void
249wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 252wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
250{ 253{
@@ -290,6 +293,7 @@ env_receive (void *cls,
290 293
291static int got_reply; 294static int got_reply;
292 295
296
293/** 297/**
294 * Take the given address and append it to the set of results sent back to 298 * Take the given address and append it to the set of results sent back to
295 * the client. 299 * the client.
@@ -435,7 +439,8 @@ env_notify_address (void *cls,
435 } 439 }
436} 440}
437 441
438struct GNUNET_ATS_Information 442
443static struct GNUNET_ATS_Information
439env_get_address_type (void *cls, 444env_get_address_type (void *cls,
440 const struct sockaddr *addr, 445 const struct sockaddr *addr,
441 size_t addrlen) 446 size_t addrlen)
@@ -446,19 +451,22 @@ env_get_address_type (void *cls,
446 return ats; 451 return ats;
447} 452}
448 453
449const struct GNUNET_MessageHeader * 454
450env_get_our_hello (void) 455static const struct GNUNET_MessageHeader *
456env_get_our_hello ()
451{ 457{
452 return (const struct GNUNET_MessageHeader *) hello; 458 return (const struct GNUNET_MessageHeader *) hello;
453} 459}
454 460
455void env_session_end (void *cls,
456 const struct GNUNET_PeerIdentity *peer,
457 struct Session * session)
458{
459 461
462static void
463env_session_end (void *cls,
464 const struct GNUNET_PeerIdentity *peer,
465 struct Session * session)
466{
460} 467}
461 468
469
462static void 470static void
463setup_plugin_environment () 471setup_plugin_environment ()
464{ 472{
@@ -482,6 +490,7 @@ handle_helper_message (void *cls, void *client,
482 return GNUNET_OK; 490 return GNUNET_OK;
483} 491}
484 492
493
485/** 494/**
486 * Runs the test. 495 * Runs the test.
487 * 496 *
@@ -502,33 +511,31 @@ run (void *cls, char *const *args, const char *cfgfile,
502 511
503 cfg = c; 512 cfg = c;
504 /* parse configuration */ 513 /* parse configuration */
505 if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, 514 if ( (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c,
506 "TRANSPORT", 515 "TRANSPORT",
507 "NEIGHBOUR_LIMIT", 516 "NEIGHBOUR_LIMIT",
508 &tneigh)) || 517 &tneigh)) ||
509 (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, 518 (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c,
510 "GNUNETD", "HOSTKEY", 519 "GNUNETD", "HOSTKEY",
511 &keyfile))) 520 &keyfile)))
512 { 521 {
513 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 522 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
514 _("Transport service is lacking key configuration settings. Exiting.\n")); 523 _("Transport service is lacking key configuration settings. Exiting.\n"));
515
516 return; 524 return;
517 } 525 }
518 526
519 stats = GNUNET_STATISTICS_create ("transport", cfg); 527 if (NULL == (stats = GNUNET_STATISTICS_create ("transport", cfg)))
520 if (NULL == stats)
521 { 528 {
522 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 529 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
523 _("Could not create statistics. Exiting.\n")); 530 _("Could not create statistics. Exiting.\n"));
524 end_badly_now (); 531 end_badly_now ();
525 return; 532 return;
526 } 533 }
527 534
528 max_connect_per_transport = (uint32_t) tneigh; 535 max_connect_per_transport = (uint32_t) tneigh;
529 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 536 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
530 GNUNET_free (keyfile); 537 GNUNET_free (keyfile);
531 if (my_private_key == NULL) 538 if (NULL == my_private_key)
532 { 539 {
533 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 540 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
534 _("Transport service could not access hostkey. Exiting.\n")); 541 _("Transport service could not access hostkey. Exiting.\n"));
@@ -638,7 +645,7 @@ run (void *cls, char *const *args, const char *cfgfile,
638 645
639 646
640/** 647/**
641 * The main function for the transport service. 648 * The main function for the test
642 * 649 *
643 * @param argc number of arguments from the command line 650 * @param argc number of arguments from the command line
644 * @param argv command line arguments 651 * @param argv command line arguments
@@ -656,20 +663,19 @@ main (int argc, char *const *argv)
656 "test_plugin_transport", 663 "test_plugin_transport",
657 "-c", 664 "-c",
658 "test_plugin_transport_data.conf", 665 "test_plugin_transport_data.conf",
659 "-L", "WARNING",
660 NULL 666 NULL
661 }; 667 };
662 GNUNET_log_setup ("test-plugin-transport", 668 GNUNET_log_setup ("test-plugin-transport",
663 "WARNING", 669 "WARNING",
664 NULL); 670 NULL);
665 ok = 1; /* set to fail */ 671 ok = 1; /* set to fail */
666 ret = (GNUNET_OK == GNUNET_PROGRAM_run (5, 672 ret = (GNUNET_OK == GNUNET_PROGRAM_run (3,
667 argv_prog, 673 argv_prog,
668 "test-plugin-transport", 674 "test-plugin-transport",
669 "testcase", 675 "testcase",
670 options, 676 options,
671 &run, 677 &run,
672 (void *) argv)) ? ok : 1; 678 (void *) argv)) ? ok : 1;
673 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); 679 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport");
674 return ret; 680 return ret;
675} 681}