aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-04-09 09:18:26 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-04-09 09:18:26 +0000
commitc1f9c2ff70af78dc5d2aed84fc1b5166c5733f3e (patch)
treea9ab35f4b91f90d67818f0496e8caaf26676b3ed /src/transport/gnunet-transport.c
parentd253f3957dee9fcf51a81c187489cb7e1aca57bd (diff)
downloadgnunet-c1f9c2ff70af78dc5d2aed84fc1b5166c5733f3e.tar.gz
gnunet-c1f9c2ff70af78dc5d2aed84fc1b5166c5733f3e.zip
more information why nat tests fail
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r--src/transport/gnunet-transport.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 7842433ed..6f8690244 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -39,7 +39,7 @@
39 * How long do we wait for the NAT test to report success? 39 * How long do we wait for the NAT test to report success?
40 * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'. 40 * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
41 */ 41 */
42#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 42#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
43#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 43#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
44#define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 44#define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
45 45
@@ -263,6 +263,24 @@ struct TestContext
263 263
264}; 264};
265 265
266enum TestResult
267{
268 /* NAT returned success */
269 NAT_TEST_SUCCESS = GNUNET_OK,
270
271 /* NAT returned failure */
272 NAT_TEST_FAIL = GNUNET_NO,
273
274 /* NAT returned failure while running test */
275 NAT_TEST_INTERNAL_FAIL = GNUNET_SYSERR,
276
277 /* We could not start the test */
278 NAT_TEST_FAILED_TO_START = 2,
279
280 /* We had a timeout while running the test */
281 NAT_TEST_TIMEOUT = 3,
282};
283
266static struct ValidationResolutionContext *vc_head; 284static struct ValidationResolutionContext *vc_head;
267static struct ValidationResolutionContext *vc_tail; 285static struct ValidationResolutionContext *vc_tail;
268 286
@@ -455,8 +473,33 @@ run_nat_test ();
455 * @param result #GNUNET_YES on success 473 * @param result #GNUNET_YES on success
456 */ 474 */
457static void 475static void
458display_test_result (struct TestContext *tc, int result) 476display_test_result (struct TestContext *tc, enum TestResult result)
459{ 477{
478 switch (result) {
479 case NAT_TEST_FAIL:
480 FPRINTF (stderr, _("Configuration for plugin `%s' did not work!\n"),
481 tc->name);
482 break;
483 case NAT_TEST_SUCCESS:
484 FPRINTF (stderr, _("Configuration for plugin `%s' did work!\n"),
485 tc->name);
486 break;
487 case NAT_TEST_INTERNAL_FAIL:
488 FPRINTF (stderr, _("Internal NAT error while running test for plugin `%s'\n"),
489 tc->name);
490 break;
491 case NAT_TEST_FAILED_TO_START:
492 FPRINTF (stderr, _("Failed to start NAT test for plugin `%s'\n"),
493 tc->name);
494 break;
495 case NAT_TEST_TIMEOUT:
496 FPRINTF (stderr, _("Timeout while waiting for result of NAT test for plugin `%s'\n"),
497 tc->name);
498 break;
499 default:
500 break;
501 }
502
460 if (GNUNET_YES != result) 503 if (GNUNET_YES != result)
461 { 504 {
462 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name); 505 FPRINTF (stderr, "Configuration for plugin `%s' did not work!\n", tc->name);
@@ -518,7 +561,7 @@ fail_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
518 struct TestContext *tstc = cls; 561 struct TestContext *tstc = cls;
519 562
520 tstc->tsk = GNUNET_SCHEDULER_NO_TASK; 563 tstc->tsk = GNUNET_SCHEDULER_NO_TASK;
521 display_test_result (tstc, GNUNET_NO); 564 display_test_result (tstc, NAT_TEST_TIMEOUT);
522} 565}
523 566
524 567
@@ -676,6 +719,10 @@ void process_validation_cb (void *cls,
676static void 719static void
677run_nat_test () 720run_nat_test ()
678{ 721{
722 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
723 "Running test for plugin `%s' using bind port %u and advertised port %u \n",
724 head->name, (uint16_t) head->bnd_port, (uint16_t) head->adv_port);
725
679 head->tst = GNUNET_NAT_test_start (cfg, 726 head->tst = GNUNET_NAT_test_start (cfg,
680 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES, 727 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES,
681 (uint16_t) head->bnd_port, 728 (uint16_t) head->bnd_port,
@@ -683,7 +730,7 @@ run_nat_test ()
683 &result_callback, head); 730 &result_callback, head);
684 if (NULL == head->tst) 731 if (NULL == head->tst)
685 { 732 {
686 display_test_result (head, GNUNET_SYSERR); 733 display_test_result (head, NAT_TEST_FAILED_TO_START);
687 return; 734 return;
688 } 735 }
689 head->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, head); 736 head->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, head);
@@ -726,8 +773,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
726 _("No port configured for plugin `%s', cannot test it\n"), tok); 773 _("No port configured for plugin `%s', cannot test it\n"), tok);
727 continue; 774 continue;
728 } 775 }
729 if (GNUNET_OK 776 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, section,
730 != GNUNET_CONFIGURATION_get_value_number (cfg, section,
731 "ADVERTISED_PORT", &adv_port)) 777 "ADVERTISED_PORT", &adv_port))
732 adv_port = bnd_port; 778 adv_port = bnd_port;
733 779
@@ -747,6 +793,12 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
747 NULL, NULL, NULL, 793 NULL, NULL, NULL,
748 binary, 794 binary,
749 "gnunet-service-resolver", NULL ); 795 "gnunet-service-resolver", NULL );
796 if (NULL == resolver)
797 {
798 FPRINTF (stderr, _("Failed to start resolver!\n"));
799 return;
800 }
801
750 GNUNET_free(binary); 802 GNUNET_free(binary);
751 GNUNET_RESOLVER_connect (cfg); 803 GNUNET_RESOLVER_connect (cfg);
752 run_nat_test (); 804 run_nat_test ();