[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15872 - in gnunet-setup: contrib src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15872 - in gnunet-setup: contrib src |
Date: |
Thu, 7 Jul 2011 16:15:20 +0200 |
Author: grothoff
Date: 2011-07-07 16:15:20 +0200 (Thu, 07 Jul 2011)
New Revision: 15872
Added:
gnunet-setup/src/gnunet-setup-transport-udp.c
Modified:
gnunet-setup/contrib/gnunet-setup.glade
gnunet-setup/src/Makefile.am
gnunet-setup/src/gnunet-setup-transport-tcp.c
Log:
udp test
Modified: gnunet-setup/contrib/gnunet-setup.glade
===================================================================
--- gnunet-setup/contrib/gnunet-setup.glade 2011-07-07 13:45:31 UTC (rev
15871)
+++ gnunet-setup/contrib/gnunet-setup.glade 2011-07-07 14:15:20 UTC (rev
15872)
@@ -511,7 +511,6 @@
<property
name="hadjustment">adjustment7</property>
<property
name="vadjustment">adjustment8</property>
<property
name="hscrollbar_policy">never</property>
- <property
name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTreeView"
id="GNUNET_setup_hostlist_url_treeview">
<property
name="visible">True</property>
@@ -1292,28 +1291,33 @@
<packing>
<property
name="expand">False</property>
<property name="fill">False</property>
+ <property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkImage"
id="GNUNET_setup_transport_tcp_test_success_image">
<property
name="can_focus">False</property>
+ <property name="tooltip_text"
translatable="yes">Configuration works!</property>
<property
name="stock">gtk-ok</property>
</object>
<packing>
<property
name="expand">False</property>
<property name="fill">False</property>
+ <property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkImage"
id="GNUNET_setup_transport_tcp_test_fail_image">
<property
name="can_focus">False</property>
+ <property name="tooltip_text"
translatable="yes">Test failed!</property>
<property
name="stock">gtk-dialog-error</property>
</object>
<packing>
<property
name="expand">False</property>
<property name="fill">False</property>
+ <property name="padding">5</property>
<property name="position">3</property>
</packing>
</child>
@@ -1391,7 +1395,94 @@
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkVBox"
id="GNUNET_setup_transport_udp_test_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkHBox"
id="GNUNET_setup_transport_udp_test_hbox">
+ <property
name="visible">True</property>
+ <property
name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property
name="visible">True</property>
+ <property
name="can_focus">False</property>
+ </object>
+ <packing>
+ <property
name="expand">True</property>
+ <property
name="fill">True</property>
+ <property
name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_setup_transport_udp_test_button">
+ <property name="label"
translatable="yes">Test configuration</property>
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property
name="receives_default">True</property>
+ <property
name="use_action_appearance">False</property>
+ <signal name="clicked"
handler="GNUNET_setup_transport_udp_test_button_clicked_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ <property
name="padding">5</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage"
id="GNUNET_setup_transport_udp_test_success_image">
+ <property
name="can_focus">False</property>
+ <property name="tooltip_text"
translatable="yes">Configuration works!</property>
+ <property
name="stock">gtk-ok</property>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ <property
name="padding">5</property>
+ <property
name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage"
id="GNUNET_setup_transport_udp_test_fail_image">
+ <property
name="can_focus">False</property>
+ <property name="tooltip_text"
translatable="yes">Test failed!</property>
+ <property
name="stock">gtk-dialog-error</property>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ <property
name="padding">5</property>
+ <property
name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property
name="visible">True</property>
+ <property
name="can_focus">False</property>
+ </object>
+ <packing>
+ <property
name="expand">True</property>
+ <property
name="fill">True</property>
+ <property
name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
@@ -3441,7 +3532,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
- <property
name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport"
id="GNUNET_setup_vpn_viewport">
Modified: gnunet-setup/src/Makefile.am
===================================================================
--- gnunet-setup/src/Makefile.am 2011-07-07 13:45:31 UTC (rev 15871)
+++ gnunet-setup/src/Makefile.am 2011-07-07 14:15:20 UTC (rev 15872)
@@ -12,6 +12,7 @@
gnunet-setup-options.c gnunet-setup-options.h \
gnunet-setup-transport-plugins.c \
gnunet-setup-transport-tcp.c \
+ gnunet-setup-transport-udp.c \
gnunet-setup-transport.c \
gnunet-setup-datastore-plugins.c \
gnunet-setup-datastore-config.c \
Modified: gnunet-setup/src/gnunet-setup-transport-tcp.c
===================================================================
--- gnunet-setup/src/gnunet-setup-transport-tcp.c 2011-07-07 13:45:31 UTC
(rev 15871)
+++ gnunet-setup/src/gnunet-setup-transport-tcp.c 2011-07-07 14:15:20 UTC
(rev 15872)
@@ -24,6 +24,7 @@
* @author Christian Grothoff
*/
#include "gnunet-setup.h"
+#include <gnunet/gnunet_resolver_service.h>
#include <gnunet/gnunet_nat_lib.h>
/**
@@ -56,7 +57,6 @@
int *ok = cls;
*ok = success;
-
GNUNET_SCHEDULER_cancel (tsk);
tsk = GNUNET_SCHEDULER_NO_TASK;
GNUNET_NAT_test_stop (tst);
@@ -76,7 +76,8 @@
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
int *ok = cls;
-
+
+ GNUNET_assert (NULL != tst);
*ok = GNUNET_NO;
tsk = GNUNET_SCHEDULER_NO_TASK;
GNUNET_NAT_test_stop (tst);
@@ -115,15 +116,20 @@
"ADVERTISED_PORT",
&adv_port))
adv_port = bnd_port;
- tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &fail_timeout,
- ok);
tst = GNUNET_NAT_test_start (cfg,
GNUNET_YES,
(uint16_t) bnd_port,
(uint16_t) adv_port,
&result_callback,
ok);
+ if (NULL == tst)
+ {
+ *ok = GNUNET_SYSERR;
+ return;
+ }
+ tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &fail_timeout,
+ ok);
}
/**
@@ -137,11 +143,8 @@
int ok;
struct GNUNET_OS_Process *resolver;
- if (NULL != tst)
- {
- GNUNET_NAT_test_stop (tst);
- tst = NULL;
- }
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
+ GNUNET_assert (NULL == tst);
w = GTK_WIDGET (gtk_builder_get_object (builder,
"GNUNET_setup_transport_tcp_test_success_image"));
gtk_widget_hide (w);
Copied: gnunet-setup/src/gnunet-setup-transport-udp.c (from rev 15869,
gnunet-setup/src/gnunet-setup-transport-tcp.c)
===================================================================
--- gnunet-setup/src/gnunet-setup-transport-udp.c
(rev 0)
+++ gnunet-setup/src/gnunet-setup-transport-udp.c 2011-07-07 14:15:20 UTC
(rev 15872)
@@ -0,0 +1,181 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010, 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/gnunet-setup-transport-udp.c
+ * @brief support for UDP configuration
+ * @author Christian Grothoff
+ */
+#include "gnunet-setup.h"
+#include <gnunet/gnunet_resolver_service.h>
+#include <gnunet/gnunet_nat_lib.h>
+
+/**
+ * How long do we wait for the NAT test to report success?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+
+/**
+ * Handle to the active NAT test.
+ */
+static struct GNUNET_NAT_Test *tst;
+
+/**
+ * Task identifier for the timeout.
+ */
+static GNUNET_SCHEDULER_TaskIdentifier tsk;
+
+
+/**
+ * Function called by NAT on success.
+ * Clean up and update GUI (with success).
+ *
+ * @param cls closure (unused)
+ * @param success currently always GNUNET_OK
+ */
+static void
+result_callback (void *cls,
+ int success)
+{
+ int *ok = cls;
+
+ *ok = success;
+ GNUNET_SCHEDULER_cancel (tsk);
+ tsk = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_NAT_test_stop (tst);
+ tst = NULL;
+}
+
+
+/**
+ * Function called if NAT failed to confirm success.
+ * Clean up and update GUI (with failure).
+ *
+ * @param cls closure (unused)
+ * @param tc scheduler callback
+ */
+static void
+fail_timeout (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ int *ok = cls;
+
+ *ok = GNUNET_NO;
+ tsk = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_NAT_test_stop (tst);
+ tst = NULL;
+}
+
+
+/**
+ * Main function for the NAT test.
+ *
+ * @param cls the 'int*' for the result
+ * @param tc scheduler context
+ */
+static void
+test (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ int *ok = cls;
+ unsigned long long bnd_port;
+ unsigned long long adv_port;
+
+ GNUNET_assert (NULL != cfg);
+ GNUNET_RESOLVER_connect (cfg);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "transport-udp",
+ "PORT",
+ &bnd_port))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "transport-udp",
+ "ADVERTISED_PORT",
+ &adv_port))
+ adv_port = bnd_port;
+ tst = GNUNET_NAT_test_start (cfg,
+ GNUNET_NO,
+ (uint16_t) bnd_port,
+ (uint16_t) adv_port,
+ &result_callback,
+ ok);
+ if (NULL == tst)
+ {
+ *ok = GNUNET_SYSERR;
+ return;
+ }
+ tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &fail_timeout,
+ ok);
+}
+
+/**
+ * Function called whenever the user wants to test the
+ * UDP configuration.
+ */
+void
+GNUNET_setup_transport_udp_test_button_clicked_cb ()
+{
+ GtkWidget *w;
+ int ok;
+ struct GNUNET_OS_Process *resolver;
+
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tsk);
+ GNUNET_assert (NULL == tst);
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_udp_test_success_image"));
+ gtk_widget_hide (w);
+ resolver = GNUNET_OS_start_process (NULL, NULL,
+ "gnunet-service-resolver",
+ "gnunet-service-resolver", NULL);
+ ok = GNUNET_NO;
+ GNUNET_SCHEDULER_run (&test, &ok);
+ if (NULL != resolver)
+ {
+ GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
+ GNUNET_OS_process_close (resolver);
+ }
+ if (GNUNET_YES != ok)
+ {
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_udp_test_fail_image"));
+ gtk_widget_show (w);
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_udp_test_success_image"));
+ gtk_widget_hide (w);
+ }
+ else
+ {
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_udp_test_fail_image"));
+ gtk_widget_hide (w);
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_udp_test_success_image"));
+ gtk_widget_show (w);
+ }
+}
+
+
+/* end of gnunet-setup-transport-udp.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15872 - in gnunet-setup: contrib src,
gnunet <=