diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-29 09:05:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-29 09:05:59 +0000 |
commit | 9d9a3728af2e311bd21cf735561160d91f25e504 (patch) | |
tree | f2d6323663a038a4bf0534d78236dce9032aa1c6 /src/transport/gnunet-transport.c | |
parent | 0241063bab9c0f58c9401d99edc81c1b70361d84 (diff) | |
download | gnunet-9d9a3728af2e311bd21cf735561160d91f25e504.tar.gz gnunet-9d9a3728af2e311bd21cf735561160d91f25e504.zip |
-doxygen fixes, fix starting gnunet-service-resolver as it is no longer in /opt/jdk1.6.0_22/bin/:/home/grothoff/bin/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:.
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 115 |
1 files changed, 72 insertions, 43 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 0393a06cc..8bfa6f7aa 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -165,7 +165,6 @@ static GNUNET_SCHEDULER_TaskIdentifier end; | |||
165 | */ | 165 | */ |
166 | static GNUNET_SCHEDULER_TaskIdentifier op_timeout; | 166 | static GNUNET_SCHEDULER_TaskIdentifier op_timeout; |
167 | 167 | ||
168 | |||
169 | /** | 168 | /** |
170 | * Selected level of verbosity. | 169 | * Selected level of verbosity. |
171 | */ | 170 | */ |
@@ -270,13 +269,14 @@ shutdown_task (void *cls, | |||
270 | } | 269 | } |
271 | } | 270 | } |
272 | 271 | ||
273 | struct ResolutionContext *rc_head; | 272 | |
274 | struct ResolutionContext *rc_tail; | 273 | static struct ResolutionContext *rc_head; |
274 | static struct ResolutionContext *rc_tail; | ||
275 | 275 | ||
276 | struct ResolutionContext | 276 | struct ResolutionContext |
277 | { | 277 | { |
278 | struct ResolutionContext *next; | 278 | struct ResolutionContext *next; |
279 | struct ResolutionContext *prev; | 279 | struct ResolutionContext *prev; |
280 | struct GNUNET_HELLO_Address *addrcp; | 280 | struct GNUNET_HELLO_Address *addrcp; |
281 | struct GNUNET_TRANSPORT_AddressToStringContext *asc; | 281 | struct GNUNET_TRANSPORT_AddressToStringContext *asc; |
282 | int printed; | 282 | int printed; |
@@ -285,10 +285,10 @@ struct ResolutionContext | |||
285 | 285 | ||
286 | static void | 286 | static void |
287 | operation_timeout (void *cls, | 287 | operation_timeout (void *cls, |
288 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 288 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
289 | { | 289 | { |
290 | struct ResolutionContext *cur; | 290 | struct ResolutionContext *cur; |
291 | struct ResolutionContext *next; | 291 | struct ResolutionContext *next; |
292 | op_timeout = GNUNET_SCHEDULER_NO_TASK; | 292 | op_timeout = GNUNET_SCHEDULER_NO_TASK; |
293 | if ((try_connect) || (benchmark_send) || | 293 | if ((try_connect) || (benchmark_send) || |
294 | (benchmark_receive)) | 294 | (benchmark_receive)) |
@@ -331,7 +331,7 @@ operation_timeout (void *cls, | |||
331 | * Display the result of the test. | 331 | * Display the result of the test. |
332 | * | 332 | * |
333 | * @param tc test context | 333 | * @param tc test context |
334 | * @param result GNUNET_YES on success | 334 | * @param result #GNUNET_YES on success |
335 | */ | 335 | */ |
336 | static void | 336 | static void |
337 | display_test_result (struct TestContext *tc, int result) | 337 | display_test_result (struct TestContext *tc, int result) |
@@ -370,7 +370,7 @@ display_test_result (struct TestContext *tc, int result) | |||
370 | * Clean up and update GUI (with success). | 370 | * Clean up and update GUI (with success). |
371 | * | 371 | * |
372 | * @param cls test context | 372 | * @param cls test context |
373 | * @param success currently always GNUNET_OK | 373 | * @param success currently always #GNUNET_OK |
374 | */ | 374 | */ |
375 | static void | 375 | static void |
376 | result_callback (void *cls, int success) | 376 | result_callback (void *cls, int success) |
@@ -411,6 +411,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
411 | unsigned long long bnd_port; | 411 | unsigned long long bnd_port; |
412 | unsigned long long adv_port; | 412 | unsigned long long adv_port; |
413 | struct TestContext *tc; | 413 | struct TestContext *tc; |
414 | char *binary; | ||
414 | 415 | ||
415 | if (GNUNET_OK != | 416 | if (GNUNET_OK != |
416 | GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins", | 417 | GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins", |
@@ -440,12 +441,17 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
440 | &adv_port)) | 441 | &adv_port)) |
441 | adv_port = bnd_port; | 442 | adv_port = bnd_port; |
442 | if (NULL == resolver) | 443 | if (NULL == resolver) |
444 | { | ||
445 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); | ||
443 | resolver = | 446 | resolver = |
444 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-resolver", | 447 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, |
448 | binary, | ||
445 | "gnunet-service-resolver", NULL); | 449 | "gnunet-service-resolver", NULL); |
450 | GNUNET_free (binary); | ||
451 | } | ||
446 | resolver_users++; | 452 | resolver_users++; |
447 | GNUNET_RESOLVER_connect (cfg); | 453 | GNUNET_RESOLVER_connect (cfg); |
448 | tc = GNUNET_malloc (sizeof (struct TestContext)); | 454 | tc = GNUNET_new (struct TestContext); |
449 | tc->name = GNUNET_strdup (tok); | 455 | tc->name = GNUNET_strdup (tok); |
450 | tc->tst = | 456 | tc->tst = |
451 | GNUNET_NAT_test_start (cfg, | 457 | GNUNET_NAT_test_start (cfg, |
@@ -464,16 +470,17 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
464 | GNUNET_free (plugins); | 470 | GNUNET_free (plugins); |
465 | } | 471 | } |
466 | 472 | ||
473 | |||
467 | /** | 474 | /** |
468 | * Function called to notify a client about the socket | 475 | * Function called to notify a client about the socket |
469 | * begin ready to queue more data. "buf" will be | 476 | * begin ready to queue more data. @a buf will be |
470 | * NULL and "size" zero if the socket was closed for | 477 | * NULL and @a size zero if the socket was closed for |
471 | * writing in the meantime. | 478 | * writing in the meantime. |
472 | * | 479 | * |
473 | * @param cls closure | 480 | * @param cls closure |
474 | * @param size number of bytes available in buf | 481 | * @param size number of bytes available in @a buf |
475 | * @param buf where the callee should write the message | 482 | * @param buf where the callee should write the message |
476 | * @return number of bytes written to buf | 483 | * @return number of bytes written to @a buf |
477 | */ | 484 | */ |
478 | static size_t | 485 | static size_t |
479 | transmit_data (void *cls, size_t size, void *buf) | 486 | transmit_data (void *cls, size_t size, void *buf) |
@@ -598,7 +605,8 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
598 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); | 605 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); |
599 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); | 606 | const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); |
600 | 607 | ||
601 | FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), | 608 | FPRINTF (stdout, |
609 | _("%24s: %-17s %4s (%u connections in total)\n"), | ||
602 | now_str, | 610 | now_str, |
603 | _("Connected to"), | 611 | _("Connected to"), |
604 | GNUNET_i2s (peer), | 612 | GNUNET_i2s (peer), |
@@ -622,7 +630,8 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
622 | GNUNET_assert (monitor_connect_counter > 0); | 630 | GNUNET_assert (monitor_connect_counter > 0); |
623 | monitor_connect_counter --; | 631 | monitor_connect_counter --; |
624 | 632 | ||
625 | FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), | 633 | FPRINTF (stdout, |
634 | _("%24s: %-17s %4s (%u connections in total)\n"), | ||
626 | now_str, | 635 | now_str, |
627 | _("Disconnected from"), | 636 | _("Disconnected from"), |
628 | GNUNET_i2s (peer), | 637 | GNUNET_i2s (peer), |
@@ -647,7 +656,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
647 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) | 656 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) |
648 | return; | 657 | return; |
649 | if (verbosity > 0) | 658 | if (verbosity > 0) |
650 | FPRINTF (stdout, _("Received %u bytes from %s\n"), | 659 | FPRINTF (stdout, |
660 | _("Received %u bytes from %s\n"), | ||
651 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); | 661 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); |
652 | 662 | ||
653 | if (traffic_received == 0) | 663 | if (traffic_received == 0) |
@@ -658,8 +668,9 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
658 | } | 668 | } |
659 | 669 | ||
660 | 670 | ||
661 | static void resolve_address (const struct GNUNET_HELLO_Address *address, | 671 | static void |
662 | int numeric); | 672 | resolve_address (const struct GNUNET_HELLO_Address *address, |
673 | int numeric); | ||
663 | 674 | ||
664 | 675 | ||
665 | static void | 676 | static void |
@@ -670,7 +681,11 @@ process_string (void *cls, const char *address) | |||
670 | 681 | ||
671 | if (address != NULL) | 682 | if (address != NULL) |
672 | { | 683 | { |
673 | FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name, address); | 684 | FPRINTF (stdout, |
685 | _("Peer `%s': %s %s\n"), | ||
686 | GNUNET_i2s (&addrcp->peer), | ||
687 | addrcp->transport_name, | ||
688 | address); | ||
674 | rc->printed = GNUNET_YES; | 689 | rc->printed = GNUNET_YES; |
675 | } | 690 | } |
676 | else | 691 | else |
@@ -680,12 +695,15 @@ process_string (void *cls, const char *address) | |||
680 | address_resolutions --; | 695 | address_resolutions --; |
681 | if (GNUNET_NO == rc->printed) | 696 | if (GNUNET_NO == rc->printed) |
682 | { | 697 | { |
683 | if (numeric == GNUNET_NO) | 698 | if (numeric == GNUNET_NO) |
684 | { | 699 | { |
685 | resolve_address (rc->addrcp, GNUNET_YES ); /* Failed to resolve address, try numeric lookup */ | 700 | resolve_address (rc->addrcp, GNUNET_YES ); /* Failed to resolve address, try numeric lookup */ |
686 | } | 701 | } |
687 | else | 702 | else |
688 | FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name); | 703 | FPRINTF (stdout, |
704 | _("Peer `%s': %s <unable to resolve address>\n"), | ||
705 | GNUNET_i2s (&addrcp->peer), | ||
706 | addrcp->transport_name); | ||
689 | } | 707 | } |
690 | GNUNET_free (rc->addrcp); | 708 | GNUNET_free (rc->addrcp); |
691 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc); | 709 | GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, rc); |
@@ -708,12 +726,14 @@ process_string (void *cls, const char *address) | |||
708 | } | 726 | } |
709 | } | 727 | } |
710 | 728 | ||
711 | static void resolve_address (const struct GNUNET_HELLO_Address *address, | 729 | |
712 | int numeric) | 730 | static void |
731 | resolve_address (const struct GNUNET_HELLO_Address *address, | ||
732 | int numeric) | ||
713 | { | 733 | { |
714 | struct ResolutionContext *rc; | 734 | struct ResolutionContext *rc; |
715 | 735 | ||
716 | rc = GNUNET_malloc(sizeof (struct ResolutionContext)); | 736 | rc = GNUNET_new (struct ResolutionContext); |
717 | GNUNET_assert (NULL != rc); | 737 | GNUNET_assert (NULL != rc); |
718 | GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); | 738 | GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); |
719 | address_resolutions ++; | 739 | address_resolutions ++; |
@@ -763,8 +783,10 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
763 | resolve_address (address, numeric); | 783 | resolve_address (address, numeric); |
764 | } | 784 | } |
765 | 785 | ||
766 | void try_connect_cb (void *cls, | 786 | |
767 | const int result) | 787 | static void |
788 | try_connect_cb (void *cls, | ||
789 | const int result) | ||
768 | { | 790 | { |
769 | static int retries = 0; | 791 | static int retries = 0; |
770 | if (GNUNET_OK == result) | 792 | if (GNUNET_OK == result) |
@@ -792,7 +814,7 @@ void try_connect_cb (void *cls, | |||
792 | * service is running. | 814 | * service is running. |
793 | * | 815 | * |
794 | * @param cls closure with our configuration | 816 | * @param cls closure with our configuration |
795 | * @param result GNUNET_YES if transport is running | 817 | * @param result #GNUNET_YES if transport is running |
796 | */ | 818 | */ |
797 | static void | 819 | static void |
798 | testservice_task (void *cls, | 820 | testservice_task (void *cls, |
@@ -822,13 +844,15 @@ testservice_task (void *cls, | |||
822 | 844 | ||
823 | if (1 < counter) | 845 | if (1 < counter) |
824 | { | 846 | { |
825 | FPRINTF (stderr, _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"), | 847 | FPRINTF (stderr, |
848 | _("Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s\n"), | ||
826 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); | 849 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); |
827 | return; | 850 | return; |
828 | } | 851 | } |
829 | if (0 == counter) | 852 | if (0 == counter) |
830 | { | 853 | { |
831 | FPRINTF (stderr, _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"), | 854 | FPRINTF (stderr, |
855 | _("No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s\n"), | ||
832 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); | 856 | "connect", "benchmark send", "benchmark receive", "information", "monitor", "events"); |
833 | return; | 857 | return; |
834 | } | 858 | } |
@@ -837,7 +861,8 @@ testservice_task (void *cls, | |||
837 | { | 861 | { |
838 | if (NULL == cpid) | 862 | if (NULL == cpid) |
839 | { | 863 | { |
840 | FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), | 864 | FPRINTF (stderr, |
865 | _("Option `%s' makes no sense without option `%s'.\n"), | ||
841 | "-C", "-p"); | 866 | "-C", "-p"); |
842 | ret = 1; | 867 | ret = 1; |
843 | return; | 868 | return; |
@@ -848,16 +873,20 @@ testservice_task (void *cls, | |||
848 | ¬ify_disconnect); | 873 | ¬ify_disconnect); |
849 | if (NULL == handle) | 874 | if (NULL == handle) |
850 | { | 875 | { |
851 | FPRINTF (stderr, "%s", _("Failed to connect to transport service\n")); | 876 | FPRINTF (stderr, |
877 | "%s", | ||
878 | _("Failed to connect to transport service\n")); | ||
852 | ret = 1; | 879 | ret = 1; |
853 | return; | 880 | return; |
854 | } | 881 | } |
855 | tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL); | 882 | tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid, try_connect_cb, NULL); |
856 | if (NULL == tc_handle) | 883 | if (NULL == tc_handle) |
857 | { | 884 | { |
858 | FPRINTF (stderr, "%s", _("Failed to send request to transport service\n")); | 885 | FPRINTF (stderr, |
859 | ret = 1; | 886 | "%s", |
860 | return; | 887 | _("Failed to send request to transport service\n")); |
888 | ret = 1; | ||
889 | return; | ||
861 | } | 890 | } |
862 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, | 891 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, |
863 | &operation_timeout, NULL); | 892 | &operation_timeout, NULL); |
@@ -968,8 +997,8 @@ static void | |||
968 | run (void *cls, char *const *args, const char *cfgfile, | 997 | run (void *cls, char *const *args, const char *cfgfile, |
969 | const struct GNUNET_CONFIGURATION_Handle *mycfg) | 998 | const struct GNUNET_CONFIGURATION_Handle *mycfg) |
970 | { | 999 | { |
971 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; | 1000 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; |
972 | if (test_configuration) | 1001 | if (test_configuration) |
973 | { | 1002 | { |
974 | do_test_configuration (cfg); | 1003 | do_test_configuration (cfg); |
975 | return; | 1004 | return; |