diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-24 22:44:15 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-24 22:44:15 +0900 |
commit | 5c5a31d18c22192922e7dac302e10a53135d3248 (patch) | |
tree | 96dff193df8b2b90c843d68f8de7fb5ec4452770 /src/transport/transport-testing2.c | |
parent | a967815bd7207de41c7e719ef34628f2eaed3ab0 (diff) | |
download | gnunet-5c5a31d18c22192922e7dac302e10a53135d3248.tar.gz gnunet-5c5a31d18c22192922e7dac302e10a53135d3248.zip |
start nat for tcp
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r-- | src/transport/transport-testing2.c | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index ba58776fb..558bf007f 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -80,6 +80,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | |||
80 | struct GNUNET_OS_Process *c_proc; | 80 | struct GNUNET_OS_Process *c_proc; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * NAT process | ||
84 | */ | ||
85 | struct GNUNET_OS_Process *nat_proc; | ||
86 | |||
87 | /** | ||
83 | * @brief Task that will be run on shutdown to stop and clean communicator | 88 | * @brief Task that will be run on shutdown to stop and clean communicator |
84 | */ | 89 | */ |
85 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; | 90 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; |
@@ -660,10 +665,8 @@ transport_communicator_start ( | |||
660 | * @param cls Closure - Process of communicator | 665 | * @param cls Closure - Process of communicator |
661 | */ | 666 | */ |
662 | static void | 667 | static void |
663 | shutdown_communicator (void *cls) | 668 | shutdown_process (struct GNUNET_OS_Process *proc) |
664 | { | 669 | { |
665 | struct GNUNET_OS_Process *proc = cls; | ||
666 | |||
667 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 670 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
668 | { | 671 | { |
669 | LOG (GNUNET_ERROR_TYPE_WARNING, | 672 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -677,6 +680,13 @@ shutdown_communicator (void *cls) | |||
677 | GNUNET_OS_process_destroy (proc); | 680 | GNUNET_OS_process_destroy (proc); |
678 | } | 681 | } |
679 | 682 | ||
683 | static void | ||
684 | shutdown_communicator (void *cls) | ||
685 | { | ||
686 | struct GNUNET_OS_Process *proc = cls; | ||
687 | shutdown_process(proc); | ||
688 | } | ||
689 | |||
680 | 690 | ||
681 | /** | 691 | /** |
682 | * @brief Start the communicator | 692 | * @brief Start the communicator |
@@ -711,6 +721,51 @@ communicator_start ( | |||
711 | GNUNET_free (binary); | 721 | GNUNET_free (binary); |
712 | } | 722 | } |
713 | 723 | ||
724 | /** | ||
725 | * @brief Task run at shutdown to kill communicator and clean up | ||
726 | * | ||
727 | * @param cls Closure - Process of communicator | ||
728 | */ | ||
729 | static void | ||
730 | shutdown_nat (void *cls) | ||
731 | { | ||
732 | struct GNUNET_OS_Process *proc = cls; | ||
733 | shutdown_process (proc); | ||
734 | } | ||
735 | |||
736 | |||
737 | /** | ||
738 | * @brief Start NAT | ||
739 | * | ||
740 | */ | ||
741 | static void | ||
742 | nat_start ( | ||
743 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | ||
744 | { | ||
745 | char *binary; | ||
746 | |||
747 | LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n"); | ||
748 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat"); | ||
749 | tc_h->nat_proc = GNUNET_OS_start_process (GNUNET_YES, | ||
750 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
751 | NULL, | ||
752 | NULL, | ||
753 | NULL, | ||
754 | binary, | ||
755 | "gnunet-service-nat", | ||
756 | "-c", | ||
757 | tc_h->cfg_filename, | ||
758 | NULL); | ||
759 | if (NULL == tc_h->nat_proc) | ||
760 | { | ||
761 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!"); | ||
762 | return; | ||
763 | } | ||
764 | LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n"); | ||
765 | GNUNET_free (binary); | ||
766 | } | ||
767 | |||
768 | |||
714 | 769 | ||
715 | static void | 770 | static void |
716 | do_shutdown (void *cls) | 771 | do_shutdown (void *cls) |
@@ -718,6 +773,7 @@ do_shutdown (void *cls) | |||
718 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 773 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
719 | shutdown_communicator(tc_h->c_proc); | 774 | shutdown_communicator(tc_h->c_proc); |
720 | shutdown_service(tc_h->sh); | 775 | shutdown_service(tc_h->sh); |
776 | shutdown_nat(tc_h->nat_proc); | ||
721 | } | 777 | } |
722 | 778 | ||
723 | 779 | ||
@@ -771,7 +827,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | |||
771 | 827 | ||
772 | /* Start communicator part of service */ | 828 | /* Start communicator part of service */ |
773 | transport_communicator_start (tc_h); | 829 | transport_communicator_start (tc_h); |
774 | 830 | /* Start NAT */ | |
831 | nat_start (tc_h); | ||
775 | /* Schedule start communicator */ | 832 | /* Schedule start communicator */ |
776 | communicator_start (tc_h, | 833 | communicator_start (tc_h, |
777 | binary_name); | 834 | binary_name); |