aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-24 22:44:15 +0900
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-24 22:44:15 +0900
commit5c5a31d18c22192922e7dac302e10a53135d3248 (patch)
tree96dff193df8b2b90c843d68f8de7fb5ec4452770 /src/transport/transport-testing2.c
parenta967815bd7207de41c7e719ef34628f2eaed3ab0 (diff)
downloadgnunet-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.c65
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 */
662static void 667static void
663shutdown_communicator (void *cls) 668shutdown_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
683static void
684shutdown_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 */
729static void
730shutdown_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 */
741static void
742nat_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
715static void 770static void
716do_shutdown (void *cls) 771do_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);