aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 16:49:31 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 16:49:31 +0000
commite8a17adb08f54e3c0648393ca6c7010386bcdb18 (patch)
tree470e2034178ae3a0471bb0f6ebac588e620cd039
parentf3d03c48f42088a3d76042eaa7b05f54d41c2d0b (diff)
downloadgnunet-gtk-e8a17adb08f54e3c0648393ca6c7010386bcdb18.tar.gz
gnunet-gtk-e8a17adb08f54e3c0648393ca6c7010386bcdb18.zip
regex on w32 only
-rw-r--r--src/setup/Makefile.am6
-rw-r--r--src/setup/gnunet-setup-transport.c64
2 files changed, 40 insertions, 30 deletions
diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am
index ebb7c27c..a30485ed 100644
--- a/src/setup/Makefile.am
+++ b/src/setup/Makefile.am
@@ -7,6 +7,10 @@ INCLUDES = \
7 @GNUNET_CFLAGS@ \ 7 @GNUNET_CFLAGS@ \
8 @GLADE_CFLAGS@ 8 @GLADE_CFLAGS@
9 9
10if MINGW
11 WINLIBS = -lregex
12endif
13
10bin_PROGRAMS = gnunet-setup 14bin_PROGRAMS = gnunet-setup
11 15
12gnunet_setup_SOURCES = \ 16gnunet_setup_SOURCES = \
@@ -26,7 +30,7 @@ gnunet_setup_SOURCES = \
26gnunet_setup_LDADD = \ 30gnunet_setup_LDADD = \
27 $(top_builddir)/src/lib/libgnunetgtk.la \ 31 $(top_builddir)/src/lib/libgnunetgtk.la \
28 @GTK_LIBS@ \ 32 @GTK_LIBS@ \
29 -lregex \ 33 $(WINLIBS) \
30 -lgnunetutil -lgnunetnat \ 34 -lgnunetutil -lgnunetnat \
31 $(INTLLIBS) 35 $(INTLLIBS)
32gnunet_setup_LDFLAGS = \ 36gnunet_setup_LDFLAGS = \
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 */