gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36626 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r36626 - gnunet/src/transport
Date: Thu, 29 Oct 2015 15:32:42 +0100

Author: grothoff
Date: 2015-10-29 15:32:42 +0100 (Thu, 29 Oct 2015)
New Revision: 36626

Modified:
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/gnunet-transport-profiler.c
Log:
preparations for replacing try_connect from gnunet-transport-profiler.

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2015-10-29 14:27:51 UTC (rev 36625)
+++ gnunet/src/transport/Makefile.am    2015-10-29 14:32:42 UTC (rev 36626)
@@ -228,6 +228,7 @@
   libgnunettransport.la \
   $(top_builddir)/src/nat/libgnunetnat.la \
   $(top_builddir)/src/hello/libgnunethello.la \
+  $(top_builddir)/src/ats/libgnunetats.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
 

Modified: gnunet/src/transport/gnunet-transport-profiler.c
===================================================================
--- gnunet/src/transport/gnunet-transport-profiler.c    2015-10-29 14:27:51 UTC 
(rev 36625)
+++ gnunet/src/transport/gnunet-transport-profiler.c    2015-10-29 14:32:42 UTC 
(rev 36626)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- Copyright (C) 2011-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2011-2015 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
@@ -19,17 +19,18 @@
  */
 
 /**
- * @file src/transport/gnunet-transport.c
- * @brief Tool to help configure, measure and control the transport subsystem.
+ * @file src/transport/gnunet-transport-profiler.c
+ * @brief Tool to help benchmark the transport subsystem.
  * @author Christian Grothoff
  * @author Nathan Evans
  *
- * This utility can be used to test if a transport mechanism for
- * GNUnet is properly configured.
+ * This utility can be used to benchmark a transport mechanism for
+ * GNUnet.
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
+#include "gnunet_ats_service.h"
 #include "gnunet_transport_service.h"
 
 struct Iteration
@@ -109,6 +110,11 @@
 static struct GNUNET_TRANSPORT_Handle *handle;
 
 /**
+ * Handle to ATS service.
+ */
+static struct GNUNET_ATS_ConnectivityHandle *ats;
+
+/**
  * Configuration handle
  */
 static struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -116,11 +122,11 @@
 /**
  * Try_connect handle
  */
-struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
+static struct GNUNET_TRANSPORT_TryConnectHandle *tc_handle;
 
+static struct Iteration *ihead;
 
-struct Iteration *ihead;
-struct Iteration *itail;
+static struct Iteration *itail;
 
 /**
  * Global return value (0 success).
@@ -131,7 +137,7 @@
  */
 static struct GNUNET_TRANSPORT_TransmitHandle *th;
 
-struct GNUNET_TRANSPORT_Blacklist *bl_handle;
+static struct GNUNET_TRANSPORT_Blacklist *bl_handle;
 
 /**
  * Identity of the peer we transmit to / connect to.
@@ -149,6 +155,7 @@
  */
 static int verbosity;
 
+
 /**
  * Task run in monitor mode when the user presses CTRL-C to abort.
  * Stops monitoring activity.
@@ -186,7 +193,11 @@
     GNUNET_TRANSPORT_blacklist_cancel (bl_handle);
     bl_handle = NULL;
   }
-
+  if (NULL != ats)
+  {
+    GNUNET_ATS_connectivity_done (ats);
+    ats = NULL;
+  }
   if (NULL != handle)
   {
     GNUNET_TRANSPORT_disconnect (handle);
@@ -283,6 +294,7 @@
 static void
 iteration_done ();
 
+
 /**
  * Function called to notify a client about the socket
  * begin ready to queue more data.  @a buf will be
@@ -360,6 +372,7 @@
   }
 }
 
+
 static void
 iteration_done ()
 {
@@ -382,7 +395,6 @@
 }
 
 
-
 /**
  * Function called to notify transport users that another
  * peer connected to us.
@@ -437,6 +449,7 @@
   }
 }
 
+
 /**
  * Function called by the transport for each received message.
  *
@@ -463,7 +476,6 @@
 }
 
 
-
 static void
 try_connect_cb (void *cls,
                 const int result)
@@ -498,6 +510,7 @@
   }
 }
 
+
 static int
 blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
@@ -543,14 +556,14 @@
     FPRINTF (stderr, _("No peer identity given\n"));
     return;
   }
-  if ((GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen 
(cpid),
-              &pid.public_key)))
+  if ((GNUNET_OK !=
+       GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
+                                                   &pid.public_key)))
   {
     FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
     return;
   }
 
-
   if (1 == benchmark_send)
   {
     if (verbosity > 0)
@@ -570,18 +583,33 @@
     return;
   }
 
-  handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, &notify_receive,
-      &notify_connect, &notify_disconnect);
+  ats = GNUNET_ATS_connectivity_init (cfg);
+  if (NULL == ats)
+  {
+    FPRINTF (stderr, "%s", _("Failed to connect to ATS service\n"));
+    ret = 1;
+    return;
+  }
 
+  handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
+                                     &notify_receive,
+                                     &notify_connect,
+                                     &notify_disconnect);
   if (NULL == handle)
   {
     FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
+    GNUNET_ATS_connectivity_done (ats);
+    ats = NULL;
     ret = 1;
     return;
   }
 
-  bl_handle = GNUNET_TRANSPORT_blacklist (cfg, blacklist_cb, NULL);
-  tc_handle = GNUNET_TRANSPORT_try_connect(handle, &pid, try_connect_cb, NULL);
+  bl_handle = GNUNET_TRANSPORT_blacklist (cfg,
+                                          &blacklist_cb,
+                                          NULL);
+  tc_handle = GNUNET_TRANSPORT_try_connect (handle, &pid,
+                                            &try_connect_cb,
+                                            NULL);
 
   end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                       &shutdown_task,
@@ -608,6 +636,7 @@
       &testservice_task, (void *) cfg);
 }
 
+
 int
 main (int argc, char * const *argv)
 {
@@ -655,4 +684,4 @@
   return 1;
 }
 
-/* end of gnunet-transport.c */
+/* end of gnunet-transport-profiler.c */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]