aboutsummaryrefslogtreecommitdiff
path: root/src/setup/gnunet-setup-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup/gnunet-setup-transport.c')
-rw-r--r--src/setup/gnunet-setup-transport.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/setup/gnunet-setup-transport.c b/src/setup/gnunet-setup-transport.c
index 652c356b..85792964 100644
--- a/src/setup/gnunet-setup-transport.c
+++ b/src/setup/gnunet-setup-transport.c
@@ -43,6 +43,30 @@ static struct GNUNET_NAT_Test *tst;
43 */ 43 */
44static GNUNET_SCHEDULER_TaskIdentifier tsk; 44static GNUNET_SCHEDULER_TaskIdentifier tsk;
45 45
46static struct GNUNET_OS_Process *resolver;
47
48
49/**
50 * Update the ICMP server button based on the result.
51 *
52 * @param on GNUNET_YES to enable, GNUNET_NO to disable
53 */
54static void
55update_icmp_server_enable_button (int on)
56{
57 GtkToggleButton *button;
58
59 button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_icmp_server_enable_checkbutton"));
60 if (button == NULL)
61 {
62 GNUNET_break (0);
63 return;
64 }
65 gtk_toggle_button_set_active (button,
66 on ? TRUE : FALSE);
67}
68
69
46 70
47/** 71/**
48 * Function called by NAT on success. 72 * Function called by NAT on success.
@@ -55,13 +79,16 @@ static void
55result_callback (void *cls, 79result_callback (void *cls,
56 int success) 80 int success)
57{ 81{
58 int *ok = cls;
59
60 *ok = success;
61 GNUNET_SCHEDULER_cancel (tsk); 82 GNUNET_SCHEDULER_cancel (tsk);
62 tsk = GNUNET_SCHEDULER_NO_TASK; 83 tsk = GNUNET_SCHEDULER_NO_TASK;
63 GNUNET_NAT_test_stop (tst); 84 GNUNET_NAT_test_stop (tst);
64 tst = NULL; 85 tst = NULL;
86 if (NULL != resolver)
87 {
88 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
89 GNUNET_OS_process_close (resolver);
90 }
91 update_icmp_server_enable_button (success);
65} 92}
66 93
67 94
@@ -76,15 +103,14 @@ static void
76fail_timeout (void *cls, 103fail_timeout (void *cls,
77 const struct GNUNET_SCHEDULER_TaskContext *tc) 104 const struct GNUNET_SCHEDULER_TaskContext *tc)
78{ 105{
79 int *ok = cls;
80
81 GNUNET_assert (NULL != tst); 106 GNUNET_assert (NULL != tst);
82 *ok = GNUNET_NO;
83 tsk = GNUNET_SCHEDULER_NO_TASK; 107 tsk = GNUNET_SCHEDULER_NO_TASK;
84 GNUNET_NAT_test_stop (tst); 108 GNUNET_NAT_test_stop (tst);
85 tst = NULL; 109 tst = NULL;
110 update_icmp_server_enable_button (GNUNET_NO);
86} 111}
87 112
113
88/** 114/**
89 * Main function for the connection reversal test. 115 * Main function for the connection reversal test.
90 * 116 *
@@ -116,26 +142,14 @@ reversal_test (void *cls,
116 142
117/** 143/**
118 * Test if connection reversal (ICMP method) works. 144 * Test if connection reversal (ICMP method) works.
119 *
120 * @return GNUNET_YES if it works, GNUNET_NO if not.
121 */ 145 */
122static int 146static void
123test_connection_reversal () 147test_connection_reversal ()
124{ 148{
125 int ok;
126 struct GNUNET_OS_Process *resolver;
127
128 resolver = GNUNET_OS_start_process (NULL, NULL, 149 resolver = GNUNET_OS_start_process (NULL, NULL,
129 "gnunet-service-resolver", 150 "gnunet-service-resolver",
130 "gnunet-service-resolver", NULL); 151 "gnunet-service-resolver", NULL);
131 ok = GNUNET_NO; 152 GNUNET_SCHEDULER_add_now (&reversal_test, NULL);
132 GNUNET_SCHEDULER_run (&reversal_test, &ok);
133 if (NULL != resolver)
134 {
135 GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
136 GNUNET_OS_process_close (resolver);
137 }
138 return ok;
139} 153}
140 154
141 155
@@ -255,16 +269,8 @@ GNUNET_setup_transport_autoconfig_button_clicked_cb ()
255 GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server")) ); 269 GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server")) );
256 GNUNET_free_non_null (tmp); 270 GNUNET_free_non_null (tmp);
257 if (hns) 271 if (hns)
258 hns = test_connection_reversal (); 272 test_connection_reversal ();
259 273
260 button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_icmp_server_enable_checkbutton"));
261 if (button == NULL)
262 {
263 GNUNET_break (0);
264 return;
265 }
266 gtk_toggle_button_set_active (button,
267 hns ? TRUE : FALSE);
268 274
269 275
270 /* test gnunet-helper-nat-client */ 276 /* test gnunet-helper-nat-client */