[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15862 - gnunet-setup/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15862 - gnunet-setup/src |
Date: |
Thu, 7 Jul 2011 10:23:46 +0200 |
Author: grothoff
Date: 2011-07-07 10:23:46 +0200 (Thu, 07 Jul 2011)
New Revision: 15862
Modified:
gnunet-setup/src/gnunet-setup-transport-tcp.c
Log:
autotest
Modified: gnunet-setup/src/gnunet-setup-transport-tcp.c
===================================================================
--- gnunet-setup/src/gnunet-setup-transport-tcp.c 2011-07-06 15:48:30 UTC
(rev 15861)
+++ gnunet-setup/src/gnunet-setup-transport-tcp.c 2011-07-07 08:23:46 UTC
(rev 15862)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2010 Christian Grothoff (and other contributing authors)
+ (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
@@ -25,13 +25,132 @@
*/
#include "gnunet-setup.h"
+/**
+ * How long do we wait for the NAT test to report success?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+/**
+ * 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)
+{
+ GtkWidget *w;
+
+ if (GNUNET_SCHEDULER_NO_TASK != tsk)
+ {
+ GNUNET_SCHEDULER_cancel (tsk);
+ tsk = GNUNET_SCHEDULER_NO_TASK;
+ }
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_success_image"));
+ gtk_widget_show (w);
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_fail_image"));
+ gtk_widget_hide (w);
+ 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)
+{
+ GtkWidget *w;
+
+ tsk = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_NAT_test_stop (tst);
+ tst = NULL;
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_success_image"));
+ gtk_widget_hide (w);
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_fail_image"));
+ gtk_widget_show (w);
+}
+
+
+/**
+ * Function called whenever the user wants to test the
+ * TCP configuration.
+ */
void
GNUNET_setup_transport_tcp_test_button_clicked_cb ()
{
- GNUNET_break (0); /* not implemented */
+ unsigned long long bnd_port;
+ unsigned long long adv_port;
+ GtkWidget *w;
+
+ if (NULL != tst)
+ {
+ GNUNET_NAT_TEST_stop (tst);
+ tst = NULL;
+ }
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_success_image"));
+ gtk_widget_hide (w);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "transport-tcp",
+ "PORT",
+ &bnd_port))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "transport-tcp",
+ "ADVERTISED_PORT",
+ &adv_port))
+ adv_port = bnd_port;
+ tst = GNUNET_NAT_test_start (cfg,
+ GNUNET_YES,
+ (uint16_t) bnd_port,
+ (uint16_t) adv_port,
+ &result_callback,
+ NULL);
+ if (NULL == tst)
+ {
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_fail_image"));
+ gtk_widget_show (w);
+ return;
+ }
+ w = GTK_WIDGET (gtk_builder_get_object (builder,
+
"GNUNET_setup_transport_tcp_test_fail_image"));
+ gtk_widget_hide (w);
+ if (GNUNET_SCHEDULER_NO_TASK != tsk)
+ GNUNET_SCHEDULER_cancel (tsk);
+ tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &fail_timeout,
+ NULL);
}
/* end of gnunet-setup-transport-tcp.c */
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15862 - gnunet-setup/src,
gnunet <=